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.
This commit is contained in:
Gnome Ann 2021-08-26 01:06:57 -04:00
parent 27c7baab92
commit 8fd8612cca
3 changed files with 10 additions and 8 deletions

View File

@ -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('<action>\\1</action>', item)
item = vars.acregex_ui.sub('<action>\\1</action>', item) # Add special formatting to adventure actions
text_parts.extend(('<chunk n="', str(idx), '" id="n', str(idx), '" tabindex="-1">', item, '</chunk>'))
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('<action>\\1</action>', item)
item = vars.acregex_ui.sub('<action>\\1</action>', item) # Add special formatting to adventure actions
chunk_text = f'<chunk n="{idx}" id="n{idx}" tabindex="-1">{formatforhtml(item)}</chunk>'
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)

View File

@ -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);
}

View File

@ -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 * {