Fixed sync start

This commit is contained in:
WBHarry 2026-03-15 17:17:42 +01:00
parent d3437ffa7b
commit d9e36e3a23
8 changed files with 80 additions and 7 deletions

View file

@ -402,6 +402,17 @@ Hooks.on('chatMessage', (_, message) => {
}
});
Hooks.on(CONFIG.DH.HOOKS.hooksConfig.tagTeamStart, async data => {
if (data.openForAllPlayers && data.partyId) {
const party = game.actors.get(data.partyId);
if (!party) return;
const dialog = new game.system.api.applications.dialogs.TagTeamDialog(party);
dialog.tabGroups.application = 'tagTeamRoll';
await dialog.render({ force: true });
}
});
const updateActorsRangeDependentEffects = async token => {
const rangeMeasurement = game.settings.get(
CONFIG.DH.id,

View file

@ -19,6 +19,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
selected: false
}));
this.intiator = null;
this.openForAllPlayers = true;
this.tabGroups.application = Object.keys(party.system.tagTeam.members).length
? 'tagTeamRoll'
@ -33,6 +34,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
static DEFAULT_OPTIONS = {
tag: 'form',
id: 'TagTeamDialog',
classes: ['daggerheart', 'views', 'dh-style', 'dialog', 'tag-team-dialog'],
position: { width: 550, height: 'auto' },
actions: {
@ -77,6 +79,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.isEditable = this.getIsEditable();
return context;
}
@ -94,6 +97,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
partContext.initiator = this.initiator;
partContext.initiatorOptions = selectedMembers.map(x => ({ value: x.id, label: x.name }));
partContext.initiatorDisabled = !selectedMembers.length;
partContext.openForAllPlayers = this.openForAllPlayers;
break;
case 'tagTeamRoll':
@ -139,6 +143,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
partContext.members[actorId] = {
...data,
isEditable: actor.testUserPermission(game.user, CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER),
key: actorId,
readyToRoll: Boolean(data.rollChoice),
hasRolled: Boolean(data.rollData),
@ -164,8 +169,10 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
}
static async updateData(_event, _, formData) {
const { initiator, ...partyData } = foundry.utils.expandObject(formData.object);
const { initiator, openForAllPlayers, ...partyData } = foundry.utils.expandObject(formData.object);
this.initiator = initiator;
this.openForAllPlayers = openForAllPlayers !== undefined ? openForAllPlayers : this.openForAllPlayers;
this.updatePartyData(partyData);
}
@ -181,10 +188,20 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
}
}
getIsEditable() {
return this.party.system.partyMembers.some(actor => {
const selected = Boolean(this.party.system.tagTeam.members[actor.id]);
return selected && actor.testUserPermission(game.user, CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER);
});
}
tagTeamRefresh = ({ refreshType, action }) => {
if (refreshType !== RefreshType.TagTeamRoll) return;
switch (action) {
case 'startTagTeamRoll':
this.tabGroups.application = 'tagTeamRoll';
break;
case 'refresh':
this.render();
break;
@ -227,9 +244,23 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
}, {})
})
});
/* Update Party data and refresh all views */
this.tabGroups.application = 'tagTeamRoll';
// if (this.openForAllplayers) {
// game.socket.emit(`system.${CONFIG.DH.id}`, {
// action: socketEvent.Refresh,
// data: { refreshType: RefreshType.TagTeamRoll, action: 'startTagTeamRoll' }
// });
// }
const hookData = { openForAllPlayers: this.openForAllPlayers, partyId: this.party.id };
Hooks.callAll(CONFIG.DH.HOOKS.hooksConfig.tagTeamStart, hookData);
game.socket.emit(`system.${CONFIG.DH.id}`, {
action: socketEvent.TagTeamStart,
data: hookData
});
this.render();
}
//#endregion

View file

@ -1,4 +1,5 @@
export const hooksConfig = {
effectDisplayToggle: 'DHEffectDisplayToggle',
lockedTooltipDismissed: 'DHLockedTooltipDismissed'
lockedTooltipDismissed: 'DHLockedTooltipDismissed',
tagTeamStart: 'DHTagTeamRollStart'
};

View file

@ -15,6 +15,9 @@ export function handleSocketEvent({ action = null, data = {} } = {}) {
case socketEvent.DowntimeTrigger:
Party.downtimeMoveQuery(data);
break;
case socketEvent.TagTeamStart:
Hooks.callAll(CONFIG.DH.HOOKS.hooksConfig.tagTeamStart, data);
break;
}
}
@ -22,7 +25,8 @@ export const socketEvent = {
GMUpdate: 'DhGMUpdate',
Refresh: 'DhRefresh',
DhpFearUpdate: 'DhFearUpdate',
DowntimeTrigger: 'DowntimeTrigger'
DowntimeTrigger: 'DowntimeTrigger',
TagTeamStart: 'DhTagTeamStart'
};
export const GMUpdateEvent = {

View file

@ -38,10 +38,22 @@
footer {
margin-top: 8px;
display: flex;
gap: 8px;
> * {
button {
flex: 1;
}
.finish-tools {
flex: none;
display: flex;
align-items: center;
gap: 4px;
&.inactive {
opacity: 0.4;
}
}
}
}
}

View file

@ -4,6 +4,11 @@
flex-direction: column;
gap: 16px;
&.inactive {
opacity: 0.4;
pointer-events: none;
}
.team-container {
display: flex;
gap: 16px;
@ -15,6 +20,11 @@
gap: 8px;
flex: 1;
&.inactive {
opacity: 0.4;
pointer-events: none;
}
.data-container {
display: flex;
flex-direction: column;

View file

@ -26,5 +26,9 @@
<footer>
<button type="button" data-action="startTagTeamRoll" {{#unless canStartTagTeam}}disabled{{/unless}}>{{localize "Start Tag Team Roll"}} <i class="fa-solid fa-arrow-right-long"></i></button>
<div class="finish-tools {{#unless canStartTagTeam}}inactive{{/unless}}">
<span>{{localize "Open Dialog For All"}}</span>
<input type="checkbox" name="openForAllPlayers" {{#unless canStartTagTeam}}disabled{{/unless}} {{checked openForAllPlayers}} />
</div>
</footer>
</section>

View file

@ -1,8 +1,8 @@
<section class="tag-team-roll tab {{#if tabs.tagTeamRoll.active}} active{{/if}}" data-group="{{tabs.tagTeamRoll.group}}" data-tab="{{tabs.tagTeamRoll.id}}">
<div class="tag-team-roll-container">
<div class="tag-team-roll-container {{#unless isEditable}}inactive{{/unless}}">
<div class="team-container">
{{#each members as |member key|}}
<fieldset class="member-container">
<fieldset class="member-container {{#unless member.isEditable}}inactive{{/unless}}">
<div class="data-container">
<div class="member-info">
<img src="{{member.img}}" />