Merge branch 'development' into feature/1122-compendium-browser-position-saved

This commit is contained in:
Chris Ryan 2025-09-19 10:48:40 +10:00
commit 804f734568
9 changed files with 116 additions and 38 deletions

View file

@ -2029,6 +2029,7 @@
"range": "Range", "range": "Range",
"reactionRoll": "Reaction Roll", "reactionRoll": "Reaction Roll",
"recovery": "Recovery", "recovery": "Recovery",
"refresh": "Refresh",
"reroll": "Reroll", "reroll": "Reroll",
"rerollThing": "Reroll {thing}", "rerollThing": "Reroll {thing}",
"resource": "Resource", "resource": "Resource",

View file

@ -16,7 +16,7 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
this.action = this.action =
config.data.attack?._id == config.source.action config.data.attack?._id == config.source.action
? config.data.attack ? config.data.attack
: this.item.system.actions.get(config.source.action); : this.item.system.actionsList?.find(a => a.id === config.source.action);
} }
} }

View file

@ -1,10 +1,49 @@
export default class DhSidebar extends Sidebar { export default class DhSidebar extends foundry.applications.sidebar.Sidebar {
/** @override */ /** @override */
static TABS = { static TABS = {
...super.TABS, chat: {
documentName: 'ChatMessage'
},
combat: {
documentName: 'Combat'
},
scenes: {
documentName: 'Scene',
gmOnly: true
},
actors: {
documentName: 'Actor'
},
items: {
documentName: 'Item'
},
journal: {
documentName: 'JournalEntry',
tooltip: 'SIDEBAR.TabJournal'
},
tables: {
documentName: 'RollTable'
},
cards: {
documentName: 'Cards'
},
macros: {
documentName: 'Macro'
},
playlists: {
documentName: 'Playlist'
},
compendium: {
tooltip: 'SIDEBAR.TabCompendium',
icon: 'fa-solid fa-book-atlas'
},
daggerheartMenu: { daggerheartMenu: {
tooltip: 'DAGGERHEART.UI.Sidebar.daggerheartMenu.title', tooltip: 'DAGGERHEART.UI.Sidebar.daggerheartMenu.title',
img: 'systems/daggerheart/assets/logos/FoundryBorneLogoWhite.svg' img: 'systems/daggerheart/assets/logos/FoundryBorneLogoWhite.svg'
},
settings: {
tooltip: 'SIDEBAR.TabSettings',
icon: 'fa-solid fa-gears'
} }
}; };

View file

@ -370,19 +370,6 @@ export const typeConfig = {
label: 'DAGGERHEART.ITEMS.Subclass.spellcastingTrait' label: 'DAGGERHEART.ITEMS.Subclass.spellcastingTrait'
} }
], ],
filters: []
},
beastforms: {
columns: [
{
key: 'system.tier',
label: 'DAGGERHEART.GENERAL.Tiers.singular'
},
{
key: 'system.mainTrait',
label: 'DAGGERHEART.GENERAL.Trait.single'
}
],
filters: [ filters: [
{ {
key: 'system.linkedClass.uuid', key: 'system.linkedClass.uuid',

View file

@ -103,7 +103,7 @@ export default class CostField extends fields.ArrayField {
static calcCosts(costs) { static calcCosts(costs) {
const resources = CostField.getResources.call(this, costs); const resources = CostField.getResources.call(this, costs);
let filteredCosts = costs; let filteredCosts = costs;
if (this.parent.metadata.isQuantifiable && this.parent.consumeOnUse === false) { if (this.parent?.metadata.isQuantifiable && this.parent.consumeOnUse === false) {
filteredCosts = filteredCosts.filter(c => c.key !== 'quantity'); filteredCosts = filteredCosts.filter(c => c.key !== 'quantity');
} }

View file

@ -57,7 +57,10 @@ export default class DhTemplateManager {
* @param {wheel Event} event * @param {wheel Event} event
*/ */
#onMouseWheel(event) { #onMouseWheel(event) {
if (!event.shiftKey) return; if (!this.#activePreview) {
return;
}
if (!event.shiftKey && !event.ctrlKey) return;
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
const { moveTime, object } = this.#activePreview; const { moveTime, object } = this.#activePreview;
@ -66,8 +69,10 @@ export default class DhTemplateManager {
if (now - (moveTime || 0) <= 16) return; if (now - (moveTime || 0) <= 16) return;
this.#activePreview.moveTime = now; this.#activePreview.moveTime = now;
const multiplier = event.shiftKey ? 0.2 : 0.1;
object.document.updateSource({ object.document.updateSource({
direction: object.document.direction + event.deltaY * 0.2 direction: object.document.direction + event.deltaY * multiplier
}); });
object.renderFlags.set({ refresh: true }); object.renderFlags.set({ refresh: true });
} }
@ -77,12 +82,13 @@ export default class DhTemplateManager {
* @param {contextmenu Event} event * @param {contextmenu Event} event
*/ */
#cancelTemplate(event) { #cancelTemplate(event) {
const { mousemove, mousedown, contextmenu } = this.#activePreview.events; const { mousemove, mousedown, contextmenu, wheel } = this.#activePreview.events;
canvas.templates._onDragLeftCancel(event); canvas.templates._onDragLeftCancel(event);
canvas.stage.off('mousemove', mousemove); canvas.stage.off('mousemove', mousemove);
canvas.stage.off('mousedown', mousedown); canvas.stage.off('mousedown', mousedown);
canvas.app.view.removeEventListener('contextmenu', contextmenu); canvas.app.view.removeEventListener('contextmenu', contextmenu);
canvas.app.view.removeEventListener('wheel', wheel);
} }
/** /**
@ -91,9 +97,9 @@ export default class DhTemplateManager {
*/ */
#confirmTemplate(event) { #confirmTemplate(event) {
event.stopPropagation(); event.stopPropagation();
this.#cancelTemplate(event);
canvas.scene.createEmbeddedDocuments('MeasuredTemplate', [this.#activePreview.document.toObject()]); canvas.scene.createEmbeddedDocuments('MeasuredTemplate', [this.#activePreview.document.toObject()]);
this.#activePreview = undefined;
this.#cancelTemplate(event);
} }
} }

View file

@ -3,6 +3,8 @@ export default function DhTemplateEnricher(match, _options) {
let type = null, let type = null,
range = null, range = null,
angle = CONFIG.MeasuredTemplate.defaults.angle,
direction = 0,
inline = false; inline = false;
parts.forEach(part => { parts.forEach(part => {
@ -16,14 +18,24 @@ export default function DhTemplateEnricher(match, _options) {
type = matchedType; type = matchedType;
break; break;
case 'range': case 'range':
const matchedRange = Object.values(CONFIG.DH.GENERAL.templateRanges).find( if (Number.isNaN(Number(split[1]))) {
x => x.id.toLowerCase() === split[1] || x.short === split[1] const matchedRange = Object.values(CONFIG.DH.GENERAL.templateRanges).find(
); x => x.id.toLowerCase() === split[1] || x.short === split[1]
range = matchedRange?.id; );
range = matchedRange?.id;
} else {
range = split[1];
}
break; break;
case 'inline': case 'inline':
inline = true; inline = true;
break; break;
case 'angle':
angle = split[1];
break;
case 'direction':
direction = split[1];
break;
} }
} }
}); });
@ -32,10 +44,32 @@ export default function DhTemplateEnricher(match, _options) {
const label = game.i18n.localize(`DAGGERHEART.CONFIG.TemplateTypes.${type}`); const label = game.i18n.localize(`DAGGERHEART.CONFIG.TemplateTypes.${type}`);
const rangeDisplay = Number.isNaN(Number(range)) ? game.i18n.localize(`DAGGERHEART.CONFIG.Range.${range}.name`) : range;
let angleDisplay = '';
if (angle != CONFIG.MeasuredTemplate.defaults.angle) {
angleDisplay = 'angle:' + angle;
}
let directionDisplay = '';
if (direction != 0) {
directionDisplay = 'direction:' + direction;
}
let extraDisplay = '';
if (angleDisplay != '' && directionDisplay != '') {
extraDisplay = ' (' + angleDisplay + '|' + directionDisplay + ')';
} else if (angleDisplay != '') {
extraDisplay = ' (' + angleDisplay + ')';
} else if (directionDisplay != '') {
extraDisplay = ' (' + directionDisplay + ')';
}
const templateElement = document.createElement('span'); const templateElement = document.createElement('span');
templateElement.innerHTML = ` templateElement.innerHTML = `
<button type="button" class="measured-template-button${inline ? ' inline' : ''}" data-type="${type}" data-range="${range}"> <button type="button" class="measured-template-button${inline ? ' inline' : ''}"
${label} - ${game.i18n.localize(`DAGGERHEART.CONFIG.Range.${range}.name`)} data-type="${type}" data-range="${range}" data-angle="${angle}" data-direction="${direction}">
${label} - ${rangeDisplay}${extraDisplay}
</button> </button>
`; `;
@ -45,21 +79,25 @@ export default function DhTemplateEnricher(match, _options) {
export const renderMeasuredTemplate = async event => { export const renderMeasuredTemplate = async event => {
const button = event.currentTarget, const button = event.currentTarget,
type = button.dataset.type, type = button.dataset.type,
range = button.dataset.range; range = button.dataset.range,
angle = button.dataset.angle,
direction = button.dataset.direction;
if (!type || !range || !game.canvas.scene) return; if (!type || !range || !game.canvas.scene) return;
const usedType = type === 'inFront' ? 'cone' : type === 'emanation' ? 'circle' : type; const usedType = type === 'inFront' ? 'cone' : type === 'emanation' ? 'circle' : type;
const angle = const usedAngle =
type === CONST.MEASURED_TEMPLATE_TYPES.CONE type === CONST.MEASURED_TEMPLATE_TYPES.CONE
? CONFIG.MeasuredTemplate.defaults.angle ? (angle ?? CONFIG.MeasuredTemplate.defaults.angle)
: type === CONFIG.DH.GENERAL.templateTypes.INFRONT : type === CONFIG.DH.GENERAL.templateTypes.INFRONT
? '180' ? '180'
: undefined; : undefined;
const baseDistance = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.variantRules).rangeMeasurement[ let baseDistance = range;
range if (Number.isNaN(Number(range))) {
]; baseDistance =
game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.variantRules).rangeMeasurement[range];
}
const distance = type === CONFIG.DH.GENERAL.templateTypes.EMANATION ? baseDistance + 2.5 : baseDistance; const distance = type === CONFIG.DH.GENERAL.templateTypes.EMANATION ? baseDistance + 2.5 : baseDistance;
const { width, height } = game.canvas.scene.dimensions; const { width, height } = game.canvas.scene.dimensions;
@ -69,7 +107,8 @@ export const renderMeasuredTemplate = async event => {
t: usedType, t: usedType,
distance: distance, distance: distance,
width: type === CONST.MEASURED_TEMPLATE_TYPES.RAY ? 5 : undefined, width: type === CONST.MEASURED_TEMPLATE_TYPES.RAY ? 5 : undefined,
angle: angle angle: usedAngle,
direction: direction
}; };
CONFIG.ux.TemplateManager.createPreview(data); CONFIG.ux.TemplateManager.createPreview(data);

View file

@ -210,7 +210,13 @@
} }
p { p {
margin: 0; &:first-child {
margin-top: 0;
}
&:last-child {
margin-bottom: 0;
}
} }
ul { ul {

View file

@ -16,7 +16,7 @@
{{/each}} {{/each}}
</div> </div>
<button data-action="refreshActors" {{disabled disableRefresh}}>{{localize "Refresh"}}</button> <button data-action="refreshActors" {{disabled disableRefresh}}>{{localize "DAGGERHEART.GENERAL.refresh"}}</button>
</div> </div>
</fieldset> </fieldset>
</div> </div>