Fixed Ducking. Refined UI.
This commit is contained in:
@@ -31,7 +31,9 @@ class UIInputHandlerModule extends BaseModule {
|
||||
'formatCommandHistory',
|
||||
'resetCursorPosition',
|
||||
'focusInput',
|
||||
'setProcessState'
|
||||
'setProcessState',
|
||||
'setInputAvailability',
|
||||
'clearHistory'
|
||||
]);
|
||||
|
||||
console.log('UIInputHandler: Constructor initialized');
|
||||
@@ -254,6 +256,24 @@ class UIInputHandlerModule extends BaseModule {
|
||||
}
|
||||
|
||||
console.log(`Cursor process state: ${nextState}`, detail);
|
||||
this.setInputAvailability(nextState === 'ready');
|
||||
}
|
||||
|
||||
setInputAvailability(enabled) {
|
||||
this.inputEnabled = Boolean(enabled);
|
||||
const commandInput = document.getElementById('command_input');
|
||||
if (commandInput) {
|
||||
commandInput.classList.toggle('fading', !this.inputEnabled);
|
||||
commandInput.setAttribute('aria-hidden', this.inputEnabled ? 'false' : 'true');
|
||||
}
|
||||
|
||||
if (this.playerInput) {
|
||||
this.playerInput.disabled = !this.inputEnabled;
|
||||
this.playerInput.readOnly = !this.inputEnabled;
|
||||
if (this.inputEnabled && document.body.dataset.gameRunning === 'true') {
|
||||
this.focusInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
applyMouseCursor(state) {
|
||||
@@ -344,6 +364,7 @@ class UIInputHandlerModule extends BaseModule {
|
||||
*/
|
||||
submitCommand() {
|
||||
if (!this.playerInput || !this.playerInput.value.trim()) return;
|
||||
if (document.body.dataset.gameRunning !== 'true' || !this.inputEnabled) return;
|
||||
|
||||
const command = this.playerInput.value.trim();
|
||||
console.log(`UIInputHandler: Submitting command: "${command}"`);
|
||||
@@ -367,6 +388,17 @@ class UIInputHandlerModule extends BaseModule {
|
||||
// Focus input field
|
||||
this.playerInput.focus();
|
||||
}
|
||||
|
||||
clearHistory() {
|
||||
this.commandHistory = [];
|
||||
this.historyIndex = -1;
|
||||
if (!this.commandHistoryElement) {
|
||||
this.commandHistoryElement = document.getElementById('command_history');
|
||||
}
|
||||
if (this.commandHistoryElement) {
|
||||
this.commandHistoryElement.innerHTML = '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add command to history
|
||||
|
||||
Reference in New Issue
Block a user