From 760d6f316cf4817730d72b320fba955719fee901 Mon Sep 17 00:00:00 2001 From: SirSengir Date: Sat, 19 May 2012 12:36:43 +0200 Subject: [PATCH] Added localization support to guis. --- .../builders/GuiBlueprintLibrary.java | 19 ++++++++++-------- .../src/buildcraft/builders/GuiBuilder.java | 10 ++++++---- .../src/buildcraft/builders/GuiFiller.java | 11 ++++++---- .../src/buildcraft/builders/GuiTemplate.java | 8 +++++--- .../buildcraft/core/GuiAdvancedInterface.java | 2 +- .../src/buildcraft/core/GuiBuildCraft.java | 20 +++++++++++++++++++ .../energy/GuiCombustionEngine.java | 9 ++++++--- .../src/buildcraft/energy/GuiSteamEngine.java | 9 ++++++--- .../buildcraft/factory/GuiAutoCrafting.java | 9 ++++++--- .../src/buildcraft/factory/GuiRefinery.java | 6 ++++-- .../buildcraft/silicon/GuiAssemblyTable.java | 7 ++++--- .../buildcraft/transport/GuiDiamondPipe.java | 6 +++--- .../transport/GuiGateInterface.java | 10 +++------- common/lang/buildcraft/en_US.properties | 7 +++++++ 14 files changed, 89 insertions(+), 44 deletions(-) create mode 100644 buildcraft_client/net/minecraft/src/buildcraft/core/GuiBuildCraft.java diff --git a/buildcraft_client/net/minecraft/src/buildcraft/builders/GuiBlueprintLibrary.java b/buildcraft_client/net/minecraft/src/buildcraft/builders/GuiBlueprintLibrary.java index f52a8e71..13dc908b 100644 --- a/buildcraft_client/net/minecraft/src/buildcraft/builders/GuiBlueprintLibrary.java +++ b/buildcraft_client/net/minecraft/src/buildcraft/builders/GuiBlueprintLibrary.java @@ -16,10 +16,12 @@ import net.minecraft.src.GuiContainer; import net.minecraft.src.ModLoader; import net.minecraft.src.buildcraft.core.BptBase; import net.minecraft.src.buildcraft.core.BptPlayerIndex; +import net.minecraft.src.buildcraft.core.GuiBuildCraft; +import net.minecraft.src.forestry.core.utils.StringUtil; import org.lwjgl.opengl.GL11; -public class GuiBlueprintLibrary extends GuiContainer { +public class GuiBlueprintLibrary extends GuiBuildCraft { EntityPlayer player; TileBlueprintLibrary library; @@ -64,21 +66,22 @@ public class GuiBlueprintLibrary extends GuiContainer { controlList.add(nextPageButton); // if (library.owner.equals(player.username)) { - deleteButton = new GuiButton(2, j + 100, k + 114, 25, 20, "Del"); + deleteButton = new GuiButton(2, j + 100, k + 114, 25, 20, StringUtil.localize("gui.del")); controlList.add(deleteButton); - lockButton = new GuiButton(3, j + 127, k + 114, 40, 20, "Lock"); + lockButton = new GuiButton(3, j + 127, k + 114, 40, 20, StringUtil.localize("gui.lock")); controlList.add(lockButton); if (library.locked) - lockButton.displayString = "Unlock"; - else lockButton.displayString = "Lock"; + lockButton.displayString = StringUtil.localize("gui.unlock"); + else lockButton.displayString = StringUtil.localize("gui.lock"); } @Override protected void drawGuiContainerForegroundLayer() { // fontRenderer.drawString(library.owner + "'s Library", 6, 6, 0x404040); - fontRenderer.drawString("Blueprint Library", 6, 6, 0x404040); + String title = StringUtil.localize("tile.libraryBlock"); + fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040); int c = 0; for (BptBase bpt : container.contents) { @@ -165,9 +168,9 @@ public class GuiBlueprintLibrary extends GuiContainer { library.locked = !library.locked; if (library.locked) - lockButton.displayString = "Unlock"; + lockButton.displayString = StringUtil.localize("gui.unlock"); else - lockButton.displayString = "Lock"; + lockButton.displayString = StringUtil.localize("gui.lock"); } else if (deleteButton != null && deleteButton.mousePressed(ModLoader.getMinecraftInstance(), i, j)) if (library.selected != null) { index.deleteBluePrint (library.selected.file.getName()); diff --git a/buildcraft_client/net/minecraft/src/buildcraft/builders/GuiBuilder.java b/buildcraft_client/net/minecraft/src/buildcraft/builders/GuiBuilder.java index b70c28e7..065405b9 100644 --- a/buildcraft_client/net/minecraft/src/buildcraft/builders/GuiBuilder.java +++ b/buildcraft_client/net/minecraft/src/buildcraft/builders/GuiBuilder.java @@ -14,6 +14,7 @@ import java.util.Collection; import net.minecraft.src.IInventory; import net.minecraft.src.ItemStack; import net.minecraft.src.buildcraft.core.GuiAdvancedInterface; +import net.minecraft.src.forestry.core.utils.StringUtil; import org.lwjgl.opengl.GL11; @@ -40,12 +41,13 @@ public class GuiBuilder extends GuiAdvancedInterface { protected void drawGuiContainerForegroundLayer() { super.drawGuiContainerForegroundLayer (); - fontRenderer.drawString("Builder", 73, 12, 0x404040); - fontRenderer.drawString("Building Resources", 8, 60, 0x404040); - fontRenderer.drawString("Inventory", 8, ySize - 97, 0x404040); + String title = StringUtil.localize("tile.builderBlock"); + fontRenderer.drawString(title, getCenteredOffset(title), 12, 0x404040); + fontRenderer.drawString(StringUtil.localize("gui.building.resources"), 8, 60, 0x404040); + fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, ySize - 97, 0x404040); if (builder.isBuildingBlueprint()) - fontRenderer.drawString("Needed", 185, 7, 0x404040); + fontRenderer.drawString(StringUtil.localize("gui.needed"), 185, 7, 0x404040); drawForegroundSelection(); } diff --git a/buildcraft_client/net/minecraft/src/buildcraft/builders/GuiFiller.java b/buildcraft_client/net/minecraft/src/buildcraft/builders/GuiFiller.java index 1b22ec27..69ecc8b3 100644 --- a/buildcraft_client/net/minecraft/src/buildcraft/builders/GuiFiller.java +++ b/buildcraft_client/net/minecraft/src/buildcraft/builders/GuiFiller.java @@ -11,10 +11,12 @@ package net.minecraft.src.buildcraft.builders; import net.minecraft.src.GuiContainer; import net.minecraft.src.IInventory; +import net.minecraft.src.buildcraft.core.GuiBuildCraft; +import net.minecraft.src.forestry.core.utils.StringUtil; import org.lwjgl.opengl.GL11; -public class GuiFiller extends GuiContainer { +public class GuiFiller extends GuiBuildCraft { IInventory playerInventory; TileFiller filler; @@ -29,9 +31,10 @@ public class GuiFiller extends GuiContainer { @Override protected void drawGuiContainerForegroundLayer() { - fontRenderer.drawString("Filler", 75, 6, 0x404040); - fontRenderer.drawString("Filling Resources", 8, 74, 0x404040); - fontRenderer.drawString("Inventory", 8, 142, 0x404040); + String title = StringUtil.localize("tile.fillerBlock"); + fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040); + fontRenderer.drawString(StringUtil.localize("gui.filling.resources"), 8, 74, 0x404040); + fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, 142, 0x404040); if(filler.currentPattern != null) drawForegroundSelection(filler.currentPattern.getName()); diff --git a/buildcraft_client/net/minecraft/src/buildcraft/builders/GuiTemplate.java b/buildcraft_client/net/minecraft/src/buildcraft/builders/GuiTemplate.java index c60e7aef..478aabd3 100644 --- a/buildcraft_client/net/minecraft/src/buildcraft/builders/GuiTemplate.java +++ b/buildcraft_client/net/minecraft/src/buildcraft/builders/GuiTemplate.java @@ -14,10 +14,12 @@ import java.util.Date; import net.minecraft.src.BuildCraftBuilders; import net.minecraft.src.GuiContainer; import net.minecraft.src.IInventory; +import net.minecraft.src.buildcraft.core.GuiBuildCraft; +import net.minecraft.src.forestry.core.utils.StringUtil; import org.lwjgl.opengl.GL11; -public class GuiTemplate extends GuiContainer { +public class GuiTemplate extends GuiBuildCraft { IInventory playerInventory; TileArchitect template; @@ -34,8 +36,8 @@ public class GuiTemplate extends GuiContainer { @Override protected void drawGuiContainerForegroundLayer() { - fontRenderer.drawString(template.getInvName(), 8, 6, 0x404040); - fontRenderer.drawString("Inventory", 8, ySize - 152, 0x404040); + fontRenderer.drawString(template.getInvName(), getCenteredOffset(template.getInvName()), 6, 0x404040); + fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, ySize - 152, 0x404040); if (editMode && ((new Date ()).getTime() / 100) % 8 >= 4) fontRenderer.drawString(template.name + "|", 51, 62, 0x404040); diff --git a/buildcraft_client/net/minecraft/src/buildcraft/core/GuiAdvancedInterface.java b/buildcraft_client/net/minecraft/src/buildcraft/core/GuiAdvancedInterface.java index a7ecaa70..01367ad3 100644 --- a/buildcraft_client/net/minecraft/src/buildcraft/core/GuiAdvancedInterface.java +++ b/buildcraft_client/net/minecraft/src/buildcraft/core/GuiAdvancedInterface.java @@ -8,7 +8,7 @@ import net.minecraft.src.RenderHelper; import org.lwjgl.opengl.GL11; -public abstract class GuiAdvancedInterface extends GuiContainer { +public abstract class GuiAdvancedInterface extends GuiBuildCraft { public abstract class AdvancedSlot { final public int x, y; diff --git a/buildcraft_client/net/minecraft/src/buildcraft/core/GuiBuildCraft.java b/buildcraft_client/net/minecraft/src/buildcraft/core/GuiBuildCraft.java new file mode 100644 index 00000000..36c35a1a --- /dev/null +++ b/buildcraft_client/net/minecraft/src/buildcraft/core/GuiBuildCraft.java @@ -0,0 +1,20 @@ +package net.minecraft.src.buildcraft.core; + +import net.minecraft.src.Container; +import net.minecraft.src.GuiContainer; + +public abstract class GuiBuildCraft extends GuiContainer { + + public GuiBuildCraft(Container par1Container) { + super(par1Container); + } + + protected int getCenteredOffset(String string) { + return getCenteredOffset(string, xSize); + } + protected int getCenteredOffset(String string, int xWidth) { + return (xWidth - fontRenderer.getStringWidth(string)) / 2; + } + + +} diff --git a/buildcraft_client/net/minecraft/src/buildcraft/energy/GuiCombustionEngine.java b/buildcraft_client/net/minecraft/src/buildcraft/energy/GuiCombustionEngine.java index 8dfb0e88..cd1340df 100644 --- a/buildcraft_client/net/minecraft/src/buildcraft/energy/GuiCombustionEngine.java +++ b/buildcraft_client/net/minecraft/src/buildcraft/energy/GuiCombustionEngine.java @@ -13,12 +13,14 @@ import net.minecraft.src.Block; import net.minecraft.src.GuiContainer; import net.minecraft.src.InventoryPlayer; import net.minecraft.src.Item; +import net.minecraft.src.buildcraft.core.GuiBuildCraft; +import net.minecraft.src.forestry.core.utils.StringUtil; import net.minecraft.src.forge.ITextureProvider; import net.minecraft.src.forge.MinecraftForgeClient; import org.lwjgl.opengl.GL11; -public class GuiCombustionEngine extends GuiContainer { +public class GuiCombustionEngine extends GuiBuildCraft { private TileEngine tileEngine; @@ -31,8 +33,9 @@ public class GuiCombustionEngine extends GuiContainer { @Override protected void drawGuiContainerForegroundLayer() { - fontRenderer.drawString("Combustion Engine", 50, 6, 0x404040); - fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); + String title = StringUtil.localize("tile.engineIron"); + fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040); + fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040); } @Override diff --git a/buildcraft_client/net/minecraft/src/buildcraft/energy/GuiSteamEngine.java b/buildcraft_client/net/minecraft/src/buildcraft/energy/GuiSteamEngine.java index 0ec9f291..35e4331c 100644 --- a/buildcraft_client/net/minecraft/src/buildcraft/energy/GuiSteamEngine.java +++ b/buildcraft_client/net/minecraft/src/buildcraft/energy/GuiSteamEngine.java @@ -11,10 +11,12 @@ package net.minecraft.src.buildcraft.energy; import net.minecraft.src.GuiContainer; import net.minecraft.src.InventoryPlayer; +import net.minecraft.src.buildcraft.core.GuiBuildCraft; +import net.minecraft.src.forestry.core.utils.StringUtil; import org.lwjgl.opengl.GL11; -public class GuiSteamEngine extends GuiContainer { +public class GuiSteamEngine extends GuiBuildCraft { private TileEngine tileEngine; @@ -25,8 +27,9 @@ public class GuiSteamEngine extends GuiContainer { @Override protected void drawGuiContainerForegroundLayer() { - fontRenderer.drawString("Steam Engine", 60, 6, 0x404040); - fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); + String title = StringUtil.localize("tile.engineStone"); + fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040); + fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040); } @Override diff --git a/buildcraft_client/net/minecraft/src/buildcraft/factory/GuiAutoCrafting.java b/buildcraft_client/net/minecraft/src/buildcraft/factory/GuiAutoCrafting.java index 8e276166..1a412a4d 100644 --- a/buildcraft_client/net/minecraft/src/buildcraft/factory/GuiAutoCrafting.java +++ b/buildcraft_client/net/minecraft/src/buildcraft/factory/GuiAutoCrafting.java @@ -12,10 +12,12 @@ package net.minecraft.src.buildcraft.factory; import net.minecraft.src.GuiContainer; import net.minecraft.src.InventoryPlayer; import net.minecraft.src.World; +import net.minecraft.src.buildcraft.core.GuiBuildCraft; +import net.minecraft.src.forestry.core.utils.StringUtil; import org.lwjgl.opengl.GL11; -public class GuiAutoCrafting extends GuiContainer { +public class GuiAutoCrafting extends GuiBuildCraft { public GuiAutoCrafting(InventoryPlayer inventoryplayer, World world, TileAutoWorkbench tile) { @@ -30,8 +32,9 @@ public class GuiAutoCrafting extends GuiContainer { @Override protected void drawGuiContainerForegroundLayer() { - fontRenderer.drawString("Crafting", 28, 6, 0x404040); - fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); + String title = StringUtil.localize("tile.tile.autoWorkBenchBlock"); + fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040); + fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040); } @Override diff --git a/buildcraft_client/net/minecraft/src/buildcraft/factory/GuiRefinery.java b/buildcraft_client/net/minecraft/src/buildcraft/factory/GuiRefinery.java index 37f518ba..5eed5091 100644 --- a/buildcraft_client/net/minecraft/src/buildcraft/factory/GuiRefinery.java +++ b/buildcraft_client/net/minecraft/src/buildcraft/factory/GuiRefinery.java @@ -14,6 +14,7 @@ import net.minecraft.src.ItemStack; import net.minecraft.src.buildcraft.api.BuildCraftAPI; import net.minecraft.src.buildcraft.api.RefineryRecipe; import net.minecraft.src.buildcraft.core.GuiAdvancedInterface; +import net.minecraft.src.forestry.core.utils.StringUtil; import org.lwjgl.opengl.GL11; @@ -39,10 +40,11 @@ public class GuiRefinery extends GuiAdvancedInterface { @Override protected void drawGuiContainerForegroundLayer() { - fontRenderer.drawString("Refinery Setup", 28, 6, 0x404040); + String title = StringUtil.localize("tile.refineryBlock"); + fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040); fontRenderer.drawString("->", 63, 59, 0x404040); fontRenderer.drawString("<-", 106, 59, 0x404040); - fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); + fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040); drawForegroundSelection (); } diff --git a/buildcraft_client/net/minecraft/src/buildcraft/silicon/GuiAssemblyTable.java b/buildcraft_client/net/minecraft/src/buildcraft/silicon/GuiAssemblyTable.java index 7924fe11..181189b4 100644 --- a/buildcraft_client/net/minecraft/src/buildcraft/silicon/GuiAssemblyTable.java +++ b/buildcraft_client/net/minecraft/src/buildcraft/silicon/GuiAssemblyTable.java @@ -23,6 +23,7 @@ import net.minecraft.src.buildcraft.core.network.PacketPayload; import net.minecraft.src.buildcraft.core.network.PacketUpdate; import net.minecraft.src.buildcraft.factory.TileAssemblyTable; import net.minecraft.src.buildcraft.factory.TileAssemblyTable.SelectionMessage; +import net.minecraft.src.forestry.core.utils.StringUtil; import org.lwjgl.opengl.GL11; @@ -84,9 +85,9 @@ public class GuiAssemblyTable extends GuiAdvancedInterface { @Override protected void drawGuiContainerForegroundLayer() { - fontRenderer.drawString("Assembly Table", 60, 15, 0x404040); - fontRenderer.drawString("Inventory", 8, ySize - 97, - 0x404040); + String title = StringUtil.localize("tile.assemblyTableBlock"); + fontRenderer.drawString(title, getCenteredOffset(title), 15, 0x404040); + fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, ySize - 97, 0x404040); drawForegroundSelection(); } diff --git a/buildcraft_client/net/minecraft/src/buildcraft/transport/GuiDiamondPipe.java b/buildcraft_client/net/minecraft/src/buildcraft/transport/GuiDiamondPipe.java index defe8a77..c105514a 100644 --- a/buildcraft_client/net/minecraft/src/buildcraft/transport/GuiDiamondPipe.java +++ b/buildcraft_client/net/minecraft/src/buildcraft/transport/GuiDiamondPipe.java @@ -17,6 +17,7 @@ import net.minecraft.src.buildcraft.core.GuiAdvancedInterface; import net.minecraft.src.buildcraft.core.network.PacketIds; import net.minecraft.src.buildcraft.core.network.PacketSlotChange; import net.minecraft.src.buildcraft.transport.PipeLogicDiamond.PacketStack; +import net.minecraft.src.forestry.core.utils.StringUtil; import org.lwjgl.opengl.GL11; @@ -47,9 +48,8 @@ public class GuiDiamondPipe extends GuiAdvancedInterface { @Override protected void drawGuiContainerForegroundLayer() { - fontRenderer.drawString(filterInventory.getInvName(), 8, 6, 0x404040); - fontRenderer.drawString("Inventory", 8, ySize - 97, - 0x404040); + fontRenderer.drawString(filterInventory.getInvName(), getCenteredOffset(filterInventory.getInvName()), 6, 0x404040); + fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, ySize - 97, 0x404040); drawForegroundSelection (); } diff --git a/buildcraft_client/net/minecraft/src/buildcraft/transport/GuiGateInterface.java b/buildcraft_client/net/minecraft/src/buildcraft/transport/GuiGateInterface.java index 95dc92ae..b7b1baba 100644 --- a/buildcraft_client/net/minecraft/src/buildcraft/transport/GuiGateInterface.java +++ b/buildcraft_client/net/minecraft/src/buildcraft/transport/GuiGateInterface.java @@ -18,6 +18,7 @@ import net.minecraft.src.buildcraft.api.Trigger; import net.minecraft.src.buildcraft.api.TriggerParameter; import net.minecraft.src.buildcraft.core.GuiAdvancedInterface; import net.minecraft.src.buildcraft.transport.Gate.GateKind; +import net.minecraft.src.forestry.core.utils.StringUtil; import org.lwjgl.opengl.GL11; @@ -212,13 +213,8 @@ public class GuiGateInterface extends GuiAdvancedInterface { protected void drawGuiContainerForegroundLayer() { String name = _container.getGateName(); - if(name == "Gate") - fontRenderer.drawString("Gate", 75, 15, 0x404040); - else - fontRenderer.drawString(name, 60, 15, 0x404040); - - fontRenderer.drawString("Inventory", 8, ySize - 97, - 0x404040); + fontRenderer.drawString(name, getCenteredOffset(name), 15, 0x404040); + fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, ySize - 97, 0x404040); drawForegroundSelection (); } diff --git a/common/lang/buildcraft/en_US.properties b/common/lang/buildcraft/en_US.properties index 5fb621ca..9745aa58 100644 --- a/common/lang/buildcraft/en_US.properties +++ b/common/lang/buildcraft/en_US.properties @@ -1,5 +1,12 @@ # Master language file +gui.building.resources=Building Resources +gui.del=Del +gui.filling.resources=Filling Resources +gui.inventory=Inventory +gui.lock=Lock +gui.needed=Needed +gui.unlock=Unlock item.bucketFuel=Fuel Bucket item.bucketOil=Oil Bucket item.woodenGearItem=Wood Gear