Fix exit to world map edge cases (Adventure) (#7522)

* Fixing an issue in which touching the space the map occupies outside of the world map does not allow the player to move (very relevant on maps with content in the top left corner)

* Attempt to band-aid two problems relating to showing a dialog to return to the main map, one in which some patrolling enemies ignore the menu restriction and another in which such enemies touching a player who is transitioning out of a dungeon causing a soft lock upon returning to the map
This commit is contained in:
rwalters
2025-05-12 23:28:00 -04:00
committed by GitHub
parent ef28a92dff
commit 35bc80767f
5 changed files with 27 additions and 8 deletions

View File

@@ -155,7 +155,7 @@ public class TileMapScene extends HudScene {
@Override @Override
public boolean isInHudOnlyMode() { public boolean isInHudOnlyMode() {
return MapStage.getInstance().getDialogOnlyInput(); return MapStage.getInstance().isDialogOnlyInput();
} }
public void loadNext(String targetMap, int entryTargetObject) { public void loadNext(String targetMap, int entryTargetObject) {

View File

@@ -313,7 +313,7 @@ public class GameHUD extends Stage {
return true; return true;
} }
//auto follow touchpad //auto follow touchpad
if (GuiBase.isAndroid() && !MapStage.getInstance().getDialogOnlyInput() && !console.isVisible()) { if (GuiBase.isAndroid() && !MapStage.getInstance().isDialogOnlyInput() && !console.isVisible()) {
if (!(Controls.actorContainsVector(avatar, touch)) // not inside avatar bounds if (!(Controls.actorContainsVector(avatar, touch)) // not inside avatar bounds
&& !(Controls.actorContainsVector(miniMap, touch)) // not inside map bounds && !(Controls.actorContainsVector(miniMap, touch)) // not inside map bounds
&& !(Controls.actorContainsVector(gamehud, touch)) //not inside gamehud bounds && !(Controls.actorContainsVector(gamehud, touch)) //not inside gamehud bounds
@@ -687,6 +687,7 @@ public class GameHUD extends Stage {
} }
private void exitDungeonCallback() { private void exitDungeonCallback() {
MapStage.getInstance().onBeginLeavingDungeon();
hideDialog(true); hideDialog(true);
} }
@@ -874,6 +875,8 @@ public class GameHUD extends Stage {
dialog.show(this, Actions.show()); dialog.show(this, Actions.show());
dialog.setPosition((this.getWidth() - dialog.getWidth()) / 2, (this.getHeight() - dialog.getHeight()) / 2); dialog.setPosition((this.getWidth() - dialog.getWidth()) / 2, (this.getHeight() - dialog.getHeight()) / 2);
dialogOnlyInput = true; dialogOnlyInput = true;
gameStage.hudIsShowingDialog(true);
MapStage.getInstance().hudIsShowingDialog(true);
if (Forge.hasGamepad() && !dialogButtonMap.isEmpty()) if (Forge.hasGamepad() && !dialogButtonMap.isEmpty())
this.setKeyboardFocus(dialogButtonMap.first()); this.setKeyboardFocus(dialogButtonMap.first());
} }
@@ -891,7 +894,10 @@ public class GameHUD extends Stage {
return true; return true;
} }
})); }));
dialogOnlyInput = false; dialogOnlyInput = false;
gameStage.hudIsShowingDialog(false);
MapStage.getInstance().hudIsShowingDialog(false);
} }
private void selectNextDialogButton() { private void selectNextDialogButton() {

View File

@@ -85,10 +85,6 @@ public abstract class GameStage extends Stage {
protected final Array<TextraButton> dialogButtonMap = new Array<>(); protected final Array<TextraButton> dialogButtonMap = new Array<>();
TextraButton selectedKey; TextraButton selectedKey;
public boolean getDialogOnlyInput() {
return dialogOnlyInput;
}
public Dialog getDialog() { public Dialog getDialog() {
return dialog; return dialog;
} }
@@ -113,6 +109,7 @@ public abstract class GameStage extends Stage {
dialog.show(dialogStage, Actions.show()); dialog.show(dialogStage, Actions.show());
dialog.setPosition((dialogStage.getWidth() - dialog.getWidth()) / 2, (dialogStage.getHeight() - dialog.getHeight()) / 2); dialog.setPosition((dialogStage.getWidth() - dialog.getWidth()) / 2, (dialogStage.getHeight() - dialog.getHeight()) / 2);
dialogOnlyInput = true; dialogOnlyInput = true;
if (Forge.hasGamepad() && !dialogButtonMap.isEmpty()) if (Forge.hasGamepad() && !dialogButtonMap.isEmpty())
dialogStage.setKeyboardFocus(dialogButtonMap.first()); dialogStage.setKeyboardFocus(dialogButtonMap.first());
} }
@@ -124,6 +121,14 @@ public abstract class GameStage extends Stage {
dialog.clearListeners(); dialog.clearListeners();
} }
/**
* Triggered when the hud is showing a dialog, which is tracked separately
* @param isShowing Whether a dialog is currently showing
*/
public void hudIsShowingDialog(boolean isShowing) {
dialogOnlyInput = isShowing;
}
public void effectDialog(EffectData effectData) { public void effectDialog(EffectData effectData) {
dialog.getButtonTable().clear(); dialog.getButtonTable().clear();
dialog.getContentTable().clear(); dialog.getContentTable().clear();

View File

@@ -61,6 +61,7 @@ public class MapStage extends GameStage {
private EnemySprite currentMob; private EnemySprite currentMob;
Queue<Vector2> positions = new LinkedList<>(); Queue<Vector2> positions = new LinkedList<>();
private boolean isLoadingMatch = false; private boolean isLoadingMatch = false;
private boolean isPlayerLeavingDungeon = false;
//private HashMap<String, Byte> mapFlags = new HashMap<>(); //Stores local map flags. These aren't available outside this map. //private HashMap<String, Byte> mapFlags = new HashMap<>(); //Stores local map flags. These aren't available outside this map.
@@ -758,6 +759,8 @@ public class MapStage extends GameStage {
if (defeated) if (defeated)
WorldStage.getInstance().resetPlayerLocation(); WorldStage.getInstance().resetPlayerLocation();
Forge.switchScene(GameScene.instance()); Forge.switchScene(GameScene.instance());
isPlayerLeavingDungeon = false;
dialogOnlyInput = false;
return true; return true;
} }
@@ -934,8 +937,9 @@ public class MapStage extends GameStage {
@Override @Override
protected void onActing(float delta) { protected void onActing(float delta) {
if (isPaused() || isDialogOnlyInput() || Forge.advFreezePlayerControls) if (isPaused() || isDialogOnlyInput() || Forge.advFreezePlayerControls || isPlayerLeavingDungeon)
return; return;
Iterator<EnemySprite> it = enemies.iterator(); Iterator<EnemySprite> it = enemies.iterator();
if (freezeAllEnemyBehaviors) { if (freezeAllEnemyBehaviors) {
@@ -1110,6 +1114,10 @@ public class MapStage extends GameStage {
return isInMap; return isInMap;
} }
public void onBeginLeavingDungeon() {
isPlayerLeavingDungeon = true;
}
@Override @Override
public void showDialog() { public void showDialog() {
if (dialogStage == null){ if (dialogStage == null){

View File

@@ -1,7 +1,7 @@
package forge.adventure.util; package forge.adventure.util;
/** /**
* Interface to save the content the the save game file * Interface to save the content of the save game file
*/ */
public interface SaveFileContent { public interface SaveFileContent {
void load(SaveFileData data); void load(SaveFileData data);