Ejemplo n.º 1
0
        private void GameLoop_Saving(object sender, StardewModdingAPI.Events.SavingEventArgs e)
        {
            ColorDictData dict = new ColorDictData();

            Monitor.Log($"writing recolor data for {colorDict.Count} locations from save");
            foreach (var kvp in colorDict)
            {
                Monitor.Log($"writing {kvp.Value.Count} recolors for location {kvp.Key} to save");
                dict.colorDict[kvp.Key] = new List <RecolorData>();
                foreach (var kvp2 in kvp.Value)
                {
                    dict.colorDict[kvp.Key].Add(kvp2.Value);
                }
            }
            Helper.Data.WriteSaveData(saveKey, dict);
        }
Ejemplo n.º 2
0
        private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e)
        {
            colorDict.Clear();
            try
            {
                ColorDictData colorDictData = Helper.Data.ReadSaveData <ColorDictData>(saveKey) ?? new ColorDictData();

                Monitor.Log($"reading recolor data for {colorDictData.colorDict.Count} locations from save");
                foreach (var kvp in colorDictData.colorDict)
                {
                    colorDict[kvp.Key] = new Dictionary <Vector2, RecolorData>();
                    Monitor.Log($"reading {kvp.Value.Count} recolors for location {kvp.Key}");
                    foreach (var kvp2 in kvp.Value)
                    {
                        colorDict[kvp.Key][new Vector2(kvp2.X, kvp2.Y)] = kvp2;
                    }
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Invalid color dict in save file... starting fresh. \n\n{ex}", LogLevel.Warn);
            }
        }