Add delete for redo options

This commit is contained in:
ebolam
2022-09-22 13:21:27 -04:00
parent f63099ce33
commit 2fb1214709
4 changed files with 31 additions and 0 deletions

View File

@@ -7624,6 +7624,13 @@ def UI_2_Use_Option_Text(data):
else:
koboldai_vars.actions.use_option(int(data['option']), action_step=int(data['chunk']))
#==================================================================#
# Event triggered when Option is Selected
#==================================================================#
@socketio.on('delete_option')
@logger.catch
def UI_2_delete_option(data):
koboldai_vars.actions.delete_option(int(data['option']), action_step=int(data['chunk']))
#==================================================================#
# Event triggered when user clicks the submit button

View File

@@ -1141,6 +1141,7 @@ class KoboldStoryRegister(object):
process_variable_changes(self.socketio, "story", 'actions', {"id": pointer, 'action': self.actions[pointer]}, None)
self.set_game_saved()
def set_action_in_ai(self, action_id, used=True):
if 'In AI Input' in self.actions[action_id]:
old = self.actions[action_id]['In AI Input']
@@ -1195,6 +1196,17 @@ class KoboldStoryRegister(object):
self.action_count+=1
self.socketio.emit("var_changed", {"classname": "actions", "name": "Action Count", "old_value": None, "value":self.action_count}, broadcast=True, room="UI_2")
process_variable_changes(self.socketio, "story", 'actions', {"id": action_step, 'action': self.actions[action_step]}, None)
self.clear_unused_options(pointer=action_step)
ignore = self.koboldai_vars.calc_ai_text()
self.set_game_saved()
def delete_option(self, option_number, action_step=None):
if action_step is None:
action_step = self.action_count+1
if action_step in self.actions:
if option_number < len(self.actions[action_step]['Options']):
del self.actions[action_step]['Options'][option_number]
process_variable_changes(self.socketio, "story", 'actions', {"id": action_step, 'action': self.actions[action_step]}, None)
ignore = self.koboldai_vars.calc_ai_text()
self.set_game_saved()

View File

@@ -1270,6 +1270,12 @@ body {
grid-area: icon;
padding-left: 10px;
margin: auto auto auto auto;
display: flex;
flex-direction: column;
}
.delete_option_icon {
font-size: 1.2em !important;
}
.sequence:hover {

View File

@@ -220,6 +220,12 @@ function create_options(data) {
icon.classList.add("oi");
icon.setAttribute('data-glyph', "loop-circular");
iconcell.append(icon);
delete_icon = $e("span", iconcell, {"classes": ["material-icons-outlined", "cursor", 'delete_option_icon'],
"title": "delete option", 'option_id': i,
'option_chunk': data.value.id, 'textContent': 'delete'});
delete_icon.onclick = function () {
socket.emit("delete_option", {"chunk": this.getAttribute("option_chunk"), "option": this.getAttribute("option_id")});
};
textcell.onclick = function () {
socket.emit("Use Option Text", {"chunk": this.getAttribute("option_chunk"), "option": this.getAttribute("option_id")});
};