jakesays-old / gwen-dotnet

Automatically exported from code.google.com/p/gwen-dotnet
0 stars 0 forks source link

GWen.net resizing solution and the combination of keys Alt+enter to fullScreen #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Today I discovered your project GWen.net, I liked it, but I found that resizing 
the window does not work well, and the key combination Alt + Enter (fullscreen).

I modified the following methods:

SimpleGwenGame.cs

        bool altDown = false;

        void Keyboard_KeyDown(object sender, KeyboardKeyEventArgs e)
        {
            if (e.Key == global::OpenTK.Input.Key.Escape)
                Exit();
            else if (e.Key == global::OpenTK.Input.Key.AltLeft)
                altDown = true;
            else if (altDown && e.Key == global::OpenTK.Input.Key.Enter)
                if (WindowState == WindowState.Fullscreen)
                    WindowState = WindowState.Normal;
                else
                    WindowState = WindowState.Fullscreen;

            input.ProcessKeyDown(e);
        }

        void Keyboard_KeyUp(object sender, KeyboardKeyEventArgs e)
        {
            altDown = false;
            input.ProcessKeyUp(e);
        }

        protected override void OnLoad(EventArgs e)
        {
            GL.ClearColor(Color.MidnightBlue);

            renderer = new Gwen.Renderer.OpenTK();
            skin = new Gwen.Skin.TexturedBase(renderer, "DefaultSkin.png");
            //skin = new Gwen.Skin.Simple(renderer);
            skin.DefaultFont = new Font(renderer, "Courier", 10);
            canvas = new Canvas(skin);

            input = new Input.OpenTK();
            input.Initialize(canvas);

            canvas.SetSize(Width, Height);
            canvas.ShouldDrawBackground = true;
            canvas.BackgroundColor = Color.FromArgb(255, 150, 170, 170);
            //canvas.KeyboardInputEnabled = true;

            test = new UnitTest.UnitTest(canvas);

            stopwatch.Restart();
            lastTime = 0;
        }
        protected override void OnResize(EventArgs e)
        {
            GL.Viewport(0, 0, Width, Height);
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.Ortho(0, Width, Height, 0, -1, 1);

            canvas.SetSize(Width, Height);
        }

Greetings ...

Miguel

https://sites.google.com/site/bitiopia/

Original issue reported on code.google.com by bitiopia...@gmail.com on 21 Dec 2011 at 6:27

GoogleCodeExporter commented 9 years ago
Sorry for the delay, for some reason the tracker didn't send me email 
notifications. Your changes are now applied.

Original comment by der.ag...@gmail.com on 5 Jan 2012 at 10:20