diff --git a/aiserver.py b/aiserver.py index 8f54677a..77032708 100644 --- a/aiserver.py +++ b/aiserver.py @@ -6495,6 +6495,13 @@ def UI_2_load_story(file): print("loading {}".format(file)) loadRequest(file) +#==================================================================# +# Event triggered on load story +#==================================================================# +@socketio.on('new_story') +def UI_2_new_story(data): + koboldai_vars.create_story("") + #==================================================================# # Event triggered when user moves world info diff --git a/koboldai_settings.py b/koboldai_settings.py index d40805c1..eba3b26f 100644 --- a/koboldai_settings.py +++ b/koboldai_settings.py @@ -316,7 +316,7 @@ class story_settings(settings): def __init__(self, socketio, tokenizer=None): self.socketio = socketio self.tokenizer = tokenizer - self.story_name = "" # Title of the story + self.story_name = "New Game" # Title of the story self.lastact = "" # The last action received from the user self.submission = "" # Same as above, but after applying input formatting self.lastctx = "" # The last context submitted to the generator diff --git a/static/koboldai.css b/static/koboldai.css index 5a207094..b14bd5a6 100644 --- a/static/koboldai.css +++ b/static/koboldai.css @@ -43,6 +43,10 @@ --wi_card_bg_color: #262626; --wi_card_tag_bg_color: #404040; --wi_tag_color: #337ab7; + + --story_pinned_areas: "menuicon options gamescreen lefticon" + "menuicon inputrow inputrow lefticon"; + --story_pinned_area_widths: 30px 30% auto 30px; } /*----------------Folder Tabs--------------------*/ @@ -603,9 +607,8 @@ body { .main-grid.story_pinned { margin-left: var(--flyout_menu_closed_width); margin-right: var(--flyout_menu_width); - grid-template-areas: "menuicon gamescreen options lefticon" - "menuicon inputrow inputrow lefticon"; - grid-template-columns: 30px auto 30% 30px; + grid-template-areas: var(--story_pinned_areas); + grid-template-columns: var(--story_pinned_area_widths); } .main-grid.settings_pinned.story_pinned { margin-left: var(--flyout_menu_width); diff --git a/static/koboldai.js b/static/koboldai.js index de16236e..1c16e9aa 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -1255,6 +1255,18 @@ function show_error_message(data) { error_message_box.querySelector("#popup_list_area").textContent = data; } //--------------------------------------------UI to Server Functions---------------------------------- +function new_story() { + //check if the story is saved + if (document.getElementById('save_story').getAttribute('story_gamesaved') == "false") { + //ask the user if they want to continue + if (window.confirm("You asked for a new story but your current story has not been saved. If you continue you will loose your changes.")) { + socket.emit('new_story', ''); + } + } else { + socket.emit('new_story', ''); + } +} + function save_as_story(response) { if (response == "overwrite?") { document.getElementById('save-confirm').classList.remove('hidden') @@ -1346,10 +1358,34 @@ function preserve_game_space(preserve) { if (preserve) { setCookie("preserve_game_space", "true"); r.style.setProperty('--setting_menu_closed_width_no_pins_width', '0px'); + if (!(document.getElementById('preserve_game_space_setting').checked)) { + //not sure why the bootstrap-toggle won't respect a standard item.checked = true/false, so.... + document.getElementById('preserve_game_space_setting').parentNode.click(); + } document.getElementById('preserve_game_space_setting').checked = true; } else { setCookie("preserve_game_space", "false"); r.style.setProperty('--setting_menu_closed_width_no_pins_width', '450px'); + if (document.getElementById('preserve_game_space_setting').checked) { + //not sure why the bootstrap-toggle won't respect a standard item.checked = true/false, so.... + document.getElementById('preserve_game_space_setting').parentNode.click(); + } + document.getElementById('preserve_game_space_setting').checked = false; + } +} + +function options_on_right(data) { + var r = document.querySelector(':root'); + console.log("Setting cookie to: "+data); + if (data) { + setCookie("options_on_right", "true"); + r.style.setProperty('--story_pinned_areas', '"menuicon gamescreen options lefticon"\n"menuicon inputrow inputrow lefticon"'); + r.style.setProperty('--story_pinned_area_widths', '30px auto 30% 30px'); + document.getElementById('preserve_game_space_setting').checked = true; + } else { + setCookie("options_on_right", "false"); + r.style.setProperty('--story_pinned_areas', '"menuicon options gamescreen lefticon"\n"menuicon inputrow inputrow lefticon"'); + r.style.setProperty('--story_pinned_area_widths', '30px 30% auto 30px'); document.getElementById('preserve_game_space_setting').checked = false; } } @@ -2071,4 +2107,5 @@ $(document).ready(function(){ } console.log("cookie: "+getCookie("preserve_game_space")); preserve_game_space((getCookie("preserve_game_space") == "true")); + options_on_right((getCookie("options_on_right") == "true")); }); \ No newline at end of file diff --git a/templates/settings flyout.html b/templates/settings flyout.html index a1a2b96e..c9bcd988 100644 --- a/templates/settings flyout.html +++ b/templates/settings flyout.html @@ -53,6 +53,7 @@
Story Name:
+ @@ -106,6 +107,23 @@
+
+ + Keep options on Right: + + ? + + When enabled and only the story menu is pinned, the generated story options will be shown on the right instead of the left of the game text. + + + + + + + + + +
\ No newline at end of file