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

View File

@@ -672,6 +672,8 @@ public class GameScene extends PixelScene {
private float notifyDelay = 1/60f;
public static boolean updateItemDisplays = false;
public static boolean tagsNeedLayout = false;
@Override
public synchronized void update() {
@@ -728,7 +730,6 @@ public class GameScene extends PixelScene {
tagAction != action.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) ||
(loot.visible && !tagLoot) ||
(action.visible && !tagAction) ||
@@ -739,13 +740,11 @@ public class GameScene extends PixelScene {
tagAction = action.visible;
tagResume = resume.visible;
//except if action is the only tag left, then let it drop to the bottom
// this is because the action tag can sometimes be persistent
if (tagAction && !tagAttack && !tagLoot && !tagResume){
tagAppearing = true;
}
//if a new tag appears, re-layout tags immediately
//otherwise, wait until the hero acts, so as to not suddenly change their position
if (tagAppearing) layoutTags();
else tagsNeedLayout = true;
if (tagAppearing) layoutTags();
}
cellSelector.enable(Dungeon.hero.ready);
@@ -1392,6 +1391,10 @@ public class GameScene extends PixelScene {
QuickSlotButton.cancel();
InventoryPane.cancelTargeting();
if (scene != null && scene.toolbar != null) scene.toolbar.examining = false;
if (tagsNeedLayout) {
layoutTags();
tagsNeedLayout = false;
}
}
public static void checkKeyHold(){

View File

@@ -135,6 +135,7 @@ public class ActionIndicator extends Tag {
@Override
protected void onClick() {
super.onClick();
if (action != null && Dungeon.hero.ready) {
action.doAction();
}

View File

@@ -174,6 +174,7 @@ public class AttackIndicator extends Tag {
@Override
protected void onClick() {
super.onClick();
if (enabled && Dungeon.hero.ready) {
if (Dungeon.hero.handle( lastTarget.pos )) {
Dungeon.hero.next();

View File

@@ -109,6 +109,7 @@ public class DangerIndicator extends Tag {
@Override
protected void onClick() {
super.onClick();
if (Dungeon.hero.visibleEnemies() > 0) {
Mob target = Dungeon.hero.visibleEnemy(++enemyIndex);

View File

@@ -48,6 +48,7 @@ public class LootIndicator extends Tag {
slot = new ItemSlot() {
protected void onClick() {
LootIndicator.this.onClick();
if (Dungeon.hero.ready && Dungeon.hero.handle(Dungeon.hero.pos)){
Dungeon.hero.next();
}

View File

@@ -67,6 +67,7 @@ public class ResumeIndicator extends Tag {
@Override
protected void onClick() {
super.onClick();
if (Dungeon.hero.ready) {
Dungeon.hero.resume();
}

View File

@@ -22,6 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon.ui;
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.watabou.noosa.Game;
import com.watabou.noosa.NinePatch;
@@ -55,7 +56,12 @@ public class Tag extends Button {
bg.hardlight( r, g, b );
add( bg );
}
@Override
protected void onClick() {
GameScene.tagsNeedLayout = false;
}
@Override
protected void layout() {