diff options
| author | ilotterytea <iltsu@alright.party> | 2024-10-25 12:16:44 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-10-25 12:16:44 +0500 |
| commit | 354e2876e93bf45ca6b748e9eb23093fe9bffaa6 (patch) | |
| tree | 8637b646a6176b4808695d714443839c2624a961 /core/src/kz/ilotterytea/maxon/screens | |
| parent | f416c899aa619b21fad2f96f5f5a4475024557db (diff) | |
feat: LocalizationManager + removed unused lines and classes
Diffstat (limited to 'core/src/kz/ilotterytea/maxon/screens')
4 files changed, 15 insertions, 100 deletions
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; |
