mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-14 19:39:29 +02:00
Add destroy function to ui handlers
This commit is contained in:
parent
001b61c1c7
commit
586607b2e3
@ -89,6 +89,13 @@ export class NavigationManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes menus from the manager in preparation for reset
|
||||
*/
|
||||
public clearNavigationMenus() {
|
||||
this.navigationMenus.length = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default class NavigationMenu extends Phaser.GameObjects.Container {
|
||||
|
@ -62,4 +62,9 @@ export default abstract class UiHandler {
|
||||
clear() {
|
||||
this.active = false;
|
||||
}
|
||||
/**
|
||||
* To be implemented by individual handlers when necessary to free memory
|
||||
* Called when {@linkcode BattleScene} is reset
|
||||
*/
|
||||
destroy(): void {}
|
||||
}
|
||||
|
11
src/ui/ui.ts
11
src/ui/ui.ts
@ -53,6 +53,7 @@ import TestDialogueUiHandler from "#app/ui/test-dialogue-ui-handler";
|
||||
import AutoCompleteUiHandler from "./autocomplete-ui-handler";
|
||||
import { Device } from "#enums/devices";
|
||||
import MysteryEncounterUiHandler from "./mystery-encounter-ui-handler";
|
||||
import { NavigationManager } from "./settings/navigationMenu";
|
||||
|
||||
export enum Mode {
|
||||
MESSAGE,
|
||||
@ -614,4 +615,14 @@ export default class UI extends Phaser.GameObjects.Container {
|
||||
return globalScene.inputMethod;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to free memory held by UI handlers
|
||||
* and clears menus from {@linkcode NavigationManager} to prepare for reset
|
||||
*/
|
||||
public freeUIData(): void {
|
||||
this.handlers.forEach(h => h.destroy());
|
||||
this.handlers = [];
|
||||
NavigationManager.getInstance().clearNavigationMenus();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user