v3.3.4: game scene now persists item selection UI on scene reset
This commit is contained in:
@@ -50,14 +50,21 @@ public abstract class InventoryScroll extends Scroll {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void confirmCancelation() {
|
private void confirmCancelation() {
|
||||||
GameScene.show( new WndOptions(new ItemSprite(this),
|
GameScene.show( new WndConfirmCancel() );
|
||||||
Messages.titleCase(name()),
|
}
|
||||||
Messages.get(this, "warning"),
|
|
||||||
Messages.get(this, "yes"),
|
public class WndConfirmCancel extends WndOptions{
|
||||||
Messages.get(this, "no") ) {
|
|
||||||
@Override
|
public WndConfirmCancel(){
|
||||||
protected void onSelect( int index ) {
|
super(new ItemSprite(InventoryScroll.this),
|
||||||
switch (index) {
|
Messages.titleCase(name()),
|
||||||
|
Messages.get(InventoryScroll.this, "warning"),
|
||||||
|
Messages.get(InventoryScroll.this, "yes"),
|
||||||
|
Messages.get(InventoryScroll.this, "no") );
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void onSelect( int index ) {
|
||||||
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
curUser.spendAndNext( TIME_TO_READ );
|
curUser.spendAndNext( TIME_TO_READ );
|
||||||
identifiedByUse = false;
|
identifiedByUse = false;
|
||||||
@@ -65,10 +72,14 @@ public abstract class InventoryScroll extends Scroll {
|
|||||||
case 1:
|
case 1:
|
||||||
GameScene.selectItem( itemSelector );
|
GameScene.selectItem( itemSelector );
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public void onBackPressed() {}
|
}
|
||||||
} );
|
public void onBackPressed() {}
|
||||||
|
|
||||||
|
public WndBag.ItemSelector getItemSelector(){
|
||||||
|
return itemSelector;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String inventoryTitle(){
|
private String inventoryTitle(){
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndUpgrade;
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndUpgrade;
|
||||||
|
|
||||||
public class ScrollOfUpgrade extends InventoryScroll {
|
public class ScrollOfUpgrade extends InventoryScroll {
|
||||||
@@ -70,6 +71,12 @@ public class ScrollOfUpgrade extends InventoryScroll {
|
|||||||
GameScene.selectItem(itemSelector);
|
GameScene.selectItem(itemSelector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WndBag.ItemSelector getSelector(boolean force){
|
||||||
|
identifiedByUse = force;
|
||||||
|
curItem = this;
|
||||||
|
return itemSelector;
|
||||||
|
}
|
||||||
|
|
||||||
public Item upgradeItem( Item item ){
|
public Item upgradeItem( Item item ){
|
||||||
upgrade( curUser );
|
upgrade( curUser );
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndUpgrade;
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndUpgrade;
|
||||||
import com.watabou.noosa.audio.Sample;
|
import com.watabou.noosa.audio.Sample;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
@@ -68,6 +69,11 @@ public class MagicalInfusion extends InventorySpell {
|
|||||||
GameScene.selectItem(itemSelector);
|
GameScene.selectItem(itemSelector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WndBag.ItemSelector getSelector(){
|
||||||
|
curItem = this;
|
||||||
|
return itemSelector;
|
||||||
|
}
|
||||||
|
|
||||||
public void useAnimation(){
|
public void useAnimation(){
|
||||||
curUser.spend(1f);
|
curUser.spend(1f);
|
||||||
curUser.busy();
|
curUser.busy();
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose;
|
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.journal.Guidebook;
|
import com.shatteredpixel.shatteredpixeldungeon.items.journal.Guidebook;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.InventoryScroll;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation;
|
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.DimensionalSundial;
|
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.DimensionalSundial;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.TrinketCatalyst;
|
import com.shatteredpixel.shatteredpixeldungeon.items.trinkets.TrinketCatalyst;
|
||||||
@@ -121,6 +122,7 @@ import com.shatteredpixel.shatteredpixeldungeon.windows.WndKeyBindings;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndMessage;
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndMessage;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndResurrect;
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndResurrect;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndUpgrade;
|
||||||
import com.watabou.gltextures.TextureCache;
|
import com.watabou.gltextures.TextureCache;
|
||||||
import com.watabou.glwrap.Blending;
|
import com.watabou.glwrap.Blending;
|
||||||
import com.watabou.input.ControllerHandler;
|
import com.watabou.input.ControllerHandler;
|
||||||
@@ -1584,7 +1586,42 @@ public class GameScene extends PixelScene {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//logic for preserving inventory selection windows on scene reset (e.g. via auto-rotate)
|
||||||
|
private static WndBag.ItemSelector savedSelector;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void saveWindows() {
|
||||||
|
super.saveWindows();
|
||||||
|
if (scene.inventory != null && scene.inventory.getSelector() != null){
|
||||||
|
savedSelector = scene.inventory.getSelector();
|
||||||
|
} else {
|
||||||
|
for (Gizmo g : members.toArray(new Gizmo[0])){
|
||||||
|
if (g instanceof WndBag){
|
||||||
|
savedSelector = ((WndBag) g).getSelector();
|
||||||
|
//also keeps selector active over inventory scroll cancel and upgrade window
|
||||||
|
} else if (g instanceof InventoryScroll.WndConfirmCancel){
|
||||||
|
savedSelector = ((InventoryScroll.WndConfirmCancel) g).getItemSelector();
|
||||||
|
} else if (g instanceof WndUpgrade){
|
||||||
|
savedSelector = ((WndUpgrade) g).getItemSelector();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void restoreWindows() {
|
||||||
|
super.restoreWindows();
|
||||||
|
if (savedSelector != null){
|
||||||
|
if (scene.inventory != null){
|
||||||
|
scene.inventory.setSelector(savedSelector);
|
||||||
|
} else {
|
||||||
|
addToFront(new WndBag(Dungeon.hero.belongings.backpack, savedSelector));
|
||||||
|
}
|
||||||
|
savedSelector = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean cancel() {
|
public static boolean cancel() {
|
||||||
cellSelector.resetKeyHold();
|
cellSelector.resetKeyHold();
|
||||||
if (Dungeon.hero != null && (Dungeon.hero.curAction != null || Dungeon.hero.resting)) {
|
if (Dungeon.hero != null && (Dungeon.hero.curAction != null || Dungeon.hero.resting)) {
|
||||||
|
|||||||
@@ -393,6 +393,10 @@ public class InventoryPane extends Component {
|
|||||||
updateInventory();
|
updateInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WndBag.ItemSelector getSelector() {
|
||||||
|
return selector;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isSelecting(){
|
public boolean isSelecting(){
|
||||||
return selector != null;
|
return selector != null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,8 +141,12 @@ public class WndBag extends WndTabbed {
|
|||||||
|
|
||||||
layoutTabs();
|
layoutTabs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WndBag lastBag( ItemSelector selector ) {
|
public ItemSelector getSelector() {
|
||||||
|
return selector;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WndBag lastBag(ItemSelector selector ) {
|
||||||
|
|
||||||
if (lastBag != null && Dungeon.hero.belongings.backpack.contains( lastBag )) {
|
if (lastBag != null && Dungeon.hero.belongings.backpack.contains( lastBag )) {
|
||||||
|
|
||||||
|
|||||||
@@ -509,6 +509,15 @@ public class WndUpgrade extends Window {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WndBag.ItemSelector getItemSelector(){
|
||||||
|
if (upgrader instanceof ScrollOfUpgrade) {
|
||||||
|
return ((ScrollOfUpgrade) upgrader).getSelector(force);
|
||||||
|
} else if (upgrader instanceof MagicalInfusion){
|
||||||
|
return ((MagicalInfusion)upgrader).getSelector();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private float fillFields(String title, String msg1, String msg2, float bottom){
|
private float fillFields(String title, String msg1, String msg2, float bottom){
|
||||||
|
|
||||||
//the ~ symbol is more commonly used in Chinese
|
//the ~ symbol is more commonly used in Chinese
|
||||||
|
|||||||
Reference in New Issue
Block a user