mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-22 07:23:37 +02:00
Fixed sync start
This commit is contained in:
parent
d3437ffa7b
commit
d9e36e3a23
8 changed files with 80 additions and 7 deletions
|
|
@ -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 updateActorsRangeDependentEffects = async token => {
|
||||||
const rangeMeasurement = game.settings.get(
|
const rangeMeasurement = game.settings.get(
|
||||||
CONFIG.DH.id,
|
CONFIG.DH.id,
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
selected: false
|
selected: false
|
||||||
}));
|
}));
|
||||||
this.intiator = null;
|
this.intiator = null;
|
||||||
|
this.openForAllPlayers = true;
|
||||||
|
|
||||||
this.tabGroups.application = Object.keys(party.system.tagTeam.members).length
|
this.tabGroups.application = Object.keys(party.system.tagTeam.members).length
|
||||||
? 'tagTeamRoll'
|
? 'tagTeamRoll'
|
||||||
|
|
@ -33,6 +34,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
|
|
||||||
static DEFAULT_OPTIONS = {
|
static DEFAULT_OPTIONS = {
|
||||||
tag: 'form',
|
tag: 'form',
|
||||||
|
id: 'TagTeamDialog',
|
||||||
classes: ['daggerheart', 'views', 'dh-style', 'dialog', 'tag-team-dialog'],
|
classes: ['daggerheart', 'views', 'dh-style', 'dialog', 'tag-team-dialog'],
|
||||||
position: { width: 550, height: 'auto' },
|
position: { width: 550, height: 'auto' },
|
||||||
actions: {
|
actions: {
|
||||||
|
|
@ -77,6 +79,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
|
|
||||||
async _prepareContext(_options) {
|
async _prepareContext(_options) {
|
||||||
const context = await super._prepareContext(_options);
|
const context = await super._prepareContext(_options);
|
||||||
|
context.isEditable = this.getIsEditable();
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
@ -94,6 +97,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
partContext.initiator = this.initiator;
|
partContext.initiator = this.initiator;
|
||||||
partContext.initiatorOptions = selectedMembers.map(x => ({ value: x.id, label: x.name }));
|
partContext.initiatorOptions = selectedMembers.map(x => ({ value: x.id, label: x.name }));
|
||||||
partContext.initiatorDisabled = !selectedMembers.length;
|
partContext.initiatorDisabled = !selectedMembers.length;
|
||||||
|
partContext.openForAllPlayers = this.openForAllPlayers;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'tagTeamRoll':
|
case 'tagTeamRoll':
|
||||||
|
|
@ -139,6 +143,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
|
|
||||||
partContext.members[actorId] = {
|
partContext.members[actorId] = {
|
||||||
...data,
|
...data,
|
||||||
|
isEditable: actor.testUserPermission(game.user, CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER),
|
||||||
key: actorId,
|
key: actorId,
|
||||||
readyToRoll: Boolean(data.rollChoice),
|
readyToRoll: Boolean(data.rollChoice),
|
||||||
hasRolled: Boolean(data.rollData),
|
hasRolled: Boolean(data.rollData),
|
||||||
|
|
@ -164,8 +169,10 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
}
|
}
|
||||||
|
|
||||||
static async updateData(_event, _, formData) {
|
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.initiator = initiator;
|
||||||
|
this.openForAllPlayers = openForAllPlayers !== undefined ? openForAllPlayers : this.openForAllPlayers;
|
||||||
|
|
||||||
this.updatePartyData(partyData);
|
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 }) => {
|
tagTeamRefresh = ({ refreshType, action }) => {
|
||||||
if (refreshType !== RefreshType.TagTeamRoll) return;
|
if (refreshType !== RefreshType.TagTeamRoll) return;
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
case 'startTagTeamRoll':
|
||||||
|
this.tabGroups.application = 'tagTeamRoll';
|
||||||
|
break;
|
||||||
case 'refresh':
|
case 'refresh':
|
||||||
this.render();
|
this.render();
|
||||||
break;
|
break;
|
||||||
|
|
@ -227,9 +244,23 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
}, {})
|
}, {})
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
/* Update Party data and refresh all views */
|
|
||||||
this.tabGroups.application = 'tagTeamRoll';
|
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();
|
this.render();
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
export const hooksConfig = {
|
export const hooksConfig = {
|
||||||
effectDisplayToggle: 'DHEffectDisplayToggle',
|
effectDisplayToggle: 'DHEffectDisplayToggle',
|
||||||
lockedTooltipDismissed: 'DHLockedTooltipDismissed'
|
lockedTooltipDismissed: 'DHLockedTooltipDismissed',
|
||||||
|
tagTeamStart: 'DHTagTeamRollStart'
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,9 @@ export function handleSocketEvent({ action = null, data = {} } = {}) {
|
||||||
case socketEvent.DowntimeTrigger:
|
case socketEvent.DowntimeTrigger:
|
||||||
Party.downtimeMoveQuery(data);
|
Party.downtimeMoveQuery(data);
|
||||||
break;
|
break;
|
||||||
|
case socketEvent.TagTeamStart:
|
||||||
|
Hooks.callAll(CONFIG.DH.HOOKS.hooksConfig.tagTeamStart, data);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -22,7 +25,8 @@ export const socketEvent = {
|
||||||
GMUpdate: 'DhGMUpdate',
|
GMUpdate: 'DhGMUpdate',
|
||||||
Refresh: 'DhRefresh',
|
Refresh: 'DhRefresh',
|
||||||
DhpFearUpdate: 'DhFearUpdate',
|
DhpFearUpdate: 'DhFearUpdate',
|
||||||
DowntimeTrigger: 'DowntimeTrigger'
|
DowntimeTrigger: 'DowntimeTrigger',
|
||||||
|
TagTeamStart: 'DhTagTeamStart'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const GMUpdateEvent = {
|
export const GMUpdateEvent = {
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,22 @@
|
||||||
footer {
|
footer {
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
|
||||||
> * {
|
button {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.finish-tools {
|
||||||
|
flex: none;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
|
||||||
|
&.inactive {
|
||||||
|
opacity: 0.4;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,11 @@
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 16px;
|
gap: 16px;
|
||||||
|
|
||||||
|
&.inactive {
|
||||||
|
opacity: 0.4;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
.team-container {
|
.team-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 16px;
|
gap: 16px;
|
||||||
|
|
@ -15,6 +20,11 @@
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|
||||||
|
&.inactive {
|
||||||
|
opacity: 0.4;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
.data-container {
|
.data-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
|
||||||
|
|
@ -26,5 +26,9 @@
|
||||||
|
|
||||||
<footer>
|
<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>
|
<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>
|
</footer>
|
||||||
</section>
|
</section>
|
||||||
|
|
@ -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}}">
|
<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">
|
<div class="team-container">
|
||||||
{{#each members as |member key|}}
|
{{#each members as |member key|}}
|
||||||
<fieldset class="member-container">
|
<fieldset class="member-container {{#unless member.isEditable}}inactive{{/unless}}">
|
||||||
<div class="data-container">
|
<div class="data-container">
|
||||||
<div class="member-info">
|
<div class="member-info">
|
||||||
<img src="{{member.img}}" />
|
<img src="{{member.img}}" />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue