mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 23:49:02 +01:00
add setting to extend description from items and add molilo contacts in system.json
This commit is contained in:
parent
69f0106139
commit
1a444fbb15
5 changed files with 93 additions and 15 deletions
|
|
@ -2083,8 +2083,11 @@
|
||||||
"displayFear": { "label": "Fear Display" },
|
"displayFear": { "label": "Fear Display" },
|
||||||
"dualityColorScheme": { "label": "Chat Style" },
|
"dualityColorScheme": { "label": "Chat Style" },
|
||||||
"showGenericStatusEffects": { "label": "Show Foundry Status Effects" },
|
"showGenericStatusEffects": { "label": "Show Foundry Status Effects" },
|
||||||
"expandedCharacterDescriptions": { "label": "Auto-expand Descriptions from Characters" },
|
"expandedTitle": "Auto-expand Descriptions",
|
||||||
"expandedAdversaryDescriptions": { "label": "Auto-expand Descriptions from Adversaries" }
|
"extendCharacterDescriptions": { "label": "Characters" },
|
||||||
|
"extendAdversaryDescriptions": { "label": "Adversaries" },
|
||||||
|
"extendEnvironmentDescriptions": { "label": "Environments" },
|
||||||
|
"extendItemDescriptions": { "label": "Items" }
|
||||||
},
|
},
|
||||||
"fearDisplay": {
|
"fearDisplay": {
|
||||||
"token": "Tokens",
|
"token": "Tokens",
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,23 @@ const { HandlebarsApplicationMixin } = foundry.applications.api;
|
||||||
import { getDocFromElement, getDocFromElementSync, tagifyElement } from '../../../helpers/utils.mjs';
|
import { getDocFromElement, getDocFromElementSync, tagifyElement } from '../../../helpers/utils.mjs';
|
||||||
import { ItemBrowser } from '../../ui/itemBrowser.mjs';
|
import { ItemBrowser } from '../../ui/itemBrowser.mjs';
|
||||||
|
|
||||||
|
const typeSettingsMap = {
|
||||||
|
character: 'extendCharacterDescriptions',
|
||||||
|
adversary: 'extendAdversaryDescriptions',
|
||||||
|
environment: 'extendEnvironmentDescriptions',
|
||||||
|
ancestry: 'extendItemDescriptions',
|
||||||
|
community: 'extendItemDescriptions',
|
||||||
|
class: 'extendItemDescriptions',
|
||||||
|
subclass: 'extendItemDescriptions',
|
||||||
|
feature: 'extendItemDescriptions',
|
||||||
|
domainCard: 'extendItemDescriptions',
|
||||||
|
loot: 'extendItemDescriptions',
|
||||||
|
consumable: 'extendItemDescriptions',
|
||||||
|
weapon: 'extendItemDescriptions',
|
||||||
|
armor: 'extendItemDescriptions',
|
||||||
|
beastform: 'extendItemDescriptions'
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction
|
* @typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction
|
||||||
*/
|
*/
|
||||||
|
|
@ -137,6 +154,8 @@ export default function DHApplicationMixin(Base) {
|
||||||
docs.filter(doc => doc).forEach(doc => (doc.apps[this.id] = this));
|
docs.filter(doc => doc).forEach(doc => (doc.apps[this.id] = this));
|
||||||
|
|
||||||
if (!!this.options.contextMenus.length) this._createContextMenus();
|
if (!!this.options.contextMenus.length) this._createContextMenus();
|
||||||
|
|
||||||
|
this.#autoExtendDescriptions(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
|
|
@ -149,7 +168,7 @@ export default function DHApplicationMixin(Base) {
|
||||||
async _onRender(context, options) {
|
async _onRender(context, options) {
|
||||||
await super._onRender(context, options);
|
await super._onRender(context, options);
|
||||||
this._createTagifyElements(this.options.tagifyConfigs);
|
this._createTagifyElements(this.options.tagifyConfigs);
|
||||||
await this.#prepareInventoryDescription();
|
await this.#prepareInventoryDescription(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
|
@ -391,8 +410,6 @@ export default function DHApplicationMixin(Base) {
|
||||||
context.fields = this.document.schema.fields;
|
context.fields = this.document.schema.fields;
|
||||||
context.systemFields = this.document.system.schema.fields;
|
context.systemFields = this.document.system.schema.fields;
|
||||||
context.settings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance);
|
context.settings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance);
|
||||||
// settings.expandedCharacterDescriptions
|
|
||||||
// settings.expandedAdversaryDescriptions
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -404,7 +421,7 @@ export default function DHApplicationMixin(Base) {
|
||||||
* Prepares and enriches an inventory item or action description for display.
|
* Prepares and enriches an inventory item or action description for display.
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
async #prepareInventoryDescription() {
|
async #prepareInventoryDescription(context) {
|
||||||
// Get all inventory item elements with a data-item-uuid attribute
|
// Get all inventory item elements with a data-item-uuid attribute
|
||||||
const inventoryItems = this.element.querySelectorAll('.inventory-item[data-item-uuid]');
|
const inventoryItems = this.element.querySelectorAll('.inventory-item[data-item-uuid]');
|
||||||
for (const el of inventoryItems) {
|
for (const el of inventoryItems) {
|
||||||
|
|
@ -435,6 +452,38 @@ export default function DHApplicationMixin(Base) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
/* Extend Descriptions by Settings */
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extend inventory description when enabled in settings.
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async #autoExtendDescriptions(context) {
|
||||||
|
const inventoryItems = this.element.querySelectorAll('.inventory-item[data-item-uuid]');
|
||||||
|
for (const el of inventoryItems) {
|
||||||
|
// Get the doc uuid from the element
|
||||||
|
const { itemUuid } = el?.dataset || {};
|
||||||
|
if (!itemUuid) continue;
|
||||||
|
|
||||||
|
//get doc by uuid
|
||||||
|
const doc = await fromUuid(itemUuid);
|
||||||
|
|
||||||
|
//check the type of the document
|
||||||
|
const actorType =
|
||||||
|
doc?.type === 'adversary' && context.document?.type === 'environment'
|
||||||
|
? typeSettingsMap[doc?.type]
|
||||||
|
: doc.actor?.type;
|
||||||
|
|
||||||
|
// If the actor type is defined and the setting is enabled, extend the description
|
||||||
|
if (typeSettingsMap[actorType]) {
|
||||||
|
const settingKey = typeSettingsMap[actorType];
|
||||||
|
if (context.settings[settingKey]) this.#activeExtended(el);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/* Application Clicks Actions */
|
/* Application Clicks Actions */
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
|
@ -609,6 +658,11 @@ export default function DHApplicationMixin(Base) {
|
||||||
const extensible = container?.querySelector('.extensible');
|
const extensible = container?.querySelector('.extensible');
|
||||||
extensible?.classList.toggle('extended');
|
extensible?.classList.toggle('extended');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async #activeExtended(element) {
|
||||||
|
const extensible = element?.querySelector('.extensible');
|
||||||
|
extensible?.classList.add('extended');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DHSheetV2;
|
return DHSheetV2;
|
||||||
|
|
|
||||||
|
|
@ -56,13 +56,21 @@ export default class DhAppearance extends foundry.abstract.DataModel {
|
||||||
initial: true,
|
initial: true,
|
||||||
label: 'DAGGERHEART.SETTINGS.Appearance.FIELDS.showGenericStatusEffects.label'
|
label: 'DAGGERHEART.SETTINGS.Appearance.FIELDS.showGenericStatusEffects.label'
|
||||||
}),
|
}),
|
||||||
expandedCharacterDescriptions: new fields.BooleanField({
|
extendCharacterDescriptions: new fields.BooleanField({
|
||||||
initial: false,
|
initial: false,
|
||||||
label: 'DAGGERHEART.SETTINGS.Appearance.FIELDS.expandedCharacterDescriptions.label'
|
label: 'DAGGERHEART.SETTINGS.Appearance.FIELDS.extendCharacterDescriptions.label'
|
||||||
}),
|
}),
|
||||||
expandedAdversaryDescriptions: new fields.BooleanField({
|
extendAdversaryDescriptions: new fields.BooleanField({
|
||||||
initial: false,
|
initial: false,
|
||||||
label: 'DAGGERHEART.SETTINGS.Appearance.FIELDS.expandedAdversaryDescriptions.label'
|
label: 'DAGGERHEART.SETTINGS.Appearance.FIELDS.extendAdversaryDescriptions.label'
|
||||||
|
}),
|
||||||
|
extendEnvironmentDescriptions: new fields.BooleanField({
|
||||||
|
initial: false,
|
||||||
|
label: 'DAGGERHEART.SETTINGS.Appearance.FIELDS.extendEnvironmentDescriptions.label'
|
||||||
|
}),
|
||||||
|
extendItemDescriptions: new fields.BooleanField({
|
||||||
|
initial: false,
|
||||||
|
label: 'DAGGERHEART.SETTINGS.Appearance.FIELDS.extendItemDescriptions.label'
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,10 @@
|
||||||
"name": "jacobwojoski"
|
"name": "jacobwojoski"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "moliloo"
|
"name": "moliloo",
|
||||||
|
"url": "https://github.com/moliloo",
|
||||||
|
"email": "molilofl@gmail.com",
|
||||||
|
"discord": "molilo"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Mysteryusy"
|
"name": "Mysteryusy"
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,20 @@
|
||||||
<header class="dialog-header">
|
<header class="dialog-header">
|
||||||
<h1>{{localize 'DAGGERHEART.SETTINGS.Menu.appearance.name'}}</h1>
|
<h1>{{localize 'DAGGERHEART.SETTINGS.Menu.appearance.name'}}</h1>
|
||||||
</header>
|
</header>
|
||||||
{{formGroup settingFields.schema.fields.displayFear value=settingFields._source.displayFear localize=true}}
|
|
||||||
{{formGroup settingFields.schema.fields.showGenericStatusEffects value=settingFields._source.showGenericStatusEffects localize=true}}
|
<fieldset>
|
||||||
{{formGroup settingFields.schema.fields.expandedCharacterDescriptions value=settingFields._source.expandedCharacterDescriptions localize=true}}
|
<legend>{{localize 'DAGGERHEART.GENERAL.fear'}}</legend>
|
||||||
{{formGroup settingFields.schema.fields.expandedAdversaryDescriptions value=settingFields._source.expandedAdversaryDescriptions localize=true}}
|
{{formGroup settingFields.schema.fields.displayFear value=settingFields._source.displayFear localize=true}}
|
||||||
|
{{formGroup settingFields.schema.fields.showGenericStatusEffects value=settingFields._source.showGenericStatusEffects localize=true}}
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>{{localize 'DAGGERHEART.SETTINGS.Appearance.FIELDS.expandedTitle'}}</legend>
|
||||||
|
{{formGroup settingFields.schema.fields.extendCharacterDescriptions value=settingFields._source.extendCharacterDescriptions localize=true}}
|
||||||
|
{{formGroup settingFields.schema.fields.extendAdversaryDescriptions value=settingFields._source.extendAdversaryDescriptions localize=true}}
|
||||||
|
{{formGroup settingFields.schema.fields.extendEnvironmentDescriptions value=settingFields._source.extendEnvironmentDescriptions localize=true}}
|
||||||
|
{{formGroup settingFields.schema.fields.extendItemDescriptions value=settingFields._source.extendItemDescriptions localize=true}}
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
{{#if showDiceSoNice}}
|
{{#if showDiceSoNice}}
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue