diff options
| author | inyourwalls <inyourwalls@tutanota.com> | 2024-01-29 00:10:15 -0500 |
|---|---|---|
| committer | inyourwalls <inyourwalls@tutanota.com> | 2024-01-29 00:10:15 -0500 |
| commit | 3f596f5f02bb9dc34e644a04d1d21ba703a0ad1f (patch) | |
| tree | b329a00b1ea6022a71e115972e7a6a11030dd642 | |
| parent | 037db74c048b66e20d62bde7a35e85f579661552 (diff) | |
make the screen look somewhat passable
| -rw-r--r-- | src/main/java/net/inyourwalls/frank/config/ConfigScreen.java | 48 | ||||
| -rw-r--r-- | src/main/resources/assets/frank/lang/en_us.json | 3 |
2 files changed, 36 insertions, 15 deletions
diff --git a/src/main/java/net/inyourwalls/frank/config/ConfigScreen.java b/src/main/java/net/inyourwalls/frank/config/ConfigScreen.java index f074f9a..211dee5 100644 --- a/src/main/java/net/inyourwalls/frank/config/ConfigScreen.java +++ b/src/main/java/net/inyourwalls/frank/config/ConfigScreen.java @@ -5,14 +5,15 @@ import net.inyourwalls.frank.Frank; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.tooltip.Tooltip; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.text.Text; import net.minecraft.util.Identifier; import java.io.IOException; -import java.util.stream.IntStream; +import static net.minecraft.client.gui.widget.ButtonWidget.DEFAULT_WIDTH; import static net.minecraft.client.gui.widget.ButtonWidget.DEFAULT_WIDTH_SMALL; import static net.minecraft.client.gui.widget.ButtonWidget.DEFAULT_HEIGHT; @@ -20,6 +21,8 @@ public class ConfigScreen extends Screen { private static final Identifier FURNACE_UI_TEXTURE = new Identifier("textures/gui/container/furnace.png"); private static final int FURNACE_TEXTURE_WIDTH = 176; private static final int FURNACE_TEXTURE_HEIGHT = 166; + private static final Text DISPLAY_MODE_LABEL = Text.translatable("ui.frank.config.display_mode"); + private static final Text TEXT_COLOUR_LABEL = Text.translatable("ui.frank.config.text_colour"); private final FrankConfig modifiedConfig = new FrankConfig(); private final Screen previousScreen; @@ -32,24 +35,21 @@ public class ConfigScreen extends Screen { @Override public void init() { - int exitButtonY = this.height / 2 + FURNACE_TEXTURE_HEIGHT + 10; - ButtonWidget backButton = ButtonWidget.builder(Text.translatable("gui.back"), thisButton -> { - this.close(); - }) - .size(DEFAULT_WIDTH_SMALL, DEFAULT_HEIGHT) - .position(this.width / 2 - DEFAULT_WIDTH_SMALL, exitButtonY) - .build(); + ButtonWidget backButton = ButtonWidget.builder(Text.translatable("gui.back"), thisButton -> this.close()) + .size(DEFAULT_WIDTH, DEFAULT_HEIGHT) + .position(this.width / 2 - DEFAULT_WIDTH - 4, this.height - 28) + .build(); ButtonWidget saveButton = ButtonWidget.builder(Text.translatable("selectWorld.edit.save"), thisButton -> { try { Frank.saveConfig(modifiedConfig); - Frank.LOGGER.info("Configuration file was successfully saved."); + Frank.LOGGER.debug("Configuration file was successfully saved."); } catch (IOException ex) { Frank.LOGGER.error("Failed to save configuration file", ex); } }) - .size(DEFAULT_WIDTH_SMALL, DEFAULT_HEIGHT) - .position(this.width / 2, exitButtonY) + .size(DEFAULT_WIDTH, DEFAULT_HEIGHT) + .position(this.width / 2 + 4, this.height - 28) .build(); ButtonWidget modeToggleButton = ButtonWidget.builder( @@ -66,16 +66,16 @@ public class ConfigScreen extends Screen { } ) .size(DEFAULT_WIDTH_SMALL, DEFAULT_HEIGHT) - .position(this.width / 2 - DEFAULT_WIDTH_SMALL, 15) + .position(this.width / 2 + 4, 25) .build(); TextFieldWidget colourField = new TextFieldWidget( this.textRenderer, - this.width / 2 - DEFAULT_WIDTH_SMALL, - 35, + this.width / 2 + 4, + 55, DEFAULT_WIDTH_SMALL, DEFAULT_HEIGHT, - Text.translatable("ui.frank.config.text_colour") + TEXT_COLOUR_LABEL ); colourField.setChangedListener(input -> { try { @@ -88,6 +88,8 @@ public class ConfigScreen extends Screen { (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') || (c >= '0' && c <= '9') ) ); + colourField.setText(String.format("%x", modifiedConfig.getTextColour())); + colourField.setTooltip(Tooltip.of(Text.translatable("ui.frank.config.text_colour.tooltip"))); this.addDrawableChild(backButton); this.addDrawableChild(saveButton); @@ -105,6 +107,22 @@ public class ConfigScreen extends Screen { super.render(context, mouseX, mouseY, delta); context.drawCenteredTextWithShadow(this.textRenderer, Text.translatable("ui.frank.config"), this.width / 2, 5, 0xffffff); + int labelX = this.width / 2 - Math.max(this.textRenderer.getWidth(DISPLAY_MODE_LABEL), this.textRenderer.getWidth(TEXT_COLOUR_LABEL)) - 4; + context.drawTextWithShadow( + this.textRenderer, + DISPLAY_MODE_LABEL, + labelX, + 30, + 0xffffff + ); + context.drawTextWithShadow( + this.textRenderer, + TEXT_COLOUR_LABEL, + labelX, + 60, + 0xffffff + ); + int x = (this.width / 2) - (FURNACE_TEXTURE_WIDTH / 2); int y = this.height / 2 - (FURNACE_TEXTURE_HEIGHT / 2); renderPreview(context, x, y); diff --git a/src/main/resources/assets/frank/lang/en_us.json b/src/main/resources/assets/frank/lang/en_us.json index 0a4e82f..1a7471d 100644 --- a/src/main/resources/assets/frank/lang/en_us.json +++ b/src/main/resources/assets/frank/lang/en_us.json @@ -9,6 +9,9 @@ "ui.frank.config.items_smeltable_first": "Items Smeltable First", "ui.frank.config.items_smeltable_only": "Items Smeltable Only", "ui.frank.config.disabled": "Disabled", + "ui.frank.config.display_mode": "Display Mode", + "ui.frank.config.text_colour": "Text Color", + "ui.frank.config.text_colour.tooltip": "Hexadecimal RGB value for the text color.", "frank.matrix": "Matrix" } |
