static void Main(string[] args) { // Configure Resource manager string path = System.Configuration.ConfigurationSettings.AppSettings["ResourcePath"]; if ( path == null ) { //throw new System.Configuration.ConfigurationException( "ResourcePath" ); } CurrentMessageProcessor = new MessageProcessor(); // Initialise required objects CurrentServerConnection = new ServerConnection(); CurrentServerConnection.OnConnect += new ServerConnection.OnConnectHandler( HandleConnect ); CurrentServerConnection.OnDisconnect += new ServerConnection.OnDisconnectHandler( HandleDisconnect ); CurrentMainWindow = new Windows.Main(); CurrentMainWindow.Show(); //CurrentWorld.InitialiseView( CurrentMainWindow, CurrentMainWindow.RenderTarget, CurrentMainWindow.miniMap.RenderTarget ); Windows.ChildWindows.Connection con = new Windows.ChildWindows.Connection(); con.Show(); while( !CurrentMainWindow.IsDisposed ) { // NB: This is a tight renderloop // it will chew cpu // TODO: could be made nicer by // P/Invoke into the Win32 API and call PeekMessage/TranslateMessage/DispatchMessage. (Doevents actually does something similar, but you can do this without the extra allocations). Application.DoEvents(); if ( CurrentServerConnection.isRunning ) { GameLoop(); } System.Threading.Thread.Sleep( 0 ); } // must terminate all threads to quit CurrentServerConnection.Stop(); }
private void ViewConnect_Click(object sender, System.EventArgs e) { // Connection Game.Stop(); ChildWindows.Connection con = new ChildWindows.Connection(); con.ShowDialog(this); }
static void Main(string[] args) { // Configure Resource manager string path = System.Configuration.ConfigurationSettings.AppSettings["ResourcePath"]; if (path == null) { //throw new System.Configuration.ConfigurationException( "ResourcePath" ); } CurrentMessageProcessor = new MessageProcessor(); // Initialise required objects CurrentServerConnection = new ServerConnection(); CurrentServerConnection.OnConnect += new ServerConnection.OnConnectHandler(HandleConnect); CurrentServerConnection.OnDisconnect += new ServerConnection.OnDisconnectHandler(HandleDisconnect); CurrentMainWindow = new Windows.Main(); CurrentMainWindow.Show(); //CurrentWorld.InitialiseView( CurrentMainWindow, CurrentMainWindow.RenderTarget, CurrentMainWindow.miniMap.RenderTarget ); Windows.ChildWindows.Connection con = new Windows.ChildWindows.Connection(); con.Show(); while (!CurrentMainWindow.IsDisposed) { // NB: This is a tight renderloop // it will chew cpu // TODO: could be made nicer by // P/Invoke into the Win32 API and call PeekMessage/TranslateMessage/DispatchMessage. (Doevents actually does something similar, but you can do this without the extra allocations). Application.DoEvents(); if (CurrentServerConnection.isRunning) { GameLoop(); } System.Threading.Thread.Sleep(0); } // must terminate all threads to quit CurrentServerConnection.Stop(); }