forked from quisquous/cactbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathraidboss.js
91 lines (76 loc) · 3.34 KB
/
raidboss.js
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
import { addOverlayListener } from '../../resources/overlay_plugin_api';
import './raidboss_config';
import '../../resources/timerbar';
import { PopupText, PopupTextGenerator } from './popup-text';
import { TimelineController, TimelineLoader, TimelineUI } from './timeline';
import UserConfig from '../../resources/user_config';
import { addRemotePlayerSelectUI } from '../../resources/player_override';
import raidbossFileData from './data/manifest.txt';
import Options from './raidboss_options';
UserConfig.getUserConfigLocation('raidboss', Options, (e) => {
// Query params override default and user options.
// This allows for html files that say "timeline only" or "alerts only".
const params = new URLSearchParams(window.location.search);
Options.IsRemoteRaidboss = false;
if (params.get('OVERLAY_WS')) {
const wsParam = decodeURIComponent(params.get('OVERLAY_WS'));
// TODO: is there a better way to do this?? This seems better than looking for ngrok.
const isLocal = wsParam.includes('localhost') || wsParam.includes('127.0.0.1');
Options.IsRemoteRaidboss = !isLocal;
}
const playerNameParam = params.get('player');
if (playerNameParam) {
Options.PlayerNameOverride = playerNameParam;
console.log('Enabling player name override via query parameter, name: ' + playerNameParam);
}
if (Options.IsRemoteRaidboss && playerNameParam === null) {
const lang = Options.DisplayLanguage || Options.ParserLanguage || 'en';
addRemotePlayerSelectUI(lang);
// Page will reload once player selected.
return;
}
const ttsParam = params.get('forceTTS');
if (ttsParam) {
const forceEnable = !!parseInt(ttsParam);
if (forceEnable) {
Options.SpokenAlertsEnabled = true;
console.log('Force enabling TTS via query parameter');
}
}
const alertsParam = params.get('alerts');
if (alertsParam !== null) {
const previous = Options.AlertsEnabled;
Options.AlertsEnabled = !!parseInt(alertsParam);
if (!previous && Options.AlertsEnabled)
console.log('Enabling alerts via query parameter');
}
const timelineParam = params.get('timeline');
if (timelineParam !== null) {
const previous = Options.TimelineEnabled;
Options.TimelineEnabled = !!parseInt(timelineParam);
if (!previous && Options.TimelineEnabled)
console.log('Enabling timeline via query parameter');
}
const audioParam = params.get('audio');
if (audioParam !== null) {
const previous = Options.AudioAllowed;
Options.AudioAllowed = !!parseInt(audioParam);
if (!previous && Options.AudioAllowed)
console.log('Enabling audio via query parameter');
}
const container = document.getElementById('container');
if (!Options.AlertsEnabled)
container.classList.add('hide-alerts');
if (!Options.TimelineEnabled)
container.classList.add('hide-timeline');
const timelineUI = new TimelineUI(Options);
const timelineController = new TimelineController(Options, timelineUI, raidbossFileData);
const timelineLoader = new TimelineLoader(timelineController);
const popupText = new PopupText(Options, timelineLoader, raidbossFileData);
// Connect the timelines to the popup text, if alerts are desired.
if (Options.AlertsEnabled)
timelineController.SetPopupTextInterface(new PopupTextGenerator(popupText));
addOverlayListener('onLogEvent', (e) => {
timelineController.OnLogEvent(e);
});
});