Only the current area's event chains are now shown.

This commit is contained in:
Daan Vanden Bosch 2019-10-27 22:40:26 +01:00
parent a72b51511c
commit 2ed9659d9b

View File

@ -17,24 +17,30 @@ export class EventsView extends ResizableWidget {
super(); super();
this.disposables( this.disposables(
quest_editor_store.current_quest.observe(({ value: quest }) => { quest_editor_store.current_quest.observe(this.update),
this.quest_disposer.dispose_all(); quest_editor_store.current_area.observe(this.update),
if (quest) {
this.quest_disposer.add(
bind_children_to(
this.element,
quest.event_chains,
this.create_chain_element,
),
);
}
}),
); );
this.finalize_construction(EventsView.prototype); 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] => { private create_chain_element = (chain: QuestEventChainModel): [HTMLElement, Disposable] => {
const disposer = new Disposer(); const disposer = new Disposer();
const element = el.div( const element = el.div(