예제 #1
0
파일: UI.cs 프로젝트: VividCoder/SpaceRPG
        private void UpdateUpdateList(UIForm begin)
        {
            //  UpdateList.Clear();

            AddNodeBackward(UpdateList, begin);
        }
예제 #2
0
파일: UI.cs 프로젝트: VividCoder/SpaceRPG
        private void UpdateInput()
        {
            UIForm top = GetTopForm(MX, MY);

            if (top != null)
            {
                if (TopForm != top)
                {
                    if (TopForm != null)
                    {
                        if (TopForm != Pressed[0])
                        {
                            TopForm.MouseLeave?.Invoke();
                        }
                    }

                    top.MouseEnter?.Invoke();
                }
            }
            bool am = false;

            if (top != null)
            {
                if (top == TopForm)
                {
                    //    am = true;
                    //     top.MouseMove?.Invoke(MX - top.GX, MY - top.GY, MXD, MYD);
                }
            }
            bool pm = false;

            for (int i = 0; i < 32; i++)
            {
                if (Pressed[i] != null)
                {
                    pm = true;
                    Pressed[i].MouseMove?.Invoke(MX - Pressed[i].GX, MY - Pressed[i].GY, MXD, MYD);
                    break;
                }
            }
            if (TopForm != null && pm == false)
            {
                TopForm.MouseMove?.Invoke(MX - TopForm.GX, MY - TopForm.GY, MXD, MYD);
            }

            if (top == null)
            {
                if (TopForm != null)
                {
                    if (TopForm != Pressed[0])
                    {
                        TopForm.MouseLeave?.Invoke();
                    }
                }
            }
            TopForm = top;

            if (Active != null)
            {
                Active.KeysIn?.Invoke(Input.Input.KeysIn());

                OpenTK.Input.Key key = Input.Input.KeyIn();
                if (key != OpenTK.Input.Key.LastKey)
                {
                    if (key == OpenTK.Input.Key.LastKey)
                    {
                        LastKey = OpenTK.Input.Key.LastKey;
                        NextKey = 0;
                    }
                    if (key == LastKey)
                    {
                        bool shift = false;
                        if (Input.Input.KeyIn(OpenTK.Input.Key.ShiftLeft))
                        {
                            shift = true;
                        }
                        if (Input.Input.KeyIn(OpenTK.Input.Key.ShiftRight))
                        {
                            shift = true;
                        }
                        if (Environment.TickCount > NextKey)
                        {
                            Active.KeyPress?.Invoke(key, shift);
                            NextKey = Environment.TickCount + 90;
                        }
                    }
                    else
                    {
                        bool shift = false;
                        if (Input.Input.KeyIn(OpenTK.Input.Key.ShiftLeft))
                        {
                            shift = true;
                        }
                        if (Input.Input.KeyIn(OpenTK.Input.Key.ShiftRight))
                        {
                            shift = true;
                        }
                        LastKey = key;
                        Active.KeyPress?.Invoke(key, shift);
                        NextKey = Environment.TickCount + 250;
                    }
                }
            }

            if (Input.Input.AnyButtons())
            {
                int bn = Input.Input.ButtonNum();
                if (TopForm != ActiveMenu)
                {
                    //ActiveMenu = null;
                }
                if (TopForm != null)
                {
                    if (Pressed[bn] == null)
                    {
                        if (bn == 0)
                        {
                            //if (ActiveMenu)
                            if (ActiveMenu != null)
                            {
                                if (TopForm == ActiveMenu.Owner)
                                {
                                    ActiveMenu = null;
                                }
                            }
                        }
                        if (bn == 1)
                        {
                            if (TopForm.ContextMenu != null)
                            {
                                ActiveMenu       = TopForm.ContextMenu;
                                ActiveMenu.X     = MX - 10;
                                ActiveMenu.Y     = MY - 10;
                                ActiveMenu.Owner = TopForm;
                                goto SkipClick;
                            }
                        }

                        if (Environment.TickCount < lastClick + 300)
                        {
                            clicks++;
                            if (clicks == 2)
                            {
                                TopForm.DoubleClick?.Invoke(bn);
                            }
                        }
                        else
                        {
                            clicks = 1;
                            //TopForm.Click?.Invoke(0);
                        }
                        lastClick = Environment.TickCount;
                        TopForm.MouseDown?.Invoke(bn);

                        Pressed[bn] = TopForm;
                        if (Active != TopForm)
                        {
                            if (Active != null)
                            {
                                Active.Deactivate?.Invoke();
                            }
                        }
                        Active = TopForm;
                        TopForm.Activate?.Invoke();
                        UIForm root = TopForm;
                        if (bn == 0)
                        {
                            while (true)
                            {
                                if (root.GetType().IsSubclassOf(typeof(Forms.WindowForm)))
                                {
                                    if (root.Root != null)
                                    {
                                        root.Root.Forms.Remove(root);
                                        root.Root.Forms.Add(root);
                                    }
                                    break;
                                }
                                root = root.Root;
                                if (root == null)
                                {
                                    break;
                                }
                            }
                        }
                        if (sdrag)
                        {
                            sdx = MX;
                            sdy = MY;
                        }
                    }
                    else if (Pressed[bn] == TopForm)
                    {
                        TopForm.MousePressed?.Invoke(bn);
                    }
                    else if (Pressed[bn] != TopForm)
                    {
                        Pressed[bn].MousePressed?.Invoke(bn);
                    }
                }
                else
                {
                    if (Pressed[bn] != null)
                    {
                        Pressed[bn].MousePressed?.Invoke(0);
                        //  Pressed[bn].Click?.Invoke(0);
                    }
                }

                if (Pressed[bn] != null)
                {
                    // Console.WriteLine("MX:" + MX + " MY:" + MY + " SDX:" + sdx + " SDY:" + sdy);
                    int mvx = MX - sdx;
                    int mvy = MY - sdy;
                    if (mvx != 0 || mvy != 0)
                    {
                        Pressed[bn].Drag?.Invoke(mvx, mvy);
                        Pressed[bn].PostDrag?.Invoke(mvx, mvy);
                    }
                    sdx = MX;

                    sdy = MY;
                    //Console.WriteLine(@)

                    //sdx = MX-Pressed[0].GY;

                    //sdy = MY-Pressed[0].GY;
                }
            }
            else
            {
                for (int i = 0; i < 32; i++)
                {
                    //Console.WriteLine("Wop");
                    if (Pressed[i] != null)
                    {
                        if (Pressed[i].InBounds(MX, MY) == false)
                        {
                            Pressed[i].MouseLeave?.Invoke();
                        }

                        Pressed[i].MouseUp?.Invoke(i);
                        if (!(Pressed[i] is Resonance.Forms.ButtonForm))
                        {
                            Pressed[i].Click?.Invoke(i);
                        }
                        Pressed[i] = null;
                        sdrag      = true;
                    }
                }
            }
            for (int i = 0; i < 32; i++)
            {
                if (Pressed[i] != null)
                {
                    WindS += (float)(Math.Abs(MXD + MYD)) / 150.0f;
                    if (WindS > 1.5f)
                    {
                        WindS = 1.5f;
                    }
                }
            }
SkipClick:

            return;
        }
예제 #3
0
파일: UI.cs 프로젝트: VividCoder/SpaceRPG
 private void UpdateRenderList(UIForm begin)
 {
     AddNodeForward(RenderList, begin);
 }
예제 #4
0
파일: UI.cs 프로젝트: VividCoder/SpaceRPG
        public void Render2()
        {
            if (FullScreenOn)
            {
                FullScreen.Root.Set(0, 0, App.AppInfo.W, App.AppInfo.H);
                FullScreen.Render();

                return;
            }

            // Vivid.Draw.IntelliDraw.BeginDraw();

            if (Top != null)
            {
                TopB = TopB + 0.045f;
                if (TopB > 0.8f)
                {
                    TopB = 0.8f;
                }
            }
            else
            {
                TopB = TopB - 0.088f;
                if (TopB < 0)
                {
                    TopB = 0;
                }
            }

            UIForm prev = null;

            RenderList.Clear();

            if (Top != null)
            {
                UpdateRenderList(Root);
                if (ActiveMenu != null)
                {
                    UpdateRenderList(ActiveMenu);
                }

                foreach (UIForm form in RenderList)
                {
                    GL.Scissor(form.ViewX, Vivid.App.AppInfo.H - (form.ViewY + form.ViewH), form.ViewW, form.ViewH);
                    //  // GL.Scissor(form.ViewX, form.ViewY, form.ViewW, form.ViewH);
                    // GL.Scissor(0, 0, App.AppInfo.W, App.AppInfo.H);
                    //  GL.Scissor(form.ViewX, form.ViewY, form.ViewW, form.ViewH);
                    GL.Enable(EnableCap.ScissorTest);
                    Vivid.Draw.IntelliDraw.BeginDraw();
                    form.Draw?.Invoke();
                    Vivid.Draw.IntelliDraw.EndDraw();
                }
                if (ActiveMenu != null)
                {
                    var form = ActiveMenu;
                    GL.Scissor(form.ViewX, Vivid.App.AppInfo.H - (form.ViewY + form.ViewH), form.ViewW, form.ViewH);
                    //  // GL.Scissor(form.ViewX, form.ViewY, form.ViewW, form.ViewH);
                    // GL.Scissor(0, 0, App.AppInfo.W, App.AppInfo.H);
                    //  GL.Scissor(form.ViewX, form.ViewY, form.ViewW, form.ViewH);
                    GL.Enable(EnableCap.ScissorTest);
                    Vivid.Draw.IntelliDraw.BeginDraw();
                    //form.Draw?.Invoke();

                    ActiveMenu.Draw.Invoke();
                    Vivid.Draw.IntelliDraw.EndDraw();
                }
                Texture.Texture2D ntex = new Texture.Texture2D(Vivid.App.VividApp.W, Vivid.App.VividApp.H);

                ntex.CopyTex(0, 0);
                //  OpenTK.Graphics.OpenGL4.GL.Clear(OpenTK.Graphics.OpenGL4.ClearBufferMask.ColorBufferBit);
                //  Iris3D.Draw.Pen2D.RectBlur2(0, 0, Iris3D.App.IrisApp.W, Iris3D.App.IrisApp.H, ntex, new OpenTK.Vector4(1, 1, 1, 1), TopB);

                RenderList.Clear();

                foreach (UIForm form in RenderList)
                {
                    GL.Scissor(form.ViewX, Vivid.App.AppInfo.H - (form.ViewY + form.ViewH), form.ViewW, form.ViewH);
                    //  // GL.Scissor(form.ViewX, form.ViewY, form.ViewW, form.ViewH);
                    // GL.Scissor(0, 0, App.AppInfo.W, App.AppInfo.H);
                    //  GL.Scissor(form.ViewX, form.ViewY, form.ViewW, form.ViewH);
                    GL.Enable(EnableCap.ScissorTest);
                    Vivid.Draw.IntelliDraw.BeginDraw();
                    form.Draw?.Invoke();
                    Vivid.Draw.IntelliDraw.EndDraw();
                }
                GL.Disable(EnableCap.ScissorTest);

                RenderList.Clear();
                foreach (var f in Overlay)
                {
                    UpdateRenderList(f);
                }


                UpdateRenderList(Top);

                // RenderList.Reverse();
                GL.Disable(EnableCap.ScissorTest);
                foreach (UIForm form in RenderList)
                {
                    //form.ViewH= Vivid.App.AppInfo.H/
                    //Vivid.App.SetVP.Set(form.ViewX, Vivid.App.AppInfo.H - (form.ViewY + form.ViewH), form.ViewW, form.ViewH);
                    // GL.Scissor(form.ViewX, Vivid.App.AppInfo.H - (form.ViewY + form.ViewH), form.ViewW, form.ViewH);
                    //  // GL.Scissor(form.ViewX, form.ViewY, form.ViewW, form.ViewH);
                    // GL.Scissor(0, 0, App.AppInfo.W, App.AppInfo.H);
                    //  GL.Scissor(form.ViewX, form.ViewY, form.ViewW, form.ViewH);
                    //   GL.Enable(EnableCap.ScissorTest);
                    GL.Clear(ClearBufferMask.DepthBufferBit);
                    Vivid.Draw.IntelliDraw.BeginDraw();
                    form.Draw?.Invoke();
                    Vivid.Draw.IntelliDraw.EndDraw();
                }


                // Vivid.App.SetVP.Set(0, 0, Vivid.App.AppInfo.W, Vivid.App.AppInfo.H);

                ntex.Delete();
            }
            else
            {
                UpdateRenderList(Root);
                if (ActiveMenu != null)
                {
                    UpdateRenderList(ActiveMenu);
                }


                if (DragObj != null)
                {
                    UpdateRenderList(DragObj);
                }

                GL.DepthMask(false);

                foreach (UIForm form in RenderList)
                {
                    //form.ViewH= Vivid.App.AppInfo.H/
                    //Vivid.App.SetVP.Set(form.ViewX, Vivid.App.AppInfo.H - (form.ViewY + form.ViewH), form.ViewW, form.ViewH);
                    GL.Scissor(form.ViewX, Vivid.App.AppInfo.H - (form.ViewY + form.ViewH), form.ViewW, form.ViewH);
                    //  // GL.Scissor(form.ViewX, form.ViewY, form.ViewW, form.ViewH);
                    // GL.Scissor(0, 0, App.AppInfo.W, App.AppInfo.H);
                    //  GL.Scissor(form.ViewX, form.ViewY, form.ViewW, form.ViewH);
                    if (form.Clip)
                    {
                        GL.Enable(EnableCap.ScissorTest);
                    }
                    else
                    {
                        GL.Disable(EnableCap.ScissorTest);
                    }
                    // GL.Disable(EnableCap.ScissorTest);
                    GL.Clear(ClearBufferMask.DepthBufferBit);
                    GL.DepthMask(false);
                    Vivid.Draw.IntelliDraw.BeginDraw();
                    form.Draw?.Invoke();
                    Vivid.Draw.IntelliDraw.EndDraw();
                }

                GL.DepthMask(true);

                RenderList.Clear();
                foreach (var f in Overlay)
                {
                    UpdateRenderList(f);
                }
                // RenderList.Reverse();
                GL.Disable(EnableCap.ScissorTest);
                foreach (UIForm form in RenderList)
                {
                    //form.ViewH= Vivid.App.AppInfo.H/
                    //Vivid.App.SetVP.Set(form.ViewX, Vivid.App.AppInfo.H - (form.ViewY + form.ViewH), form.ViewW, form.ViewH);
                    GL.Scissor(form.ViewX, Vivid.App.AppInfo.H - (form.ViewY + form.ViewH), form.ViewW, form.ViewH);
                    //  // GL.Scissor(form.ViewX, form.ViewY, form.ViewW, form.ViewH);
                    // GL.Scissor(0, 0, App.AppInfo.W, App.AppInfo.H);
                    //  GL.Scissor(form.ViewX, form.ViewY, form.ViewW, form.ViewH);
                    //   GL.Enable(EnableCap.ScissorTest);
                    if (form.Clip)
                    {
                        GL.Enable(EnableCap.ScissorTest);
                    }
                    else
                    {
                        GL.Disable(EnableCap.ScissorTest);
                    }
                    GL.Clear(ClearBufferMask.DepthBufferBit);
                    Vivid.Draw.IntelliDraw.BeginDraw();
                    form.Draw?.Invoke();
                    Vivid.Draw.IntelliDraw.EndDraw();
                }

                GL.Disable(EnableCap.ScissorTest);
                // Vivid.App.SetVP.Set(0, 0, Vivid.App.AppInfo.W, Vivid.App.AppInfo.H);


                if (TopB > 0)
                {
                    Texture.Texture2D ntex = new Texture.Texture2D(Vivid.App.VividApp.W, Vivid.App.VividApp.H);
                    ntex.CopyTex(0, 0);
                    OpenTK.Graphics.OpenGL4.GL.Clear(OpenTK.Graphics.OpenGL4.ClearBufferMask.ColorBufferBit);
                    // Iris3D.Draw.Pen2D.RectBlur2(0, 0, Iris3D.App.IrisApp.W, Iris3D.App.IrisApp.H, ntex, new OpenTK.Vector4(1, 1, 1, 1), TopB);
                    ntex.Delete();
                }
            }

            RenderList.Clear();
            UpdateRenderList(Dock);
            Vivid.Draw.IntelliDraw.BeginDraw();
            foreach (var f in RenderList)
            {
                f?.Draw();
            }
            Vivid.Draw.IntelliDraw.EndDraw();
            //Dock.Draw?.Invoke();

            // Vivid.Draw.IntelliDraw.EndDraw();

            return;

            GL.Clear(ClearBufferMask.DepthBufferBit);

            Vivid.Draw.IntelliDraw.BeginDraw();

            Vivid.Draw.IntelliDraw.DrawImg(MX, MY, 24, 24, CursorImg, new Vector4(1, 1, 1, 1));

            Vivid.Draw.IntelliDraw.EndDraw();

            return;

            //  GL.Disable(EnableCap.ScissorTest);
            Vivid.Draw.Pen2D.SetProj(0, 0, Vivid.App.AppInfo.W, Vivid.App.AppInfo.H);
            Vivid.Draw.Pen2D.BlendMod = Vivid.Draw.PenBlend.Alpha;
            Vivid.Draw.Pen2D.Rect(MX, MY, 24, 24, CursorImg, new OpenTK.Vector4(1, 1, 1, 1));

            GL.DisableVertexAttribArray(0);
            GL.DisableVertexAttribArray(1);
            GL.DisableVertexAttribArray(2);
            Vivid.Draw.Pen2D.Unbindv();
            GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.DepthTest);
        }