Stability fixes for back/retry re genseqs/useprompt

* Back and Retry buttons no longer pop a story chunk while in the
  "Select sequence to keep" menu
* No longer freezes if you retry with no story chunks beyond the initial
  prompt chunk
* When "Always Add Prompt" is on, allow Retry even if the prompt is the
  only chunk in the story
* Added error messages for Back and Retry buttons
This commit is contained in:
Gnome Ann 2021-08-25 14:42:37 -04:00
parent cbdf3fa037
commit cf677c60fc
2 changed files with 14 additions and 4 deletions

View File

@ -878,12 +878,16 @@ def actionretry(data):
return
if(vars.aibusy):
return
set_aibusy(1)
# Remove last action if possible and resubmit
if(len(vars.actions) > 0):
vars.actions.pop()
if(vars.gamestarted if vars.useprompt else len(vars.actions) > 0):
set_aibusy(1)
if(len(vars.actions) != 0 and len(vars.genseqs) == 0): # Don't pop if we're in the "Select sequence to keep" menu or if there are no non-prompt actions
vars.actions.pop()
vars.genseqs = []
refresh_story()
calcsubmit('')
elif(not vars.useprompt):
emit('from_server', {'cmd': 'errmsg', 'data': "Please enable \"Always Add Prompt\" to retry with your prompt."})
#==================================================================#
#
@ -892,9 +896,13 @@ def actionback():
if(vars.aibusy):
return
# Remove last index of actions and refresh game screen
if(len(vars.actions) > 0):
if(len(vars.genseqs) == 0 and len(vars.actions) > 0):
vars.actions.pop()
refresh_story()
elif(len(vars.genseqs) == 0):
emit('from_server', {'cmd': 'errmsg', 'data': "Cannot delete the prompt."})
else:
vars.genseqs = []
#==================================================================#
# Take submitted text and build the text to be given to generator

View File

@ -1070,11 +1070,13 @@ $(document).ready(function(){
});
button_actretry.on("click", function(ev) {
hideMessage();
socket.send({'cmd': 'retry', 'data': ''});
hidegenseqs();
});
button_actback.on("click", function(ev) {
hideMessage();
socket.send({'cmd': 'back', 'data': ''});
hidegenseqs();
});