Fix #1
This commit is contained in:
parent
4d38676db5
commit
deed913001
5 changed files with 28 additions and 25 deletions
|
|
@ -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
|
||||
fabric_version=0.76.1+1.19.3
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ public class ProfilesListWidget extends ElementListWidget<ProfilesListWidget.Ent
|
|||
|
||||
for (File profile : Objects.requireNonNull(profilesDirectory.listFiles())) {
|
||||
String profileName = FilenameUtils.removeExtension(profile.getName());
|
||||
this.addEntry(new ProfilesListWidget.ProfileEntry(Text.of(profileName)));
|
||||
|
||||
// Sodium
|
||||
// This code doesn't work yet
|
||||
|
|
@ -60,16 +61,17 @@ public class ProfilesListWidget extends ElementListWidget<ProfilesListWidget.Ent
|
|||
|
||||
ProfileEntry(final Text profileName) {
|
||||
this.profileName = profileName;
|
||||
this.editButton = new ButtonWidget(0, 0, 75, 20, Text.translatable("gui.options-profiles.edit-profile-text"), (button) -> {
|
||||
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<ProfilesListWidget.Ent
|
|||
Objects.requireNonNull(ProfilesListWidget.this.client.textRenderer);
|
||||
var10000.draw(matrices, profileName, x, (float)(var10004 - 9 / 2), 16777215);
|
||||
|
||||
this.editButton.x = x + 115;
|
||||
this.editButton.y = y;
|
||||
this.editButton.setPos(x + 115, y);
|
||||
this.editButton.render(matrices, mouseX, mouseY, tickDelta);
|
||||
|
||||
this.loadButton.x = x + 190;
|
||||
this.loadButton.y = y;
|
||||
this.loadButton.setPos(x + 190, y);
|
||||
this.loadButton.render(matrices, mouseX, mouseY, tickDelta);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,13 +22,14 @@ public class ProfilesScreen extends Screen {
|
|||
this.addSelectableChild(this.profilesList);
|
||||
|
||||
// Bottom Buttons
|
||||
this.addDrawableChild(new ButtonWidget(this.width / 2 - 155, this.height - 29, 150, 20, Text.translatable("gui.options-profiles.save-current-options"), (button -> {
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue