diff --git a/src/components/encounters/Entities.vue b/src/components/encounters/Entities.vue index a989caa6..0afae61f 100644 --- a/src/components/encounters/Entities.vue +++ b/src/components/encounters/Entities.vue @@ -111,8 +111,31 @@ :filter="searchNpc" wrap-cells > + +
@@ -565,6 +594,7 @@ export default { maxContent: true, }, }, + npcExpandData: {}, monster_resource_setter: undefined, loading_monsters: true, loading_npcs: true, @@ -992,6 +1022,27 @@ export default { ? this.$set(this.encounter.entities, uuid(), entity) : this.$set(this.encounter, "entities", { [uuid()]: entity }); }, + async toggleCustomNpc(props, id) { + props.expand = !props.expand; + if (props.expand && !this.npcExpandData[id]) { + try { + const npc = await this.get_npc({ uid: this.user.uid, id }); + if (!npc) { + props.expand = false; + this.$snotify.error("This NPC could not be loaded.", "NPC unavailable", { + position: "centerTop", + }); + return; + } + this.$set(this.npcExpandData, id, npc); + } catch (e) { + props.expand = false; + this.$snotify.error("Failed to load NPC statblock.", "Load error", { + position: "centerTop", + }); + } + } + }, setSize(e) { this.width = e.width; },