public ItemGrabMenuWrapper(IList <Item> inventory, bool reverseGrab, bool showReceivingMenu,
                            InventoryMenu.highlightThisItem highlightFunction, behaviorOnItemSelect behaviorOnItemSelectFunction,
                            string message, behaviorOnItemSelect behaviorOnItemGrab = null, bool snapToBottom = false,
                            bool canBeExitedWithKey = false, bool playRightClickSound = true, bool allowRightClick = true,
                            bool showOrganizeButton = false, int source = 0, Item sourceItem = null, int whichSpecialButton = -1,
                            object context          = null) : base(inventory, reverseGrab, showReceivingMenu, highlightFunction,
                                                                   behaviorOnItemSelectFunction, message, behaviorOnItemGrab, snapToBottom, canBeExitedWithKey,
                                                                   playRightClickSound, allowRightClick, showOrganizeButton, source, sourceItem, whichSpecialButton, context)
 {
 }
예제 #2
0
        public ChestExMenu(IList <Item> inventory, Boolean reverseGrab, Boolean showReceivingMenu, InventoryMenu.highlightThisItem highlightFunction, behaviorOnItemSelect behaviorOnItemSelectFunction, String message, behaviorOnItemSelect behaviorOnItemGrab = null, Boolean snapToBottom = false, Boolean canBeExitedWithKey = false, Boolean playRightClickSound = true, Boolean allowRightClick = true, Boolean showOrganizeButton = false, Int32 source = 0, Item sourceItem = null, Int32 whichSpecialButton = -1, System.Object context = null)
            : base(null, new ArbitrationObjects(highlightFunction, true, false, 0, bgYDiff))
        {
            this.source                       = source;
            this.message                      = message;
            this.reverseGrab                  = reverseGrab;
            this.showReceivingMenu            = showReceivingMenu;
            this.playRightClickSound          = playRightClickSound;
            this.allowRightClick              = allowRightClick;
            this.inventory.showGrayedOutSlots = true;
            this.sourceItem                   = sourceItem;

            // get MenuWithInventory/IClickable calls
            {
                deepBaseCalls.pEmergencyShutDown = DeepBaseCallsGetter.GetDeepBaseFunction <DeepBaseCalls.tEmergencyShutdown>(this, "emergencyShutDown");
                deepBaseCalls.pPopulateClickableComponentList = DeepBaseCallsGetter.GetDeepBaseFunction <DeepBaseCalls.tPopulateClickableComponentList>(this, "populateClickableComponentList");
                deepBaseCalls.pApplyMovementKey     = DeepBaseCallsGetter.GetDeepBaseFunction <DeepBaseCalls.tApplyMovementKey>(this, "applyMovementKey", new Type[] { typeof(Keys) });
                deepBaseCalls.pDrawMouse            = DeepBaseCallsGetter.GetDeepBaseFunction <DeepBaseCalls.tDrawMouse>(this, "drawMouse", new Type[] { typeof(SpriteBatch) });
                deepBaseCalls.pExitThisMenu         = DeepBaseCallsGetter.GetDeepBaseFunction <DeepBaseCalls.tExitThisMenu>(this, "exitThisMenu", new Type[] { typeof(Boolean) });
                deepBaseCalls.pReceiveGamePadButton = DeepBaseCallsGetter.GetDeepBaseFunction <DeepBaseCalls.tReceiveGamePadButton>(this, "receiveGamePadButton", new Type[] { typeof(Buttons) });
                deepBaseCalls.pUpdate             = DeepBaseCallsGetter.GetDeepBaseFunction <DeepBaseCalls.tUpdate>(this, "update", new Type[] { typeof(GameTime) });
                deepBaseCalls.pMovePosition       = DeepBaseCallsGetter.GetDeepBaseFunction <DeepBaseCalls.tMovePosition>(this, "movePosition", new Type[] { typeof(Int32), typeof(Int32) });
                deepBaseCalls.pPerformHoverAction = DeepBaseCallsGetter.GetDeepBaseFunction <DeepBaseCalls.tPerformHoverAction>(this, "performHoverAction", new Type[] { typeof(Int32), typeof(Int32) });
                deepBaseCalls.pDraw               = DeepBaseCallsGetter.GetDeepBaseFunction <DeepBaseCalls.tDraw>(this, "draw", new Type[] { typeof(SpriteBatch), typeof(Boolean), typeof(Boolean) });
                deepBaseCalls.pReceiveLeftClick   = DeepBaseCallsGetter.GetDeepBaseFunction <DeepBaseCalls.tReceiveLeftClick>(this, "receiveLeftClick", new Type[] { typeof(Int32), typeof(Int32), typeof(Boolean) });
                deepBaseCalls.pReceiveRightClick  = DeepBaseCallsGetter.GetDeepBaseFunction <DeepBaseCalls.tReceiveRightClick>(this, "receiveRightClick", new Type[] { typeof(Int32), typeof(Int32), typeof(Boolean) });
                deepBaseCalls.pGetComponentWithID = DeepBaseCallsGetter.GetDeepBaseFunction <DeepBaseCalls.tGetComponentWithID>(this, "getComponentWithID", new Type[] { typeof(Int32) });
            }
            // calc bgXDiff
            {
                if (Config.instance.columns < 12) // game's default column amount
                {
                    bgXDiff = (12 - Config.instance.columns) * 32;
                }
                else
                {
                    bgXDiff = (Config.instance.columns - 12) * -32;
                }
            }

            this.ItemsToGrabMenu = new InventoryMenu(this.inventory.xPositionOnScreen + bgXDiff,
                                                     this.inventory.yPositionOnScreen + 16 - (64 * Config.instance.rows) - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder,
                                                     false, inventory, null, Config.instance.getCapacity(), Config.instance.rows, 0, 0, true);
            this.ItemsToGrabMenu.populateClickableComponentList();

            if (source == 1 && sourceItem != null && sourceItem is Chest)
            {
                setColorPicker();
                if (Game1.player.showChestColorPicker)
                {
                    this.chestColorPicker.visible = Game1.player.showChestColorPicker = false;
                }
            }
            this.context = context;

            if (Game1.options.SnappyMenus)
            {
                this.ItemsToGrabMenu.populateClickableComponentList();
                for (Int32 i = 0; i < this.ItemsToGrabMenu.inventory.Count; i++)
                {
                    if (this.ItemsToGrabMenu.inventory[i] != null)
                    {
                        this.ItemsToGrabMenu.inventory[i].myID            += 53910;
                        this.ItemsToGrabMenu.inventory[i].upNeighborID    += 53910;
                        this.ItemsToGrabMenu.inventory[i].rightNeighborID += 53910;
                        this.ItemsToGrabMenu.inventory[i].downNeighborID   = -7777;
                        this.ItemsToGrabMenu.inventory[i].leftNeighborID  += 53910;
                        this.ItemsToGrabMenu.inventory[i].fullyImmutable   = true;
                    }
                }
            }
            this.behaviorFunction   = behaviorOnItemSelectFunction;
            this.behaviorOnItemGrab = behaviorOnItemGrab;
            this.canExitOnKey       = canBeExitedWithKey;
            if (showOrganizeButton)
            {
                setOrganizeButton();
            }
            if ((Game1.isAnyGamePadButtonBeingPressed() || !Game1.lastCursorMotionWasMouse) && this.ItemsToGrabMenu.actualInventory.Count > 0 && Game1.activeClickableMenu == null)
            {
                Game1.setMousePosition(this.inventory.inventory[0].bounds.Center);
            }
            if (Game1.options.snappyMenus && Game1.options.gamepadControls)
            {
                for (Int32 k = 0; k < 12; k++)
                {
                    if (this.inventory != null && this.inventory.inventory != null && this.inventory.inventory.Count >= 12)
                    {
                        this.inventory.inventory[k].upNeighborID = (this.shippingBin ? 12598 : ((this.discreteColorPickerCC != null && this.ItemsToGrabMenu != null && this.ItemsToGrabMenu.inventory.Count <= k) ? 4343 : ((this.ItemsToGrabMenu.inventory.Count > k) ? (53910 + k) : 53910)));
                    }
                    if (this.discreteColorPickerCC != null && this.ItemsToGrabMenu != null && this.ItemsToGrabMenu.inventory.Count > k)
                    {
                        this.ItemsToGrabMenu.inventory[k].upNeighborID = 4343;
                    }
                }
                for (Int32 l = 0; l < Config.instance.getCapacity(); l++)
                {
                    if (this.inventory != null && this.inventory.inventory != null && this.inventory.inventory.Count > l)
                    {
                        this.inventory.inventory[l].upNeighborID        = -7777;
                        this.inventory.inventory[l].upNeighborImmutable = true;
                    }
                }
                if (this.okButton != null)
                {
                    this.okButton.leftNeighborID = 11;
                }
                deepBaseCalls.pPopulateClickableComponentList();
                this.snapToDefaultClickableComponent();
            }
        }
예제 #3
0
        public ChestExMenu(IList <Item> inventory, Boolean reverseGrab, Boolean showReceivingMenu, InventoryMenu.highlightThisItem highlightFunction, behaviorOnItemSelect behaviorOnItemSelectFunction, String message, behaviorOnItemSelect behaviorOnItemGrab = null, Boolean snapToBottom = false, Boolean canBeExitedWithKey = false, Boolean playRightClickSound = true, Boolean allowRightClick = true, Boolean showOrganizeButton = false, Int32 source = 0, Item sourceItem = null, Int32 whichSpecialButton = -1, System.Object context = null)
            : base(null, new ArbitrationObjects(highlightFunction, true, false, 0, bgYDiff))
        {
            this.source                       = source;
            this.message                      = message;
            this.reverseGrab                  = reverseGrab;
            this.showReceivingMenu            = showReceivingMenu;
            this.playRightClickSound          = playRightClickSound;
            this.allowRightClick              = allowRightClick;
            this.inventory.showGrayedOutSlots = true;
            this.sourceItem                   = sourceItem;
            this.context                      = context;
            this.behaviorFunction             = behaviorOnItemSelectFunction;
            this.behaviorOnItemGrab           = behaviorOnItemGrab;
            this.canExitOnKey                 = canBeExitedWithKey;

            // get MenuWithInventory/IClickable calls
            {
                deepBaseCalls.pEmergencyShutDown = DeepBaseCallsGetter.GetDeepBaseFunction <DeepBaseCalls.tEmergencyShutdown>(this, "emergencyShutDown");
                deepBaseCalls.pPopulateClickableComponentList = DeepBaseCallsGetter.GetDeepBaseFunction <DeepBaseCalls.tPopulateClickableComponentList>(this, "populateClickableComponentList");
                deepBaseCalls.pDrawMouse          = DeepBaseCallsGetter.GetDeepBaseFunction <DeepBaseCalls.tDrawMouse>(this, "drawMouse", new Type[] { typeof(SpriteBatch) });
                deepBaseCalls.pUpdate             = DeepBaseCallsGetter.GetDeepBaseFunction <DeepBaseCalls.tUpdate>(this, "update", new Type[] { typeof(GameTime) });
                deepBaseCalls.pDraw               = DeepBaseCallsGetter.GetDeepBaseFunction <DeepBaseCalls.tDraw>(this, "draw", new Type[] { typeof(SpriteBatch), typeof(Boolean), typeof(Boolean), typeof(Int32), typeof(Int32), typeof(Int32) });
                deepBaseCalls.pPerformHoverAction = DeepBaseCallsGetter.GetDeepBaseFunction <DeepBaseCalls.tPerformHoverAction>(this, "performHoverAction", new Type[] { typeof(Int32), typeof(Int32) });
                deepBaseCalls.pReceiveLeftClick   = DeepBaseCallsGetter.GetDeepBaseFunction <DeepBaseCalls.tReceiveMouseClick>(this, "receiveLeftClick", new Type[] { typeof(Int32), typeof(Int32), typeof(Boolean) });
                deepBaseCalls.pReceiveRightClick  = DeepBaseCallsGetter.GetDeepBaseFunction <DeepBaseCalls.tReceiveMouseClick>(this, "receiveRightClick", new Type[] { typeof(Int32), typeof(Int32), typeof(Boolean) });
            }
            // calc bgXDiff
            {
                if (Config.instance.columns < 12) // game's default column amount
                {
                    bgXDiff = (12 - Config.instance.columns) * 32;
                }
                else
                {
                    bgXDiff = (Config.instance.columns - 12) * -32;
                }
            }

            this.inventory.yPositionOnScreen += bgYDiff;
            foreach (var item in this.inventory.inventory)
            {
                item.bounds.Y += bgYDiff;
            }
            this.ItemsToGrabMenu = new InventoryMenu(this.inventory.xPositionOnScreen + bgXDiff,
                                                     this.inventory.yPositionOnScreen + 16 - (64 * Config.instance.rows) - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder,
                                                     false, inventory, null, Config.instance.getCapacity(), Config.instance.rows, 0, 0, true);
            this.ItemsToGrabMenu.populateClickableComponentList();
            for (int i = 0; i < this.ItemsToGrabMenu.inventory.Count; i++)
            {
                if (this.ItemsToGrabMenu.inventory[i] != null)
                {
                    this.ItemsToGrabMenu.inventory[i].myID            += ItemGrabMenu.region_itemsToGrabMenuModifier;
                    this.ItemsToGrabMenu.inventory[i].upNeighborID    += ItemGrabMenu.region_itemsToGrabMenuModifier;
                    this.ItemsToGrabMenu.inventory[i].rightNeighborID += ItemGrabMenu.region_itemsToGrabMenuModifier;
                    this.ItemsToGrabMenu.inventory[i].downNeighborID   = ClickableComponent.CUSTOM_SNAP_BEHAVIOR;
                    this.ItemsToGrabMenu.inventory[i].leftNeighborID  += ItemGrabMenu.region_itemsToGrabMenuModifier;
                }
            }

            if (source == ItemGrabMenu.source_chest && sourceItem != null && sourceItem is Chest)
            {
                setColorPicker();
                this.chestColorPicker.visible = Game1.player.showChestColorPicker = false;
                this.defSnappyMenus           = Game1.options.snappyMenus;
            }
            if (showOrganizeButton)
            {
                setOrganizeButton();
            }

            if (this.trashCan != null && this.inventory.inventory.Count >= 12 && this.inventory.inventory[11] != null)
            {
                this.inventory.inventory[11].rightNeighborID = this.trashCan.myID;
            }

            if (this.okButton != null)
            {
                this.okButton.leftNeighborID = 11;
            }

            deepBaseCalls.pPopulateClickableComponentList();
            if (Game1.options.SnappyMenus)
            {
                this.snapToDefaultClickableComponent();
            }
            SetupBorderNeighbors();
        }
예제 #4
0
        // Constructors:
        #region Constructors

        public MainMenu(IList <Item> inventory, Boolean reverseGrab, Boolean showReceivingMenu, InventoryMenu.highlightThisItem highlightFunction,
                        behaviorOnItemSelect behaviorOnItemSelectFunction, String message, behaviorOnItemSelect behaviorOnItemGrab = null, Boolean snapToBottom = false,
                        Boolean canBeExitedWithKey = false, Boolean playRightClickSound = true, Boolean allowRightClick = true, Boolean showOrganizeButton = false,
                        Int32 source = 0, Item sourceItem = null, Int32 whichSpecialButton = -1, Object context = null)
            : base(inventory,
                   reverseGrab,
                   showReceivingMenu,
                   highlightFunction,
                   behaviorOnItemSelectFunction,
                   message,
                   behaviorOnItemGrab,
                   snapToBottom,
                   canBeExitedWithKey,
                   playRightClickSound,
                   allowRightClick,
                   showOrganizeButton,
                   source,
                   sourceItem,
                   whichSpecialButton,
                   context)
        {
            this.UnregisterInputEvents();

            Rectangle ui_viewport = GlobalVars.gUIViewport;

            this.ItemsToGrabMenu = new InventoryMenu(ui_viewport.Width / 2
                                                     - this.ItemsToGrabMenu.width / 2
                                                     /* organize buttons padding */
                                                     - (64 + 16),
                                                     Math.Max((GlobalVars.gIsChestsAnywhereLoaded ? 82 : 48) + (GlobalVars.gIsExpandedStorageLoaded ? 52 : 0),
                                                              (Int32)(ui_viewport.Height * 0.5f - this.ItemsToGrabMenu.height * 0.75f)),
                                                     false,
                                                     this.ItemsToGrabMenu.actualInventory,
                                                     this.ItemsToGrabMenu.highlightMethod,
                                                     Config.Get().GetCapacity(),
                                                     Config.Get().mRows,
                                                     this.ItemsToGrabMenu.horizontalGap,
                                                     this.ItemsToGrabMenu.verticalGap,
                                                     this.ItemsToGrabMenu.drawSlots);
            this.ItemsToGrabMenu.populateClickableComponentList();
            this.mSourceInventoryOptions.mDialogueBoxBounds = this.ItemsToGrabMenu.GetTextureBoxRectangle(borderScale: this.mSourceInventoryOptions.mBorderScale);
            this.mSourceInventoryOptions.SetVisible(this.mSourceInventoryOptions.mIsVisible);
            if (GlobalVars.gIsExpandedStorageLoaded)
            {
                this.mSourceInventoryOptions.mDialogueBoxBounds.Y      -= 52;
                this.mSourceInventoryOptions.mDialogueBoxBounds.Height += 52;
            }

            foreach (ClickableComponent cc in this.ItemsToGrabMenu.inventory.Where(cc => cc != null))
            {
                cc.myID            += region_itemsToGrabMenuModifier;
                cc.upNeighborID    += region_itemsToGrabMenuModifier;
                cc.rightNeighborID += region_itemsToGrabMenuModifier;
                cc.downNeighborID   = ClickableComponent.CUSTOM_SNAP_BEHAVIOR;
                cc.leftNeighborID  += region_itemsToGrabMenuModifier;
                cc.fullyImmutable   = true;
            }

            Int32 compatibility_y_shift = GlobalVars.gIsExpandedStorageLoaded ? 48 : 0;

            this.inventory = new InventoryMenu(this.mSourceInventoryOptions.mDialogueBoxBounds.Center.X - this.inventory.width / 2 - 4,
                                               Math.Min(ui_viewport.Height - this.inventory.height - 32,
                                                        this.mSourceInventoryOptions.mDialogueBoxBounds.Bottom + 48 + compatibility_y_shift),
                                               false,
                                               null,
                                               this.inventory.highlightMethod,
                                               this.inventory.capacity,
                                               this.inventory.rows,
                                               this.inventory.horizontalGap,
                                               this.inventory.verticalGap,
                                               this.inventory.drawSlots);
            this.mPlayerInventoryOptions.mDialogueBoxBounds = this.inventory.GetTextureBoxRectangle(borderScale: this.mPlayerInventoryOptions.mBorderScale);
            this.mPlayerInventoryOptions.SetVisible(this.mPlayerInventoryOptions.mIsVisible);

            this.SetBounds(this.mSourceInventoryOptions.mDialogueBoxBounds.X,
                           this.mSourceInventoryOptions.mDialogueBoxBounds.Y,
                           this.mSourceInventoryOptions.mDialogueBoxBounds.Width,
                           this.mSourceInventoryOptions.mDialogueBoxBounds.Height
                           + this.mSourceInventoryOptions.mDialogueBoxBounds.Y
                           + 32
                           + this.mPlayerInventoryOptions.mDialogueBoxBounds.Height);

            // handle organization buttons
            this.CreateOrganizationButtons(true, true, true);

            // TODO:
            // absolute position/tile position for chest saving?
            // need to sync farmhand hinges color to farmer MP
            // gamepad interaction is f****d

            this.populateClickableComponentList();
            if (Game1.options.SnappyMenus)
            {
                this.snapToDefaultClickableComponent();
            }
            this.SetupBorderNeighbors();

            this.RegisterInputEvents();
        }