v2.2.0: improved logic for lowering tags into empty space

This commit is contained in:
Evan Debenham
2023-07-13 11:22:01 -04:00
parent 39a50a1dc0
commit 795bfdc616
7 changed files with 22 additions and 8 deletions
@@ -673,6 +673,8 @@ public class GameScene extends PixelScene {
public static boolean updateItemDisplays = false; public static boolean updateItemDisplays = false;
public static boolean tagsNeedLayout = false;
@Override @Override
public synchronized void update() { public synchronized void update() {
lastOffset = null; lastOffset = null;
@@ -728,7 +730,6 @@ public class GameScene extends PixelScene {
tagAction != action.visible || tagAction != action.visible ||
tagResume != resume.visible) { tagResume != resume.visible) {
//we only want to change the layout when new tags pop in, not when existing ones leave.
boolean tagAppearing = (attack.active && !tagAttack) || boolean tagAppearing = (attack.active && !tagAttack) ||
(loot.visible && !tagLoot) || (loot.visible && !tagLoot) ||
(action.visible && !tagAction) || (action.visible && !tagAction) ||
@@ -739,13 +740,11 @@ public class GameScene extends PixelScene {
tagAction = action.visible; tagAction = action.visible;
tagResume = resume.visible; tagResume = resume.visible;
//except if action is the only tag left, then let it drop to the bottom //if a new tag appears, re-layout tags immediately
// this is because the action tag can sometimes be persistent //otherwise, wait until the hero acts, so as to not suddenly change their position
if (tagAction && !tagAttack && !tagLoot && !tagResume){ if (tagAppearing) layoutTags();
tagAppearing = true; else tagsNeedLayout = true;
}
if (tagAppearing) layoutTags();
} }
cellSelector.enable(Dungeon.hero.ready); cellSelector.enable(Dungeon.hero.ready);
@@ -1392,6 +1391,10 @@ public class GameScene extends PixelScene {
QuickSlotButton.cancel(); QuickSlotButton.cancel();
InventoryPane.cancelTargeting(); InventoryPane.cancelTargeting();
if (scene != null && scene.toolbar != null) scene.toolbar.examining = false; if (scene != null && scene.toolbar != null) scene.toolbar.examining = false;
if (tagsNeedLayout) {
layoutTags();
tagsNeedLayout = false;
}
} }
public static void checkKeyHold(){ public static void checkKeyHold(){
@@ -135,6 +135,7 @@ public class ActionIndicator extends Tag {
@Override @Override
protected void onClick() { protected void onClick() {
super.onClick();
if (action != null && Dungeon.hero.ready) { if (action != null && Dungeon.hero.ready) {
action.doAction(); action.doAction();
} }
@@ -174,6 +174,7 @@ public class AttackIndicator extends Tag {
@Override @Override
protected void onClick() { protected void onClick() {
super.onClick();
if (enabled && Dungeon.hero.ready) { if (enabled && Dungeon.hero.ready) {
if (Dungeon.hero.handle( lastTarget.pos )) { if (Dungeon.hero.handle( lastTarget.pos )) {
Dungeon.hero.next(); Dungeon.hero.next();
@@ -109,6 +109,7 @@ public class DangerIndicator extends Tag {
@Override @Override
protected void onClick() { protected void onClick() {
super.onClick();
if (Dungeon.hero.visibleEnemies() > 0) { if (Dungeon.hero.visibleEnemies() > 0) {
Mob target = Dungeon.hero.visibleEnemy(++enemyIndex); Mob target = Dungeon.hero.visibleEnemy(++enemyIndex);
@@ -48,6 +48,7 @@ public class LootIndicator extends Tag {
slot = new ItemSlot() { slot = new ItemSlot() {
protected void onClick() { protected void onClick() {
LootIndicator.this.onClick();
if (Dungeon.hero.ready && Dungeon.hero.handle(Dungeon.hero.pos)){ if (Dungeon.hero.ready && Dungeon.hero.handle(Dungeon.hero.pos)){
Dungeon.hero.next(); Dungeon.hero.next();
} }
@@ -67,6 +67,7 @@ public class ResumeIndicator extends Tag {
@Override @Override
protected void onClick() { protected void onClick() {
super.onClick();
if (Dungeon.hero.ready) { if (Dungeon.hero.ready) {
Dungeon.hero.resume(); Dungeon.hero.resume();
} }
@@ -22,6 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon.ui; package com.shatteredpixel.shatteredpixeldungeon.ui;
import com.shatteredpixel.shatteredpixeldungeon.Chrome; import com.shatteredpixel.shatteredpixeldungeon.Chrome;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.watabou.noosa.Game; import com.watabou.noosa.Game;
import com.watabou.noosa.NinePatch; import com.watabou.noosa.NinePatch;
@@ -56,6 +57,11 @@ public class Tag extends Button {
add( bg ); add( bg );
} }
@Override
protected void onClick() {
GameScene.tagsNeedLayout = false;
}
@Override @Override
protected void layout() { protected void layout() {