示例#1
0
        /// <summary>
        ///     Sets up the game window, or if the window is already setup it 
        ///     refreshs it to take resolution changes into effect.
        /// </summary>
        protected void SetupGameWindow()
        {
            if (_window == null)
            {
                DebugLogger.WriteLog("Creating graphics window " + (_showInFullscreen == true ? "(Fullscreen)" : "(Windowed)") + " with size " + _realResolution[0] + "," + _realResolution[1] + "...");
                _window = new GameWindow(_realResolution[0], _realResolution[1], _showInFullscreen ? GraphicsFlags.FullScreen : 0);
                _window.FormClosing += new FormClosingEventHandler(OnClosing);
                _window.Text = _gameTitle;
                AudioManager.Driver.AttachToControl(_window);
            }
            else
            {
                _window.Reset(_realResolution[0], _realResolution[1], _showInFullscreen ? GraphicsFlags.FullScreen : 0);
            }

            // Set the resolution to the one in the game configuration file.
            DebugLogger.WriteLog("Emulating resolution at " + _resolution[0] + "x" + _resolution[1] + " ...");
            GraphicsManager.SetResolution(_resolution[0], _resolution[1], _keepAspectRatio);
        }
示例#2
0
        /// <summary>
        ///		Called by the base engine class when its safe to begin deinitialization.
        /// </summary>
        protected override void Finish()
        {
            // Remember me!!! Remember me!!
            if (_rememberUser == true)
            {
                _engineConfigFile.SetSetting("account:username", _currentUsername);
                _engineConfigFile.SetSetting("account:password", _currentPassword);
            }
            else
            {
                _engineConfigFile.SetSetting("account:username", "");
                _engineConfigFile.SetSetting("account:password", "");
            }

            // Ignore everything else if we are not running a game.
            if (_gameName == "")
            {
                _explorerWindow.Dispose();
                _explorerWindow = null;
                GC.Collect();
                return;
            }

            // Close network.
            if (_serverWindow != null)
                NetworkManager.Finish();

            // Pump out a GameFinish event.
            EventManager.FireEvent(new Event("game_finish", this, null));

            // Allow the processes some time to be notified of closing events.
            EventManager.ProcessEvents();
            ProcessManager.RunProcesses(-1);

            // Close down the window.
            if (_window != null)
            {
                _window.Dispose();
                _window = null;
                GC.Collect();
            }

            // Close down the server window.
            if (_serverWindow != null)
            {
                _serverWindow.Dispose();
                _serverWindow = null;
                GC.Collect();
            }

            // Close the network connection.
            NetworkManager.Close();
        }