Fix for story loading from V1 only pulling in first action

Added accessibility labels for better support with screen readers.
This commit is contained in:
ebolam
2022-09-30 14:05:28 -04:00
parent 104ecd3ad3
commit bf58542ca5
3 changed files with 26 additions and 23 deletions

View File

@@ -7053,11 +7053,13 @@ def load_story_v1(js):
else:
koboldai_vars.gamestarted = False
if(koboldai_vars.gamestarted):
#We set the action count higher so that we don't trigger a scroll in the UI.
#Once all but the last is loaded we can bring it back down and do the last one so we scroll to it
koboldai_vars.actions.action_count += 1
for i in range(len(js["actions"])):
if i == len(js["actions"])-1:
koboldai_vars.actions.action_count -= 1
koboldai_vars.actions.append(js["actions"][i])
for i in range(len(js["actions"])-1):
koboldai_vars.actions.append(js["actions"][i], action_id_offset=-1)
koboldai_vars.actions.action_count -= 1
koboldai_vars.actions.append(js["actions"][len(js["actions"])-1])
if "actions_metadata" in js:
if type(js["actions_metadata"]) == dict:

View File

@@ -1113,30 +1113,31 @@ class KoboldStoryRegister(object):
self.set_game_saved()
self.story_settings.save_story()
def append(self, text):
def append(self, text, action_id_offset=0):
self.clear_unused_options()
self.action_count+=1
if self.action_count in self.actions:
if self.actions[self.action_count]["Selected Text"] != text:
self.actions[self.action_count]["Selected Text"] = text
self.actions[i]["WI Search Text"] = re.sub("[^0-9a-z \'\"]", "", text)
self.actions[self.action_count]["Probabilities"] = []
action_id = self.action_count + action_id_offset
if action_id in self.actions:
if self.actions[action_id]["Selected Text"] != text:
self.actions[action_id]["Selected Text"] = text
self.actions[action_id]["WI Search Text"] = re.sub("[^0-9a-z \'\"]", "", text)
self.actions[action_id]["Probabilities"] = []
selected_text_length = 0
self.actions[self.action_count]["Selected Text Length"] = selected_text_length
self.actions[self.action_count]["In AI Input"] = False
for item in self.actions[self.action_count]["Options"]:
self.actions[action_id]["Selected Text Length"] = selected_text_length
self.actions[action_id]["In AI Input"] = False
for item in self.actions[action_id]["Options"]:
if item['text'] == text:
old_options = self.actions[self.action_count]["Options"]
old_options = self.actions[action_id]["Options"]
del item
else:
selected_text_length = 0
self.actions[self.action_count] = {"Selected Text": text, "Selected Text Length": selected_text_length,
self.actions[action_id] = {"Selected Text": text, "Selected Text Length": selected_text_length,
"WI Search Text": re.sub("[^0-9a-z \'\"]", "", text),
"In AI Input": False, "Options": [], "Probabilities": []}
process_variable_changes(self.socketio, "story", 'actions', {"id": self.action_count, 'action': self.actions[self.action_count]}, None)
process_variable_changes(self.socketio, "story", 'actions', {"id": action_id, 'action': self.actions[action_id]}, None)
self.set_game_saved()
logger.debug("Calcing AI Text from Action Append")
ignore = self.koboldai_vars.calc_ai_text()

View File

@@ -7,14 +7,14 @@
<div class="flyout_menu_contents">
<div id="story_menu_memory" class="story_category_area tab-target tab-target-story">
<div id="Memory">
<h4 class="section_header">Memory</h4>
<h4 class="section_header"><label for="memory">Memory</label></h4>
<span class="help_text">
Important information the AI should always keep in mind.
</span>
<textarea rows=20 id="memory" class="var_sync_story_memory var_sync_alt_story_memory_length fullwidth" onchange='sync_to_server(this);' oninput="autoResize(this)" autocomplete="off"></textarea>
</div>
<div id="Auto-Memory">
<h4 class="section_header">Auto-Memory (non-functional)</h4>
<h4 class="section_header"><label for="auto_memory">Auto-Memory (non-functional)</label></h4>
<span class="help_text">
What the system would use for automatic memory summarized from the game
</span>
@@ -29,9 +29,9 @@
Heavily influences the direction and style of the AI's writing.
</span>
Template:<br/>
<input autocomplete="off" type=text class="var_sync_story_authornotetemplate fullwidth" onchange='sync_to_server(this);'><br/>
Author's Notes:<br/>
<label for="authors_notes_template">Template:</label><br/>
<input autocomplete="off" id=authors_notes_template type=text class="var_sync_story_authornotetemplate fullwidth" onchange='sync_to_server(this);'><br/>
<label for="authors_notes">Author's Notes:</label><br/>
<textarea autocomplete="off" rows=17 id="authors_notes" class="var_sync_story_authornote var_sync_alt_story_authornote_length fullwidth" oninput="autoResize(this)" onchange='sync_to_server(this);'></textarea><br/>
<div class="setting_tile_area">
{% with menu='author_notes' %}
@@ -44,11 +44,11 @@
</div>
<div id="story_menu_notes" class="story_category_area tab-target tab-target-story hidden">
<div id="Notes">
<h4 class="section_header">Notes</h4>
<h4 class="section_header"><label for="notes">Notes</label></h4>
<span class="help_text">
Notes about the story. These notes are not read by the AI!
</span>
<textarea autocomplete="off" rows=20 class="var_sync_story_notes fullwidth" onchange='sync_to_server(this);' oninput="autoResize(this)"></textarea>
<textarea id="notes" autocomplete="off" rows=20 class="var_sync_story_notes fullwidth" onchange='sync_to_server(this);' oninput="autoResize(this)"></textarea>
</div>
</div>
<div id="story_menu_wi" class="story_category_area tab-target tab-target-story hidden">