-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
140 lines (124 loc) · 5.37 KB
/
main.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
if(SugarSight === undefined) var SugarSight = {};
SugarSight.name = 'Sugar Sight';
SugarSight.version = '1.052';
SugarSight.GameVersion = '2.052';
SugarSight.launch = function(){
SugarSight.init = function(){
SugarSight.isLoaded = 1;
SugarSight.Backup = {};
SugarSight.config = {};
SugarSight.config = SugarSight.defaultConfig();
if(CCSE.config.OtherMods.SugarSight && !Game.modSaveData[SugarSight.name]) Game.modSaveData[SugarSight.name] = JSON.stringify(CCSE.config.OtherMods.SugarSight);
Game.customOptionsMenu.push(function(){
CCSE.AppendCollapsibleOptionsMenu(SugarSight.name, SugarSight.getMenuString());
});
Game.customStatsMenu.push(function(){
CCSE.AppendStatsVersionNumber(SugarSight.name, SugarSight.version);
});
Game.customLumpTooltip.push(function(str){
var colour = "";
var name = SugarSight.getLumpName();
colour = SugarSight.config.colorOverride[name];
str = str.replace(loc("• Sugar lumps can be harvested when mature, though if left alone beyond that point they will start ripening (increasing the chance of harvesting them) and will eventually fall and be auto-harvested after some time.<br>• Sugar lumps are delicious and may be used as currency for all sorts of things.<br>• Once a sugar lump is harvested, another one will start growing in its place.<br>• Note that sugar lumps keep growing when the game is closed.")+'</div>',
loc("• Sugar lumps can be harvested when mature, though if left alone beyond that point they will start ripening (increasing the chance of harvesting them) and will eventually fall and be auto-harvested after some time.<br>• Sugar lumps are delicious and may be used as currency for all sorts of things.<br>• Once a sugar lump is harvested, another one will start growing in its place.<br>• Note that sugar lumps keep growing when the game is closed.")+
'<div class="line"></div>Your current lump is: <b style="color:'+colour+';">'+name+'</b></div>');
return str;
});
Game.customClickLump.push(function(){
if(SugarSight.config.soundToggles[SugarSight.getLumpName()]) Game.playGoldenCookieChime();
});
//***********************************
// Post-Load Hooks
// To support other mods interfacing with this one
//***********************************
if(SugarSight.postloadHooks) {
for(var i = 0; i < SugarSight.postloadHooks.length; ++i) {
SugarSight.postloadHooks[i]();
}
}
if (Game.prefs.popups) Game.Popup(SugarSight.name + ' loaded!');
else Game.Notify(SugarSight.name + ' loaded!', '', '', 1, 1);
}
SugarSight.getLumpName = function(){
var name = "";
if(Game.lumpCurrentType == 0) {// Normal
name = "Normal";
} else if(Game.lumpCurrentType == 1) {// Bifurcated
name = "Bifurcated";
} else if(Game.lumpCurrentType == 2) {// Golden
name = "Golden";
} else if(Game.lumpCurrentType == 3) {// Meaty
name = "Meaty";
} else if(Game.lumpCurrentType == 4) {// Caramelized
name = "Caramelized";
}
return name;
}
//***********************************
// Configuration
//***********************************
SugarSight.save = function(){
return JSON.stringify(SugarSight.config);
}
SugarSight.load = function(str){
var config = JSON.parse(str);
for(var pref in config){
SugarSight.config[pref] = config[pref];
}
}
SugarSight.defaultConfig = function(){
return {
colorOverride: {
'Normal' : "#FFFFFF",
'Bifurcated' : "#00FFFF",
'Golden' : "#00FF00",
'Meaty' : "#FF0000",
'Caramelized' : "#FF8000"
},
soundToggles: {
'Normal' : false,
'Bifurcated' : false,
'Golden' : true,
'Meaty' : false,
'Caramelized' : false
}
}
}
SugarSight.SetOverrideColor = function(effect, color){
SugarSight.config.colorOverride[effect] = color;
Game.UpdateMenu();
}
SugarSight.getMenuString = function(){
let m = CCSE.MenuHelper;
var str = m.Header('Lump Type Settings') +
'<div class="listing">Set color coding and sound options for each lump type. Note: Will only play sounds if the sound selector is unlocked and a sound is selected.</div>';
for(var color in SugarSight.config.colorOverride){
var style = 'width:65px;' +
'background-color:' + SugarSight.config.colorOverride[color] + ';';
str += '<div class="listing">' +
m.CheckBox(SugarSight.config.soundToggles, color, 'lump'+color+'Button', color, color, "SugarSight.Toggle") +
'<input id="SugarSightColorOverride' + color + '" class="option" style="' + style + '" value="' + SugarSight.config.colorOverride[color] + '" onChange="SugarSight.SetOverrideColor(\'' + color + '\', l(\'SugarSightColorOverride' + color + '\').value)">' +
'</div>';
}
return str;
}
SugarSight.Toggle = function(prefName, button, on, off, invert){
if(SugarSight.config.soundToggles[prefName]){
SugarSight.config.soundToggles[prefName] = 0;
}
else{
SugarSight.config.soundToggles[prefName] = 1;
}
}
if(CCSE.ConfirmGameVersion(SugarSight.name, SugarSight.version, SugarSight.GameVersion)) Game.registerMod(SugarSight.name, SugarSight); // SugarSight.init();
}
if(!SugarSight.isLoaded){
if(CCSE && CCSE.isLoaded){
SugarSight.launch();
}
else{
if(!CCSE) var CCSE = {};
if(!CCSE.postLoadHooks) CCSE.postLoadHooks = [];
CCSE.postLoadHooks.push(SugarSight.launch);
}
}