Skip to content

Commit

Permalink
add strings to localization
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectron committed Aug 30, 2015
1 parent ebc6267 commit 6b4fc66
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 62 deletions.
2 changes: 1 addition & 1 deletion src/main/java/mapwriter/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class Config {
public static String backgroundTextureMode = backgroundTextureModeDef;
public static boolean moreRealisticMapDef = false;
public static boolean moreRealisticMap = moreRealisticMapDef;
public static boolean newMarkerDialogDef = false;
public static boolean newMarkerDialogDef = true;
public static boolean newMarkerDialog = newMarkerDialogDef;


Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mapwriter/config/ConfigurationHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static void loadConfig()
Config.undergroundMode = configuration.getBoolean("undergroundMode", Reference.catOptions, Config.undergroundModeDef, "mw.config.undergroundMode");
Config.regionFileOutputEnabledSP = configuration.getBoolean("regionFileOutputEnabledSP", Reference.catOptions, Config.regionFileOutputEnabledSPDef, "mw.config.regionFileOutputEnabledSP");
Config.regionFileOutputEnabledMP = configuration.getBoolean("regionFileOutputEnabledMP", Reference.catOptions, Config.regionFileOutputEnabledMPDef, "mw.config.regionFileOutputEnabledMP");
Config.backgroundTextureMode = configuration.getString("backgroundTextureMode", Reference.catOptions, Config.backgroundTextureModeDef, "mw.config.backgroundTextureModeDef", Config.backgroundModeStringArray);
Config.backgroundTextureMode = configuration.getString("backgroundTextureMode", Reference.catOptions, Config.backgroundTextureModeDef, "mw.config.backgroundTextureMode", Config.backgroundModeStringArray);
Config.zoomOutLevels = configuration.getInt("zoomOutLevels", Reference.catOptions, Config.zoomOutLevelsDef, 1, 256, "mw.config.zoomOutLevels");
Config.zoomInLevels = -configuration.getInt("zoomInLevels", Reference.catOptions, -Config.zoomInLevelsDef, 1, 256, "mw.config.zoomInLevels");

Expand All @@ -50,7 +50,7 @@ public static void loadConfig()
Config.moreRealisticMap = configuration.getBoolean("moreRealisticMap", Reference.catOptions, Config.moreRealisticMapDef, "mw.config.moreRealisticMap");

Config.newMarkerDialog = configuration.getBoolean("newMarkerDialog", Reference.catOptions, Config.newMarkerDialogDef, "mw.config.newMarkerDialog");

Config.fullScreenMap.loadConfig();
Config.largeMap.loadConfig();
Config.smallMap.loadConfig();
Expand Down
73 changes: 44 additions & 29 deletions src/main/java/mapwriter/gui/MwGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiConfirmOpenLink;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.BlockPos;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
Expand Down Expand Up @@ -197,13 +198,16 @@ public void mergeMapViewToImage() {
this.mapView.getDimension(), this.mw.worldDir, this.mw.worldDir
.getName()));

Utils.printBoth("merging to '" + this.mw.worldDir.getAbsolutePath()
Utils.printBoth(I18n.format("mw.gui.mwgui.chatmsg.merge", new Object[0]) + " '" + this.mw.worldDir.getAbsolutePath()
+ "'");
}

public void regenerateView() {
Utils.printBoth(String.format(
"regenerating %dx%d blocks starting from (%d, %d)",
I18n.format("mw.gui.mwgui.chatmsg.regenmap.1", new Object[0]) +
" %dx%d " +
I18n.format("mw.gui.mwgui.chatmsg.regenmap.2", new Object[0]) +
" (%d, %d)",
(int) this.mapView.getWidth(), (int) this.mapView.getHeight(),
(int) this.mapView.getMinX(), (int) this.mapView.getMinZ()));
// this.mw.reloadBlockColours();
Expand Down Expand Up @@ -404,14 +408,25 @@ protected void mouseClicked(int x, int y, int button) {
if ((marker != null) && (prevMarker == marker)) {
// right clicked previously selected marker.
// edit the marker
if (Config.newMarkerDialog)
{
this.mc.displayGuiScreen(
new MwGuiMarkerDialogNew(this,
this.mw.markerManager, marker
)
);
}
else
{
this.mc.displayGuiScreen(new MwGuiMarkerDialog(this,
this.mw.markerManager, marker));
}

} else if (marker == null) {
// open new marker dialog
String group = this.mw.markerManager.getVisibleGroupName();
if (group.equals("none")) {
group = "group";
group = I18n.format("mw.gui.mwgui.group", new Object[0]);
}

int mx, my, mz;
Expand Down Expand Up @@ -521,7 +536,7 @@ public void mouseDWheelScrolled(int x, int y, int direction) {

// called every frame
public void updateScreen() {
// MwUtil.log("MwGui.updateScreen() " +
// TODO:MwUtil.log("MwGui.updateScreen() " +
// Thread.currentThread().getName());
// need to wait one tick before exiting so that the game doesn't
// handle the 'm' key and re-open the gui.
Expand All @@ -538,14 +553,14 @@ public void updateScreen() {
public void drawStatus(int bX, int bY, int bZ) {
String s;
if (bY != 0) {
s = String.format("cursor: (%d, %d, %d)", bX, bY, bZ);
s = String.format(I18n.format("mw.gui.mwgui.status.cursor", new Object[0]) + ": (%d, %d, %d)", bX, bY, bZ);
} else {
s = String.format("cursor: (%d, ?, %d)", bX, bZ);
s = String.format(I18n.format("mw.gui.mwgui.status.cursor", new Object[0]) + ": (%d, ?, %d)", bX, bZ);
}
if (this.mc.theWorld != null) {
if (!this.mc.theWorld.getChunkFromBlockCoords(
new BlockPos(bX, 0, bZ)).isEmpty()) {
s += String.format(", biome: %s",
s += String.format(", " + I18n.format("mw.gui.mwgui.status.biome", new Object[0]) + ": %s",
this.mc.theWorld.getBiomeGenForCoords(new BlockPos(bX,
0, bZ)).biomeName);
}
Expand Down Expand Up @@ -584,24 +599,24 @@ public void drawHelp() {
" R\n" +
" U\n\n" +

"Left click drag or arrow keys pan the map.\n" +
"Mouse wheel or Page Up/Down zooms map.\n" +
"Right click map to create a new marker.\n" +
"Left click drag a selected marker to move it.\n" +
"Mouse wheel over selected marker to cycle colour.\n" +
"Mouse wheel over dimension or group box to cycle.\n",
I18n.format("mw.gui.mwgui.helptext.1", new Object[0]) + "\n" +
I18n.format("mw.gui.mwgui.helptext.2", new Object[0]) + "\n" +
I18n.format("mw.gui.mwgui.helptext.3", new Object[0]) + "\n" +
I18n.format("mw.gui.mwgui.helptext.4", new Object[0]) + "\n" +
I18n.format("mw.gui.mwgui.helptext.5", new Object[0]) + "\n" +
I18n.format("mw.gui.mwgui.helptext.6", new Object[0]) + "\n",
15, 24, this.width - 30, 0xffffff);
this.fontRendererObj.drawSplitString(
"| Next marker group\n" +
"| Delete selected marker\n" +
"| Cycle selected marker colour\n" +
"| Centre map on player\n" +
"| Centre map on selected marker\n" +
"| Select next marker\n" +
"| Teleport to cursor or selected marker\n" +
"| Save PNG of visible map area\n" +
"| Regenerate visible map area from region files\n" +
"| Underground map mode\n",
"| " + I18n.format("mw.gui.mwgui.helptext.nextmarkergroup", new Object[0]) + "\n" +
"| " + I18n.format("mw.gui.mwgui.helptext.deletemarker", new Object[0]) + "\n" +
"| " + I18n.format("mw.gui.mwgui.helptext.cyclecolour", new Object[0]) + "\n" +
"| " + I18n.format("mw.gui.mwgui.helptext.centermap", new Object[0]) + "\n" +
"| " + I18n.format("mw.gui.mwgui.helptext.centermapplayer", new Object[0]) + "\n" +
"| " + I18n.format("mw.gui.mwgui.helptext.selectnextmarker", new Object[0]) + "\n" +
"| " + I18n.format("mw.gui.mwgui.helptext.teleport", new Object[0]) + "\n" +
"| " + I18n.format("mw.gui.mwgui.helptext.savepng", new Object[0]) + "\n" +
"| " + I18n.format("mw.gui.mwgui.helptext.regenerate", new Object[0]) + "\n" +
"| " + I18n.format("mw.gui.mwgui.helptext.undergroundmap", new Object[0]) + "\n",
75, 42, this.width - 90, 0xffffff);
}

Expand Down Expand Up @@ -687,20 +702,20 @@ public void drawScreen(int mouseX, int mouseY, float f) {
this.drawStatus(this.mouseBlockX, this.mouseBlockY, this.mouseBlockZ);

// draw labels
this.helpLabel.draw(menuX, menuY, "[help]");
this.optionsLabel.drawToRightOf(this.helpLabel, "[options]");
String dimString = String.format("[dimension: %d]",
this.helpLabel.draw(menuX, menuY, "[" + I18n.format("mw.gui.mwgui.help", new Object[0]) + "]");
this.optionsLabel.drawToRightOf(this.helpLabel, "[" + I18n.format("mw.gui.mwgui.options", new Object[0]) + "]");
String dimString = String.format("[" + I18n.format("mw.gui.mwgui.dimension", new Object[0]) + ": %d]",
this.mapView.getDimension());
this.dimensionLabel.drawToRightOf(this.optionsLabel, dimString);
String groupString = String.format("[group: %s]",
String groupString = String.format("[" + I18n.format("mw.gui.mwgui.group", new Object[0]) + ": %s]",
this.mw.markerManager.getVisibleGroupName());
this.groupLabel.drawToRightOf(this.dimensionLabel, groupString);
String overlayString = String.format("[overlay: %s]",
String overlayString = String.format("[" + I18n.format("mw.gui.mwgui.overlay", new Object[0]) + ": %s]",
MwAPI.getCurrentProviderName());
this.overlayLabel.drawToRightOf(this.groupLabel, overlayString);

if (!VersionCheck.isLatestVersion()) {
String updateString = String.format("[New version : %s]",
String updateString = String.format("[" + I18n.format("mw.gui.mwgui.newversion", new Object[0]) + ": %s]",
VersionCheck.getLatestVersion());
this.updateLabel.drawToRightOf(this.overlayLabel, updateString);
}
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/mapwriter/gui/MwGuiDimensionDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import mapwriter.config.WorldConfig;
import mapwriter.map.MapView;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

Expand All @@ -15,7 +16,10 @@ public class MwGuiDimensionDialog extends MwGuiTextDialog {
final int dimension;

public MwGuiDimensionDialog(GuiScreen parentScreen, Mw mw, MapView mapView, int dimension) {
super(parentScreen, "Set dimension to:", "" + dimension, "invalid dimension");
super(parentScreen,
I18n.format("mw.gui.mwguidimensiondialog.title", new Object[0]) + ":",
Integer.toString(dimension),
I18n.format("mw.gui.mwguidimensiondialog.error", new Object[0]));
this.mw = mw;
this.mapView = mapView;
this.dimension = dimension;
Expand Down
31 changes: 19 additions & 12 deletions src/main/java/mapwriter/gui/MwGuiMarkerDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,27 @@
import mapwriter.map.Marker;
import mapwriter.map.MarkerManager;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class MwGuiMarkerDialog extends MwGuiTextDialog {
private final MarkerManager markerManager;
private Marker editingMarker;
private String markerName = "name";
private String markerGroup = "group";
private String markerName = "";
private String markerGroup = "";
private int markerX = 0;
private int markerY = 80;
private int markerZ = 0;
private int state = 0;
private int dimension = 0;

public MwGuiMarkerDialog(GuiScreen parentScreen, MarkerManager markerManager, String markerName, String markerGroup, int x, int y, int z, int dimension) {
super(parentScreen, "Marker Name:", markerName, "marker must have a name");
super(parentScreen,
I18n.format("mw.gui.mwguimarkerdialog.title.new", new Object[0]) + ":",
markerName,
I18n.format("mw.gui.mwguimarkerdialog.error", new Object[0]));
this.markerManager = markerManager;
this.markerName = markerName;
this.markerGroup = markerGroup;
Expand All @@ -31,7 +35,10 @@ public MwGuiMarkerDialog(GuiScreen parentScreen, MarkerManager markerManager, St
}

public MwGuiMarkerDialog(GuiScreen parentScreen, MarkerManager markerManager, Marker editingMarker) {
super(parentScreen, "Edit Marker Name:", editingMarker.name, "marker must have a name");
super(parentScreen,
I18n.format("mw.gui.mwguimarkerdialog.title.edit", new Object[0]) + ":",
editingMarker.name,
I18n.format("mw.gui.mwguimarkerdialog.error", new Object[0]));
this.markerManager = markerManager;
this.editingMarker = editingMarker;
this.markerName = editingMarker.name;
Expand All @@ -49,36 +56,36 @@ public boolean submit() {
case 0:
this.markerName = this.getInputAsString();
if (this.inputValid) {
this.title = "Marker Group:";
this.title = I18n.format("mw.gui.mwguimarkerdialog.title.group", new Object[0]) + ":";
this.setText(this.markerGroup);
this.error = "marker must have a group name";
this.error = I18n.format("mw.gui.mwguimarkerdialog.error.group", new Object[0]);
this.state++;
}
break;
case 1:
this.markerGroup = this.getInputAsString();
if (this.inputValid) {
this.title = "Marker X:";
this.title = I18n.format("mw.gui.mwguimarkerdialog.title.x", new Object[0]) + ":";
this.setText("" + this.markerX);
this.error = "invalid value";
this.error = I18n.format("mw.gui.mwguimarkerdialog.error.x", new Object[0]);
this.state++;
}
break;
case 2:
this.markerX = this.getInputAsInt();
if (this.inputValid) {
this.title = "Marker Y:";
this.title = I18n.format("mw.gui.mwguimarkerdialog.title.y", new Object[0]) + ":";
this.setText("" + this.markerY);
this.error = "invalid value";
this.error = I18n.format("mw.gui.mwguimarkerdialog.error.y", new Object[0]);
this.state++;
}
break;
case 3:
this.markerY = this.getInputAsInt();
if (this.inputValid) {
this.title = "Marker Z:";
this.title = I18n.format("mw.gui.mwguimarkerdialog.title.z", new Object[0]) + ":";
this.setText("" + this.markerZ);
this.error = "invalid value";
this.error = I18n.format("mw.gui.mwguimarkerdialog.error.z", new Object[0]);
this.state++;
}
break;
Expand Down
33 changes: 19 additions & 14 deletions src/main/java/mapwriter/gui/MwGuiMarkerDialogNew.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import mapwriter.util.Render;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;

Expand All @@ -18,12 +19,14 @@
@net.minecraftforge.fml.relauncher.SideOnly(Side.CLIENT)
public class MwGuiMarkerDialogNew extends GuiScreen {
private final GuiScreen parentScreen;
String title = "Add new marker";
private String editMarkerName = "Name:";
private String editMarkerGroup = "Group:";
private String editMarkerX = "X:";
private String editMarkerY = "Y:";
private String editMarkerZ = "Z:";
String title = "";
String titleNew = "mw.gui.mwguimarkerdialognew.title.new";
String titleEdit = "mw.gui.mwguimarkerdialognew.title.edit";
private String editMarkerName = "mw.gui.mwguimarkerdialognew.editMarkerName";
private String editMarkerGroup = "mw.gui.mwguimarkerdialognew.editMarkerGroup";
private String editMarkerX = "mw.gui.mwguimarkerdialognew.editMarkerX";
private String editMarkerY = "mw.gui.mwguimarkerdialognew.editMarkerY";
private String editMarkerZ = "mw.gui.mwguimarkerdialognew.editMarkerZ";
ScrollableTextBox scrollableTextBoxName = null;
ScrollableTextBox scrollableTextBoxGroup = null;
ScrollableNumericTextBox scrollableNumericTextBoxX = null;
Expand All @@ -34,8 +37,8 @@ public class MwGuiMarkerDialogNew extends GuiScreen {
static final int elementVSpacing = 20;
private final MarkerManager markerManager;
private Marker editingMarker;
private String markerName = "name";
private String markerGroup = "none";
private String markerName = "";
private String markerGroup = "";
private int markerX = 0;
private int markerY = 80;
private int markerZ = 0;
Expand Down Expand Up @@ -241,6 +244,7 @@ public MwGuiMarkerDialogNew(GuiScreen parentScreen,
this.editingMarker = null;
this.dimension = dimension;
this.parentScreen = parentScreen;
this.title = this.titleNew;
}

public MwGuiMarkerDialogNew(GuiScreen parentScreen,
Expand All @@ -254,6 +258,7 @@ public MwGuiMarkerDialogNew(GuiScreen parentScreen,
this.markerZ = editingMarker.z;
this.dimension = editingMarker.dimension;
this.parentScreen = parentScreen;
this.title = this.titleEdit;
}

public boolean submit() {
Expand Down Expand Up @@ -300,28 +305,28 @@ public void initGui() {
int x = (this.width - width) / 2 + labelsWidth;
int y = (this.height - elementVSpacing * 5) / 2;
this.scrollableTextBoxName = new ScrollableTextBox(x, y, width,
this.editMarkerName);
I18n.format(this.editMarkerName, new Object[0]));
this.scrollableTextBoxName.init();
this.scrollableTextBoxName.textField.setFocused(true);
this.scrollableTextBoxName.textField.setText(this.markerName);
this.scrollableTextBoxGroup = new ScrollableTextBox(x, y
+ this.elementVSpacing, width, this.editMarkerGroup,
+ this.elementVSpacing, width, I18n.format(this.editMarkerGroup, new Object[0]),
this.markerManager.groupList);
this.scrollableTextBoxGroup.init();
this.scrollableTextBoxGroup.textField.setText(this.markerGroup);
this.scrollableTextBoxGroup.setDrawArrows(true);
this.scrollableNumericTextBoxX = new ScrollableNumericTextBox(x, y
+ this.elementVSpacing * 2, width, this.editMarkerX);
+ this.elementVSpacing * 2, width, I18n.format(this.editMarkerX, new Object[0]));
this.scrollableNumericTextBoxX.init();
this.scrollableNumericTextBoxX.textField.setText("" + this.markerX);
this.scrollableNumericTextBoxX.setDrawArrows(true);
this.scrollableNumericTextBoxY = new ScrollableNumericTextBox(x, y
+ this.elementVSpacing * 3, width, this.editMarkerY);
+ this.elementVSpacing * 3, width, I18n.format(this.editMarkerY, new Object[0]));
this.scrollableNumericTextBoxY.init();
this.scrollableNumericTextBoxY.textField.setText("" + this.markerY);
this.scrollableNumericTextBoxY.setDrawArrows(true);
this.scrollableNumericTextBoxZ = new ScrollableNumericTextBox(x, y
+ this.elementVSpacing * 4, width, this.editMarkerZ);
+ this.elementVSpacing * 4, width, I18n.format(this.editMarkerZ, new Object[0]));
this.scrollableNumericTextBoxZ.init();
this.scrollableNumericTextBoxZ.textField.setText("" + this.markerZ);
this.scrollableNumericTextBoxZ.setDrawArrows(true);
Expand All @@ -344,7 +349,7 @@ public void drawScreen(int mouseX, int mouseY, float f) {
0x80000000);
this.drawCenteredString(
this.fontRendererObj,
this.title,
I18n.format(this.title, new Object[0]),
(this.width) / 2,
(this.height - this.elementVSpacing * 6) / 2
- this.elementVSpacing / 4,
Expand Down
Loading

0 comments on commit 6b4fc66

Please sign in to comment.