update NewGameScene translations

This commit is contained in:
Anthony Calosa
2023-02-24 10:48:09 +08:00
parent d500bc32a4
commit 1bc9f77cdb
14 changed files with 166 additions and 49 deletions

View File

@@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Json;
import forge.Forge;
import forge.adventure.util.Config;
import forge.adventure.util.Paths;
@@ -67,7 +68,7 @@ public class HeroListData {
instance = read();
Array<String> ret = new Array<>();
for (HeroData hero : instance.heroes) {
ret.add(hero.name);
ret.add(Forge.getLocalizer().getMessageorUseDefault("lbl"+hero.name, hero.name));
}
return ret;
}

View File

@@ -1,9 +1,11 @@
package forge.adventure.scene;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Array;
import com.github.tommyettinger.textra.TextraLabel;
@@ -45,7 +47,8 @@ public class NewGameScene extends UIScene {
private final Array<String> custom;
private final TextraLabel colorLabel;
private final Array<AdventureModes> modes=new Array<>();
private final Array<AdventureModes> modes = new Array<>();
private NewGameScene() {
super(Forge.isLandscapeMode() ? "ui/new_game.json" : "ui/new_game_portrait.json");
@@ -71,21 +74,18 @@ public class NewGameScene extends UIScene {
for (DifficultyData diff : Config.instance().getConfigData().difficulties)//check first difficulty if exists
{
if(diff.starterDecks!=null)
{
if (diff.starterDecks != null) {
modes.add(AdventureModes.Standard);
AdventureModes.Standard.setSelectionName(colorIdLabel);
AdventureModes.Standard.setModes(colorNames);
}
if(diff.constructedStarterDecks!=null)
{
if (diff.constructedStarterDecks != null) {
modes.add(AdventureModes.Constructed);
AdventureModes.Constructed.setSelectionName(colorIdLabel);
AdventureModes.Constructed.setModes(colorNames);
}
if(diff.pileDecks!=null)
{
if (diff.pileDecks != null) {
modes.add(AdventureModes.Pile);
AdventureModes.Pile.setSelectionName(colorIdLabel);
AdventureModes.Pile.setModes(colorNames);
@@ -106,28 +106,36 @@ public class NewGameScene extends UIScene {
starterEdition.setTextList(editionNames);
modes.add(AdventureModes.Chaos);
AdventureModes.Chaos.setSelectionName("[BLACK]"+Forge.getLocalizer().getMessage("lblDeck")+":");
AdventureModes.Chaos.setSelectionName("[BLACK]" + Forge.getLocalizer().getMessage("lblDeck") + ":");
AdventureModes.Chaos.setModes(new Array<>(new String[]{Forge.getLocalizer().getMessage("lblRandomDeck")}));
for (DeckProxy deckProxy : DeckProxy.getAllCustomStarterDecks())
custom.add(deckProxy.getName());
if(!custom.isEmpty())
{
if (!custom.isEmpty()) {
modes.add(AdventureModes.Custom);
AdventureModes.Custom.setSelectionName("[BLACK]"+Forge.getLocalizer().getMessage("lblDeck")+":");
AdventureModes.Custom.setSelectionName("[BLACK]" + Forge.getLocalizer().getMessage("lblDeck") + ":");
AdventureModes.Custom.setModes(custom);
}
String[] modeNames=new String[modes.size];
for(int i=0;i<modes.size;i++)
modeNames[i]=modes.get(i).getName();
String[] modeNames = new String[modes.size];
for (int i = 0; i < modes.size; i++)
modeNames[i] = modes.get(i).getName();
mode.setTextList(modeNames);
gender.setTextList(new String[]{"Male", "Female"});
gender.setTextList(new String[]{Forge.getLocalizer().getInstance().getMessage("lblMale"), Forge.getLocalizer().getInstance().getMessage("lblFemale")});
gender.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
//gender should be either Male or Female
String val = gender.getCurrentIndex() > 0 ? "Female" : "Male";
selectedName.setText(NameGenerator.getRandomName(val, "Any", ""));
super.clicked(event, x, y);
}
});
gender.addListener(event -> NewGameScene.this.updateAvatar());
mode.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent changeEvent, Actor actor) {
AdventureModes smode=modes.get(mode.getCurrentIndex());
AdventureModes smode = modes.get(mode.getCurrentIndex());
colorLabel.setText(smode.getSelectionName());
colorId.setTextList(smode.getModes());
starterEdition.setVisible(smode == AdventureModes.Standard);
@@ -145,7 +153,7 @@ public class NewGameScene extends UIScene {
for (DifficultyData diff : Config.instance().getConfigData().difficulties) {
if (diff.startingDifficulty)
startingDifficulty = i;
diffList.add(diff.name);
diffList.add(Forge.getLocalizer().getInstance().getMessageorUseDefault("lbl" + diff.name, diff.name));
i++;
}
difficulty.setTextList(diffList);
@@ -166,17 +174,22 @@ public class NewGameScene extends UIScene {
private static NewGameScene object;
public static NewGameScene instance() {
if(object==null)
object=new NewGameScene();
if (object == null)
object = new NewGameScene();
return object;
}
boolean started = false;
public boolean start() {
if (started)
return true;
started = true;
if (selectedName.getText().isEmpty()) {
selectedName.setText(NameGenerator.getRandomName("Any", "Any", ""));
}
Runnable runnable = () -> {
started = false;
FModel.getPreferences().setPref(ForgePreferences.FPref.UI_ENABLE_MUSIC, false);
WorldSave.generateNewWorld(selectedName.getText(),
gender.getCurrentIndex() == 0,
@@ -229,7 +242,7 @@ public class NewGameScene extends UIScene {
colorIds[colorId.getCurrentIndex()],
Config.instance().getConfigData().difficulties[difficulty.getCurrentIndex()],
modes.get(mode.getCurrentIndex()), colorId.getCurrentIndex(),
editionIds[starterEdition.getCurrentIndex()],0);
editionIds[starterEdition.getCurrentIndex()], 0);
GamePlayerUtil.getGuiPlayer().setName(selectedName.getText());
Forge.switchScene(GameScene.instance());
}

View File

@@ -62,7 +62,7 @@ public class SaveLoadScene extends UIScene {
int c = 0;
String[] diffList = new String[Config.instance().getConfigData().difficulties.length];
for (DifficultyData diff : Config.instance().getConfigData().difficulties) {
diffList[c] = diff.name;
diffList[c] = Forge.getLocalizer().getMessageorUseDefault("lbl" + diff.name, diff.name);
c++;
}
@@ -75,7 +75,7 @@ public class SaveLoadScene extends UIScene {
playerLocation = Controls.newTextraLabel("");
playerLocation.setText("");
playerLocation.setX(previewImage.getX());
playerLocation.setY(previewImage.getY()+5);
playerLocation.setY(previewImage.getY() + 5);
ui.addActor(playerLocation);
header = Controls.newTextraLabel(Forge.getLocalizer().getMessage("lblSave"));
header.setAlignment(Align.center);
@@ -98,33 +98,31 @@ public class SaveLoadScene extends UIScene {
difficulty.setSelectedIndex(1);
difficulty.setAlignment(Align.center);
difficulty.getStyle().fontColor = Color.GOLD;
difficulty.setX(scrollPane.getWidth()-difficulty.getWidth()+5);
difficulty.setY(scrollPane.getTop()-difficulty.getHeight()-5);
difficulty.setX(scrollPane.getWidth() - difficulty.getWidth() + 5);
difficulty.setY(scrollPane.getTop() - difficulty.getHeight() - 5);
}
private static SaveLoadScene object;
public static SaveLoadScene instance() {
if(object==null)
object=new SaveLoadScene();
if (object == null)
object = new SaveLoadScene();
return object;
}
public class SaveSlot extends Selectable<TextraButton>
{
public class SaveSlot extends Selectable<TextraButton> {
private int slotNumber;
public SaveSlot( int slotNumber) {
public SaveSlot(int slotNumber) {
super(Controls.newTextButton("..."));
this.slotNumber = slotNumber;
SaveSlot self=this;
SaveSlot self = this;
actor.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
try {
if (!actor.isDisabled())
{
if (!actor.isDisabled()) {
selectActor(self);
}
} catch (Exception e) {
@@ -133,9 +131,9 @@ public class SaveLoadScene extends UIScene {
}
});
}
@Override
public void onSelect(UIScene scene)
{
public void onSelect(UIScene scene) {
super.onSelect(scene);
updateSlot(slotNumber);
}
@@ -145,17 +143,17 @@ public class SaveLoadScene extends UIScene {
private Selectable<TextraButton> addSaveSlot(String name, int i) {
layout.add(Controls.newLabel(name)).align(Align.left).pad(2, 5, 2, 10);
SaveSlot button = new SaveSlot(i);
layout.add(button.actor).fill(true,false).expand(true,false).align(Align.left).expandX();
layout.add(button.actor).fill(true, false).expand(true, false).align(Align.left).expandX();
buttons.put(i, button);
layout.row();
addToSelectable(button) ;
addToSelectable(button);
return button;
}
public boolean select(int slot) {
if(!buttons.containsKey(slot))
if (!buttons.containsKey(slot))
return false;
selectActor(buttons.get(slot));
return updateSlot(slot);
@@ -175,7 +173,7 @@ public class SaveLoadScene extends UIScene {
previewImage.setVisible(true);
previewDate.setVisible(true);
if (header.saveDate != null)
previewDate.setText("[%98]"+DateFormat.getDateInstance().format(header.saveDate) + " " + DateFormat.getTimeInstance(DateFormat.SHORT).format(header.saveDate));
previewDate.setText("[%98]" + DateFormat.getDateInstance().format(header.saveDate) + " " + DateFormat.getTimeInstance(DateFormat.SHORT).format(header.saveDate));
else
previewDate.setText("");
if (header.name.contains(Character.toString(ASCII_179))) {
@@ -206,7 +204,7 @@ public class SaveLoadScene extends UIScene {
//prevent NPE, allowed saveslot is 1 to 10..
textInput.setText(buttons.get(currentSlot).actor.getText().toString());
Dialog dialog=prepareDialog(Forge.getLocalizer().getMessage("lblSave"),ButtonOk|ButtonAbort,() -> SaveLoadScene.this.save());
Dialog dialog = prepareDialog(Forge.getLocalizer().getMessage("lblSave"), ButtonOk | ButtonAbort, () -> SaveLoadScene.this.save());
dialog.getContentTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblNameYourSaveFile"))).colspan(2).pad(2, 15, 2, 15);
dialog.getContentTable().row();
@@ -255,7 +253,7 @@ public class SaveLoadScene extends UIScene {
public void save() {
if (WorldSave.getCurrentSave().save(textInput.getText()+ASCII_179+GameScene.instance().getAdventurePlayerLocation(true), currentSlot)) {
if (WorldSave.getCurrentSave().save(textInput.getText() + ASCII_179 + GameScene.instance().getAdventurePlayerLocation(true), currentSlot)) {
updateFiles();
//ensure the dialog is hidden before switching

View File

@@ -1,13 +1,14 @@
package forge.adventure.util;
import com.badlogic.gdx.utils.Array;
import forge.Forge;
public enum AdventureModes {
Standard("Standard"),
Constructed("Constructed"),
Chaos("[GOLD]Chaos"),
Pile("Pile"),
Custom("Custom");
Standard(Forge.getLocalizer().getMessage("lblStandard")),
Constructed(Forge.getLocalizer().getMessage("lblConstructed")),
Chaos("[GOLD]"+Forge.getLocalizer().getMessage("lblChaos")),
Pile(Forge.getLocalizer().getMessage("lblPile")),
Custom(Forge.getLocalizer().getMessage("lblCustom"));
private final String name;
private String selectionName;