diff options
| author | ilotterytea <iltsu@alright.party> | 2024-11-10 21:02:17 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-11-10 21:02:17 +0500 |
| commit | 34f3b60afdc7d6934cf45d990bead9d90f1380f9 (patch) | |
| tree | 347e5ae8c2eee910a84a6368e82f1082312e020e /core | |
| parent | 9534ea1bdfe588c653be91f139bfc7457a108801 (diff) | |
upd: name for music and sfx in settings
Diffstat (limited to 'core')
10 files changed, 24 insertions, 24 deletions
diff --git a/core/src/kz/ilotterytea/maxon/MaxonGame.java b/core/src/kz/ilotterytea/maxon/MaxonGame.java index f2c0bad..63de3e8 100644 --- a/core/src/kz/ilotterytea/maxon/MaxonGame.java +++ b/core/src/kz/ilotterytea/maxon/MaxonGame.java @@ -80,14 +80,6 @@ public class MaxonGame extends Game { Gdx.graphics.setWindowedMode(width, height); } - // Compatibility with old settings file - try { - int x = prefs.getInteger("music"); - } catch (Exception ignored) { - prefs.putInteger("music", prefs.getBoolean("music") ? 10 : 0); - prefs.flush(); - } - assetManager = new AssetManager(); petManager = new PetManager(assetManager); diff --git a/core/src/kz/ilotterytea/maxon/constants/SettingsConstants.java b/core/src/kz/ilotterytea/maxon/constants/SettingsConstants.java index 3eb2c98..e1654d5 100644 --- a/core/src/kz/ilotterytea/maxon/constants/SettingsConstants.java +++ b/core/src/kz/ilotterytea/maxon/constants/SettingsConstants.java @@ -3,4 +3,7 @@ package kz.ilotterytea.maxon.constants; public class SettingsConstants { public static Float UI_MAX_SCALE = 1.5f; public static Float UI_DEFAULT_SCALE = 1f; + + public static String MUSIC_NAME = "musicVolume"; + public static String SFX_NAME = "sfxVolume"; } diff --git a/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java b/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java index 054ca4e..43dfbca 100644 --- a/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java +++ b/core/src/kz/ilotterytea/maxon/screens/MenuScreen.java @@ -74,7 +74,7 @@ public class MenuScreen implements Screen { menuMusic.setLooping(true); clickSound = game.assetManager.get("sfx/ui/click.ogg", Sound.class); - soundVolume = game.prefs.getInteger("sfx", 10) / 10f; + soundVolume = game.prefs.getInteger(SettingsConstants.SFX_NAME, 10) / 10f; // - - - - - - U I - - - - - - float iconSize = (OsUtils.isMobile ? 256f : 64f) * game.prefs.getFloat("guiScale", SettingsConstants.UI_DEFAULT_SCALE); @@ -230,10 +230,10 @@ public class MenuScreen implements Screen { }); // Music button - menuMusic.setVolume(game.prefs.getInteger("music", 10) / 10f); + menuMusic.setVolume(game.prefs.getInteger(SettingsConstants.MUSIC_NAME, 10) / 10f); String musicButtonStyleName; - if (OsUtils.isPC || game.prefs.getInteger("music", 10) > 0) { + if (OsUtils.isPC || game.prefs.getInteger(SettingsConstants.MUSIC_NAME, 10) > 0) { musicButtonStyleName = "music_on"; menuMusic.play(); } else { @@ -253,7 +253,7 @@ public class MenuScreen implements Screen { } String style; - int v = game.prefs.getInteger("music", 10); + int v = game.prefs.getInteger(SettingsConstants.MUSIC_NAME, 10); if (v > 0) { style = "music_off"; @@ -263,7 +263,7 @@ public class MenuScreen implements Screen { menuMusic.play(); } - game.prefs.putInteger("music", game.prefs.getInteger("music", 10) > 0 ? 0 : 10); + game.prefs.putInteger(SettingsConstants.MUSIC_NAME, game.prefs.getInteger(SettingsConstants.MUSIC_NAME, 10) > 0 ? 0 : 10); game.prefs.flush(); musicButton.setDrawable(widgetSkin, style); @@ -516,7 +516,7 @@ public class MenuScreen implements Screen { public void changed(ChangeEvent event, Actor actor) { if (actor instanceof Slider s) { int v = (int) s.getValue(); - game.prefs.putInteger(sliderName, v); + game.prefs.putInteger(sliderName + "Volume", v); game.prefs.flush(); switch (sliderName) { @@ -535,7 +535,7 @@ public class MenuScreen implements Screen { } }); - int value = game.prefs.getInteger(sliderName, 10); + int value = game.prefs.getInteger(sliderName + "Volume", 10); if (value > 10) value = 10; else if (value < 0) value = 0; diff --git a/core/src/kz/ilotterytea/maxon/screens/SlotsMinigameScreen.java b/core/src/kz/ilotterytea/maxon/screens/SlotsMinigameScreen.java index ce564e5..0ea6c5d 100644 --- a/core/src/kz/ilotterytea/maxon/screens/SlotsMinigameScreen.java +++ b/core/src/kz/ilotterytea/maxon/screens/SlotsMinigameScreen.java @@ -242,8 +242,8 @@ public class SlotsMinigameScreen implements Screen { audioLoop = game.assetManager.get("mus/minigames/slots/slots_loop.mp3"); audioLoop.setLooping(true); - audioLoop.setVolume(game.prefs.getInteger("music", 10) / 10f); - soundVolume = game.prefs.getInteger("sfx", 10) / 10f; + audioLoop.setVolume(game.prefs.getInteger(SettingsConstants.MUSIC_NAME, 10) / 10f); + soundVolume = game.prefs.getInteger(SettingsConstants.SFX_NAME, 10) / 10f; Timer.schedule(multiplierTask, 0.1f, 0.1f); diff --git a/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java b/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java index bdc2f8d..3bea785 100644 --- a/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java +++ b/core/src/kz/ilotterytea/maxon/screens/game/GameScreen.java @@ -19,6 +19,7 @@ import com.badlogic.gdx.utils.viewport.ScreenViewport; import kz.ilotterytea.maxon.MaxonGame; import kz.ilotterytea.maxon.anim.SpriteUtils; import kz.ilotterytea.maxon.audio.Playlist; +import kz.ilotterytea.maxon.constants.SettingsConstants; import kz.ilotterytea.maxon.inputprocessors.CrossProcessor; import kz.ilotterytea.maxon.pets.Pet; import kz.ilotterytea.maxon.pets.PetManager; @@ -91,7 +92,7 @@ public class GameScreen implements Screen, InputProcessor { game.assetManager.get("mus/game/shopping_spree.mp3", Music.class) ); playlist.setShuffleMode(true); - playlist.setVolume(game.prefs.getInteger("music", 10) / 10f); + playlist.setVolume(game.prefs.getInteger(SettingsConstants.MUSIC_NAME, 10) / 10f); playlist.next(); createStageUI(); diff --git a/core/src/kz/ilotterytea/maxon/screens/game/Giftbox.java b/core/src/kz/ilotterytea/maxon/screens/game/Giftbox.java index d79bfb1..d676709 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.constants.SettingsConstants; import kz.ilotterytea.maxon.localization.LineId; import kz.ilotterytea.maxon.pets.Pet; import kz.ilotterytea.maxon.pets.PetManager; @@ -96,12 +97,12 @@ public class Giftbox implements Disposable { this.openedSound = assetManager.get("sfx/giftbox/giftbox_click.ogg"); } - this.soundVolume = MaxonGame.getInstance().prefs.getInteger("sfx", 10) / 10f; + this.soundVolume = MaxonGame.getInstance().prefs.getInteger(SettingsConstants.SFX_NAME, 10) / 10f; this.openedMusic = assetManager.get("mus/giftbox/giftbox_opened.mp3"); openedMusic.setLooping(true); - float musicVolume = MaxonGame.getInstance().prefs.getInteger("music", 10) / 10f; + float musicVolume = MaxonGame.getInstance().prefs.getInteger(SettingsConstants.MUSIC_NAME, 10) / 10f; openedMusic.setVolume(musicVolume); this.boxPosition = new Vector3(3.3f, 0f, 0.4f); diff --git a/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopMerchant.java b/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopMerchant.java index 85c2bbe..294514c 100644 --- a/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopMerchant.java +++ b/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopMerchant.java @@ -11,6 +11,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.utils.Align; import kz.ilotterytea.maxon.MaxonGame; import kz.ilotterytea.maxon.anim.SpriteUtils; +import kz.ilotterytea.maxon.constants.SettingsConstants; import kz.ilotterytea.maxon.ui.AnimatedImage; import kz.ilotterytea.maxon.utils.OsUtils; @@ -51,7 +52,7 @@ public class ShopMerchant extends Stack { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); - sound.play(game.prefs.getInteger("sfx", 10) / 10f); + sound.play(game.prefs.getInteger(SettingsConstants.SFX_NAME, 10) / 10f); } }); } diff --git a/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopUI.java b/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopUI.java index 8189eb7..8d4291d 100644 --- a/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopUI.java +++ b/core/src/kz/ilotterytea/maxon/screens/game/shop/ShopUI.java @@ -9,6 +9,7 @@ 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.MaxonGame; +import kz.ilotterytea.maxon.constants.SettingsConstants; import kz.ilotterytea.maxon.localization.LineId; import kz.ilotterytea.maxon.pets.Pet; import kz.ilotterytea.maxon.pets.PetWidget; @@ -51,7 +52,7 @@ public class ShopUI { this.notEnoughMoneySound = game.assetManager.get("sfx/shop/not_enough_money.ogg", Sound.class); this.purchaseSound = game.assetManager.get("sfx/shop/purchase.ogg", Sound.class); this.sellSound = game.assetManager.get("sfx/shop/sell.ogg", Sound.class); - this.soundVolume = game.prefs.getInteger("sfx", 10) / 10f; + this.soundVolume = game.prefs.getInteger(SettingsConstants.SFX_NAME, 10) / 10f; this.stageWidth = stage.getWidth(); diff --git a/core/src/kz/ilotterytea/maxon/ui/SavegameWidget.java b/core/src/kz/ilotterytea/maxon/ui/SavegameWidget.java index 643a963..cb02dec 100644 --- a/core/src/kz/ilotterytea/maxon/ui/SavegameWidget.java +++ b/core/src/kz/ilotterytea/maxon/ui/SavegameWidget.java @@ -11,6 +11,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.constants.SettingsConstants; import kz.ilotterytea.maxon.localization.LineId; import kz.ilotterytea.maxon.player.Savegame; import kz.ilotterytea.maxon.screens.game.GameScreen; @@ -37,7 +38,7 @@ public class SavegameWidget extends Table implements Disposable { this.stage = stage; this.atlas = game.assetManager.get("sprites/gui/player_icons.atlas", TextureAtlas.class); this.clickSound = game.assetManager.get("sfx/ui/click.ogg", Sound.class); - this.soundVolume = game.prefs.getInteger("sfx", 10) / 10f; + this.soundVolume = game.prefs.getInteger(SettingsConstants.SFX_NAME, 10) / 10f; this.skin = skin; this.savegame = savegame; diff --git a/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.java b/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.java index 1940d65..687b910 100644 --- a/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.java +++ b/core/src/kz/ilotterytea/maxon/ui/game/QuickActionsTable.java @@ -23,7 +23,7 @@ public class QuickActionsTable extends Table { MaxonGame game = MaxonGame.getInstance(); Sound clickSound = game.assetManager.get("sfx/ui/click.ogg"); - float soundVolume = game.prefs.getInteger("sfx", 10) / 10f; + float soundVolume = game.prefs.getInteger(SettingsConstants.SFX_NAME, 10) / 10f; float iconSize = (OsUtils.isMobile ? 256f : 64f) * game.prefs.getFloat("guiScale", SettingsConstants.UI_DEFAULT_SCALE); |
