forked from eternaldensity/Sandcastle-Builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
327 lines (289 loc) · 8.04 KB
/
options.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
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
Molpy.OptionsN = 0;
Molpy.Options = [];
Molpy.options = [];
Molpy.OptionsById = [];
Molpy.Option = function(args) {
this.id = Molpy.OptionsN;
this.name = args.name; // Name of option - needed for all
this.title = args.title || args.name; // Title to appear on options pane
this.defaultval = args.defaultval || 0; // Default value of option
this.visability = args.visability || 1; // Visability of option (maybe function)
this.onchange = args.onchange || 0; // Function - Action to take when it changes
this.range = args.range || 1; // Highest value (currently 1-9)
this.text = args.text || ["No","Yes"]; // Text for option, if an array it is indexed by the value (maybe function)
this.breakafter = args.breakafter || 0; // Put a line break after the option to format the options pane
Molpy.Options[this.name] = this;
Molpy.OptionsById[this.id] = this;
Molpy.OptionsN++;
}
Molpy.DefaultOptions = function() {
for (var opi in Molpy.Options) {
var opt=Molpy.Options[opi];
Molpy.options[opt.name] = opt.defaultval;
if (opt.onchange) opt.onchange(0);
}
}
Molpy.RefreshOptions = function(manual) {
if(!Molpy.molpish) return;
if (manual) Molpy.EarnBadge('Decisions, Decisions');
str = '';
for (var opi in Molpy.OptionsById) {
var opt=Molpy.OptionsById[opi];
if (EvalMaybeFunction(opt.visability) > 0) {
str += '<div id=' + opt.name + 'option class=minifloatbox><a onclick=Molpy.ToggleOption(\'' + opt.name + '\')>' + opt.title +
'</a><div id=' + opt.name + 'descripton><br>';
var texts = EvalMaybeFunction(opt.text,opt);
if (typeof(texts) === 'object') str += texts[Molpy.options[opt.name]]
else str += texts;
str += '</div></div>';
if (opt.breakafter) str += '<br>';
}
}
g('optionsItems').innerHTML = str;
}
Molpy.ToggleOption = function(id) {
opt = Molpy.Options[id];
Molpy.options[opt.name]++;
if (Molpy.options[opt.name] > opt.range) Molpy.options[opt.name]=0;
if (opt.onchange) opt.onchange(1);
Molpy.RefreshOptions(1);
}
Molpy.Setoption = function(opt,val) {
Molpy.options[opt] = val;
}
Molpy.OptionsToString = function() {
var str = '';
for (var opt in Molpy.OptionSaveOrder) str += Molpy.options[Molpy.OptionSaveOrder[opt]] || 0;
return str;
};
Molpy.OptionsFromString = function(thread) {
thread = thread.replace(/N/g,''); // This is a fudge to remove a bug introduced in 3.4
thread = thread.replace(/A/g,'0'); // and fixed in 3.411
var pixels = thread.split('');
for (var opt in Molpy.OptionSaveOrder) {
var name = Molpy.OptionSaveOrder[opt];
Molpy.options[name] = parseInt(pixels[opt]);
if (isNaN(Molpy.options[name])) Molpy.options[name] = Molpy.Options[name].defaultval;
}
};
// ALWAYS add to the end of this list. NEVER EVER remove an option
Molpy.OptionSaveOrder = [ 'particles', 'numbers', 'autosave', 'autoupdate', 'sea', 'colpix', 'longpostfix', 'colourscheme',
'sandmultibuy', 'castlemultibuy', 'fade', 'typo', 'science', 'autosavelayouts', 'autoscroll',
'boostsort', 'european', 'smalldecimal', 'logicatcol', 'loglimit', 'autoshow', 'mindecimal', 'edigits' ];
// These options are defined in the display order
new Molpy.Option({
name: 'autosave',
title: 'Autosave',
defaultval: 2,
range: 9,
visability: function() {return Molpy.Got('Autosave Option')},
text: function() {
var auto = Molpy.options.autosave;
if(auto) {
return 'Every ' + auto * 5 + 'milliNewPix';
} else {
return 'Off (remember to save manually!)';
}
}
});
new Molpy.Option({
name: 'autosavelayouts',
title: 'Autosave Layouts',
range: 2,
visability: function() {return (Molpy.Got('Autosave Option') && !noLayout)},
defaultval: 1,
text: [ 'Off (remember to save layouts manually!)', 'When you save the game manually', 'Whenever the game is saved'],
breakafter: 1,
});
new Molpy.Option({
name: 'autoscroll',
title: 'Autoscroll Log',
});
new Molpy.Option({
name: 'loglimit',
title: 'Kept logs',
defaultval: 3,
range: 9,
text: function() {
val = Molpy.options.loglimit;
if(val) {
return '' + val + ' ONGs of logs';
} else {
return 'No limit';
}
},
onchange: function() {
Molpy.CleanLogs();
},
});
new Molpy.Option({
name: 'boostsort',
title: 'Sort Boosts by',
onchange: function() {
Molpy.boostNeedRepaint = 1;
},
text: ['Price','Name'],
breakafter: 1,
});
Molpy.flashes = 0;
new Molpy.Option({
name: 'colourscheme',
title: 'Colour Scheme',
visability: function() {return Molpy.Got('Chromatic Heresy')},
onchange: function(manual) {
if (manual) Molpy.EarnBadge('Night and Dip');
Molpy.UpdateColourScheme();
Molpy.flashes++;
if(Molpy.flashes == 30) Molpy.EarnBadge('I love my flashy gif');
Molpy.Overview.DoAll();
},
text: [ "Dark Theme", "Light Theme"],
defaultval: 1,
});
new Molpy.Option({
name: 'colpix',
title: 'Show Colpix',
onchange: function() { Molpy.UpdateColourScheme() },
defaultval: 0,
});
new Molpy.Option({
name: 'logicatcol',
title: 'Logicat Colours',
visability: function() {return Molpy.Got('Chromatic Heresy') && Molpy.Got('LogiPuzzle') },
onchange: function() {
Molpy.Boosts['Logicat'].repaint();
Molpy.UpdateFaves();
},
text: ['Greys','Colours'],
});
new Molpy.Option({
name: 'numbers',
title: 'Draw +Sand Numbers',
defaultval: 1,
breakafter: 1,
onchange: function() {
g('sparticles').style.display = Molpy.options.numbers?"block":"none";
},
});
new Molpy.Option({
name: 'science',
title: 'Scientific Notation',
onchange: function() {
Molpy.allNeedRepaint = 1;
Molpy.UpdateFaves();
},
});
new Molpy.Option({
name: 'edigits',
title: 'Number of digits before collapsing to epsilon notation',
range: 4,
text: ['Standart', '9', '10', '11', '12'],
visability: function() {
if (Molpy.options.science) {
return 1;
} else {
return 0;
}
},
onchange: function() {
Molpy.allNeedRepaint = 1;
Molpy.UpdateFaves();
}
});
new Molpy.Option({
name: 'longpostfix',
title: 'Use long postfixes',
onchange: function() {
Molpy.allNeedRepaint = 1;
Molpy.UpdateFaves();
},
});
new Molpy.Option({
name: 'european',
title: 'European format numbers',
onchange: function() {
Molpy.allNeedRepaint = 1;
Molpy.UpdateFaves();
},
});
new Molpy.Option({
name: 'mindecimal',
title: 'Minimum Decimal Digits',
range: 5,
onchange: function() {
Molpy.allNeedRepaint = 1;
Molpy.UpdateFaves();
},
text: function() { return Molpy.options.mindecimal },
});
new Molpy.Option({
name: 'smalldecimal',
title: 'Decimal Settings',
text: ['Normal','Small','Shaded','Italic','Red','Lime','Orange','Mauve','Teal','Blue'],
range: 9,
breakafter: 1,
});
new Molpy.Option({
name: 'sandmultibuy',
title: 'Buy N Sand tools at once',
range: 5,
visability: function() {return Molpy.Got('Sand Tool Multi-Buy')},
onchange: function() { Molpy.toolsNeedRepaint = 1 },
text: function() { return Math.pow(4, Molpy.options.sandmultibuy) + ' tool' + plural(Molpy.options.sandmultibuy + 1) },
});
new Molpy.Option({
name: 'castlemultibuy',
title: 'Buy N Castle tools at once',
range: 5,
visability: function() {return Molpy.Got('Castle Tool Multi-Buy')},
onchange: function() { Molpy.toolsNeedRepaint = 1 },
text: function() { return Math.pow(4, Molpy.options.castlemultibuy) + ' tool' + plural(Molpy.options.castlemultibuy + 1) },
});
new Molpy.Option({
name: 'fade',
title: 'Colour Scheme Fade',
range: 10,
visability: function() {return Molpy.Got('I love my flashy gif')},
onchange: function() { Molpy.AdjustFade() },
text: function() {
var f = Molpy.options.fade;
if(!f) {
return "No";
} else {
return Molpify(f / 2, 1) + 's';
}
}
});
new Molpy.Option({
name: 'autoshow',
title: 'Auto show new things',
range: 2,
defaultval: 1,
text: ['Never', 'Always', 'No discoveries']
});
new Molpy.Option({
name: 'typo',
title: 'typo',
visability: -1,
});
new Molpy.Option({ //Not Used
name: 'sea',
title: '',
visability: -1,
});
new Molpy.Option({ //Not Used
name: 'particles',
title: '',
visability: -1,
});
new Molpy.Option({ //Not Used
name: 'autoupdate',
title: '',
visability: -1,
});
/*
new Molpy.Option({
name: '',
title: '',
});
*/