Skip to content

Commit

Permalink
Quickslot in Global Settings
Browse files Browse the repository at this point in the history
Save the Second QuickSlot State in Global Preferences
  • Loading branch information
rodriformiga committed Apr 2, 2015
1 parent 23b285c commit 5d366cb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/com/watabou/pixeldungeon/PixelDungeon.java
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,14 @@ public static void intro( boolean value ) {
public static boolean intro() {
return Preferences.INSTANCE.getBoolean( Preferences.KEY_INTRO, true );
}

public static void secondQuickslot( boolean value ) {
Preferences.INSTANCE.put( Preferences.KEY_2QUICK, value );
}

public static boolean secondQuickslot() {
return Preferences.INSTANCE.getBoolean( Preferences.KEY_2QUICK, false );
}

/*
* <--- Preferences
Expand Down
1 change: 1 addition & 0 deletions src/com/watabou/pixeldungeon/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ enum Preferences {
public static final String KEY_DONATED = "donated";
public static final String KEY_INTRO = "intro";
public static final String KEY_BRIGHTNESS = "brightness";
public static final String KEY_2QUICK = "2quick_slot";

private SharedPreferences prefs;

Expand Down
8 changes: 5 additions & 3 deletions src/com/watabou/pixeldungeon/ui/Toolbar.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.watabou.pixeldungeon.Dungeon;
import com.watabou.pixeldungeon.DungeonTilemap;
import com.watabou.pixeldungeon.R;
import com.watabou.pixeldungeon.PixelDungeon;
import com.watabou.pixeldungeon.actors.Actor;
import com.watabou.pixeldungeon.actors.mobs.Mob;
import com.watabou.pixeldungeon.items.Heap;
Expand Down Expand Up @@ -121,7 +122,7 @@ protected void layout() {

add( btnQuick1 = new QuickslotTool( 83, 7, 22, 24, true ) );
add( btnQuick2 = new QuickslotTool( 83, 7, 22, 24, false ) );
btnQuick2.visible = (QuickSlot.secondaryValue != null);
btnQuick2.visible = secondQuickslot();

add( pickedUp = new PickedUpItem() );
}
Expand All @@ -132,7 +133,7 @@ protected void layout() {
btnSearch.setPos( btnWait.right(), y );
btnInfo.setPos( btnSearch.right(), y );
btnQuick1.setPos( width - btnQuick1.width(), y );
if (btnQuick2.visible) {
if (secondQuickslot()) {
btnQuick2.setPos(btnQuick1.left() - btnQuick2.width(), y );
btnInventory.setPos( btnQuick2.left() - btnInventory.width(), y );
} else {
Expand Down Expand Up @@ -166,13 +167,14 @@ public void pickup( Item item ) {
}

public static boolean secondQuickslot() {
return instance.btnQuick2.visible;
return PixelDungeon.secondQuickslot();
}

public static void secondQuickslot( boolean value ) {
instance.btnQuick2.visible =
instance.btnQuick2.active =
value;
PixelDungeon.secondQuickslot(value);
instance.layout();
}

Expand Down

0 comments on commit 5d366cb

Please sign in to comment.