示例#1
0
        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);
            }
        }
示例#2
0
        //private static bool savingInProgress = false;

        private void OnSave(object sender, SavingEventArgs e)
        {
            VoidshroomTree.RemovalAll();
            //CaveCarrot.RemoveAll();
            ModState.visitedMineshafts.Clear();
            ModState.SaveMod();
        }
示例#3
0
        public static ModState getModState()
        {
            if (thisModState == null)
            {
                thisModState = new ModState();
            }

            return(thisModState);
        }
示例#4
0
 private void OnSave(object sender, SavingEventArgs e)
 {
     if (!savingInProgress)
     {
         savingInProgress = true;
         VoidshroomTree.RemovalAll();
         ModState.visitedMineshafts.Clear();
         ModState.SaveMod();
         savingInProgress = false;
     }
 }
示例#5
0
        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());
        }
示例#6
0
        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);
        }
示例#7
0
        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);
            }
        }
示例#8
0
 private void AfterSaveLoad(object sender, SaveLoadedEventArgs e)
 {
     ModState.LoadMod();
     VoidshroomTree.ReplaceAll();
 }