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) {
|
if (canvas.tokens.controlled.length > 0) {
|
||||||
tokens = canvas.tokens.controlled
|
tokens = canvas.tokens.controlled;
|
||||||
}
|
}
|
||||||
if (tokens.length > 0) {
|
if (tokens.length > 0) {
|
||||||
main(tokens)
|
main(tokens);
|
||||||
} else {
|
} else {
|
||||||
ui.notifications.error('Please select or target a token')
|
ui.notifications.error('Please select or target a token');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main (tokens) {
|
async function main(tokens) {
|
||||||
const currencies = ['Copper', 'Silver', 'Gold', 'Platinum']
|
const currencies = ['Copper', 'Silver', 'Gold', 'Platinum'];
|
||||||
let template = '<div><table><thead><tr><th>Actor</th><th>Currency</th></tr></thead><tbody>'
|
let template = '<div><table><thead><tr><th>Actor</th><th>Currency</th></tr></thead><tbody>';
|
||||||
const fmtOptions = {
|
const fmtOptions = {
|
||||||
minimumIntegerDigits: 1,
|
minimumIntegerDigits: 1,
|
||||||
minimumFractionDigits: 2,
|
minimumFractionDigits: 2,
|
||||||
maximumFractionDigits: 2
|
maximumFractionDigits: 2,
|
||||||
}
|
};
|
||||||
const fmt = Intl.NumberFormat('en-US', fmtOptions)
|
const fmt = Intl.NumberFormat('en-US', fmtOptions);
|
||||||
for (const token of tokens) {
|
for (const token of tokens) {
|
||||||
const actor = token.actor
|
const actor = token.actor;
|
||||||
let total = 0
|
let total = 0;
|
||||||
for (const item of actor.items.filter(i => currencies.indexOf(i.name) > -1)) {
|
for (const item of actor.items.filter((i) => currencies.indexOf(i.name) > -1)) {
|
||||||
total += item.system.price * item.system.quantity
|
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>'
|
template += '</thead></tbody>';
|
||||||
Dialog.prompt({
|
foundry.applications.api.DialogV2.prompt({
|
||||||
title: 'Currency Totals',
|
window: { title: 'Currency Totals' },
|
||||||
content: template
|
content: template,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
new Dialog({
|
new foundry.applications.api.DialogV2({
|
||||||
title: 'Damage Roll Configuration',
|
window: { title: "Damage Roll Configuration" },
|
||||||
content: `
|
content: `
|
||||||
<form>
|
<form>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -16,24 +16,28 @@ new Dialog({
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
`,
|
`,
|
||||||
buttons: {
|
buttons: [
|
||||||
ok: {
|
{
|
||||||
label: 'Roll Damage',
|
action: "ok",
|
||||||
callback: (html) => {
|
label: "Roll Damage",
|
||||||
const damageRoll = html.find('input[name="damageRoll"]').val()
|
callback: (event, button, dialog) => {
|
||||||
let flavor = html.find('input[name="flavor"]').val()
|
const form = new foundry.applications.ux.FormDataExtended(button.form);
|
||||||
const ap = parseInt(html.find('input[name="ap"]').val()) || 0
|
console.log(form)
|
||||||
const options = {}
|
const damageRoll = form.object.damageRoll;
|
||||||
|
let flavor = form.object.flavor;
|
||||||
|
const ap = parseInt(form.object.ap) || 0;
|
||||||
|
const options = {};
|
||||||
if (ap > 0) {
|
if (ap > 0) {
|
||||||
flavor = `${flavor ? flavor + ' - ' : ''}AP: ${ap}`
|
flavor = `${flavor ? flavor + " - " : ""}AP: ${ap}`
|
||||||
options.ap = ap
|
options.ap = ap;
|
||||||
}
|
}
|
||||||
// Perform the damage roll and send the message
|
// 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'
|
{
|
||||||
}
|
action: "cancel",
|
||||||
}
|
label: "Cancel",
|
||||||
}).render(true)
|
},
|
||||||
|
],
|
||||||
|
}).render(true);
|
||||||
|
|||||||
@ -10,8 +10,8 @@ async function main() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
new Dialog({
|
new foundry.applications.api.DialogV2({
|
||||||
title: 'Request Fear roll...',
|
window: { title: 'Request Fear roll...' },
|
||||||
content: `
|
content: `
|
||||||
<form>
|
<form>
|
||||||
<p>Requesting Fear roll from ${tokens.map((t) => t.name).join(', ')}.</p>
|
<p>Requesting Fear roll from ${tokens.map((t) => t.name).join(', ')}.</p>
|
||||||
@ -21,19 +21,21 @@ async function main() {
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</form>`,
|
</form>`,
|
||||||
buttons: {
|
buttons: [
|
||||||
ok: {
|
{
|
||||||
|
action: "submit",
|
||||||
label: 'Request Roll',
|
label: 'Request Roll',
|
||||||
callback: (html) => {
|
callback: (event, button, dialog) => {
|
||||||
const fear = parseInt(html.find('input[name="fear"]').val()) || 0;
|
formdata = new foundry.applications.ux.FormDataExtended(button.form).object
|
||||||
|
const fear = parseInt(formdata.fear) || 0;
|
||||||
const options = { targetNumber: 4, fear };
|
const options = { targetNumber: 4, fear };
|
||||||
requestFearRollFromTokens(tokens, options);
|
requestFearRollFromTokens(tokens, options);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
cancel: {
|
{
|
||||||
label: 'Cancel',
|
action: "cancel", label: 'Cancel',
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
],
|
||||||
}).render(true);
|
}).render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -60,12 +60,14 @@ async function main() {
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
`;
|
`;
|
||||||
const buttons = {
|
const buttons = [
|
||||||
ok: {
|
{
|
||||||
|
action: "submit",
|
||||||
label: 'Request Roll',
|
label: 'Request Roll',
|
||||||
callback: (html) => {
|
callback: (event, button, dialog) => {
|
||||||
const form = html[0].querySelector('form');
|
const form = button.form;
|
||||||
const formDataObject = new FormDataExtended(form).object;
|
const formDataObject = new foundry.applications.ux.FormDataExtended(form).object;
|
||||||
|
console.log(formDataObject);
|
||||||
const rollMod = parseInt(formDataObject.mod);
|
const rollMod = parseInt(formDataObject.mod);
|
||||||
const rollModDesc = formDataObject.modDesc;
|
const rollModDesc = formDataObject.modDesc;
|
||||||
const rollParts = formDataObject.trait.split('|');
|
const rollParts = formDataObject.trait.split('|');
|
||||||
@ -79,12 +81,12 @@ async function main() {
|
|||||||
requestRollFromTokens(tokens, rollType, rollDesc, options);
|
requestRollFromTokens(tokens, rollType, rollDesc, options);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
cancel: {
|
{
|
||||||
label: 'Cancel',
|
action: "cancel", label: 'Cancel',
|
||||||
},
|
},
|
||||||
};
|
];
|
||||||
new Dialog({
|
new foundry.applications.api.DialogV2({
|
||||||
title: 'Request roll',
|
window { title: 'Request roll' },
|
||||||
content,
|
content,
|
||||||
buttons,
|
buttons,
|
||||||
}).render(true);
|
}).render(true);
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
/* globals args */
|
|
||||||
const argBright = typeof args === 'undefined' ? null : args.length > 0 ? args[0] : null;
|
const argBright = typeof args === 'undefined' ? null : args.length > 0 ? args[0] : null;
|
||||||
// argument can be one of 'bright', 'dim', 'dark', 'pitchdark'. Other values
|
// argument can be one of 'bright', 'dim', 'dark', 'pitchdark'. Other values
|
||||||
// will guess based on scene darkness
|
// will guess based on scene darkness
|
||||||
@ -73,8 +72,8 @@ async function main() {
|
|||||||
bright = argBright;
|
bright = argBright;
|
||||||
}
|
}
|
||||||
|
|
||||||
new Dialog({
|
new foundry.applications.api.DialogV2({
|
||||||
title: 'Select scene brightness',
|
window: { title: 'Select scene brightness' },
|
||||||
content: `
|
content: `
|
||||||
<form>
|
<form>
|
||||||
<h2>Set token vision</h2>
|
<h2>Set token vision</h2>
|
||||||
@ -109,14 +108,16 @@ async function main() {
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
`,
|
`,
|
||||||
buttons: {
|
buttons: [
|
||||||
ok: {
|
{
|
||||||
|
action: "submit",
|
||||||
label: 'Select scene Brightness',
|
label: 'Select scene Brightness',
|
||||||
value: 'ok',
|
value: 'ok',
|
||||||
callback: (html) => {
|
callback: (event, button, dialog) => {
|
||||||
const form = html[0].querySelector('form');
|
const form = button.form;
|
||||||
const formDataObject = new FormDataExtended(form).Object;
|
const formDataObject = new foundry.applications.ux.FormDataExtended(form).object;
|
||||||
console.log('form data', formDataObject, form);
|
console.log('form data', formDataObject, form);
|
||||||
|
|
||||||
bright = formDataObject.bright;
|
bright = formDataObject.bright;
|
||||||
for (const tokenId of scene.tokens.map((t) => t.id)) {
|
for (const tokenId of scene.tokens.map((t) => t.id)) {
|
||||||
const token = scene.tokens.get(tokenId);
|
const token = scene.tokens.get(tokenId);
|
||||||
@ -147,10 +148,8 @@ async function main() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
cancel: {
|
{ action: "cancel", label: 'Cancel' },
|
||||||
label: 'Cancel',
|
],
|
||||||
},
|
|
||||||
},
|
|
||||||
}).render(true);
|
}).render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
2025/05/28-21:41:56.707066 7ce44d7be640 Delete type=3 #1
|
2025/05/28-22:37:46.855626 7bc6857bc640 Delete type=3 #1
|
||||||
2025/05/28-21:41:56.709675 7ce44bfbb640 Level-0 table #5: started
|
2025/05/28-22:37:46.857913 7bc684fbb640 Level-0 table #5: started
|
||||||
2025/05/28-21:41:56.712231 7ce44bfbb640 Level-0 table #5: 19401 bytes OK
|
2025/05/28-22:37:46.860494 7bc684fbb640 Level-0 table #5: 19401 bytes OK
|
||||||
2025/05/28-21:41:56.714241 7ce44bfbb640 Delete type=0 #3
|
2025/05/28-22:37:46.862582 7bc684fbb640 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.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-22:37:46.975797 7364abfff640 Delete type=3 #1
|
||||||
2025/05/28-21:41:56.842145 7912d7fbb640 Level-0 table #5: started
|
2025/05/28-22:37:46.978271 7364a9bff640 Level-0 table #5: started
|
||||||
2025/05/28-21:41:56.844320 7912d7fbb640 Level-0 table #5: 6870 bytes OK
|
2025/05/28-22:37:46.980551 7364a9bff640 Level-0 table #5: 6870 bytes OK
|
||||||
2025/05/28-21:41:56.846291 7912d7fbb640 Delete type=0 #3
|
2025/05/28-22:37:46.982643 7364a9bff640 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.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-22:37:47.109584 77100d5fa640 Delete type=3 #1
|
||||||
2025/05/28-21:41:56.988479 7f67fdbff640 Level-0 table #5: started
|
2025/05/28-22:37:47.111689 770fe6ffd640 Level-0 table #5: started
|
||||||
2025/05/28-21:41:56.990440 7f67fdbff640 Level-0 table #5: 2017 bytes OK
|
2025/05/28-22:37:47.113682 770fe6ffd640 Level-0 table #5: 2017 bytes OK
|
||||||
2025/05/28-21:41:56.992375 7f67fdbff640 Delete type=0 #3
|
2025/05/28-22:37:47.115738 770fe6ffd640 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.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-22:37:47.223706 722ad5fbe640 Delete type=3 #1
|
||||||
2025/05/28-21:41:57.103563 7d718ffff640 Level-0 table #5: started
|
2025/05/28-22:37:47.226010 722ab7fff640 Level-0 table #5: started
|
||||||
2025/05/28-21:41:57.105990 7d718ffff640 Level-0 table #5: 21473 bytes OK
|
2025/05/28-22:37:47.228570 722ab7fff640 Level-0 table #5: 16824 bytes OK
|
||||||
2025/05/28-21:41:57.108035 7d718ffff640 Delete type=0 #3
|
2025/05/28-22:37:47.230659 722ab7fff640 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.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-22:37:47.371068 75e9a17bd640 Delete type=3 #1
|
||||||
2025/05/28-21:41:57.217780 7be096ffd640 Level-0 table #5: started
|
2025/05/28-22:37:47.373331 75e983fff640 Level-0 table #5: started
|
||||||
2025/05/28-21:41:57.220087 7be096ffd640 Level-0 table #5: 22029 bytes OK
|
2025/05/28-22:37:47.375656 75e983fff640 Level-0 table #5: 22029 bytes OK
|
||||||
2025/05/28-21:41:57.222061 7be096ffd640 Delete type=0 #3
|
2025/05/28-22:37:47.377626 75e983fff640 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.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