mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Fixed token-config
This commit is contained in:
parent
809255ba79
commit
51a4d74a04
9 changed files with 163 additions and 21 deletions
|
|
@ -611,6 +611,9 @@
|
||||||
"insufficientHope": "The initiating character doesn't have enough hope",
|
"insufficientHope": "The initiating character doesn't have enough hope",
|
||||||
"createTagTeam": "Create TagTeam Roll",
|
"createTagTeam": "Create TagTeam Roll",
|
||||||
"chatMessageRollTitle": "Roll"
|
"chatMessageRollTitle": "Roll"
|
||||||
|
},
|
||||||
|
"TokenConfig": {
|
||||||
|
"actorSizeUsed": "Actor size is set, determining the dimensions"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"CLASS": {
|
"CLASS": {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,18 @@
|
||||||
export default class DhPrototypeTokenConfig extends foundry.applications.sheets.PrototypeTokenConfig {
|
export default class DhPrototypeTokenConfig extends foundry.applications.sheets.PrototypeTokenConfig {
|
||||||
|
/** @override */
|
||||||
|
static PARTS = {
|
||||||
|
tabs: super.PARTS.tabs,
|
||||||
|
identity: super.PARTS.identity,
|
||||||
|
appearance: {
|
||||||
|
template: 'systems/daggerheart/templates/sheets-settings/token-config/appearance.hbs',
|
||||||
|
scrollable: ['']
|
||||||
|
},
|
||||||
|
vision: super.PARTS.vision,
|
||||||
|
light: super.PARTS.light,
|
||||||
|
resources: super.PARTS.resources,
|
||||||
|
footer: super.PARTS.footer
|
||||||
|
};
|
||||||
|
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
async _prepareResourcesTab() {
|
async _prepareResourcesTab() {
|
||||||
const token = this.token;
|
const token = this.token;
|
||||||
|
|
@ -17,4 +31,11 @@ export default class DhPrototypeTokenConfig extends foundry.applications.sheets.
|
||||||
turnMarkerAnimations: CONFIG.Combat.settings.turnMarkerAnimations
|
turnMarkerAnimations: CONFIG.Combat.settings.turnMarkerAnimations
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _prepareAppearanceTab() {
|
||||||
|
const context = await super._prepareAppearanceTab();
|
||||||
|
context.actorSizeUsed = this.token.actor ? Boolean(this.token.actor.system.size) : false;
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,18 @@
|
||||||
export default class DhTokenConfig extends foundry.applications.sheets.TokenConfig {
|
export default class DhTokenConfig extends foundry.applications.sheets.TokenConfig {
|
||||||
|
/** @override */
|
||||||
|
static PARTS = {
|
||||||
|
tabs: super.PARTS.tabs,
|
||||||
|
identity: super.PARTS.identity,
|
||||||
|
appearance: {
|
||||||
|
template: 'systems/daggerheart/templates/sheets-settings/token-config/appearance.hbs',
|
||||||
|
scrollable: ['']
|
||||||
|
},
|
||||||
|
vision: super.PARTS.vision,
|
||||||
|
light: super.PARTS.light,
|
||||||
|
resources: super.PARTS.resources,
|
||||||
|
footer: super.PARTS.footer
|
||||||
|
};
|
||||||
|
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
async _prepareResourcesTab() {
|
async _prepareResourcesTab() {
|
||||||
const token = this.token;
|
const token = this.token;
|
||||||
|
|
@ -17,4 +31,11 @@ export default class DhTokenConfig extends foundry.applications.sheets.TokenConf
|
||||||
turnMarkerAnimations: CONFIG.Combat.settings.turnMarkerAnimations
|
turnMarkerAnimations: CONFIG.Combat.settings.turnMarkerAnimations
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _prepareAppearanceTab() {
|
||||||
|
const context = await super._prepareAppearanceTab();
|
||||||
|
context.actorSizeUsed = this.token.actor ? Boolean(this.token.actor.system.size) : false;
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -212,6 +212,11 @@ export const adversaryTraits = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const tokenSize = {
|
export const tokenSize = {
|
||||||
|
custom: {
|
||||||
|
id: 'custom',
|
||||||
|
value: 0,
|
||||||
|
label: 'DAGGERHEART.GENERAL.custom'
|
||||||
|
},
|
||||||
tiny: {
|
tiny: {
|
||||||
id: 'tiny',
|
id: 'tiny',
|
||||||
value: 1,
|
value: 1,
|
||||||
|
|
|
||||||
|
|
@ -80,9 +80,9 @@ export default class BaseDataActor extends foundry.abstract.TypeDataModel {
|
||||||
if (this.metadata.usesSize)
|
if (this.metadata.usesSize)
|
||||||
schema.size = new fields.StringField({
|
schema.size = new fields.StringField({
|
||||||
required: true,
|
required: true,
|
||||||
nullable: true,
|
nullable: false,
|
||||||
choices: CONFIG.DH.ACTOR.tokenSize,
|
choices: CONFIG.DH.ACTOR.tokenSize,
|
||||||
initial: null
|
initial: CONFIG.DH.ACTOR.tokenSize.custom.id
|
||||||
});
|
});
|
||||||
return schema;
|
return schema;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,10 @@ export default class DhScene extends Scene {
|
||||||
/** Synchronize a token's dimensions with its actor's size category. */
|
/** Synchronize a token's dimensions with its actor's size category. */
|
||||||
syncTokenDimensions(tokenDoc, tokenSize) {
|
syncTokenDimensions(tokenDoc, tokenSize) {
|
||||||
if (!tokenDoc.parent?.tokens.has(tokenDoc.id)) return;
|
if (!tokenDoc.parent?.tokens.has(tokenDoc.id)) return;
|
||||||
|
const prototype = tokenDoc.actor?.prototypeToken ?? tokenDoc;
|
||||||
this.#sizeSyncBatch.set(tokenDoc.id, {
|
this.#sizeSyncBatch.set(tokenDoc.id, {
|
||||||
size: tokenSize,
|
size: tokenSize,
|
||||||
|
prototypeSize: { width: prototype.width, height: prototype.height },
|
||||||
position: { x: tokenDoc.x, y: tokenDoc.y, elevation: tokenDoc.elevation }
|
position: { x: tokenDoc.x, y: tokenDoc.y, elevation: tokenDoc.elevation }
|
||||||
});
|
});
|
||||||
this.#processSyncBatch();
|
this.#processSyncBatch();
|
||||||
|
|
@ -20,18 +22,15 @@ export default class DhScene extends Scene {
|
||||||
const entries = this.#sizeSyncBatch
|
const entries = this.#sizeSyncBatch
|
||||||
.entries()
|
.entries()
|
||||||
.toArray()
|
.toArray()
|
||||||
.map(([_id, { size, position }]) => {
|
.map(([_id, { size, prototypeSize, position }]) => {
|
||||||
const tokenSize = tokenSizes[size];
|
const tokenSize = tokenSizes[size];
|
||||||
const updatedPosition = DHToken.getSnappedPositionInSquareGrid(
|
const width = size !== CONFIG.DH.ACTOR.tokenSize.custom.id ? tokenSize : prototypeSize.width;
|
||||||
this.grid,
|
const height = size !== CONFIG.DH.ACTOR.tokenSize.custom.id ? tokenSize : prototypeSize.height;
|
||||||
position,
|
const updatedPosition = DHToken.getSnappedPositionInSquareGrid(this.grid, position, width, height);
|
||||||
tokenSize,
|
|
||||||
tokenSize
|
|
||||||
);
|
|
||||||
return {
|
return {
|
||||||
_id,
|
_id,
|
||||||
width: tokenSize,
|
width,
|
||||||
height: tokenSize,
|
height,
|
||||||
...updatedPosition
|
...updatedPosition
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ export default class DHToken extends CONFIG.Token.documentClass {
|
||||||
const actor = document.actor;
|
const actor = document.actor;
|
||||||
if (actor?.system.metadata.usesSize) {
|
if (actor?.system.metadata.usesSize) {
|
||||||
const tokenSize = tokenSizes[actor.system.size];
|
const tokenSize = tokenSizes[actor.system.size];
|
||||||
if (tokenSize) {
|
if (tokenSize && tokenSize !== CONFIG.DH.ACTOR.tokenSize.custom.id) {
|
||||||
document.updateSource({
|
document.updateSource({
|
||||||
width: tokenSize,
|
width: tokenSize,
|
||||||
height: tokenSize
|
height: tokenSize
|
||||||
|
|
@ -126,12 +126,21 @@ export default class DHToken extends CONFIG.Token.documentClass {
|
||||||
super._onRelatedUpdate(update, operation);
|
super._onRelatedUpdate(update, operation);
|
||||||
|
|
||||||
if (!this.actor?.isOwner) return;
|
if (!this.actor?.isOwner) return;
|
||||||
|
|
||||||
|
const updates = Array.isArray(update) ? update : [update];
|
||||||
const activeGM = game.users.activeGM; // Let the active GM take care of updates if available
|
const activeGM = game.users.activeGM; // Let the active GM take care of updates if available
|
||||||
if (this.actor.system.metadata.usesSize && update.system?.size && activeGM && game.user.id === activeGM.id) {
|
for (let update of updates) {
|
||||||
const tokenSizes = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).tokenSizes;
|
if (
|
||||||
const tokenSize = tokenSizes[update.system.size];
|
this.actor.system.metadata.usesSize &&
|
||||||
if (tokenSize !== this.width || tokenSize !== this.height) {
|
update.system?.size &&
|
||||||
this.parent?.syncTokenDimensions(this, update.system.size);
|
activeGM &&
|
||||||
|
game.user.id === activeGM.id
|
||||||
|
) {
|
||||||
|
const tokenSizes = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).tokenSizes;
|
||||||
|
const tokenSize = tokenSizes[update.system.size];
|
||||||
|
if (tokenSize !== this.width || tokenSize !== this.height) {
|
||||||
|
this.parent?.syncTokenDimensions(this, update.system.size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -156,8 +165,10 @@ export default class DHToken extends CONFIG.Token.documentClass {
|
||||||
if (this.actor?.system.metadata.usesSize) {
|
if (this.actor?.system.metadata.usesSize) {
|
||||||
const tokenSizes = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).tokenSizes;
|
const tokenSizes = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).tokenSizes;
|
||||||
const tokenSize = tokenSizes[this.actor.system.size];
|
const tokenSize = tokenSizes[this.actor.system.size];
|
||||||
width = tokenSize ?? width;
|
if (tokenSize && tokenSize !== CONFIG.DH.ACTOR.tokenSize.custom.id) {
|
||||||
height = tokenSize ?? height;
|
width = tokenSize ?? width;
|
||||||
|
height = tokenSize ?? height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Round width and height to nearest multiple of 0.5 if not small
|
// Round width and height to nearest multiple of 0.5 if not small
|
||||||
|
|
|
||||||
82
templates/sheets-settings/token-config/appearance.hbs
Normal file
82
templates/sheets-settings/token-config/appearance.hbs
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
<div class="tab scrollable{{#if tab.active}} active{{/if}}" data-group="{{tab.group}}" data-tab="{{tab.id}}">
|
||||||
|
{{formGroup fields.texture.fields.src value=source.texture.src rootId=rootId}}
|
||||||
|
{{#if randomImgEnabled}}
|
||||||
|
{{formGroup fields.randomImg value=source.randomImg classes="slim" rootId=rootId}}
|
||||||
|
{{else if hasAlternates}}
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{rootId}}-alternateImages">{{localize "TOKEN.ImageAlts"}}</label>
|
||||||
|
<select id="{{rootId}}-alternateImages" class="alternate-images" name="alternateImages">
|
||||||
|
{{selectOptions alternateImages selected=source.texture.src blank=""}}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group slim" {{#if actorSizeUsed}}data-tooltip="{{localize "DAGGERHEART.APPLICATIONS.TokenConfig.actorSizeUsed"}}"{{/if}}>
|
||||||
|
<label>
|
||||||
|
{{localize "TOKEN.Dimensions"}} <span class="units">({{localize "GridSpaces"}})</span>
|
||||||
|
{{#if actorSizeUsed}}
|
||||||
|
<i class="fa-solid fa-lock"></i>
|
||||||
|
{{/if}}
|
||||||
|
</label>
|
||||||
|
<div class="form-fields">
|
||||||
|
<label for="{{rootId}}-width">{{localize "DOCUMENT.FIELDS.width.label"}}</label>
|
||||||
|
{{formInput fields.width value=source.width id=(concat rootId "-width") disabled=actorSizeUsed}}
|
||||||
|
<label for="{{rootId}}-height">{{localize "DOCUMENT.FIELDS.height.label"}}</label>
|
||||||
|
{{formInput fields.height value=source.height id=(concat rootId "-height") disabled=actorSizeUsed}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{#if shapes}}
|
||||||
|
{{formGroup fields.shape value=source.shape choices=shapes classes="slim" rootId=rootId}}
|
||||||
|
{{/if}}
|
||||||
|
{{formGroup fields.texture.fields.fit value=source.texture.fit choices=textureFitModes classes="slim" rootId=rootId}}
|
||||||
|
|
||||||
|
<div class="form-group slim">
|
||||||
|
<label>{{localize "Anchor"}}</label>
|
||||||
|
<div class="form-fields">
|
||||||
|
<label for="{{rootId}}-anchorX">{{localize "TOKEN.FIELDS.texture.anchorX.label"}}</label>
|
||||||
|
{{formInput fields.texture.fields.anchorX value=source.texture.anchorX id=(concat rootId "-anchorX")
|
||||||
|
placeholder="0.5"}}
|
||||||
|
<label for="{{rootId}}-anchorY">{{localize "TOKEN.FIELDS.texture.anchorY.label"}}</label>
|
||||||
|
{{formInput fields.texture.fields.anchorY value=source.texture.anchorY id=(concat rootId "-anchorY")
|
||||||
|
placeholder="0.5"}}
|
||||||
|
</div>
|
||||||
|
<p class="hint">{{localize "TOKEN.AnchorHint"}}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{rootId}}-scale">{{localize "Scale"}} <span class="units">({{localize "Ratio"}})</span></label>
|
||||||
|
<div class="form-fields">
|
||||||
|
<range-picker id="{{rootId}}-scale" name="scale" value={{scale}} min="0.2" max="3" step="0.05"></range-picker>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group slim">
|
||||||
|
<label>{{localize "TOKEN.Mirror"}}</label>
|
||||||
|
<div class="form-fields">
|
||||||
|
<label class="checkbox" for="{{rootId}}-mirrorX">
|
||||||
|
{{localize "TOKEN.MirrorX"}}
|
||||||
|
<input type="checkbox" id="{{rootId}}-mirrorX" name="mirrorX" {{checked mirrorX}}>
|
||||||
|
</label>
|
||||||
|
<label class="checkbox" for="{{rootId}}-mirrorY">
|
||||||
|
{{localize "TOKEN.MirrorY"}}
|
||||||
|
<input type="checkbox" id="{{rootId}}-mirrorY" name="mirrorY" {{checked mirrorY}}>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{formGroup fields.texture.fields.tint value=source.texture.tint placeholder="#ffffff" rootId=rootId}}
|
||||||
|
{{formGroup fields.alpha value=source.alpha step=0.05 rootId=rootId}}
|
||||||
|
{{formGroup fields.lockRotation value=source.lockRotation rootId=rootId}}
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>{{localize "TOKEN.RING.SHEET.legend"}}</legend>
|
||||||
|
{{formGroup fields.ring.fields.enabled value=source.ring.enabled rootId=rootId}}
|
||||||
|
{{formGroup fields.ring.fields.colors.fields.ring value=source.ring.colors.ring rootId=rootId}}
|
||||||
|
{{formGroup fields.ring.fields.colors.fields.background value=source.ring.colors.background rootId=rootId}}
|
||||||
|
{{formGroup fields.ring.fields.subject.fields.texture value=source.ring.subject.texture rootId=rootId}}
|
||||||
|
{{formGroup fields.ring.fields.subject.fields.scale value=source.ring.subject.scale max=3 step=0.02 rootId=rootId}}
|
||||||
|
{{formGroup fields.ring.fields.effects value=source.ring.effects input=ringEffectsInput stacked=true rootId=rootId}}
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
|
@ -23,11 +23,11 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<div class="tag" data-tooltip="DAGGERHEART.UI.Tooltip.tokenSize">
|
<div class="tag" data-tooltip="DAGGERHEART.UI.Tooltip.tokenSize">
|
||||||
<i class="fa-solid fa-circle-user"></i>
|
<i class="fa-solid fa-circle-user"></i>
|
||||||
{{#if source.system.size}}
|
{{#unless (eq source.system.size 'custom')}}
|
||||||
<span>{{localize (concat "DAGGERHEART.CONFIG.TokenSize." source.system.size)}}</span>
|
<span>{{localize (concat "DAGGERHEART.CONFIG.TokenSize." source.system.size)}}</span>
|
||||||
{{else}}
|
{{else}}
|
||||||
<span>{{source.prototypeToken.width}}x{{source.prototypeToken.height}}</span>
|
<span>{{source.prototypeToken.width}}x{{source.prototypeToken.height}}</span>
|
||||||
{{/if}}
|
{{/unless}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<line-div></line-div>
|
<line-div></line-div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue