-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathoptions.js
412 lines (364 loc) · 10 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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
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','approx',
'notifsilence', 'loglength'];
// 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: 'cloudsync',
title: 'Cloud Sync (Click this to progress)',
text: ['Off', 'Enter github credentials', 'Setup sync time', 'Stop everything'],
range: 3,
breakafter: 1,
onchange: function() {
if (Molpy.options.cloudsync == 2) {
var username = prompt('Enter your username');
var password = prompt('Enter your password');
GH.setup(username, password);
this.breakafter = 0;
} else if (Molpy.options.cloudsync == 3) {
var time = prompt('Enter amount of seconds...');
//TODO: setup export via timer
GH.tTime = parseInt(time);
GH.tId = setInterval(GH.exportToCloud, time * 1000);
this.title = 'Sync every' + ' ' + time + ' ' + 'seconds (Click this to progress)'
} else if (Molpy.options.cloudsync == 0) {
GH.teardown();
this.title = 'Cloud Sync (Click this to progress)';
this.breakafter = 1;
}
},
visability: function() {return Molpy.Got('Autosave Option')},
});
new Molpy.Option({
name: 'cloudimp',
title: 'Import data from cloud',
text: ['WARNING: NO CONFIRMATION!', 'Unpress the button'],
onchange: function() {
if (Molpy.options.cloudimp) {
if (GH.fGist) {
GH.importFromCloud()
}
}
},
visability: function() {
if ((Molpy.options.cloudsync == 2) || (Molpy.options.cloudsync == 3)) {
return 1
} else {
return 0
}
},
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: 'notifsilence',
title: 'Notifications',
range: 2,
text: ['All notifs', 'Less notifs', 'Critical only'],
visability: 1
});
new Molpy.Option({
name: 'loglength',
title: 'Log N notifications',
range: 6,
text: ['∞', '1','5','10','20','50','100'],
visibility: 1
});
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: 'approx',
title: 'Use rougher approximations',
range: 4,
text: ['Very Rough', 'Rough', 'Chunky', 'Smooth', 'Silky Smooth'],
visability: -1
});
new Molpy.Option({
name: 'notifsilence',
title: 'Notifications',
range: 2,
text: ['All notifs', 'Less notifs', 'Critical only'],
visability: 1
});
/*
new Molpy.Option({
name: '',
title: '',
});
*/