private void LoadInventory() { List <Item> items = ItemMenu.ItemList.OrderBy(o => o.Name).ToList(); switch (this.SortID) { case 1: items = ItemMenu.ItemList.OrderBy(o => o.category).ToList(); break; case 2: items = ItemMenu.ItemList.OrderBy(o => o.parentSheetIndex).ToList(); break; } this.InventoryItems.Clear(); foreach (Item item in items) { item.Stack = item.maximumStackSize(); if (item is SObject obj) { obj.quality = (int)this.Quality; } if (this.IsCategoryAllowed(item) && item.Name.ToLower().Contains(this.Textbox.Text.ToLower())) { this.InventoryItems.Add(item); } } this.ItemsToGrabMenu = new ItemInventoryMenu(this.xPositionOnScreen + Game1.tileSize / 2, this.yPositionOnScreen, false, this.InventoryItems); }
/********* ** Public methods *********/ public ItemMenuWithInventory(InventoryMenu.highlightThisItem highlighterMethod = null, bool okButton = false, bool trashCan = false, int inventoryXOffset = 0, int inventoryYOffset = 0) : base(Game1.viewport.Width / 2 - (800 + IClickableMenu.borderWidth * 2) / 2, Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2, 800 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2) { if (this.yPositionOnScreen < IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder) { this.yPositionOnScreen = IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder; } if (this.xPositionOnScreen < 0) { this.xPositionOnScreen = 0; } this.InventoryYOffset = inventoryYOffset; int yPosition = this.yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth + Game1.tileSize * 3 - Game1.tileSize / 4 + inventoryYOffset; this.Inventory = new ItemInventoryMenu(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth / 2 + inventoryXOffset, yPosition, false, null, highlighterMethod); if (okButton) { this.OkButton = new ClickableTextureComponent("ok-button", new Rectangle(this.xPositionOnScreen + this.width + 4, this.yPositionOnScreen + this.height - Game1.tileSize * 3 - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), "", "", Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46), 1f); } if (!trashCan) { return; } this.TrashCan = new ClickableTextureComponent("trashcan", new Rectangle(this.xPositionOnScreen + this.width + 4, this.yPositionOnScreen + this.height - Game1.tileSize * 3 - Game1.tileSize / 2 - IClickableMenu.borderWidth - 104, Game1.tileSize, 104), "", "", Game1.mouseCursors, new Rectangle(669, 261, 16, 26), Game1.pixelZoom); }
private void loadInventory() { List <Item> tempItems = itemList.OrderBy(o => o.Name).ToList(); switch (sortID) { case 1: tempItems = itemList.OrderBy(o => o.category).ToList(); break; case 2: tempItems = itemList.OrderBy(o => o.parentSheetIndex).ToList(); break; } this.inventoryItems.Clear(); foreach (Item item in tempItems) { item.Stack = item.maximumStackSize(); if (item is StardewValley.Object) { ((StardewValley.Object)item).quality = quality; } if (isCategoryAllowed(item) && item.Name.ToLower().Contains(this.textBox.Text.ToLower())) { this.inventoryItems.Add(item); } } this.ItemsToGrabMenu = new ItemInventoryMenu(this.xPositionOnScreen + Game1.tileSize / 2, this.yPositionOnScreen, false, this.inventoryItems, null, -1, 3, 0, 0, true); }
public Item LeftClick(int x, int y, Item toPlace, bool playSound = true) { foreach (ClickableComponent clickableComponent in this.Inventory) { if (clickableComponent.containsPoint(x, y)) { int index = Convert.ToInt32(clickableComponent.name); if (!this.PlayerInventory) { index = this.Capacity / this.Rows * ItemInventoryMenu.ScrollIndex + index; } if (index < this.ActualInventory.Count && (this.ActualInventory[index] == null || this.HighlightMethod(this.ActualInventory[index]) || this.ActualInventory[index].canStackWith(toPlace))) { if (this.ActualInventory[index] != null) { if (toPlace != null) { if (playSound) { Game1.playSound("stoneStep"); } return(ItemInventoryMenu.AddItemToInventory(toPlace, index, this.ActualInventory)); } if (playSound) { Game1.playSound("dwop"); } return(ItemInventoryMenu.RemoveItemFromInventory(index, this.ActualInventory)); } if (toPlace != null) { if (playSound) { Game1.playSound("stoneStep"); } return(ItemInventoryMenu.AddItemToInventory(toPlace, index, this.ActualInventory)); } } } } return(toPlace); }
public override void gameWindowSizeChanged(Rectangle oldBounds, Rectangle newBounds) { base.gameWindowSizeChanged(oldBounds, newBounds); if (this.yPositionOnScreen < IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder) { this.yPositionOnScreen = IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder; } if (this.xPositionOnScreen < 0) { this.xPositionOnScreen = 0; } int yPosition = this.yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth + Game1.tileSize * 3 - Game1.tileSize / 4; this.Inventory = new ItemInventoryMenu(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth / 2, yPosition, false, null, this.Inventory.HighlightMethod); if (this.OkButton != null) { this.OkButton = new ClickableTextureComponent("ok-button", new Rectangle(this.xPositionOnScreen + this.width + 4, this.yPositionOnScreen + this.height - Game1.tileSize * 3 - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), "", "", Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46), 1f); } if (this.TrashCan == null) { return; } this.TrashCan = new ClickableTextureComponent("trashcan", new Rectangle(this.xPositionOnScreen + this.width + 4, this.yPositionOnScreen + this.height - Game1.tileSize * 3 - Game1.tileSize / 2 - IClickableMenu.borderWidth - 104, Game1.tileSize, 104), "", "", Game1.mouseCursors, new Rectangle(669, 261, 16, 26), Game1.pixelZoom); }