/* * Pixel Dungeon * Copyright (C) 2012-2014 Oleg Dolya * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see */ package com.shatteredpixel.shatteredpixeldungeon; import android.content.pm.ActivityInfo; import android.os.Bundle; import android.util.Log; import android.view.Display; import com.watabou.noosa.Game; import com.watabou.noosa.audio.Music; import com.watabou.noosa.audio.Sample; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.TitleScene; public class ShatteredPixelDungeon extends Game { public ShatteredPixelDungeon() { super( TitleScene.class ); com.watabou.utils.Bundle.addAlias( com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade.class, "com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfEnhancement" ); com.watabou.utils.Bundle.addAlias( com.shatteredpixel.shatteredpixeldungeon.actors.blobs.WaterOfHealth.class, "com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Light" ); com.watabou.utils.Bundle.addAlias( com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfMending.class, "com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfRejuvenation" ); com.watabou.utils.Bundle.addAlias( com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfTelekinesis.class, "com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfTelekenesis" ); com.watabou.utils.Bundle.addAlias( com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Foliage.class, "com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blooming" ); com.watabou.utils.Bundle.addAlias( com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Shadows.class, "com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Rejuvenation" ); com.watabou.utils.Bundle.addAlias( com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfPsionicBlast.class, "com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfNuclearBlast" ); com.watabou.utils.Bundle.addAlias( com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero.class, "com.shatteredpixel.shatteredpixeldungeon.actors.Hero" ); // com.watabou.utils.Bundle.addAlias( // com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Javelin.class, // "com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang" ); com.watabou.utils.Bundle.addAlias( com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Shopkeeper.class, "com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Shopkeeper" ); // 1.6.1 com.watabou.utils.Bundle.addAlias( com.shatteredpixel.shatteredpixeldungeon.items.quest.DriedRose.class, "com.shatteredpixel.shatteredpixeldungeon.items.DriedRose" ); com.watabou.utils.Bundle.addAlias( com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.MirrorImage.class, "com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMirrorImage.MirrorImage" ); // 1.6.4 com.watabou.utils.Bundle.addAlias( com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements.class, "com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfCleansing" ); com.watabou.utils.Bundle.addAlias( com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements.class, "com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfResistance" ); com.watabou.utils.Bundle.addAlias( com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang.class, "com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.RangersBoomerang" ); com.watabou.utils.Bundle.addAlias( com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfPower.class, "com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfEnergy" ); } @SuppressWarnings("deprecation") @Override protected void onCreate( Bundle savedInstanceState ) { super.onCreate( savedInstanceState ); /* if (android.os.Build.VERSION.SDK_INT >= 19) { getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY ); }*/ Display display = instance.getWindowManager().getDefaultDisplay(); boolean landscape = display.getWidth() > display.getHeight(); if (Preferences.INSTANCE.getBoolean( Preferences.KEY_LANDSCAPE, false ) != landscape) { landscape( !landscape ); } Music.INSTANCE.enable( music() ); Sample.INSTANCE.enable( soundFx() ); } /* * ---> Prefernces */ public static void landscape( boolean value ) { Game.instance.setRequestedOrientation( value ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT ); Preferences.INSTANCE.put( Preferences.KEY_LANDSCAPE, value ); } public static boolean landscape() { return width > height; } public static void scaleUp( boolean value ) { Preferences.INSTANCE.put( Preferences.KEY_SCALE_UP, value ); switchScene( TitleScene.class ); } public static boolean scaleUp() { return Preferences.INSTANCE.getBoolean( Preferences.KEY_SCALE_UP, true ); } public static void zoom( int value ) { Preferences.INSTANCE.put( Preferences.KEY_ZOOM, value ); } public static int zoom() { return Preferences.INSTANCE.getInt( Preferences.KEY_ZOOM, 0 ); } public static void music( boolean value ) { Music.INSTANCE.enable( value ); Preferences.INSTANCE.put( Preferences.KEY_MUSIC, value ); } public static boolean music() { return Preferences.INSTANCE.getBoolean( Preferences.KEY_MUSIC, true ); } public static void soundFx( boolean value ) { Sample.INSTANCE.enable( value ); Preferences.INSTANCE.put( Preferences.KEY_SOUND_FX, value ); } public static boolean soundFx() { return Preferences.INSTANCE.getBoolean( Preferences.KEY_SOUND_FX, true ); } public static void brightness( boolean value ) { Preferences.INSTANCE.put( Preferences.KEY_BRIGHTNESS, value ); if (scene() instanceof GameScene) { ((GameScene)scene()).brightness( value ); } } public static boolean brightness() { return Preferences.INSTANCE.getBoolean( Preferences.KEY_BRIGHTNESS, false ); } public static void donated( String value ) { Preferences.INSTANCE.put( Preferences.KEY_DONATED, value ); } public static String donated() { return Preferences.INSTANCE.getString( Preferences.KEY_DONATED, "" ); } public static void lastClass( int value ) { Preferences.INSTANCE.put( Preferences.KEY_LAST_CLASS, value ); } public static int lastClass() { return Preferences.INSTANCE.getInt( Preferences.KEY_LAST_CLASS, 0 ); } public static void intro( boolean value ) { Preferences.INSTANCE.put( Preferences.KEY_INTRO, value ); } public static boolean intro() { return Preferences.INSTANCE.getBoolean( Preferences.KEY_INTRO, true ); } /* * <--- Preferences */ public static void reportException( Exception e ) { Log.e( "PD", Log.getStackTraceString( e ) ); } }