Example #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);
            }
        }
Example #2
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());
        }
Example #3
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);
        }