From 971444f847d0570a81c0657deff1d5877a34bd70 Mon Sep 17 00:00:00 2001 From: Daan Vanden Bosch Date: Wed, 2 Oct 2019 21:15:35 +0200 Subject: [PATCH] F5 keybinding for "Run in VM". Bugfix for feature flags. --- src/core/stores/GuiStore.ts | 4 ++-- src/quest_editor/gui/QuestEditorToolBar.ts | 10 ++++++++-- src/quest_editor/stores/QuestEditorStore.ts | 7 +++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/core/stores/GuiStore.ts b/src/core/stores/GuiStore.ts index 93702a38..abaed8df 100644 --- a/src/core/stores/GuiStore.ts +++ b/src/core/stores/GuiStore.ts @@ -38,8 +38,6 @@ class GuiStore implements Disposable { const url = window.location.hash.slice(2); const [tool_str, params_str] = url.split("?"); - this.tool.val = string_to_gui_tool(tool_str) || GuiTool.Viewer; - if (params_str) { const features = params_str .split("&") @@ -53,6 +51,8 @@ class GuiStore implements Disposable { } } + this.tool.val = string_to_gui_tool(tool_str) || GuiTool.Viewer; + this.server = this._server; window.addEventListener("keydown", this.dispatch_global_keydown); diff --git a/src/quest_editor/gui/QuestEditorToolBar.ts b/src/quest_editor/gui/QuestEditorToolBar.ts index a99e6a81..dcc41dd1 100644 --- a/src/quest_editor/gui/QuestEditorToolBar.ts +++ b/src/quest_editor/gui/QuestEditorToolBar.ts @@ -71,7 +71,7 @@ export class QuestEditorToolBar extends ToolBar { ); const run_button = new Button("Run in VM", { icon_left: Icon.Play, - tooltip: "[Experimental] Run the current quest in a virtual machine." + tooltip: "[Experimental] Run the current quest in a virtual machine (F5)", }); const children = [ @@ -117,7 +117,7 @@ export class QuestEditorToolBar extends ToolBar { quest_editor_store.set_current_area(area), ), - run_button.click.observe(() => quest_editor_store.run_current_quest_in_vm()), + run_button.click.observe(quest_editor_store.run_current_quest_in_vm), gui_store.on_global_keydown(GuiTool.QuestEditor, "Ctrl-O", () => open_file_button.click(), @@ -136,6 +136,12 @@ export class QuestEditorToolBar extends ToolBar { gui_store.on_global_keydown(GuiTool.QuestEditor, "Ctrl-Shift-Z", () => { undo_manager.redo(); }), + + gui_store.on_global_keydown( + GuiTool.QuestEditor, + "F5", + quest_editor_store.run_current_quest_in_vm, + ), ); this.finalize_construction(QuestEditorToolBar.prototype); diff --git a/src/quest_editor/stores/QuestEditorStore.ts b/src/quest_editor/stores/QuestEditorStore.ts index 48c18cea..7c566b4c 100644 --- a/src/quest_editor/stores/QuestEditorStore.ts +++ b/src/quest_editor/stores/QuestEditorStore.ts @@ -352,7 +352,7 @@ export class QuestEditorStore implements Disposable { } }; - run_current_quest_in_vm = () => { + run_current_quest_in_vm = (): void => { logger.setLevel(logger.TRACE); const quest = this.current_quest.val; @@ -365,8 +365,7 @@ export class QuestEditorStore implements Disposable { vm.load_object_code(quest.object_code); vm.start_thread(0); - exec_loop: - while (true) { + exec_loop: while (true) { const exec_result = vm.execute(); switch (exec_result) { @@ -379,7 +378,7 @@ export class QuestEditorStore implements Disposable { break exec_loop; } } - } + }; } export const quest_editor_store = new QuestEditorStore();