forked from Xbozon/rpg-styled-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpg-ui.js
120 lines (111 loc) · 3.59 KB
/
rpg-ui.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
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
Hooks.on('init', () => {
// Register module settings.
game.settings.register('rpg-styled-ui', 'navigationVerticalToggle', {
name: game.i18n.localize('RPGUI.SETTINGS.NAVIGATION'),
hint: game.i18n.localize('RPGUI.SETTINGS.NAVIGATION_HINT'),
scope: "world",
type: Boolean,
default: false,
config: true,
onChange: () => {
location.reload();
}
});
game.settings.register('rpg-styled-ui', 'compactModeToggle', {
name: game.i18n.localize('RPGUI.SETTINGS.COMPACT_MODE'),
hint: game.i18n.localize('RPGUI.SETTINGS.COMPACT_MODE_HINT'),
scope: "world",
type: Boolean,
default: false,
config: true,
onChange: () => {
location.reload();
}
});
game.settings.register('rpg-styled-ui', 'standardLogoToggle', {
name: game.i18n.localize('RPGUI.SETTINGS.STANDARD_LOGO'),
hint: game.i18n.localize('RPGUI.SETTINGS.STANDARD_LOGO_HINT'),
scope: "world",
type: Boolean,
default: false,
config: true,
onChange: () => {
location.reload();
}
});
game.settings.register('rpg-styled-ui', 'minimalUICompatibility', {
name: game.i18n.localize('RPGUI.SETTINGS.MINIMAL_UI'),
hint: game.i18n.localize('RPGUI.SETTINGS.MINIMAL_UI_HINT'),
scope: "world",
type: Boolean,
default: false,
config: true,
onChange: () => {
location.reload();
}
});
game.settings.register('rpg-styled-ui', 'disableAllStyles', {
name: game.i18n.localize('RPGUI.SETTINGS.DISABLE_STYLES'),
hint: game.i18n.localize('RPGUI.SETTINGS.DISABLE_STYLES_HINT'),
scope: "client",
type: Boolean,
default: false,
config: true,
onChange: () => {
location.reload();
}
});
if (!game.settings.get('rpg-styled-ui', 'compactModeToggle')) {
if (!game.settings.get('rpg-styled-ui', 'standardLogoToggle')) {
addClassByQuerySelector("hide", "img#logo")
let newLogo = document.createElement('div');
let uiLeft = document.getElementById('ui-left')
newLogo.classList.add("new-logo")
newLogo.innerText = "Foundry \nVTT"
uiLeft.prepend(newLogo)
}
}
if (!game.settings.get('rpg-styled-ui', 'disableAllStyles')) {
rpgUIAddMainCss()
}
if (game.settings.get('rpg-styled-ui', 'minimalUICompatibility')) {
addClassByQuerySelector('minimal-ui-mode', 'body.vtt')
}
});
// Retreat class of Monk's Little Details
// Create just an error without incident if Monk's little details isn't activate.
Hooks.on('ready', async () => {
game.settings.set("monks-little-details", "window-css-changes", false);
$("body").removeClass("change-windows");
});
Hooks.on('getSceneNavigationContext', () => {
if (!game.settings.get('rpg-styled-ui', 'navigationVerticalToggle')) {
navigation = document.querySelector("nav.app > ol#scene-list");
if (navigation) {
navigation.classList.add("vertical")
}
}
if (game.settings.get('rpg-styled-ui', 'compactModeToggle')) {
addClassByQuerySelector("compact-mode", "body")
}
});
Hooks.on('renderCombatCarousel', () => {
let carouselSize = game.settings.get('combat-carousel', 'carouselSize')
if (carouselSize !== "") {
addClassByQuerySelector(carouselSize, "#combat-carousel")
}
});
function addClassByQuerySelector(className, selector) {
let navigation = document.querySelector(selector);
navigation.classList.add(className)
}
function rpgUIAddMainCss() {
const head = document.getElementsByTagName("head")[0];
const mainCss = document.createElement("link");
mainCss.setAttribute("rel", "stylesheet")
mainCss.setAttribute("type", "text/css")
mainCss.setAttribute("href", "modules/rpg-styled-ui/css/rpg-ui.css")
// mainCss.setAttribute("href", "modules/rpg-styled-ui/css/compatibility.css")
mainCss.setAttribute("media", "all")
head.insertBefore(mainCss, head.lastChild);
}