mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-06-07 21:34:16 +02:00
Merge 83b25f4771 into a4428fd5be
This commit is contained in:
commit
26d0b1ce9a
6 changed files with 84 additions and 24 deletions
|
|
@ -2887,7 +2887,9 @@
|
||||||
"iconName": "Icon Name",
|
"iconName": "Icon Name",
|
||||||
"iconNameHint": "Icons are from fontawesome",
|
"iconNameHint": "Icons are from fontawesome",
|
||||||
"bagName": "Bag Name",
|
"bagName": "Bag Name",
|
||||||
"chestName": "Chest Name"
|
"chestName": "Chest Name",
|
||||||
|
"denomination": "Denomination",
|
||||||
|
"initialAmount": "Starting Amount"
|
||||||
},
|
},
|
||||||
"domains": {
|
"domains": {
|
||||||
"domainsTitle": "Base Domains",
|
"domainsTitle": "Base Domains",
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,18 @@ export default class DhCharacter extends DhCreature {
|
||||||
core: new fields.BooleanField({ initial: false })
|
core: new fields.BooleanField({ initial: false })
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
gold: new GoldField(),
|
gold: new GoldField({
|
||||||
|
initial: () => {
|
||||||
|
const homebrew = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew);
|
||||||
|
const { coins, handfuls, bags, chests } = homebrew.currency;
|
||||||
|
return {
|
||||||
|
coins: coins.enabled ? coins.initialAmount : 0,
|
||||||
|
handfuls: handfuls.enabled ? handfuls.initialAmount : 0,
|
||||||
|
bags: bags.enabled ? bags.initialAmount : 0,
|
||||||
|
chests: chests.enabled ? chests.initialAmount : 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}),
|
||||||
scars: new fields.NumberField({ initial: 0, integer: true, label: 'DAGGERHEART.GENERAL.scars' }),
|
scars: new fields.NumberField({ initial: 0, integer: true, label: 'DAGGERHEART.GENERAL.scars' }),
|
||||||
biography: new fields.SchemaField({
|
biography: new fields.SchemaField({
|
||||||
background: new fields.HTMLField(),
|
background: new fields.HTMLField(),
|
||||||
|
|
|
||||||
|
|
@ -116,13 +116,28 @@ class ResourcesField extends fields.TypedObjectField {
|
||||||
}
|
}
|
||||||
|
|
||||||
class GoldField extends fields.SchemaField {
|
class GoldField extends fields.SchemaField {
|
||||||
constructor() {
|
constructor({ initial, ...options } = {}) {
|
||||||
super({
|
super(
|
||||||
coins: new fields.NumberField({ initial: 0, integer: true }),
|
{
|
||||||
handfuls: new fields.NumberField({ initial: 1, integer: true }),
|
coins: new fields.NumberField({ initial: 0, integer: true }),
|
||||||
bags: new fields.NumberField({ initial: 0, integer: true }),
|
handfuls: new fields.NumberField({ initial: 1, integer: true }),
|
||||||
chests: new fields.NumberField({ initial: 0, integer: true })
|
bags: new fields.NumberField({ initial: 0, integer: true }),
|
||||||
});
|
chests: new fields.NumberField({ initial: 0, integer: true })
|
||||||
|
},
|
||||||
|
options
|
||||||
|
);
|
||||||
|
this._initialCallback = initial;
|
||||||
|
}
|
||||||
|
|
||||||
|
getInitialValue(data) {
|
||||||
|
if (this._initialCallback) {
|
||||||
|
try {
|
||||||
|
return this._initialCallback(data);
|
||||||
|
} catch {
|
||||||
|
/* settings not yet available */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.getInitialValue(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { defaultRestOptions } from '../../config/generalConfig.mjs';
|
||||||
import { resetAndRerenderActors } from '../../helpers/utils.mjs';
|
import { resetAndRerenderActors } from '../../helpers/utils.mjs';
|
||||||
import { ActionsField } from '../fields/actionField.mjs';
|
import { ActionsField } from '../fields/actionField.mjs';
|
||||||
|
|
||||||
const currencyField = (initial, label, icon) =>
|
const currencyField = (initial, label, icon, initialAmount = 0) =>
|
||||||
new foundry.data.fields.SchemaField({
|
new foundry.data.fields.SchemaField({
|
||||||
enabled: new foundry.data.fields.BooleanField({ required: true, initial: true }),
|
enabled: new foundry.data.fields.BooleanField({ required: true, initial: true }),
|
||||||
label: new foundry.data.fields.StringField({
|
label: new foundry.data.fields.StringField({
|
||||||
|
|
@ -10,7 +10,14 @@ const currencyField = (initial, label, icon) =>
|
||||||
initial,
|
initial,
|
||||||
label
|
label
|
||||||
}),
|
}),
|
||||||
icon: new foundry.data.fields.StringField({ required: true, nullable: false, blank: true, initial: icon })
|
icon: new foundry.data.fields.StringField({ required: true, nullable: false, blank: true, initial: icon }),
|
||||||
|
initialAmount: new foundry.data.fields.NumberField({
|
||||||
|
required: true,
|
||||||
|
integer: true,
|
||||||
|
min: 0,
|
||||||
|
initial: initialAmount,
|
||||||
|
label: 'DAGGERHEART.SETTINGS.Homebrew.currency.initialAmount'
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
const restMoveField = () =>
|
const restMoveField = () =>
|
||||||
|
|
@ -108,7 +115,8 @@ export default class DhHomebrew extends foundry.abstract.DataModel {
|
||||||
handfuls: currencyField(
|
handfuls: currencyField(
|
||||||
'Handfuls',
|
'Handfuls',
|
||||||
'DAGGERHEART.SETTINGS.Homebrew.currency.handfulName',
|
'DAGGERHEART.SETTINGS.Homebrew.currency.handfulName',
|
||||||
'fa-solid fa-coins'
|
'fa-solid fa-coins',
|
||||||
|
1
|
||||||
),
|
),
|
||||||
bags: currencyField('Bags', 'DAGGERHEART.SETTINGS.Homebrew.currency.bagName', 'fa-solid fa-sack'),
|
bags: currencyField('Bags', 'DAGGERHEART.SETTINGS.Homebrew.currency.bagName', 'fa-solid fa-sack'),
|
||||||
chests: currencyField(
|
chests: currencyField(
|
||||||
|
|
@ -193,6 +201,7 @@ export default class DhHomebrew extends foundry.abstract.DataModel {
|
||||||
for (const type of ['coins', 'handfuls', 'bags', 'chests']) {
|
for (const type of ['coins', 'handfuls', 'bags', 'chests']) {
|
||||||
const initial = this.schema.fields.currency.fields[type].getInitialValue();
|
const initial = this.schema.fields.currency.fields[type].getInitialValue();
|
||||||
source.currency[type] = foundry.utils.mergeObject(initial, source.currency[type], { inplace: false });
|
source.currency[type] = foundry.utils.mergeObject(initial, source.currency[type], { inplace: false });
|
||||||
|
source.currency[type].initialAmount ??= 0;
|
||||||
}
|
}
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -201,6 +201,23 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.currency-rows {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: auto 1fr 1fr auto;
|
||||||
|
gap: 4px;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.currency-header-label {
|
||||||
|
text-align: center;
|
||||||
|
font-size: var(--font-size-14);
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type='checkbox'] {
|
||||||
|
justify-self: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.settings-hint {
|
.settings-hint {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
||||||
|
|
@ -42,29 +42,35 @@
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>
|
<legend>
|
||||||
{{localize "DAGGERHEART.SETTINGS.Homebrew.currency.title"}}
|
{{localize "DAGGERHEART.SETTINGS.Homebrew.currency.title"}}
|
||||||
</legend>
|
</legend>
|
||||||
<div class="toggleable-row spaced">
|
<div class="toggleable-row spaced">
|
||||||
{{formGroup settingFields.schema.fields.currency.fields.title value=settingFields._source.currency.title localize=true}}
|
{{formGroup settingFields.schema.fields.currency.fields.title value=settingFields._source.currency.title localize=true}}
|
||||||
</div>
|
</div>
|
||||||
<div class="toggleable-row">
|
<div class="currency-rows">
|
||||||
|
<span></span>
|
||||||
|
<span class="currency-header-label">{{localize "DAGGERHEART.SETTINGS.Homebrew.currency.denomination"}}</span>
|
||||||
|
<span class="currency-header-label">{{localize "DAGGERHEART.SETTINGS.Homebrew.currency.initialAmount"}}</span>
|
||||||
|
<span></span>
|
||||||
|
|
||||||
<button class="icon {{settingFields._source.currency.coins.icon}}" data-action="editCurrencyIcon" data-currency="coins" data-tooltip="DAGGERHEART.SETTINGS.Homebrew.currency.changeIcon"></button>
|
<button class="icon {{settingFields._source.currency.coins.icon}}" data-action="editCurrencyIcon" data-currency="coins" data-tooltip="DAGGERHEART.SETTINGS.Homebrew.currency.changeIcon"></button>
|
||||||
{{formGroup settingFields.schema.fields.currency.fields.coins.fields.label value=settingFields._source.currency.coins.label localize=true}}
|
{{formInput settingFields.schema.fields.currency.fields.coins.fields.label value=settingFields._source.currency.coins.label name="currency.coins.label"}}
|
||||||
|
<input type="number" name="currency.coins.initialAmount" value="{{settingFields._source.currency.coins.initialAmount}}" min="0" step="1" />
|
||||||
<input type="checkbox" name="currency.coins.enabled" {{checked settingFields._source.currency.coins.enabled}} />
|
<input type="checkbox" name="currency.coins.enabled" {{checked settingFields._source.currency.coins.enabled}} />
|
||||||
</div>
|
|
||||||
<div class="toggleable-row">
|
|
||||||
<button class="icon {{settingFields._source.currency.handfuls.icon}}" data-action="editCurrencyIcon" data-currency="handfuls" data-tooltip="DAGGERHEART.SETTINGS.Homebrew.currency.changeIcon"></button>
|
<button class="icon {{settingFields._source.currency.handfuls.icon}}" data-action="editCurrencyIcon" data-currency="handfuls" data-tooltip="DAGGERHEART.SETTINGS.Homebrew.currency.changeIcon"></button>
|
||||||
{{formGroup settingFields.schema.fields.currency.fields.handfuls.fields.label value=settingFields._source.currency.handfuls.label localize=true}}
|
{{formInput settingFields.schema.fields.currency.fields.handfuls.fields.label value=settingFields._source.currency.handfuls.label name="currency.handfuls.label"}}
|
||||||
|
<input type="number" name="currency.handfuls.initialAmount" value="{{settingFields._source.currency.handfuls.initialAmount}}" min="0" step="1" />
|
||||||
<input type="checkbox" name="currency.handfuls.enabled" {{checked settingFields._source.currency.handfuls.enabled}} />
|
<input type="checkbox" name="currency.handfuls.enabled" {{checked settingFields._source.currency.handfuls.enabled}} />
|
||||||
</div>
|
|
||||||
<div class="toggleable-row">
|
|
||||||
<button class="icon {{settingFields._source.currency.bags.icon}}" data-action="editCurrencyIcon" data-currency="bags" data-tooltip="DAGGERHEART.SETTINGS.Homebrew.currency.changeIcon"></button>
|
<button class="icon {{settingFields._source.currency.bags.icon}}" data-action="editCurrencyIcon" data-currency="bags" data-tooltip="DAGGERHEART.SETTINGS.Homebrew.currency.changeIcon"></button>
|
||||||
{{formGroup settingFields.schema.fields.currency.fields.bags.fields.label value=settingFields._source.currency.bags.label localize=true}}
|
{{formInput settingFields.schema.fields.currency.fields.bags.fields.label value=settingFields._source.currency.bags.label name="currency.bags.label"}}
|
||||||
|
<input type="number" name="currency.bags.initialAmount" value="{{settingFields._source.currency.bags.initialAmount}}" min="0" step="1" />
|
||||||
<input type="checkbox" name="currency.bags.enabled" {{checked settingFields._source.currency.bags.enabled}} />
|
<input type="checkbox" name="currency.bags.enabled" {{checked settingFields._source.currency.bags.enabled}} />
|
||||||
</div>
|
|
||||||
<div class="toggleable-row">
|
|
||||||
<button class="icon {{settingFields._source.currency.chests.icon}}" data-action="editCurrencyIcon" data-currency="chests" data-tooltip="DAGGERHEART.SETTINGS.Homebrew.currency.changeIcon"></button>
|
<button class="icon {{settingFields._source.currency.chests.icon}}" data-action="editCurrencyIcon" data-currency="chests" data-tooltip="DAGGERHEART.SETTINGS.Homebrew.currency.changeIcon"></button>
|
||||||
{{formGroup settingFields.schema.fields.currency.fields.chests.fields.label value=settingFields._source.currency.chests.label localize=true}}
|
{{formInput settingFields.schema.fields.currency.fields.chests.fields.label value=settingFields._source.currency.chests.label name="currency.chests.label"}}
|
||||||
|
<input type="number" name="currency.chests.initialAmount" value="{{settingFields._source.currency.chests.initialAmount}}" min="0" step="1" />
|
||||||
<input type="checkbox" name="currency.chests.enabled" {{checked settingFields._source.currency.chests.enabled}} />
|
<input type="checkbox" name="currency.chests.enabled" {{checked settingFields._source.currency.chests.enabled}} />
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue