Finish the Inventory item improvements
This commit is contained in:
parent
83039c6144
commit
2f8ec1b79c
9 changed files with 107 additions and 13 deletions
|
|
@ -254,6 +254,9 @@
|
|||
},
|
||||
"warn": {
|
||||
"negative-aspect-limit": "The Aspect limit must be 0 or greater"
|
||||
},
|
||||
"info": {
|
||||
"increased-item-quantity": "Increased the item quantity for: {name}"
|
||||
}
|
||||
},
|
||||
"dialogs": {
|
||||
|
|
@ -274,6 +277,12 @@
|
|||
"title": "You want to kill your pet?!",
|
||||
"content": "Are you sure you would like to kill the pet: {name}<br /><br />This action cannot be undone."
|
||||
}
|
||||
},
|
||||
"untyped": {
|
||||
"delete": {
|
||||
"title": "Confirm Item Deletion",
|
||||
"content": "Are you sure you would like to delete the item: {name}<br /><br />This action cannot be undone."
|
||||
}
|
||||
}
|
||||
},
|
||||
"keyword": {
|
||||
|
|
@ -317,6 +326,9 @@
|
|||
},
|
||||
"pet": {
|
||||
"name": "(Unnamed Pet)"
|
||||
},
|
||||
"untyped": {
|
||||
"name": "Unknown Item"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ export class ActorHandler extends Actor {
|
|||
*/
|
||||
async preItemEmbed(item) {
|
||||
let type = item.type[0].toUpperCase() + item.type.slice(1);
|
||||
console.log(`preEmbed type =`, type)
|
||||
if (this.fn?.[`pre${type}Embed`]) {
|
||||
return await this.fn?.[`pre${type}Embed`].bind(this)(item);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -46,6 +46,14 @@ async function createCustomItem(defaults, opts = {}) {
|
|||
};
|
||||
};
|
||||
|
||||
/** @this {Actor} */
|
||||
async function createCustomUntyped() {
|
||||
await createCustomItem.bind(this)([{
|
||||
type: `untyped`,
|
||||
name: game.i18n.format(`dotdungeon.defaults.untyped.name`),
|
||||
}]);
|
||||
};
|
||||
|
||||
/** @this {Actor} */
|
||||
async function createCustomAspect() {
|
||||
await createCustomItem.bind(this)([{
|
||||
|
|
@ -105,12 +113,33 @@ async function preAspectEmbed(item) {
|
|||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {ItemHandler} item
|
||||
* @this {Actor}
|
||||
*/
|
||||
async function preUntypedEmbed(item) {
|
||||
let inventoryItem = this.itemTypes.untyped.find(i => i.name === item.name);
|
||||
if (inventoryItem) {
|
||||
inventoryItem.update({"system.quantity": inventoryItem.system.quantity + 1});
|
||||
ui.notifications.info(
|
||||
game.i18n.format(
|
||||
`dotdungeon.notification.info.increased-item-quantity`,
|
||||
{ name: inventoryItem.name }
|
||||
),
|
||||
{ console: false }
|
||||
);
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
export default {
|
||||
atAspectLimit,
|
||||
createCustomItem,
|
||||
createCustomUntyped,
|
||||
createCustomAspect,
|
||||
createCustomSpell,
|
||||
createCustomPet,
|
||||
genericEmbeddedDelete,
|
||||
preAspectEmbed,
|
||||
preUntypedEmbed,
|
||||
};
|
||||
|
|
@ -23,7 +23,8 @@ export class ItemHandler extends Item {
|
|||
};
|
||||
|
||||
async _preCreate(...args) {
|
||||
if (!this.fn?._preCreate) return;
|
||||
return this.fn?._preCreate.bind(this)(...args);
|
||||
if (this.fn?._preCreate) return this.fn?._preCreate.bind(this)(...args);
|
||||
if (this.isEmbedded) return await this.actor?.preItemEmbed(this);
|
||||
return;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import { ActorHandler } from "./documents/Actor/Handler.mjs";
|
|||
import { ItemHandler } from "./documents/Item/Handler.mjs";
|
||||
|
||||
// Item Sheets
|
||||
import { CustomItemSheet } from "./sheets/Items/CustomItemSheet.mjs";
|
||||
import { UntypedItemSheet } from "./sheets/Items/UntypedItemSheet.mjs";
|
||||
import { AspectSheet } from "./sheets/Items/AspectSheet.mjs";
|
||||
import { SpellSheet } from "./sheets/Items/SpellSheet.mjs";
|
||||
import { PetSheet } from "./sheets/Items/PetSheet.mjs";
|
||||
|
|
@ -41,7 +41,7 @@ Hooks.once(`init`, async () => {
|
|||
CONFIG.Actor.dataModels.player = PlayerData;
|
||||
CONFIG.Actor.dataModels.sync = SyncData;
|
||||
CONFIG.Actor.dataModels.mob = MobData;
|
||||
CONFIG.Item.dataModels.custom = DescribedItemData;
|
||||
CONFIG.Item.dataModels.untyped = DescribedItemData;
|
||||
CONFIG.Item.dataModels.aspect = AspectItemData;
|
||||
CONFIG.Item.dataModels.spell = SpellItemData;
|
||||
CONFIG.Item.dataModels.pet = PetItemData;
|
||||
|
|
@ -82,9 +82,9 @@ Hooks.once(`init`, async () => {
|
|||
types: ["pet"],
|
||||
label: "dotdungeon.sheet-names.PetSheet"
|
||||
});
|
||||
Items.registerSheet("dotdungeon", CustomItemSheet, {
|
||||
Items.registerSheet("dotdungeon", UntypedItemSheet, {
|
||||
makeDefault: true,
|
||||
label: "dotdungeon.sheet-names.CustomItemSheet"
|
||||
label: "dotdungeon.sheet-names.UntypedItemSheet"
|
||||
})
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { GenericItemSheet } from "./GenericItemSheet.mjs";
|
||||
|
||||
export class CustomItemSheet extends GenericItemSheet {
|
||||
export class UntypedItemSheet extends GenericItemSheet {
|
||||
static get defaultOptions() {
|
||||
let opts = mergeObject(
|
||||
super.defaultOptions,
|
||||
|
|
@ -11,6 +11,6 @@
|
|||
gap: 8px;
|
||||
|
||||
.name { grid-area: name; }
|
||||
.usage { grid-area: usage; }
|
||||
.usage { grid-area: usage; white-space: nowrap; }
|
||||
.description { grid-area: description; }
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
},
|
||||
"Item": {
|
||||
"types": [
|
||||
"custom",
|
||||
"untyped",
|
||||
"aspect",
|
||||
"weapon",
|
||||
"armour",
|
||||
|
|
|
|||
|
|
@ -58,8 +58,59 @@
|
|||
aria-valuenow="{{system.supplies}}"
|
||||
>
|
||||
</label>
|
||||
<label class="grow col">
|
||||
Inventory
|
||||
<textarea class="grow" name="system.inventoryString">{{system.inventoryString}}</textarea>
|
||||
</label>
|
||||
{{#each items.untyped as | item |}}
|
||||
<details {{dd-expanded ../meta.expanded item.uuid}}>
|
||||
<summary data-collapse-id="{{item.uuid}}">
|
||||
{{item.name}} (x {{item.system.quantity}})
|
||||
</summary>
|
||||
<div class="item">
|
||||
{{#if (defined item.system.buy)}}
|
||||
<div>Cost: {{item.system.buy}}</div>
|
||||
{{/if}}
|
||||
{{#if item.system.description}}
|
||||
<p>{{item.system.description}}</p>
|
||||
{{/if}}
|
||||
<div class="actions">
|
||||
<button
|
||||
type="button"
|
||||
class="confirm"
|
||||
data-embedded-edit="{{item.uuid}}"
|
||||
>
|
||||
Edit
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="neutral equal-padding"
|
||||
data-message-type="Untyped"
|
||||
data-message-content="{{item.system.description}}"
|
||||
data-embedded-id="{{item.uuid}}"
|
||||
>
|
||||
<div aria-hidden="true" class="icon icon--20">
|
||||
{{{ ../icons.chat-bubble }}}
|
||||
</div>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="danger equal-padding"
|
||||
data-embedded-delete
|
||||
data-embedded-id="{{item.uuid}}"
|
||||
>
|
||||
<div aria-hidden="true" class="icon icon--20">
|
||||
{{{ ../icons.garbage-bin }}}
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
{{/each}}
|
||||
<button
|
||||
type="button"
|
||||
class="confirm"
|
||||
data-embedded-create="Untyped"
|
||||
>
|
||||
<div aria-hidden="true" class="icon icon--20">
|
||||
{{{ icons.create }}}
|
||||
</div>
|
||||
Add Item
|
||||
</button>
|
||||
{{/ dotdungeon.panel}}
|
||||
Loading…
Add table
Add a link
Reference in a new issue