Skip to content

Commit af05de5

Browse files
committed
new starting message system
1 parent 953901f commit af05de5

4 files changed

Lines changed: 318 additions & 30 deletions

File tree

scripts/apps/setup-warning.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { MODULE_ID } from "../config.js";
2+
3+
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
4+
5+
export class SetupWarningDialog extends HandlebarsApplicationMixin(ApplicationV2) {
6+
static DEFAULT_OPTIONS = {
7+
id: "ib-setup-warning",
8+
tag: "div",
9+
classes: ["ib-setup-warning-app"],
10+
window: {
11+
title: "Investigation Board: Setup Recommended",
12+
resizable: false,
13+
minimizable: false,
14+
},
15+
position: {
16+
width: 500,
17+
height: "auto"
18+
}
19+
};
20+
21+
static PARTS = {
22+
content: {
23+
template: "modules/investigation-board/templates/setup-warning.html"
24+
}
25+
};
26+
27+
async _prepareContext(options) {
28+
const users = game.users.filter(u => !u.isGM);
29+
const playerRoles = [...new Set(users.map(u => u.role))];
30+
if (playerRoles.length === 0) playerRoles.push(1);
31+
32+
const drawingPerm = playerRoles.every(role => game.permissions.DRAWING_CREATE.includes(role));
33+
const browsePerm = playerRoles.every(role => game.permissions.FILES_BROWSE.includes(role));
34+
const uploadPerm = playerRoles.every(role => game.permissions.FILES_UPLOAD.includes(role));
35+
36+
const roleNames = {
37+
1: "Player",
38+
2: "Trusted Player",
39+
3: "Assistant GM"
40+
};
41+
42+
const missingUsers = users.map(u => {
43+
const canDraw = game.permissions.DRAWING_CREATE.includes(u.role);
44+
const canBrowse = game.permissions.FILES_BROWSE.includes(u.role);
45+
const canUpload = game.permissions.FILES_UPLOAD.includes(u.role);
46+
47+
return {
48+
name: u.name,
49+
roleName: roleNames[u.role] || "Unknown",
50+
canDraw,
51+
canBrowse,
52+
canUpload
53+
};
54+
});
55+
56+
return {
57+
drawingPerm,
58+
browsePerm,
59+
uploadPerm,
60+
missingUsers
61+
};
62+
}
63+
64+
_onRender(context, options) {
65+
const html = this.element;
66+
67+
html.querySelector('[data-action="ok"]')?.addEventListener("click", () => {
68+
this.close();
69+
});
70+
71+
html.querySelector('[data-action="disable"]')?.addEventListener("click", async () => {
72+
await game.settings.set(MODULE_ID, "showSetupWarning", false);
73+
this.close();
74+
});
75+
}
76+
}

scripts/main.js

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
clearConnectionPreview
1212
} from "./canvas/connection-manager.js";
1313
import { initSocket, socket, collaborativeUpdate } from "./utils/socket-handler.js";
14+
import { SetupWarningDialog } from "./apps/setup-warning.js";
1415
import {
1516
createNote,
1617
createPhotoNoteFromActor,
@@ -255,36 +256,16 @@ Hooks.once("ready", () => {
255256

256257
// Show setup warning to GM if enabled
257258
if (game.user.isGM && game.settings.get(MODULE_ID, "showSetupWarning")) {
258-
const drawingPerm = game.permissions.DRAWING_CREATE.includes(1); // PLAYER role
259-
const filePerm = game.permissions.FILES_BROWSE.includes(1); // PLAYER role
259+
const users = game.users.filter(u => !u.isGM);
260+
const playerRoles = [...new Set(users.map(u => u.role))];
261+
if (playerRoles.length === 0) playerRoles.push(1);
262+
263+
const drawingPerm = playerRoles.every(role => game.permissions.DRAWING_CREATE.includes(role));
264+
const browsePerm = playerRoles.every(role => game.permissions.FILES_BROWSE.includes(role));
265+
const uploadPerm = playerRoles.every(role => game.permissions.FILES_UPLOAD.includes(role));
260266

261-
if (!drawingPerm || !filePerm) {
262-
const { DialogV2 } = foundry.applications.api;
263-
new DialogV2({
264-
window: { title: "Investigation Board: Setup Recommended" },
265-
content: `
266-
<p>To allow <strong>Players</strong> to fully use the Investigation Board, consider updating these World Permissions in <b>Game Settings >> User Management >> Configure Permissions</b>:</p>
267-
<ul>
268-
<li><strong>Use Drawing Tools</strong>: ${drawingPerm ? "✅ Enabled" : "❌ Disabled (Needed to create/manipulate notes and connections)"}</li>
269-
<li><strong>Upload Files</strong>: ${filePerm ? "✅ Enabled" : "❌ Disabled (Needed to create Photo and Handout notes with images)"}</li>
270-
</ul>
271-
<p style="color: #882222; font-style: italic;"><strong>Security Note:</strong> Enabling 'Upload Files' for players gives them access to your server's file system through the File Picker. Be careful with who you let access your files!</p>
272-
<hr>
273-
`,
274-
buttons: [
275-
{
276-
action: "ok",
277-
label: "Understood",
278-
icon: "fas fa-check"
279-
},
280-
{
281-
action: "disable",
282-
label: "Don't show again",
283-
icon: "fas fa-times",
284-
callback: (event, button, dialog) => game.settings.set(MODULE_ID, "showSetupWarning", false)
285-
}
286-
]
287-
}).render(true);
267+
if (!drawingPerm || !browsePerm || !uploadPerm) {
268+
new SetupWarningDialog().render(true);
288269
}
289270
}
290271
});

styles/style.css

Lines changed: 163 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,5 +957,167 @@ body.investigation-board-mode .drawing:not([data-investigation-note="true"]) {
957957
.preview-text-container.courier-new { font-family: 'Courier New', monospace; }
958958
.preview-text-container.times-new-roman { font-family: 'Times New Roman', serif; }
959959
.preview-text-container.signika { font-family: 'Signika', sans-serif; }
960-
.preview-text-container.arial { font-family: 'Arial', sans-serif; }
960+
/* ========================= */
961+
/* Setup Warning Dialog */
962+
/* ========================= */
963+
964+
.ib-setup-warning {
965+
padding: 10px;
966+
font-family: "Signika", sans-serif;
967+
}
968+
969+
.permissions-summary {
970+
display: flex;
971+
flex-direction: column;
972+
gap: 8px;
973+
margin: 15px 0;
974+
padding: 10px;
975+
background: rgba(0, 0, 0, 0.05);
976+
border-radius: 4px;
977+
}
978+
979+
.theme-dark .permissions-summary {
980+
background: rgba(255, 255, 255, 0.05);
981+
}
982+
983+
.permission-item {
984+
display: flex;
985+
align-items: center;
986+
gap: 10px;
987+
font-size: 14px;
988+
}
989+
990+
.permission-item.enabled { color: #2e7d32; }
991+
.theme-dark .permission-item.enabled { color: #81c784; }
992+
.permission-item.disabled { color: #d32f2f; }
993+
.theme-dark .permission-item.disabled { color: #e57373; }
994+
995+
.permission-explanation {
996+
background: rgba(46, 125, 50, 0.1);
997+
border-left: 4px solid #2e7d32;
998+
padding: 10px;
999+
font-size: 13px;
1000+
margin: 10px 0;
1001+
color: #1b5e20;
1002+
}
1003+
1004+
.theme-dark .permission-explanation {
1005+
background: rgba(129, 199, 132, 0.1);
1006+
border-left-color: #81c784;
1007+
color: #c8e6c9;
1008+
}
1009+
1010+
.user-permissions-table-container {
1011+
max-height: 250px;
1012+
overflow-y: auto;
1013+
margin: 10px 0;
1014+
border: 1px solid rgba(0, 0, 0, 0.1);
1015+
border-radius: 4px;
1016+
}
1017+
1018+
.ib-permissions-table {
1019+
width: 100%;
1020+
border-collapse: collapse;
1021+
font-size: 13px;
1022+
background: rgba(255, 255, 255, 0.8);
1023+
color: #222;
1024+
}
1025+
1026+
.theme-dark .ib-permissions-table {
1027+
background: rgba(0, 0, 0, 0.2);
1028+
color: #f0f0e0;
1029+
}
1030+
1031+
.ib-permissions-table th {
1032+
background: rgba(0, 0, 0, 0.05);
1033+
padding: 8px;
1034+
text-align: left;
1035+
border-bottom: 2px solid rgba(0, 0, 0, 0.1);
1036+
position: sticky;
1037+
top: 0;
1038+
z-index: 1;
1039+
}
1040+
1041+
.theme-dark .ib-permissions-table th {
1042+
background: rgba(255, 255, 255, 0.1);
1043+
border-bottom-color: rgba(255, 255, 255, 0.2);
1044+
}
1045+
1046+
.ib-permissions-table td {
1047+
padding: 8px;
1048+
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
1049+
}
1050+
1051+
.theme-dark .ib-permissions-table td {
1052+
border-bottom-color: rgba(255, 255, 255, 0.05);
1053+
}
1054+
1055+
.ib-permissions-table tr:hover {
1056+
background: rgba(0, 0, 0, 0.02);
1057+
}
1058+
1059+
.theme-dark .ib-permissions-table tr:hover {
1060+
background: rgba(255, 255, 255, 0.02);
1061+
}
1062+
1063+
.text-center {
1064+
text-align: center !important;
1065+
}
1066+
1067+
.missing-list {
1068+
margin: 4px 0 0 15px;
1069+
padding: 0;
1070+
font-size: 13px;
1071+
color: #d32f2f;
1072+
}
1073+
1074+
.security-note {
1075+
font-size: 12px;
1076+
font-style: italic;
1077+
margin-top: 15px;
1078+
padding: 8px;
1079+
background: #fff8e1;
1080+
border-left: 4px solid #ffc107;
1081+
color: #5d4037;
1082+
}
1083+
1084+
.theme-dark .security-note {
1085+
background: rgba(255, 193, 7, 0.05);
1086+
border-left-color: #ffc107;
1087+
color: #ffe082;
1088+
}
1089+
1090+
.ib-dialog-buttons {
1091+
display: flex;
1092+
gap: 10px;
1093+
margin-top: 20px;
1094+
}
1095+
1096+
.ib-btn {
1097+
flex: 1;
1098+
padding: 8px;
1099+
border: none;
1100+
border-radius: 4px;
1101+
cursor: pointer;
1102+
font-weight: bold;
1103+
display: flex;
1104+
align-items: center;
1105+
justify-content: center;
1106+
gap: 8px;
1107+
transition: filter 0.2s;
1108+
}
1109+
1110+
.ib-btn.ok {
1111+
background: #3f51b5;
1112+
color: white;
1113+
}
1114+
1115+
.ib-btn.disable {
1116+
background: #757575;
1117+
color: white;
1118+
}
1119+
1120+
.ib-btn:hover {
1121+
filter: brightness(1.1);
1122+
}
9611123

templates/setup-warning.html

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<div class="ib-setup-warning">
2+
<p>To allow <strong>all players</strong> to fully use the Investigation Board, consider updating World Permissions in <b>Game Settings >> User Management >> Configure Permissions</b>.</p>
3+
4+
<div class="permissions-summary">
5+
<div class="permission-item {{#if drawingPerm}}enabled{{else}}disabled{{/if}}">
6+
<i class="fas {{#if drawingPerm}}fa-check-circle{{else}}fa-exclamation-triangle{{/if}}"></i>
7+
<span><strong>Use Drawing Tools</strong> (Needed to create notes/connections)</span>
8+
</div>
9+
<div class="permission-item {{#if browsePerm}}enabled{{else}}disabled{{/if}}">
10+
<i class="fas {{#if browsePerm}}fa-check-circle{{else}}fa-exclamation-triangle{{/if}}"></i>
11+
<span><strong>Browse Files</strong> (Needed to select assets)</span>
12+
</div>
13+
<div class="permission-item {{#if uploadPerm}}enabled{{else}}disabled{{/if}}">
14+
<i class="fas {{#if uploadPerm}}fa-check-circle{{else}}fa-exclamation-triangle{{/if}}"></i>
15+
<span><strong>Upload Files</strong> (Needed to upload assets)</span>
16+
</div>
17+
</div>
18+
19+
<p class="permission-explanation">
20+
<i class="fas fa-info-circle"></i>
21+
To allow players to <strong>move, edit, and connect</strong> notes, you only need to enable <strong>Use Drawing Tools</strong>. This permission is harmless as it only affects canvas drawings and does not grant access to your server files.
22+
</p>
23+
24+
<hr>
25+
26+
<h3>Users with Missing Permissions:</h3>
27+
<div class="user-permissions-table-container">
28+
<table class="ib-permissions-table">
29+
<thead>
30+
<tr>
31+
<th>User</th>
32+
<th>Role</th>
33+
<th class="text-center">Draw</th>
34+
<th class="text-center">Browse</th>
35+
<th class="text-center">Upload</th>
36+
</tr>
37+
</thead>
38+
<tbody>
39+
{{#each missingUsers}}
40+
<tr>
41+
<td>{{this.name}}</td>
42+
<td><small>{{this.roleName}}</small></td>
43+
<td class="text-center">{{#if this.canDraw}}✅{{else}}❌{{/if}}</td>
44+
<td class="text-center">{{#if this.canBrowse}}✅{{else}}❌{{/if}}</td>
45+
<td class="text-center">{{#if this.canUpload}}✅{{else}}❌{{/if}}</td>
46+
</tr>
47+
{{else}}
48+
<tr>
49+
<td colspan="5" class="text-center">No active players missing permissions.</td>
50+
</tr>
51+
{{/each}}
52+
</tbody>
53+
</table>
54+
</div>
55+
56+
<p class="security-note">
57+
<i class="fas fa-user-shield"></i>
58+
<strong>Security Note:</strong> Enabling file permissions gives players access to your server's file system through the File Picker.
59+
</p>
60+
61+
<div class="ib-dialog-buttons">
62+
<button type="button" class="ib-btn ok" data-action="ok">
63+
<i class="fas fa-check"></i> Understood
64+
</button>
65+
<button type="button" class="ib-btn disable" data-action="disable">
66+
<i class="fas fa-times"></i> Don't show again
67+
</button>
68+
</div>
69+
</div>

0 commit comments

Comments
 (0)