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",
"reactionRoll": "Reaction Roll",
"recovery": "Recovery",
"refresh": "Refresh",
"reroll": "Reroll",
"rerollThing": "Reroll {thing}",
"resource": "Resource",

View file

@ -16,7 +16,7 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
this.action =
config.data.attack?._id == config.source.action
? 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 */
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: {
tooltip: 'DAGGERHEART.UI.Sidebar.daggerheartMenu.title',
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'
}
],
filters: []
},
beastforms: {
columns: [
{
key: 'system.tier',
label: 'DAGGERHEART.GENERAL.Tiers.singular'
},
{
key: 'system.mainTrait',
label: 'DAGGERHEART.GENERAL.Trait.single'
}
],
filters: [
{
key: 'system.linkedClass.uuid',

View file

@ -103,7 +103,7 @@ export default class CostField extends fields.ArrayField {
static calcCosts(costs) {
const resources = CostField.getResources.call(this, 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');
}

View file

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

View file

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

View file

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

View file

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