Skip to content

Commit

Permalink
Finished HudScreen with translation
Browse files Browse the repository at this point in the history
  • Loading branch information
The2019 committed Nov 19, 2023
1 parent d80f991 commit d8e7121
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public ConfigScreen(Screen parent, GameOptions gameOptions) {

@Override
protected void init() {
this.addDrawable(new TextWidget(x, 20, 100, 20, Text.translatable("newbase.configscreen.name").formatted(Formatting.BOLD), textRenderer)).alignLeft();
this.addDrawable(new TextWidget(x, 20, 100, 20, Text.translatable("newbase.configscreen.name").formatted(Formatting.BOLD), textRenderer)).alignLeft().setTooltip(Tooltip.of(Text.translatable("newbase.configscreen.nametooltip")));

//Hud
this.addDrawable(new TextWidget(x, y, 100, 20, Text.translatable("newbase.configscreen.hud"), mc.textRenderer).alignLeft());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
import net.minecraft.client.option.GameOptions;
import net.minecraft.text.Text;

import static net.The2019.NewBase.features.config.ModuleStates.*;

public class HudScreen extends Screen {
private final Screen parent;
private final GameOptions settings;
private static int x = 20;
private static int y = 50;
private static final MinecraftClient mc = MinecraftClient.getInstance();
private static Text coordinatesToggle = Text.translatable("newbase.hudscreen.enabled");
private static Text biomeToggle = Text.translatable("newbase.hudscreen.enabled");
private static Text fpsToggle = Text.translatable("newbase.hudscreen.enabled");

public HudScreen(Screen parent, GameOptions settings) {
super(Text.translatable("newbase.hudscreen.name"));
Expand All @@ -28,13 +32,32 @@ protected void init() {

this.addDrawableChild(new ButtonWidget.Builder(Text.translatable("newbase.hudscreen.back"), button -> {mc.setScreen(new ConfigScreen(mc.currentScreen, mc.options));}).dimensions(17, 20, 100,20).build());

//Hud
//Coordinates
this.addDrawable(new TextWidget(x, y, 500, 20, Text.translatable("newbase.hudscreen.togglecoordinatesdisplay"), mc.textRenderer).alignLeft());
this.addDrawableChild(new ButtonWidget.Builder(coordinatesToggle, button -> {
toggleModule(coordinatesToggle);
coordinatesToggle = toggleModule(coordinatesToggle);
mc.setScreen(new HudScreen(mc.currentScreen, mc.options));
coordinatesDisplayState = !coordinatesDisplayState;

}).tooltip(Tooltip.of(Text.translatable("newbase.hudscreen.tooltip"))).dimensions(this.width - 220, y, 200, 20).build());

//Biome
this.addDrawable(new TextWidget(x, y+30, 500, 20, Text.translatable("newbase.hudscreen.togglebiomedisplay"), mc.textRenderer).alignLeft());
this.addDrawableChild(new ButtonWidget.Builder(biomeToggle, button -> {
biomeToggle = toggleModule(biomeToggle);
mc.setScreen(new HudScreen(mc.currentScreen, mc.options));
biomDisplayState = !biomDisplayState;

}).tooltip(Tooltip.of(Text.translatable("newbase.hudscreen.tooltip"))).dimensions(this.width - 220, y+30, 200, 20).build());

//Fps
this.addDrawable(new TextWidget(x, y+60, 500, 20, Text.translatable("newbase.hudscreen.togglefpsdisplay"), mc.textRenderer).alignLeft());
this.addDrawableChild(new ButtonWidget.Builder(fpsToggle, button -> {
fpsToggle = toggleModule(fpsToggle);
mc.setScreen(new HudScreen(mc.currentScreen, mc.options));
fpsDisplayState = !fpsDisplayState;

}).tooltip(Tooltip.of(Text.translatable("newbase.hudscreen.tooltip"))).dimensions(this.width - 220, y+60, 200, 20).build());
}

private static Text toggleModule(Text toggle){
Expand Down
7 changes: 5 additions & 2 deletions src/client/resources/assets/newbase/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
"newbase.configscreen.render": "Render Configs",
"newbase.configscreen.renderbutton": "Render Configs",
"newbase.configscreen.rendertooltip": "Opens the config menu for the Renderings.",
"newbase.configscreen.nametooltip": "Close with ESC.",

"newbase.hudscreen.name": "Hud Config Screen",
"newbase.hudscreen.back": "§4Back",
"newbase.hudscreen.togglecoordinatesdisplay": "Toggle Coordinates Display",
"newbase.hudscreen.enabled": "§aENABLED",
"newbase.hudscreen.disabled": "§4DISABLED",
"newbase.hudscreen.togglebiomedisplay": "Toggle Biome Display",
"newbase.hudscreen.togglefpsdisplay": "Toggle Fps Display",
"newbase.hudscreen.enabled": "§aEnabled",
"newbase.hudscreen.disabled": "§4Disabled",
"newbase.hudscreen.tooltip": "Press to Toggle",


Expand Down

0 comments on commit d8e7121

Please sign in to comment.