public static void LoadMod() { if (!Game1.IsMasterGame) { return; } try { ModState state = ModEntry.GetHelper().Data.ReadSaveData <ModState>(SAVE_KEY); if (state == null) { //need to find folks who have the old data model and convert them to the new one. //since the save key used doesn't match the current save key, lets try the old method. String data = ModEntry.GetHelper().Data.ReadSaveData <String>("data"); ModEntry.GetMonitor().Log("Attempting to load mod data"); state = JsonConvert.DeserializeObject <ModState>(data); if (state != null) { //this user has the old save format. Save in new format real quick and blank out the old key. ModEntry.GetHelper().Data.WriteSaveData(SAVE_KEY, ModState.getModState()); ModEntry.GetHelper().Data.WriteSaveData("data", ""); } } } catch (Exception e) { ModEntry.GetMonitor().Log(e.Message); } }
//private static bool savingInProgress = false; private void OnSave(object sender, SavingEventArgs e) { VoidshroomTree.RemovalAll(); //CaveCarrot.RemoveAll(); ModState.visitedMineshafts.Clear(); ModState.SaveMod(); }
public static ModState getModState() { if (thisModState == null) { thisModState = new ModState(); } return(thisModState); }
private void OnSave(object sender, SavingEventArgs e) { if (!savingInProgress) { savingInProgress = true; VoidshroomTree.RemovalAll(); ModState.visitedMineshafts.Clear(); ModState.SaveMod(); savingInProgress = false; } }
public static void SaveMod() { if (!Game1.IsMasterGame) { return; } // save data ModEntry.GetMonitor().Log("Attempting to save mod data"); ModEntry.GetHelper().Data.WriteSaveData(SAVE_KEY, ModState.getModState()); }
public static void SaveMod() { if (!Game1.IsMasterGame) { return; } // save data string json = JsonConvert.SerializeObject(ModState.getModState()); ModEntry.GetMonitor().Log("Attempting to save mod data"); ModEntry.GetHelper().Data.WriteSaveData("data", json); }
public static void LoadMod() { if (!Game1.IsMasterGame) { return; } try { String data = ModEntry.GetHelper().Data.ReadSaveData <String>("data"); ModEntry.GetMonitor().Log("Attempting to load mod data"); ModState state = JsonConvert.DeserializeObject <ModState>(data); } catch (Exception e) { ModEntry.GetMonitor().Log(e.Message); } }
private void AfterSaveLoad(object sender, SaveLoadedEventArgs e) { ModState.LoadMod(); VoidshroomTree.ReplaceAll(); }