Compare commits
2 commits
0df05e0d0b
...
642d74c9f8
| Author | SHA1 | Date | |
|---|---|---|---|
| 642d74c9f8 | |||
| 43c630c1f7 |
4 changed files with 67 additions and 71 deletions
|
|
@ -2,11 +2,11 @@
|
|||
"id": "seitime-bridge",
|
||||
"title": "Seitime Bridge",
|
||||
"description": "Pushes dnd5e character data from Foundry VTT to a Seitime Frappe site at session end. Companion to the st Frappe app.",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"compatibility": {
|
||||
"minimum": "12",
|
||||
"verified": "12",
|
||||
"maximum": "13"
|
||||
"verified": "13",
|
||||
"maximum": "14"
|
||||
},
|
||||
"authors": [
|
||||
{ "name": "Vassili" }
|
||||
|
|
|
|||
|
|
@ -101,45 +101,44 @@ async function showAttendanceDialog(proposal) {
|
|||
})
|
||||
.join("");
|
||||
|
||||
return new Promise((resolve) => {
|
||||
new Dialog(
|
||||
const result = await foundry.applications.api.DialogV2.wait({
|
||||
window: { title: "Finalize Attendance" },
|
||||
content: `
|
||||
<p>Confirm each player's attendance for this session.</p>
|
||||
<table style="width:100%; border-collapse:collapse;">
|
||||
<thead>
|
||||
<tr style="border-bottom:1px solid #ccc;">
|
||||
<th style="text-align:left; padding:0.25em;">Player</th>
|
||||
<th style="text-align:left; padding:0.25em;">Character(s)</th>
|
||||
<th style="text-align:left; padding:0.25em; width:9em;">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>${rows}</tbody>
|
||||
</table>
|
||||
`,
|
||||
buttons: [
|
||||
{ action: "cancel", label: "Cancel", callback: () => null },
|
||||
{
|
||||
title: "Finalize Attendance",
|
||||
content: `
|
||||
<p>Confirm each player's attendance for this session.</p>
|
||||
<table style="width:100%; border-collapse:collapse;">
|
||||
<thead>
|
||||
<tr style="border-bottom:1px solid #ccc;">
|
||||
<th style="text-align:left; padding:0.25em;">Player</th>
|
||||
<th style="text-align:left; padding:0.25em;">Character(s)</th>
|
||||
<th style="text-align:left; padding:0.25em; width:9em;">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>${rows}</tbody>
|
||||
</table>
|
||||
`,
|
||||
buttons: {
|
||||
cancel: { label: "Cancel", callback: () => resolve(null) },
|
||||
confirm: {
|
||||
label: "Confirm",
|
||||
callback: (html) => {
|
||||
const result = [];
|
||||
html.find("select[data-player]").each(function () {
|
||||
result.push({
|
||||
player: $(this).data("player"),
|
||||
status: $(this).val(),
|
||||
});
|
||||
});
|
||||
resolve(result);
|
||||
},
|
||||
},
|
||||
action: "confirm",
|
||||
label: "Confirm",
|
||||
default: true,
|
||||
callback: (_event, _button, dialog) => {
|
||||
const out = [];
|
||||
dialog.element.querySelectorAll("select[data-player]").forEach((select) => {
|
||||
out.push({
|
||||
player: select.dataset.player,
|
||||
status: select.value,
|
||||
});
|
||||
});
|
||||
return out;
|
||||
},
|
||||
default: "confirm",
|
||||
close: () => resolve(null),
|
||||
},
|
||||
{ width: 560 },
|
||||
).render(true);
|
||||
],
|
||||
position: { width: 560 },
|
||||
rejectClose: false,
|
||||
});
|
||||
|
||||
return result ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -167,15 +166,14 @@ export async function pushAllSnapshots() {
|
|||
async function pickSession(sessions) {
|
||||
if (sessions.length === 1) {
|
||||
const s = sessions[0];
|
||||
const confirmed = await Dialog.confirm({
|
||||
title: "End Session",
|
||||
const confirmed = await foundry.applications.api.DialogV2.confirm({
|
||||
window: { title: "End Session" },
|
||||
content: `
|
||||
<p>End <b>${escapeHtml(s.session_title)}</b>?</p>
|
||||
<p>This will mark it Completed, schedule the next session, and push snapshots for all PCs.</p>
|
||||
`,
|
||||
yes: () => true,
|
||||
no: () => false,
|
||||
defaultYes: true,
|
||||
yes: { default: true },
|
||||
rejectClose: false,
|
||||
});
|
||||
return confirmed ? s.session_id : null;
|
||||
}
|
||||
|
|
@ -187,29 +185,27 @@ async function pickSession(sessions) {
|
|||
)
|
||||
.join("");
|
||||
|
||||
return new Promise((resolve) => {
|
||||
new Dialog({
|
||||
title: "End Session",
|
||||
content: `
|
||||
<p>Multiple scheduled sessions match this Foundry world. Pick one to end:</p>
|
||||
<select id="seitime-session-pick" style="width:100%; margin-bottom:0.5em;">
|
||||
${options}
|
||||
</select>
|
||||
`,
|
||||
buttons: {
|
||||
cancel: { label: "Cancel", callback: () => resolve(null) },
|
||||
end: {
|
||||
label: "End Session",
|
||||
callback: (html) => {
|
||||
const value = html.find("#seitime-session-pick").val();
|
||||
resolve(value || null);
|
||||
},
|
||||
},
|
||||
const value = await foundry.applications.api.DialogV2.wait({
|
||||
window: { title: "End Session" },
|
||||
content: `
|
||||
<p>Multiple scheduled sessions match this Foundry world. Pick one to end:</p>
|
||||
<select id="seitime-session-pick" style="width:100%; margin-bottom:0.5em;">
|
||||
${options}
|
||||
</select>
|
||||
`,
|
||||
buttons: [
|
||||
{ action: "cancel", label: "Cancel", callback: () => null },
|
||||
{
|
||||
action: "end",
|
||||
label: "End Session",
|
||||
default: true,
|
||||
callback: (_event, _button, dialog) =>
|
||||
dialog.element.querySelector("#seitime-session-pick")?.value || null,
|
||||
},
|
||||
default: "end",
|
||||
close: () => resolve(null),
|
||||
}).render(true);
|
||||
],
|
||||
rejectClose: false,
|
||||
});
|
||||
return value ?? null;
|
||||
}
|
||||
|
||||
function summarizeAttendance(attendance) {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ function scheduleSnapshotPush(actor) {
|
|||
|
||||
let debouncer = snapshotDebouncers.get(actor.id);
|
||||
if (!debouncer) {
|
||||
const debounceMs = game.settings.get(MODULE_ID, "snapshotDebounceMs");
|
||||
const debounceMs = game.settings.get(MODULE_ID, "snapshotDebounceSeconds") * 1000;
|
||||
debouncer = foundry.utils.debounce((a) => {
|
||||
pushSnapshot(a).catch((err) => {
|
||||
console.warn(`[${MODULE_ID}] snapshot push for ${a.name} failed:`, err);
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ import { MODULE_ID } from "./constants.js";
|
|||
export function registerSettings() {
|
||||
game.settings.register(MODULE_ID, "frappeBaseUrl", {
|
||||
name: "Frappe Base URL",
|
||||
hint: "Base URL of your Seitime Frappe site, e.g. https://seitime.vassi.li (no trailing slash).",
|
||||
hint: "Base URL of your Seitime Frappe site, e.g. https://seitimegames.com (no trailing slash).",
|
||||
scope: "world",
|
||||
config: true,
|
||||
type: String,
|
||||
default: "",
|
||||
default: "https://seitimegames.com",
|
||||
});
|
||||
|
||||
game.settings.register(MODULE_ID, "sharedSecret", {
|
||||
|
|
@ -50,14 +50,14 @@ export function registerSettings() {
|
|||
range: { min: 0, max: 120, step: 1 },
|
||||
});
|
||||
|
||||
game.settings.register(MODULE_ID, "snapshotDebounceMs", {
|
||||
name: "Snapshot Debounce (ms)",
|
||||
game.settings.register(MODULE_ID, "snapshotDebounceSeconds", {
|
||||
name: "Snapshot Debounce (seconds)",
|
||||
hint: "How long to wait after the last actor edit before pushing a snapshot. Combat causes frequent edits, so a few seconds is usually right.",
|
||||
scope: "world",
|
||||
config: true,
|
||||
type: Number,
|
||||
default: 5000,
|
||||
range: { min: 500, max: 60000, step: 500 },
|
||||
default: 5,
|
||||
range: { min: 1, max: 60, step: 1 },
|
||||
});
|
||||
|
||||
game.settings.register(MODULE_ID, "snapshotAutoSync", {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue