Converted almost everything to an I18nBundle

This commit is contained in:
Anuken
2017-12-26 17:58:20 -05:00
parent 40bb499eeb
commit 42909abf53
36 changed files with 525 additions and 593 deletions

View File

@@ -59,7 +59,7 @@ public class FileChooser extends FloatingDialog{
if(!open) Mindustry.platforms.addDialog(filefield);
filefield.setDisabled(open);
ok = new TextButton(open ? "Open" : "Save");
ok = new TextButton(open ? "$text.save" : "$text.save");
ok.clicked(() -> {
if(ok.isDisabled()) return;
@@ -74,8 +74,8 @@ public class FileChooser extends FloatingDialog{
filefield.change();
TextButton cancel = new TextButton("Cancel");
cancel.clicked(() -> hide());
TextButton cancel = new TextButton("$text.cancel");
cancel.clicked(this::hide);
navigation = new TextField("");
navigation.setTouchable(Touchable.disabled);

View File

@@ -14,6 +14,7 @@ import io.anuke.ucore.scene.ui.layout.Stack;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.utils.ClickListener;
import io.anuke.ucore.scene.utils.Elements;
import io.anuke.ucore.util.Bundles;
import io.anuke.ucore.util.Tmp;
public class LevelDialog extends FloatingDialog{
@@ -22,7 +23,7 @@ public class LevelDialog extends FloatingDialog{
private ScrollPane pane;
public LevelDialog(){
super("Level Select");
super("$text.level.select");
getTitleTable().getCell(title()).growX().center();
getTitleTable().center();
addCloseButton();
@@ -43,10 +44,10 @@ public class LevelDialog extends FloatingDialog{
Table selmode = new Table();
ButtonGroup<TextButton> group = new ButtonGroup<>();
selmode.add("Gamemode: ").padRight(10f);
selmode.add("$text.level.mode").padRight(15f);
for(GameMode mode : GameMode.values()){
TextButton b = Elements.newButton(mode.toString(), "toggle", ()->{
TextButton b = Elements.newButton("$mode."+mode.name()+".name", "toggle", ()->{
Vars.control.setMode(mode);
});
group.add(b);
@@ -66,9 +67,9 @@ public class LevelDialog extends FloatingDialog{
}
Table inset = new Table("pane-button");
inset.add("[accent]"+map.name).pad(3f);
inset.add("[accent]" + Bundles.get("map."+map.name+".name", map.name)).pad(3f);
inset.row();
inset.label((() -> "High Score: [accent]" + Settings.getInt("hiscore" + map.name)))
inset.label((() -> Bundles.format("text.level.highscore", Settings.getInt("hiscore" + map.name))))
.pad(3f);
inset.pack();
@@ -87,7 +88,7 @@ public class LevelDialog extends FloatingDialog{
image.row();
delete[0] = image.addButton("Delete", () -> {
Timers.run(1f, () -> {
Vars.ui.showConfirm("Confirm Delete", "Are you sure you want to delete\nthe map \"[orange]" + map.name + "[]\"?", () -> {
Vars.ui.showConfirm("$text.level.delete.title", Bundles.format("text.level.delete", Bundles.get("map."+map.name+".name", map.name)), () -> {
Vars.world.maps().removeMap(map);
reload();
Core.scene.setScrollFocus(pane);

View File

@@ -12,12 +12,13 @@ import io.anuke.ucore.scene.ui.Label;
import io.anuke.ucore.scene.ui.ScrollPane;
import io.anuke.ucore.scene.ui.TextButton;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.util.Bundles;
public class LoadDialog extends FloatingDialog{
ScrollPane pane;
public LoadDialog() {
this("Load Game");
this("$text.loadgame");
}
public LoadDialog(String title) {
@@ -35,7 +36,7 @@ public class LoadDialog extends FloatingDialog{
private void setup(){
content().clear();
content().add("Select a save slot.").padBottom(2);
content().add("$text.selectslot").padBottom(2);
content().row();
Table slots = new Table();
@@ -46,15 +47,15 @@ public class LoadDialog extends FloatingDialog{
for(int i = 0; i < Vars.saveSlots; i++){
TextButton button = new TextButton("[accent]Slot " + (i + 1));
TextButton button = new TextButton(Bundles.format("text.slot", (i + 1)));
button.margin(12);
button.getLabelCell().top().left().growX();
button.row();
Label info = new Label("[gray]" + (!SaveIO.isSaveValid(i) ? "<empty>" : SaveIO.getMode(i) + ", "
+ SaveIO.getMap(i).name + ", Wave " + SaveIO.getWave(i)
+ "\nLast Saved: " + SaveIO.getTimeString(i)));
Label info = new Label("[gray]" + (!SaveIO.isSaveValid(i) ? Bundles.get("text.empty") : SaveIO.getMode(i) + ", "
+ SaveIO.getMap(i).name + ", " + Bundles.format("text.save.wave", SaveIO.getWave(i)) + "\n"
+ Bundles.format("text.save.date", SaveIO.getTimeString(i))));
info.setAlignment(Align.center, Align.center);
button.add(info).padBottom(3).padTop(7);
@@ -88,7 +89,7 @@ public class LoadDialog extends FloatingDialog{
Vars.ui.hideMenu();
GameState.set(State.menu);
Vars.control.reset();
Vars.ui.showError("[orange]Save file corrupted or invalid!");
Vars.ui.showError("$text.save.corrupted");
return;
}
});

View File

@@ -31,32 +31,32 @@ public class MenuDialog extends FloatingDialog{
if(!Vars.android){
content().defaults().width(220).height(50);
content().addButton("Back", () -> {
content().addButton("$text.back", () -> {
hide();
if(!wasPaused)
GameState.set(State.playing);
});
content().row();
content().addButton("Settings", () -> {
content().addButton("$text.settings", () -> {
ui.showPrefs();
});
if(!Vars.gwt){
content().row();
content().addButton("Save Game", () -> {
content().addButton("$text.savegame", () -> {
save.show();
});
content().row();
content().addButton("Load Game", () -> {
content().addButton("$text.loadgame", () -> {
load.show();
});
}
content().row();
content().addButton("Quit", () -> {
new ConfirmDialog("Confirm", "Are you sure you want to quit?", () -> {
content().addButton("$text.quit", () -> {
new ConfirmDialog("$text.confirm", "$text.quit.confirm", () -> {
hide();
GameState.set(State.menu);
}){
@@ -79,16 +79,16 @@ public class MenuDialog extends FloatingDialog{
hide();
if(!wasPaused)
GameState.set(State.playing);
}).text("Back").padTop(4f);
}).text("$text.back").padTop(4f);
new imagebutton("icon-tools", isize, () -> ui.showPrefs()).text("Settings").padTop(4f);
new imagebutton("icon-tools", isize, () -> ui.showPrefs()).text("$text.settings").padTop(4f);
new imagebutton("icon-save", isize, ()-> save.show()).text("Save").padTop(4f);
new imagebutton("icon-save", isize, ()-> save.show()).text("$text.save").padTop(4f);
new imagebutton("icon-load", isize, () -> load.show()).text("Load").padTop(4f);
new imagebutton("icon-load", isize, () -> load.show()).text("$text.load").padTop(4f);
new imagebutton("icon-quit", isize, () -> {
new ConfirmDialog("Confirm", "Are you sure you want to quit?", () -> {
new ConfirmDialog("$text.confirm", "$text.quit.confirm", () -> {
hide();
GameState.set(State.menu);
}){{

View File

@@ -21,7 +21,7 @@ public class MindustryKeybindDialog extends KeybindDialog{
@Override
public void addCloseButton(){
buttons().addImageTextButton("Back", "icon-arrow-left", 30f, this::hide).size(230f, 64f);
buttons().addImageTextButton("$text.back", "icon-arrow-left", 30f, this::hide).size(230f, 64f);
keyDown(key->{
if(key == Keys.ESCAPE || key == Keys.BACK)

View File

@@ -39,7 +39,7 @@ public class MindustrySettingsDialog extends SettingsDialog{
Consumer<SettingsTable> s = table -> {
table.row();
table.addImageTextButton("Back", "icon-arrow-left", 10*3, this::back).size(240f, 60f).colspan(2).padTop(15f);
table.addImageTextButton("$text.back", "icon-arrow-left", 10*3, this::back).size(240f, 60f).colspan(2).padTop(15f);
};
game = new SettingsTable(s);
@@ -51,15 +51,15 @@ public class MindustrySettingsDialog extends SettingsDialog{
prefs.margin(14f);
menu.defaults().size(300f, 60f).pad(3f);
menu.addButton("Game", () -> visible(0));
menu.addButton("$text.settings.game", () -> visible(0));
menu.row();
menu.addButton("Graphics", () -> visible(1));
menu.addButton("$text.settings.graphics", () -> visible(1));
menu.row();
menu.addButton("Sound", () -> visible(2));
menu.addButton("$text.settings.sound", () -> visible(2));
if(!Vars.android) {
menu.row();
menu.addButton("Controls", () -> Vars.ui.showControls());
menu.addButton("$text.settings.controls", () -> Vars.ui.showControls());
}
prefs.clearChildren();
@@ -89,7 +89,7 @@ public class MindustrySettingsDialog extends SettingsDialog{
@Override
public void addCloseButton(){
buttons().addImageTextButton("Menu", "icon-arrow-left", 30f, this::hide).size(230f, 64f);
buttons().addImageTextButton("$text.menu", "icon-arrow-left", 30f, this::hide).size(230f, 64f);
keyDown(key->{
if(key == Keys.ESCAPE || key == Keys.BACK)

View File

@@ -8,18 +8,19 @@ import io.anuke.ucore.core.Timers;
import io.anuke.ucore.scene.ui.ConfirmDialog;
import io.anuke.ucore.scene.ui.TextButton;
import io.anuke.ucore.scene.ui.layout.Cell;
import io.anuke.ucore.util.Bundles;
public class SaveDialog extends LoadDialog{
public SaveDialog() {
super("Save Game");
super("$text.savegame");
}
@Override
public void modifyButton(TextButton button, int slot){
button.clicked(() -> {
if(SaveIO.isSaveValid(slot)){
new ConfirmDialog("Overwrite", "Are you sure you want to overwrite\nthis save slot?", () -> {
new ConfirmDialog("$text.overwrite", "$text.save.overwrite", () -> {
save(slot);
}){
{
@@ -35,7 +36,7 @@ public class SaveDialog extends LoadDialog{
}
void save(int slot){
Vars.ui.showLoading("[accent]Saving...");
Vars.ui.showLoading("text.saveload");
Timers.runTask(5f, () -> {
hide();
@@ -45,7 +46,7 @@ public class SaveDialog extends LoadDialog{
}catch(Throwable e){
e = (e.getCause() == null ? e : e.getCause());
Vars.ui.showError("[orange]Failed to save game!\n[white]" + ClassReflection.getSimpleName(e.getClass()) + ": " + e.getMessage() + "\n" + "at " + e.getStackTrace()[0].getFileName() + ":" + e.getStackTrace()[0].getLineNumber());
Vars.ui.showError("[orange]"+Bundles.get("text.savefail")+"\n[white]" + ClassReflection.getSimpleName(e.getClass()) + ": " + e.getMessage() + "\n" + "at " + e.getStackTrace()[0].getFileName() + ":" + e.getStackTrace()[0].getLineNumber());
}
});
}

View File

@@ -21,7 +21,7 @@ public class UpgradeDialog extends FloatingDialog{
boolean wasPaused = false;
public UpgradeDialog() {
super("Upgrades");
super("$text.upgrades");
setup();
}
@@ -107,7 +107,7 @@ public class UpgradeDialog extends FloatingDialog{
tiptable.add("[gray]" + description).left();
tiptable.row();
if(control.hasWeapon(weapon)){
tiptable.add("[LIME]Purchased!").padTop(6).left();
tiptable.add("$text.purchased").padTop(6).left();
}
tiptable.margin(14f);
};
@@ -131,7 +131,7 @@ public class UpgradeDialog extends FloatingDialog{
});
}
content().add("Weapons");
content().add("$text.weapons");
content().row();
content().add(weptab);
content().row();

View File

@@ -2,9 +2,12 @@ package io.anuke.mindustry.ui.fragments;
import static io.anuke.mindustry.Vars.*;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.core.GameState;
@@ -13,9 +16,11 @@ import io.anuke.mindustry.resource.ItemStack;
import io.anuke.mindustry.resource.Recipe;
import io.anuke.mindustry.resource.Section;
import io.anuke.mindustry.ui.FloatingDialog;
import io.anuke.ucore.UCore;
import io.anuke.ucore.core.Core;
import io.anuke.ucore.core.Draw;
import io.anuke.ucore.graphics.Hue;
import io.anuke.ucore.scene.actions.Actions;
import io.anuke.ucore.scene.builders.button;
import io.anuke.ucore.scene.builders.imagebutton;
import io.anuke.ucore.scene.builders.table;
@@ -23,6 +28,7 @@ import io.anuke.ucore.scene.event.Touchable;
import io.anuke.ucore.scene.ui.*;
import io.anuke.ucore.scene.ui.layout.Stack;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.util.Bundles;
import io.anuke.ucore.util.Mathf;
public class BlocksFragment implements Fragment{
@@ -38,7 +44,7 @@ public class BlocksFragment implements Fragment{
visible(() -> !GameState.is(State.menu));
new table(){{
Table blocks = new table(){{
new table("button") {{
visible(() -> player.recipe != null);
@@ -108,10 +114,8 @@ public class BlocksFragment implements Fragment{
image.getImageCell().size(size);
image.update(() -> {
boolean canPlace = !control.getTutorial().active() || control.getTutorial().canPlace();
boolean has = (control.hasItems(r.requirements)) && canPlace;
//image.setDisabled(!has);
image.setChecked(player.recipe == r);
image.setTouchable(canPlace ? Touchable.enabled : Touchable.disabled);
image.getImage().setColor(has ? Color.WHITE : Hue.lightness(0.33f));
@@ -133,22 +137,42 @@ public class BlocksFragment implements Fragment{
add(stack).colspan(Section.values().length);
margin(10f);
get().marginLeft(0f);
get().marginRight(0f);
marginLeft(0f);
marginRight(0f);
end();
}}.right().bottom().uniformX();
visible(() -> !GameState.is(State.menu) && shown);
}}.end();
}}.end().get();
row();
new imagebutton("icon-arrow-down", 10*2, () -> {
shown = !shown;
}).padBottom(-5).uniformX().fillX()
.update(i -> i.getStyle().imageUp = Core.skin.getDrawable(shown ? "icon-arrow-down" : "icon-arrow-up"));
ImageButton buttons[] = new ImageButton[2];
float size = 46f;
float t = 0.2f;
Interpolation ip = Interpolation.pow3Out;
//TODO fix glitch when resizing
buttons[0] = new imagebutton("icon-arrow-down", 10*2, () -> {
if(blocks.getActions().size != 0) return;
blocks.actions(Actions.translateBy(0, -blocks.getHeight(), t, ip), Actions.call(() -> shown = false));
buttons[0].actions(Actions.fadeOut(t));
buttons[1].actions(Actions.fadeIn(t));
}).padBottom(-5).visible(() -> shown).height(size).uniformX().fillX()
.update(i -> i.getStyle().imageUp = Core.skin.getDrawable(shown ? "icon-arrow-down" : "icon-arrow-up")).get();
buttons[1] = new imagebutton("icon-arrow-up", 10*2, () -> {
if(blocks.getActions().size != 0) return;
blocks.actions(Actions.translateBy(0, blocks.getHeight(), t, ip));
shown = true;
buttons[0].actions(Actions.fadeIn(t));
buttons[1].actions(Actions.fadeOut(t));
}).touchable(() -> shown ? Touchable.disabled : Touchable.enabled).size(size).padBottom(-5).padLeft(-size).get();
buttons[1].getColor().a = 0f;
}}.end();
}
@@ -187,7 +211,7 @@ public class BlocksFragment implements Fragment{
boolean wasPaused = GameState.is(State.paused);
GameState.set(State.paused);
FloatingDialog d = new FloatingDialog("Block Info");
FloatingDialog d = new FloatingDialog("$text.blocks.blockinfo");
Table table = new Table();
table.defaults().pad(1f);
ScrollPane pane = new ScrollPane(table, "clear");
@@ -204,7 +228,7 @@ public class BlocksFragment implements Fragment{
d.content().add(pane).grow();
if(statlist.size > 0){
table.add("[accent]extra block info:").padTop(6).padBottom(5).left();
table.add("$text.blocks.extrainfo").padTop(6).padBottom(5).left();
table.row();
}
@@ -213,7 +237,7 @@ public class BlocksFragment implements Fragment{
table.row();
}
d.buttons().addButton("OK", ()->{
d.buttons().addButton("$text.ok", ()->{
if(!wasPaused) GameState.set(State.playing);
d.hide();
}).size(110, 50).pad(10f);
@@ -252,7 +276,7 @@ public class BlocksFragment implements Fragment{
desctable.row();
Label label = new Label("[health]health: " + recipe.result.health + (recipe.result.description == null ?
Label label = new Label("[health]"+ Bundles.get("text.health")+": " + recipe.result.health + (recipe.result.description == null ?
"" : ("\n[]" + recipe.result.description)));
label.setWrap(true);
desctable.add(label).width(200).padTop(4).padBottom(2);

View File

@@ -23,6 +23,7 @@ import io.anuke.ucore.scene.ui.Image;
import io.anuke.ucore.scene.ui.Label;
import io.anuke.ucore.scene.ui.layout.Cell;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.util.Bundles;
public class HudFragment implements Fragment{
private Table itemtable, respawntable;
@@ -91,7 +92,7 @@ public class HudFragment implements Fragment{
atop();
new table("pane"){{
new label("[orange]< paused >").scale(0.75f).pad(6);
new label("[orange]< "+ Bundles.get("text.paused") + " >").scale(0.75f).pad(6);
}}.end();
}}.end();
@@ -122,7 +123,7 @@ public class HudFragment implements Fragment{
new table(){{
new table("pane"){{
new label(()->"[orange]Respawning in " + (int)(control.getRespawnTime()/60)).scale(0.75f).pad(10);
new label(()->"[orange]"+Bundles.get("text.respawn")+" " + (int)(control.getRespawnTime()/60)).scale(0.75f).pad(10);
visible(()->control.getRespawnTime() > 0 && !GameState.is(State.menu));
@@ -149,10 +150,10 @@ public class HudFragment implements Fragment{
}
}
private String printEnemiesRemaining() {
private String getEnemiesRemaining() {
if(control.getEnemiesRemaining() == 1) {
return " enemy left";
} else return " enemies left";
return Bundles.format("text.single", control.getEnemiesRemaining());
} else return Bundles.format("text.enemies", control.getEnemiesRemaining());
}
private void addWaveTable(){
@@ -163,13 +164,14 @@ public class HudFragment implements Fragment{
new table(){{
aleft();
new label(()->"[orange]Wave " + control.getWave()).scale(fontscale*1.5f).left();
new label(() -> Bundles.format("text.wave", control.getWave())).scale(fontscale*1.5f).left();
row();
new label(()-> control.getEnemiesRemaining() > 0 ?
control.getEnemiesRemaining() + printEnemiesRemaining() :
(control.getTutorial().active() || Vars.control.getMode().toggleWaves) ? "waiting..." : "Wave in " + (int) (control.getWaveCountdown() / 60f))
getEnemiesRemaining() :
(control.getTutorial().active() || Vars.control.getMode().toggleWaves) ? "$text.waiting"
: Bundles.format("text.wave.waiting", (int) (control.getWaveCountdown() / 60f)))
.minWidth(140).left();
margin(12f);

View File

@@ -56,22 +56,22 @@ public class MenuFragment implements Fragment{
defaults().size(120f).pad(5);
float isize = 14f*4;
new imagebutton("icon-play-2", isize, () -> ui.showLevels()).text("Play").padTop(4f);
new imagebutton("icon-play-2", isize, () -> ui.showLevels()).text("$text.play").padTop(4f);
new imagebutton("icon-tutorial", isize, () -> control.playMap(world.maps().getMap("tutorial"))).text("Tutorial").padTop(4f);
new imagebutton("icon-tutorial", isize, () -> control.playMap(world.maps().getMap("tutorial"))).text("$text.tutorial").padTop(4f);
new imagebutton("icon-load", isize, () -> ui.showLoadGame()).text("Load").padTop(4f);
new imagebutton("icon-load", isize, () -> ui.showLoadGame()).text("$text.load").padTop(4f);
row();
new imagebutton("icon-editor", isize, () -> ui.showEditor()).text("Editor").padTop(4f);
new imagebutton("icon-editor", isize, () -> ui.showEditor()).text("$text.editor").padTop(4f);
new imagebutton("icon-tools", isize, () -> ui.showPrefs()).text("Settings").padTop(4f);
new imagebutton("icon-tools", isize, () -> ui.showPrefs()).text("$text.settings").padTop(4f);
if(Mindustry.donationsCallable != null){
new imagebutton("icon-donate", isize, () -> {
Mindustry.donationsCallable.run();
}).text("Donate").padTop(4f);
}).text("$text.donate").padTop(4f);
}
visible(()->GameState.is(State.menu));

View File

@@ -28,7 +28,7 @@ public class PlacementFragment implements Fragment{
touchable(Touchable.enabled);
aleft();
new label("place mode");
new label("$text.placemode");
row();
new table("pane"){{
@@ -76,7 +76,7 @@ public class PlacementFragment implements Fragment{
abottom();
aleft();
new label("break mode");
new label("$text.breakmode");
row();
new table("pane"){{

View File

@@ -28,7 +28,7 @@ public class WeaponFragment implements Fragment{
public void updateWeapons(){
weapontable.clearChildren();
ButtonGroup group = new ButtonGroup();
ButtonGroup<ImageButton> group = new ButtonGroup<>();
weapontable.defaults().size(58, 62);
@@ -52,14 +52,14 @@ public class WeaponFragment implements Fragment{
String description = weapon.description;
tiptable.background("button");
tiptable.add("" + weapon.name(), 0.5f).left().padBottom(3f);
tiptable.add("weapon."+weapon.name()+".name", 0.5f).left().padBottom(3f);
tiptable.row();
tiptable.row();
tiptable.add("[GRAY]" + description).left();
tiptable.margin(14f);
Tooltip tip = new Tooltip(tiptable);
Tooltip<Table> tip = new Tooltip<>(tiptable);
tip.setInstant(true);