Esempio n. 1
0
        public override void Entry(IModHelper helper)
        {
            instance = this;

            SaveEvents.AfterLoad          += this.SaveEvents_AfterLoad;
            SaveEvents.BeforeSave         += this.SaveEvents_BeforeSave;
            SaveEvents.AfterSave          += this.SaveEvents_AfterSave;
            MenuEvents.MenuChanged        += this.MenuEvents_MenuChanged;
            PlayerEvents.InventoryChanged += this.PlayerEvents_InventoryChanged;
            this.Config = this.Helper.ReadConfig <ModConfig>();
            ItemFrameMod.itemFrameDatum = this.Helper.ReadJsonFile <List <ItemFrameData> >("data/frames.json");
            this.itemFrameDict          = new Dictionary <string, ItemFrameData>();
            foreach (ItemFrameData ifd in itemFrameDatum)
            {
                ifd.texture = this.Helper.Content.Load <Texture2D>(ifd.textureFile, ContentSource.ModFolder);
                ifd.id      = nextID;
                nextID     += (int)(ifd.texture.Width / 16);
                //Skip a row to leave room for 32px high textures
                if (nextID % 32 == 0 || nextID % 32 == 31)
                {
                    nextID += 32;
                }
                if (ifd.displayItems.Count != 0)
                {
                    ifd.displayName = $"ItemFrame{ifd.displayName}";
                    this.itemFrameDict[$"'{ifd.displayName}'"] = ifd;
                }
            }
            this.Monitor.Log(String.Join <string>(",", this.itemFrameDict.Keys));
        }
Esempio n. 2
0
 private void ConvertItemFrames()
 {
     foreach (GameLocation location in ItemFrameMod.GetLocations())
     {
         foreach (StardewValley.Object o in location.objects.Values)
         {
             if (o is Chest chest)
             {
                 for (int i = 0; i < chest.items.Count; i++)
                 {
                     if (chest.items[i] is ItemFrame frame)
                     {
                         chest.items[i] = frame.asFurniture();
                     }
                 }
             }
         }
         if (location is StardewValley.Locations.DecoratableLocation decoLoc)
         {
             for (int i = 0; i < decoLoc.furniture.Count; i++)
             {
                 if (decoLoc.furniture[i] is ItemFrame frame)
                 {
                     decoLoc.furniture[i] = frame.asFurniture();
                 }
             }
         }
     }
     for (int i = 0; i < Game1.player.items.Count; i++)
     {
         if (Game1.player.items[i] is ItemFrame frame)
         {
             Game1.player.items[i] = frame.asFurniture();
         }
     }
 }
Esempio n. 3
0
 private void RestoreItemFrames()
 {
     foreach (GameLocation location in ItemFrameMod.GetLocations())
     {
         foreach (StardewValley.Object o in location.objects.Values)
         {
             if (o is Chest chest)
             {
                 for (int i = 0; i < chest.items.Count; i++)
                 {
                     if (chest.items[i] is Furniture furniture2 && this.itemFrameDict.ContainsKey(furniture2.Name))
                     {
                         chest.items[i] = this.restoreFrame(furniture2);
                     }
                 }
             }
         }
         if (location is StardewValley.Locations.DecoratableLocation decoLoc)
         {
             for (int i = 0; i < decoLoc.furniture.Count; i++)
             {
                 if (this.itemFrameDict.ContainsKey(decoLoc.furniture[i].Name))
                 {
                     decoLoc.furniture[i] = this.restoreFrame(decoLoc.furniture[i]);
                 }
             }
         }
     }
     for (int i = 0; i < Game1.player.items.Count; i++)
     {
         if (Game1.player.items[i] is Furniture furniture && this.itemFrameDict.ContainsKey(furniture.Name))
         {
             Game1.player.items[i] = this.restoreFrame(furniture);
         }
     }
 }