Polish #8

Merged
brianfertig merged 5 commits from Polish into main 2026-09-01 04:46:30 +00:00
1 changed files with 10 additions and 2 deletions
Showing only changes of commit 429102105b - Show all commits

View File

@ -24,12 +24,19 @@ const ICON_X_OFFSET = -145;
// How far (px) a grid travels off screen when switching categories.
const GRID_TRAVEL = GAME_WIDTH + 800;
// The most recently selected category. Module scope so it survives scene
// restarts (scene.start() reuses the instance) and also covers paths that
// start the menu without category data — the menu always returns to where
// the user last was.
let lastCategory = null;
export default class GameMenuScene extends Phaser.Scene {
constructor() { super('GameMenu'); }
init(data) {
// Set when coming back from the opponent picker — restore that category.
this._initialCategory = (data && data.category) || null;
// Category to restore on entry: the explicit one (coming back from the
// opponent picker) or the most recently selected one.
this._initialCategory = (data && data.category) || lastCategory;
// scene.start() reuses the existing scene instance, so instance props from
// the previous visit survive — reset them so this create() starts clean
// (otherwise showCategory()'s "same category" guard swallows the restore).
@ -152,6 +159,7 @@ export default class GameMenuScene extends Phaser.Scene {
showCategory(key) {
if (key === this._currentCategory) return;
this._currentCategory = key;
lastCategory = key;
if (this._hintText) { this._hintText.destroy(); this._hintText = null; }
if (this._titleText) {