summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/i18n/en_us.json44
-rw-r--r--assets/i18n/ru_ru.json47
-rw-r--r--core/src/kz/ilotterytea/maxon/MaxonGame.java14
-rw-r--r--core/src/kz/ilotterytea/maxon/localization/LineId.java75
-rw-r--r--core/src/kz/ilotterytea/maxon/localization/LocalizationManager.java70
-rw-r--r--core/src/kz/ilotterytea/maxon/pets/Pet.java5
-rw-r--r--core/src/kz/ilotterytea/maxon/screens/MenuScreen.java13
-rw-r--r--core/src/kz/ilotterytea/maxon/screens/SlotsMinigameScreen.kt11
-rw-r--r--core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java88
-rw-r--r--core/src/kz/ilotterytea/maxon/screens/game/Giftbox.java3
-rw-r--r--core/src/kz/ilotterytea/maxon/ui/OptionsTable.java180
-rw-r--r--core/src/kz/ilotterytea/maxon/ui/SavegameWidget.java5
-rw-r--r--core/src/kz/ilotterytea/maxon/utils/I18N.java53
13 files changed, 177 insertions, 431 deletions
diff --git a/assets/i18n/en_us.json b/assets/i18n/en_us.json
index 9be139d..838d2e6 100644
--- a/assets/i18n/en_us.json
+++ b/assets/i18n/en_us.json
@@ -1,49 +1,9 @@
{
"updater.info": "A new update is available!",
- "debug.version": "%s (LibGDX %s, Java %s)",
- "debug.c_fps": "%s FPS",
- "debug.c_mem": "Used memory: %s MB (total of %s MB)",
-
- "splash.disclaimer": "This game contains an unbelievable dose of cheeky \"woolbags\". Please, it is not recommended for anyone to play. Any match in real life of the presented images of cats is pure coincidence! All cat images were generated by \"NUT-S\" neural network.",
-
- "menu.last_savegame.found": "Savegame: %s - %s Squish Points (x%s/click) - %s purchased items.",
- "menu.last_savegame.empty": "No savegame found.",
- "menu.pressStart": "PRESS START",
- "menu.playGame": "PLAY GAME",
- "menu.options": "OPTIONS",
- "menu.quit": "QUIT TO DESKTOP",
"menu.continue": "CONTINUE",
"menu.reset": "RESET",
- "savegame.title": "Save %s (%s)",
- "savegame.new": "New savegame...",
- "savegame.points": "Points",
- "savegame.multiplier": "Multiplier",
- "savegame.multiplier.count": "+%s/click",
- "savegame.purchased": "Purchased items",
- "savegame.your_name": "Say your name",
-
- "options.title": "Options",
- "options.music": "Music",
- "options.sound": "Sound",
- "options.vsync": "Vertical Sync",
- "options.fullscreen": "Fullscreen",
- "options.language": "Language: %s (%s)",
- "options.debug": "Show debug",
- "options.reset": "Reset save data",
- "options.close": "Back to main title",
- "options.general": "General",
- "options.video": "Video",
- "options.audio": "Audio",
-
- "game.petShop": "Pet Shop",
- "game.points": "%s",
- "game.multiplier": "%s/click",
- "game.newPoint": "{SHAKE}{RAINBOW}+%s{ENDRAINBOW}{ENDSHAKE}",
-
- "dialogs.not_enough_points": "Not enough points!",
-
"giftbox.open": "You got",
"minigame.slots.nothing": "YOU WON NOTHINGG",
@@ -52,8 +12,6 @@
"minigame.slots.spin_button": "SPIN",
"minigame.slots.exit_button": " X ",
- "game.inventory.title": "Inventory",
-
"pet.bror.name": "The Suspicious and Sleepy Bro",
"pet.bror.desc": "A falling asleep Bror will help you to pet Maxon almost to besvimers",
@@ -98,6 +56,4 @@
"pet.succat.name": "Sucking cat",
"pet.succat.desc": "Maskot. Increases amount of petting with his sucking power."
-
-
} \ No newline at end of file
diff --git a/assets/i18n/ru_ru.json b/assets/i18n/ru_ru.json
index ff70cd3..2289900 100644
--- a/assets/i18n/ru_ru.json
+++ b/assets/i18n/ru_ru.json
@@ -1,57 +1,15 @@
{
"updater.info": "Доступно новое обновление!",
- "debug.version": "%s (LibGDX %s, Java %s)",
- "debug.c_fps": "%s FPS",
- "debug.c_mem": "Потребление ОЗУ: %s МБ (из %s МБ)",
-
- "splash.disclaimer": "Эта игра содержит невероятную дозу щекастых \"шерстяных мешков\". Никому не рекомендуется не играть в эту игру. Любое сходство в реальной жизни с представленными изображениями котов - чистое совпадение! Все изображения котов были сгенерированы нейросетью \"NUT-S\".",
-
- "menu.last_savegame.found": "Сохранение: %s - %s баллы жмякания (х%s/клик) - %s куплено предметов.",
- "menu.last_savegame.empty": "Сохранение не найдено!",
- "menu.pressStart": "НАЖМИТЕ ЛЮБУЮ КНОПКУ",
- "menu.playGame": "НАЧАТЬ ИГРУ",
- "menu.options": "НАСТРОЙКИ...",
- "menu.quit": "ВЫЙТИ НА РАБОЧИЙ СТОЛ",
"menu.continue": "ПРОДОЛЖИТЬ",
"menu.reset": "СБРОСИТЬ",
- "savegame.title": "Сохранение %s (%s)",
- "savegame.new": "Новое сохранение...",
- "savegame.points": "Баллов жмяканья",
- "savegame.multiplier": "Множитель",
- "savegame.multiplier.count": "+%s/жмяк",
- "savegame.purchased": "Купленных предметов",
- "savegame.your_name": "Ваше имя",
-
- "options.title": "Настройки",
- "options.music": "Музыка",
- "options.sound": "Звук",
- "options.vsync": "Верт. синхронизация",
- "options.fullscreen": "Полноэкранный режим",
- "options.language": "Язык: %s (%s)",
- "options.debug": "Показать откладку",
- "options.reset": "Сбросить сохранение",
- "options.close": "Вернуться на главный экран",
- "options.general": "Основное",
- "options.video": "Видео",
- "options.audio": "Аудио",
-
- "game.petShop": "Магазин Щекастых",
- "game.points": "%s",
- "game.multiplier": "%s/жмяк",
- "game.newPoint": "{SHAKE}{RAINBOW}+%s{ENDRAINBOW}{ENDSHAKE}",
-
"minigame.slots.nothing": "ТЫ НИЧЕГО НЕ ВЫИГРАЛ",
"minigame.slots.prize": "ТЫ ВЫИГРАЛ %s P$",
"minigame.slots.bet": "СТАВКА",
"minigame.slots.spin_button": "КРУТАНУТЬ",
"minigame.slots.exit_button": " X ",
- "game.inventory.title": "Инвентарь",
-
- "dialogs.not_enough_points": "Недостаточно поинтов!",
-
"giftbox.open": "Ты получил",
"pet.bror.name": "Cонный Брор",
@@ -98,9 +56,4 @@
"pet.succat.name": "Сосущий кот",
"pet.succat.desc": "Талисман. Своими сосательными навыками увеличивает количество поглаживаний."
-
-
-
-
-
} \ No newline at end of file
diff --git a/core/src/kz/ilotterytea/maxon/MaxonGame.java b/core/src/kz/ilotterytea/maxon/MaxonGame.java
index f457270..2dbe324 100644
--- a/core/src/kz/ilotterytea/maxon/MaxonGame.java
+++ b/core/src/kz/ilotterytea/maxon/MaxonGame.java
@@ -6,18 +6,18 @@ import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
+import kz.ilotterytea.maxon.localization.LocalizationManager;
import kz.ilotterytea.maxon.pets.PetManager;
import kz.ilotterytea.maxon.screens.SplashScreen;
import kz.ilotterytea.maxon.utils.GameUpdater;
-import kz.ilotterytea.maxon.utils.I18N;
public class MaxonGame extends Game {
public SpriteBatch batch;
public ShapeRenderer shapeRenderer;
public AssetManager assetManager;
public Preferences prefs;
- public I18N locale;
+ private LocalizationManager locale;
private PetManager petManager;
private static MaxonGame instance;
@@ -33,6 +33,14 @@ public class MaxonGame extends Game {
return petManager;
}
+ public LocalizationManager getLocale() {
+ return locale;
+ }
+
+ public void setLocale(LocalizationManager locale) {
+ this.locale = locale;
+ }
+
@Override
public void create () {
// Check the latest version
@@ -41,7 +49,7 @@ public class MaxonGame extends Game {
batch = new SpriteBatch();
shapeRenderer = new ShapeRenderer();
prefs = Gdx.app.getPreferences(MaxonConstants.GAME_APP_PACKAGE);
- locale = new I18N(Gdx.files.internal("i18n/" + prefs.getString("lang", "en_us") + ".json"));
+ locale = new LocalizationManager(Gdx.files.internal("i18n/" + prefs.getString("lang", "en_us") + ".json"));
Gdx.graphics.setVSync(prefs.getBoolean("vsync", true));
diff --git a/core/src/kz/ilotterytea/maxon/localization/LineId.java b/core/src/kz/ilotterytea/maxon/localization/LineId.java
new file mode 100644
index 0000000..3fe2203
--- /dev/null
+++ b/core/src/kz/ilotterytea/maxon/localization/LineId.java
@@ -0,0 +1,75 @@
+package kz.ilotterytea.maxon.localization;
+
+import org.slf4j.LoggerFactory;
+
+import java.util.Locale;
+
+public enum LineId {
+ UpdaterInfo,
+
+ MenuContinue,
+ MenuReset,
+
+ GiftboxOpen,
+
+ MinigameSlotsSpinbutton,
+ MinigameSlotsExitbutton,
+ MinigameSlotsBet,
+ MinigameSlotsNothing,
+ MinigameSlotsPrize,
+
+ PetBrorName,
+ PetBrorDesc,
+ PetSandwichName,
+ PetSandwichDesc,
+ PetManlooshkaName,
+ PetManlooshkaDesc,
+ PetThirstyName,
+ PetThirstyDesc,
+ PetFuriosName,
+ PetFuriosDesc,
+ PetTvcatName,
+ PetTvcatDesc,
+ PetProgcatName,
+ PetProgcatDesc,
+ PetScreamcatName,
+ PetScreamcatDesc,
+ PetHellcatName,
+ PetHellcatDesc,
+ PetLurkerName,
+ PetLurkerDesc,
+ PetPianoName,
+ PetPianoDesc,
+ PetBeeName,
+ PetBeeDesc,
+ PetBusyName,
+ PetBusyDesc,
+ PetAeaeName,
+ PetAeaeDesc,
+ PetSuccatName,
+ PetSuccatDesc,
+ ;
+
+ public static LineId fromJson(String value) {
+ StringBuilder result = new StringBuilder();
+ String[] chunks = value.split("\\.");
+
+ for (String chunk : chunks) {
+ chunk = chunk.replace("_", "");
+
+ String firstLetter = chunk.substring(0, 1).toUpperCase(Locale.ROOT);
+ String otherPart = chunk.substring(1);
+
+ result.append(firstLetter).append(otherPart);
+ }
+
+ value = result.toString();
+
+ try {
+ return LineId.valueOf(value);
+ } catch (Exception e) {
+ LoggerFactory.getLogger(LineId.class.getName()).error("The key '{}' not registered in LineId enum", value);
+ return null;
+ }
+ }
+}
diff --git a/core/src/kz/ilotterytea/maxon/localization/LocalizationManager.java b/core/src/kz/ilotterytea/maxon/localization/LocalizationManager.java
new file mode 100644
index 0000000..afa2841
--- /dev/null
+++ b/core/src/kz/ilotterytea/maxon/localization/LocalizationManager.java
@@ -0,0 +1,70 @@
+package kz.ilotterytea.maxon.localization;
+
+import com.badlogic.gdx.files.FileHandle;
+import com.badlogic.gdx.utils.JsonReader;
+import com.badlogic.gdx.utils.JsonValue;
+import com.badlogic.gdx.utils.StringBuilder;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Scanner;
+
+public class LocalizationManager {
+ private final Map<LineId, String> lines = new HashMap<>();
+ private final FileHandle handle;
+
+ public LocalizationManager(FileHandle localizationFile) {
+ this.handle = localizationFile;
+
+ JsonValue json = new JsonReader().parse(handle);
+ for (JsonValue val : json.iterator()) {
+ LineId key = LineId.fromJson(val.name);
+ if (key == null) continue;
+ String value;
+
+ try {
+ value = json.getString(val.name);
+ } catch (Exception e) {
+ value = val.name;
+ }
+
+ lines.put(key, value);
+ }
+ }
+
+ public String getLine(LineId id) {
+ return lines.get(id);
+ }
+
+ public String getFormattedLine(LineId id, CharSequence... params) {
+ String line = this.getLine(id);
+
+ if (line == null) return null;
+
+ Scanner scanner = new Scanner(line);
+ StringBuilder result = new StringBuilder();
+ int index = 0;
+
+ while (scanner.hasNext()) {
+ String next = scanner.next();
+
+ if (next.contains("%s")) {
+ next = next.replace("%s", params[index]);
+
+ if (index + 1 < params.length) index++;
+ }
+
+ result.append(next).append(' ');
+ }
+
+ return result.substring(0, result.length - 1);
+ }
+
+ public FileHandle getHandle() {
+ return handle;
+ }
+
+ public Map<LineId, String> getLines() {
+ return lines;
+ }
+}
diff --git a/core/src/kz/ilotterytea/maxon/pets/Pet.java b/core/src/kz/ilotterytea/maxon/pets/Pet.java
index 521df0c..0106439 100644
--- a/core/src/kz/ilotterytea/maxon/pets/Pet.java
+++ b/core/src/kz/ilotterytea/maxon/pets/Pet.java
@@ -7,6 +7,7 @@ import com.badlogic.gdx.utils.GdxRuntimeException;
import kz.ilotterytea.maxon.MaxonConstants;
import kz.ilotterytea.maxon.MaxonGame;
import kz.ilotterytea.maxon.anim.SpriteUtils;
+import kz.ilotterytea.maxon.localization.LineId;
import kz.ilotterytea.maxon.ui.AnimatedImage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,12 +53,12 @@ public class Pet {
AnimatedImage icon = new AnimatedImage(regions, 5);
- String name = game.locale.TranslatableText("pet." + id + ".name");
+ String name = game.getLocale().getLine(LineId.fromJson("pet." + id + ".name"));
if (name == null) {
name = "pet." + id + ".name";
}
- String description = game.locale.TranslatableText("pet." + id + ".desc");
+ String description = game.getLocale().getLine(LineId.fromJson("pet." + id + ".desc"));
if (description == null) {
description = "pet." + id + ".desc";
}
diff --git a/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java b/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java
index 153a5bd..14dabf8 100644
--- a/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java
+++ b/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java
@@ -22,10 +22,11 @@ import com.badlogic.gdx.utils.Timer;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import kz.ilotterytea.maxon.MaxonConstants;
import kz.ilotterytea.maxon.MaxonGame;
+import kz.ilotterytea.maxon.localization.LineId;
+import kz.ilotterytea.maxon.localization.LocalizationManager;
import kz.ilotterytea.maxon.player.Savegame;
import kz.ilotterytea.maxon.ui.*;
import kz.ilotterytea.maxon.utils.GameUpdater;
-import kz.ilotterytea.maxon.utils.I18N;
import kz.ilotterytea.maxon.utils.OsUtils;
import net.mgsx.gltf.scene3d.attributes.PBRCubemapAttribute;
import net.mgsx.gltf.scene3d.attributes.PBRTextureAttribute;
@@ -235,7 +236,7 @@ public class MenuScreen implements Screen {
}, 5, 5));
// Localization
- String[] fh4Locale = game.locale.getFileHandle().nameWithoutExtension().split("_");
+ String[] fh4Locale = game.getLocale().getHandle().nameWithoutExtension().split("_");
String localeButtonStyleName = "locale_" + fh4Locale[0];
ShakingImageButton localeButton = new ShakingImageButton(widgetSkin, localeButtonStyleName);
@@ -249,13 +250,13 @@ public class MenuScreen implements Screen {
fhArray.add(MaxonConstants.FILE_RU_RU);
fhArray.add(MaxonConstants.FILE_EN_US);
- if (fhArray.indexOf(game.locale.getFileHandle()) + 1 < fhArray.size()) {
- index = fhArray.indexOf(game.locale.getFileHandle()) + 1;
+ if (fhArray.indexOf(game.getLocale().getHandle()) + 1 < fhArray.size()) {
+ index = fhArray.indexOf(game.getLocale().getHandle()) + 1;
}
FileHandle fhNext = fhArray.get(index);
- game.locale = new I18N(fhNext);
+ game.setLocale(new LocalizationManager(fhNext));
game.prefs.putString("lang", fhNext.nameWithoutExtension());
game.prefs.flush();
@@ -359,7 +360,7 @@ public class MenuScreen implements Screen {
// Suggest an update
if (!GameUpdater.CLIENT_IS_ON_LATEST_VERSION && OsUtils.isPC) {
- TextButton updateButton = new TextButton(game.locale.TranslatableText("updater.info"), uiSkin, "link");
+ TextButton updateButton = new TextButton(game.getLocale().getLine(LineId.UpdaterInfo), uiSkin, "link");
updateButton.setPosition(8f, stage.getHeight() - 32f);
diff --git a/core/src/kz/ilotterytea/maxon/screens/SlotsMinigameScreen.kt b/core/src/kz/ilotterytea/maxon/screens/SlotsMinigameScreen.kt
index 863f295..6de252f 100644
--- a/core/src/kz/ilotterytea/maxon/screens/SlotsMinigameScreen.kt
+++ b/core/src/kz/ilotterytea/maxon/screens/SlotsMinigameScreen.kt
@@ -29,6 +29,7 @@ import com.badlogic.gdx.utils.Timer.Task
import com.badlogic.gdx.utils.viewport.FitViewport
import com.badlogic.gdx.utils.viewport.ScreenViewport
import kz.ilotterytea.maxon.MaxonGame
+import kz.ilotterytea.maxon.localization.LineId
import kz.ilotterytea.maxon.player.Savegame
import kz.ilotterytea.maxon.screens.game.GameScreen
import kz.ilotterytea.maxon.utils.formatters.NumberFormatter
@@ -97,7 +98,7 @@ class SlotsMinigameScreen : Screen {
table.add(background)
// Buttons
- spinButton = TextButton(game.locale.TranslatableText("minigame.slots.spin_button"), skin)
+ spinButton = TextButton(game.locale.getLine(LineId.MinigameSlotsSpinbutton), skin)
spinButton?.isDisabled = true
spinButton?.width = 420f
spinButton?.setPosition(62f, 60f)
@@ -110,7 +111,7 @@ class SlotsMinigameScreen : Screen {
})
stage.addActor(spinButton)
- exitButton = TextButton(game.locale.TranslatableText("minigame.slots.exit_button"), skin)
+ exitButton = TextButton(game.locale.getLine(LineId.MinigameSlotsExitbutton), skin)
exitButton?.setPosition(62f, stage.height / 2f - 150f)
exitButton?.addListener(object : ClickListener() {
override fun clicked(event: InputEvent?, x: Float, y: Float) {
@@ -138,7 +139,7 @@ class SlotsMinigameScreen : Screen {
moneyLabel?.setPosition(stage.width / 2f, stage.height / 2f - 180f)
stage.addActor(moneyLabel)
- val stakeLabel = Label(game.locale.TranslatableText("minigame.slots.bet"), skin, "slots")
+ val stakeLabel = Label(game.locale.getLine(LineId.MinigameSlotsBet), skin, "slots")
stakeLabel.setAlignment(Align.center)
stakeLabel.setPosition(stage.width / 2f - 40f, stage.height / 2f - 100f)
stage.addActor(stakeLabel)
@@ -325,9 +326,9 @@ class SlotsMinigameScreen : Screen {
private fun updateLabels() {
val prizeText = if (prize == 0.0) {
- game.locale.TranslatableText("minigame.slots.nothing")
+ game.locale.getLine(LineId.MinigameSlotsNothing)
} else {
- game.locale.FormattedText("minigame.slots.prize", NumberFormatter.format(prize.toLong()))
+ game.locale.getFormattedLine(LineId.MinigameSlotsPrize, NumberFormatter.format(prize.toLong()))
}
prizeLabel?.setText(prizeText)
diff --git a/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java b/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java
index 3f8c19b..65b2dde 100644
--- a/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java
+++ b/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java
@@ -251,61 +251,6 @@ public class GameScreen implements Screen, InputProcessor {
this.shopUI.update();
}
- private void showInventory() {
- // - - - - - - I N V E N T O R Y T A B L E - - - - - - :
- final Table inventoryTable = new Table(skin);
- inventoryTable.setBackground("bg");
- inventoryTable.setSize(stage.getWidth() - 20f, stage.getHeight() - (boardTable.getHeight() + quickTable.getHeight() + 20f));
- inventoryTable.setPosition(10f, quickTable.getHeight() + 10f);
- inventoryTable.align(Align.top | Align.center);
-
- stage.addActor(inventoryTable);
-
- // Header table:
- Table headInventoryTable = new Table();
- inventoryTable.add(headInventoryTable).width(inventoryTable.getWidth()).row();
-
- // - - - S H O P T I T L E - - -:
- Label inventoryTitle = new Label(game.locale.TranslatableText("game.inventory.title"), skin);
- headInventoryTable.add(inventoryTitle).expandX();
-
- // - - - C L O S E B U T T O N - - - :
- TextButton closeButton = new TextButton("X", skin);
-
- closeButton.addListener(new ClickListener() {
- @Override
- public void clicked(InputEvent event, float x, float y) {
- inventoryTable.remove();
- isInventoryEnabled = !isInventoryEnabled;
- }
- });
-
- headInventoryTable.add(closeButton).row();
-
- // - - - I N V E N T O R Y C O N T E N T - - - :
- Table contentTable = new Table();
- contentTable.align(Align.left);
-
- // Adding items to inventory:
- for (int i = 0; i < invItems.keySet().size(); i++) {
- MaxonItem item = MaxonItemRegister.get(i);
-
- if (item != null) {
- InventoryAnimatedItem invItem = new InventoryAnimatedItem(item, skin, invItems.get(i));
- Cell<InventoryAnimatedItem> cell = contentTable.add(invItem).size(64, 64).pad(5f);
-
- if (i != 0 && i % (inventoryTable.getWidth() / 69f) == 0) {
- cell.row();
- }
- }
- };
-
- // Scroll panel for content table:
- ScrollPane contentPane = new ScrollPane(contentTable);
- contentPane.setScrollingDisabled(true, false);
- inventoryTable.add(contentPane);
- }
-
@Override public void pause() {}
@Override public void resume() {}
@@ -341,39 +286,6 @@ public class GameScreen implements Screen, InputProcessor {
return false;
}
- private void displayPointIncrease() {
- cat.nextFrame();
- maxon.setDrawable(cat.getDrawable());
-
- savegame.increaseMoney(savegame.getMultiplier());
-
- final TypingLabel label = new TypingLabel(game.locale.FormattedText("game.newPoint", MaxonConstants.DECIMAL_FORMAT.format(savegame.getMultiplier())), skin, "default");
-
- label.setPosition(
- maxon.getX(),
- maxon.getY() + maxon.getHeight()
- );
-
- label.setWidth(maxon.getWidth());
-
- label.setAlignment(Align.center);
-
- label.addAction(Actions.parallel(
- Actions.fadeOut(5f),
- Actions.moveTo(
- label.getX(), label.getY() + Math.getRandomNumber(10, 156), 5f, Interpolation.exp5Out)
- ));
-
- tasks.add(Timer.schedule(new Timer.Task() {
- @Override
- public void run() {
- label.remove();
- }
- }, 10f));
-
- stage.addActor(label);
- }
-
private void create3D() {
sceneManager = new SceneManager();
diff --git a/core/src/kz/ilotterytea/maxon/screens/game/Giftbox.java b/core/src/kz/ilotterytea/maxon/screens/game/Giftbox.java
index 83ce8ab..752d7a1 100644
--- a/core/src/kz/ilotterytea/maxon/screens/game/Giftbox.java
+++ b/core/src/kz/ilotterytea/maxon/screens/game/Giftbox.java
@@ -24,6 +24,7 @@ import kz.ilotterytea.javaextra.tuples.Triple;
import kz.ilotterytea.maxon.MaxonGame;
import kz.ilotterytea.javaextra.comparators.MapValueKeyComparator;
import kz.ilotterytea.maxon.anim.SpriteUtils;
+import kz.ilotterytea.maxon.localization.LineId;
import kz.ilotterytea.maxon.pets.Pet;
import kz.ilotterytea.maxon.pets.PetManager;
import kz.ilotterytea.maxon.player.Savegame;
@@ -302,7 +303,7 @@ public class Giftbox implements Disposable {
mainTable.add(table);
// Adding the title
- Label title = new Label(MaxonGame.getInstance().locale.TranslatableText("giftbox.open"), skin);
+ Label title = new Label(MaxonGame.getInstance().getLocale().getLine(LineId.GiftboxOpen), skin);
table.add(title).row();
String regionName;
diff --git a/core/src/kz/ilotterytea/maxon/ui/OptionsTable.java b/core/src/kz/ilotterytea/maxon/ui/OptionsTable.java
deleted file mode 100644
index 8ce0720..0000000
--- a/core/src/kz/ilotterytea/maxon/ui/OptionsTable.java
+++ /dev/null
@@ -1,180 +0,0 @@
-package kz.ilotterytea.maxon.ui;
-
-import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.audio.Music;
-import com.badlogic.gdx.files.FileHandle;
-import com.badlogic.gdx.math.Interpolation;
-import com.badlogic.gdx.scenes.scene2d.InputEvent;
-import com.badlogic.gdx.scenes.scene2d.actions.Actions;
-import com.badlogic.gdx.scenes.scene2d.ui.*;
-import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
-import com.badlogic.gdx.utils.Align;
-import kz.ilotterytea.maxon.MaxonConstants;
-import kz.ilotterytea.maxon.MaxonGame;
-import kz.ilotterytea.maxon.screens.SplashScreen;
-import kz.ilotterytea.maxon.utils.I18N;
-
-import java.util.ArrayList;
-import java.util.Locale;
-
-public class OptionsTable extends Table {
- public OptionsTable(
- final MaxonGame game,
- Skin skin,
- Skin widgetSkin,
- final Music music,
- final Table menuTable,
- final Image bgImage,
- final Image brandLogo
- ) {
- super();
-
- Label optionsLabel = new Label(game.locale.TranslatableText("options.title"), skin);
- optionsLabel.setAlignment(Align.center);
- super.add(optionsLabel).fillX().pad(81f).row();
-
- Table lidlOptionsTable = new Table();
-
- // Music button:
- final TextButton musicButton = new TextButton(game.locale.FormattedText("options.music", (game.prefs.getBoolean("music", true)) ? "ON" : "OFF"), widgetSkin, "default");
-
- musicButton.addListener(new ClickListener() {
- @Override
- public void clicked(InputEvent event, float x, float y) {
- game.prefs.putBoolean("music", !game.prefs.getBoolean("music", true));
- game.prefs.flush();
-
- if (game.prefs.getBoolean("music", true)) {
- music.setVolume(1f);
- music.setLooping(true);
- music.play();
- } else {
- music.stop();
- }
-
- musicButton.setText(game.locale.FormattedText("options.music", (game.prefs.getBoolean("music", true)) ? "ON" : "OFF"));
- }
- });
-
- lidlOptionsTable.add(musicButton).size(512f, 81f).pad(10f).left();
-
- final TextButton soundButton = new TextButton(game.locale.FormattedText("options.sound", (game.prefs.getBoolean("sound", true)) ? "ON" : "OFF"), widgetSkin, "default");
-
- soundButton.addListener(new ClickListener() {
- @Override
- public void clicked(InputEvent event, float x, float y) {
- game.prefs.putBoolean("sound", !game.prefs.getBoolean("sound", true));
- game.prefs.flush();
-
- soundButton.setText(game.locale.FormattedText("options.sound", (game.prefs.getBoolean("sound", true)) ? "ON" : "OFF"));
- }
- });
-
- lidlOptionsTable.add(soundButton).size(512f, 81f).pad(10f).right().row();
-
- final TextButton vsyncButton = new TextButton(game.locale.FormattedText("options.vsync", (game.prefs.getBoolean("vsync", true)) ? "ON" : "OFF"), widgetSkin, "default");
-
- vsyncButton.addListener(new ClickListener() {
- @Override
- public void clicked(InputEvent event, float x, float y) {
- game.prefs.putBoolean("vsync", !game.prefs.getBoolean("vsync", true));
- game.prefs.flush();
-
- if (game.prefs.getBoolean("vsync", true)) {
- Gdx.graphics.setVSync(true);
- } else {
- Gdx.graphics.setVSync(false);
- }
-
- vsyncButton.setText(game.locale.FormattedText("options.vsync", (game.prefs.getBoolean("vsync", true)) ? "ON" : "OFF"));
- }
- });
-
- lidlOptionsTable.add(vsyncButton).size(512f, 81f).pad(10f).left();
-
- final TextButton fullscreenButton = new TextButton(game.locale.FormattedText("options.fullscreen", (game.prefs.getBoolean("fullscreen", false)) ? "ON" : "OFF"), widgetSkin, "default");
-
- fullscreenButton.addListener(new ClickListener() {
- @Override
- public void clicked(InputEvent event, float x, float y) {
- game.prefs.putBoolean("fullscreen", !game.prefs.getBoolean("fullscreen", false));
- game.prefs.flush();
-
- if (game.prefs.getBoolean("fullscreen", false)) {
- Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
- } else {
- Gdx.graphics.setWindowedMode(game.prefs.getInteger("width", Gdx.graphics.getWidth()), game.prefs.getInteger("height", Gdx.graphics.getHeight()));
- }
-
- fullscreenButton.setText(game.locale.FormattedText("options.fullscreen", (game.prefs.getBoolean("fullscreen", false)) ? "ON" : "OFF"));
- }
- });
-
- lidlOptionsTable.add(fullscreenButton).size(512f, 81f).pad(10f).right().row();
-
- super.add(lidlOptionsTable).center().row();
-
- String[] fh4Locale = game.locale.getFileHandle().nameWithoutExtension().split("_");
- Locale locale = new Locale(fh4Locale[0], fh4Locale[1]);
-
- final TextButton switchLangButton = new TextButton(game.locale.FormattedText("options.language", locale.getDisplayLanguage(), locale.getDisplayCountry()), widgetSkin, "default");
-
- switchLangButton.addListener(new ClickListener() {
- @Override
- public void clicked(InputEvent event, float x, float y) {
- int index = 0;
- ArrayList<FileHandle> fhArray = new ArrayList<>();
- fhArray.add(MaxonConstants.FILE_RU_RU);
- fhArray.add(MaxonConstants.FILE_EN_US);
-
- if (fhArray.indexOf(game.locale.getFileHandle()) + 1 < fhArray.size()) {
- index = fhArray.indexOf(game.locale.getFileHandle()) + 1;
- }
-
- FileHandle fhNext = fhArray.get(index);
-
- game.locale = new I18N(fhNext);
- game.prefs.putString("lang", fhNext.nameWithoutExtension());
- game.prefs.flush();
-
- String[] fh4Locale = fhNext.nameWithoutExtension().split("_");
- Locale locale = new Locale(fh4Locale[0], fh4Locale[1]);
-
- switchLangButton.setText(game.locale.FormattedText("options.language", locale.getDisplayLanguage(), locale.getDisplayCountry()));
- game.setScreen(new SplashScreen());
- music.stop();
- }
- });
-
- super.add(switchLangButton).size(1024f, 81f).padTop(91f).center().row();
-
- final TextButton optionsCloseButton = new TextButton(game.locale.TranslatableText("options.close"), widgetSkin, "default");
-
- optionsCloseButton.addListener(new ClickListener() {
- @Override
- public void clicked(InputEvent event, float x, float y) {
- close(menuTable, bgImage, brandLogo);
- }
- });
-
- super.add(optionsCloseButton).size(1024f, 81f).pad(91f).center().row();
-
- super.setPosition(0, 0);
- super.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
- }
-
- private void close(Table menu, Image bg, Image logo) {
- super.clearActions();
- super.addAction(Actions.moveTo(Gdx.graphics.getWidth(), super.getY(), 0.75f, Interpolation.sine));
-
- menu.clearActions();
- menu.addAction(Actions.moveTo(0, menu.getY(), 0.75f, Interpolation.sine));
-
- bg.clearActions();
- bg.addAction(Actions.alpha(0.25f));
-
- logo.addAction(
- Actions.moveTo(logo.getX(), logo.getY() - 512f, 0.5f, Interpolation.sine)
- );
- }
-}
diff --git a/core/src/kz/ilotterytea/maxon/ui/SavegameWidget.java b/core/src/kz/ilotterytea/maxon/ui/SavegameWidget.java
index ea6587c..245e11f 100644
--- a/core/src/kz/ilotterytea/maxon/ui/SavegameWidget.java
+++ b/core/src/kz/ilotterytea/maxon/ui/SavegameWidget.java
@@ -12,6 +12,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Disposable;
import kz.ilotterytea.maxon.MaxonGame;
+import kz.ilotterytea.maxon.localization.LineId;
import kz.ilotterytea.maxon.player.Savegame;
import kz.ilotterytea.maxon.screens.game.GameScreen;
import kz.ilotterytea.maxon.screens.WelcomeScreen;
@@ -128,7 +129,7 @@ public class SavegameWidget extends Table implements Disposable {
this.dataTable.add(data).grow();
// - - - C O N T R O L - - -
- TextButton playButton = new TextButton(game.locale.TranslatableText("menu.continue"), skin, styleName);
+ TextButton playButton = new TextButton(game.getLocale().getLine(LineId.MenuContinue), skin, styleName);
playButton.addListener(new ClickListener() {
@Override
@@ -139,7 +140,7 @@ public class SavegameWidget extends Table implements Disposable {
}
});
- TextButton resetButton = new TextButton(game.locale.TranslatableText("menu.reset"), skin, styleName);
+ TextButton resetButton = new TextButton(game.getLocale().getLine(LineId.MenuReset), skin, styleName);
resetButton.addListener(new ClickListener() {
@Override
diff --git a/core/src/kz/ilotterytea/maxon/utils/I18N.java b/core/src/kz/ilotterytea/maxon/utils/I18N.java
deleted file mode 100644
index 7d4013e..0000000
--- a/core/src/kz/ilotterytea/maxon/utils/I18N.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package kz.ilotterytea.maxon.utils;
-
-import com.badlogic.gdx.files.FileHandle;
-import com.badlogic.gdx.utils.JsonReader;
-import com.badlogic.gdx.utils.JsonValue;
-
-import java.lang.StringBuilder;
-import java.util.*;
-
-public class I18N {
- private Map<String, String> language = new HashMap<>();
- private FileHandle fileHandle;
-
- public I18N(FileHandle fh) {
- fileHandle = fh;
-
- JsonValue json = new JsonReader().parse(fileHandle);
-
- for (JsonValue val : json.iterator()) {
- this.language.put(val.name, json.getString(val.name));
- }
- }
-
- public FileHandle getFileHandle() { return fileHandle; }
- public Map<String, String> getLanguage() { return language; }
-
- public String TranslatableText(String id) {
- if (language.containsKey(id)) {
- return language.get(id);
- }
- return null;
- }
-
- public String FormattedText(String id, CharSequence... params) {
- if (!language.containsKey(id)) { return null; }
- Scanner scan = new Scanner(language.get(id));
- StringBuilder result = new StringBuilder();
- int index = 0;
-
- while (scan.hasNext()) {
- String next = scan.next();
-
- if (next.contains("%s")) {
- next = next.replace("%s", params[index]);
- if (index + 1 < params.length) { index++; }
- }
-
- result.append(next).append(' ');
- }
-
- return result.toString();
- }
-}