fix a floating cursor not destroyed

pull/685/head
Greenlamp 2024-05-12 00:20:47 +02:00
parent 3b693d2231
commit ae85f1b416
1 changed files with 8 additions and 11 deletions

View File

@ -166,6 +166,9 @@ export default class SettingsGamepadUiHandler extends UiHandler {
Object.keys(this.layout).forEach((key) => this.layout[key].optionsContainer.setVisible(false)); Object.keys(this.layout).forEach((key) => this.layout[key].optionsContainer.setVisible(false));
const activeConfig = this.scene.inputController.getActiveConfig(); const activeConfig = this.scene.inputController.getActiveConfig();
const configType = activeConfig.padType; const configType = activeConfig.padType;
this.cursorObj?.destroy();
this.cursorObj = null;
this.scrollCursor = null;
const layout = this.layout[configType]; const layout = this.layout[configType];
this.keys = layout.keys; this.keys = layout.keys;
this.optionsContainer = layout.optionsContainer; this.optionsContainer = layout.optionsContainer;
@ -188,8 +191,8 @@ export default class SettingsGamepadUiHandler extends UiHandler {
if (!this.inputsIcons[key]) debugger; if (!this.inputsIcons[key]) debugger;
this.inputsIcons[key].setFrame(icon); this.inputsIcons[key].setFrame(icon);
} }
this.setCursor(0, true); this.setCursor(0);
this.setScrollCursor(0, true); this.setScrollCursor(0);
} }
show(args: any[]): boolean { show(args: any[]): boolean {
@ -197,7 +200,6 @@ export default class SettingsGamepadUiHandler extends UiHandler {
this.updateBindings(); this.updateBindings();
this.settingsContainer.setVisible(true); this.settingsContainer.setVisible(true);
this.setCursor(0);
this.setScrollCursor(0); this.setScrollCursor(0);
this.getUi().moveTo(this.settingsContainer, this.getUi().length - 1); this.getUi().moveTo(this.settingsContainer, this.getUi().length - 1);
@ -258,14 +260,9 @@ export default class SettingsGamepadUiHandler extends UiHandler {
return success; return success;
} }
setCursor(cursor: integer, override?: boolean): boolean { setCursor(cursor: integer): boolean {
const ret = super.setCursor(cursor); const ret = super.setCursor(cursor);
if (override) {
Object.keys(this.layout).forEach(k => this.layout[k].optionsContainer.remove(this.cursorObj));
this.cursorObj = null;
}
if (!this.cursorObj) { if (!this.cursorObj) {
this.cursorObj = this.scene.add.nineslice(0, 0, 'summary_moves_cursor', null, (this.scene.game.canvas.width / 6) - 10, 16, 1, 1, 1, 1); this.cursorObj = this.scene.add.nineslice(0, 0, 'summary_moves_cursor', null, (this.scene.game.canvas.width / 6) - 10, 16, 1, 1, 1, 1);
this.cursorObj.setOrigin(0, 0); this.cursorObj.setOrigin(0, 0);
@ -313,8 +310,8 @@ export default class SettingsGamepadUiHandler extends UiHandler {
return true; return true;
} }
setScrollCursor(scrollCursor: integer, override?: boolean): boolean { setScrollCursor(scrollCursor: integer): boolean {
if (scrollCursor === this.scrollCursor && !override) if (scrollCursor === this.scrollCursor)
return false; return false;
this.scrollCursor = scrollCursor; this.scrollCursor = scrollCursor;