2 Commits

Author SHA1 Message Date
8d2c58cb5f Merge pull request 'Remove bottom HUD text, move keys to ESC menu' (#28) from fix/remove-bottom-hud-text into master 2026-03-23 16:35:59 +00:00
986c2ea9eb 🔥 remove bottom HUD text, move keys to ESC menu (fixes #27)
- Removed controls hint text and tile coordinate display from the screen
- Removed coordsText / controlsHintText fields and createCoordsDisplay / onCameraMoved methods
- Added keyboard shortcut reference block at the bottom of the ESC menu

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-23 16:32:45 +00:00

View File

@@ -22,8 +22,6 @@ export class UIScene extends Phaser.Scene {
private villagerPanelVisible = false private villagerPanelVisible = false
private buildModeText!: Phaser.GameObjects.Text private buildModeText!: Phaser.GameObjects.Text
private farmToolText!: Phaser.GameObjects.Text private farmToolText!: Phaser.GameObjects.Text
private coordsText!: Phaser.GameObjects.Text
private controlsHintText!: Phaser.GameObjects.Text
private popText!: Phaser.GameObjects.Text private popText!: Phaser.GameObjects.Text
private stockpileTitleText!: Phaser.GameObjects.Text private stockpileTitleText!: Phaser.GameObjects.Text
private contextMenuGroup!: Phaser.GameObjects.Group private contextMenuGroup!: Phaser.GameObjects.Group
@@ -75,7 +73,6 @@ export class UIScene extends Phaser.Scene {
this.createBuildMenu() this.createBuildMenu()
this.createBuildModeIndicator() this.createBuildModeIndicator()
this.createFarmToolIndicator() this.createFarmToolIndicator()
this.createCoordsDisplay()
this.createDebugPanel() this.createDebugPanel()
const gameScene = this.scene.get('Game') const gameScene = this.scene.get('Game')
@@ -83,7 +80,6 @@ export class UIScene extends Phaser.Scene {
gameScene.events.on('farmToolChanged', (t: FarmingTool, l: string) => this.onFarmToolChanged(t, l)) gameScene.events.on('farmToolChanged', (t: FarmingTool, l: string) => this.onFarmToolChanged(t, l))
gameScene.events.on('toast', (m: string) => this.showToast(m)) gameScene.events.on('toast', (m: string) => this.showToast(m))
gameScene.events.on('openBuildMenu', () => this.toggleBuildMenu()) gameScene.events.on('openBuildMenu', () => this.toggleBuildMenu())
gameScene.events.on('cameraMoved', (pos: { tileX: number; tileY: number }) => this.onCameraMoved(pos))
this.input.keyboard!.addKey(Phaser.Input.Keyboard.KeyCodes.B) this.input.keyboard!.addKey(Phaser.Input.Keyboard.KeyCodes.B)
.on('down', () => gameScene.events.emit('uiRequestBuildMenu')) .on('down', () => gameScene.events.emit('uiRequestBuildMenu'))
@@ -386,24 +382,6 @@ export class UIScene extends Phaser.Scene {
this.farmToolText.setText(tool === 'none' ? '' : `[F] Farm: ${label} [RMB cancel]`).setVisible(tool !== 'none') this.farmToolText.setText(tool === 'none' ? '' : `[F] Farm: ${label} [RMB cancel]`).setVisible(tool !== 'none')
} }
// ─── Coords + controls ────────────────────────────────────────────────────
/** Creates the tile-coordinate display and controls hint at the bottom-left. */
private createCoordsDisplay(): void {
this.coordsText = this.add.text(10, this.scale.height - 24, '', { fontSize: '11px', color: '#666666', fontFamily: 'monospace' }).setScrollFactor(0).setDepth(100)
this.controlsHintText = this.add.text(10, this.scale.height - 42, '[WASD] Pan [Scroll] Zoom [F] Farm [B] Build [V] Nisse [F3] Debug', {
fontSize: '10px', color: '#444444', fontFamily: 'monospace', backgroundColor: '#00000066', padding: { x: 4, y: 2 }
}).setScrollFactor(0).setDepth(100)
}
/**
* Updates the tile-coordinate display when the camera moves.
* @param pos - Tile position of the camera center
*/
private onCameraMoved(pos: { tileX: number; tileY: number }): void {
this.coordsText.setText(`Tile: ${pos.tileX}, ${pos.tileY}`)
}
// ─── Debug Panel (F3) ───────────────────────────────────────────────────── // ─── Debug Panel (F3) ─────────────────────────────────────────────────────
/** Creates the debug panel text object (initially hidden). */ /** Creates the debug panel text object (initially hidden). */
@@ -589,8 +567,9 @@ export class UIScene extends Phaser.Scene {
{ label: '⚙️ Settings', action: () => this.doSettings() }, { label: '⚙️ Settings', action: () => this.doSettings() },
{ label: '🆕 New Game', action: () => this.doNewGame() }, { label: '🆕 New Game', action: () => this.doNewGame() },
] ]
// 32px header + entries × (btnH + 8px gap) + 8px bottom padding const keysBlock = '[WASD] Pan [Scroll] Zoom\n[F] Farm [B] Build [V] Nisse\n[F3] Debug [ESC] Menu'
const menuH = 32 + entries.length * (btnH + 8) + 8 // 32px header + entries × (btnH + 8px gap) + 8px sep + 46px keys block + 12px bottom padding
const menuH = 32 + entries.length * (btnH + 8) + 8 + 46 + 12
const mx = this.scale.width / 2 - menuW / 2 const mx = this.scale.width / 2 - menuW / 2
const my = this.scale.height / 2 - menuH / 2 const my = this.scale.height / 2 - menuH / 2
@@ -617,6 +596,14 @@ export class UIScene extends Phaser.Scene {
}).setOrigin(0, 0.5).setScrollFactor(0).setDepth(402) }).setOrigin(0, 0.5).setScrollFactor(0).setDepth(402)
) )
}) })
// Keyboard shortcuts reference at the bottom of the menu
const keysY = my + 32 + entries.length * (btnH + 8) + 8
this.escMenuGroup.add(
this.add.text(mx + menuW / 2, keysY, keysBlock, {
fontSize: '10px', color: '#555555', fontFamily: 'monospace', align: 'center',
}).setOrigin(0.5, 0).setScrollFactor(0).setDepth(401)
)
} }
/** Saves the game and shows a toast confirmation. */ /** Saves the game and shows a toast confirmation. */
@@ -1172,9 +1159,6 @@ export class UIScene extends Phaser.Scene {
// Bottom elements // Bottom elements
this.hintText.setPosition(width / 2, height - 40) this.hintText.setPosition(width / 2, height - 40)
this.toastText.setPosition(width / 2, 60) this.toastText.setPosition(width / 2, 60)
this.coordsText.setPosition(10, height - 24)
this.controlsHintText.setPosition(10, height - 42)
// Close centered panels — their position is calculated on open, so they // Close centered panels — their position is calculated on open, so they
// would be off-center if left open during a resize // would be off-center if left open during a resize
if (this.buildMenuVisible) this.closeBuildMenu() if (this.buildMenuVisible) this.closeBuildMenu()