From 2ed9659d9b8e4102c54dc00f3c9adaa37ea203ad Mon Sep 17 00:00:00 2001 From: Daan Vanden Bosch Date: Sun, 27 Oct 2019 22:40:26 +0100 Subject: [PATCH] Only the current area's event chains are now shown. --- src/quest_editor/gui/EventsView.ts | 32 ++++++++++++++++++------------ 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/quest_editor/gui/EventsView.ts b/src/quest_editor/gui/EventsView.ts index c0d81927..00505a01 100644 --- a/src/quest_editor/gui/EventsView.ts +++ b/src/quest_editor/gui/EventsView.ts @@ -17,24 +17,30 @@ export class EventsView extends ResizableWidget { super(); this.disposables( - quest_editor_store.current_quest.observe(({ value: quest }) => { - this.quest_disposer.dispose_all(); - - if (quest) { - this.quest_disposer.add( - bind_children_to( - this.element, - quest.event_chains, - this.create_chain_element, - ), - ); - } - }), + quest_editor_store.current_quest.observe(this.update), + quest_editor_store.current_area.observe(this.update), ); this.finalize_construction(EventsView.prototype); } + private update = (): void => { + this.quest_disposer.dispose_all(); + + const quest = quest_editor_store.current_quest.val; + const area = quest_editor_store.current_area.val; + + if (quest && area) { + this.quest_disposer.add( + bind_children_to( + this.element, + quest.event_chains.filtered(chain => chain.events.get(0).area_id === area.id), + this.create_chain_element, + ), + ); + } + }; + private create_chain_element = (chain: QuestEventChainModel): [HTMLElement, Disposable] => { const disposer = new Disposer(); const element = el.div(