Merge pull request #162 from VE-FORBRYDERNE/whitespace-cleanup

Story whitespace cleanup
This commit is contained in:
henk717
2022-06-25 13:36:03 +02:00
committed by GitHub
4 changed files with 65 additions and 6 deletions

View File

@ -5474,7 +5474,8 @@ def loadRequest(loadpath, filename=None):
for text in js['actions']:
vars.actions_metadata[i] = {'Selected Text': text, 'Alternative Text': []}
i+=1
footer = ""
if(len(vars.prompt.strip()) == 0):
while(len(actions)):
@ -5484,9 +5485,25 @@ def loadRequest(loadpath, filename=None):
break
else:
vars.gamestarted = False
vars.prompt = vars.prompt.lstrip()
ln = len(vars.prompt.rstrip())
footer += vars.prompt[ln:]
vars.prompt = vars.prompt[:ln]
if(vars.gamestarted):
for s in actions:
vars.actions.append(s)
if(len(s.strip()) == 0):
# If this action only contains whitespace, we merge it with the next action
footer += s
continue
vars.actions.append(footer + s)
footer = ""
# If there is trailing whitespace at the end of an action, we move that whitespace to the beginning of the next action
ln = len(vars.actions[vars.actions.get_last_key()].rstrip())
footer += vars.actions[vars.actions.get_last_key()][ln:]
vars.actions[vars.actions.get_last_key()] = vars.actions[vars.actions.get_last_key()][:ln]
if(len(vars.actions) == 0):
vars.gamestarted = False
# Try not to break older save files
if("authorsnote" in js):