Attribute Item Subtype #76
4 changed files with 79 additions and 64 deletions
|
|
@ -97,6 +97,7 @@
|
|||
"toggle-item-description": "Show/Hide Item Description",
|
||||
"tab-names": {
|
||||
"content": "Content",
|
||||
"attributes": "Attributes",
|
||||
"items": "Items"
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -45,9 +45,10 @@ export class PlayerSheet extends
|
|||
|
||||
static PARTS = {
|
||||
header: { template: filePath(`templates/PlayerSheet/header.hbs`) },
|
||||
attributes: { template: filePath(`templates/PlayerSheet/attributes.hbs`) },
|
||||
primaryAttributes: { template: filePath(`templates/PlayerSheet/primary-attributes.hbs`) },
|
||||
tabs: { template: filePath(`templates/generic/tabs.hbs`) },
|
||||
content: { template: filePath(`templates/PlayerSheet/content.hbs`) },
|
||||
attributeTab: {},
|
||||
items: {
|
||||
template: filePath(`templates/PlayerSheet/item-lists.hbs`),
|
||||
scrollable: [``],
|
||||
|
|
@ -78,6 +79,7 @@ export class PlayerSheet extends
|
|||
labelPrefix: `taf.Apps.PlayerSheet.tab-names`,
|
||||
tabs: [
|
||||
{ id: `content` },
|
||||
{ id: `attributes` },
|
||||
{ id: `items` },
|
||||
],
|
||||
},
|
||||
|
|
@ -104,6 +106,10 @@ export class PlayerSheet extends
|
|||
Logger.debug(`Asserting app "${this.id}" from tab "items" to "${initial}"`);
|
||||
this.tabGroups.primary = initial;
|
||||
};
|
||||
if (this.tabGroups.primary === `attributes` && !this.hasAttributesTab) {
|
||||
Logger.debug(`Asserting app "${this.id}" from tab "attributes" to "${initial}"`);
|
||||
this.tabGroups.primary = initial;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -118,6 +124,7 @@ export class PlayerSheet extends
|
|||
switch (tabID) {
|
||||
case `content`: return this.hasContentTab;
|
||||
case `items`: return this.hasItemsTab;
|
||||
case `attributes`: return this.hasAttributesTab;
|
||||
};
|
||||
return false;
|
||||
};
|
||||
|
|
@ -127,7 +134,8 @@ export class PlayerSheet extends
|
|||
};
|
||||
|
||||
get hasAttributesTab() {
|
||||
return this.actor.itemTypes.attributes
|
||||
return this.actor.itemTypes
|
||||
.attribute
|
||||
.filter(attr => !attr.system.aboveTheFold)
|
||||
.length > 0;
|
||||
};
|
||||
|
|
@ -262,8 +270,12 @@ export class PlayerSheet extends
|
|||
|
||||
async _preparePartContext(partID, ctx) {
|
||||
switch (partID) {
|
||||
case `attributes`: {
|
||||
await this._prepareAttributes(ctx);
|
||||
case `primaryAttributes`: {
|
||||
await this._preparePrimaryAttributes(ctx);
|
||||
break;
|
||||
};
|
||||
case `attributeTab`: {
|
||||
await this._prepareAttributesTab(ctx);
|
||||
break;
|
||||
};
|
||||
case `tabs`: {
|
||||
|
|
@ -283,19 +295,14 @@ export class PlayerSheet extends
|
|||
return ctx;
|
||||
};
|
||||
|
||||
async _prepareAttributes(ctx) {
|
||||
ctx.hasAttributes = this.actor.system.hasAttributes;
|
||||
async _preparePrimaryAttributes(ctx) {
|
||||
const attrs = this.actor.itemTypes.attribute ?? [];
|
||||
const filtered = attrs.filter(attr => attr.system.aboveTheFold);
|
||||
ctx.hasAttributes = filtered.length > 0;
|
||||
ctx.attrs = filtered;
|
||||
};
|
||||
|
||||
const attrs = [];
|
||||
for (const [id, data] of Object.entries(this.actor.system.attr)) {
|
||||
attrs.push({
|
||||
...data,
|
||||
id,
|
||||
path: `system.attr.${id}`,
|
||||
});
|
||||
};
|
||||
ctx.attrs = attrs.toSorted(attributeSorter);
|
||||
};
|
||||
async _prepareAttributesTab(ctx) {};
|
||||
|
||||
async _prepareTabList(ctx) {
|
||||
ctx.tabs = await this._prepareTabs(`primary`);
|
||||
|
|
@ -337,8 +344,9 @@ export class PlayerSheet extends
|
|||
|
||||
let summedWeight = 0;
|
||||
for (const item of items) {
|
||||
summedWeight += item.system.quantifiedWeight;
|
||||
preparedItems.push(await this._prepareItem(item));
|
||||
summedWeight += item.system.quantifiedWeight ?? 0;
|
||||
const data = await this._prepareItem(item);
|
||||
if (data) preparedItems.push(data);
|
||||
};
|
||||
totalWeight += summedWeight;
|
||||
|
||||
|
|
@ -355,18 +363,7 @@ export class PlayerSheet extends
|
|||
};
|
||||
|
||||
async _prepareItem(item) {
|
||||
if (item.type !== "generic") {
|
||||
return {
|
||||
uuid: item.uuid,
|
||||
img: item.img,
|
||||
name: item.name,
|
||||
equipped: false,
|
||||
quantity: 0,
|
||||
weight: 0,
|
||||
isExpanded: false,
|
||||
canExpand: false,
|
||||
};
|
||||
}
|
||||
if (item.type !== `generic`) { return };
|
||||
const ctx = {
|
||||
uuid: item.uuid,
|
||||
img: item.img,
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
{{#if hasAttributes}}
|
||||
<div class="attributes">
|
||||
{{#each attrs as | attr |}}
|
||||
<fieldset data-attribute="{{ attr.id }}">
|
||||
<legend>
|
||||
{{ attr.name }}
|
||||
</legend>
|
||||
<div class="attr-range">
|
||||
<input
|
||||
type="number"
|
||||
class="attr-range__value"
|
||||
name="{{attr.path}}.value"
|
||||
value="{{attr.value}}"
|
||||
aria-label="{{localize "taf.Apps.PlayerSheet.current-value"}}"
|
||||
data-tooltip="@{{ attr.id }}{{#if attr.isRange}}.value{{/if}}"
|
||||
>
|
||||
{{#if attr.isRange}}
|
||||
<span aria-hidden="true">/</span>
|
||||
<input
|
||||
type="number"
|
||||
class="attr-range__max"
|
||||
name="{{attr.path}}.max"
|
||||
value="{{attr.max}}"
|
||||
aria-label="{{localize "taf.Apps.PlayerSheet.max-value"}}"
|
||||
data-tooltip="@{{ attr.id }}.max"
|
||||
>
|
||||
{{/if}}
|
||||
</div>
|
||||
</fieldset>
|
||||
{{/each}}
|
||||
</div>
|
||||
{{else}}
|
||||
<template />
|
||||
{{/if}}
|
||||
51
templates/PlayerSheet/primary-attributes.hbs
Normal file
51
templates/PlayerSheet/primary-attributes.hbs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
{{#if hasAttributes}}
|
||||
<div class="attributes">
|
||||
{{#each attrs as | attr |}}
|
||||
<fieldset data-foreign-uuid="{{ attr.uuid }}">
|
||||
<legend>
|
||||
{{ attr.name }}
|
||||
</legend>
|
||||
<div class="attr-range">
|
||||
{{#if attr.system.isRange }}
|
||||
<input
|
||||
type="number"
|
||||
id="{{attr.uuid}}-value"
|
||||
class="attr-range__value"
|
||||
data-foreign-name="system.value"
|
||||
value="{{attr.system.value}}"
|
||||
min="{{attr.system.min}}"
|
||||
max="{{attr.system.max}}"
|
||||
aria-label="{{localize "taf.Apps.PlayerSheet.current-value"}}"
|
||||
data-tooltip="@{{ attr.system.key }}.value"
|
||||
>
|
||||
<span aria-hidden="true">/</span>
|
||||
<input
|
||||
type="number"
|
||||
id="{{attr.uuid}}-max"
|
||||
class="attr-range__max"
|
||||
data-foreign-name="system.max"
|
||||
value="{{attr.system.max}}"
|
||||
min="{{attr.system.min}}"
|
||||
aria-label="{{localize "taf.Apps.PlayerSheet.max-value"}}"
|
||||
data-tooltip="@{{ attr.system.key }}.max"
|
||||
>
|
||||
{{else}}
|
||||
<input
|
||||
type="number"
|
||||
id="{{attr.uuid}}-value"
|
||||
class="attr-range__value"
|
||||
data-foreign-name="system.value"
|
||||
value="{{attr.system.value}}"
|
||||
min="{{attr.system.min}}"
|
||||
max="{{attr.system.max}}"
|
||||
aria-label="{{localize "taf.Apps.PlayerSheet.current-value"}}"
|
||||
data-tooltip="@{{ attr.system.key }}"
|
||||
>
|
||||
{{/if}}
|
||||
</div>
|
||||
</fieldset>
|
||||
{{/each}}
|
||||
</div>
|
||||
{{else}}
|
||||
<template />
|
||||
{{/if}}
|
||||
Loading…
Add table
Add a link
Reference in a new issue