forked from CCDirectLink/CCNewGamePP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuiManager.js
66 lines (60 loc) · 1.59 KB
/
uiManager.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
export class UiManager {
constructor() {
}
/**
*
* @param {string} name
* @param {string} display
* @param {'SINGLE' | 'MULTI'} type How many options can be selected
* @param {number} [order]
*/
addCategory(name, display, type, order) {
if (typeof order !== 'number') {
order = this._getLastOrder() + 100;
}
sc.NEW_GAME_SETS[name] = {type, order};
ig.lang.labels.sc.gui.menu['new-game'].sets[name] = display;
const cat = name;
return {
/**
*
* @param {string} name
* @param {string} display
* @param {string} description
* @param {number} cost
* @param {boolean} [needsSaveFile]
*/
addEntry: (name, display, description, cost, needsSaveFile) => {
return this.addEntry(name, display, description, cat, cost, needsSaveFile);
}
};
}
/**
*
* @param {string} name
* @param {string} display
* @param {string} description
* @param {string} cat The exact name of the category
* @param {number} cost
* @param {boolean} [needsSaveFile]
*/
addEntry(name, display, description, cat, cost, needsSaveFile) {
sc.NEW_GAME_OPTIONS[name] = {
set: cat,
cost: cost,
needsSaveFile: needsSaveFile,
};
ig.lang.labels.sc.gui.menu['new-game'].options.names[name] = display;
ig.lang.labels.sc.gui.menu['new-game'].options.descriptions[name] = description;
}
_getLastOrder() {
let result = -1;
for (const name of Object.keys(sc.NEW_GAME_SETS)) {
const cat = sc.NEW_GAME_SETS[name];
if (cat.order > result) {
result = cat.order;
}
}
return result;
}
}