/// <summary>
 /// Closes menus until the passed in menu is on top of the stack.
 /// </summary>
 /// <param name="menu"></param>
 public void closeUntilThisMenu(IClickableMenuExtended menu)
 {
     while (this.activeMenu != menu)
     {
         this.closeActiveMenu();
     }
 }
        /// <summary>
        /// Draws the menu to the screen.
        /// </summary>
        /// <param name="b"></param>
        public override void draw(SpriteBatch b)
        {
            this.drawDialogueBoxBackground(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, this.backgroundColor);

            this.clockSprite.draw(b);
            b.DrawString(Game1.smallFont, TimeUtilities.GetTimeString(this.objectSource.MinutesUntilReady), this.timeDisplayLocation + new Vector2(0, 36f), Color.Black);


            //Draw the energy on the screen.

            if (this.shouldDrawBattery)
            {
                this.batteryBackground.draw(b, 1f, 1f);
                this.energyMeterColorSwap();
                b.Draw(this.energyTexture, new Rectangle((int)this.energyPosition.X + (int)(11 * this.batteryBackground.scale), (int)this.energyPosition.Y + (int)(18 * this.batteryBackground.scale) + (int)(46 * this.batteryBackground.scale), (int)((9 * this.batteryBackground.scale)), (int)(46 * this.batteryBackground.scale * this.energy.energyPercentRemaining)), new Rectangle(0, 0, 1, 1), Color.White, 0f, new Vector2(0f, 1f), SpriteEffects.None, 0.2f);
                this.battergyEnergyGuage.draw(b, 1f, 1f);

                this.energyRequiredButton.draw(b);
                b.DrawString(Game1.smallFont, this.requiredEnergyPer10Min + " E/10m", this.energyRequiredDisplayLocation + new Vector2(0, 36f), Color.Black);
            }

            if (this.objectSource.info.inventory.HasInventory)
            {
                this.storageButton.draw(b);
                b.DrawString(Game1.smallFont, "Storage remaining: " + (this.objectSource.info.inventory.capacity - this.objectSource.info.inventory.ItemCount) + "/" + this.objectSource.info.inventory.capacity, this.storageRemainingDisplayLocation + new Vector2(0, 32f), Color.Black);
            }

            if (this.objectSource.info.fluidManager.InteractsWithFluids)
            {
                if (this.objectSource.info.fluidManager.inputTank1.capacity > 0)
                {
                    this.inputFluidTank1Button.draw(b);
                    b.DrawString(Game1.smallFont, this.objectSource.info.fluidManager.inputTank1.getFluidDisplayString(), this.fluidDisplayLocation + new Vector2(32, 0f), Color.Black);
                }
                if (this.objectSource.info.fluidManager.inputTank2.capacity > 0)
                {
                    this.inputFluidTank2Button.draw(b);
                    b.DrawString(Game1.smallFont, this.objectSource.info.fluidManager.inputTank2.getFluidDisplayString(), this.fluidDisplayLocation + new Vector2(32, 64f), Color.Black);
                }
                if (this.objectSource.info.fluidManager.outputTank.capacity > 0)
                {
                    //ModCore.log("Color:" + this.objectSource.GetFluidManager().outputTank.fluid.color);
                    this.outputFluidTankButton.draw(b);
                    b.DrawString(Game1.smallFont, this.objectSource.info.fluidManager.outputTank.getFluidDisplayString(), this.fluidDisplayLocation + new Vector2(32, 128f), Color.Black);
                }
            }

            this.objectSource.drawFullyInMenu(b, new Vector2((int)(this.xPositionOnScreen + (this.width / 2) - (this.itemDisplayOffset.X / 2)), (int)(this.yPositionOnScreen + 128f)), .24f);
            Vector2 nameOffset = Game1.dialogueFont.MeasureString(this.objectSource.DisplayName);

            b.DrawString(Game1.dialogueFont, this.objectSource.DisplayName, new Vector2(this.xPositionOnScreen + (this.width / 2) - nameOffset.X / 2, (this.yPositionOnScreen + 150f)) + new Vector2(0, ObjectUtilities.GetHeightOffsetFromItem(this.objectSource)), Color.Black);

            if (string.IsNullOrEmpty(this.hoverText) == false)
            {
                IClickableMenuExtended.drawHoverText(b, this.hoverText, Game1.dialogueFont);
            }


            this.drawMouse(b);
        }
        public void addInMenuTab(string Name, AnimatedButton Button, IClickableMenuExtended Menu, bool DefaultTab = false)
        {
            int count = this.menuPages.Count;

            Vector2 newPos = new Vector2(208 + (24 * 2) * (count + 1), this.yPositionOnScreen + (80));

            Button.Position = newPos;
            this.menuPages.Add(Name, new KeyValuePair <AnimatedButton, IClickableMenuExtended>(Button, Menu));

            if (DefaultTab)
            {
                this.currentTab = Name;
            }
        }
        /// <summary>
        /// Closes the top most active menu on the menu stack.
        /// </summary>
        public void closeActiveMenu()
        {
            if (this.menus == null)
            {
                return;
            }
            if (this.menus.Count == 0)
            {
                return;
            }
            IClickableMenuExtended m = this.menus.Pop();

            m.exitMenu();
        }
        public override void draw(SpriteBatch b)
        {
            foreach (KeyValuePair <AnimatedButton, IClickableMenuExtended> button in this.menuPages.Values)
            {
                button.Key.draw(b);
            }
            if (this.CurrentMenu != null)
            {
                this.CurrentMenu.draw(b);
            }

            if (string.IsNullOrEmpty(this.hoverText) == false)
            {
                IClickableMenuExtended.drawHoverText(b, this.hoverText, Game1.dialogueFont);
            }

            this.drawMouse(b);
        }
        /// <summary>
        /// Draws
        /// </summary>
        /// <param name="b"></param>
        public override void draw(SpriteBatch b)
        {
            this.playerInventory.draw(b);
            this.otherInventory.draw(b);

            this.transferButton.draw(b, 1f, this.currentMode == CurrentMode.TransferItems? 1f:.4f);
            this.trashButton.draw(b, 1f, this.currentMode == CurrentMode.TrashItem ? 1f : .4f);
            this.trashedItem.draw(b, 0.25f, (this.currentMode == CurrentMode.TrashItem || this.trashedItem.item != null) ? 1f:.4f, false);
            if (this.hoverText != null)
            {
                IClickableMenuExtended.drawHoverText(b, this.hoverText, Game1.dialogueFont);
            }
            //To prevent awkward overlap from the other menu.
            if (this.playerInventory.hoverText != null)
            {
                this.playerInventory.drawToolTip(b);
            }

            this.drawToolTip(b);
            this.drawMouse(b);
        }
Exemple #7
0
        public void AddMenuTab(Button b, IClickableMenuExtended menu)
        {
            int count = this.menuTabsAndPages.Count % tabsPerPage;
            int xPos  = this.xPositionOnScreen + count * 64;
            int yPos  = this.yPositionOnScreen;

            b.bounds = new Rectangle(xPos, yPos, b.bounds.Width, b.bounds.Height);

            if (b.extraTextures == null)
            {
                this.menuTabsAndPages.Add(b, menu);
                return;
            }
            for (int i = 0; i < b.extraTextures.Count; i++)
            {
                ClickableTextureComponent text = b.extraTextures.ElementAt(i).Key;
                Rectangle bounds = new Rectangle(b.bounds.X + text.bounds.X, b.bounds.Y + text.bounds.Y, text.bounds.Width, text.bounds.Height);
                text.bounds        = bounds;
                b.extraTextures[i] = new KeyValuePair <ClickableTextureComponent, ExtraTextureDrawOrder>(text, b.extraTextures.ElementAt(i).Value);
            }

            this.menuTabsAndPages.Add(b, menu);
        }
Exemple #8
0
 public void changeTab(Button b, IClickableMenuExtended menu)
 {
     currentButton = b;
     currentMenu   = menu;
 }
Exemple #9
0
 public void changeTab(int which)
 {
     currentPageIndex = which % tabsPerPage;
     currentButton    = menuTabsAndPages.ElementAt(which).Key;
     currentMenu      = menuTabsAndPages.ElementAt(which).Value;
 }
        /// <summary>
        /// Draws the menu to the screen.
        /// </summary>
        /// <param name="b"></param>
        public override void draw(SpriteBatch b)
        {
            this.drawDialogueBoxBackground(this.xPositionOnScreen + this.xOffset, this.yPositionOnScreen, this.width, this.height, this.backgroundColor);

            if (this.currentPageIndex > this.maxPages)
            {
                this.currentPageIndex = 0;
            }

            this.leftButton.draw(b);
            //Draw page numbers here.
            //b.DrawString(Game1.smallFont,"Page: "+this.currentPageIndex.ToString()/)
            b.DrawString(Game1.dialogueFont, ("Page: " + (this.currentPageIndex + 1) + " / " + (this.maxPages + 1)).ToString(), new Vector2(this.xPositionOnScreen + 128, this.yPositionOnScreen + 32), Color.White);
            this.rightButton.draw(b);

            this.searchBox.Draw(b, true);

            //this.drawDialogueBoxBackground();
            foreach (KeyValuePair <string, AnimatedButton> pair in this.CraftingTabs)
            {
                pair.Value.draw(b);
            }

            if (string.IsNullOrEmpty(this.currentTab))
            {
                if (string.IsNullOrEmpty(this.hoverText) == false)
                {
                    IClickableMenuExtended.drawHoverText(b, this.hoverText, Game1.dialogueFont);
                }
                this.drawMouse(b);
                return;
            }

            List <CraftingRecipeButton> buttonsToDraw = this.getRecipeButtonsToDisplay();

            foreach (CraftingRecipeButton button in buttonsToDraw)
            {
                if (button.recipe.CanCraft(this.fromInventory))
                {
                    button.draw(b);
                }
                else
                {
                    button.draw(b, .25f);
                }

                b.DrawString(Game1.smallFont, button.displayItem.item.DisplayName, button.displayItem.Position + new Vector2(64, 0), Color.Brown);
            }

            if (this.craftingInfo != null)
            {
                this.craftingInfo.draw(b);
            }

            if (string.IsNullOrEmpty(this.hoverText) == false)
            {
                IClickableMenuExtended.drawHoverText(b, this.hoverText, Game1.dialogueFont);
            }

            this.drawMouse(b);
        }
 /// <summary>
 /// Adds a new menu to the menu stack.
 /// </summary>
 /// <param name="menu"></param>
 public void addNewMenu(IClickableMenuExtended menu)
 {
     this.menus.Push(menu);
 }
 /// <summary>
 /// Checks if the give menu is the active menu.
 /// </summary>
 /// <param name="menu"></param>
 /// <returns></returns>
 public bool isThisActiveMenu(IClickableMenuExtended menu)
 {
     return(this.menus.Peek() == menu);
 }