diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java index 8832a3751..35d54fb59 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Dungeon.java @@ -183,7 +183,7 @@ public class Dungeon { public static void init() { version = Game.versionCode; - challenges = ShatteredPixelDungeon.challenges(); + challenges = SPDSettings.challenges(); seed = DungeonSeed.randomSeed(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDSettings.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDSettings.java index 273e189bc..e5b4bc9b3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDSettings.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDSettings.java @@ -21,30 +21,241 @@ package com.shatteredpixel.shatteredpixeldungeon; +import com.shatteredpixel.shatteredpixeldungeon.messages.Languages; +import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; +import com.watabou.noosa.Game; +import com.watabou.noosa.RenderedText; +import com.watabou.noosa.audio.Music; +import com.watabou.noosa.audio.Sample; import com.watabou.utils.GameSettings; +import java.util.Locale; + public class SPDSettings extends GameSettings { + //Version info + + public static final String KEY_VERSION = "version"; + + public static void version( int value) { + put( KEY_VERSION, value ); + } + + public static int version() { + return getInt( KEY_VERSION, 0 ); + } + + //Graphics + + public static final String KEY_FULLSCREEN = "fullscreen"; public static final String KEY_LANDSCAPE = "landscape"; - public static final String KEY_IMMERSIVE = "immersive"; public static final String KEY_POWER_SAVER = "power_saver"; public static final String KEY_SCALE = "scale"; - public static final String KEY_MUSIC = "music"; - public static final String KEY_MUSIC_VOL = "music_vol"; - public static final String KEY_SOUND_FX = "soundfx"; - public static final String KEY_SFX_VOL = "sfx_vol"; public static final String KEY_ZOOM = "zoom"; - public static final String KEY_LAST_CLASS = "last_class"; - public static final String KEY_CHALLENGES = "challenges"; + public static final String KEY_BRIGHTNESS = "brightness"; + public static final String KEY_GRID = "visual_grid"; + + public static void fullscreen( boolean value ) { + put( KEY_FULLSCREEN, value ); + + ShatteredPixelDungeon.instance.runOnUiThread( new Runnable() { + @Override + public void run() { + ShatteredPixelDungeon.updateSystemUI(); + } + } ); + } + + public static boolean fullscreen() { + return getBoolean( KEY_FULLSCREEN, false ); + } + + public static void landscape( boolean value ){ + put( KEY_LANDSCAPE, value ); + ((ShatteredPixelDungeon)ShatteredPixelDungeon.instance).updateDisplaySize(); + } + + public static boolean landscape() { + return getBoolean(KEY_LANDSCAPE, Game.dispWidth > Game.dispHeight); + } + + public static void powerSaver( boolean value ){ + put( KEY_POWER_SAVER, value ); + ((ShatteredPixelDungeon)ShatteredPixelDungeon.instance).updateDisplaySize(); + } + + public static boolean powerSaver(){ + return getBoolean( KEY_POWER_SAVER, false ); + } + + public static void scale( int value ) { + put( KEY_SCALE, value ); + } + + public static int scale() { + return getInt( KEY_SCALE, 0 ); + } + + public static void zoom( int value ) { + put( KEY_ZOOM, value ); + } + + public static int zoom() { + return getInt( KEY_ZOOM, 0 ); + } + + public static void brightness( int value ) { + put( KEY_BRIGHTNESS, value ); + GameScene.updateFog(); + } + + public static int brightness() { + return getInt( KEY_BRIGHTNESS, 0, -2, 2 ); + } + + public static void visualGrid( int value ){ + put( KEY_GRID, value ); + GameScene.updateMap(); + } + + public static int visualGrid() { + return getInt( KEY_GRID, 0, -1, 3 ); + } + + //Interface + public static final String KEY_QUICKSLOTS = "quickslots"; public static final String KEY_FLIPTOOLBAR = "flipped_ui"; public static final String KEY_FLIPTAGS = "flip_tags"; public static final String KEY_BARMODE = "toolbar_mode"; - public static final String KEY_LANG = "language"; - public static final String KEY_CLASSICFONT = "classic_font"; + + public static void quickSlots( int value ){ put( KEY_QUICKSLOTS, value ); } + + public static int quickSlots(){ return getInt( KEY_QUICKSLOTS, 4, 0, 4); } + + public static void flipToolbar( boolean value) { + put(KEY_FLIPTOOLBAR, value ); + } + + public static boolean flipToolbar(){ return getBoolean(KEY_FLIPTOOLBAR, false); } + + public static void flipTags( boolean value) { + put(KEY_FLIPTAGS, value ); + } + + public static boolean flipTags(){ return getBoolean(KEY_FLIPTAGS, false); } + + public static void toolbarMode( String value ) { + put( KEY_BARMODE, value ); + } + + public static String toolbarMode() { + return getString(KEY_BARMODE, !SPDSettings.landscape() ? "SPLIT" : "GROUP"); + } + + //Game State + + public static final String KEY_LAST_CLASS = "last_class"; + public static final String KEY_CHALLENGES = "challenges"; public static final String KEY_INTRO = "intro"; - public static final String KEY_BRIGHTNESS = "brightness"; - public static final String KEY_GRID = "visual_grid"; - public static final String KEY_VERSION = "version"; + + public static void intro( boolean value ) { + put( KEY_INTRO, value ); + } + + public static boolean intro() { + return getBoolean( KEY_INTRO, true ); + } + + public static void lastClass( int value ) { + put( KEY_LAST_CLASS, value ); + } + + public static int lastClass() { + return getInt( KEY_LAST_CLASS, 0, 0, 3 ); + } + + public static void challenges( int value ) { + put( KEY_CHALLENGES, value ); + } + + public static int challenges() { + return getInt( KEY_CHALLENGES, 0, 0, Challenges.MAX_VALUE ); + } + + //Audio + + public static final String KEY_MUSIC = "music"; + public static final String KEY_MUSIC_VOL = "music_vol"; + public static final String KEY_SOUND_FX = "soundfx"; + public static final String KEY_SFX_VOL = "sfx_vol"; + + public static void music( boolean value ) { + Music.INSTANCE.enable( value ); + put( KEY_MUSIC, value ); + } + + public static boolean music() { + return getBoolean( KEY_MUSIC, true ); + } + + public static void musicVol( int value ){ + Music.INSTANCE.volume(value/10f); + put( KEY_MUSIC_VOL, value ); + } + + public static int musicVol(){ + return getInt( KEY_MUSIC_VOL, 10, 0, 10 ); + } + + public static void soundFx( boolean value ) { + Sample.INSTANCE.enable( value ); + put( KEY_SOUND_FX, value ); + } + + public static boolean soundFx() { + return getBoolean( KEY_SOUND_FX, true ); + } + + public static void SFXVol( int value ) { + Sample.INSTANCE.volume(value/10f); + put( KEY_SFX_VOL, value ); + } + + public static int SFXVol() { + return getInt( KEY_SFX_VOL, 10, 0, 10 ); + } + + //Languages and Font + + public static final String KEY_LANG = "language"; + public static final String KEY_SYSTEMFONT = "system_font"; + + public static void language(Languages lang) { + put( KEY_LANG, lang.code()); + } + + public static Languages language() { + String code = getString(KEY_LANG, null); + if (code == null){ + return Languages.matchLocale(Locale.getDefault()); + } else { + return Languages.matchCode(code); + } + } + + public static void systemFont(boolean value){ + put(KEY_SYSTEMFONT, value); + if (!value) { + RenderedText.setFont("pixelfont.ttf"); + } else { + RenderedText.setFont( null ); + } + } + + public static boolean systemFont(){ + return getBoolean(KEY_SYSTEMFONT, + (language() == Languages.KOREAN || language() == Languages.CHINESE)); + } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java index 3f4e3337a..e6b5e02d6 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java @@ -24,7 +24,6 @@ package com.shatteredpixel.shatteredpixeldungeon; import android.content.pm.ActivityInfo; import android.os.Build; import android.os.Bundle; -import android.util.DisplayMetrics; import android.util.Log; import android.view.View; import android.view.WindowManager; @@ -39,8 +38,6 @@ import com.watabou.noosa.audio.Music; import com.watabou.noosa.audio.Sample; import com.watabou.utils.DeviceCompat; -import java.util.Locale; - import javax.microedition.khronos.opengles.GL10; public class ShatteredPixelDungeon extends Game { @@ -139,25 +136,12 @@ public class ShatteredPixelDungeon extends Game { super.onCreate(savedInstanceState); updateSystemUI(); + SPDSettings.landscape ( SPDSettings.landscape() ); - if (SPDSettings.contains( SPDSettings.KEY_LANDSCAPE )){ - landscape ( SPDSettings.getBoolean( SPDSettings.KEY_LANDSCAPE, false)); - - } else { - DisplayMetrics metrics = new DisplayMetrics(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) - getWindowManager().getDefaultDisplay().getRealMetrics( metrics ); - else - getWindowManager().getDefaultDisplay().getMetrics( metrics ); - boolean landscape = metrics.widthPixels > metrics.heightPixels; - - landscape( landscape ); - } - - Music.INSTANCE.enable( music() ); - Music.INSTANCE.volume( musicVol()/10f ); - Sample.INSTANCE.enable( soundFx() ); - Sample.INSTANCE.volume( SFXVol()/10f ); + Music.INSTANCE.enable( SPDSettings.music() ); + Music.INSTANCE.volume( SPDSettings.musicVol()/10f ); + Sample.INSTANCE.enable( SPDSettings.soundFx() ); + Sample.INSTANCE.volume( SPDSettings.SFXVol()/10f ); Music.setMuteListener(); @@ -211,7 +195,7 @@ public class ShatteredPixelDungeon extends Game { Assets.SND_DEGRADE, Assets.SND_MIMIC ); - if (classicFont()) { + if (!SPDSettings.systemFont()) { RenderedText.setFont("pixelfont.ttf"); } else { RenderedText.setFont( null ); @@ -239,47 +223,6 @@ public class ShatteredPixelDungeon extends Game { switchScene( c, callback ); } - /* - * ---> Settings - */ - - //TODO migrate some of these to SPDSettings, no reason to clutter up Shattered Pixel Dungeon - - public static void landscape( boolean value ) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { - Game.instance.setRequestedOrientation(value ? - ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : - ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); - } else { - Game.instance.setRequestedOrientation(value ? - ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : - ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); - } - SPDSettings.put( SPDSettings.KEY_LANDSCAPE, value ); - ((ShatteredPixelDungeon)instance).updateDisplaySize(); - } - - public static boolean landscape() { - return width > height; - } - - public static void scale( int value ) { - SPDSettings.put( SPDSettings.KEY_SCALE, value ); - } - - public static void immerse( boolean value ) { - SPDSettings.put( SPDSettings.KEY_IMMERSIVE, value ); - - instance.runOnUiThread( new Runnable() { - @Override - public void run() { - updateSystemUI(); - //ensures surfacechanged is called if the view was previously set to be fixed. - ((ShatteredPixelDungeon)instance).view.getHolder().setSizeFromLayout(); - } - } ); - } - @Override public void onSurfaceChanged( GL10 gl, int width, int height ) { @@ -289,7 +232,21 @@ public class ShatteredPixelDungeon extends Game { } - private void updateDisplaySize(){ + public void updateDisplaySize(){ + boolean landscape = SPDSettings.landscape(); + + if (landscape != (width > height)) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { + instance.setRequestedOrientation(landscape ? + ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : + ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); + } else { + instance.setRequestedOrientation(landscape ? + ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : + ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + } + } + if (view.getMeasuredWidth() == 0 || view.getMeasuredHeight() == 0) return; @@ -305,7 +262,7 @@ public class ShatteredPixelDungeon extends Game { if (dispWidth < renderWidth*2 || dispHeight < renderHeight*2) SPDSettings.put( SPDSettings.KEY_POWER_SAVER, true ); - if (powerSaver()){ + if (SPDSettings.powerSaver()){ int maxZoom = (int)Math.min(dispWidth/renderWidth, dispHeight/renderHeight); @@ -354,7 +311,7 @@ public class ShatteredPixelDungeon extends Game { } if (DeviceCompat.supportsFullScreen()){ - if (fullscreen && immersed()) { + if (fullscreen && SPDSettings.fullscreen()) { instance.getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | @@ -368,170 +325,6 @@ public class ShatteredPixelDungeon extends Game { } - public static boolean immersed() { - return SPDSettings.getBoolean( SPDSettings.KEY_IMMERSIVE, false ); - } - - public static boolean powerSaver(){ - return SPDSettings.getBoolean( SPDSettings.KEY_POWER_SAVER, false ); - } - - public static void powerSaver( boolean value ){ - SPDSettings.put( SPDSettings.KEY_POWER_SAVER, value ); - ((ShatteredPixelDungeon)instance).updateDisplaySize(); - } - - public static int scale() { - return SPDSettings.getInt( SPDSettings.KEY_SCALE, 0 ); - } - - public static void zoom( int value ) { - SPDSettings.put( SPDSettings.KEY_ZOOM, value ); - } - - public static int zoom() { - return SPDSettings.getInt( SPDSettings.KEY_ZOOM, 0 ); - } - - public static void music( boolean value ) { - Music.INSTANCE.enable( value ); - SPDSettings.put( SPDSettings.KEY_MUSIC, value ); - } - - public static boolean music() { - return SPDSettings.getBoolean( SPDSettings.KEY_MUSIC, true ); - } - - public static void musicVol( int value ){ - SPDSettings.put( SPDSettings.KEY_MUSIC_VOL, value ); - } - - public static int musicVol(){ - return SPDSettings.getInt( SPDSettings.KEY_MUSIC_VOL, 10, 0, 10 ); - } - - public static void soundFx( boolean value ) { - Sample.INSTANCE.enable( value ); - SPDSettings.put( SPDSettings.KEY_SOUND_FX, value ); - } - - public static boolean soundFx() { - return SPDSettings.getBoolean( SPDSettings.KEY_SOUND_FX, true ); - } - - public static void SFXVol( int value ) { - SPDSettings.put( SPDSettings.KEY_SFX_VOL, value ); - } - - public static int SFXVol() { - return SPDSettings.getInt( SPDSettings.KEY_SFX_VOL, 10, 0, 10 ); - } - - public static void brightness( int value ) { - SPDSettings.put( SPDSettings.KEY_BRIGHTNESS, value ); - GameScene.updateFog(); - } - - public static int brightness() { - return SPDSettings.getInt( SPDSettings.KEY_BRIGHTNESS, 0, -2, 2 ); - } - - public static void visualGrid( int value ){ - SPDSettings.put( SPDSettings.KEY_GRID, value ); - GameScene.updateMap(); - } - - public static int visualGrid() { - return SPDSettings.getInt( SPDSettings.KEY_GRID, 0, -1, 3 ); - } - - public static void language(Languages lang) { - SPDSettings.put( SPDSettings.KEY_LANG, lang.code()); - } - - public static Languages language() { - String code = SPDSettings.getString(SPDSettings.KEY_LANG, null); - if (code == null){ - return Languages.matchLocale(Locale.getDefault()); - } else { - return Languages.matchCode(code); - } - } - - public static void classicFont(boolean classic){ - SPDSettings.put(SPDSettings.KEY_CLASSICFONT, classic); - if (classic) { - RenderedText.setFont("pixelfont.ttf"); - } else { - RenderedText.setFont( null ); - } - } - - public static boolean classicFont(){ - return SPDSettings.getBoolean(SPDSettings.KEY_CLASSICFONT, - (language() != Languages.KOREAN && language() != Languages.CHINESE)); - } - - public static void lastClass( int value ) { - SPDSettings.put( SPDSettings.KEY_LAST_CLASS, value ); - } - - public static int lastClass() { - return SPDSettings.getInt( SPDSettings.KEY_LAST_CLASS, 0, 0, 3 ); - } - - public static void challenges( int value ) { - SPDSettings.put( SPDSettings.KEY_CHALLENGES, value ); - } - - public static int challenges() { - return SPDSettings.getInt( SPDSettings.KEY_CHALLENGES, 0, 0, Challenges.MAX_VALUE ); - } - - public static void quickSlots( int value ){ SPDSettings.put( SPDSettings.KEY_QUICKSLOTS, value ); } - - public static int quickSlots(){ return SPDSettings.getInt( SPDSettings.KEY_QUICKSLOTS, 4, 0, 4); } - - public static void flipToolbar( boolean value) { - SPDSettings.put(SPDSettings.KEY_FLIPTOOLBAR, value ); - } - - public static boolean flipToolbar(){ return SPDSettings.getBoolean(SPDSettings.KEY_FLIPTOOLBAR, false); } - - public static void flipTags( boolean value) { - SPDSettings.put(SPDSettings.KEY_FLIPTAGS, value ); - } - - public static boolean flipTags(){ return SPDSettings.getBoolean(SPDSettings.KEY_FLIPTAGS, false); } - - public static void toolbarMode( String value ) { - SPDSettings.put( SPDSettings.KEY_BARMODE, value ); - } - - public static String toolbarMode() { - return SPDSettings.getString(SPDSettings.KEY_BARMODE, !landscape() ? "SPLIT" : "GROUP"); - } - - public static void intro( boolean value ) { - SPDSettings.put( SPDSettings.KEY_INTRO, value ); - } - - public static boolean intro() { - return SPDSettings.getBoolean( SPDSettings.KEY_INTRO, true ); - } - - public static void version( int value) { - SPDSettings.put( SPDSettings.KEY_VERSION, value ); - } - - public static int version() { - return SPDSettings.getInt( SPDSettings.KEY_VERSION, 0 ); - } - - /* - * <--- Settings - */ - public static void reportException( Throwable tr ) { Log.e("PD", Log.getStackTraceString(tr)); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/messages/Messages.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/messages/Messages.java index d08a29adf..ece1716f7 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/messages/Messages.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/messages/Messages.java @@ -21,6 +21,7 @@ package com.shatteredpixel.shatteredpixeldungeon.messages; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.watabou.utils.DeviceCompat; @@ -73,7 +74,7 @@ public class Messages { }; static{ - setup(ShatteredPixelDungeon.language()); + setup(SPDSettings.language()); } public static void setup( Languages lang ){ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/AboutScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/AboutScene.java index 81f4df8ea..fe62d0a7d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/AboutScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/AboutScene.java @@ -23,6 +23,8 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes; import android.content.Intent; import android.net.Uri; + +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.effects.Flare; import com.shatteredpixel.shatteredpixeldungeon.ui.Archs; @@ -58,9 +60,9 @@ public class AboutScene extends PixelScene { public void create() { super.create(); - final float colWidth = Camera.main.width / (ShatteredPixelDungeon.landscape() ? 2 : 1); - final float colTop = (Camera.main.height / 2) - (ShatteredPixelDungeon.landscape() ? 30 : 90); - final float wataOffset = ShatteredPixelDungeon.landscape() ? colWidth : 0; + final float colWidth = Camera.main.width / (SPDSettings.landscape() ? 2 : 1); + final float colTop = (Camera.main.height / 2) - (SPDSettings.landscape() ? 30 : 90); + final float wataOffset = SPDSettings.landscape() ? colWidth : 0; Image shpx = Icons.SHPX.get(); shpx.x = (colWidth - shpx.width()) / 2; @@ -104,7 +106,7 @@ public class AboutScene extends PixelScene { Image wata = Icons.WATA.get(); wata.x = wataOffset + (colWidth - wata.width()) / 2; - wata.y = ShatteredPixelDungeon.landscape() ? + wata.y = SPDSettings.landscape() ? colTop: shpxlink.top() + wata.height + 20; align(wata); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/BadgesScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/BadgesScene.java index 993e71f9d..710ea4d3c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/BadgesScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/BadgesScene.java @@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Badges; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.effects.BadgeBanner; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; @@ -81,8 +82,8 @@ public class BadgesScene extends PixelScene { blankBadges = Math.max(0, blankBadges); //guarantees a max of 5 rows in landscape, and 8 in portrait, assuming a max of 40 buttons - int nCols = ShatteredPixelDungeon.landscape() ? 7 : 4; - if (badges.size() + blankBadges > 32 && !ShatteredPixelDungeon.landscape()) nCols++; + int nCols = SPDSettings.landscape() ? 7 : 4; + if (badges.size() + blankBadges > 32 && !SPDSettings.landscape()) nCols++; int nRows = 1 + (blankBadges + badges.size())/nCols; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/CellSelector.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/CellSelector.java index 6ddbf5db7..a25e36ad7 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/CellSelector.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/CellSelector.java @@ -22,7 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; -import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; @@ -82,7 +82,7 @@ public class CellSelector extends TouchArea { private float zoom( float value ) { value = GameMath.gate( PixelScene.minZoom, value, PixelScene.maxZoom ); - ShatteredPixelDungeon.zoom((int) (value - PixelScene.defaultZoom)); + SPDSettings.zoom((int) (value - PixelScene.defaultZoom)); camera.zoom( value ); //Resets character sprite positions with the new camera zoom diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java index 3fe138e21..208520051 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java @@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.Statistics; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; @@ -161,10 +162,10 @@ public class GameScene extends PixelScene { Music.INSTANCE.play( Assets.TUNE, true ); - ShatteredPixelDungeon.lastClass(Dungeon.hero.heroClass.ordinal()); + SPDSettings.lastClass(Dungeon.hero.heroClass.ordinal()); super.create(); - Camera.main.zoom( GameMath.gate(minZoom, defaultZoom + ShatteredPixelDungeon.zoom(), maxZoom)); + Camera.main.zoom( GameMath.gate(minZoom, defaultZoom + SPDSettings.zoom(), maxZoom)); scene = this; @@ -528,9 +529,9 @@ public class GameScene extends PixelScene { if (scene == null) return; - float tagLeft = ShatteredPixelDungeon.flipTags() ? 0 : uiCamera.width - scene.attack.width(); + float tagLeft = SPDSettings.flipTags() ? 0 : uiCamera.width - scene.attack.width(); - if (ShatteredPixelDungeon.flipTags()) { + if (SPDSettings.flipTags()) { scene.log.setRect(scene.attack.width(), scene.toolbar.top(), uiCamera.width - scene.attack.width(), 0); } else { scene.log.setRect(0, scene.toolbar.top(), uiCamera.width - scene.attack.width(), 0 ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/PixelScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/PixelScene.java index ffe322e41..0a2fec83b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/PixelScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/PixelScene.java @@ -23,7 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Badges; -import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.effects.BadgeBanner; import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextMultiline; import com.watabou.glwrap.Blending; @@ -73,7 +73,7 @@ public class PixelScene extends Scene { GameScene.scene = null; float minWidth, minHeight; - if (ShatteredPixelDungeon.landscape()) { + if (SPDSettings.landscape()) { minWidth = MIN_WIDTH_L; minHeight = MIN_HEIGHT_L; } else { @@ -83,7 +83,7 @@ public class PixelScene extends Scene { maxDefaultZoom = (int)Math.min(Game.width/minWidth, Game.height/minHeight); maxScreenZoom = (int)Math.min(Game.dispWidth/minWidth, Game.dispHeight/minHeight); - defaultZoom = ShatteredPixelDungeon.scale(); + defaultZoom = SPDSettings.scale(); if (defaultZoom < Math.ceil( Game.density * 2 ) || defaultZoom > maxDefaultZoom){ defaultZoom = (int)Math.ceil( Game.density * 2.5 ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/StartScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/StartScene.java index 9f3a5667d..76e60c1ab 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/StartScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/StartScene.java @@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; import com.shatteredpixel.shatteredpixeldungeon.effects.BannerSprites; @@ -93,7 +94,7 @@ public class StartScene extends PixelScene { int h = Camera.main.height; float width, height; - if (ShatteredPixelDungeon.landscape()) { + if (SPDSettings.landscape()) { width = WIDTH_L; height = HEIGHT_L; } else { @@ -161,7 +162,7 @@ public class StartScene extends PixelScene { shields.put( cl, shield ); add( shield ); } - if (ShatteredPixelDungeon.landscape()) { + if (SPDSettings.landscape()) { float shieldW = width / 4; float shieldH = Math.min( centralHeight, shieldW ); top = title.y + title.height + (centralHeight - shieldH) / 2; @@ -219,7 +220,7 @@ public class StartScene extends PixelScene { GamesInProgress.curSlot = 0; ActionIndicator.action = null; - updateClass( HeroClass.values()[ShatteredPixelDungeon.lastClass()] ); + updateClass( HeroClass.values()[SPDSettings.lastClass()] ); fadeIn(); @@ -300,8 +301,8 @@ public class StartScene extends PixelScene { Dungeon.hero = null; InterlevelScene.mode = InterlevelScene.Mode.DESCEND; - if (ShatteredPixelDungeon.intro()) { - ShatteredPixelDungeon.intro( false ); + if (SPDSettings.intro()) { + SPDSettings.intro( false ); Game.switchScene( IntroScene.class ); } else { Game.switchScene( InterlevelScene.class ); @@ -492,7 +493,7 @@ public class StartScene extends PixelScene { super.createChildren(); - image = Icons.get( ShatteredPixelDungeon.challenges() > 0 ? Icons.CHALLENGE_ON :Icons.CHALLENGE_OFF ); + image = Icons.get( SPDSettings.challenges() > 0 ? Icons.CHALLENGE_ON :Icons.CHALLENGE_OFF ); add( image ); } @@ -508,10 +509,10 @@ public class StartScene extends PixelScene { @Override protected void onClick() { if (Badges.isUnlocked( Badges.Badge.VICTORY )) { - StartScene.this.add(new WndChallenges(ShatteredPixelDungeon.challenges(), true) { + StartScene.this.add(new WndChallenges(SPDSettings.challenges(), true) { public void onBackPressed() { super.onBackPressed(); - image.copy( Icons.get( ShatteredPixelDungeon.challenges() > 0 ? + image.copy( Icons.get( SPDSettings.challenges() > 0 ? Icons.CHALLENGE_ON :Icons.CHALLENGE_OFF ) ); } } ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/TitleScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/TitleScene.java index 91b90c773..4a6642ab3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/TitleScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/TitleScene.java @@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes; import com.shatteredpixel.shatteredpixeldungeon.Assets; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.effects.BannerSprites; import com.shatteredpixel.shatteredpixeldungeon.effects.Fireball; @@ -65,7 +66,7 @@ public class TitleScene extends PixelScene { float topRegion = Math.max(95f, h*0.45f); title.x = (w - title.width()) / 2f; - if (ShatteredPixelDungeon.landscape()) + if (SPDSettings.landscape()) title.y = (topRegion - title.height()) / 2f; else title.y = 16 + (topRegion - title.height() - 16) / 2f; @@ -113,7 +114,7 @@ public class TitleScene extends PixelScene { DashboardItem btnPlay = new DashboardItem( Messages.get(this, "play"), 0 ) { @Override protected void onClick() { - ShatteredPixelDungeon.switchNoFade( StartScene.class ); + ShatteredPixelDungeon.switchNoFade( StartSceneV2.class ); } }; add( btnPlay ); @@ -126,7 +127,7 @@ public class TitleScene extends PixelScene { }; add( btnRankings ); - if (ShatteredPixelDungeon.landscape()) { + if (SPDSettings.landscape()) { btnRankings .setPos( w / 2 - btnRankings.width(), topRegion ); btnBadges .setPos( w / 2, topRegion ); btnPlay .setPos( btnRankings.left() - btnPlay.width(), topRegion ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/WelcomeScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/WelcomeScene.java index 7d75042c2..3d7814b5e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/WelcomeScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/WelcomeScene.java @@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress; import com.shatteredpixel.shatteredpixeldungeon.Rankings; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.effects.BannerSprites; import com.shatteredpixel.shatteredpixeldungeon.effects.Fireball; @@ -47,7 +48,7 @@ public class WelcomeScene extends PixelScene { public void create() { super.create(); - final int previousVersion = ShatteredPixelDungeon.version(); + final int previousVersion = SPDSettings.version(); if (ShatteredPixelDungeon.versionCode == previousVersion) { ShatteredPixelDungeon.switchNoFade(TitleScene.class); @@ -66,7 +67,7 @@ public class WelcomeScene extends PixelScene { float topRegion = Math.max(95f, h*0.45f); title.x = (w - title.width()) / 2f; - if (ShatteredPixelDungeon.landscape()) + if (SPDSettings.landscape()) title.y = (topRegion - title.height()) / 2f; else title.y = 16 + (topRegion - title.height() - 16) / 2f; @@ -199,8 +200,8 @@ public class WelcomeScene extends PixelScene { Badges.disown(Badges.Badge.ALL_ITEMS_IDENTIFIED); Badges.saveGlobal(); } - - ShatteredPixelDungeon.version(ShatteredPixelDungeon.versionCode); + + SPDSettings.version(ShatteredPixelDungeon.versionCode); } private void placeTorch( float x, float y ) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/FogOfWar.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/FogOfWar.java index 31999bc62..b0b62c85c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/FogOfWar.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/FogOfWar.java @@ -22,7 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.tiles; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; -import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.watabou.gltextures.BufferTexture; import com.watabou.gltextures.TextureCache; import com.watabou.noosa.Image; @@ -168,7 +168,7 @@ public class FogOfWar extends Image { this.visible = visible; this.visited = visited; this.mapped = mapped; - this.brightness = ShatteredPixelDungeon.brightness() + 2; + this.brightness = SPDSettings.brightness() + 2; moveToUpdating(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/GridTileMap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/GridTileMap.java index b337a4c98..610964962 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/GridTileMap.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/GridTileMap.java @@ -22,7 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.tiles; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; -import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; public class GridTileMap extends DungeonTilemap { @@ -37,7 +37,7 @@ public class GridTileMap extends DungeonTilemap { @Override public synchronized void updateMap() { - gridSetting = ShatteredPixelDungeon.visualGrid(); + gridSetting = SPDSettings.visualGrid(); super.updateMap(); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java index b97b77bfa..35e7c61c1 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java @@ -23,7 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.ui; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; -import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector; @@ -157,7 +157,7 @@ public class Toolbar extends Component { protected void layout() { int[] visible = new int[4]; - int slots = ShatteredPixelDungeon.quickSlots(); + int slots = SPDSettings.quickSlots(); for(int i = 0; i <= 3; i++) visible[i] = (int)((slots > i) ? y+2 : y+25); @@ -167,8 +167,8 @@ public class Toolbar extends Component { //decides on quickslot layout, depending on available screen size. if (slots == 4 && width < 152){ if (width < 138){ - if ((ShatteredPixelDungeon.flipToolbar() && i == 3) || - (!ShatteredPixelDungeon.flipToolbar() && i == 0)) { + if ((SPDSettings.flipToolbar() && i == 3) || + (!SPDSettings.flipToolbar() && i == 0)) { btnQuick[i].border(0, 0); btnQuick[i].frame(88, 0, 17, 24); } else { @@ -176,12 +176,12 @@ public class Toolbar extends Component { btnQuick[i].frame(88, 0, 18, 24); } } else { - if (i == 0 && !ShatteredPixelDungeon.flipToolbar() || - i == 3 && ShatteredPixelDungeon.flipToolbar()){ + if (i == 0 && !SPDSettings.flipToolbar() || + i == 3 && SPDSettings.flipToolbar()){ btnQuick[i].border(0, 2); btnQuick[i].frame(106, 0, 19, 24); - } else if (i == 0 && ShatteredPixelDungeon.flipToolbar() || - i == 3 && !ShatteredPixelDungeon.flipToolbar()){ + } else if (i == 0 && SPDSettings.flipToolbar() || + i == 3 && !SPDSettings.flipToolbar()){ btnQuick[i].border(2, 1); btnQuick[i].frame(86, 0, 20, 24); } else { @@ -197,7 +197,7 @@ public class Toolbar extends Component { } float right = width; - switch(Mode.valueOf(ShatteredPixelDungeon.toolbarMode())){ + switch(Mode.valueOf(SPDSettings.toolbarMode())){ case SPLIT: btnWait.setPos(x, y); btnSearch.setPos(btnWait.right(), y); @@ -231,7 +231,7 @@ public class Toolbar extends Component { } right = width; - if (ShatteredPixelDungeon.flipToolbar()) { + if (SPDSettings.flipToolbar()) { btnWait.setPos( (right - btnWait.right()), y); btnSearch.setPos( (right - btnSearch.right()), y); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java index 5e60dcf18..945a6566b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java @@ -25,7 +25,7 @@ import android.graphics.RectF; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; -import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem; @@ -119,7 +119,7 @@ public class WndBag extends WndTabbed { lastMode = mode; lastBag = bag; - nCols = ShatteredPixelDungeon.landscape() ? COLS_L : COLS_P; + nCols = SPDSettings.landscape() ? COLS_L : COLS_P; nRows = (int)Math.ceil((Belongings.BACKPACK_SIZE + 4) / (float)nCols); int slotsWidth = SLOT_WIDTH * nCols + SLOT_MARGIN * (nCols - 1); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndChallenges.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndChallenges.java index 21fdc0353..7f822f6ed 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndChallenges.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndChallenges.java @@ -22,7 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; import com.shatteredpixel.shatteredpixeldungeon.Challenges; -import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.ui.CheckBox; @@ -86,7 +86,7 @@ public class WndChallenges extends Window { value |= Challenges.MASKS[i]; } } - ShatteredPixelDungeon.challenges( value ); + SPDSettings.challenges( value ); } super.onBackPressed(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndGame.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndGame.java index 3f570ff97..620cfd3a9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndGame.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndGame.java @@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; @@ -74,7 +75,7 @@ public class WndGame extends Window { @Override protected void onClick() { Dungeon.hero = null; - ShatteredPixelDungeon.challenges( Dungeon.challenges ); + SPDSettings.challenges( Dungeon.challenges ); InterlevelScene.mode = InterlevelScene.Mode.DESCEND; InterlevelScene.noStory = true; Game.switchScene( InterlevelScene.class ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoItem.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoItem.java index e4ec2778e..e2a808c04 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoItem.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoItem.java @@ -21,7 +21,7 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; -import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.items.Heap; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; @@ -57,7 +57,7 @@ public class WndInfoItem extends Window { } else { fillFields( heap.image(), heap.glowing(), TITLE_COLOR, heap.toString(), heap.info() ); - + } } @@ -77,7 +77,7 @@ public class WndInfoItem extends Window { private void fillFields( int image, ItemSprite.Glowing glowing, int titleColor, String title, String info ) { - int width = ShatteredPixelDungeon.landscape() ? WIDTH_L : WIDTH_P; + int width = SPDSettings.landscape() ? WIDTH_L : WIDTH_P; IconTitle titlebar = new IconTitle(); titlebar.icon( new ItemSprite( image, glowing ) ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndItem.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndItem.java index 97b61c349..295adb679 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndItem.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndItem.java @@ -22,7 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; -import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; @@ -52,7 +52,7 @@ public class WndItem extends Window { super(); - int width = ShatteredPixelDungeon.landscape() ? WIDTH_L : WIDTH_P; + int width = SPDSettings.landscape() ? WIDTH_L : WIDTH_P; IconTitle titlebar = new IconTitle( item ); titlebar.setRect( 0, 0, width, 0 ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java index c70a436ac..00764abb3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java @@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; @@ -68,8 +69,8 @@ public class WndJournal extends WndTabbed { public WndJournal(){ - int width = ShatteredPixelDungeon.landscape() ? WIDTH_L : WIDTH_P; - int height = ShatteredPixelDungeon.landscape() ? HEIGHT_L : HEIGHT_P; + int width = SPDSettings.landscape() ? WIDTH_L : WIDTH_P; + int height = SPDSettings.landscape() ? HEIGHT_L : HEIGHT_P; resize(width, height); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndLangs.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndLangs.java index cbc1afbc5..94d983cfe 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndLangs.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndLangs.java @@ -21,6 +21,7 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.messages.Languages; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; @@ -71,7 +72,7 @@ public class WndLangs extends Window { ShatteredPixelDungeon.switchNoFade(TitleScene.class, new Game.SceneChangeCallback() { @Override public void beforeCreate() { - ShatteredPixelDungeon.language(langs.get(langIndex)); + SPDSettings.language(langs.get(langIndex)); RenderedText.clearCache(); } @Override @@ -94,7 +95,7 @@ public class WndLangs extends Window { } } btn.setSize(BTN_WIDTH, BTN_HEIGHT); - if (ShatteredPixelDungeon.landscape() && i % 2 == 1){ + if (SPDSettings.landscape() && i % 2 == 1){ btn.setPos(BTN_WIDTH+1, y-(BTN_HEIGHT + 1)); } else { btn.setPos(0, y); @@ -104,7 +105,7 @@ public class WndLangs extends Window { add(btn); } y = Math.max(MIN_HEIGHT, y); - resize(ShatteredPixelDungeon.landscape() ? WIDTH_L : WIDTH_P, y); + resize(SPDSettings.landscape() ? WIDTH_L : WIDTH_P, y); int textLeft = width - 65; int textWidth = width - textLeft; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndMessage.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndMessage.java index 11e7f5a5b..a64dd700f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndMessage.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndMessage.java @@ -21,7 +21,7 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; -import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextMultiline; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; @@ -37,7 +37,7 @@ public class WndMessage extends Window { super(); RenderedTextMultiline info = PixelScene.renderMultiline( text, 6 ); - info.maxWidth((ShatteredPixelDungeon.landscape() ? WIDTH_L : WIDTH_P) - MARGIN * 2); + info.maxWidth((SPDSettings.landscape() ? WIDTH_L : WIDTH_P) - MARGIN * 2); info.setPos(MARGIN, MARGIN); add( info ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndOptions.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndOptions.java index 16cdc04a6..6151a0e1a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndOptions.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndOptions.java @@ -21,7 +21,7 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; -import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextMultiline; @@ -38,7 +38,7 @@ public class WndOptions extends Window { public WndOptions( String title, String message, String... options ) { super(); - int width = ShatteredPixelDungeon.landscape() ? WIDTH_L : WIDTH_P; + int width = SPDSettings.landscape() ? WIDTH_L : WIDTH_P; RenderedTextMultiline tfTitle = PixelScene.renderMultiline( title, 9 ); tfTitle.hardlight( TITLE_COLOR ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java index 38166d9ab..c5263b006 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java @@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; import com.shatteredpixel.shatteredpixeldungeon.Assets; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; @@ -33,7 +34,6 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.Toolbar; import com.watabou.noosa.Game; import com.watabou.noosa.Group; import com.watabou.noosa.RenderedText; -import com.watabou.noosa.audio.Music; import com.watabou.noosa.audio.Sample; import com.watabou.utils.DeviceCompat; @@ -112,8 +112,8 @@ public class WndSettings extends WndTabbed { PixelScene.maxDefaultZoom ) { @Override protected void onChange() { - if (getSelectedValue() != ShatteredPixelDungeon.scale()) { - ShatteredPixelDungeon.scale(getSelectedValue()); + if (getSelectedValue() != SPDSettings.scale()) { + SPDSettings.scale(getSelectedValue()); ShatteredPixelDungeon.switchNoFade((Class) ShatteredPixelDungeon.scene().getClass(), new Game.SceneChangeCallback() { @Override public void beforeCreate() { @@ -149,27 +149,27 @@ public class WndSettings extends WndTabbed { protected void onSelect(int index) { if (index == 0) { checked(!checked()); - ShatteredPixelDungeon.powerSaver(checked()); + SPDSettings.powerSaver(checked()); } } }); } else { - ShatteredPixelDungeon.powerSaver(checked()); + SPDSettings.powerSaver(checked()); } } }; if (PixelScene.maxScreenZoom >= 2) { chkSaver.setRect(0, scale.bottom() + GAP_TINY, WIDTH, BTN_HEIGHT); - chkSaver.checked(ShatteredPixelDungeon.powerSaver()); + chkSaver.checked(SPDSettings.powerSaver()); add(chkSaver); } - RedButton btnOrientation = new RedButton( ShatteredPixelDungeon.landscape() ? + RedButton btnOrientation = new RedButton( SPDSettings.landscape() ? Messages.get(this, "portrait") : Messages.get(this, "landscape") ) { @Override protected void onClick() { - ShatteredPixelDungeon.landscape(!ShatteredPixelDungeon.landscape()); + SPDSettings.landscape(!SPDSettings.landscape()); } }; btnOrientation.setRect(0, chkSaver.bottom() + GAP_TINY, WIDTH, BTN_HEIGHT); @@ -180,10 +180,10 @@ public class WndSettings extends WndTabbed { Messages.get(this, "dark"), Messages.get(this, "bright"), -2, 2) { @Override protected void onChange() { - ShatteredPixelDungeon.brightness(getSelectedValue()); + SPDSettings.brightness(getSelectedValue()); } }; - brightness.setSelectedValue(ShatteredPixelDungeon.brightness()); + brightness.setSelectedValue(SPDSettings.brightness()); brightness.setRect(0, btnOrientation.bottom() + GAP_LRG, WIDTH, SLIDER_HEIGHT); add(brightness); @@ -191,10 +191,10 @@ public class WndSettings extends WndTabbed { Messages.get(this, "off"), Messages.get(this, "high"), -1, 3) { @Override protected void onChange() { - ShatteredPixelDungeon.visualGrid(getSelectedValue()); + SPDSettings.visualGrid(getSelectedValue()); } }; - tileGrid.setSelectedValue(ShatteredPixelDungeon.visualGrid()); + tileGrid.setSelectedValue(SPDSettings.visualGrid()); tileGrid.setRect(0, brightness.bottom() + GAP_TINY, WIDTH, SLIDER_HEIGHT); add(tileGrid); @@ -215,7 +215,7 @@ public class WndSettings extends WndTabbed { RedButton btnSplit = new RedButton(Messages.get(this, "split")){ @Override protected void onClick() { - ShatteredPixelDungeon.toolbarMode(Toolbar.Mode.SPLIT.name()); + SPDSettings.toolbarMode(Toolbar.Mode.SPLIT.name()); Toolbar.updateLayout(); } }; @@ -225,7 +225,7 @@ public class WndSettings extends WndTabbed { RedButton btnGrouped = new RedButton(Messages.get(this, "group")){ @Override protected void onClick() { - ShatteredPixelDungeon.toolbarMode(Toolbar.Mode.GROUP.name()); + SPDSettings.toolbarMode(Toolbar.Mode.GROUP.name()); Toolbar.updateLayout(); } }; @@ -235,7 +235,7 @@ public class WndSettings extends WndTabbed { RedButton btnCentered = new RedButton(Messages.get(this, "center")){ @Override protected void onClick() { - ShatteredPixelDungeon.toolbarMode(Toolbar.Mode.CENTER.name()); + SPDSettings.toolbarMode(Toolbar.Mode.CENTER.name()); Toolbar.updateLayout(); } }; @@ -246,34 +246,34 @@ public class WndSettings extends WndTabbed { @Override protected void onClick() { super.onClick(); - ShatteredPixelDungeon.flipToolbar(checked()); + SPDSettings.flipToolbar(checked()); Toolbar.updateLayout(); } }; chkFlipToolbar.setRect(0, btnGrouped.bottom() + GAP_TINY, WIDTH, BTN_HEIGHT); - chkFlipToolbar.checked(ShatteredPixelDungeon.flipToolbar()); + chkFlipToolbar.checked(SPDSettings.flipToolbar()); add(chkFlipToolbar); final CheckBox chkFlipTags = new CheckBox(Messages.get(this, "flip_indicators")){ @Override protected void onClick() { super.onClick(); - ShatteredPixelDungeon.flipTags(checked()); + SPDSettings.flipTags(checked()); GameScene.layoutTags(); } }; chkFlipTags.setRect(0, chkFlipToolbar.bottom() + GAP_TINY, WIDTH, BTN_HEIGHT); - chkFlipTags.checked(ShatteredPixelDungeon.flipTags()); + chkFlipTags.checked(SPDSettings.flipTags()); add(chkFlipTags); OptionSlider slots = new OptionSlider(Messages.get(this, "quickslots"), "0", "4", 0, 4) { @Override protected void onChange() { - ShatteredPixelDungeon.quickSlots(getSelectedValue()); + SPDSettings.quickSlots(getSelectedValue()); Toolbar.updateLayout(); } }; - slots.setSelectedValue(ShatteredPixelDungeon.quickSlots()); + slots.setSelectedValue(SPDSettings.quickSlots()); slots.setRect(0, chkFlipTags.bottom() + GAP_TINY, WIDTH, SLIDER_HEIGHT); add(slots); @@ -281,11 +281,11 @@ public class WndSettings extends WndTabbed { @Override protected void onClick() { super.onClick(); - ShatteredPixelDungeon.immerse(checked()); + SPDSettings.fullscreen(checked()); } }; chkImmersive.setRect( 0, slots.bottom() + GAP_SML, WIDTH, BTN_HEIGHT ); - chkImmersive.checked(ShatteredPixelDungeon.immersed()); + chkImmersive.checked(SPDSettings.fullscreen()); chkImmersive.enable(DeviceCompat.supportsFullScreen()); add(chkImmersive); @@ -296,7 +296,7 @@ public class WndSettings extends WndTabbed { ShatteredPixelDungeon.switchNoFade((Class) ShatteredPixelDungeon.scene().getClass(), new Game.SceneChangeCallback() { @Override public void beforeCreate() { - ShatteredPixelDungeon.classicFont(!checked()); + SPDSettings.systemFont(checked()); } @Override @@ -307,7 +307,7 @@ public class WndSettings extends WndTabbed { } }; chkFont.setRect(0, chkImmersive.bottom() + GAP_TINY, WIDTH, BTN_HEIGHT); - chkFont.checked(!ShatteredPixelDungeon.classicFont()); + chkFont.checked(SPDSettings.systemFont()); add(chkFont); } @@ -319,11 +319,10 @@ public class WndSettings extends WndTabbed { OptionSlider musicVol = new OptionSlider(Messages.get(this, "music_vol"), "0", "10", 0, 10) { @Override protected void onChange() { - Music.INSTANCE.volume(getSelectedValue()/10f); - ShatteredPixelDungeon.musicVol(getSelectedValue()); + SPDSettings.musicVol(getSelectedValue()); } }; - musicVol.setSelectedValue(ShatteredPixelDungeon.musicVol()); + musicVol.setSelectedValue(SPDSettings.musicVol()); musicVol.setRect(0, 0, WIDTH, SLIDER_HEIGHT); add(musicVol); @@ -331,22 +330,21 @@ public class WndSettings extends WndTabbed { @Override protected void onClick() { super.onClick(); - ShatteredPixelDungeon.music(!checked()); + SPDSettings.music(!checked()); } }; musicMute.setRect(0, musicVol.bottom() + GAP_TINY, WIDTH, BTN_HEIGHT); - musicMute.checked(!ShatteredPixelDungeon.music()); + musicMute.checked(!SPDSettings.music()); add(musicMute); OptionSlider SFXVol = new OptionSlider(Messages.get(this, "sfx_vol"), "0", "10", 0, 10) { @Override protected void onChange() { - Sample.INSTANCE.volume(getSelectedValue()/10f); - ShatteredPixelDungeon.SFXVol(getSelectedValue()); + SPDSettings.SFXVol(getSelectedValue()); } }; - SFXVol.setSelectedValue(ShatteredPixelDungeon.SFXVol()); + SFXVol.setSelectedValue(SPDSettings.SFXVol()); SFXVol.setRect(0, musicMute.bottom() + GAP_LRG, WIDTH, SLIDER_HEIGHT); add(SFXVol); @@ -354,12 +352,12 @@ public class WndSettings extends WndTabbed { @Override protected void onClick() { super.onClick(); - ShatteredPixelDungeon.soundFx(!checked()); + SPDSettings.soundFx(!checked()); Sample.INSTANCE.play( Assets.SND_CLICK ); } }; btnSound.setRect(0, SFXVol.bottom() + GAP_TINY, WIDTH, BTN_HEIGHT); - btnSound.checked(!ShatteredPixelDungeon.soundFx()); + btnSound.checked(!SPDSettings.soundFx()); add( btnSound ); resize( WIDTH, (int)btnSound.bottom()); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndStory.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndStory.java index 68b7b6ab8..cc2e36562 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndStory.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndStory.java @@ -23,7 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; import com.shatteredpixel.shatteredpixeldungeon.Chrome; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; -import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextMultiline; @@ -67,7 +67,7 @@ public class WndStory extends Window { super( 0, 0, Chrome.get( Chrome.Type.SCROLL ) ); tf = PixelScene.renderMultiline( text, 6 ); - tf.maxWidth(ShatteredPixelDungeon.landscape() ? + tf.maxWidth(SPDSettings.landscape() ? WIDTH_L - MARGIN * 2: WIDTH_P - MARGIN *2); tf.invert(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndTextInput.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndTextInput.java index 04b74edff..65c43d707 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndTextInput.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndTextInput.java @@ -34,6 +34,7 @@ import android.widget.EditText; import android.widget.FrameLayout; import android.widget.TextView; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; @@ -65,14 +66,14 @@ public class WndTextInput extends Window { super(); //need to offset to give space for the soft keyboard - if (ShatteredPixelDungeon.landscape()) { + if (SPDSettings.landscape()) { offset( multiLine ? -45 : -45 ); } else { offset( multiLine ? -60 : -45 ); } final int width; - if (ShatteredPixelDungeon.landscape() && multiLine){ + if (SPDSettings.landscape() && multiLine){ width = W_LAND_MULTI; //more editing space for landscape users } else { width = WIDTH; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndTitledMessage.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndTitledMessage.java index 661fde91a..b53da4874 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndTitledMessage.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndTitledMessage.java @@ -21,7 +21,7 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; -import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextMultiline; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; @@ -44,7 +44,7 @@ public class WndTitledMessage extends Window { super(); - int width = ShatteredPixelDungeon.landscape() ? WIDTH_L : WIDTH_P; + int width = SPDSettings.landscape() ? WIDTH_L : WIDTH_P; titlebar.setRect( 0, 0, width, 0 ); add(titlebar);