Support keyboard turn prompt actions

This commit is contained in:
2026-07-05 03:38:33 +09:00
parent 7063895b23
commit 7ac636874d

View File

@@ -3059,6 +3059,8 @@ export class BattleScene extends Phaser.Scene {
private battleEventObjects: Phaser.GameObjects.GameObject[] = [];
private turnPromptObjects: Phaser.GameObjects.GameObject[] = [];
private turnPromptMode?: TurnPromptMode;
private turnPromptPrimaryAction?: () => void;
private turnPromptSecondaryAction?: () => void;
private combatCutInObjects: Phaser.GameObjects.GameObject[] = [];
private facingIndicatorObjects: Phaser.GameObjects.GameObject[] = [];
private facingIndicatorUnitId?: string;
@@ -3167,6 +3169,11 @@ export class BattleScene extends Phaser.Scene {
});
this.input.on('pointermove', (pointer: Phaser.Input.Pointer) => this.updatePointerFeedback(pointer));
this.input.keyboard?.on('keydown-ENTER', () => {
if (this.turnPromptObjects.length > 0) {
this.activateTurnPromptPrimaryAction();
return;
}
this.confirmLockedTargetPreview();
});
this.input.keyboard?.on('keydown-ESC', () => {
@@ -3191,8 +3198,7 @@ export class BattleScene extends Phaser.Scene {
}
if (this.turnPromptObjects.length > 0) {
soundDirector.playSelect();
this.hideTurnEndPrompt();
this.activateTurnPromptSecondaryAction();
return;
}
@@ -4700,7 +4706,6 @@ export class BattleScene extends Phaser.Scene {
this.hideTurnEndPrompt();
this.showCommandMenu(unit, commandX, commandY);
this.renderUnitDetail(unit, '공격, 책략, 도구, 대기 중 하나를 선택하세요.\n우클릭하면 이동을 취소합니다.');
soundDirector.playSelect();
}
});
}
@@ -15703,20 +15708,22 @@ export class BattleScene extends Phaser.Scene {
const secondaryLabel = options.secondaryLabel ?? '전장 확인';
const primaryAction = options.primaryAction ?? (() => this.endAllyTurn());
const secondaryAction = options.secondaryAction ?? (() => this.hideTurnEndPrompt());
this.turnPromptPrimaryAction = primaryAction;
this.turnPromptSecondaryAction = secondaryAction;
const buttonWidth = 136;
const buttons = [
{ label: primaryLabel, x: left + 119, action: primaryAction, primary: true },
{ label: secondaryLabel, x: left + 269, action: secondaryAction, primary: false }
{ label: primaryLabel, x: left + 119, primary: true },
{ label: secondaryLabel, x: left + 269, primary: false }
];
buttons.forEach(({ label, x, action, primary }) => {
buttons.forEach(({ label, x, primary }) => {
const bg = this.add.rectangle(x, top + 116, buttonWidth, 36, 0x1a2630, 0.95);
bg.setDepth(41);
bg.setStrokeStyle(1, primary ? palette.gold : palette.blue, 0.72);
bg.setInteractive({ useHandCursor: true });
bg.on('pointerover', () => bg.setFillStyle(0x283947, 0.98));
bg.on('pointerout', () => bg.setFillStyle(0x1a2630, 0.95));
bg.on('pointerdown', action);
bg.on('pointerdown', () => (primary ? this.activateTurnPromptPrimaryAction() : this.activateTurnPromptSecondaryAction()));
this.turnPromptObjects.push(bg);
const text = this.add.text(x, top + 116, label, {
@@ -15728,17 +15735,34 @@ export class BattleScene extends Phaser.Scene {
text.setOrigin(0.5);
text.setDepth(42);
text.setInteractive({ useHandCursor: true });
text.on('pointerdown', action);
text.on('pointerdown', () => (primary ? this.activateTurnPromptPrimaryAction() : this.activateTurnPromptSecondaryAction()));
this.turnPromptObjects.push(text);
});
void message;
}
private activateTurnPromptPrimaryAction() {
if (!this.turnPromptPrimaryAction) {
return;
}
soundDirector.playSelect();
this.turnPromptPrimaryAction();
}
private activateTurnPromptSecondaryAction() {
const action = this.turnPromptSecondaryAction ?? (() => this.hideTurnEndPrompt());
soundDirector.playSelect();
action();
}
private hideTurnEndPrompt() {
this.turnPromptObjects.forEach((object) => object.destroy());
this.turnPromptObjects = [];
this.turnPromptMode = undefined;
this.turnPromptPrimaryAction = undefined;
this.turnPromptSecondaryAction = undefined;
}
private pushBattleLog(message: string) {