This commit is contained in:
AxolotlMaid 2023-04-29 13:34:12 +01:00
parent 4d38676db5
commit deed913001
5 changed files with 28 additions and 25 deletions

View file

@ -4,8 +4,8 @@ org.gradle.parallel=true
# Fabric Properties # Fabric Properties
# check these on https://fabricmc.net/develop # check these on https://fabricmc.net/develop
minecraft_version=1.19 minecraft_version=1.19.3
yarn_mappings=1.19+build.4 yarn_mappings=1.19.3+build.5
loader_version=0.14.19 loader_version=0.14.19
# Mod Properties # Mod Properties
@ -14,4 +14,4 @@ maven_group=dev.axolotlmaid.optionsprofiles
archives_base_name=options-profiles archives_base_name=options-profiles
# Dependencies # Dependencies
fabric_version=0.58.0+1.19 fabric_version=0.76.1+1.19.3

View file

@ -1,6 +1,7 @@
package dev.axolotlmaid.optionsprofiles.gui; package dev.axolotlmaid.optionsprofiles.gui;
import dev.axolotlmaid.optionsprofiles.Profiles; import dev.axolotlmaid.optionsprofiles.Profiles;
import net.minecraft.client.gui.screen.GameModeSelectionScreen;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.TextFieldWidget; 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")); 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(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()); new Profiles().writeOptionsFileToProfile(profileName.getString());
this.client.setScreen(this.parent); 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()); new Profiles().editProfile(profileName.getString(), textfield.getText());
this.client.setScreen(this.parent); 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); 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()); new Profiles().deleteProfile(profileName.getString());
this.client.setScreen(this.parent); 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) { public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {

View file

@ -28,6 +28,7 @@ public class ProfilesListWidget extends ElementListWidget<ProfilesListWidget.Ent
for (File profile : Objects.requireNonNull(profilesDirectory.listFiles())) { for (File profile : Objects.requireNonNull(profilesDirectory.listFiles())) {
String profileName = FilenameUtils.removeExtension(profile.getName()); String profileName = FilenameUtils.removeExtension(profile.getName());
this.addEntry(new ProfilesListWidget.ProfileEntry(Text.of(profileName)));
// Sodium // Sodium
// This code doesn't work yet // This code doesn't work yet
@ -60,16 +61,17 @@ public class ProfilesListWidget extends ElementListWidget<ProfilesListWidget.Ent
ProfileEntry(final Text profileName) { ProfileEntry(final Text profileName) {
this.profileName = 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)); ProfilesListWidget.this.client.setScreen(new EditProfileScreen(parent, profileName));
}); }).position(0, 0).size(75, 20).build();
this.loadButton = new ButtonWidget(0, 0, 75, 20, Text.translatable("gui.options-profiles.load-profile-text"), (button) -> {
this.loadButton = new ButtonWidget.Builder(Text.translatable("gui.options-profiles.load-profile-text"), (button) -> {
new Profiles().overwriteOptionsFile(profileName.getString()); new Profiles().overwriteOptionsFile(profileName.getString());
client.options.load(); client.options.load();
client.worldRenderer.reload(); client.worldRenderer.reload();
client.getSoundManager().reloadSounds(); 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) { 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); Objects.requireNonNull(ProfilesListWidget.this.client.textRenderer);
var10000.draw(matrices, profileName, x, (float)(var10004 - 9 / 2), 16777215); var10000.draw(matrices, profileName, x, (float)(var10004 - 9 / 2), 16777215);
this.editButton.x = x + 115; this.editButton.setPos(x + 115, y);
this.editButton.y = y;
this.editButton.render(matrices, mouseX, mouseY, tickDelta); this.editButton.render(matrices, mouseX, mouseY, tickDelta);
this.loadButton.x = x + 190; this.loadButton.setPos(x + 190, y);
this.loadButton.y = y;
this.loadButton.render(matrices, mouseX, mouseY, tickDelta); this.loadButton.render(matrices, mouseX, mouseY, tickDelta);
} }

View file

@ -22,13 +22,14 @@ public class ProfilesScreen extends Screen {
this.addSelectableChild(this.profilesList); this.addSelectableChild(this.profilesList);
// Bottom Buttons // 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(); new Profiles().createProfile();
this.profilesList.refreshEntries(); this.profilesList.refreshEntries();
}))); }).position(this.width / 2 - 155, this.height - 29).size(150, 20).build());
this.addDrawableChild(new ButtonWidget(this.width / 2 - 155 + 160, this.height - 29, 150, 20, ScreenTexts.DONE, (button) -> {
this.addDrawableChild(new ButtonWidget.Builder(ScreenTexts.DONE, (button) -> {
this.client.setScreen(this.parent); 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) { public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {

View file

@ -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.ControlsOptionsScreen;
import net.minecraft.client.gui.screen.option.OptionsScreen; import net.minecraft.client.gui.screen.option.OptionsScreen;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
@ -21,8 +22,8 @@ public class OptionsScreenMixin extends Screen {
@Inject(at = @At("TAIL"), method = "init") @Inject(at = @At("TAIL"), method = "init")
private void init(CallbackInfo info) { private void init(CallbackInfo info) {
MinecraftClient minecraft = MinecraftClient.getInstance(); 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)); minecraft.setScreen(new ProfilesScreen(this));
}))); }).position(5, 5).size(100, 20).build());
} }
} }