macro cleanup DialogV2
This commit is contained in:
parent
f900cb7d53
commit
be74c79b35
@ -1,33 +1,33 @@
|
||||
let tokens = []
|
||||
let tokens = [];
|
||||
if (canvas.tokens.controlled.length > 0) {
|
||||
tokens = canvas.tokens.controlled
|
||||
tokens = canvas.tokens.controlled;
|
||||
}
|
||||
if (tokens.length > 0) {
|
||||
main(tokens)
|
||||
main(tokens);
|
||||
} else {
|
||||
ui.notifications.error('Please select or target a token')
|
||||
ui.notifications.error('Please select or target a token');
|
||||
}
|
||||
|
||||
async function main (tokens) {
|
||||
const currencies = ['Copper', 'Silver', 'Gold', 'Platinum']
|
||||
let template = '<div><table><thead><tr><th>Actor</th><th>Currency</th></tr></thead><tbody>'
|
||||
async function main(tokens) {
|
||||
const currencies = ['Copper', 'Silver', 'Gold', 'Platinum'];
|
||||
let template = '<div><table><thead><tr><th>Actor</th><th>Currency</th></tr></thead><tbody>';
|
||||
const fmtOptions = {
|
||||
minimumIntegerDigits: 1,
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2
|
||||
}
|
||||
const fmt = Intl.NumberFormat('en-US', fmtOptions)
|
||||
maximumFractionDigits: 2,
|
||||
};
|
||||
const fmt = Intl.NumberFormat('en-US', fmtOptions);
|
||||
for (const token of tokens) {
|
||||
const actor = token.actor
|
||||
let total = 0
|
||||
for (const item of actor.items.filter(i => currencies.indexOf(i.name) > -1)) {
|
||||
total += item.system.price * item.system.quantity
|
||||
const actor = token.actor;
|
||||
let total = 0;
|
||||
for (const item of actor.items.filter((i) => currencies.indexOf(i.name) > -1)) {
|
||||
total += item.system.price * item.system.quantity;
|
||||
}
|
||||
template += `<tr><td>${actor.name}</td><td>${fmt.format::(total)}</td></tr>`
|
||||
template += `<tr><td>${actor.name}</td><td>${fmt.format(total)}</td></tr>`;
|
||||
}
|
||||
template += '</thead></tbody>'
|
||||
Dialog.prompt({
|
||||
title: 'Currency Totals',
|
||||
content: template
|
||||
})
|
||||
template += '</thead></tbody>';
|
||||
foundry.applications.api.DialogV2.prompt({
|
||||
window: { title: 'Currency Totals' },
|
||||
content: template,
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
new Dialog({
|
||||
title: 'Damage Roll Configuration',
|
||||
new foundry.applications.api.DialogV2({
|
||||
window: { title: "Damage Roll Configuration" },
|
||||
content: `
|
||||
<form>
|
||||
<div class="form-group">
|
||||
@ -16,24 +16,28 @@ new Dialog({
|
||||
</div>
|
||||
</form>
|
||||
`,
|
||||
buttons: {
|
||||
ok: {
|
||||
label: 'Roll Damage',
|
||||
callback: (html) => {
|
||||
const damageRoll = html.find('input[name="damageRoll"]').val()
|
||||
let flavor = html.find('input[name="flavor"]').val()
|
||||
const ap = parseInt(html.find('input[name="ap"]').val()) || 0
|
||||
const options = {}
|
||||
buttons: [
|
||||
{
|
||||
action: "ok",
|
||||
label: "Roll Damage",
|
||||
callback: (event, button, dialog) => {
|
||||
const form = new foundry.applications.ux.FormDataExtended(button.form);
|
||||
console.log(form)
|
||||
const damageRoll = form.object.damageRoll;
|
||||
let flavor = form.object.flavor;
|
||||
const ap = parseInt(form.object.ap) || 0;
|
||||
const options = {};
|
||||
if (ap > 0) {
|
||||
flavor = `${flavor ? flavor + ' - ' : ''}AP: ${ap}`
|
||||
options.ap = ap
|
||||
flavor = `${flavor ? flavor + " - " : ""}AP: ${ap}`
|
||||
options.ap = ap;
|
||||
}
|
||||
// Perform the damage roll and send the message
|
||||
new CONFIG.Dice.DamageRoll(damageRoll, null, options).toMessage({ flavor })
|
||||
}
|
||||
new CONFIG.Dice.DamageRoll(damageRoll, null, options).toMessage({ flavor });
|
||||
},
|
||||
},
|
||||
cancel: {
|
||||
label: 'Cancel'
|
||||
}
|
||||
}
|
||||
}).render(true)
|
||||
{
|
||||
action: "cancel",
|
||||
label: "Cancel",
|
||||
},
|
||||
],
|
||||
}).render(true);
|
||||
|
||||
@ -10,8 +10,8 @@ async function main() {
|
||||
return;
|
||||
}
|
||||
|
||||
new Dialog({
|
||||
title: 'Request Fear roll...',
|
||||
new foundry.applications.api.DialogV2({
|
||||
window: { title: 'Request Fear roll...' },
|
||||
content: `
|
||||
<form>
|
||||
<p>Requesting Fear roll from ${tokens.map((t) => t.name).join(', ')}.</p>
|
||||
@ -21,19 +21,21 @@ async function main() {
|
||||
</label>
|
||||
</div>
|
||||
</form>`,
|
||||
buttons: {
|
||||
ok: {
|
||||
buttons: [
|
||||
{
|
||||
action: "submit",
|
||||
label: 'Request Roll',
|
||||
callback: (html) => {
|
||||
const fear = parseInt(html.find('input[name="fear"]').val()) || 0;
|
||||
callback: (event, button, dialog) => {
|
||||
formdata = new foundry.applications.ux.FormDataExtended(button.form).object
|
||||
const fear = parseInt(formdata.fear) || 0;
|
||||
const options = { targetNumber: 4, fear };
|
||||
requestFearRollFromTokens(tokens, options);
|
||||
},
|
||||
},
|
||||
cancel: {
|
||||
label: 'Cancel',
|
||||
{
|
||||
action: "cancel", label: 'Cancel',
|
||||
},
|
||||
},
|
||||
],
|
||||
}).render(true);
|
||||
}
|
||||
|
||||
|
||||
@ -60,12 +60,14 @@ async function main() {
|
||||
</div>
|
||||
</form>
|
||||
`;
|
||||
const buttons = {
|
||||
ok: {
|
||||
const buttons = [
|
||||
{
|
||||
action: "submit",
|
||||
label: 'Request Roll',
|
||||
callback: (html) => {
|
||||
const form = html[0].querySelector('form');
|
||||
const formDataObject = new FormDataExtended(form).object;
|
||||
callback: (event, button, dialog) => {
|
||||
const form = button.form;
|
||||
const formDataObject = new foundry.applications.ux.FormDataExtended(form).object;
|
||||
console.log(formDataObject);
|
||||
const rollMod = parseInt(formDataObject.mod);
|
||||
const rollModDesc = formDataObject.modDesc;
|
||||
const rollParts = formDataObject.trait.split('|');
|
||||
@ -79,12 +81,12 @@ async function main() {
|
||||
requestRollFromTokens(tokens, rollType, rollDesc, options);
|
||||
},
|
||||
},
|
||||
cancel: {
|
||||
label: 'Cancel',
|
||||
{
|
||||
action: "cancel", label: 'Cancel',
|
||||
},
|
||||
};
|
||||
new Dialog({
|
||||
title: 'Request roll',
|
||||
];
|
||||
new foundry.applications.api.DialogV2({
|
||||
window { title: 'Request roll' },
|
||||
content,
|
||||
buttons,
|
||||
}).render(true);
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
/* globals args */
|
||||
const argBright = typeof args === 'undefined' ? null : args.length > 0 ? args[0] : null;
|
||||
// argument can be one of 'bright', 'dim', 'dark', 'pitchdark'. Other values
|
||||
// will guess based on scene darkness
|
||||
@ -58,7 +57,7 @@ function findAbility(token, swid) {
|
||||
return token.actor.items.find((i) => i.type === 'ability' && i.system.swid === swid);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
async function main() {
|
||||
const scene = game.scenes.current;
|
||||
let sceneBright = BRIGHT_LEVELS[0];
|
||||
if (scene.darkness > THRESHOLDS.pitchdark) {
|
||||
@ -73,8 +72,8 @@ async function main() {
|
||||
bright = argBright;
|
||||
}
|
||||
|
||||
new Dialog({
|
||||
title: 'Select scene brightness',
|
||||
new foundry.applications.api.DialogV2({
|
||||
window: { title: 'Select scene brightness' },
|
||||
content: `
|
||||
<form>
|
||||
<h2>Set token vision</h2>
|
||||
@ -109,14 +108,16 @@ async function main() {
|
||||
</div>
|
||||
</form>
|
||||
`,
|
||||
buttons: {
|
||||
ok: {
|
||||
buttons: [
|
||||
{
|
||||
action: "submit",
|
||||
label: 'Select scene Brightness',
|
||||
value: 'ok',
|
||||
callback: (html) => {
|
||||
const form = html[0].querySelector('form');
|
||||
const formDataObject = new FormDataExtended(form).Object;
|
||||
callback: (event, button, dialog) => {
|
||||
const form = button.form;
|
||||
const formDataObject = new foundry.applications.ux.FormDataExtended(form).object;
|
||||
console.log('form data', formDataObject, form);
|
||||
|
||||
bright = formDataObject.bright;
|
||||
for (const tokenId of scene.tokens.map((t) => t.id)) {
|
||||
const token = scene.tokens.get(tokenId);
|
||||
@ -147,10 +148,8 @@ async function main() {
|
||||
}
|
||||
},
|
||||
},
|
||||
cancel: {
|
||||
label: 'Cancel',
|
||||
},
|
||||
},
|
||||
{ action: "cancel", label: 'Cancel' },
|
||||
],
|
||||
}).render(true);
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
2025/05/28-21:41:56.707066 7ce44d7be640 Delete type=3 #1
|
||||
2025/05/28-21:41:56.709675 7ce44bfbb640 Level-0 table #5: started
|
||||
2025/05/28-21:41:56.712231 7ce44bfbb640 Level-0 table #5: 19401 bytes OK
|
||||
2025/05/28-21:41:56.714241 7ce44bfbb640 Delete type=0 #3
|
||||
2025/05/28-21:41:56.714365 7ce44bfbb640 Manual compaction at level-0 from '!folders!0nDRFmMBs5DBJU9M' @ 72057594037927935 : 1 .. '!items.effects!RC1Nz6iph8wPPK1B.g9W5hJisq3MsCpZW' @ 0 : 0; will stop at (end)
|
||||
2025/05/28-22:37:46.855626 7bc6857bc640 Delete type=3 #1
|
||||
2025/05/28-22:37:46.857913 7bc684fbb640 Level-0 table #5: started
|
||||
2025/05/28-22:37:46.860494 7bc684fbb640 Level-0 table #5: 19401 bytes OK
|
||||
2025/05/28-22:37:46.862582 7bc684fbb640 Delete type=0 #3
|
||||
2025/05/28-22:37:46.862712 7bc684fbb640 Manual compaction at level-0 from '!folders!0nDRFmMBs5DBJU9M' @ 72057594037927935 : 1 .. '!items.effects!RC1Nz6iph8wPPK1B.g9W5hJisq3MsCpZW' @ 0 : 0; will stop at (end)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
2025/05/28-21:41:56.840173 7912d87bc640 Delete type=3 #1
|
||||
2025/05/28-21:41:56.842145 7912d7fbb640 Level-0 table #5: started
|
||||
2025/05/28-21:41:56.844320 7912d7fbb640 Level-0 table #5: 6870 bytes OK
|
||||
2025/05/28-21:41:56.846291 7912d7fbb640 Delete type=0 #3
|
||||
2025/05/28-21:41:56.846358 7912d7fbb640 Manual compaction at level-0 from '!items!JWyBQe4tnOYljFAF' @ 72057594037927935 : 1 .. '!items!tWWSfEMmLmws6Yb1' @ 0 : 0; will stop at (end)
|
||||
2025/05/28-22:37:46.975797 7364abfff640 Delete type=3 #1
|
||||
2025/05/28-22:37:46.978271 7364a9bff640 Level-0 table #5: started
|
||||
2025/05/28-22:37:46.980551 7364a9bff640 Level-0 table #5: 6870 bytes OK
|
||||
2025/05/28-22:37:46.982643 7364a9bff640 Delete type=0 #3
|
||||
2025/05/28-22:37:46.982766 7364a9bff640 Manual compaction at level-0 from '!items!JWyBQe4tnOYljFAF' @ 72057594037927935 : 1 .. '!items!tWWSfEMmLmws6Yb1' @ 0 : 0; will stop at (end)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
2025/05/28-21:41:56.986214 7f67ff7fe640 Delete type=3 #1
|
||||
2025/05/28-21:41:56.988479 7f67fdbff640 Level-0 table #5: started
|
||||
2025/05/28-21:41:56.990440 7f67fdbff640 Level-0 table #5: 2017 bytes OK
|
||||
2025/05/28-21:41:56.992375 7f67fdbff640 Delete type=0 #3
|
||||
2025/05/28-21:41:56.992443 7f67fdbff640 Manual compaction at level-0 from '!actors!U5v4gFHquo0Y1SAq' @ 72057594037927935 : 1 .. '!actors!U5v4gFHquo0Y1SAq' @ 0 : 0; will stop at (end)
|
||||
2025/05/28-22:37:47.109584 77100d5fa640 Delete type=3 #1
|
||||
2025/05/28-22:37:47.111689 770fe6ffd640 Level-0 table #5: started
|
||||
2025/05/28-22:37:47.113682 770fe6ffd640 Level-0 table #5: 2017 bytes OK
|
||||
2025/05/28-22:37:47.115738 770fe6ffd640 Delete type=0 #3
|
||||
2025/05/28-22:37:47.115806 770fe6ffd640 Manual compaction at level-0 from '!actors!U5v4gFHquo0Y1SAq' @ 72057594037927935 : 1 .. '!actors!U5v4gFHquo0Y1SAq' @ 0 : 0; will stop at (end)
|
||||
|
||||
Binary file not shown.
@ -1,5 +1,5 @@
|
||||
2025/05/28-21:41:57.101447 7d71ad7bd640 Delete type=3 #1
|
||||
2025/05/28-21:41:57.103563 7d718ffff640 Level-0 table #5: started
|
||||
2025/05/28-21:41:57.105990 7d718ffff640 Level-0 table #5: 21473 bytes OK
|
||||
2025/05/28-21:41:57.108035 7d718ffff640 Delete type=0 #3
|
||||
2025/05/28-21:41:57.108115 7d718ffff640 Manual compaction at level-0 from '!folders!8FWN37c0gcpAisAv' @ 72057594037927935 : 1 .. '!macros!ypFtlnrgQkzqLpxI' @ 0 : 0; will stop at (end)
|
||||
2025/05/28-22:37:47.223706 722ad5fbe640 Delete type=3 #1
|
||||
2025/05/28-22:37:47.226010 722ab7fff640 Level-0 table #5: started
|
||||
2025/05/28-22:37:47.228570 722ab7fff640 Level-0 table #5: 16824 bytes OK
|
||||
2025/05/28-22:37:47.230659 722ab7fff640 Delete type=0 #3
|
||||
2025/05/28-22:37:47.230782 722ab7fff640 Manual compaction at level-0 from '!folders!8FWN37c0gcpAisAv' @ 72057594037927935 : 1 .. '!macros!ypFtlnrgQkzqLpxI' @ 0 : 0; will stop at (end)
|
||||
|
||||
Binary file not shown.
@ -1,5 +1,5 @@
|
||||
2025/05/28-21:41:57.215575 7be0bd7fa640 Delete type=3 #1
|
||||
2025/05/28-21:41:57.217780 7be096ffd640 Level-0 table #5: started
|
||||
2025/05/28-21:41:57.220087 7be096ffd640 Level-0 table #5: 22029 bytes OK
|
||||
2025/05/28-21:41:57.222061 7be096ffd640 Delete type=0 #3
|
||||
2025/05/28-21:41:57.222149 7be096ffd640 Manual compaction at level-0 from '!journal!HbtPlHNFO1L6RVj0' @ 72057594037927935 : 1 .. '!journal.pages!w4TImRTAiNiqDWeL.vQhO6BVdKZOubTUQ' @ 0 : 0; will stop at (end)
|
||||
2025/05/28-22:37:47.371068 75e9a17bd640 Delete type=3 #1
|
||||
2025/05/28-22:37:47.373331 75e983fff640 Level-0 table #5: started
|
||||
2025/05/28-22:37:47.375656 75e983fff640 Level-0 table #5: 22029 bytes OK
|
||||
2025/05/28-22:37:47.377626 75e983fff640 Delete type=0 #3
|
||||
2025/05/28-22:37:47.377712 75e983fff640 Manual compaction at level-0 from '!journal!HbtPlHNFO1L6RVj0' @ 72057594037927935 : 1 .. '!journal.pages!w4TImRTAiNiqDWeL.vQhO6BVdKZOubTUQ' @ 0 : 0; will stop at (end)
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,19 +0,0 @@
|
||||
{
|
||||
"name": "Poison",
|
||||
"sorting": "a",
|
||||
"folder": null,
|
||||
"type": "Macro",
|
||||
"_id": "DbVwJ0fIfuijv8Nu",
|
||||
"sort": 0,
|
||||
"color": null,
|
||||
"flags": {},
|
||||
"_stats": {
|
||||
"systemId": "swade",
|
||||
"systemVersion": "3.2.5",
|
||||
"coreVersion": "11.315",
|
||||
"createdTime": 1705990230579,
|
||||
"modifiedTime": 1705990230579,
|
||||
"lastModifiedBy": "sVoCvBU1knmXzoYe"
|
||||
},
|
||||
"_key": "!folders!DbVwJ0fIfuijv8Nu"
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user