예제 #1
0
 private void Events_KeyPressed(object sender, EventArgsKeyPressed e)
 {
     if (e.KeyPressed == Microsoft.Xna.Framework.Input.Keys.I)
     {
         if (Game1.hasLoadedGame && Game1.activeClickableMenu == null && Game1.player.CanMove && !Game1.dialogueUp && !Game1.eventUp)
         {
             ItemMenu.Open();
         }
     }
 }
예제 #2
0
        /*********
        ** Public methods
        *********/
        public ItemMenu(int tabIndex, int sortID, ItemQuality quality)
            : base(null, true, true, 0, -50)
        {
            this.MovePosition(110, Game1.viewport.Height / 2 - (650 + IClickableMenu.borderWidth * 2) / 2);
            this.TabIndex = tabIndex;
            this.SortID   = sortID;
            this.Quality  = quality;

            this.Textbox          = new TextBox(null, null, Game1.dialogueFont, Game1.textColor);
            this.Textbox.X        = Game1.viewport.Width / 2 - Game1.tileSize * 3;
            this.Textbox.Y        = Game1.viewport.Height / 2;
            this.Textbox.Width    = Game1.tileSize * 8;
            this.Textbox.Height   = Game1.tileSize * 3;
            this.Textbox.X        = this.xPositionOnScreen + (width / 2) - (this.Textbox.Width / 2) - Game1.tileSize + 32;
            this.Textbox.Y        = this.yPositionOnScreen + (height / 2) + Game1.tileSize * 2 + 40;
            this.Textbox.Selected = false;
            this.Textbox.Text     = this.TempText;
            Game1.keyboardDispatcher.Subscriber = this.Textbox;
            this.TextboxBounds = new Rectangle(this.Textbox.X, this.Textbox.Y, this.Textbox.Width, this.Textbox.Height / 3);

            this.Title         = new ClickableComponent(new Rectangle(this.xPositionOnScreen + width - Game1.tileSize, this.yPositionOnScreen - Game1.tileSize * 2, Game1.tileSize * 4, Game1.tileSize), "CJB Item Spawner");
            this.SortButton    = new ClickableComponent(new Rectangle(this.xPositionOnScreen, this.yPositionOnScreen - Game1.tileSize * 2 + 10, Game1.tileSize * 4, Game1.tileSize), "Sort By: Name");
            this.QualityButton = new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 4, this.yPositionOnScreen - Game1.tileSize * 2 + 10, Game1.tileSize * 4, Game1.tileSize), "Quality");
            this.UpArrow       = new ClickableTextureComponent("up-arrow", new Rectangle(this.xPositionOnScreen + width - Game1.tileSize / 2, this.yPositionOnScreen - Game1.tileSize, 11 * Game1.pixelZoom, 12 * Game1.pixelZoom), "", "", Game1.mouseCursors, new Rectangle(421, 459, 11, 12), Game1.pixelZoom);
            this.DownArrow     = new ClickableTextureComponent("down-arrow", new Rectangle(this.xPositionOnScreen + width - Game1.tileSize / 2, this.yPositionOnScreen + height / 2 - Game1.tileSize * 2, 11 * Game1.pixelZoom, 12 * Game1.pixelZoom), "", "", Game1.mouseCursors, new Rectangle(421, 472, 11, 12), Game1.pixelZoom);

            {
                int i = -1;

                int x         = (int)(this.xPositionOnScreen - Game1.tileSize * 5.3f);
                int y         = this.yPositionOnScreen + 10;
                int lblHeight = (int)(Game1.tileSize * 0.9F);

                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), "All"));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), "Tools & Equipment"));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), "Seeds & Crops"));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), "Fish & Bait & Trash"));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), "Forage & Fruits"));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), "Artifacts & Minerals"));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), "Resources & Crafting"));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), "Artisan & Cooking"));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), "Animal & Monster"));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), "Decorating"));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i, Game1.tileSize * 5, Game1.tileSize), "Misc"));
            }

            if (!ItemMenu.ItemsLoaded)
            {
                ItemMenu.LoadItems();
            }

            this.AllowRightClick = true;
            this.Inventory.ShowGrayedOutSlots = true;

            switch (this.SortID)
            {
            case 0:
                this.SortButton.name = "Sort By: Name";
                break;

            case 1:
                this.SortButton.name = "Sort By: Category";
                break;

            case 2:
                this.SortButton.name = "Sort By: ID";
                break;
            }

            this.LoadInventory();
        }
예제 #3
0
        private static void LoadItems()
        {
            ItemMenu.ItemsLoaded = true;
            ItemMenu.ItemList    = new List <Item>
            {
                ToolFactory.getToolFromDescription(0, 0),
                ToolFactory.getToolFromDescription(0, 1),
                ToolFactory.getToolFromDescription(0, 2),
                ToolFactory.getToolFromDescription(0, 3),
                ToolFactory.getToolFromDescription(0, 4),
                ToolFactory.getToolFromDescription(1, 0),
                ToolFactory.getToolFromDescription(1, 1),
                ToolFactory.getToolFromDescription(1, 2),
                ToolFactory.getToolFromDescription(1, 3),
                ToolFactory.getToolFromDescription(1, 4),
                ToolFactory.getToolFromDescription(2, 0),
                ToolFactory.getToolFromDescription(2, 1),
                ToolFactory.getToolFromDescription(2, 2),
                ToolFactory.getToolFromDescription(2, 3),
                ToolFactory.getToolFromDescription(3, 0),
                ToolFactory.getToolFromDescription(3, 1),
                ToolFactory.getToolFromDescription(3, 2),
                ToolFactory.getToolFromDescription(3, 3),
                ToolFactory.getToolFromDescription(3, 4),
                ToolFactory.getToolFromDescription(4, 0),
                ToolFactory.getToolFromDescription(4, 1),
                ToolFactory.getToolFromDescription(4, 2),
                ToolFactory.getToolFromDescription(4, 3),
                ToolFactory.getToolFromDescription(4, 4),
                new MilkPail(),
                new Shears(),
                new Pan()
            };

            foreach (KeyValuePair <string, string> o in CraftingRecipe.craftingRecipes)
            {
                CraftingRecipe rec  = new CraftingRecipe(o.Key, false);
                Item           item = rec.createItem();
                if (item != null)
                {
                    ItemMenu.ItemList.Add(item);
                }
            }

            for (int i = 0; i < 112; i++)
            {
                ItemMenu.ItemList.Add(new Wallpaper(i)
                {
                    category = -24
                });
            }

            for (int i = 0; i < 40; i++)
            {
                ItemMenu.ItemList.Add(new Wallpaper(i, true)
                {
                    category = -24
                });
            }

            foreach (KeyValuePair <int, string> o in Game1.content.Load <Dictionary <int, string> >("Data\\Boots"))
            {
                Item item = new Boots(o.Key);
                ItemMenu.ItemList.Add(item);
            }

            foreach (KeyValuePair <int, string> o in Game1.content.Load <Dictionary <int, string> >("Data\\hats"))
            {
                Item item = new Hat(o.Key);
                ItemMenu.ItemList.Add(item);
            }

            foreach (KeyValuePair <int, string> o in Game1.content.Load <Dictionary <int, string> >("Data\\Furniture"))
            {
                Item item = new Furniture(o.Key, Vector2.Zero);

                if (o.Key == 1466 || o.Key == 1468)
                {
                    item = new TV(o.Key, Vector2.Zero);
                }
                ItemMenu.ItemList.Add(item);
            }

            foreach (KeyValuePair <int, string> o in Game1.content.Load <Dictionary <int, string> >("Data\\weapons"))
            {
                Item item = new MeleeWeapon(o.Key);

                if (o.Key >= 32 && o.Key <= 34)
                {
                    item = new Slingshot(o.Key);
                }

                ItemMenu.ItemList.Add(item);
            }

            foreach (KeyValuePair <int, string> o in Game1.content.Load <Dictionary <int, string> >("Data\\Fish"))
            {
                Item item = new SObject(o.Key, 999);
                item.category = -4;
                ItemMenu.ItemList.Add(item);
            }

            foreach (KeyValuePair <int, string> o in Game1.bigCraftablesInformation)
            {
                if (ItemMenu.HasItem(o.Key, o.Value.Split('/')[0]))
                {
                    continue;
                }

                ItemMenu.ItemList.Add(new SObject(Vector2.Zero, o.Key));
            }

            foreach (KeyValuePair <int, string> o in Game1.objectInformation)
            {
                if (ItemMenu.HasItem(o.Key, o.Value.Split('/')[0]))
                {
                    continue;
                }

                string[] info = o.Value.Split('/');
                if (info.Length >= 3)
                {
                    if (info[3].StartsWith("Ring"))
                    {
                        ItemMenu.ItemList.Add(new Ring(o.Key));
                        continue;
                    }
                    SObject item = new SObject(o.Key, 1);
                    ItemMenu.ItemList.Add(item);

                    if (item.category == -79)
                    {
                        ItemMenu.ItemList.Add(new SObject(Vector2.Zero, 348, item.Name + " Wine", false, true, false, false)
                        {
                            name  = item.Name + " Wine",
                            price = item.price * 3
                        });
                    }
                    if (item.category == -75)
                    {
                        ItemMenu.ItemList.Add(new SObject(Vector2.Zero, 350, item.Name + " Juice", false, true, false, false)
                        {
                            name  = item.Name + " Juice",
                            price = (int)(item.price * 2.25d)
                        });
                    }

                    if (item.category == -79)
                    {
                        ItemMenu.ItemList.Add(new SObject(Vector2.Zero, 344, item.Name + " Jelly", false, true, false, false)
                        {
                            name  = item.Name + " Jelly",
                            price = 50 + item.Price * 2
                        });
                    }
                    if (item.category == -75)
                    {
                        ItemMenu.ItemList.Add(new SObject(Vector2.Zero, 342, "Pickled " + item.Name, false, true, false, false)
                        {
                            name  = "Pickled " + item.Name,
                            price = 50 + item.Price * 2
                        });
                    }
                }
            }
        }