From deed913001970068ea93ef6b6fb12b8587ae0eee Mon Sep 17 00:00:00 2001 From: AxolotlMaid <124442837+AxolotlMaid@users.noreply.github.com> Date: Sat, 29 Apr 2023 13:34:12 +0100 Subject: [PATCH] Fix #1 --- gradle.properties | 6 +++--- .../optionsprofiles/gui/EditProfileScreen.java | 17 +++++++++-------- .../optionsprofiles/gui/ProfilesListWidget.java | 16 ++++++++-------- .../optionsprofiles/gui/ProfilesScreen.java | 9 +++++---- .../mixin/OptionsScreenMixin.java | 5 +++-- 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/gradle.properties b/gradle.properties index 2b234e0..9443bed 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,8 +4,8 @@ org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_version=1.19 -yarn_mappings=1.19+build.4 +minecraft_version=1.19.3 +yarn_mappings=1.19.3+build.5 loader_version=0.14.19 # Mod Properties @@ -14,4 +14,4 @@ maven_group=dev.axolotlmaid.optionsprofiles archives_base_name=options-profiles # Dependencies -fabric_version=0.58.0+1.19 \ No newline at end of file +fabric_version=0.76.1+1.19.3 \ No newline at end of file diff --git a/src/main/java/dev/axolotlmaid/optionsprofiles/gui/EditProfileScreen.java b/src/main/java/dev/axolotlmaid/optionsprofiles/gui/EditProfileScreen.java index 210018c..13e9ffd 100644 --- a/src/main/java/dev/axolotlmaid/optionsprofiles/gui/EditProfileScreen.java +++ b/src/main/java/dev/axolotlmaid/optionsprofiles/gui/EditProfileScreen.java @@ -1,6 +1,7 @@ package dev.axolotlmaid.optionsprofiles.gui; import dev.axolotlmaid.optionsprofiles.Profiles; +import net.minecraft.client.gui.screen.GameModeSelectionScreen; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.TextFieldWidget; @@ -23,24 +24,24 @@ public class EditProfileScreen extends Screen { TextFieldWidget textfield = new TextFieldWidget(textRenderer, this.width / 2 - 102, this.height / 4 + 24, 204, 20, Text.translatable("profile-name-text-field")); this.addDrawableChild(textfield); - this.addDrawableChild(new ButtonWidget(this.width / 2 - 50, this.height / 4 + 50, 100, 20, Text.translatable("gui.options-profiles.update-profile-text"), (button) -> { + this.addDrawableChild(new ButtonWidget.Builder(Text.translatable("gui.options-profiles.update-profile-text"), (button) -> { new Profiles().writeOptionsFileToProfile(profileName.getString()); this.client.setScreen(this.parent); - })); + }).position(this.width / 2 - 50, this.height / 4 + 50).size(100, 20).build()); - this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height - 65, 200, 20, Text.translatable("gui.options-profiles.save-profile-text"), (button) -> { + this.addDrawableChild( new ButtonWidget.Builder(Text.translatable("gui.options-profiles.save-profile-text"), (button) -> { new Profiles().editProfile(profileName.getString(), textfield.getText()); this.client.setScreen(this.parent); - })); + }).position(this.width / 2 - 100, this.height - 65).size(200, 20).build()); - this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height - 40, 200, 20, ScreenTexts.CANCEL, (button) -> { + this.addDrawableChild(new ButtonWidget.Builder(ScreenTexts.CANCEL, (button) -> { this.client.setScreen(this.parent); - })); + }).position(this.width / 2 - 100, this.height - 40).size(200, 20).build()); - this.addDrawableChild(new ButtonWidget(5, this.height - 25, 100, 20, Text.translatable("gui.options-profiles.delete-profile-text"), (button) -> { + this.addDrawableChild(new ButtonWidget.Builder(Text.translatable("gui.options-profiles.delete-profile-text"), (button) -> { new Profiles().deleteProfile(profileName.getString()); this.client.setScreen(this.parent); - })); + }).position(5, this.height - 25).size(100, 20).build()); } public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { diff --git a/src/main/java/dev/axolotlmaid/optionsprofiles/gui/ProfilesListWidget.java b/src/main/java/dev/axolotlmaid/optionsprofiles/gui/ProfilesListWidget.java index a5f1f0a..fcf09ae 100644 --- a/src/main/java/dev/axolotlmaid/optionsprofiles/gui/ProfilesListWidget.java +++ b/src/main/java/dev/axolotlmaid/optionsprofiles/gui/ProfilesListWidget.java @@ -28,6 +28,7 @@ public class ProfilesListWidget extends ElementListWidget { + this.editButton = new ButtonWidget.Builder(Text.translatable("gui.options-profiles.edit-profile-text"), (button) -> { ProfilesListWidget.this.client.setScreen(new EditProfileScreen(parent, profileName)); - }); - this.loadButton = new ButtonWidget(0, 0, 75, 20, Text.translatable("gui.options-profiles.load-profile-text"), (button) -> { + }).position(0, 0).size(75, 20).build(); + + this.loadButton = new ButtonWidget.Builder(Text.translatable("gui.options-profiles.load-profile-text"), (button) -> { new Profiles().overwriteOptionsFile(profileName.getString()); client.options.load(); client.worldRenderer.reload(); client.getSoundManager().reloadSounds(); - }); + }).position(0, 0).size(75, 20).build(); } public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) { @@ -80,12 +82,10 @@ public class ProfilesListWidget extends ElementListWidget { + this.addDrawableChild(new ButtonWidget.Builder(Text.translatable("gui.options-profiles.save-current-options"), (button) -> { new Profiles().createProfile(); this.profilesList.refreshEntries(); - }))); - this.addDrawableChild(new ButtonWidget(this.width / 2 - 155 + 160, this.height - 29, 150, 20, ScreenTexts.DONE, (button) -> { + }).position(this.width / 2 - 155, this.height - 29).size(150, 20).build()); + + this.addDrawableChild(new ButtonWidget.Builder(ScreenTexts.DONE, (button) -> { this.client.setScreen(this.parent); - })); + }).position(this.width / 2 - 155 + 160, this.height - 29).size(150, 20).build()); } public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { diff --git a/src/main/java/dev/axolotlmaid/optionsprofiles/mixin/OptionsScreenMixin.java b/src/main/java/dev/axolotlmaid/optionsprofiles/mixin/OptionsScreenMixin.java index 1b8d8b9..6e4d180 100644 --- a/src/main/java/dev/axolotlmaid/optionsprofiles/mixin/OptionsScreenMixin.java +++ b/src/main/java/dev/axolotlmaid/optionsprofiles/mixin/OptionsScreenMixin.java @@ -6,6 +6,7 @@ import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.option.ControlsOptionsScreen; import net.minecraft.client.gui.screen.option.OptionsScreen; import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.screen.ScreenTexts; import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -21,8 +22,8 @@ public class OptionsScreenMixin extends Screen { @Inject(at = @At("TAIL"), method = "init") private void init(CallbackInfo info) { MinecraftClient minecraft = MinecraftClient.getInstance(); - this.addDrawableChild(new ButtonWidget(5, 5, 100, 20, Text.translatable("gui.options-profiles.profiles-menu-text"), (button -> { + this.addDrawableChild(new ButtonWidget.Builder(Text.translatable("gui.options-profiles.profiles-menu-text"), (button) -> { minecraft.setScreen(new ProfilesScreen(this)); - }))); + }).position(5, 5).size(100, 20).build()); } } \ No newline at end of file