summaryrefslogtreecommitdiff
path: root/core/src/kz/ilotterytea/maxon/ui
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-10-25 12:16:44 +0500
committerilotterytea <iltsu@alright.party>2024-10-25 12:16:44 +0500
commit354e2876e93bf45ca6b748e9eb23093fe9bffaa6 (patch)
tree8637b646a6176b4808695d714443839c2624a961 /core/src/kz/ilotterytea/maxon/ui
parentf416c899aa619b21fad2f96f5f5a4475024557db (diff)
feat: LocalizationManager + removed unused lines and classes
Diffstat (limited to 'core/src/kz/ilotterytea/maxon/ui')
-rw-r--r--core/src/kz/ilotterytea/maxon/ui/OptionsTable.java180
-rw-r--r--core/src/kz/ilotterytea/maxon/ui/SavegameWidget.java5
2 files changed, 3 insertions, 182 deletions
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