Exemplo n.º 1
0
 static void OnKey(SFMLDevice Dev, KeyEventArgs E, bool Down)
 {
     if (E.Code == Keyboard.Key.LShift || E.Code == Keyboard.Key.RShift)
     {
         Dev.OnKey(nk_keys.NK_KEY_SHIFT, Down);
     }
     else if (E.Code == Keyboard.Key.LControl || E.Code == Keyboard.Key.RControl)
     {
         Dev.OnKey(nk_keys.NK_KEY_CTRL, Down);
     }
     else if (E.Code == Keyboard.Key.Delete)
     {
         Dev.OnKey(nk_keys.NK_KEY_DEL, Down);
     }
     else if (E.Code == Keyboard.Key.Return)
     {
         Dev.OnKey(nk_keys.NK_KEY_ENTER, Down);
     }
     else if (E.Code == Keyboard.Key.Tab)
     {
         Dev.OnKey(nk_keys.NK_KEY_TAB, Down);
     }
     else if (E.Code == Keyboard.Key.BackSpace)
     {
         Dev.OnKey(nk_keys.NK_KEY_BACKSPACE, Down);
     }
     else if (E.Code == Keyboard.Key.Up)
     {
         Dev.OnKey(nk_keys.NK_KEY_UP, Down);
     }
     else if (E.Code == Keyboard.Key.Down)
     {
         Dev.OnKey(nk_keys.NK_KEY_DOWN, Down);
     }
     else if (E.Code == Keyboard.Key.Left)
     {
         Dev.OnKey(nk_keys.NK_KEY_LEFT, Down);
     }
     else if (E.Code == Keyboard.Key.Right)
     {
         Dev.OnKey(nk_keys.NK_KEY_RIGHT, Down);
     }
     else if (E.Code == Keyboard.Key.Home)
     {
         Dev.OnKey(nk_keys.NK_KEY_SCROLL_START, Down);
     }
     else if (E.Code == Keyboard.Key.End)
     {
         Dev.OnKey(nk_keys.NK_KEY_SCROLL_END, Down);
     }
     else if (E.Code == Keyboard.Key.PageDown)
     {
         Dev.OnKey(nk_keys.NK_KEY_SCROLL_DOWN, Down);
     }
     else if (E.Code == Keyboard.Key.PageUp)
     {
         Dev.OnKey(nk_keys.NK_KEY_SCROLL_UP, Down);
     }
 }
Exemplo n.º 2
0
 static void OnKey(SFMLDevice Dev, KeyEventArgs E, bool Down)
 {
     if (E.Code == Keyboard.Key.LShift || E.Code == Keyboard.Key.RShift)
     {
         Dev.OnKey(NkKeys.Shift, Down);
     }
     else if (E.Code == Keyboard.Key.LControl || E.Code == Keyboard.Key.RControl)
     {
         Dev.OnKey(NkKeys.Ctrl, Down);
     }
     else if (E.Code == Keyboard.Key.Delete)
     {
         Dev.OnKey(NkKeys.Del, Down);
     }
     else if (E.Code == Keyboard.Key.Return)
     {
         Dev.OnKey(NkKeys.Enter, Down);
     }
     else if (E.Code == Keyboard.Key.Tab)
     {
         Dev.OnKey(NkKeys.Tab, Down);
     }
     else if (E.Code == Keyboard.Key.BackSpace)
     {
         Dev.OnKey(NkKeys.Backspace, Down);
     }
     else if (E.Code == Keyboard.Key.Up)
     {
         Dev.OnKey(NkKeys.Up, Down);
     }
     else if (E.Code == Keyboard.Key.Down)
     {
         Dev.OnKey(NkKeys.Down, Down);
     }
     else if (E.Code == Keyboard.Key.Left)
     {
         Dev.OnKey(NkKeys.Left, Down);
     }
     else if (E.Code == Keyboard.Key.Right)
     {
         Dev.OnKey(NkKeys.Right, Down);
     }
     else if (E.Code == Keyboard.Key.Home)
     {
         Dev.OnKey(NkKeys.ScrollStart, Down);
     }
     else if (E.Code == Keyboard.Key.End)
     {
         Dev.OnKey(NkKeys.ScrollEnd, Down);
     }
     else if (E.Code == Keyboard.Key.PageDown)
     {
         Dev.OnKey(NkKeys.ScrollDown, Down);
     }
     else if (E.Code == Keyboard.Key.PageUp)
     {
         Dev.OnKey(NkKeys.ScrollUp, Down);
     }
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Console.Title = "Nuklear SFML .NET";
            Stopwatch SWatch = Stopwatch.StartNew();

            VideoMode    VMode      = new VideoMode(1366, 768);
            RenderWindow RWind      = new RenderWindow(VMode, Console.Title, Styles.Close);
            Color        ClearColor = new Color(50, 50, 50);

            RWind.Closed += (S, E) => RWind.Close();

            SFMLDevice Dev = new SFMLDevice(RWind);

            RWind.MouseButtonPressed  += (S, E) => Dev.OnMouseButton((NuklearEvent.MouseButton)E.Button, E.X, E.Y, true);
            RWind.MouseButtonReleased += (S, E) => Dev.OnMouseButton((NuklearEvent.MouseButton)E.Button, E.X, E.Y, false);
            RWind.MouseMoved          += (S, E) => Dev.OnMouseMove(E.X, E.Y);
            RWind.MouseWheelMoved     += (S, E) => Dev.OnScroll(0, E.Delta);
            RWind.TextEntered         += (S, E) => Dev.OnText(E.Unicode);
            RWind.KeyPressed          += (S, E) => OnKey(Dev, E, true);
            RWind.KeyReleased         += (S, E) => OnKey(Dev, E, false);

            NuklearAPI.Init(Dev);

            NuklearCalculator CalcA = new NuklearCalculator("Calc A", 50, 50);
            NuklearCalculator CalcB = new NuklearCalculator("Calc B", 300, 50);

            float Dt = 0.1f;

            while (RWind.IsOpen)
            {
                RWind.DispatchEvents();
                RWind.Clear(ClearColor);

                NuklearAPI.SetDeltaTime(Dt);
                NuklearAPI.Frame(() => {
                    if (CalcA.Open)
                    {
                        CalcA.Calculator();
                    }

                    if (CalcB.Open)
                    {
                        CalcB.Calculator();
                    }

                    TestWindow(400, 350);
                });

                RWind.Display();


                Dt = SWatch.ElapsedMilliseconds / 1000.0f;
                SWatch.Restart();
            }

            Environment.Exit(0);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            Console.Title = "Nuklear SFML .NET";

            Stopwatch SWatch     = Stopwatch.StartNew();
            Color     ClearColor = new Color(170, 80, 20);
            VideoMode VMode      = new VideoMode(1366, 768);

            RenderWindow RWind = new RenderWindow(VMode, Console.Title, Styles.Close);

            RWind.SetKeyRepeatEnabled(true);

            SFMLDevice Dev = new SFMLDevice(RWind);

            RWind.Closed              += (S, E) => RWind.Close();
            RWind.MouseButtonPressed  += (S, E) => Dev.OnMouseButton((NuklearEvent.MouseButton)E.Button, E.X, E.Y, true);
            RWind.MouseButtonReleased += (S, E) => Dev.OnMouseButton((NuklearEvent.MouseButton)E.Button, E.X, E.Y, false);
            RWind.MouseMoved          += (S, E) => Dev.OnMouseMove(E.X, E.Y);
            RWind.MouseWheelMoved     += (S, E) => Dev.OnScroll(0, E.Delta);
            RWind.KeyPressed          += (S, E) => OnKey(Dev, E, true);
            RWind.KeyReleased         += (S, E) => OnKey(Dev, E, false);
            RWind.TextEntered         += (S, E) => Dev.OnText(E.Unicode);

            Shared.Init(Dev);

            float Dt = 0.1f;

            while (RWind.IsOpen)
            {
                RWind.DispatchEvents();
                RWind.Clear(ClearColor);

                Shared.DrawLoop(Dt);

                RWind.Display();

                Dt = SWatch.ElapsedMilliseconds / 1000.0f;
                SWatch.Restart();
            }

            Environment.Exit(0);
        }