Fixed Ducking. Refined UI.
This commit is contained in:
@@ -9,7 +9,7 @@ class GameLoopModule extends BaseModule {
|
||||
super('game-loop', 'Game Loop');
|
||||
|
||||
// Dependencies
|
||||
this.dependencies = ['ui-controller', 'socket-client', 'text-buffer'];
|
||||
this.dependencies = ['ui-controller', 'socket-client', 'text-buffer', 'sentence-queue', 'playback-coordinator', 'animation-queue', 'audio-manager', 'tts-factory', 'ui-input-handler'];
|
||||
|
||||
// Game state
|
||||
this.gameState = {
|
||||
@@ -33,6 +33,7 @@ class GameLoopModule extends BaseModule {
|
||||
'requestStartGame',
|
||||
'requestSaveGame',
|
||||
'requestLoadGame',
|
||||
'resetClientPlaybackAndDisplay',
|
||||
'addText'
|
||||
]);
|
||||
}
|
||||
@@ -199,14 +200,7 @@ class GameLoopModule extends BaseModule {
|
||||
const socketClient = this.getModule('socket-client');
|
||||
if (!socketClient) return;
|
||||
|
||||
const uiController = this.getModule('ui-controller');
|
||||
if (uiController) {
|
||||
uiController.clearDisplay();
|
||||
}
|
||||
const textBuffer = this.getModule('text-buffer');
|
||||
if (textBuffer && typeof textBuffer.clear === 'function') {
|
||||
textBuffer.clear();
|
||||
}
|
||||
await this.resetClientPlaybackAndDisplay();
|
||||
const response = await socketClient.newGame();
|
||||
if (!response?.success) {
|
||||
console.error('GameLoop: newGame failed', response);
|
||||
@@ -246,14 +240,7 @@ class GameLoopModule extends BaseModule {
|
||||
return;
|
||||
}
|
||||
|
||||
const uiController = this.getModule('ui-controller');
|
||||
if (uiController) {
|
||||
uiController.clearDisplay();
|
||||
}
|
||||
const textBuffer = this.getModule('text-buffer');
|
||||
if (textBuffer && typeof textBuffer.clear === 'function') {
|
||||
textBuffer.clear();
|
||||
}
|
||||
await this.resetClientPlaybackAndDisplay();
|
||||
const response = await socketClient.loadGame(1);
|
||||
if (response?.success) {
|
||||
this.gameState.started = true;
|
||||
@@ -262,6 +249,48 @@ class GameLoopModule extends BaseModule {
|
||||
this.updateUIState();
|
||||
}
|
||||
}
|
||||
|
||||
async resetClientPlaybackAndDisplay() {
|
||||
const playbackCoordinator = this.getModule('playback-coordinator');
|
||||
if (playbackCoordinator && typeof playbackCoordinator.stop === 'function') {
|
||||
await playbackCoordinator.stop();
|
||||
}
|
||||
|
||||
const animationQueue = this.getModule('animation-queue');
|
||||
if (animationQueue && typeof animationQueue.clearAll === 'function') {
|
||||
animationQueue.clearAll();
|
||||
}
|
||||
|
||||
const ttsFactory = this.getModule('tts-factory');
|
||||
if (ttsFactory && typeof ttsFactory.stop === 'function') {
|
||||
ttsFactory.stop();
|
||||
}
|
||||
|
||||
const audioManager = this.getModule('audio-manager');
|
||||
if (audioManager && typeof audioManager.stopAllSounds === 'function') {
|
||||
audioManager.stopAllSounds();
|
||||
}
|
||||
|
||||
const sentenceQueue = this.getModule('sentence-queue');
|
||||
if (sentenceQueue && typeof sentenceQueue.clear === 'function') {
|
||||
sentenceQueue.clear();
|
||||
}
|
||||
|
||||
const textBuffer = this.getModule('text-buffer');
|
||||
if (textBuffer && typeof textBuffer.clear === 'function') {
|
||||
textBuffer.clear();
|
||||
}
|
||||
|
||||
const uiController = this.getModule('ui-controller');
|
||||
if (uiController) {
|
||||
uiController.clearDisplay();
|
||||
}
|
||||
|
||||
const inputHandler = this.getModule('ui-input-handler');
|
||||
if (inputHandler && typeof inputHandler.clearHistory === 'function') {
|
||||
inputHandler.clearHistory();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Manually add text to the buffer
|
||||
|
||||
Reference in New Issue
Block a user