Пример #1
0
        public static bool doHoldDownButton(int myID, int x, int y, int width, int height, string text, bool hasOutline,
                                            Color?outlineColor, Color?selectedColor)
        {
            wasPressedDown = false;
            wasReleased    = false;
            if (!outlineColor.HasValue)
            {
                outlineColor = Color.White;
            }
            if (!selectedColor.HasValue)
            {
                selectedColor = GuiData.Default_Selected_Color;
            }
            var destinationRectangle = GuiData.tmpRect;

            destinationRectangle.X      = x;
            destinationRectangle.Y      = y;
            destinationRectangle.Width  = width;
            destinationRectangle.Height = height;
            var flag = GuiData.isMouseLeftDown() && GuiData.active == myID;

            if (destinationRectangle.Contains(GuiData.getMousePoint()))
            {
                GuiData.hot = myID;
                if (GuiData.mouseWasPressed())
                {
                    wasPressedDown = true;
                }
                if (GuiData.isMouseLeftDown())
                {
                    GuiData.active = myID;
                    flag           = true;
                }
            }
            else
            {
                if (GuiData.hot == myID)
                {
                    GuiData.hot = -1;
                }
                if (!GuiData.isMouseLeftDown() && GuiData.active == myID && GuiData.active == myID)
                {
                    GuiData.active = -1;
                }
            }
            if (GuiData.mouseLeftUp())
            {
                wasReleased = true;
            }
            GuiData.spriteBatch.Draw(Utils.white, destinationRectangle,
                                     GuiData.active == myID
                    ? selectedColor.Value
                    : (GuiData.hot == myID ? GuiData.Default_Lit_Backing_Color : GuiData.Default_Light_Backing_Color));
            if (hasOutline)
            {
                RenderedRectangle.doRectangleOutline(x, y, width, height, 2, outlineColor);
            }
            return(flag);
        }
Пример #2
0
        private static void drawModernButton(int myID, int x, int y, int width, int height, string text,
                                             Color?selectedColor, Texture2D tex)
        {
            var num1 = width > 65 ? 13 : 0;

            if (!selectedColor.HasValue)
            {
                selectedColor = GuiData.Default_Trans_Grey_Strong;
            }
            var destinationRectangle = GuiData.tmpRect;

            destinationRectangle.X      = x;
            destinationRectangle.Y      = y;
            destinationRectangle.Width  = width;
            destinationRectangle.Height = height;
            if (tex.Equals(Utils.white))
            {
                if (!outlineOnly)
                {
                    GuiData.spriteBatch.Draw(Utils.white, destinationRectangle,
                                             GuiData.hot == myID
                            ? (GuiData.active == myID
                                ? GuiData.Default_Trans_Grey_Dark
                                : GuiData.Default_Trans_Grey_Bright)
                            : GuiData.Default_Trans_Grey);
                    destinationRectangle.Width = num1;
                    GuiData.spriteBatch.Draw(Utils.white, destinationRectangle, selectedColor.Value);
                }
                RenderedRectangle.doRectangleOutline(x, y, width, height, 1,
                                                     outlineOnly ? selectedColor : GuiData.Default_Trans_Grey_Solid);
            }
            else
            {
                GuiData.spriteBatch.Draw(tex, destinationRectangle,
                                         GuiData.hot == myID
                        ? (GuiData.active == myID ? GuiData.Default_Unselected_Color : GuiData.Default_Lit_Backing_Color)
                        : selectedColor.Value);
            }
            var spriteFont = smallButtonDraw ? GuiData.detailfont : GuiData.tinyfont;
            var scale      = spriteFont.MeasureString(text);
            var num2       = scale.Y;

            scale.X = scale.X <= (double)(width - 4) ? 1f : (width - (4 + num1 + 5)) / scale.X;
            scale.Y = scale.Y <= (double)height ? 1f : height / scale.Y;
            scale.X = Math.Min(scale.X, scale.Y);
            scale.Y = scale.X;
            var num3 = num1 + 4;
            var num4 = num2 * scale.Y;
            var y1   = (float)(y + height / 2.0 - num4 / 2.0 + 1.0);

            GuiData.spriteBatch.DrawString(spriteFont, text, new Vector2(x + 2 + num3, y1), Color.White, 0.0f,
                                           Vector2.Zero, scale, SpriteEffects.None, 0.5f);
        }
Пример #3
0
        public static void doRectangle(int x, int y, int width, int height, Color?color, bool blocking)
        {
            RenderedRectangle.doRectangle(x, y, width, height, color);
            Rectangle tmpRect = GuiData.tmpRect;

            tmpRect.X      = x;
            tmpRect.Y      = y;
            tmpRect.Width  = width;
            tmpRect.Height = height;
            if (!blocking || !tmpRect.Contains(GuiData.getMousePoint()))
            {
                return;
            }
            GuiData.blockingInput = true;
        }
Пример #4
0
        private static void drawModernButton(int myID, int x, int y, int width, int height, string text, Color?selectedColor, Texture2D tex)
        {
            int num1 = Button.ForceNoColorTag || width <= 65 ? 0 : 13;

            if (!selectedColor.HasValue)
            {
                selectedColor = new Color?(GuiData.Default_Trans_Grey_Strong);
            }
            Rectangle tmpRect = GuiData.tmpRect;

            tmpRect.X      = x;
            tmpRect.Y      = y;
            tmpRect.Width  = width;
            tmpRect.Height = height;
            if (tex.Equals((object)Utils.white))
            {
                if (!Button.outlineOnly)
                {
                    GuiData.spriteBatch.Draw(Utils.white, tmpRect, GuiData.hot == myID ? (GuiData.active == myID ? GuiData.Default_Trans_Grey_Dark : GuiData.Default_Trans_Grey_Bright) : GuiData.Default_Trans_Grey);
                    tmpRect.Width = num1;
                    GuiData.spriteBatch.Draw(Utils.white, tmpRect, selectedColor.Value);
                }
                RenderedRectangle.doRectangleOutline(x, y, width, height, 1, Button.outlineOnly ? selectedColor : new Color?(GuiData.Default_Trans_Grey_Solid));
            }
            else
            {
                GuiData.spriteBatch.Draw(tex, tmpRect, GuiData.hot == myID ? (GuiData.active == myID ? GuiData.Default_Unselected_Color : GuiData.Default_Lit_Backing_Color) : selectedColor.Value);
            }
            SpriteFont spriteFont = Button.smallButtonDraw ? GuiData.detailfont : GuiData.tinyfont;
            Vector2    scale      = spriteFont.MeasureString(text);
            float      num2       = LocaleActivator.ActiveLocaleIsCJK() ? 4f : 0.0f;
            float      y1         = scale.Y;

            scale.X = (double)scale.X <= (double)(width - 4) ? 1f : (float)(width - (4 + num1 + 5)) / scale.X;
            scale.Y = (double)scale.Y <= (double)height + (double)num2 - 0.0 ? 1f : (float)((double)height + (double)num2 - 0.0) / scale.Y;
            scale.X = Math.Min(scale.X, scale.Y);
            scale.Y = scale.X;
            if (Utils.FloatEquals(1f, scale.Y))
            {
                scale = Vector2.One;
            }
            int   num3 = num1 + 4;
            float num4 = y1 * scale.Y;
            float num5 = (float)((double)y + (double)height / 2.0 - (double)num4 / 2.0 + 1.0 - (double)num2 * (double)scale.Y / 2.0);

            GuiData.spriteBatch.DrawString(spriteFont, text, new Vector2((float)(int)((double)(x + 2 + num3) + 0.5), (float)(int)((double)num5 + 0.5)), Color.White, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 0.5f);
        }
Пример #5
0
        private static void drawButton(int myID, int x, int y, int width, int height, string text, Color?selectedColor,
                                       Texture2D tex)
        {
            var destinationRectangle = GuiData.tmpRect;

            destinationRectangle.X      = x;
            destinationRectangle.Y      = y;
            destinationRectangle.Width  = width;
            destinationRectangle.Height = height;
            --destinationRectangle.X;
            destinationRectangle.Width += 2;
            --destinationRectangle.Y;
            destinationRectangle.Height += 2;
            if (outlineOnly)
            {
                RenderedRectangle.doRectangleOutline(destinationRectangle.X, destinationRectangle.Y,
                                                     destinationRectangle.Width, destinationRectangle.Height, 1,
                                                     GuiData.hot == myID
                        ? (GuiData.active == myID ? GuiData.Default_Selected_Color : GuiData.Default_Lit_Backing_Color)
                        : GuiData.Default_Backing_Color);
            }
            else if (drawingOutline)
            {
                GuiData.spriteBatch.Draw(tex, destinationRectangle,
                                         GuiData.hot == myID ? GuiData.Default_Lit_Backing_Color : GuiData.Default_Backing_Color);
            }
            ++destinationRectangle.X;
            destinationRectangle.Width -= 2;
            ++destinationRectangle.Y;
            destinationRectangle.Height -= 2;
            if (!outlineOnly)
            {
                GuiData.spriteBatch.Draw(tex, destinationRectangle,
                                         GuiData.active == myID ? GuiData.Default_Unselected_Color : selectedColor.Value);
            }
            var scale = GuiData.tinyfont.MeasureString(text);

            scale.X = scale.X <= (double)(width - 4) ? 1f : (width - 4) / scale.X;
            scale.Y = scale.Y <= (double)(height - 4) ? 1f : (height - 2) / scale.Y;
            scale.X = Math.Min(scale.X, scale.Y);
            scale.Y = scale.X;
            GuiData.spriteBatch.DrawString(GuiData.tinyfont, text, new Vector2(x + 2 + 1, y + 1 + 1), Color.Black, 0.0f,
                                           Vector2.Zero, scale, SpriteEffects.None, 0.5f);
            GuiData.spriteBatch.DrawString(GuiData.tinyfont, text, new Vector2(x + 2, y + 1), Color.White, 0.0f,
                                           Vector2.Zero, scale, SpriteEffects.None, 0.5f);
        }
Пример #6
0
        public static bool doCheckBox(int myID, int x, int y, bool isChecked, Color?selectedColor)
        {
            if (!selectedColor.HasValue)
            {
                selectedColor = GuiData.Default_Selected_Color;
            }
            if (GuiData.hot == myID && GuiData.active == myID && GuiData.mouseLeftUp())
            {
                isChecked      = !isChecked;
                GuiData.active = -1;
            }
            RenderedRectangle.doRectangleOutline(x, y, 20, 20, 2,
                                                 GuiData.hot == myID ? GuiData.Default_Lit_Backing_Color : GuiData.Default_Light_Backing_Color);
            RenderedRectangle.doRectangle(x + 4, y + 4, 12, 12,
                                          isChecked
                    ? selectedColor
                    : (GuiData.active == myID ? GuiData.Default_Unselected_Color : GuiData.Default_Backing_Color));
            var rectangle = GuiData.tmpRect;

            rectangle.X      = x;
            rectangle.Y      = y;
            rectangle.Width  = 20;
            rectangle.Height = 20;
            if (rectangle.Contains(GuiData.getMousePoint()))
            {
                GuiData.hot = myID;
                if (GuiData.isMouseLeftDown())
                {
                    GuiData.active = myID;
                }
            }
            else
            {
                if (GuiData.hot == myID)
                {
                    GuiData.hot = -1;
                }
                if (GuiData.isMouseLeftDown() && GuiData.active == myID && GuiData.active == myID)
                {
                    GuiData.active = -1;
                }
            }
            return(isChecked);
        }
Пример #7
0
        private static void drawButton(int myID, int x, int y, int width, int height, string text, Color?selectedColor, Texture2D tex)
        {
            Rectangle tmpRect = GuiData.tmpRect;

            tmpRect.X      = x;
            tmpRect.Y      = y;
            tmpRect.Width  = width;
            tmpRect.Height = height;
            --tmpRect.X;
            tmpRect.Width += 2;
            --tmpRect.Y;
            tmpRect.Height += 2;
            if (Button.outlineOnly)
            {
                RenderedRectangle.doRectangleOutline(tmpRect.X, tmpRect.Y, tmpRect.Width, tmpRect.Height, 1, new Color?(GuiData.hot == myID ? (GuiData.active == myID ? GuiData.Default_Selected_Color : GuiData.Default_Lit_Backing_Color) : GuiData.Default_Backing_Color));
            }
            else if (Button.drawingOutline)
            {
                GuiData.spriteBatch.Draw(tex, tmpRect, GuiData.hot == myID ? GuiData.Default_Lit_Backing_Color : GuiData.Default_Backing_Color);
            }
            ++tmpRect.X;
            tmpRect.Width -= 2;
            ++tmpRect.Y;
            tmpRect.Height -= 2;
            if (!Button.outlineOnly)
            {
                GuiData.spriteBatch.Draw(tex, tmpRect, GuiData.active == myID ? GuiData.Default_Unselected_Color : selectedColor.Value);
            }
            Vector2 scale = GuiData.tinyfont.MeasureString(text);

            scale.X = (double)scale.X <= (double)(width - 4) ? 1f : (float)(width - 4) / scale.X;
            scale.Y = (double)scale.Y <= (double)(height - 4) ? 1f : (float)(height - 2) / scale.Y;
            scale.X = Math.Min(scale.X, scale.Y);
            scale.Y = scale.X;
            GuiData.spriteBatch.DrawString(GuiData.tinyfont, text, new Vector2((float)(x + 2 + 1), (float)(y + 1 + 1)), Color.Black, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 0.5f);
            GuiData.spriteBatch.DrawString(GuiData.tinyfont, text, new Vector2((float)(x + 2), (float)(y + 1)), Color.White, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 0.5f);
        }