mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Reduce Action Selection click number & Style Action Type Dialog (#408)
* Reduce Action Selection click number & Style Action Type Dialog * fixes * Action Select buttons color
This commit is contained in:
parent
26e3c38aa9
commit
3f95740b7a
14 changed files with 228 additions and 684 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import ActionSelectionDialog from "../applications/dialogs/actionSelectionDialog.mjs";
|
||||
|
||||
/**
|
||||
* Override and extend the basic Item implementation.
|
||||
* @extends {foundry.documents.Item}
|
||||
|
|
@ -94,41 +96,13 @@ export default class DHItem extends foundry.documents.Item {
|
|||
});
|
||||
}
|
||||
|
||||
async selectActionDialog(prevEvent) {
|
||||
const content = await foundry.applications.handlebars.renderTemplate(
|
||||
'systems/daggerheart/templates/dialogs/actionSelect.hbs',
|
||||
{
|
||||
actions: this.system.actionsList,
|
||||
itemName: this.name
|
||||
}
|
||||
),
|
||||
title = game.i18n.localize('DAGGERHEART.CONFIG.SelectAction.selectAction');
|
||||
|
||||
return foundry.applications.api.DialogV2.prompt({
|
||||
window: { title },
|
||||
classes: ['daggerheart', 'dh-style'],
|
||||
content,
|
||||
ok: {
|
||||
label: title,
|
||||
callback: (event, button, dialog) => {
|
||||
Object.defineProperty(prevEvent, 'shiftKey', {
|
||||
get() {
|
||||
return event.shiftKey;
|
||||
}
|
||||
});
|
||||
return this.system.actionsList.find(a => a._id === button.form.elements.actionId.value);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async use(event) {
|
||||
const actions = new Set(this.system.actionsList);
|
||||
if (actions?.size) {
|
||||
let action = actions.first();
|
||||
if (actions.size > 1 && !event?.shiftKey) {
|
||||
// Actions Choice Dialog
|
||||
action = await this.selectActionDialog(event);
|
||||
action = await ActionSelectionDialog.create(this, event);
|
||||
}
|
||||
if (action) return action.use(event);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue