F5 keybinding for "Run in VM". Bugfix for feature flags.

This commit is contained in:
Daan Vanden Bosch 2019-10-02 21:15:35 +02:00
parent f2d746642f
commit 971444f847
3 changed files with 13 additions and 8 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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();