Allow saving outside of autosave-interval (#469)
This commit is contained in:
@@ -652,15 +652,18 @@ CM.Cache.spawnedGoldenShimmer = 0;
|
||||
* Section: Functions related to saving, loading and restoring configs */
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function (used to) save the config of CookieMonster
|
||||
* This function saves the config of CookieMonster without saving any of the other save-data
|
||||
* This allows saving in between the autosave intervals
|
||||
* It is called by CM.Config.LoadConfig(), CM.Config.RestoreDefault(), CM.Config.ToggleConfig(),
|
||||
* CM.ToggleConfigVolume() and changes in options with type "url", "color" or "numscale"
|
||||
* TODO: See if there is a way to force Cookie CLICKER to save only the mod-data and not also Save-data.
|
||||
* Otherwise this can be removed
|
||||
*/
|
||||
CM.Config.SaveConfig = function(config) {
|
||||
CM.save();
|
||||
CM.Config.SaveConfig = function() {
|
||||
let saveString = b64_to_utf8(unescape(localStorage.getItem('CookieClickerGame')).split('!END!')[0]);
|
||||
CookieMonsterSave = saveString.match(/CookieMonster.*(;|$)/);
|
||||
if (CookieMonsterSave != null) {
|
||||
newSaveString = saveString.replace(CookieMonsterSave[0], "CookieMonster:" + CM.save());
|
||||
localStorage.setItem('CookieClickerGame', escape(utf8_to_b64(newSaveString)+'!END!'))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,7 +716,7 @@ CM.Config.LoadConfig = function(settings) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mod) CM.Config.SaveConfig(CM.Options);
|
||||
if (mod) CM.Config.SaveConfig();
|
||||
CM.Loop(); // Do loop once
|
||||
for (var i in CM.Data.ConfigDefault) {
|
||||
if (i != 'Header' && typeof CM.ConfigData[i].func !== 'undefined') {
|
||||
@@ -732,7 +735,7 @@ CM.Config.LoadConfig = function(settings) {
|
||||
*/
|
||||
CM.Config.RestoreDefault = function() {
|
||||
CM.Config.LoadConfig(CM.Data.ConfigDefault);
|
||||
CM.Config.SaveConfig(CM.Options);
|
||||
CM.Config.SaveConfig();
|
||||
Game.UpdateMenu();
|
||||
}
|
||||
|
||||
@@ -758,7 +761,7 @@ CM.Config.ToggleConfig = function(config) {
|
||||
}
|
||||
|
||||
l(CM.ConfigPrefix + config).innerHTML = CM.ConfigData[config].label[CM.Options[config]];
|
||||
CM.Config.SaveConfig(CM.Options);
|
||||
CM.Config.SaveConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -771,7 +774,7 @@ CM.Config.ToggleConfigVolume = function(config) {
|
||||
l("slider" + config + "right").innerHTML = l("slider" + config).value + "%";
|
||||
CM.Options[config] = Math.round(l("slider" + config).value);
|
||||
}
|
||||
CM.Config.SaveConfig(CM.Options);
|
||||
CM.Config.SaveConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -782,7 +785,7 @@ CM.Config.ToggleConfigVolume = function(config) {
|
||||
CM.Config.ToggleHeader = function(config) {
|
||||
CM.Options.Header[config]++;
|
||||
if (CM.Options.Header[config] > 1) CM.Options.Header[config] = 0;
|
||||
CM.Config.SaveConfig(CM.Options);
|
||||
CM.Config.SaveConfig();
|
||||
}
|
||||
|
||||
/********
|
||||
@@ -3145,7 +3148,7 @@ CM.Disp.CreatePrefOption = function(config) {
|
||||
inputPrompt.setAttribute('value', CM.Options[config]);
|
||||
var a = document.createElement('a');
|
||||
a.className = 'option';
|
||||
a.onclick = function() {Game.Prompt(inputPrompt.outerHTML, [['Save', 'CM.Options[\'' + config + '\'] = l(CM.ConfigPrefix + \'' + config + '\' + \'Prompt\').value; CM.Config.SaveConfig(CM.Options); Game.ClosePrompt(); Game.UpdateMenu();'], 'Cancel']);};
|
||||
a.onclick = function() {Game.Prompt(inputPrompt.outerHTML, [['Save', 'CM.Options[\'' + config + '\'] = l(CM.ConfigPrefix + \'' + config + '\' + \'Prompt\').value; CM.Config.SaveConfig(); Game.ClosePrompt(); Game.UpdateMenu();'], 'Cancel']);};
|
||||
a.textContent = 'Edit';
|
||||
div.appendChild(a);
|
||||
var label = document.createElement('label');
|
||||
@@ -3163,7 +3166,7 @@ CM.Disp.CreatePrefOption = function(config) {
|
||||
input.style.width = '65px';
|
||||
input.setAttribute('value', CM.Options.Colors[CM.Disp.colors[i]]);
|
||||
div.appendChild(input);
|
||||
eval('var change = function() {CM.Options.Colors[\'' + CM.Disp.colors[i] + '\'] = l(CM.ConfigPrefix + \'Color\' + \'' + CM.Disp.colors[i] + '\').value; CM.Disp.UpdateColors(); CM.Config.SaveConfig(CM.Options);}');
|
||||
eval('var change = function() {CM.Options.Colors[\'' + CM.Disp.colors[i] + '\'] = l(CM.ConfigPrefix + \'Color\' + \'' + CM.Disp.colors[i] + '\').value; CM.Disp.UpdateColors(); CM.Config.SaveConfig();}');
|
||||
var jscolorpicker = new jscolor.color(input, {hash: true, caps: false, pickerZIndex: 1000000, pickerPosition: 'right', onImmediateChange: change});
|
||||
var label = document.createElement('label');
|
||||
label.textContent = CM.ConfigData.Colors.desc[CM.Disp.colors[i]];
|
||||
@@ -3187,7 +3190,7 @@ CM.Disp.CreatePrefOption = function(config) {
|
||||
input.max = CM.ConfigData[config].max;
|
||||
input.oninput = function() {if (this.value > this.max) console.log("TEST");
|
||||
CM.Options[config] = this.value;
|
||||
CM.Config.SaveConfig(CM.Options);
|
||||
CM.Config.SaveConfig();
|
||||
CM.Disp.RefreshScale()
|
||||
}
|
||||
div.appendChild(input);
|
||||
|
||||
Reference in New Issue
Block a user