Checkpoint before line-grid scrolling refactor
This commit is contained in:
@@ -13,7 +13,7 @@ class ChoiceDisplayModule extends BaseModule {
|
||||
this.container = null;
|
||||
this.choices = [];
|
||||
this.inputMode = 'text';
|
||||
this.processState = document.documentElement.dataset.processState || 'ready';
|
||||
this.processState = document.documentElement.dataset.processState || 'loading';
|
||||
this.template = {
|
||||
cells: {
|
||||
default: {
|
||||
@@ -54,6 +54,14 @@ class ChoiceDisplayModule extends BaseModule {
|
||||
this.addEventListener(document, 'story:process-state', (event) => {
|
||||
this.handleProcessState(event.detail?.state || 'ready');
|
||||
});
|
||||
this.addEventListener(document, 'story:turn-start', () => {
|
||||
this.processState = 'waiting-generating';
|
||||
this.render();
|
||||
});
|
||||
this.addEventListener(document, 'story:history-restoring', (event) => {
|
||||
document.documentElement.dataset.historyRestoring = event.detail?.active ? 'true' : 'false';
|
||||
this.render();
|
||||
});
|
||||
this.addEventListener(document, 'keydown', this.handleKeyDown);
|
||||
|
||||
this.reportProgress(100, 'Choice display ready');
|
||||
@@ -81,6 +89,9 @@ class ChoiceDisplayModule extends BaseModule {
|
||||
} else if (!commandInput && this.container !== choicesRoot.lastElementChild) {
|
||||
choicesRoot.appendChild(this.container);
|
||||
}
|
||||
|
||||
this.container.hidden = true;
|
||||
this.container.dataset.choiceReady = 'false';
|
||||
}
|
||||
|
||||
handleChoices(choices) {
|
||||
@@ -188,7 +199,13 @@ class ChoiceDisplayModule extends BaseModule {
|
||||
if (!this.container) return;
|
||||
|
||||
this.container.innerHTML = '';
|
||||
const readyForChoices = this.inputMode === 'choice' && this.choices.length > 0 && this.processState === 'ready';
|
||||
const restoringHistory = document.documentElement.dataset.historyRestoring === 'true';
|
||||
const gameRunning = document.body?.dataset?.gameRunning === 'true';
|
||||
const readyForChoices = gameRunning &&
|
||||
!restoringHistory &&
|
||||
this.inputMode === 'choice' &&
|
||||
this.choices.length > 0 &&
|
||||
this.processState === 'ready';
|
||||
this.container.hidden = !readyForChoices;
|
||||
this.container.dataset.choiceReady = readyForChoices ? 'true' : 'false';
|
||||
if (this.container.hidden) {
|
||||
|
||||
Reference in New Issue
Block a user