Repository navigation
Expand file tree
/
Copy pathfate.js
More file actions
688 lines (625 loc) · 25.8 KB
/
Copy pathfate.js
File metadata and controls
688 lines (625 loc) · 25.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
Hooks.once('init', function() {
game.settings.registerMenu("fateroll", "fateroll", {
name: "Roll of Fate Customizer",
label: "Roll of Fate Customizer",
hint: "Roll of Fate Customizer",
icon: "fas fa-dice-d20",
type: ROFConfig,
restricted: true
});
game.settings.register('fateroll', 'displayselected', {
name: 'Display selected players',
hint: 'Enable this to also post the selected players into the chat',
scope: 'world',
config: true,
default: false,
type: Boolean,
});
game.settings.register('fateroll', 'onlyplayers', {
name: 'Only Players',
hint: 'Ignore NPCs',
scope: 'world',
config: true,
default: false,
type: Boolean,
});
game.settings.register('fateroll', 'usePlayerColorGradient', {
name: 'Use Player Color Gradient',
hint: 'If the selected token is owned by a player, use their user color as background gradient (color → black).',
scope: 'world',
config: true,
default: false,
type: Boolean,
});
game.settings.register('fateroll', 'disableMessageHeader', {
name: 'Disable Message Header',
hint: 'Hides the header (name, time, options button) for fate messages in chat.',
scope: 'world',
config: true,
default: true,
type: Boolean,
});
game.settings.register('fateroll', 'boolDisableTitle', {
name: 'Disable Title',
hint: 'Disables the title of the chat card.',
scope: 'world',
config: true,
default: false,
type: Boolean,
});
game.settings.register('fateroll', 'ROFCardHeaderGlow', {
name: 'ROFCardHeaderGlow',
hint: 'Header Glow',
scope: 'world',
config: false,
default: false,
type: Boolean,
});
game.settings.register('fateroll', 'ROFCardTextGlow', {
name: 'ROFCardTextGlow',
hint: 'Text Glow',
scope: 'world',
config: false,
default: false,
type: Boolean,
});
game.settings.register('fateroll', 'fatetext', {
name: 'Title',
hint: 'This is the text that is displayed above the chosen players name (you can define multiple titles if you seperate them with a ; )',
scope: 'world',
config: false,
default: 'Roll of Fate;Fate has been Decided',
type: String,
});
game.settings.register('fateroll', 'prefix', {
name: 'Prefix',
hint: 'This is what is inserted into the chat-message just BEFORE the players name (you can define multiple prefixes if you seperate them with a ; )',
scope: 'world',
config: false,
default: '',
type: String,
});
game.settings.register('fateroll', 'suffix', {
name: 'Suffix',
hint: 'This is what is inserted into the chat-message just AFTER the players name (you can define multiple suffixes if you seperate them with a ; )',
scope: 'world',
config: false,
default: '...you are the lucky one;...you are chosen;is endorsed by Tymora',
type: String,
});
game.settings.register('fateroll', 'titlecolor', {
name: 'Title-Color',
hint: 'You can change the title-color of the chat-message. You can use color-names or hex codes.',
scope: 'world',
config: false,
default: '#ffea00',
type: String,
});
game.settings.register('fateroll', 'textcolor', {
name: 'Text-Color',
hint: 'You can change the text-color of the chat-message. You can use color-names or hex codes.',
scope: 'world',
config: false,
default: 'white',
type: String,
});
game.settings.register('fateroll', 'backgroundcolor', {
name: 'Background-Color',
hint: 'You can change the background-color of the chat-message. You can use color-names or hex codes.',
scope: 'world',
config: false,
default: 'black',
type: String,
});
game.settings.register('fateroll', 'backgroundimg', {
name: 'Background Image',
hint: 'You can change the background image of the chat message. THIS WILL OVERWRITE THE BACKGROUND COLOR',
scope: 'world',
config: true,
default: 'modules/fateroll/images/FateStrings.webp',
type: String,
filePicker: true
});
game.settings.register('fateroll', 'backgroundimg2', {
name: 'Background Image - 2',
hint: 'If more than 1 background is used the module will choose a background randomly.',
scope: 'world',
config: true,
default: 'modules/fateroll/images/FateTower.webp',
type: String,
filePicker: true
});
game.settings.register('fateroll', 'backgroundimg3', {
name: 'Background Image - 3',
hint: 'If more than 1 background is used the module will choose a background randomly.',
scope: 'world',
config: true,
default: 'modules/fateroll/images/Galaxy.webp',
type: String,
filePicker: true
});
game.settings.register('fateroll', 'backgroundimg4', {
name: 'Background Image - 4',
hint: 'If more than 1 background is used the module will choose a background randomly.',
scope: 'world',
config: true,
default: '',
type: String,
filePicker: true
});
game.settings.register('fateroll', 'backgroundimg5', {
name: 'Background Image - 5',
hint: 'If more than 1 background is used the module will choose a background randomly.',
scope: 'world',
config: true,
default: '',
type: String,
filePicker: true
});
game.settings.register('fateroll', 'backgroundstyle', {
name: 'Background Style',
hint: 'Choose a Style for your background',
scope: 'world',
config: false,
default: 'cover',
type: String,
});
game.settings.register('fateroll', 'soundpath', {
name: 'Custom Sound',
hint: 'You can change the background-image of the chat-message. Put in an url or a path that ends with .wav / .mp3',
scope: 'world',
config: true,
default: 'sounds/dice.wav',
type: String,
filePicker: true
});
game.settings.register('fateroll', 'hidebutton', {
name: 'Hide-Button for non-GMs',
hint: 'Check this if you dont want your players to see the button',
scope: 'world',
config: true,
default: true,
type: Boolean,
});
game.settings.register('fateroll', 'dropshadow', {
name: 'Dropshadow',
hint: 'Check this if you want to enable the drop shadow',
scope: 'world',
config: false,
default: true,
type: Boolean,
});
game.settings.register('fateroll', 'titleBlend', {
name: 'titleBlend',
hint: 'blending of the title is saved here',
scope: 'world',
config: false,
default: 'hard-light',
type: String,
});
game.settings.register('fateroll', 'titleBackStyle', {
name: 'titleBackStyle',
hint: 'titleBackStyle is saved here',
scope: 'world',
config: false,
default: 'Dark',
type: String,
});
game.settings.register('fateroll', 'titleBackFilter', {
name: 'titleBackFilter',
hint: 'titleBackFilter is saved here',
scope: 'world',
config: false,
default: 'Darkness (Strong)',
type: String,
});
game.settings.register('fateroll', 'textBlend', {
name: 'textBlend',
hint: 'blending of the text is saved here',
scope: 'world',
config: false,
default: 'hard-light',
type: String,
});
game.settings.register('fateroll', 'textBackStyle', {
name: 'textBackStyle',
hint: 'textBackStyle is saved here',
scope: 'world',
config: false,
default: 'Dark',
type: String,
});
game.settings.register('fateroll', 'textBackFilter', {
name: 'textBackFilter',
hint: 'textBackFilter is saved here',
scope: 'world',
config: false,
default: 'Darkness (Strong)',
type: String,
});
game.settings.register('fateroll', 'useSequencerEffects', {
name: 'Use Sequencer Effects',
hint: 'Plays a visual effect on the selected token if Sequencer is installed.',
scope: 'world',
config: true,
default: false,
type: Boolean
});
console.log("Initialised Roll-Of-Fate-Module");
});
Hooks.on("renderChatMessage", (message, html, data) => {
if (!game.modules.get("sequencer")?.active) return;
// Player Color Gradient + Sequencer Glow
if (game.settings.get('fateroll', 'usePlayerColorGradient')) {
const div = html[0].querySelector('.roll-of-fate');
const msgEl = html[0].closest('.message');
const tokenId = div?.querySelector('.rof-token-link')?.dataset?.tokenId;
const token = canvas.tokens.get(tokenId);
const actor = token?.actor;
if (actor) {
const user = game.users.find(u => u.character?.id === actor.id && u.active);
if (user && msgEl) {
const color = user.color || "#ffaa00";
msgEl.style.setProperty('--rof-user-color', color);
msgEl.style.setProperty("background", `linear-gradient(90deg, ${color}, black)`);
if (typeof Sequencer !== "undefined" && token) {
new Sequence()
.effect()
.atLocation(token)
.attachTo(token)
.persist()
.name("fateroll-glow")
.filter("Glow", {
color,
distance: 10,
outerStrength: 5,
innerStrength: 0,
quality: 0.5
})
.scaleIn(0, 500, { ease: "easeOutCubic" })
.fadeOut(500)
.duration(2000)
.play();
}
}
}
}
});
Hooks.on("renderChatMessage", (message, html, data) => {
if (game.settings.get('fateroll', 'disableMessageHeader') && html[0].querySelector('.roll-of-fate')) {
html[0].querySelector('.message-header')?.style.setProperty("display", "none");
}
html[0].querySelectorAll(".rof-token-link").forEach(el => {
el.addEventListener("click", ev => {
const tokenId = ev.currentTarget.dataset.tokenId;
const token = canvas.tokens.get(tokenId);
if (token) canvas.animatePan({ x: token.x, y: token.y, scale: 1.5 });
});
});
if (game.settings.get('fateroll', 'usePlayerColorGradient')) {
const div = html[0].querySelector('.roll-of-fate');
const msgEl = html[0].closest('.message');
const tokenId = div?.querySelector('.rof-token-link')?.dataset?.tokenId;
const token = canvas.tokens.get(tokenId);
const actor = token?.actor;
console.log(actor);
if (actor) {
const user = game.users.find(u => u.character?.id === actor.id && u.active);
if (user && msgEl) {
msgEl.style.setProperty('--rof-user-color', user.color);
}
}
}
});
class Fatecontrol {
static addChatControl() {
const existing = document.getElementById("FATE-button");
if (existing) return;
let button;
// dorako-ui
const dorako = document.getElementById("dorako-rt-buttons");
if (dorako) {
button = document.createElement("button");
button.id = "FATE-button";
button.classList.add("button");
button.title = "Fate Roll";
button.innerHTML = `<i class="fas fa-yin-yang"></i>`;
button.onclick = Fatecontrol.initializeFATE;
dorako.insertBefore(button, dorako.firstChild);
return;
}
// v13
const rollPrivacy = document.getElementById("roll-privacy");
if (rollPrivacy) {
button = document.createElement("button");
button.id = "FATE-button";
button.classList.add("ui-control", "icon");
button.setAttribute("aria-label", "Fate Roll");
button.setAttribute("data-tooltip", "Fate Roll");
button.innerHTML = `<i class="fas fa-yin-yang"></i>`;
button.onclick = Fatecontrol.initializeFATE;
rollPrivacy.insertBefore(button, rollPrivacy.firstChild);
return;
}
// v12
const legacyTarget = document.getElementsByClassName("chat-control-icon")[0];
if (legacyTarget) {
const label = document.createElement("label");
label.innerHTML = `<i id="FATE-button" class="fas fa-yin-yang FATE-button" style="text-shadow: 0 0 1px black; margin-right: 5px;"></i>`;
label.onclick = Fatecontrol.initializeFATE;
legacyTarget.insertBefore(label, legacyTarget.firstChild);
}
}
static initializeFATE() {
event.preventDefault();
let tokens = canvas.tokens.controlled;
if(game.settings.get('fateroll', 'onlyplayers'))
{
let tempArray = []
for(let i = 0; i < tokens.length; i++){
if(tokens[i].actor.data.type != "npc"){
tempArray.push(tokens[i])
}
}
tokens = tempArray;
}
let randomtoken = tokens[Math.floor(Math.random() * tokens.length)];
let headersArray = game.settings.get("fateroll", "fatetext").split(";");
let sHeader = headersArray[Math.floor(Math.random() * headersArray.length)];
let prefixArray = game.settings.get("fateroll", "prefix").split(";");
let sPrefix = prefixArray[Math.floor(Math.random() * prefixArray.length)];
let suffixArray = game.settings.get("fateroll", "suffix").split(";");
let sSuffix = suffixArray[Math.floor(Math.random() * suffixArray.length)];
let sBackgroundColor = game.settings.get("fateroll", "backgroundcolor");
let sTitleColor = game.settings.get("fateroll", "titlecolor");
let sTextColor = game.settings.get("fateroll", "textcolor");
let sBackgroundstyle = game.settings.get("fateroll", "backgroundstyle");
let boolDisableTitle = game.settings.get("fateroll","boolDisableTitle");
let boolCardDS = game.settings.get('fateroll', 'dropshadow');
let customstyle = ""
if(boolCardDS){
customstyle += 'box-shadow: 0 7px 10px;';
}
let sBoolDisableTitle;
if(boolDisableTitle){
sBoolDisableTitle = "none";
}
else{
sBoolDisableTitle = "block";
}
let vTitleGlow = 0;
let vTextGlow = 0;
if(game.settings.get("fateroll", "ROFCardHeaderGlow")){
vTitleGlow = 5;
}
if(game.settings.get("fateroll", "ROFCardTextGlow")){
vTextGlow = 5;
}
let backgroundArray = [];
if(game.settings.get("fateroll", "backgroundimg") != ""){
backgroundArray.push(game.settings.get("fateroll", "backgroundimg"));
}
if(game.settings.get("fateroll", "backgroundimg2") != ""){
backgroundArray.push(game.settings.get("fateroll", "backgroundimg2"));
}
if(game.settings.get("fateroll", "backgroundimg3") != ""){
backgroundArray.push(game.settings.get("fateroll", "backgroundimg3"));
}
if(game.settings.get("fateroll", "backgroundimg4") != ""){
backgroundArray.push(game.settings.get("fateroll", "backgroundimg4"));
}
if(game.settings.get("fateroll", "backgroundimg5") != ""){
backgroundArray.push(game.settings.get("fateroll", "backgroundimg5"));
}
let sBackgroundImg = backgroundArray[Math.floor(Math.random() * backgroundArray.length)];
let sTitleBlend = game.settings.get('fateroll', 'titleBlend')
let sTitleBackStyle = game.settings.get('fateroll', 'titleBackStyle');
let sTitleBackFilter = game.settings.get('fateroll', 'titleBackFilter');
let sTextBlend = game.settings.get('fateroll', 'textBlend')
let sTextBackStyle = game.settings.get('fateroll', 'textBackStyle');
let sTextBackFilter = game.settings.get('fateroll', 'textBackFilter');
let sSoundPath = game.settings.get("fateroll", "soundpath");
let selectedstring = "";
for(let i = 0; i < tokens.length ; i++) {
if(i != (tokens.length -1)){
selectedstring = selectedstring + "<label class='ROFtokenname'>" + tokens[i].name +",</label>";
}
else{
selectedstring = selectedstring + "<label class='ROFtokenname'>" + tokens[i].name +"</label>";
}
}
let blind;
let whisper;
let header = `<header class="rof-card-header" style="display:${sBoolDisableTitle}; mix-blend-mode:${sTitleBlend}; background: ${sTitleBackStyle}; backdrop-filter: ${sTitleBackFilter};">
<h3 class="rof-cardtitle" style="text-align: center;color: ${sTitleColor} !important;font-family: inherit; text-shadow: 0 0 ${vTitleGlow}px;"><b>${sHeader}</b></h3>
</header>`
if(sHeader == "")
header="";
if(selectedstring == "" || !game.settings.get("fateroll", "displayselected"))
selectedstring="";
else{
selectedstring='<div class="faterollSelectedStrong" style="color:'+sTextColor+'">'+selectedstring+'</div>';
}
let rollMode;
rollMode = rollMode || game.settings.get("core", "rollMode");
if ( ["gmroll", "blindroll"].includes(rollMode) ) whisper = ChatMessage.getWhisperRecipients("GM");
if ( rollMode === "blindroll" ) blind = true;
if ( rollMode === "selfroll" ) whisper = [game.user.id];
if(tokens.length === 1){
ui.notifications.notify("ROLL OF FATE: You only selected one token...");
}
if(tokens.length === 0){
ui.notifications.warn("ROLL OF FATE: You need to select some tokens first...");
console.log("Roll of Fate | No tokens selected");
}
else{
//console.log(tokens);
let content = `
${selectedstring}
<div style="background: ${sBackgroundColor}; background-image: url(${sBackgroundImg}); background-size: ${sBackgroundstyle};${customstyle}" class="roll-of-fate">
${header}
<h3 class="rof-cardtext" style="color:${sTextColor};padding: 10px;text-align: center;text-shadow: 0 0 ${vTextGlow}px ; mix-blend-mode:${sTextBlend}; background: ${sTextBackStyle}; backdrop-filter: ${sTextBackFilter};">
${sPrefix}
<a class="rof-token-link" data-token-id="${randomtoken.id}" style="cursor: pointer; font-weight: bold; color: ${sTextColor}; text-decoration: underline;">${randomtoken.name}</a>
${sSuffix}
</h3>
</div>
`;
ChatMessage.create({
user: game.user._id,
content: content,
whisper: whisper,
blind: blind,
sound: sSoundPath,
flags: {
fateroll: {
fateroll: 'fate'
}
}
});
}
}
}
class ROFConfig extends FormApplication {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
title: "Roll of Fate Customizer",
id: "rof-config",
template: "modules/fateroll/templates/rofEditor.html",
width: 500,
height: 700,
closeOnSubmit: true
})
}
async _updateObject(event, formData) {
console.log("Saved");
let TitleColor = document.getElementById("ROFTitleC").value;
let TextColor = document.getElementById("ROFTextC").value;
let BackgroundColor = document.getElementById("ROFBackC").value;
let BackgroundStyle = document.getElementById("ROFbgstyle").value;
let sFateText = document.getElementById("ROFTitlelist").value;
sFateText = sFateText.replace(/(?:\r\n|\r|\n)/g, ';');
let sPrefix = document.getElementById("ROFPrefixList").value;
sPrefix = sPrefix.replace(/(?:\r\n|\r|\n)/g, ';');
let sSuffix = document.getElementById("ROFSuffixList").value;
sSuffix = sSuffix.replace(/(?:\r\n|\r|\n)/g, ';');
let fatetext = sFateText;
let prefix = sPrefix;
let suffix = sSuffix;
game.settings.set('fateroll', 'dropshadow', document.getElementById("ROFCardDS").checked);
game.settings.set('fateroll', 'titlecolor', TitleColor);
game.settings.set('fateroll', 'titleBlend', document.getElementById("ROFTitleBlend").value);
game.settings.set('fateroll', 'titleBackStyle', document.getElementById("TitleBackStyle").value);
game.settings.set('fateroll', 'titleBackFilter', document.getElementById("TitleBackFilter").value);
game.settings.set('fateroll', 'textcolor', TextColor);
game.settings.set('fateroll', 'textBlend', document.getElementById("ROFTextBlend").value);
game.settings.set('fateroll', 'textBackStyle', document.getElementById("TextBackStyle").value);
game.settings.set('fateroll', 'textBackFilter', document.getElementById("TextBackFilter").value);
game.settings.set('fateroll', 'backgroundcolor', BackgroundColor);
game.settings.set('fateroll', 'backgroundstyle', BackgroundStyle);
game.settings.set('fateroll', 'ROFCardHeaderGlow', document.getElementById("ROFTitleGlow").checked);
game.settings.set('fateroll', 'ROFCardTextGlow', document.getElementById("ROFTextGlow").checked);
if(fatetext.endsWith(";")){
fatetext = fatetext.slice(0, -1);
}
if(prefix.endsWith(";")){
prefix = prefix.slice(0, -1);
}
if(suffix.endsWith(";")){
suffix = suffix.slice(0, -1);
}
game.settings.set('fateroll', 'fatetext', fatetext);
game.settings.set('fateroll', 'prefix', prefix);
game.settings.set('fateroll', 'suffix', suffix);
ui.notifications.info("ROF-Saved");
}
close(options){
super.close(options);
}
}
Hooks.on('canvasReady', function(){
if(game.settings.get('fateroll', 'hidebutton')){
if(game.user.isGM){
Fatecontrol.addChatControl();
console.log("FATE GM TRUE");
}
console.log("FATE GM FIN");
}
else{
Fatecontrol.addChatControl();
console.log("FATE NOT SET");
}
});
Hooks.on('renderROFConfig', function(){
//GET VALUES FROM SETTINGS
document.getElementById("ROFCardDS").checked = game.settings.get('fateroll', 'dropshadow');
document.getElementById("ROFTitleC").value = game.settings.get('fateroll', 'titlecolor');
document.getElementById("ROFTitleBlend").value = game.settings.get('fateroll', 'titleBlend');
document.getElementById("TitleBackStyle").value = game.settings.get('fateroll', 'titleBackStyle') ;
document.getElementById("TitleBackFilter").value = game.settings.get('fateroll', 'titleBackFilter');
document.getElementById("cardpreview").style.mixBlendMode = document.getElementById("ROFTitleBlend").value;
document.getElementById("cardpreview").style.background = document.getElementById("TitleBackStyle").value;
document.getElementById("cardpreview").style.backdropFilter = document.getElementById("TitleBackFilter").value;
document.getElementById("ROFTextBlend").value = game.settings.get('fateroll', 'textBlend');
document.getElementById("TextBackStyle").value = game.settings.get('fateroll', 'textBackStyle') ;
document.getElementById("TextBackFilter").value = game.settings.get('fateroll', 'textBackFilter');
document.getElementById("textpreview").style.mixBlendMode = document.getElementById("ROFTextBlend").value;
document.getElementById("textpreview").style.background = document.getElementById("TextBackStyle").value;
document.getElementById("textpreview").style.backdropFilter = document.getElementById("TextBackFilter").value;
document.getElementById("headerpreview").style.color = game.settings.get('fateroll', 'titlecolor');
document.getElementById("ROFTextC").value = game.settings.get('fateroll', 'textcolor');
document.getElementById("textpreview").style.color = game.settings.get('fateroll', 'textcolor');
document.getElementById("ROFBackC").value = game.settings.get('fateroll', 'backgroundcolor');
document.getElementById("messagepreview").style.background = game.settings.get('fateroll', 'backgroundcolor');
let sFateText = game.settings.get("fateroll", "fatetext");
sFateText = sFateText.replace(/;/g, "\n");
let sROFPrefixList = game.settings.get("fateroll", "prefix");
sROFPrefixList = sROFPrefixList.replace(/;/g, "\n");
let sROFSuffixList = game.settings.get("fateroll", "suffix");
sROFSuffixList = sROFSuffixList.replace(/;/g, "\n");
document.getElementById("ROFTitlelist").value = sFateText;
document.getElementById("ROFPrefixList").value = sROFPrefixList;
document.getElementById("ROFSuffixList").value = sROFSuffixList;
//let backgroundArray = [];
if(game.settings.get("fateroll", "backgroundimg") != ""){
//backgroundArray.push(game.settings.get("fateroll", "backgroundimg"));
document.getElementById("ROFBG1").style.display = "unset";
}
if(game.settings.get("fateroll", "backgroundimg2") != ""){
//backgroundArray.push(game.settings.get("fateroll", "backgroundimg2"));
document.getElementById("ROFBG2").style.display = "unset";
}
if(game.settings.get("fateroll", "backgroundimg3") != ""){
//backgroundArray.push(game.settings.get("fateroll", "backgroundimg3"));
document.getElementById("ROFBG3").style.display = "unset";
}
//document.getElementById("ROFBackgroundList").value = game.settings.get("fateroll", "backgroundimg")+"\n" + game.settings.get("fateroll", "backgroundimg2") + "\n" + game.settings.get("fateroll", "backgroundimg3");
let Background = "url('"+game.settings.get("fateroll", "backgroundimg")+"')"
document.getElementById("messagepreview").style.background = Background;
document.getElementById("ROFbgstyle").value = game.settings.get("fateroll", "backgroundstyle");
document.getElementById("messagepreview").style.backgroundSize = document.getElementById("ROFbgstyle").value;
document.getElementById("ROFTitleGlow").checked = game.settings.get('fateroll', 'ROFCardHeaderGlow');
document.getElementById("ROFTextGlow").checked = game.settings.get('fateroll', 'ROFCardTextGlow');
if(document.getElementById("ROFCardDS").checked){
document.getElementById("messagepreview").style.boxShadow = "0 7px 10px";
}
if(document.getElementById("ROFTitleGlow").checked){
document.getElementById("headerpreview").style.textShadow = "0px 0px 5px";
}
else{
document.getElementById("headerpreview").style.textShadow = "0px 0px 0px";
}
if(document.getElementById("ROFTextGlow").checked){
document.getElementById("textpreview").style.textShadow = "0px 0px 5px";
}
else{
document.getElementById("textpreview").style.textShadow = "0px 0px 0px";
}
if(game.settings.get("fateroll","boolDisableTitle")){
document.getElementById("cardpreview").style.display = "none";
document.getElementById("ROFPrevCard").style.marginTop = "46px";
}
document.getElementById("ROFTitleCP").value = document.getElementById("ROFTitleC").value;
document.getElementById("ROFTextCP").value = document.getElementById("ROFTextC").value;
document.getElementById("ROFBackCP").value = document.getElementById("ROFBackC").value;
});