private void InitializeDefaults()
        {
            this.BagTypes = new List <BagType>()
            {
                BagTypeFactory.GetGemBagType(),
                    BagTypeFactory.GetSmithingBagType(),
                    BagTypeFactory.GetMineralBagType(),
                    BagTypeFactory.GetMiningBagType(),
                    BagTypeFactory.GetResourceBagType(),
                    BagTypeFactory.GetConstructionBagType(),
                    BagTypeFactory.GetTreeBagType(),
                    BagTypeFactory.GetAnimalProductBagType(),
                    BagTypeFactory.GetRecycleBagType(),
                    BagTypeFactory.GetLootBagType(),
                    BagTypeFactory.GetForagingBagType(),
                    BagTypeFactory.GetArtifactBagType(),
                    BagTypeFactory.GetSeedBagType(),
                    BagTypeFactory.GetOceanFishBagType(),
                    BagTypeFactory.GetRiverFishBagType(),
                    BagTypeFactory.GetLakeFishBagType(),
                    BagTypeFactory.GetMiscFishBagType(),
                    BagTypeFactory.GetFishBagType(),
                    BagTypeFactory.GetFarmerBagType(),
                    BagTypeFactory.GetFoodBagType(),
                    BagTypeFactory.GetCropBagType()
            };

            //this.CreatedByVersion = ItemBagsMod.CurrentVersion;

            AfterLoaded();
        }
 internal BagType GetBagTypePlaceholder()
 {
     return(new BagType()
     {
         Id = Guid,
         Name = BagName,
         Description = BagDescription,
         IconSourceTexture = IconTexture,
         IconSourceRect = IconPosition,
         SizeSettings = AllSizes.Select(x => new BagSizeConfig()
         {
             Size = x,
             MenuOptions = MenuOptions[x],
             Price = Prices[x],
             Sellers = Sellers[x],
             CapacityMultiplier = BagTypeFactory.GetCapacityMultiplier(x, Capacities[x]),
             Items = new List <StoreableBagItem>()
         }).ToArray()
     });
 }
        private static void LoadGlobalConfig()
        {
            BagConfig GlobalBagConfig = ModInstance.Helper.Data.ReadGlobalData <BagConfig>(BagConfigDataKey);

#if DEBUG
            //GlobalBagConfig = null; // force full re-creation of types for testing
#endif
            if (GlobalBagConfig != null)
            {
                bool RewriteConfig = false;

                //  Update the config with new Bag Types that were added in later versions
                if (GlobalBagConfig.CreatedByVersion == null)
                {
                    GlobalBagConfig.EnsureBagTypesExist(
                        BagTypeFactory.GetOceanFishBagType(),
                        BagTypeFactory.GetRiverFishBagType(),
                        BagTypeFactory.GetLakeFishBagType(),
                        BagTypeFactory.GetMiscFishBagType()
                        );
                    RewriteConfig = true;
                }
                if (GlobalBagConfig.CreatedByVersion == null || GlobalBagConfig.CreatedByVersion < new Version(1, 2, 4))
                {
                    if (Constants.TargetPlatform != GamePlatform.Android)
                    {
                        GlobalBagConfig.EnsureBagTypesExist(BagTypeFactory.GetFishBagType());
                        RewriteConfig = true;
                    }
                }
                if (GlobalBagConfig.CreatedByVersion == null || GlobalBagConfig.CreatedByVersion < new Version(1, 3, 1))
                {
                    GlobalBagConfig.EnsureBagTypesExist(
                        BagTypeFactory.GetFarmerBagType(),
                        BagTypeFactory.GetFoodBagType()
                        );
                    RewriteConfig = true;
                }
                if (GlobalBagConfig.CreatedByVersion == null || GlobalBagConfig.CreatedByVersion < new Version(1, 3, 3))
                {
                    GlobalBagConfig.EnsureBagTypesExist(BagTypeFactory.GetCropBagType());
                    RewriteConfig = true;
                }
                if (GlobalBagConfig.CreatedByVersion == null || GlobalBagConfig.CreatedByVersion < new Version(1, 4, 6))
                {
                    //  I was accidentally serializing BagConfig.IndexedBagTypes which doubled the file size. Whatever, doesn't really matter since it's a small file
                    RewriteConfig = true;

                    //  Lots of rebalancing happened in v1.4.6, so completely remake the config but save a backup copy of the existing file in case user manually edited it
                    ModInstance.Helper.Data.WriteGlobalData(BagConfigDataKey + "-backup_before_v1.4.6_update", GlobalBagConfig);
                    GlobalBagConfig = new BagConfig()
                    {
                        CreatedByVersion = CurrentVersion
                    };
                }
                if (GlobalBagConfig.CreatedByVersion == null || GlobalBagConfig.CreatedByVersion < new Version(1, 5, 2))
                {
                    RewriteConfig = true;
                    //  Added numerous new items from the Stardew Valley 1.5 update to existing bag types
                    ModInstance.Helper.Data.WriteGlobalData(BagConfigDataKey + "-backup_before_v1.5.2_update", GlobalBagConfig);
                    GlobalBagConfig = new BagConfig()
                    {
                        CreatedByVersion = CurrentVersion
                    };
                }

                //  Suppose you just added a new BagType "Scarecrow Bag" to version 1.0.12
                //  Then keep the BagConfig up-to-date by doing:

                /*if (GlobalBagConfig.CreatedByVersion == null || GlobalBagConfig.CreatedByVersion < new Version(1, 0, 12))
                 * {
                 *  GlobalBagConfig.EnsureBagTypesExist(
                 *      BagTypeFactory.GetScarecrowBagType()
                 *  );
                 *  ChangesMade = true;
                 * }*/
                //  Would also need to add more entries to the i18n/default.json and other translation files

                if (RewriteConfig)
                {
                    GlobalBagConfig.CreatedByVersion = CurrentVersion;
                    ModInstance.Helper.Data.WriteGlobalData(BagConfigDataKey, GlobalBagConfig);
                }
            }
            else
            {
                GlobalBagConfig = new BagConfig()
                {
                    CreatedByVersion = CurrentVersion
                };
                ModInstance.Helper.Data.WriteGlobalData(BagConfigDataKey, GlobalBagConfig);
            }
            BagConfig = GlobalBagConfig;
        }