Пример #1
0
        private void DrawUpgrades(Rectangle bounds, SpriteBatch sb)
        {
            int panelHeight = 28;

            if (this.scrollerPanel == null)
            {
                this.scrollerPanel = new ScrollableSectionedPanel(panelHeight, sb.GraphicsDevice);
            }
            this.scrollerPanel.NumberOfPanels = this.upgradeNames.Count;
            Button.outlineOnly    = true;
            Button.drawingOutline = false;
            int  drawnThisCycle    = 0;
            bool needsButtonChecks = bounds.Contains(GuiData.getMousePoint());

            this.scrollerPanel.Draw((Action <int, Rectangle, SpriteBatch>)((index, drawAreaFull, sprBatch) =>
            {
                Rectangle destinationRectangle = new Rectangle(drawAreaFull.X, drawAreaFull.Y, drawAreaFull.Width - 12, drawAreaFull.Height);
                int myID = 115700 + index * 111;
                if (needsButtonChecks && Button.doButton(myID, destinationRectangle.X, destinationRectangle.Y, destinationRectangle.Width, destinationRectangle.Height, "", new Color?(Color.Transparent)))
                {
                    this.PurchaseUpgrade(index);
                }
                else if (!needsButtonChecks && GuiData.hot == myID)
                {
                    GuiData.hot = -1;
                }
                bool flag1 = (double)this.upgradeCosts[index] <= (double)this.activeState.points;
                bool flag2 = flag1 && GuiData.hot == myID;
                if (GuiData.hot == myID)
                {
                    this.hoverIndex = index;
                }
                if (flag2)
                {
                    int height = destinationRectangle.Height;
                    int num1   = 0;
                    int num2   = 0;
                    if (drawAreaFull.X == 0 && drawAreaFull.Y == 0)
                    {
                        if (drawnThisCycle == 0)
                        {
                            num1 = bounds.X;
                            num2 = bounds.Y;
                        }
                        else
                        {
                            num1 = bounds.X;
                            num2 = bounds.Y + bounds.Height - panelHeight / 2;
                        }
                    }
                    Rectangle rectangle = new Rectangle(num1 + destinationRectangle.X - height, num2 + destinationRectangle.Y - height, destinationRectangle.Width + 2 * height, destinationRectangle.Height + 2 * height);
                    for (int index1 = 0; index1 < this.Stars.Count; ++index1)
                    {
                        this.DrawStar(rectangle, sb, this.Stars[index1]);
                    }
                    sb.Draw(this.scanlinesTextBackground, rectangle, this.ThemeColor * (GuiData.active == myID ? 0.6f : 0.3f));
                }
                sprBatch.Draw(this.scanlinesTextBackground, destinationRectangle, new Rectangle?(new Rectangle(this.scanlinesTextBackground.Width / 2, this.scanlinesTextBackground.Height / 9 * 4, this.scanlinesTextBackground.Width / 2, this.scanlinesTextBackground.Height / 4)), flag1 ? this.ThemeColor * 0.2f : Utils.AddativeWhite * 0.08f);
                if (GuiData.hot == myID)
                {
                    RenderedRectangle.doRectangle(destinationRectangle.X + 1, destinationRectangle.Y + 1, destinationRectangle.Width - 2, destinationRectangle.Height - 2, new Color?(flag2 ? (GuiData.active == myID ? Color.Black : this.ThemeColorBacking) : Color.Black));
                }
                if (index == 0)
                {
                    Utils.drawLine(sprBatch, new Vector2((float)(destinationRectangle.X + 1), (float)(destinationRectangle.Y + 1)), new Vector2((float)(destinationRectangle.X + destinationRectangle.Width - 2), (float)(destinationRectangle.Y + 1)), Vector2.Zero, this.ThemeColor, 0.8f);
                }
                Utils.drawLine(sprBatch, new Vector2((float)(destinationRectangle.X + 1), (float)(destinationRectangle.Y + destinationRectangle.Height - 2)), new Vector2((float)(destinationRectangle.X + destinationRectangle.Width - 2), (float)(destinationRectangle.Y + destinationRectangle.Height - 2)), Vector2.Zero, this.ThemeColor, 0.8f);
                if (flag1)
                {
                    sprBatch.Draw(Utils.white, new Rectangle(destinationRectangle.X, destinationRectangle.Y + 1, 8, destinationRectangle.Height - 2), this.ThemeColor);
                }
                string text = "[" + this.activeState.upgradeCounts[index].ToString("000") + "] " + this.upgradeNames[index];
                TextItem.doFontLabel(new Vector2((float)(destinationRectangle.X + 4 + (flag1 ? 10 : 0)), (float)(destinationRectangle.Y + 4)), text, GuiData.UISmallfont, new Color?(flag2 ? (GuiData.active == myID ? this.ThemeColor : (flag1 ? Color.White : Color.Gray)) : (flag1 ? Utils.AddativeWhite : Color.Gray)), (float)(destinationRectangle.Width - 6), float.MaxValue, false);
                ++drawnThisCycle;
            }), sb, bounds);
            Button.outlineOnly    = false;
            Button.drawingOutline = true;
        }
Пример #2
0
        private void DrawUpgrades(Rectangle bounds, SpriteBatch sb)
        {
            var panelHeight = 28;

            if (scrollerPanel == null)
            {
                scrollerPanel = new ScrollableSectionedPanel(panelHeight, sb.GraphicsDevice);
            }
            scrollerPanel.NumberOfPanels = upgradeNames.Count;
            Button.outlineOnly           = true;
            Button.drawingOutline        = false;
            var drawnThisCycle    = 0;
            var needsButtonChecks = bounds.Contains(GuiData.getMousePoint());

            scrollerPanel.Draw((index, drawAreaFull, sprBatch) =>
            {
                var destinationRectangle = new Rectangle(drawAreaFull.X, drawAreaFull.Y, drawAreaFull.Width - 12,
                                                         drawAreaFull.Height);
                var myID = 115700 + index * 111;
                if (needsButtonChecks &&
                    Button.doButton(myID, destinationRectangle.X, destinationRectangle.Y, destinationRectangle.Width,
                                    destinationRectangle.Height, "", Color.Transparent))
                {
                    PurchaseUpgrade(index);
                }
                else if (!needsButtonChecks && GuiData.hot == myID)
                {
                    GuiData.hot = -1;
                }
                var flag1 = upgradeCosts[index] <= (double)activeState.points;
                var flag2 = flag1 && GuiData.hot == myID;
                if (GuiData.hot == myID)
                {
                    hoverIndex = index;
                }
                if (flag2)
                {
                    var num1 = destinationRectangle.Height;
                    var num2 = 0;
                    var num3 = 0;
                    if (drawAreaFull.X == 0 && drawAreaFull.Y == 0)
                    {
                        if (drawnThisCycle == 0)
                        {
                            num2 = bounds.X;
                            num3 = bounds.Y;
                        }
                        else
                        {
                            num2 = bounds.X;
                            num3 = bounds.Y + bounds.Height - panelHeight / 2;
                        }
                    }
                    var rectangle = new Rectangle(num2 + destinationRectangle.X - num1,
                                                  num3 + destinationRectangle.Y - num1, destinationRectangle.Width + 2 * num1,
                                                  destinationRectangle.Height + 2 * num1);
                    for (var index1 = 0; index1 < Stars.Count; ++index1)
                    {
                        DrawStar(rectangle, sb, Stars[index1]);
                    }
                    sb.Draw(scanlinesTextBackground, rectangle, ThemeColor * (GuiData.active == myID ? 0.6f : 0.3f));
                }
                sprBatch.Draw(scanlinesTextBackground, destinationRectangle,
                              new Rectangle(scanlinesTextBackground.Width / 2, scanlinesTextBackground.Height / 9 * 4,
                                            scanlinesTextBackground.Width / 2, scanlinesTextBackground.Height / 4),
                              flag1 ? ThemeColor * 0.2f : Utils.AddativeWhite * 0.08f);
                if (GuiData.hot == myID)
                {
                    RenderedRectangle.doRectangle(destinationRectangle.X + 1, destinationRectangle.Y + 1,
                                                  destinationRectangle.Width - 2, destinationRectangle.Height - 2,
                                                  flag2 ? (GuiData.active == myID ? Color.Black : ThemeColorBacking) : Color.Black);
                }
                if (index == 0)
                {
                    Utils.drawLine(sprBatch, new Vector2(destinationRectangle.X + 1, destinationRectangle.Y + 1),
                                   new Vector2(destinationRectangle.X + destinationRectangle.Width - 2, destinationRectangle.Y + 1),
                                   Vector2.Zero, ThemeColor, 0.8f);
                }
                Utils.drawLine(sprBatch,
                               new Vector2(destinationRectangle.X + 1, destinationRectangle.Y + destinationRectangle.Height - 2),
                               new Vector2(destinationRectangle.X + destinationRectangle.Width - 2,
                                           destinationRectangle.Y + destinationRectangle.Height - 2), Vector2.Zero, ThemeColor, 0.8f);
                if (flag1)
                {
                    sprBatch.Draw(Utils.white,
                                  new Rectangle(destinationRectangle.X, destinationRectangle.Y + 1, 8,
                                                destinationRectangle.Height - 2), ThemeColor);
                }
                var text = "[" + activeState.upgradeCounts[index].ToString("000") + "] " + upgradeNames[index];
                TextItem.doFontLabel(
                    new Vector2(destinationRectangle.X + 4 + (flag1 ? 10 : 0), destinationRectangle.Y + 4), text,
                    GuiData.UISmallfont,
                    flag2
                        ? (GuiData.active == myID ? ThemeColor : (flag1 ? Color.White : Color.Gray))
                        : (flag1 ? Utils.AddativeWhite : Color.Gray), destinationRectangle.Width - 6, float.MaxValue);
                ++drawnThisCycle;
            }, sb, bounds);
            Button.outlineOnly    = false;
            Button.drawingOutline = true;
        }