Merge pull request #67 from ebolam/united

Autosave
This commit is contained in:
henk717 2022-01-20 14:03:41 +01:00 committed by GitHub
commit 1c98bf4f63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 0 deletions

View File

@ -166,6 +166,7 @@ class vars:
has_genmod = False # Whether or not at least one loaded Lua userscript has a generation modifier has_genmod = False # Whether or not at least one loaded Lua userscript has a generation modifier
svowname = "" # Filename that was flagged for overwrite confirm svowname = "" # Filename that was flagged for overwrite confirm
saveow = False # Whether or not overwrite confirm has been displayed saveow = False # Whether or not overwrite confirm has been displayed
autosave = False # Whether or not to automatically save after each action
genseqs = [] # Temporary storage for generated sequences genseqs = [] # Temporary storage for generated sequences
recentback = False # Whether Back button was recently used without Submitting or Retrying after recentback = False # Whether Back button was recently used without Submitting or Retrying after
recentrng = None # If a new random game was recently generated without Submitting after, this is the topic used (as a string), otherwise this is None recentrng = None # If a new random game was recently generated without Submitting after, this is the topic used (as a string), otherwise this is None
@ -2068,6 +2069,10 @@ def get_message(msg):
vars.chatmode = False vars.chatmode = False
settingschanged() settingschanged()
refresh_settings() refresh_settings()
elif(msg['cmd'] == 'autosave'):
vars.autosave = msg['data']
settingschanged()
refresh_settings()
elif(msg['cmd'] == 'setchatmode'): elif(msg['cmd'] == 'setchatmode'):
vars.chatmode = msg['data'] vars.chatmode = msg['data']
vars.adventure = False vars.adventure = False
@ -2160,6 +2165,7 @@ def savesettings():
js["nopromptgen"] = vars.nopromptgen js["nopromptgen"] = vars.nopromptgen
js["rngpersist"] = vars.rngpersist js["rngpersist"] = vars.rngpersist
js["nogenmod"] = vars.nogenmod js["nogenmod"] = vars.nogenmod
js["autosave"] = vars.autosave
js["antemplate"] = vars.setauthornotetemplate js["antemplate"] = vars.setauthornotetemplate
@ -2228,6 +2234,8 @@ def loadsettings():
vars.rngpersist = js["rngpersist"] vars.rngpersist = js["rngpersist"]
if("nogenmod" in js): if("nogenmod" in js):
vars.nogenmod = js["nogenmod"] vars.nogenmod = js["nogenmod"]
if("autosave" in js):
vars.autosave = js["autosave"]
if("antemplate" in js): if("antemplate" in js):
vars.setauthornotetemplate = js["antemplate"] vars.setauthornotetemplate = js["antemplate"]
@ -3238,6 +3246,10 @@ def update_story_chunk(idx: Union[int, str]):
chunk_text = f'<chunk n="{idx}" id="n{idx}" tabindex="-1">{formatforhtml(item)}</chunk>' 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}}, broadcast=True) emit('from_server', {'cmd': 'updatechunk', 'data': {'index': idx, 'html': chunk_text}}, broadcast=True)
#If we've set the auto save flag, we'll now save the file
if vars.autosave and (".json" in vars.savedir):
save()
#==================================================================# #==================================================================#
# Signals the Game Screen to remove one of the chunks # Signals the Game Screen to remove one of the chunks

View File

@ -173,6 +173,17 @@ gensettingstf = [{
"step": 1, "step": 1,
"default": 0, "default": 0,
"tooltip": "Disables userscript generation modifiers." "tooltip": "Disables userscript generation modifiers."
},
{
"uitype": "toggle",
"unit": "bool",
"label": "Auto Save",
"id": "autosave",
"min": 0,
"max": 1,
"step": 1,
"default": 0,
"tooltip": "Whether the game is saved after each action."
}] }]
gensettingsik =[{ gensettingsik =[{
@ -295,6 +306,17 @@ gensettingsik =[{
"step": 1, "step": 1,
"default": 0, "default": 0,
"tooltip": "When enabled, the Memory text box in the Random Story dialog will be prefilled by default with your current story's memory instead of being empty." "tooltip": "When enabled, the Memory text box in the Random Story dialog will be prefilled by default with your current story's memory instead of being empty."
},
{
"uitype": "toggle",
"unit": "bool",
"label": "Auto Save",
"id": "autosave",
"min": 0,
"max": 1,
"step": 1,
"default": 0,
"tooltip": "Whether the game is saved after each action."
}] }]
formatcontrols = [{ formatcontrols = [{