From 8fd8612cca1111905ee212aebbeb1cb25fe6abe1 Mon Sep 17 00:00:00 2001 From: Gnome Ann <> Date: Thu, 26 Aug 2021 01:06:57 -0400 Subject: [PATCH] Adventure mode colouring now controlled by a CSS class So that we can just toggle the class instead of having aiserver.py send back the entire story. --- aiserver.py | 7 ++----- static/application.js | 5 +++++ static/custom.css | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/aiserver.py b/aiserver.py index 5065f86b..781c335a 100644 --- a/aiserver.py +++ b/aiserver.py @@ -705,7 +705,6 @@ def get_message(msg): vars.adventure = msg['data'] settingschanged() refresh_settings() - refresh_story() elif(msg['cmd'] == 'importwi'): wiimportrequest() @@ -1328,8 +1327,7 @@ def refresh_story(): item = vars.actions[idx] idx += 1 item = html.escape(item) - if vars.adventure: # Add special formatting to adventure actions - item = vars.acregex_ui.sub('\\1', item) + item = vars.acregex_ui.sub('\\1', item) # Add special formatting to adventure actions text_parts.extend(('', item, '')) emit('from_server', {'cmd': 'updatescreen', 'gamestarted': vars.gamestarted, 'data': formatforhtml(''.join(text_parts))}, broadcast=True) @@ -1356,8 +1354,7 @@ def update_story_chunk(idx: Union[int, Literal['last']]): text = vars.actions[idx - 1] item = html.escape(text) - if vars.adventure: # Add special formatting to adventure actions - item = vars.acregex_ui.sub('\\1', item) + item = vars.acregex_ui.sub('\\1', item) # Add special formatting to adventure actions chunk_text = f'{formatforhtml(item)}' emit('from_server', {'cmd': 'updatechunk', 'data': {'index': idx, 'html': chunk_text, 'last': (idx == (vars.actions.get_last_key() if len(vars.actions) else 0))}}, broadcast=True) diff --git a/static/application.js b/static/application.js index d6574b8f..6de2a044 100644 --- a/static/application.js +++ b/static/application.js @@ -615,6 +615,11 @@ function setmodevisibility(state) { function setadventure(state) { adventure = state; + if(state) { + game_text.addClass("adventure"); + } else { + game_text.removeClass("adventure"); + } if(!memorymode){ setmodevisibility(state); } diff --git a/static/custom.css b/static/custom.css index 15ee3521..46df0afa 100644 --- a/static/custom.css +++ b/static/custom.css @@ -6,14 +6,14 @@ chunk { color: #ffffff; } -action { +#gametext.adventure action { color: #9ff7fa; font-weight: bold; } chunk[contenteditable="true"]:focus, chunk[contenteditable="true"]:focus * { - color: #cdf; - font-weight: normal; + color: #cdf !important; + font-weight: normal !important; } chunk, chunk * {