refactor: parameterize CommandPanel title and commands

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-03-07 16:25:11 +00:00
parent e5571ce073
commit be97e74032
2 changed files with 10 additions and 8 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ export class GameScene extends Phaser.Scene {
this.portraitCompositor = new PortraitCompositor();
this.npcInfoPanel = new NpcInfoPanel();
this.emojiManager = new InteractionEmojiManager();
this.commandPanel = new CommandPanel();
this.commandPanel = new CommandPanel('COMMANDS', [{ key: '1', label: 'Spawn NPC' }]);
this.commandPanel.show(); // Start in camera mode, so show immediately
// Draw tile grid
+9 -7
View File
@@ -21,7 +21,7 @@ export class CommandPanel {
private listContainer: HTMLDivElement;
private visible = false;
constructor() {
constructor(title = 'COMMANDS', commands: Command[] = [{ key: '1', label: 'Spawn NPC' }]) {
// Outer frame (doubled border, same as NpcInfoPanel)
this.outerFrame = document.createElement('div');
this.outerFrame.id = 'command-panel';
@@ -76,8 +76,8 @@ export class CommandPanel {
container.appendChild(shine);
// Title
const title = document.createElement('div');
title.style.cssText = `
const titleEl = document.createElement('div');
titleEl.style.cssText = `
font-size: 6px;
color: ${EB.textMuted};
text-align: center;
@@ -87,8 +87,8 @@ export class CommandPanel {
position: relative;
z-index: 2;
`;
title.textContent = '\u25C6 COMMANDS \u25C6';
container.appendChild(title);
titleEl.textContent = `\u25C6 ${title} \u25C6`;
container.appendChild(titleEl);
// Commands list
this.listContainer = document.createElement('div');
@@ -104,8 +104,10 @@ export class CommandPanel {
this.outerFrame.appendChild(container);
document.body.appendChild(this.outerFrame);
// Add default commands
this.addCommand({ key: '1', label: 'Spawn NPC' });
// Add commands
for (const cmd of commands) {
this.addCommand(cmd);
}
}
private addCommand(cmd: Command): void {