2019-08-28 06:50:38 +08:00
|
|
|
import { ResizableWidget } from "../../core/gui/ResizableWidget";
|
2019-08-26 21:42:12 +08:00
|
|
|
import { el } from "../../core/gui/dom";
|
2019-08-28 06:50:38 +08:00
|
|
|
import { RendererWidget } from "../../core/gui/RendererWidget";
|
2019-08-26 21:42:12 +08:00
|
|
|
import { QuestRenderer } from "../rendering/QuestRenderer";
|
|
|
|
import { gui_store, GuiTool } from "../../core/stores/GuiStore";
|
2019-08-27 01:19:19 +08:00
|
|
|
import { quest_editor_store } from "../stores/QuestEditorStore";
|
2019-08-26 21:42:12 +08:00
|
|
|
|
2019-08-28 06:50:38 +08:00
|
|
|
export class QuestRendererView extends ResizableWidget {
|
2019-09-16 01:32:34 +08:00
|
|
|
readonly element = el.div({ class: "quest_editor_QuestRendererView", tab_index: -1 });
|
|
|
|
|
2019-08-28 06:50:38 +08:00
|
|
|
private renderer_view = this.disposable(new RendererWidget(new QuestRenderer()));
|
2019-08-26 21:42:12 +08:00
|
|
|
|
|
|
|
constructor() {
|
2019-09-16 01:32:34 +08:00
|
|
|
super();
|
2019-08-26 21:42:12 +08:00
|
|
|
|
|
|
|
this.element.append(this.renderer_view.element);
|
|
|
|
|
2019-08-27 01:19:19 +08:00
|
|
|
this.element.addEventListener("focus", () => quest_editor_store.undo.make_current(), true);
|
|
|
|
|
2019-08-26 21:42:12 +08:00
|
|
|
this.renderer_view.start_rendering();
|
|
|
|
|
|
|
|
this.disposables(
|
|
|
|
gui_store.tool.observe(({ value: tool }) => {
|
|
|
|
if (tool === GuiTool.QuestEditor) {
|
|
|
|
this.renderer_view.start_rendering();
|
|
|
|
} else {
|
|
|
|
this.renderer_view.stop_rendering();
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
);
|
2019-09-14 21:20:36 +08:00
|
|
|
|
|
|
|
this.finalize_construction(QuestRendererView.prototype);
|
2019-08-26 21:42:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
resize(width: number, height: number): this {
|
|
|
|
super.resize(width, height);
|
|
|
|
|
|
|
|
this.renderer_view.resize(width, height);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|