From e8c9058084b90444ae7a664a8b1774e66d536fcc Mon Sep 17 00:00:00 2001 From: ThaumRystra Date: Mon, 2 Sep 2024 23:50:13 +0200 Subject: [PATCH] Made folders into groups in tabletop --- .vscode/settings.json | 2 + .../api/creature/creatures/Creatures.ts | 21 ----- .../client/ui/creature/actions/doAction.ts | 1 + .../client/ui/tabletop/TabletopActionCard.vue | 9 +- .../SelectedCreatureBar.vue | 91 ++++++++++++------- 5 files changed, 61 insertions(+), 63 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 58810132..2704425a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,6 +10,7 @@ "EJSON", "healthbar", "healthbars", + "jank", "meteortesting", "nearley", "ngraph", @@ -19,6 +20,7 @@ "Spellcasting", "uncomputed", "vuetify", + "Vuex", "walkdown" ] } \ No newline at end of file diff --git a/app/imports/api/creature/creatures/Creatures.ts b/app/imports/api/creature/creatures/Creatures.ts index 0abcc963..af8121d6 100644 --- a/app/imports/api/creature/creatures/Creatures.ts +++ b/app/imports/api/creature/creatures/Creatures.ts @@ -35,12 +35,6 @@ export type Creature = Colored & Shared & { // Tabletop tabletopId?: string, initiativeRoll?: number, - tabletopSettings?: { - iconGroups: { - name?: string, - iconIds: string[], - }[], - }, settings: { useVariantEncumbrance?: true, @@ -131,17 +125,6 @@ const IconGroupSchema = new SimpleSchema({ }, }); -const CreatureTabletopSettingsSchema = new SimpleSchema({ - iconGroups: { - type: Array, - defaultValue: [], - max: 10, - }, - 'iconGroups.$': { - type: IconGroupSchema, - }, -}); - const CreatureSchema = new SimpleSchema({ // Strings name: { @@ -252,10 +235,6 @@ const CreatureSchema = new SimpleSchema({ type: SimpleSchema.Integer, optional: true, }, - tabletopSettings: { - type: CreatureTabletopSettingsSchema, - optional: true, - }, // Settings settings: { diff --git a/app/imports/client/ui/creature/actions/doAction.ts b/app/imports/client/ui/creature/actions/doAction.ts index 16d3d7b8..de4e2768 100644 --- a/app/imports/client/ui/creature/actions/doAction.ts +++ b/app/imports/client/ui/creature/actions/doAction.ts @@ -59,6 +59,7 @@ export default async function doAction( task, }, callback(action: EngineAction) { + if (!action) return; resolve(callActionMethod(action, task)); return elementId; }, diff --git a/app/imports/client/ui/tabletop/TabletopActionCard.vue b/app/imports/client/ui/tabletop/TabletopActionCard.vue index bb32390e..060b8cd0 100644 --- a/app/imports/client/ui/tabletop/TabletopActionCard.vue +++ b/app/imports/client/ui/tabletop/TabletopActionCard.vue @@ -3,7 +3,6 @@ class="action-card overflow-y-auto" rounded :class="cardClasses" - :data-id="model._id" >
{{ model.name || propertyName }} @@ -230,13 +230,6 @@ export default { this.activated = undefined; }, 150); }, - openPropertyDetails() { - this.$store.commit('pushDialogStack', { - component: 'creature-property-dialog', - elementId: `${this.model._id}`, - data: {_id: this.model._id}, - }); - }, } } diff --git a/app/imports/client/ui/tabletop/selectedCreatureBar/SelectedCreatureBar.vue b/app/imports/client/ui/tabletop/selectedCreatureBar/SelectedCreatureBar.vue index f96c1f1a..89bac160 100644 --- a/app/imports/client/ui/tabletop/selectedCreatureBar/SelectedCreatureBar.vue +++ b/app/imports/client/ui/tabletop/selectedCreatureBar/SelectedCreatureBar.vue @@ -19,6 +19,7 @@ :close-on-click="false" :content-class="`tabletop-prop-menu rows-${rows}`" :close-on-content-click="false" + style="z-index: 2" > + + + + {{ activeIcon.icon }} + + {{ activeIcon.actionName }} + + propId + }); + // Close the menu while the dialog is open + this.menuOpen = false; }, }, meteor: { @@ -279,9 +314,9 @@ export default { // Get the standard icons const standardIconsById = { - 'cast-spell': {standardId: 'cast-spell', groupName: 'Standard Actions', icon: 'mdi-fire' }, - 'make-check': {standardId: 'make-check', groupName: 'Standard Actions', icon: 'mdi-radiobox-marked' }, - 'roll-dice': {standardId: 'roll-dice', groupName: 'Standard Actions', icon: 'mdi-dice-d20' }, + 'cast-spell': {standardId: 'cast-spell', groupName: 'Standard Actions', icon: 'mdi-fire', actionName: 'Cast Spell' }, + 'make-check': {standardId: 'make-check', groupName: 'Standard Actions', icon: 'mdi-radiobox-marked', actionName: 'Check' }, + 'roll-dice': {standardId: 'roll-dice', groupName: 'Standard Actions', icon: 'mdi-dice-d20', actionName: 'Roll' }, 'tab-stats': {standardId: 'tab-stats', groupName: 'Tabs', icon: 'mdi-chart-box', tab: 'stats', tabName: 'Stats' }, 'tab-actions': {standardId: 'tab-actions', groupName: 'Tabs', icon: 'mdi-lightning-bolt', tab: 'actions', tabName: 'Actions' }, 'tab-spells': this.creature?.settings?.hideSpellsTab ? undefined : {standardId: 'tab-spells', groupName: 'Tabs', icon: 'mdi-fire', tab: 'spells', tabName: 'Spells' }, @@ -292,28 +327,29 @@ export default { }; // Get the folders that could hide a property - const folderIds = CreatureProperties.find({ + const folderGroupsById = {}; + CreatureProperties.find({ 'root.id': this.creatureId, type: 'folder', groupStats: true, hideStatsGroup: true, removed: { $ne: true }, inactive: { $ne: true }, - }, { fields: { _id: 1 } }).map(folder => folder._id); + }, { fields: { _id: 1 } }).forEach(folder => { + const folderGroup = { name: folder._id, iconList: [] }; + iconGroups.push(folderGroup); + folderGroupsById[folder._id] = folderGroup; + }); // Get the properties that need to be shown as an icon const filter = { 'root.id': this.creatureId, - 'parentId': { - $nin: folderIds, - }, $and: [ { $or: [ { type: 'action' }, - { type: 'folder', groupStats: true }, - { type: 'attribute' }, - { type: 'toggle' }, + // { type: 'attribute' }, + // { type: 'toggle' }, { type: 'buff' } ], }, @@ -335,30 +371,15 @@ export default { const props = []; CreatureProperties.find(filter, { sort: { left: -1 }, - fields: { _id: 1, type: 1 }, + fields: { _id: 1, type: 1, parentId: 1 }, }).forEach(prop => { props.push(prop); propsById[prop._id] = prop; - }); - - // Using the creature's custom icon groups, collect the props into groups - this.creature.tabletopSettings?.iconGroups.forEach(group => { - const iconList = []; - group.iconIds?.forEach(id => { - if (propsById[id]) { - const prop = propsById[id]; - prop._placedInGroup = true; - iconList.push({ propId: prop._id }); - } else if (standardIconsById[id]) { - const standardIcon = standardIconsById[id]; - standardIcon._placedInGroup = true; - iconList.push(standardIcon); - } - }); - iconGroups.push({ - name: group.name, - iconList, - }); + // If they are in a folder, group them by that folder first + if (folderGroupsById[prop.parentId]) { + prop._placedInGroup = true; + folderGroupsById[prop.parentId].iconList.push({ propId: prop._id }); + } }); // Default groups @@ -413,7 +434,9 @@ export default { iconGroups.buffs.rows = splitToNChunks(iconGroups.buffs.iconList, this.rows); } - return iconGroups; + const filteredIconGroups = iconGroups.filter(group => group.iconList.length); + filteredIconGroups.buffs = iconGroups.buffs; + return filteredIconGroups; } }, }