예제 #1
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();
            }
        }
예제 #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;
            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();
        }