Skip to content

Commit

Permalink
UDOC-0 - Add the ability to translate many MojangFix multiplayer scre…
Browse files Browse the repository at this point in the history
…en strings
  • Loading branch information
telvarost committed May 5, 2024
1 parent 2bb06eb commit 3fe4bad
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Add ability to hide server IPs
- Update to StationAPI alpha2 and add language support
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ dependencies {
implementation "org.slf4j:slf4j-api:1.8.0-beta4"
implementation "org.apache.logging.log4j:log4j-slf4j18-impl:2.16.0"
implementation "blue.endless:jankson:1.2.1"
implementation("io.github.llamalad7:mixinextras-fabric:${project.properties["mixinextras_version"]}")

def lombok = "org.projectlombok:lombok:1.18.22"
compileOnly lombok
Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ yarn_mappings=b1.7.3+build.8
loader_version=0.14.24-babric.1

# Mod Properties
mod_version = 1.4.0
mod_version = 2.0.0
maven_group = pl.telvarost
archives_base_name = mojangfixstationapi

# Dependencies
stapi_version=2.0-alpha.1.1
stapi_version=2.0-alpha.2
mixinextras_version = 0.2.1

# Extra Dependencies
gcapi_version=1.2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected void mouseClicked(int mouseX, int mouseY, int button) {

public void render(int mouseX, int mouseY, float delta) {
this.renderBackground();
this.drawCenteredTextWithShadow(this.textRenderer, "Direct connect", this.width / 2, this.height / 4 - 60 + 20, 16777215);
this.drawCenteredTextWithShadow(this.textRenderer, TranslationStorage.getInstance().get("multiplayer.mojangfixstationapi.directConnect"), this.width / 2, this.height / 4 - 60 + 20, 16777215);
this.drawCenteredTextWithShadow(this.textRenderer, TranslationStorage.getInstance().get("multiplayer.ipinfo"), this.width / 2, this.height / 4 - 60 + 60 + 36, 10526880);
this.addressField.render();
super.render(mouseX, mouseY, delta);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public void tick() {

public void init() {
Keyboard.enableRepeatEvents(true);
this.buttons.add(this.button = new CallbackButtonWidget(this.width / 2 - 100, this.height / 4 + 96 + 12, this.server == null ? "Add" : "Edit", button -> {
TranslationStorage translations = TranslationStorage.getInstance();
this.buttons.add(this.button = new CallbackButtonWidget(this.width / 2 - 100, this.height / 4 + 96 + 12, this.server == null ? translations.get("multiplayer.mojangfixstationapi.addServer") : translations.get("multiplayer.mojangfixstationapi.edit"), button -> {
if (this.server != null) {
this.server.setName(this.nameTextField.getText());
this.server.setIp(this.ipTextField.getText());
Expand Down Expand Up @@ -89,9 +90,10 @@ protected void mouseClicked(int mouseX, int mouseY, int varbutton) {

public void render(int mouseX, int mouseY, float delta) {
this.renderBackground();
this.drawStringWithShadow(this.textRenderer, (this.server == null ? "Add" : "Edit") + " Server", this.width / 2, 20, 16777215);
this.drawStringWithShadow(this.textRenderer, "Server name", this.width / 2 - 100, 47, 10526880);
this.drawStringWithShadow(this.textRenderer, "Server IP", this.width / 2 - 100, 94, 10526880);
TranslationStorage translations = TranslationStorage.getInstance();
this.drawCenteredTextWithShadow(this.textRenderer, (this.server == null ? translations.get("multiplayer.mojangfixstationapi.addServer") : translations.get("multiplayer.mojangfixstationapi.editServerInfo")), this.width / 2, 20, 16777215);
this.drawStringWithShadow(this.textRenderer, translations.get("multiplayer.mojangfixstationapi.serverName"), this.width / 2 - 100, 47, 10526880);
this.drawStringWithShadow(this.textRenderer, translations.get("multiplayer.mojangfixstationapi.serverAddress"), this.width / 2 - 100, 94, 10526880);
this.nameTextField.render();
this.ipTextField.render();
super.render(mouseX, mouseY, delta);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,22 @@ private void loadServers() {

public void initButtons() {
TranslationStorage translationStorage = TranslationStorage.getInstance();
this.buttons.add(this.buttonConnect = new CallbackButtonWidget(this.width / 2 - 150 - 4, this.height - 52, 100, 20, "Connect", button -> {
this.buttons.add(this.buttonConnect = new CallbackButtonWidget(this.width / 2 - 150 - 4, this.height - 52, 100, 20, translationStorage.get("multiplayer.mojangfixstationapi.connect"), button -> {
this.joinServer(this.selectedServer);
}));
this.buttons.add(new CallbackButtonWidget(this.width / 2 - 50, this.height - 52, 100, 20, "Direct connect", button -> {
this.buttons.add(new CallbackButtonWidget(this.width / 2 - 50, this.height - 52, 100, 20, translationStorage.get("multiplayer.mojangfixstationapi.directConnect"), button -> {
this.minecraft.setScreen(new DirectConnectScreen(this));
}));
this.buttons.add(new CallbackButtonWidget(this.width / 2 + 50 + 4, this.height - 52, 100, 20, "Add server", button -> {
this.buttons.add(new CallbackButtonWidget(this.width / 2 + 50 + 4, this.height - 52, 100, 20, translationStorage.get("multiplayer.mojangfixstationapi.addServer"), button -> {
this.minecraft.setScreen(new EditServerScreen(this, null));
}));
this.buttons.add(this.buttonEdit = new CallbackButtonWidget(this.width / 2 - 154, this.height - 28, 70, 20, "Edit", button -> {
this.buttons.add(this.buttonEdit = new CallbackButtonWidget(this.width / 2 - 154, this.height - 28, 70, 20, translationStorage.get("multiplayer.mojangfixstationapi.edit"), button -> {
this.minecraft.setScreen(new EditServerScreen(this, this.selectedServer));
}));
this.buttons.add(this.buttonDelete = new CallbackButtonWidget(this.width / 2 - 74, this.height - 28, 70, 20, translationStorage.get("selectWorld.delete"), button -> {
TranslationStorage translate = TranslationStorage.getInstance();
this.minecraft.setScreen(new CallbackConfirmScreen(this,
translate.get("Are you sure you want to delete this server?"),
translationStorage.get("multiplayer.mojangfixstationapi.deleteConfirm1"),
"'" + this.selectedServer.getName() + "' " + translate.get("selectWorld.deleteWarning"),
translate.get("selectWorld.deleteButton"),
translate.get("gui.cancel"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected void renderEntry(int index, int x, int y, int l, Tessellator arg) {
this.parent.drawStringWithShadow(this.parent.getFontRenderer(), server.getName(), x + 2, y + 1, 0xffffff);
if (Config.config.disableServerListIpAddresses) {
TranslationStorage translations = TranslationStorage.getInstance();
String hideIp = "(" + translations.get("serverList.mojangfixstationapi:hidden") + ")";
String hideIp = "(" + translations.get("multiplayer.mojangfixstationapi.hidden") + ")";
this.parent.drawStringWithShadow(this.parent.getFontRenderer(), hideIp, x + 2, y + 12, 0x808080);
} else {
this.parent.drawStringWithShadow(this.parent.getFontRenderer(), server.getIp(), x + 2, y + 12, 0x808080);
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
serverList.hidden=Hidden
multiplayer.@.hidden=Hidden

multiplayer.@.title=Play Multiplayer
multiplayer.@.edit=Edit
multiplayer.@.delete=Delete
multiplayer.@.join=Join Server
multiplayer.@.connect=Connect
multiplayer.@.directConnect=Direct Connect
multiplayer.@.addServer=Add Server
multiplayer.@.refresh=Refresh
multiplayer.@.cancel=Cancel

multiplayer.@.deleteConfirm1=Are you sure you want to remove this server?
multiplayer.@.deleteConfirm2=will be lost forever! (A long time!)

multiplayer.@.editServerInfo=Edit Server Info
multiplayer.@.serverName=Server Name
multiplayer.@.serverAddress=Server Address
multiplayer.@.badPing=(no connection)
multiplayer.@.pingTime=ms
multiplayer.@.polling=Polling...

0 comments on commit 3fe4bad

Please sign in to comment.