Пример #1
0
        public void DrawText(string txt, int x, int y, Vector4 col)
        {
            if (Font == null)
            {
                Font = new Font2.OrchidFont("data/font/font1.ttf", 12);
            }

            var tex = Font.GenString(txt);

            if (tex != null)
            {
                DrawForm(tex, col, x, y + tex.H / 2, tex.W, tex.H);
            }

            //FontRenderer.Draw(UI.Font, txt, GX + x + OffX, GY + y + OffY, col * UI.BootAlpha);
        }
Пример #2
0
        public ButtonForm()
        {
            if (Font == null)
            {
                Font = new Font2.OrchidFont("data/font/font1.ttf", 12);
            }

            if (ButTex == null)
            {
                ButTex = new Texture2D("data/nxUI/window/title2.png", LoadMethod.Single, true);
            }
            SetImage(ButTex);
            Col = new Vector4(1, 1, 1, 1);

            void DrawFunc()
            {
                Pen2D.BlendMod = PenBlend.Alpha;

                DrawFormSolid(new Vector4(0, 0, 0, 1));
                DrawForm(CoreTex, 1, 1, W - 2, H - 2);
                //if (Text == "") return;

                //DrawText(Text, (W / 2 - Font.Width(Text) / 2)+4, (H / 2 - Font.Height())+4, new Vector4(0, 0, 0, 1));
                DrawText(Text, W / 2 - Font.Width(Text) / 2, H / 2 - Font.Height(), new Vector4(0, 0, 0, 1));
            }

            void MouseEnterFunc()
            {
                if (Pressed == false)
                {
                    Col = OverCol;
                }
                Over = true;
            }

            void MouseLeaveFunc()
            {
                if (Pressed == false)
                {
                    Col = NormCol;
                }
                Over = false;
            }

            void MouseMoveFunc(int x, int y, int dx, int dy)
            {
                if (Pressed)
                {
                    // Drag?.Invoke(dx, dy);
                }
            }

            void MouseDownFunc(int b)
            {
                Col     = PressCol;
                Pressed = true;
            }

            void MouseUpFunc(int b)
            {
                if (Over)
                {
                    Col = OverCol;
                }
                else
                {
                    Col = NormCol;
                }
                Pressed = false;
                Console.WriteLine("CLicked!");
                if (Click != null)
                {
                    Console.WriteLine("Has click");
                }
                Click?.Invoke(b);
            }

            Draw       = DrawFunc;
            MouseEnter = MouseEnterFunc;
            MouseLeave = MouseLeaveFunc;
            MouseMove  = MouseMoveFunc;
            MouseDown  = MouseDownFunc;
            MouseUp    = MouseUpFunc;
        }
Пример #3
0
        public ButtonForm()
        {
            Selectable = true;
            if (BleepSrc == null)
            {
                //BleepSrc = new Vivid.Audio.Songs.
                BleepSrc = Vivid.Audio.Songs.LoadSound("Corona/Sound/UI/beep1.wav");
                BingSrc  = Vivid.Audio.Songs.LoadSound("Corona/Sound/UI/click1.wav");
            }
            if (Font == null)
            {
                Font = new Font2.OrchidFont("data/font/font1.ttf", 12);
            }

            if (ButTex == null)
            {
                ButTex = new Texture2D("data/nxUI/button/button4.png", LoadMethod.Single, true);
            }
            SetImage(ButTex);
            Col = NormCol;

            void DrawFunc()
            {
                Pen2D.BlendMod = PenBlend.Alpha;

                //   DrawFormSolid(new Vector4(0, 0, 0, 1));
                DrawForm(CoreTex, new Vector4(Col.X * UI.CurUI.FadeAlpha, Col.Y * UI.CurUI.FadeAlpha, Col.Z * UI.CurUI.FadeAlpha, UI.CurUI.FadeAlpha), 1, 1, W - 2, H - 2);
                //if (Text == "") return;

                //DrawText(Text, (W / 2 - Font.Width(Text) / 2)+4, (H / 2 - Font.Height())+4, new Vector4(0, 0, 0, 1));
                DrawText(Text, W / 2 - Font.Width(Text) / 2, H / 2 - Font.Height(), new Vector4(0, 1 * UI.CurUI.FadeAlpha, 1 * UI.CurUI.FadeAlpha, 1 * UI.CurUI.FadeAlpha));
            }

            void MouseEnterFunc()
            {
                if (Pressed == false)
                {
                    Col = OverCol;
                }
                Vivid.Audio.Songs.PlaySource(BingSrc);
                Over = true;
            }

            void MouseLeaveFunc()
            {
                if (Pressed == false)
                {
                    Col = NormCol;
                }
                Over = false;
            }

            void MouseMoveFunc(int x, int y, int dx, int dy)
            {
                if (Pressed)
                {
                    // Drag?.Invoke(dx, dy);
                }
            }

            void MouseDownFunc(int b)
            {
                Col = PressCol;
                Vivid.Audio.Songs.PlaySource(BleepSrc);
                Pressed = true;
            }

            void MouseUpFunc(int b)
            {
                if (Over)
                {
                    Col = OverCol;
                }
                else
                {
                    Col = NormCol;
                }
                Pressed = false;
                Console.WriteLine("CLicked!");
                if (Click != null)
                {
                    Console.WriteLine("Has click");
                }
                Click?.Invoke(b);
            }

            Draw       = DrawFunc;
            MouseEnter = MouseEnterFunc;
            MouseLeave = MouseLeaveFunc;
            MouseMove  = MouseMoveFunc;
            MouseDown  = MouseDownFunc;
            MouseUp    = MouseUpFunc;
        }