static public void AddIcon(InventoryPage page, string name, int x, int y, int id, int up, int down, int left, int right, Item item) { var rect = new Rectangle( page.xPositionOnScreen + 48 + x * 4, page.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 256 - 12 + y * 4, 64, 64 ); var component = new ClickableComponent(rect, name) { myID = id, downNeighborID = down, upNeighborID = up, rightNeighborID = right, leftNeighborID = left, item = item, fullyImmutable = true }; page.equipmentIcons.Add(component); }
void OnPage(int index) { if (index > 0) { pageIndices[0] = pageIndices[index]; for (int i = 1; i < pageIndices.Length; i++) { pageIndices[i] = (pageIndices[0] >= i) ? (i - 1) : i; } for (int i = 0; i < pages.Count; i++) { pageButtons[i].Image = "munt.raw?" + (5 + pages[pageIndices[i]].PageNumber); } activePageIndex = pageIndices[0]; activePage = pages[activePageIndex]; OnSelectPage(); } }
public ActionResult Index(int?storeId, FormCollection values) { string[] selectedProdcuts = values["Isinstore"].Split(','); string[] prodIdValues = values["productId"].Split(','); string[] AmountValues = values["Amount"].Split(','); for (int i = 0; i < prodIdValues.Length; i++) { int productId = int.Parse(prodIdValues[i]); bool isInStore = selectedProdcuts.Contains(productId.ToString()); int amount = int.Parse(AmountValues[i]); Helpers.InventoryHelper.UpdateInventoryProduct(productId, isInStore, amount, storeId.Value); } InventoryPage invPage = Helpers.InventoryHelper.GetInventoryPage(storeId); return(View(invPage)); }
/// <summary>The post fix for the <see cref="InventoryPage.draw(SpriteBatch)"/> method.</summary> /// <param name="b">The sprite batch to draw to.</param> /// <param name="__instance">The current <see cref="InventoryPage"/> instance being patched.</param> /// <remarks>This is used to draw the new outerwear slot.</remarks> internal static void DrawPostFix(SpriteBatch b, InventoryPage __instance) { var overwearEquipmentIcon = __instance.equipmentIcons.FirstOrDefault(icon => icon.name == "Outerwear"); var equippedOuterwear = ModEntry.Instance.Api.GetEquippedOuterwear(); if (equippedOuterwear != null) { // draw plain slot icon b.Draw( texture: Game1.menuTexture, destinationRectangle: overwearEquipmentIcon.bounds, sourceRectangle: Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 10, -1, -1), color: Color.White, rotation: 0, origin: new Vector2(0, 0), effects: SpriteEffects.None, layerDepth: 0 ); // draw outerwear on slot equippedOuterwear.drawInMenu(b, new Vector2(overwearEquipmentIcon.bounds.X, overwearEquipmentIcon.bounds.Y), overwearEquipmentIcon.scale); } else { // draw slot with the outerwear placeholder icon b.Draw( texture: ModEntry.Instance.OuterwearSlotPlaceholder, destinationRectangle: overwearEquipmentIcon.bounds, sourceRectangle: new Rectangle(0, 0, 64, 64), color: Color.White, rotation: 0, origin: new Vector2(0, 0), effects: SpriteEffects.None, layerDepth: 0 ); } // redraw the held item so it's drawn over the outerwear slot Game1.player.CursorSlotItem?.drawInMenu(b, new Vector2(Game1.getOldMouseX() + 16, Game1.getOldMouseY() + 16), 1f); }
void ChangePage() { var pageId = _getPage(); if (pageId == _lastPage) { return; } _lastPage = pageId; RemoveAllChildren(); IUiElement page = pageId switch { InventoryPage.Summary => new InventorySummaryPage(_activeCharacter), InventoryPage.Stats => new InventoryStatsPage(_activeCharacter), InventoryPage.Misc => new InventoryMiscPage(), { } x => throw new NotImplementedException($"Unhandled inventory page \"{x}\"") }; AttachChild(page); }
static public void AutoEquipment(InventoryPage page) { var helditem = Game1.player.CursorSlotItem; foreach (ClickableComponent icon in page.equipmentIcons) { if (icon.item != null) { continue; } if (icon.name == "Hat") { continue; } if (icon.name == "Boots") { continue; } EquipmentClick(icon); break; } }
//When InventoryPage constructed, create a new button public static void Constructor(InventoryPage inventoryPage, int x, int y, int width, int height) { ButtonHolder.inventoryPage = inventoryPage; button = new ClickableTextureComponent("", new Rectangle(inventoryPage.xPositionOnScreen + width, inventoryPage.yPositionOnScreen + height / 3 - 64 + 8 + 80, 64, 64), "", "Stack to nearby chests", ButtonIcon, Rectangle.Empty, 4f, false) { myID = buttonID, downNeighborID = 105, leftNeighborID = 11, upNeighborID = 106 }; inventoryPage.organizeButton.downNeighborID = buttonID; inventoryPage.trashCan.upNeighborID = buttonID; }
/// <summary> /// Create a new Inventory Page. Also, display the left and right navigation button as /// necessary so the player can get to this page when needed. /// </summary> /// <returns></returns> private InventoryPage CreatePage() { // Instantiate a new Page object GameObject newPage = (GameObject)Instantiate(pagePrefab, inventoryPagesParent); // Make sure its the parent of the Inventory //newPage.transform.SetParent(inventoryPagesParent, false); // Define all its needed references InventoryPage inventoryPage = newPage.GetComponent <InventoryPage>(); //totalPages++; int pageNum = totalPages; inventoryPage.SetPageIndex(pageNum); inventoryPage.eventSystem = eventSystem; inventoryPage.inventoryText = inventoryText; // add the the list inventoryPages.Insert(pageNum, inventoryPage); // Hide the page from the player inventoryPage.HidePage(); // Show the navigation buttons depending on the current page number if (currentPage.GetPageIndex() < inventoryPage.GetPageIndex()) { // Show the right button rightNavButton.SetActive(true); } if (inventoryPage.GetPageIndex() < currentPage.GetPageIndex()) { // Show the left button leftNavButton.SetActive(true); } totalPages++; return(inventoryPage); }
public static InventoryPage GetInventoryPage(int?storeId) { InventoryPage invPage = new InventoryPage(); StoreEntities db = new StoreEntities(); invPage.Stores = db.Stores.ToList(); if (storeId != null) { invPage.CurrentSelectedStore = db.Stores.Find(storeId); List <ProductStore> prodStores = db.ProductStores.Where(ps => ps.StoreId == storeId).ToList(); foreach (Product prod in db.Products) { InventoryProduct invProd = new InventoryProduct(prod); ProductStore prodStore = prodStores.Where(ps => ps.ProductId == invProd.Product.Id).FirstOrDefault(); if (prodStore == null) { invProd.IsInStore = false; invProd.AmountInStock = 0; } else { invProd.IsInStore = true; invProd.AmountInStock = prodStore.AmountInStock; } invPage.InventoryProducts.Add(invProd); } } return(invPage); }
public void Checkout() { LoginPage login = new LoginPage(_driver); login.LoginWithAValidCredential(); InventoryPage inventory = new InventoryPage(_driver); inventory.AddProductsToCart(); inventory.ClickOnCartIcon(); CartPage cart = new CartPage(_driver); cart.ClickOnCheckOutButton(); CheckOutYourInformationPage checkout = new CheckOutYourInformationPage(_driver); checkout.FillOutTheInformation("Name", "Last", "122345"); CheckOutOverview checkoutTwo = new CheckOutOverview(_driver); checkoutTwo.CheckOutLastStep(); }
/// <summary>The post fix for the <see cref="InventoryPage.performHoverAction(int, int)"/> method.</summary> /// <param name="x">The X position of the mouse.</param> /// <param name="y">The Y position of the mouse.</param> /// <param name="__instance">The current <see cref="InventoryPage"/> instance being patched.</param> /// <remarks>This is used to add the tool tip for hovering over the currently equipped outerwear.</remarks> internal static void PerformHoverActionPostFix(int x, int y, InventoryPage __instance) { // ensure the player is hovering on the outerwear slot var outerwearEqupimentIcon = __instance.equipmentIcons.FirstOrDefault(icon => icon.name == "Outerwear"); if (!outerwearEqupimentIcon.containsPoint(x, y)) { return; } // get the currently equipped outerwear var equippedOuterwear = ModEntry.Instance.Api.GetEquippedOuterwear(); if (equippedOuterwear == null) { return; } // set hover values for drawing tool tip typeof(InventoryPage).GetField("hoveredItem", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(__instance, equippedOuterwear); typeof(InventoryPage).GetField("hoverTitle", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(__instance, equippedOuterwear.DisplayName); typeof(InventoryPage).GetField("hoverText", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(__instance, equippedOuterwear.getDescription()); }
internal static bool Prefix(InventoryPage __instance, out bool __state, int x, int y, bool playSound = true) { __state = false; ClickableComponent hatComponent = __instance.equipmentIcons.First(s => s.name == "Hat"); if (hatComponent.containsPoint(x, y)) { bool heldItemWasNull = Game1.player.CursorSlotItem is null; if (!IsHeadphoneHeld()) { if (IsWearingMusicPlayer()) { if (heldItemWasNull || Game1.player.CursorSlotItem is Hat) { __state = true; } } return(true); } if (IsValidMusicPlayer(Game1.player.CursorSlotItem.Name)) { Hat tmp = (Hat)helper.Reflection.GetMethod(__instance, "takeHeldItem").Invoke <Item>(); Item heldItem = Game1.player.hat; heldItem = Utility.PerformSpecialItemGrabReplacement(heldItem); Game1.player.hat.Value = tmp; if (Game1.player.hat.Value != null) { Game1.playSound("grassyStep"); } else if (Game1.player.CursorSlotItem is null) { Game1.playSound("dwop"); } if (heldItem != null && !Game1.player.addItemToInventoryBool(heldItem, false)) { helper.Reflection.GetMethod(__instance, "setHeldItem").Invoke(heldItem); } ShowCorrectPrompt(); } if (!heldItemWasNull || Game1.player.CursorSlotItem is null || !Game1.oldKBState.IsKeyDown(Keys.LeftShift)) { return(false); } for (int l = 0; l < Game1.player.items.Count; l++) { if (Game1.player.items[l] == null || Game1.player.CursorSlotItem != null && Game1.player.items[l].canStackWith(Game1.player.CursorSlotItem)) { if (Game1.player.CurrentToolIndex == l && Game1.player.CursorSlotItem != null) { Game1.player.CursorSlotItem.actionWhenBeingHeld(Game1.player); } helper.Reflection.GetMethod(__instance, "setHeldItem").Invoke(Utility.addItemToInventory(helper.Reflection.GetMethod(__instance, "takeHeldItem").Invoke <Item>(), l, __instance.inventory.actualInventory)); if (Game1.player.CurrentToolIndex == l && Game1.player.CursorSlotItem != null) { Game1.player.CursorSlotItem.actionWhenStopBeingHeld(Game1.player); } Game1.playSound("stoneStep"); return(false); } } } if (IsSelectingHeadPhonesInInventory(__instance, x, y) && Game1.oldKBState.IsKeyDown(Keys.LeftShift)) { helper.Reflection.GetMethod(__instance, "setHeldItem").Invoke(__instance.inventory.leftClick(x, y, helper.Reflection.GetMethod(__instance, "takeHeldItem").Invoke <Item>(), !Game1.oldKBState.IsKeyDown(Keys.LeftShift))); if (Game1.player.CursorSlotItem != null && Game1.oldKBState.IsKeyDown(Keys.LeftShift)) { if (Game1.player.hat.Value == null) { Game1.player.hat.Value = helper.Reflection.GetMethod(__instance, "takeHeldItem").Invoke <Item>() as Hat; ShowCorrectPrompt(); return(false); } } } return(true); }
private void Start() { // Setups inventory = new List <Item>(); totalItems = 0; // Get the correct references // UI reference if (UI == null) { Debug.LogWarning("Inventory Class is missing a reference to the inventory UI."); return; } // inventory text reference if (inventoryText == null) { Debug.LogWarning("Inventory Class is missing a reference to the Inventory Text Handler"); return; } // EventSystem reference if (eventSystem == null) { Debug.LogWarning("Inventory Class is missing a reference to the Event System that manages it."); return; } // Find the list of Slots in the inventory UI // Get to the object that has the list of Pages Transform menu = UI.transform.Find("Menu"); if (menu == null) { Debug.LogWarning("Inventory Class cannot find the Main Area.", menu); return; } // Get references to the navigation buttons Transform c = menu.transform.GetChild(2); leftNavButton = c.gameObject; c = menu.transform.GetChild(3); rightNavButton = c.gameObject; // Make sure to turn them off leftNavButton.SetActive(false); rightNavButton.SetActive(false); // Get the reference to the inventory Transform inven = menu.transform.Find("Inventory"); if (inven == null) { Debug.LogWarning("Inventory Class cannot find the Slots Area.", inven); return; } // Get all the Pages that currently exist int numPages = inven.childCount; inventoryPagesParent = inven; inventoryPages = new List <InventoryPage>(); for (int i = 0; i < numPages; i++) { // Loop through the slots area for the pages Transform child = inven.GetChild(i); InventoryPage inventoryPageComp = child.GetComponent <InventoryPage>(); if (inventoryPageComp == null) { Debug.LogWarning("Inventory Page object is missing an InventoryPage component.", child); } // Add the pages to the inventoryPages list inventoryPages.Add(inventoryPageComp); // Make sure the page has its passed down references inventoryPageComp.SetPageIndex(i); inventoryPageComp.eventSystem = eventSystem; inventoryPageComp.inventoryText = inventoryText; totalPages++; } // Set the first page as the current page currentPage = inventoryPages[0]; inventoryText.SetPageNumber(0, totalPages); // See if we need to display the buttons if (totalPages > 1) { rightNavButton.SetActive(true); } // Get the reference to the page prefab pagePrefab = Resources.Load <GameObject>("Prefabs/InventoryPage"); // Make sure to hide the inventory when done HideInventory(); // Done! Debug.Log("Successfully Init Inventory"); }
static public void AddEquipmentIcons(InventoryPage page) { for (int i = 0; i < EquipmentIcons.Length; i++) { int x = i / 4; int y = i % 4; string name = EquipmentIcons[i]; var rect = new Rectangle( page.xPositionOnScreen + 48 + x * 64, page.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 256 - 12 + y * 64, 64, 64 ); // Get the item that should be in this slot. Item item = null; if (x == 0) { if (y == 0) { item = Game1.player.hat.Value; } if (y == 1) { item = Game1.player.leftRing.Value; } if (y == 2) { item = Game1.player.rightRing.Value; } if (y == 3) { item = Game1.player.boots.Value; } } else { ActualRings ar = actualdata.GetValue(Game1.player, FarmerNotFound); if (y == 0) { item = ar.ring1.Value; } if (y == 1) { item = ar.ring2.Value; } if (y == 2) { item = ar.ring3.Value; } if (y == 3) { item = ar.ring4.Value; } } // Create the GUI element. int id = 101 + 10 * x + y; var component = new ClickableComponent(rect, name) { myID = id, downNeighborID = y < 3 ? id + 1 : -1, upNeighborID = y == 0 ? Game1.player.MaxItems - 12 + x : id - 1, upNeighborImmutable = y == 0, rightNeighborID = x == 0 ? id + 10 : 105, leftNeighborID = x == 0 ? -1 : id - 10, item = item }; page.equipmentIcons.Add(component); } }
private static void Input_ButtonPressed(object sender, ButtonPressedEventArgs e) { try { Point CursorPos = e.Cursor.ScreenPixels.AsAndroidCompatibleCursorPoint(); bool IsGamepadInput = e.Button.TryGetController(out Buttons GamepadButtons); if (Game1.activeClickableMenu != null && Game1.activeClickableMenu is ItemBagMenu IBM) { if (e.Button == SButton.MouseLeft || e.Button == SButton.MouseMiddle || e.Button == SButton.MouseRight) { try { IBM.OnMouseButtonPressed(e); } catch (Exception ex) { Monitor.Log(string.Format("Unhandled error while handling Mouse button pressed: {0}\n\n{1}", ex.Message, ex.ToString()), LogLevel.Error); } } else if (e.Button == SButton.LeftShift || e.Button == SButton.RightShift || e.Button == SButton.LeftControl || e.Button == SButton.RightControl) { try { IBM.OnModifierKeyPressed(e); } catch (Exception ex) { Monitor.Log(string.Format("Unhandled error while handling Modifier key pressed: {0}\n\n{1}", ex.Message, ex.ToString()), LogLevel.Error); } } else if (IsGamepadInput) { try { // Handle navigation buttons foreach (NavigationDirection Direction in Enum.GetValues(typeof(NavigationDirection)).Cast <NavigationDirection>()) { if (GamepadControls.IsMatch(GamepadButtons, GamepadControls.NavigateSingleButtons[Direction])) { NavigationButtonsPressedTime[Direction] = DateTime.Now; } } IBM.OnGamepadButtonsPressed(GamepadButtons); } catch (Exception ex) { Monitor.Log(string.Format("Unhandled error while handling Gamepad button pressed: {0}\n\n{1}", ex.Message, ex.ToString()), LogLevel.Error); } } } else if (Game1.activeClickableMenu != null && Game1.activeClickableMenu is GameMenu GM && GM.currentTab == GameMenu.inventoryTab) { InventoryPage InvPage = GM.pages.First(x => x is InventoryPage) as InventoryPage; InventoryMenu InvMenu = InvPage.inventory; int ClickedItemIndex = InvMenu.getInventoryPositionOfClick(CursorPos.X, CursorPos.Y); bool IsValidInventorySlot = ClickedItemIndex >= 0 && ClickedItemIndex < InvMenu.actualInventory.Count; if (IsValidInventorySlot) { Item ClickedItem = InvMenu.actualInventory[ClickedItemIndex]; // Double click an ItemBag to open it if (e.Button == SButton.MouseLeft) //SButtonExtensions.IsUseToolButton(e.Button)) { // The first time the user clicks an item in their inventory, Game1.player.CursorSlotItem is set to what they clicked (so it's like drag/drop, they're now holding the item to move it) // So to detect a double click, we can't just check if they clicked the bag twice in a row, since on the second click the item would no longer be in their inventory. // Instead, we need to check if they clicked the bag and then we need to check Game1.player.CursorSlotItem on the next click if (ClickedItem is ItemBag ClickedBag && Game1.player.CursorSlotItem == null) { LastClickedBagInventoryIndex = ClickedItemIndex; LastClickedBag = ClickedBag; LastClickedBagTime = DateTime.Now; } else if (ClickedItem == null && Game1.player.CursorSlotItem is ItemBag DraggedBag && LastClickedBag == DraggedBag && LastClickedBagInventoryIndex.HasValue && LastClickedBagInventoryIndex.Value == ClickedItemIndex && LastClickedBagTime.HasValue && DateTime.Now.Subtract(LastClickedBagTime.Value).TotalMilliseconds <= DoubleClickThresholdMS) { LastClickedBag = DraggedBag; LastClickedBagTime = DateTime.Now; // Put the item that's being dragged back into their inventory Game1.player.addItemToInventory(Game1.player.CursorSlotItem, ClickedItemIndex); Game1.player.CursorSlotItem = null; DraggedBag.OpenContents(Game1.player.Items, Game1.player.MaxItems); } } // Right-click an ItemBag to open it else if ((e.Button == SButton.MouseRight || (IsGamepadInput && GamepadControls.IsMatch(GamepadButtons, GamepadControls.Current.OpenBagFromInventory))) && ClickedItem is ItemBag ClickedBag && Game1.player.CursorSlotItem == null) { ClickedBag.OpenContents(Game1.player.Items, Game1.player.MaxItems); } // Handle dropping an item into a bag from the Inventory menu if (ClickedItem is ItemBag IB && Game1.player.CursorSlotItem != null && Game1.player.CursorSlotItem is Object Obj) { if (IB.IsValidBagItem(Obj) && (e.Button == SButton.MouseLeft || e.Button == SButton.MouseRight)) { int Qty = ItemBag.GetQuantityToTransfer(e, Obj); IB.MoveToBag(Obj, Qty, out int MovedQty, true, Game1.player.Items); if (e.Button == SButton.MouseLeft) // || (MovedQty > 0 && Obj.Stack == 0) // Handle moving the last quantity with a right-click { // Clicking the bag will have made it become the held CursorSlotItem, so queue up an action that will swap them back on next game tick QueueCursorSlotIndex = ClickedItemIndex; QueuePlaceCursorSlotItem = true; } } } } } else if (Game1.activeClickableMenu == null && (e.Button == SButton.MouseLeft || e.Button == SButton.MouseRight || (IsGamepadInput && GamepadControls.IsMatch(GamepadButtons, GamepadControls.Current.OpenBagFromToolbar)))) { // Check if they clicked a bag on the toolbar, open the bag if so Toolbar toolbar = Game1.onScreenMenus.FirstOrDefault(x => x is Toolbar) as Toolbar; if (toolbar != null) { try { List <ClickableComponent> toolbarButtons = typeof(Toolbar).GetField("buttons", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(toolbar) as List <ClickableComponent>; if (toolbarButtons != null) { // Find the slot on the toolbar that they clicked, if any for (int i = 0; i < toolbarButtons.Count; i++) { if (toolbarButtons[i].bounds.Contains(CursorPos) || (IsGamepadInput && toolbar.currentlySnappedComponent == toolbarButtons[i])) { int ActualIndex = i; if (Constants.TargetPlatform == GamePlatform.Android) { try { int StartIndex = Helper.Reflection.GetField <int>(toolbar, "_drawStartIndex").GetValue(); // This is completely untested ActualIndex = i + StartIndex; } catch (Exception) { } } // Get the corresponding Item from the player's inventory Item item = Game1.player.Items[ActualIndex]; if (item is ItemBag IB) { IB.OpenContents(Game1.player.Items, Game1.player.MaxItems); } break; } } } } catch (Exception) { } } } else if (Game1.activeClickableMenu is ItemGrabMenu IGM && IGM.context is Chest ChestSource && (e.Button == SButton.MouseRight || e.Button == SButton.MouseMiddle || (IsGamepadInput && GamepadControls.IsMatch(GamepadButtons, GamepadControls.Current.OpenBagFromChest)))) { // Check if they clicked a Bag in the inventory part of the chest interface bool Handled = false; for (int i = 0; i < IGM.inventory.inventory.Count; i++) { ClickableComponent Component = IGM.inventory.inventory[i]; if (Component != null && Component.bounds.Contains(CursorPos)) { Item ClickedInvItem = i < 0 || i >= IGM.inventory.actualInventory.Count ? null : IGM.inventory.actualInventory[i]; if (ClickedInvItem is ItemBag IB) { IB.OpenContents(IGM.inventory.actualInventory, Game1.player.MaxItems); } Handled = true; break; } } bool IsMegaStorageCompatibleWithCurrentChest = IGM.ItemsToGrabMenu.capacity == DefaultChestCapacity || MegaStorageInstalledVersion == null || MegaStorageInstalledVersion.IsNewerThan(new SemanticVersion(1, 4, 4)); if (!Handled && IsMegaStorageCompatibleWithCurrentChest) { // Check if they clicked a Bag in the chest part of the chest interface for (int i = 0; i < IGM.ItemsToGrabMenu.inventory.Count; i++) { ClickableComponent Component = IGM.ItemsToGrabMenu.inventory[i]; if (Component != null && Component.bounds.Contains(CursorPos)) { Item ClickedChestItem = i < 0 || i >= IGM.ItemsToGrabMenu.actualInventory.Count ? null : IGM.ItemsToGrabMenu.actualInventory[i]; if (ClickedChestItem is ItemBag IB) { IB.OpenContents(IGM.ItemsToGrabMenu.actualInventory, IGM.ItemsToGrabMenu.capacity); } Handled = true; break; } } } } }
public static void Postfix(InventoryPage __instance, int x, int y, int width, int height) { ButtonHolder.Constructor(__instance, x, y, width, height); }
public static SInventoryPage ConstructFromBaseClass(InventoryPage baseClass) { var s = new SInventoryPage(0, 0, 0, 0) {BaseInventoryPage = baseClass}; return s; }
public InventoryPageEvent(InventoryPage page) { Page = page; }
public static bool receiveLeftClick_Prefix(ref InventoryPage __instance, int x, int y, bool playSound) { bool performedSpecialFunctionality = false; bool heldItemWasNull = Game1.player.CursorSlotItem == null; foreach (ClickableComponent c in __instance.equipmentIcons) { if (c.containsPoint(x, y)) { if (c.name == "Hat" && !performedSpecialFunctionality) { // Unequipping hat... if ((Game1.player.CursorSlotItem == null && (Game1.player.hat.Value != null && (Game1.player.hat.Value.which == 71 || Game1.player.hat.Value is PanHat)))) { Item heldItem = Utility.PerformSpecialItemGrabReplacement(Game1.player.hat.Value); if (heldItem != null) { heldItem.NetFields.Parent = null; } Game1.player.hat.Value = null; Game1.player.CursorSlotItem = heldItem; Game1.playSound("dwop"); // Hack to allow compatibility with WearMoreRings mod. Game1.exitActiveMenu(); Game1.activeClickableMenu = new GameMenu(false); performedSpecialFunctionality = true; } // Equipping else if (Game1.player.CursorSlotItem is Pan pan && pan.UpgradeLevel > 1) { Game1.player.CursorSlotItem = Utility.PerformSpecialItemGrabReplacement(Game1.player.hat.Value); Game1.player.hat.Value = new PanHat(pan); Game1.playSound("grassyStep"); // Hack to allow compatibility with WearMoreRings mod. Game1.exitActiveMenu(); Game1.activeClickableMenu = new GameMenu(false); performedSpecialFunctionality = true; } } if (heldItemWasNull && performedSpecialFunctionality && Game1.oldKBState.IsKeyDown(Keys.LeftShift)) { for (int i = 0; i < Game1.player.items.Count; i++) { if (Game1.player.items[i] == null) { Item cursorSlotItem = Game1.player.CursorSlotItem; Game1.player.CursorSlotItem = null; Utility.addItemToInventory(cursorSlotItem, i, __instance.inventory.actualInventory); Game1.playSound("stoneStep"); break; } } } } if (heldItemWasNull && !performedSpecialFunctionality && Game1.oldKBState.IsKeyDown(Keys.LeftShift)) { int inventorySlot = __instance.inventory.getInventoryPositionOfClick(x, y); if (inventorySlot != -1 && Game1.player.items[inventorySlot] is Pan pan) { __instance.inventory.leftClick(x, y, null, false); pan.NetFields.Parent = null; if (Game1.player.hat.Value != null) { Game1.player.items[inventorySlot] = Utility.PerformSpecialItemGrabReplacement(Game1.player.hat.Value); } if (pan.UpgradeLevel > 1) { Game1.player.hat.Value = new PanHat(pan); Game1.playSound("grassyStep"); } else { Game1.player.hat.Value = new Hat(71); Game1.playSound("grassyStep"); } // Hack to allow compatibility with WearMoreRings mod. Game1.exitActiveMenu(); Game1.activeClickableMenu = new GameMenu(false); performedSpecialFunctionality = true; } } } return(!performedSpecialFunctionality); }
public ActionResult Index(int?storeId) { InventoryPage invPage = Helpers.InventoryHelper.GetInventoryPage(storeId); return(View(invPage)); }
private static bool IsSelectingHeadPhonesInInventory(InventoryPage page, int x, int y) { return(page.inventory.getItemAt(x, y) != null && (page.inventory.getItemAt(x, y).Name == "Headphones" || page.inventory.getItemAt(x, y).Name == "Earbuds" || page.inventory.getItemAt(x, y).Name == "Studio Headphones")); }
public static bool StackToNearbyChests(int range, InventoryPage inventoryPage) { if (inventoryPage == null) { return(false); } bool movedAtLeastOneTotal = false; Farmer who = Game1.player; List <Chest> chests = GetChestsAroundFarmer(who, range, true); foreach (Chest chest in chests) { List <Item> stackOverflowItems = new List <Item>(); Netcode.NetObjectList <Item> chestItems = (chest.SpecialChestType == Chest.SpecialChestTypes.MiniShippingBin || chest.SpecialChestType == Chest.SpecialChestTypes.JunimoChest) ? chest.GetItemsForPlayer(who.UniqueMultiplayerID) : chest.items; // Fill chest stacks with player inventory items foreach (Item chestItem in chestItems) { if (chestItem is null) { continue; } IList <Item> playerInventory = inventoryPage.inventory.actualInventory; foreach (Item playerItem in playerInventory) { if (playerItem is null || !playerItem.canStackWith(chestItem)) { continue; } if (ModEntry.Config.IsEnableFavoriteItems && ConvenientInventory.FavoriteItemSlots[playerInventory.IndexOf(playerItem)]) { // Skip favorited items continue; } int beforeStack = playerItem.Stack; playerItem.Stack = chestItem.addToStack(playerItem); bool movedAtLeastOne = beforeStack != playerItem.Stack; movedAtLeastOneTotal = movedAtLeastOneTotal || movedAtLeastOne; if (movedAtLeastOne) { ClickableComponent inventoryComponent = inventoryPage.inventory.inventory[playerInventory.IndexOf(playerItem)]; ConvenientInventory.AddTransferredItemSprite(new TransferredItemSprite( playerItem.getOne(), inventoryComponent.bounds.X, inventoryComponent.bounds.Y) ); if (playerItem.Stack == 0) { who.removeItemFromInventory(playerItem); } } if (chestItem.Stack == chestItem.maximumStackSize()) { if (ModEntry.Config.IsQuickStackOverflowItems) { stackOverflowItems.Add(chestItem.getOne()); } inventoryPage.inventory.ShakeItem(playerItem); break; } } } // Add overflow stacks to chest when applicable if (ModEntry.Config.IsQuickStackOverflowItems && chestItems.Count < chest.GetActualCapacity()) { IList <Item> playerInventory = inventoryPage.inventory.actualInventory; foreach (Item stackOverflowItem in stackOverflowItems) { if (stackOverflowItem is null) { continue; } foreach (Item playerItem in playerInventory) { if (playerItem is null || !playerItem.canStackWith(stackOverflowItem)) { continue; } if (ModEntry.Config.IsEnableFavoriteItems && ConvenientInventory.FavoriteItemSlots[playerInventory.IndexOf(playerItem)]) { // Skip favorited items continue; } int beforeStack = playerItem.Stack; Item leftoverItem = chest.addItem(playerItem); bool movedAtLeastOne = leftoverItem is null || beforeStack != leftoverItem.Stack; movedAtLeastOneTotal = movedAtLeastOneTotal || movedAtLeastOne; if (movedAtLeastOne) { ClickableComponent inventoryComponent = inventoryPage.inventory.inventory[playerInventory.IndexOf(playerItem)]; ConvenientInventory.AddTransferredItemSprite(new TransferredItemSprite( playerItem.getOne(), inventoryComponent.bounds.X, inventoryComponent.bounds.Y) ); } if (leftoverItem is null) { who.removeItemFromInventory(playerItem); } else { inventoryPage.inventory.ShakeItem(playerItem); } } } } } Game1.playSound(movedAtLeastOneTotal ? "Ship" : "cancel"); return(movedAtLeastOneTotal); }
public PlayerEquipmentInfo(Farmer player, Vector2 position) { var inventory = new InventoryPage(0, 0, 0, 0); inventory.equipmentIcons = null; }
public void ImageDisplayed() { InventoryPage inventoryPage = new InventoryPage(browserDriver); Assert.That(inventoryPage.AllImagesExist, Is.True); }
public static void PopulateClickableComponentsList(InventoryPage inventoryPage) { inventoryPage.allClickableComponents.Add(button); }
static public void AddEquipmentIcons(InventoryPage page) { Chest chest = GetRingInventory(Game1.player); int inv = Game1.player.MaxItems - 12; // name x y id up dn lt rt, item AddIcon(page, "Hat", 0, 0, 102, inv, 103, -1, 110, Game1.player.hat.Value); AddIcon(page, "Shirt", 0, 16, 103, 102, 104, -1, 111, Game1.player.shirtItem.Value); AddIcon(page, "Pants", 0, 32, 104, 103, 108, -1, 112, Game1.player.pantsItem.Value); AddIcon(page, "Boots", 0, 48, 108, 104, -1, -1, 112, Game1.player.boots.Value); var max_rings = getInstance().config.Rings; int slot_id(int x, int y, int def = -1) { if (x == -1) { switch (y) { case 0: return(102); case 1: return(103); case 2: return(104); case 3: return(108); } } if (y == -1) { return(inv + 3 + x); } int id = x * 4 + y; if (id >= max_rings) { return(def); } if (id == 1) { return(101); // Original id for right ring. } return(110 + x + y * 10); }; for (int i = 0; i < max_rings; i++) { String name; Ring ring; switch (i) { case 0: name = "Left Ring"; ring = Game1.player.leftRing.Value; break; case 1: name = "Right Ring"; ring = Game1.player.rightRing.Value; break; default: name = "Extra Ring " + (i - 2); ring = chest.items[i - 2] as Ring; break; } var x = i / 4; var y = i % 4; AddIcon(page, name, 52 + 16 * x, 16 * y, slot_id(x, y), slot_id(x, y - 1), slot_id(x, y + 1), slot_id(x - 1, y), slot_id(x + 1, y, 105), ring); } }
public MainPage() { Page mePage, gamePage, scorePage, charPage, invPage, monsterPage, gameitemsPage, battlePage = null; switch (Device.RuntimePlatform) { case Device.iOS: mePage = new NavigationPage(new MePage()) { Title = "Information" }; gamePage = new NavigationPage(new GamePage()) { Title = "Game" }; scorePage = new NavigationPage(new ScorePage()) { Title = "Score" }; charPage = new NavigationPage(new CharacterPage()) { Title = "Character" }; invPage = new NavigationPage(new InventoryPage()) { Title = "Inventory" }; monsterPage = new NavigationPage(new MonstersPage()) { Title = "Monsters" }; gameitemsPage = new NavigationPage(new GameItemsPage()) { Title = "Items" }; battlePage = new NavigationPage(new BattlePage()) { Title = "Battle" }; mePage.Icon = "tab_about.png"; gamePage.Icon = "tab_feed.png"; scorePage.Icon = "tab_feed.png"; charPage.Icon = "tab_about.png"; invPage.Icon = "tab_about.png"; monsterPage.Icon = "tab_about.png"; gameitemsPage.Icon = "tab_about.png"; battlePage.Icon = "tab_about.png"; //itemsPage.Icon = "tab_feed.png"; //aboutPage.Icon = "tab_about.png"; break; default: mePage = new MePage() { Title = "Me" }; gamePage = new GamePage() { Title = "Game" }; scorePage = new ScorePage() { Title = "Score" }; charPage = new CharacterPage() { Title = "Character" }; invPage = new InventoryPage() { Title = "Inventory" }; monsterPage = new MonstersPage() { Title = "Monsters" }; gameitemsPage = new GameItemsPage() { Title = "Items" }; battlePage = new BattlePage() { Title = "Battle" }; break; } Children.Add(mePage); Children.Add(gamePage); Children.Add(scorePage); Children.Add(charPage); Children.Add(invPage); Children.Add(monsterPage); Children.Add(gameitemsPage); Children.Add(battlePage); Title = Children[0].Title; }
internal static ushort GetId(InventoryPage inventoryPage) { return((ushort)GetIdInternal(inventoryPage)); }
public static void TestInitialize() { inventoryPage = new InventoryPage(DriverSetup.Driver); }
public void SetParentPage(InventoryPage page) { parentPage = page; }