From 6504e33fad95649d8a18b254f42f03569d04f9a2 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Mon, 25 Mar 2024 21:24:32 -0600 Subject: [PATCH 01/82] Remove prototype code that shouldn't be committed on main yet --- module/sheets/MobSheet.mjs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/module/sheets/MobSheet.mjs b/module/sheets/MobSheet.mjs index cb6412c..b2ecc06 100644 --- a/module/sheets/MobSheet.mjs +++ b/module/sheets/MobSheet.mjs @@ -1,6 +1,5 @@ import { GenericActorSheet } from "./GenericActorSheet.mjs"; import { DiceList } from "../dialogs/DiceList.mjs"; -import { PopoutTextEditor } from "../dialogs/PopoutTextEditor.mjs"; export class MobSheet extends GenericActorSheet { static get defaultOptions() { @@ -28,14 +27,6 @@ export class MobSheet extends GenericActorSheet { let d = new DiceList(this.actor); d.render(true); }); - html.find(`[data-text-editor]`) - .on(`click`, () => { - let editor = new PopoutTextEditor( - this.actor, - `system.description` - ); - editor.render(true); - }); }; async getData() { From 36976e5123e06b4130d219cb78e66aa760405410 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Mon, 25 Mar 2024 21:33:14 -0600 Subject: [PATCH 02/82] Add the pet details (closes #135) --- module/handlebars.mjs | 1 + module/models/Item/Pet.mjs | 8 +- module/sheets/Actors/PC/PlayerSheetV2.mjs | 2 +- .../actor/char-sheet/v2/pages/inventory.scss | 2 +- .../v2/partials/inventory/items/pet.v2.pc.hbs | 97 +++++++++++++++++++ 5 files changed, 107 insertions(+), 3 deletions(-) create mode 100644 templates/actors/char-sheet/v2/partials/inventory/items/pet.v2.pc.hbs diff --git a/module/handlebars.mjs b/module/handlebars.mjs index 596f9dd..a5a2ab3 100644 --- a/module/handlebars.mjs +++ b/module/handlebars.mjs @@ -30,6 +30,7 @@ export const partials = [ `actors/char-sheet/v2/partials/inventory/items/untyped.v2.pc.hbs`, `actors/char-sheet/v2/partials/inventory/items/aspect.v2.pc.hbs`, `actors/char-sheet/v2/partials/inventory/items/weapon.v2.pc.hbs`, + `actors/char-sheet/v2/partials/inventory/items/pet.v2.pc.hbs`, ]; export const preAliasedPartials = { diff --git a/module/models/Item/Pet.mjs b/module/models/Item/Pet.mjs index 7d46e94..886e761 100644 --- a/module/models/Item/Pet.mjs +++ b/module/models/Item/Pet.mjs @@ -3,7 +3,13 @@ import { DescribedItemData } from "./DescribedItemData.mjs"; export class PetItemData extends DescribedItemData { static defineSchema() { const fields = foundry.data.fields; - return mergeObject(super.defineSchema(), { + const parentSchema = super.defineSchema(); + + delete parentSchema.quantity; + delete parentSchema.quantity_affects_used_capacity; + delete parentSchema.usage_cost; + + return mergeObject(parentSchema, { upkeep: new fields.NumberField({ initial: null, nullable: true }), pokeballd: new fields.BooleanField({ initial: true }), }); diff --git a/module/sheets/Actors/PC/PlayerSheetV2.mjs b/module/sheets/Actors/PC/PlayerSheetV2.mjs index 63fe44a..32d0ed9 100644 --- a/module/sheets/Actors/PC/PlayerSheetV2.mjs +++ b/module/sheets/Actors/PC/PlayerSheetV2.mjs @@ -117,7 +117,7 @@ export class PlayerSheetv2 extends GenericActorSheet { return stats; }; - _itemTypesHidden = new Set([`pet`, `armour`, `equipment`, `structure`, `service`]); + _itemTypesHidden = new Set([`armour`, `equipment`, `structure`, `service`]); toggleItemFilter(filterName) { if (this._itemTypesHidden.has(filterName)) { this._itemTypesHidden.delete(filterName); diff --git a/styles/sheets/actor/char-sheet/v2/pages/inventory.scss b/styles/sheets/actor/char-sheet/v2/pages/inventory.scss index 8581328..c301f04 100644 --- a/styles/sheets/actor/char-sheet/v2/pages/inventory.scss +++ b/styles/sheets/actor/char-sheet/v2/pages/inventory.scss @@ -218,7 +218,7 @@ } } - .untyped, .aspect, .weapon { + .untyped, .aspect, .weapon, .pet { @include material.elevate(1); padding: 8px; border-radius: 4px; diff --git a/templates/actors/char-sheet/v2/partials/inventory/items/pet.v2.pc.hbs b/templates/actors/char-sheet/v2/partials/inventory/items/pet.v2.pc.hbs new file mode 100644 index 0000000..9c83d45 --- /dev/null +++ b/templates/actors/char-sheet/v2/partials/inventory/items/pet.v2.pc.hbs @@ -0,0 +1,97 @@ +
+
+ +

+ {{item.name}} +

+
+
+
+
+
+ + +
+
+ Upkeep: + + {{dd-empty-state item.system.upkeep}} + +
+
+ Tier: + {{dd-i18n (concat "dotdungeon.rarity." item.system.tier)}} +
+ +

+ {{#if item.system.description}} + {{item.system.description}} + {{else}} + + This pet hasn't been described yet... + + {{/if}} +

+ + +
+
+
From c7bafee6b6c0f3a8e0f1aa56a40b80f672d9be8c Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Mon, 25 Mar 2024 21:34:23 -0600 Subject: [PATCH 03/82] Misc template cleanup / consistency --- .../char-sheet/v2/partials/inventory/inventory.v2.pc.hbs | 2 +- .../char-sheet/v2/partials/inventory/item-list.v2.pc.hbs | 3 +-- .../char-sheet/v2/partials/inventory/items/aspect.v2.pc.hbs | 1 - .../actors/char-sheet/v2/partials/inventory/player.v2.pc.hbs | 2 +- .../actors/char-sheet/v2/partials/inventory/storage.v2.pc.hbs | 2 +- templates/actors/char-sheet/v2/partials/stats.v2.pc.hbs | 2 +- 6 files changed, 5 insertions(+), 7 deletions(-) diff --git a/templates/actors/char-sheet/v2/partials/inventory/inventory.v2.pc.hbs b/templates/actors/char-sheet/v2/partials/inventory/inventory.v2.pc.hbs index 0468990..f4e2bd5 100644 --- a/templates/actors/char-sheet/v2/partials/inventory/inventory.v2.pc.hbs +++ b/templates/actors/char-sheet/v2/partials/inventory/inventory.v2.pc.hbs @@ -1,4 +1,4 @@
{{> dotdungeon.pc.v2.storage }} {{> dotdungeon.pc.v2.player }} -
\ No newline at end of file + diff --git a/templates/actors/char-sheet/v2/partials/inventory/item-list.v2.pc.hbs b/templates/actors/char-sheet/v2/partials/inventory/item-list.v2.pc.hbs index b3905eb..4a9d5ed 100644 --- a/templates/actors/char-sheet/v2/partials/inventory/item-list.v2.pc.hbs +++ b/templates/actors/char-sheet/v2/partials/inventory/item-list.v2.pc.hbs @@ -20,7 +20,6 @@ -
@@ -34,4 +33,4 @@ {{/if}} {{/each}} - \ No newline at end of file + diff --git a/templates/actors/char-sheet/v2/partials/inventory/items/aspect.v2.pc.hbs b/templates/actors/char-sheet/v2/partials/inventory/items/aspect.v2.pc.hbs index 9381ec4..ac80d51 100644 --- a/templates/actors/char-sheet/v2/partials/inventory/items/aspect.v2.pc.hbs +++ b/templates/actors/char-sheet/v2/partials/inventory/items/aspect.v2.pc.hbs @@ -32,7 +32,6 @@ type="checkbox" {{checked item.system.used}} id="{{meta.idp}}-{{item.uuid}}-used" - value="{{item.system.used}}" data-embedded-id="{{item.uuid}}" data-embedded-update="system.used" data-embedded-update-on="change" diff --git a/templates/actors/char-sheet/v2/partials/inventory/player.v2.pc.hbs b/templates/actors/char-sheet/v2/partials/inventory/player.v2.pc.hbs index ee4ed92..e1b751c 100644 --- a/templates/actors/char-sheet/v2/partials/inventory/player.v2.pc.hbs +++ b/templates/actors/char-sheet/v2/partials/inventory/player.v2.pc.hbs @@ -90,4 +90,4 @@ {{/each}} - \ No newline at end of file + diff --git a/templates/actors/char-sheet/v2/partials/inventory/storage.v2.pc.hbs b/templates/actors/char-sheet/v2/partials/inventory/storage.v2.pc.hbs index 05b25f8..d20d2de 100644 --- a/templates/actors/char-sheet/v2/partials/inventory/storage.v2.pc.hbs +++ b/templates/actors/char-sheet/v2/partials/inventory/storage.v2.pc.hbs @@ -1 +1 @@ -
Storage
\ No newline at end of file +
Storage
diff --git a/templates/actors/char-sheet/v2/partials/stats.v2.pc.hbs b/templates/actors/char-sheet/v2/partials/stats.v2.pc.hbs index b9cb833..8db48ad 100644 --- a/templates/actors/char-sheet/v2/partials/stats.v2.pc.hbs +++ b/templates/actors/char-sheet/v2/partials/stats.v2.pc.hbs @@ -60,4 +60,4 @@ {{/if}} {{/each}} - \ No newline at end of file + From fe4abd073f9d3d507f5672b7c66018bbab5bfce5 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Mon, 25 Mar 2024 22:52:33 -0600 Subject: [PATCH 04/82] Add a context menu for the material so that it can be edited and deleted (closes #133) --- module/sheets/Actors/PC/PlayerSheetV2.mjs | 19 ++++++++++++++++++ module/sheets/GenericActorSheet.mjs | 20 +++++++++++-------- module/utils/GenericContextMenu.mjs | 6 ++++++ .../partials/inventory/items/aspect.v2.pc.hbs | 3 +-- .../inventory/items/material.v2.pc.hbs | 2 +- .../v2/partials/inventory/items/pet.v2.pc.hbs | 3 +-- .../inventory/items/untyped.v2.pc.hbs | 3 +-- .../partials/inventory/items/weapon.v2.pc.hbs | 3 +-- 8 files changed, 42 insertions(+), 17 deletions(-) create mode 100644 module/utils/GenericContextMenu.mjs diff --git a/module/sheets/Actors/PC/PlayerSheetV2.mjs b/module/sheets/Actors/PC/PlayerSheetV2.mjs index 32d0ed9..51f8da2 100644 --- a/module/sheets/Actors/PC/PlayerSheetV2.mjs +++ b/module/sheets/Actors/PC/PlayerSheetV2.mjs @@ -2,6 +2,7 @@ import { GenericActorSheet } from "../../GenericActorSheet.mjs"; import DOTDUNGEON from "../../../config.mjs"; import { localizer } from "../../../utils/localizer.mjs"; import { modifierToString } from "../../../utils/modifierToString.mjs"; +import { GenericContextMenu } from "../../../utils/GenericContextMenu.mjs"; export class PlayerSheetv2 extends GenericActorSheet { static get defaultOptions() { @@ -47,6 +48,24 @@ export class PlayerSheetv2 extends GenericActorSheet { this.toggleItemFilter(filter); this._renderInner(); }); + + // Make materials be able to be edited/deleted + new GenericContextMenu(html, `.material`, [ + { + name: localizer(`dotdungeon.common.edit`), + callback: (html) => { + const data = html[0].dataset; + this.openEmbeddedSheet.bind(this)(data.embeddedId); + }, + }, + { + name: localizer(`dotdungeon.common.delete`), + callback: (html) => { + const data = html[0].dataset; + this.genericEmbeddedDelete.bind(this)(data.embeddedId); + }, + }, + ]); }; async getData() { diff --git a/module/sheets/GenericActorSheet.mjs b/module/sheets/GenericActorSheet.mjs index 660233e..d4d38b0 100644 --- a/module/sheets/GenericActorSheet.mjs +++ b/module/sheets/GenericActorSheet.mjs @@ -59,12 +59,19 @@ export class GenericActorSheet extends ActorSheet { html.find(`[data-embedded-update-on="blur"]`) .on(`blur`, this.genericEmbeddedUpdate.bind(this)); html.find(`[data-embedded-delete]`) - .on(`click`, this.genericEmbeddedDelete.bind(this)); + .on(`click`, ($e) => { + const id = $e.currentTarget.dataset.embeddedDelete; + this.genericEmbeddedDelete.bind(this)(id); + }); html.find(`[data-embedded-create]`) .on(`click`, this.genericEmbeddedCreate.bind(this)); html.find(`[data-message-type]`) .on(`click`, this.genericSendToChat.bind(this)); html.find(`[data-embedded-edit]`) + .on(`click`, ($e) => { + const id = $e.currentTarget.dataset.embeddedEdit; + this.openEmbeddedSheet.bind(this)(id); + }) .on(`click`, this.openEmbeddedSheet.bind(this)); html.find(`button[data-increment]`) .on(`click`, this._incrementValue.bind(this)); @@ -129,10 +136,8 @@ export class GenericActorSheet extends ActorSheet { }; }; - async openEmbeddedSheet($event) { - const data = $event.currentTarget.dataset; - let item = await fromUuid(data.embeddedEdit); - console.log(data) + async openEmbeddedSheet(item_id) { + let item = await fromUuid(item_id); item?.sheet.render(true); }; @@ -186,9 +191,8 @@ export class GenericActorSheet extends ActorSheet { await item?.update({ [data.embeddedDecrement]: value - 1 }); }; - async genericEmbeddedDelete($event) { - let data = $event.currentTarget.dataset; - let item = await fromUuid(data.embeddedId); + async genericEmbeddedDelete(item_uuid) { + let item = await fromUuid(item_uuid); if (!item) { ui.notifications.error( diff --git a/module/utils/GenericContextMenu.mjs b/module/utils/GenericContextMenu.mjs new file mode 100644 index 0000000..9749b4f --- /dev/null +++ b/module/utils/GenericContextMenu.mjs @@ -0,0 +1,6 @@ +export class GenericContextMenu extends ContextMenu { + constructor(element, selector, menuItems, opts = {}) { + super(element, selector, menuItems, opts); + this.menuItems.forEach(i => i.icon ??= ``); + }; +}; diff --git a/templates/actors/char-sheet/v2/partials/inventory/items/aspect.v2.pc.hbs b/templates/actors/char-sheet/v2/partials/inventory/items/aspect.v2.pc.hbs index ac80d51..ebb09c1 100644 --- a/templates/actors/char-sheet/v2/partials/inventory/items/aspect.v2.pc.hbs +++ b/templates/actors/char-sheet/v2/partials/inventory/items/aspect.v2.pc.hbs @@ -85,8 +85,7 @@ data-tooltip="{{dd-i18n 'dotdungeon.common.delete'}}" data-tooltip-direction="RIGHT" class="aspect__button--delete" - data-embedded-delete - data-embedded-id="{{item.uuid}}" + data-embedded-delete="{{item.uuid}}" >