Ejemplo n.º 1
0
        public void OnUpdate(GraphicsDevice gfxDevice, GameTime gameTime)
        {
            gfxDevice.Clear(ClearOptions.DepthBuffer, Color.Black, 0.0f, 1);

            Rendering.ChangeDrawCall(SpriteSortMode.Immediate, null, BlendState.AlphaBlend);

            ImGuiRenderer.BeforeLayout(gameTime);
            EditorGUI.Paint();
            ImGuiRenderer.AfterLayout();

            // TEST: Create game instance.
            // TODO: Implement properly. Needs to dynamically open any type of SE Game.
            if (InputManager.KeyCodePressed(Microsoft.Xna.Framework.Input.Keys.F2))
            {
                SceneManager.CurrentScene.Unload();

                Game gameInstance = (Game)Activator.CreateInstance(typeof(SEDemos.Game), null, this, this);
                gameInstance.KeepWindowOnDipose = true;

                // Hook into the game instance. OnUpdate will be called from this instance,
                // until the game exited.
                gameInstance.Run();
                ChangeInstance(null);

                //Exit();
                // TODO: Exit and reopen program.
            }

            // Test reload.
            // This is how hot reloading of code will work. Even though it isn't hot reloading.
            // Detect change -> Save editor state -> Close -> Reopen -> Restore editor state.
            if (InputManager.KeyCodePressed(Microsoft.Xna.Framework.Input.Keys.F9))
            {
                Process.Start(AppDomain.CurrentDomain.BaseDirectory + "/SEEditor.exe");
                Thread.Sleep(2000);
                Environment.Exit(-1);
            }
        }