1
0
forked from Clones/Controlify

Use translations for new UI

This commit is contained in:
isXander
2023-05-29 07:36:21 +01:00
parent b8c38cefc2
commit 086bc0a0b5
4 changed files with 48 additions and 38 deletions

View File

@ -44,7 +44,7 @@ public class ControllerCarouselScreen extends Screen {
private Animator animator;
private ControllerCarouselScreen(Screen parent) {
super(Component.literal("Controllers"));
super(Component.translatable("controlify.gui.carousel.title"));
this.parent = parent;
}
@ -77,7 +77,7 @@ public class ControllerCarouselScreen extends Screen {
GridLayout grid = new GridLayout().columnSpacing(10);
GridLayout.RowHelper rowHelper = grid.createRowHelper(2);
rowHelper.addChild(Button.builder(Component.literal("Global Settings"), btn -> minecraft.setScreen(GlobalSettingsGui.createGlobalSettingsScreen(this))).build());
rowHelper.addChild(Button.builder(Component.translatable("controlify.gui.global_settings.title"), btn -> minecraft.setScreen(GlobalSettingsGui.createGlobalSettingsScreen(this))).build());
rowHelper.addChild(Button.builder(CommonComponents.GUI_DONE, btn -> this.onClose()).build());
grid.visitWidgets(widget -> {
widget.setTabOrderGroup(1);
@ -124,7 +124,7 @@ public class ControllerCarouselScreen extends Screen {
}
if (carouselEntries.isEmpty()) {
graphics.drawCenteredString(font, Component.literal("No controllers connected."), this.width / 2, (this.height - 36) / 2 - 10, 0xFFAAAAAA);
graphics.drawCenteredString(font, Component.translatable("controlify.gui.carousel.no_controllers"), this.width / 2, (this.height - 36) / 2 - 10, 0xFFAAAAAA);
}
super.render(graphics, mouseX, mouseY, delta);
@ -187,6 +187,7 @@ public class ControllerCarouselScreen extends Screen {
private Button useControllerButton;
private Button settingsButton;
private ImmutableList<? extends GuiEventListener> children;
private int overlayColor = 0x90000000;
@ -197,8 +198,9 @@ public class ControllerCarouselScreen extends Screen {
this.controller = controller;
this.hasNickname = this.controller.config().customName != null;
this.settingsButton = Button.builder(Component.literal("Settings"), btn -> minecraft.setScreen(ControllerConfigGui.generateConfigScreen(ControllerCarouselScreen.this, controller))).width(getWidth() / 2 - 4).build();
this.useControllerButton = Button.builder(Component.literal("Use"), btn -> Controlify.instance().setCurrentController(controller)).width(settingsButton.getWidth()).build();
this.settingsButton = Button.builder(Component.translatable("controlify.gui.carousel.entry.settings"), btn -> minecraft.setScreen(ControllerConfigGui.generateConfigScreen(ControllerCarouselScreen.this, controller))).width(getWidth() / 2 - 4).build();
this.useControllerButton = Button.builder(Component.translatable("controlify.gui.carousel.entry.use"), btn -> Controlify.instance().setCurrentController(controller)).width(settingsButton.getWidth()).build();
this.children = ImmutableList.of(settingsButton, useControllerButton);
}
@Override
@ -222,7 +224,7 @@ public class ControllerCarouselScreen extends Screen {
if (Controlify.instance().getCurrentController().orElse(null) == controller) {
graphics.blit(CHECKMARK, x + 4, y + 4, 0f, 0f, 9, 8, 9, 8);
graphics.drawString(font, Component.literal("Currently in use").withStyle(ChatFormatting.GREEN), x + 17, y + 4, -1);
graphics.drawString(font, Component.translatable("controlify.gui.carousel.entry.in_use").withStyle(ChatFormatting.GREEN), x + 17, y + 4, -1);
}
int iconWidth = width - 6;
@ -266,7 +268,7 @@ public class ControllerCarouselScreen extends Screen {
@Override
public List<? extends GuiEventListener> children() {
return ImmutableList.of(useControllerButton, settingsButton);
return children;
}
public void setX(float x) {

View File

@ -50,7 +50,7 @@ public class ControllerConfigGui {
private static ConfigCategory createBasicCategory(Controller<?, ?> controller, ControllerConfig def, ControllerConfig config) {
return ConfigCategory.createBuilder()
.name(Component.literal("Basic"))
.name(Component.translatable("controlify.gui.config.category.basic"))
.option(Option.<String>createBuilder()
.name(Component.translatable("controlify.gui.custom_name"))
.description(OptionDescription.of(Component.translatable("controlify.gui.custom_name.tooltip")))
@ -66,7 +66,7 @@ public class ControllerConfigGui {
private static OptionGroup makeSensitivityGroup(Controller<?, ?> controller, ControllerConfig def, ControllerConfig config) {
return OptionGroup.createBuilder()
.name(Component.literal("Sensitivity"))
.name(Component.translatable("controlify.gui.config.group.sensitivity"))
.option(Option.<Float>createBuilder()
.name(Component.translatable("controlify.gui.horizontal_look_sensitivity"))
.description(OptionDescription.createBuilder()
@ -110,7 +110,7 @@ public class ControllerConfigGui {
Function<Boolean, Component> holdToggleFormatter = v -> Component.translatable("controlify.gui.format.hold_toggle." + (v ? "toggle" : "hold"));
return OptionGroup.createBuilder()
.name(Component.literal("Controls"))
.name(Component.translatable("controlify.gui.config.group.controls"))
.option(Option.<Boolean>createBuilder()
.name(Component.translatable("controlify.gui.toggle_sprint"))
.description(OptionDescription.createBuilder()
@ -145,7 +145,7 @@ public class ControllerConfigGui {
private static OptionGroup makeAccessibilityGroup(Controller<?, ?> controller, ControllerConfig def, ControllerConfig config) {
return OptionGroup.createBuilder()
.name(Component.literal("Accessibility"))
.name(Component.translatable("controlify.config.group.accessibility"))
.option(Option.<Boolean>createBuilder()
.name(Component.translatable("controlify.gui.show_ingame_guide"))
.description(OptionDescription.createBuilder()
@ -178,7 +178,7 @@ public class ControllerConfigGui {
private static OptionGroup makeDeadzoneGroup(Controller<?, ?> controller, ControllerConfig def, ControllerConfig config) {
var group = OptionGroup.createBuilder()
.name(Component.literal("Deadzones"));
.name(Component.translatable("controlify.config.group.deadzones"));
if (controller instanceof GamepadController gamepad) {
var gpCfg = gamepad.config();
var gpCfgDef = gamepad.defaultConfig();
@ -269,7 +269,7 @@ public class ControllerConfigGui {
private static ConfigCategory createAdvancedCategory(Controller<?, ?> controller) {
return ConfigCategory.createBuilder()
.name(Component.literal("Advanced"))
.name(Component.translatable("controlify.config.category.advanced"))
.group(makeVibrationGroup(controller))
.group(makeGyroGroup(controller))
.build();

View File

@ -16,9 +16,9 @@ public class GlobalSettingsGui {
public static Screen createGlobalSettingsScreen(Screen parent) {
var globalSettings = Controlify.instance().config().globalSettings();
return YetAnotherConfigLib.createBuilder()
.title(Component.literal("Controlify Global Settings"))
.title(Component.translatable("controlify.gui.global_settings.title"))
.category(ConfigCategory.createBuilder()
.name(Component.literal("Global Settings"))
.name(Component.translatable("controlify.gui.global_settings.title"))
.option(Option.<Boolean>createBuilder()
.name(Component.translatable("controlify.gui.load_vibration_natives"))
.description(OptionDescription.createBuilder()