Added dedicated inline editing commands to aiserver.py

It's a lot faster now.
This commit is contained in:
Gnome Ann 2021-08-23 18:52:45 -04:00
parent a907c0a554
commit 3bf467e63c
2 changed files with 41 additions and 14 deletions

View File

@ -543,7 +543,7 @@ def get_message(msg):
# Back/Undo Action
elif(msg['cmd'] == 'back'):
actionback()
# EditMode Action
# EditMode Action (old)
elif(msg['cmd'] == 'edit'):
if(vars.mode == "play"):
vars.mode = "edit"
@ -551,10 +551,15 @@ def get_message(msg):
elif(vars.mode == "edit"):
vars.mode = "play"
emit('from_server', {'cmd': 'editmode', 'data': 'false'}, broadcast=True)
# EditLine Action
# EditLine Action (old)
elif(msg['cmd'] == 'editline'):
editrequest(int(msg['data']))
# DeleteLine Action
# Inline edit
elif(msg['cmd'] == 'inlineedit'):
inlineedit(msg['chunk'], msg['data'])
elif(msg['cmd'] == 'inlinedelete'):
inlinedelete(msg['data'])
# DeleteLine Action (old)
elif(msg['cmd'] == 'delete'):
deleterequest()
elif(msg['cmd'] == 'memory'):
@ -1382,7 +1387,7 @@ def editsubmit(data):
vars.mode = "play"
refresh_story()
emit('from_server', {'cmd': 'texteffect', 'data': vars.editln}, broadcast=True)
emit('from_server', {'cmd': 'editmode', 'data': 'false'}, broadcast=True)
emit('from_server', {'cmd': 'editmode', 'data': 'false'})
#==================================================================#
#
@ -1396,6 +1401,34 @@ def deleterequest():
del vars.actions[vars.editln-1]
vars.mode = "play"
refresh_story()
emit('from_server', {'cmd': 'editmode', 'data': 'false'})
#==================================================================#
#
#==================================================================#
def inlineedit(chunk, data):
chunk = int(chunk)
if(chunk == 0):
vars.prompt = data
else:
vars.actions[chunk-1] = data
refresh_story()
emit('from_server', {'cmd': 'texteffect', 'data': chunk}, broadcast=True)
emit('from_server', {'cmd': 'editmode', 'data': 'false'}, broadcast=True)
#==================================================================#
#
#==================================================================#
def inlinedelete(chunk):
chunk = int(chunk)
# Don't delete prompt
if(chunk == 0):
# Send error message
emit('from_server', {'cmd': 'editmode', 'data': 'false'}, broadcast=True)
else:
del vars.actions[chunk-1]
refresh_story()
emit('from_server', {'cmd': 'editmode', 'data': 'false'}, broadcast=True)
#==================================================================#

View File

@ -476,7 +476,7 @@ function newTextHighlight(ref) {
setTimeout(function () {
ref.removeClass("colorfade");
}, 1000);
}, 10);
}, 50);
}
function showAidgPopup() {
@ -732,17 +732,11 @@ function submitEditedChunk(event) {
chunk = current_editing_chunk;
current_editing_chunk = null;
// Enter edit mode if we aren't already in edit mode
if(!editmode) {
socket.send({'cmd': 'edit', 'data': ''});
}
// Submit the edited chunk if it's not empty, otherwise delete it
socket.send({'cmd': 'editline', 'data': chunk.getAttribute("n")});
if(chunk.innerText.length) {
socket.send({'cmd': 'submit', 'data': chunk.innerText});
socket.send({'cmd': 'inlineedit', 'chunk': chunk.getAttribute("n"), 'data': chunk.innerText});
} else {
socket.send({'cmd': 'delete', 'data': ''});
socket.send({'cmd': 'inlinedelete', 'data': chunk.getAttribute("n")});
}
}
@ -834,7 +828,7 @@ $(document).ready(function(){
}
});
} else if(msg.cmd == "updatescreen") {
_gamestarted = gamestarted
_gamestarted = gamestarted;
gamestarted = msg.gamestarted;
if(_gamestarted != gamestarted) {
action_mode = 0;