Compare commits

..

No commits in common. "bc9e11c0b593250a1f73fe61dd5aa902b90dfd25" and "557bf93853546666903968e098a75f6732a4d088" have entirely different histories.

10 changed files with 68 additions and 86 deletions

View file

@ -185,6 +185,8 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV
if (result === undefined) return; if (result === undefined) return;
const autoExpandDescription = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance)
.expandRollMessage?.desc;
const cls = getDocumentClass('ChatMessage'); const cls = getDocumentClass('ChatMessage');
const msg = { const msg = {
@ -200,6 +202,7 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV
img: this.selectedMove.img, img: this.selectedMove.img,
description: game.i18n.localize(this.selectedMove.description), description: game.i18n.localize(this.selectedMove.description),
result: result, result: result,
open: autoExpandDescription ? 'open' : '',
showRiskItAllButton: this.showRiskItAllButton, showRiskItAllButton: this.showRiskItAllButton,
riskItAllButtonLabel: this.riskItAllButtonLabel, riskItAllButtonLabel: this.riskItAllButtonLabel,
riskItAllHope: this.riskItAllHope riskItAllHope: this.riskItAllHope

View file

@ -196,6 +196,9 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV
.filter(x => x.testUserPermission(game.user, 'LIMITED')) .filter(x => x.testUserPermission(game.user, 'LIMITED'))
.filter(x => x.uuid !== this.actor.uuid); .filter(x => x.uuid !== this.actor.uuid);
const autoExpandDescription = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance)
.expandRollMessage?.desc;
const cls = getDocumentClass('ChatMessage'); const cls = getDocumentClass('ChatMessage');
const msg = { const msg = {
user: game.user.id, user: game.user.id,
@ -216,7 +219,8 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV
actor: { name: this.actor.name, img: this.actor.img }, actor: { name: this.actor.name, img: this.actor.img },
moves: moves, moves: moves,
characters: characters, characters: characters,
selfId: this.actor.uuid selfId: this.actor.uuid,
open: autoExpandDescription ? 'open' : ''
} }
), ),
flags: { flags: {

View file

@ -256,8 +256,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
if (Hooks.call(`${CONFIG.DH.id}.postUseAction`, this, config) === false) return; if (Hooks.call(`${CONFIG.DH.id}.postUseAction`, this, config) === false) return;
if (this.chatDisplay && !config.skips.createMessage && !config.actionChatMessageHandled) if (this.chatDisplay && !config.skips.createMessage && !config.actionChatMessageHandled) await this.toChat();
await this.toChat(null, config);
return config; return config;
} }

View file

@ -23,7 +23,7 @@ export default class DHSummonField extends fields.ArrayField {
super(summonFields, options, context); super(summonFields, options, context);
} }
static async execute(config) { static async execute() {
if (!canvas.scene) { if (!canvas.scene) {
ui.notifications.warn(game.i18n.localize('DAGGERHEART.ACTIONS.TYPES.summon.error')); ui.notifications.warn(game.i18n.localize('DAGGERHEART.ACTIONS.TYPES.summon.error'));
return; return;
@ -36,7 +36,6 @@ export default class DHSummonField extends fields.ArrayField {
const rolls = []; const rolls = [];
const summonData = []; const summonData = [];
const chatMessageData = [];
for (const summon of this.summon) { for (const summon of this.summon) {
const roll = new Roll(itemAbleRollParse(summon.count, this.actor, this.item)); const roll = new Roll(itemAbleRollParse(summon.count, this.actor, this.item));
await roll.evaluate(); await roll.evaluate();
@ -55,18 +54,17 @@ export default class DHSummonField extends fields.ArrayField {
tokenPreviewName: `${actor.prototypeToken.name}${remaining > 1 ? ` (${remaining}x)` : ''}` tokenPreviewName: `${actor.prototypeToken.name}${remaining > 1 ? ` (${remaining}x)` : ''}`
}); });
} }
chatMessageData.push({
data: actor,
quantity: countNumber
});
} }
if (rolls.length) await triggerChatRollFx(rolls); if (rolls.length) await triggerChatRollFx(rolls);
this.actor.sheet?.minimize(); this.actor.sheet?.minimize();
await CONFIG.ux.TokenManager.createTokensWithPreview(summonData, { elevation: this.actor.token?.elevation }); DHSummonField.handleSummon(summonData, this.actor);
this.actor.sheet?.maximize(); }
config.summonData = chatMessageData;
static async handleSummon(summonData, actionActor) {
await CONFIG.ux.TokenManager.createTokensWithPreview(summonData, { elevation: actionActor.token?.elevation });
return actionActor.sheet?.maximize();
} }
} }

View file

@ -269,7 +269,10 @@ export function ActionMixin(Base) {
return this.delete(); return this.delete();
} }
async toChat(origin, config) { async toChat(origin) {
const autoExpandDescription = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance)
.expandRollMessage?.desc;
const cls = getDocumentClass('ChatMessage'); const cls = getDocumentClass('ChatMessage');
const systemData = { const systemData = {
title: game.i18n.localize('DAGGERHEART.CONFIG.FeatureForm.action'), title: game.i18n.localize('DAGGERHEART.CONFIG.FeatureForm.action'),
@ -279,7 +282,7 @@ export function ActionMixin(Base) {
img: this.baseAction ? this.parent.parent.img : this.img, img: this.baseAction ? this.parent.parent.img : this.img,
tags: this.tags ? this.tags : ['Spell', 'Arcana', 'Lv 10'], tags: this.tags ? this.tags : ['Spell', 'Arcana', 'Lv 10'],
areas: this.areas, areas: this.areas,
summon: config?.summonData summon: this.summon
}, },
source: { source: {
actor: this.actor.uuid, actor: this.actor.uuid,
@ -304,7 +307,7 @@ export function ActionMixin(Base) {
system: systemData, system: systemData,
content: await foundry.applications.handlebars.renderTemplate( content: await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/ui/chat/action.hbs', 'systems/daggerheart/templates/ui/chat/action.hbs',
systemData { ...systemData, open: autoExpandDescription ? 'open' : '' }
), ),
flags: { flags: {
daggerheart: { daggerheart: {

View file

@ -3,13 +3,6 @@ import { emitGMUpdate, emitGMCreate, GMUpdateEvent } from '../systemRegistration
export default class DhpChatMessage extends foundry.documents.ChatMessage { export default class DhpChatMessage extends foundry.documents.ChatMessage {
targetHook = null; targetHook = null;
static #EXPAND_SECTIONS = [
{ selector: 'roll-section [data-action="expandRoll"]', key: 'roll' },
{ selector: 'damage-section', key: 'damage' },
{ selector: 'target-section', key: 'target' },
{ selector: 'description-section', key: 'desc' }
];
async renderHTML() { async renderHTML() {
const actor = game.actors.get(this.speaker.actor); const actor = game.actors.get(this.speaker.actor);
const actorData = const actorData =
@ -96,26 +89,23 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
} }
} }
// Check registered selectors and the main item section for expanding
// Preserving during re-render is handled by core foundry on anything with [data-action=expandRoll]
const autoExpandRoll = game.settings.get( const autoExpandRoll = game.settings.get(
CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance CONFIG.DH.id,
).expandRollMessage; CONFIG.DH.SETTINGS.gameSettings.appearance
for (const { selector, key } of DhpChatMessage.#EXPAND_SECTIONS) { ).expandRollMessage,
const elements = html.querySelectorAll(selector); rollSections = html.querySelectorAll('.roll-part'),
for (const element of elements) { itemDesc = html.querySelector('.domain-card-move');
element.classList.toggle('expanded', autoExpandRoll[key]); rollSections.forEach(s => {
} if (s.classList.contains('roll-section')) {
} const toExpand = s.querySelector('[data-action="expandRoll"]');
toExpand.classList.toggle('expanded', autoExpandRoll.roll);
// Auto expand the item description. These are not preserved by foundry during re-renders } else if (s.classList.contains('damage-section'))
const itemDesc = html.querySelector('details'); s.classList.toggle('expanded', autoExpandRoll.damage);
if (itemDesc) { else if (s.classList.contains('target-section')) s.classList.toggle('expanded', autoExpandRoll.target);
const existing = document.querySelector(`.chat-message[data-message-id="${this.id}"] details`); else if (s.classList.contains('description-section'))
if (existing?.hasAttribute('open') ?? autoExpandRoll.desc) { s.classList.toggle('expanded', autoExpandRoll.desc);
itemDesc.setAttribute('open', ''); });
} if (itemDesc && autoExpandRoll.desc) itemDesc.setAttribute('open', '');
}
} }
if (!this.isAuthor && !this.speakerActor?.isOwner) { if (!this.isAuthor && !this.speakerActor?.isOwner) {

View file

@ -19,10 +19,10 @@ export default class DhTokenManager {
} }
} }
const placedData = await canvas.tokens.placeTokens( return await canvas.tokens.placeTokens(
[ [
{ {
...(await actor.getTokenDocument()).toObject(), ...actor.prototypeToken.toObject(),
actorId: actor.id, actorId: actor.id,
displayName: 50, displayName: 50,
...tokenData ...tokenData
@ -30,8 +30,6 @@ export default class DhTokenManager {
], ],
{ create: false } { create: false }
); );
return placedData?.[0] ?? null;
} }
/** /**
@ -48,24 +46,22 @@ export default class DhTokenManager {
const createElevation = elevation ?? level.elevation.bottom; const createElevation = elevation ?? level.elevation.bottom;
for (const tokenData of tokensData) { for (const tokenData of tokensData) {
const previewToken = await this.createPreview(tokenData.actor, { const previewTokens = await this.createPreview(tokenData.actor, {
name: tokenData.tokenPreviewName, name: tokenData.tokenPreviewName,
level: game.user.viewedLevel, level: game.user.viewedLevel,
elevation: createElevation, elevation: createElevation,
flags: { daggerheart: { createPlacement: true } } flags: { daggerheart: { createPlacement: true } }
}); });
if (!previewToken) return null; if (!previewTokens?.length) return null;
const finalTokenData = {
...previewToken.toObject(),
name: tokenData.actor.prototypeToken.name,
displayName: tokenData.actor.prototypeToken.displayName,
flags: tokenData.actor.prototypeToken.flags
};
await canvas.scene.createEmbeddedDocuments( await canvas.scene.createEmbeddedDocuments(
'Token', 'Token',
[finalTokenData], previewTokens.map(x => ({
...x.toObject(),
name: tokenData.actor.prototypeToken.name,
displayName: tokenData.actor.prototypeToken.displayName,
flags: tokenData.actor.prototypeToken.flags
})),
{ controlObject: true, parent: canvas.scene } { controlObject: true, parent: canvas.scene }
); );
} }

View file

@ -599,23 +599,27 @@
} }
secret-block { secret-block {
display: block; position: relative;
section.secret {
/** A buffer to make the hover behavior work a bit better. The bottom in the button needs to compensate */ background-color: @red-10;
@buffer: 8px; padding: 0;
margin-top: -@buffer; margin-top: 0.375rem;
padding-top: @buffer; &.revealed {
background-color: @green-10;
}
p {
margin: 0.5rem 0;
}
}
button.reveal { button.reveal {
--button-size: 1rem; --button-size: 0.875rem;
height: var(--button-size);
position: absolute; position: absolute;
margin: auto; margin: auto;
left: 0; left: 0;
right: 0; right: 0;
width: min-content; width: min-content;
padding: 1px 8px 0 8px; padding: 1px 8px 0 8px;
bottom: calc(100% - 0.4375rem - 1px); bottom: calc(100% - 0.4375rem - 2px);
background-color: var(--dh-window-button-color-bg); // todo: find a better var name background-color: var(--dh-window-button-color-bg); // todo: find a better var name
border-color: var(--color-secret-border); border-color: var(--color-secret-border);
@ -623,7 +627,6 @@
font-size: var(--font-size-10); font-size: var(--font-size-10);
user-select: none; user-select: none;
text-transform: uppercase; text-transform: uppercase;
white-space: nowrap;
visibility: hidden; visibility: hidden;
} }
@ -632,20 +635,6 @@
visibility: visible; visibility: visible;
} }
} }
/**
* The element inside a secret-block.
* This is separate since during prosemirror editing, the secret-block container does not exist.
*/
section.secret {
--color-secret-bg: @red-10;
--color-revealed-bg: @green-10;
position: relative;
padding: 0;
p {
margin: 0.5rem 0;
}
}
} }
.system-daggerheart { .system-daggerheart {

View file

@ -2,7 +2,7 @@
"id": "daggerheart", "id": "daggerheart",
"title": "Daggerheart", "title": "Daggerheart",
"description": "An unofficial implementation of the Daggerheart system", "description": "An unofficial implementation of the Daggerheart system",
"version": "2.5.4", "version": "2.5.3",
"compatibility": { "compatibility": {
"minimum": "14.364", "minimum": "14.364",
"verified": "14.364", "verified": "14.364",
@ -10,7 +10,7 @@
}, },
"url": "https://github.com/Foundryborne/daggerheart", "url": "https://github.com/Foundryborne/daggerheart",
"manifest": "https://raw.githubusercontent.com/Foundryborne/daggerheart/v14/system.json", "manifest": "https://raw.githubusercontent.com/Foundryborne/daggerheart/v14/system.json",
"download": "https://github.com/Foundryborne/daggerheart/releases/download/2.5.4/system.zip", "download": "https://github.com/Foundryborne/daggerheart/releases/download/2.5.3/system.zip",
"authors": [ "authors": [
{ {
"name": "WBHarry" "name": "WBHarry"

View file

@ -16,10 +16,10 @@
{{#each action.summon}} {{#each action.summon}}
<div class="summon-container"> <div class="summon-container">
<div class="summon-label-container"> <div class="summon-label-container">
<img src="{{this.data.img}}" /> <img src="{{this.actor.img}}" />
<label>{{this.data.name}}</label> <label>{{this.actor.name}}</label>
</div> </div>
<span># {{this.quantity}}</span> <span># {{this.rolledCount}}</span>
</div> </div>
{{/each}} {{/each}}
</div> </div>