From f0133ba2609b40832da41470c8a3c9b64edb4ea7 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Wed, 17 Mar 2010 16:27:17 +0000 Subject: [PATCH] Added a more user friendly messagebox when network errors are encountered. Added fix for Fullscreen OpenGL Mode --- source/glest_game/main/program.cpp | 15 ++++++++++----- source/glest_game/main/program.h | 4 +++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/source/glest_game/main/program.cpp b/source/glest_game/main/program.cpp index 9d604c059..b674d98c5 100644 --- a/source/glest_game/main/program.cpp +++ b/source/glest_game/main/program.cpp @@ -50,7 +50,7 @@ Program::ShowMessageProgramState::ShowMessageProgramState(Program *program, cons ProgramState(program) { //if(Socket::enableDebugText) printf("In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); - + userWantsExit = false; msgBox.init("Ok"); //if(Socket::enableDebugText) printf("In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -85,6 +85,7 @@ void Program::ShowMessageProgramState::mouseDownLeft(int x, int y) { //if(Socket::enableDebugText) printf("In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); program->exit(); + userWantsExit = true; } //if(Socket::enableDebugText) printf("In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -244,7 +245,7 @@ void Program::setState(ProgramState *programState) //if(Socket::enableDebugText) printf("In [%s::%s] END\n",__FILE__,__FUNCTION__); } -void Program::exit(){ +void Program::exit() { //if(Socket::enableDebugText) printf("In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -345,11 +346,14 @@ void Program::showMessage(const char *msg) { //if(Socket::enableDebugText) printf("In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); - this->programState = new ShowMessageProgramState(this, msg); + SDL_ShowCursor(SDL_ENABLE); + //SDL_WM_ToggleFullScreen(SDL_GetVideoSurface()); + ShowMessageProgramState *showMsg = new ShowMessageProgramState(this, msg); + this->programState = showMsg; //if(Socket::enableDebugText) printf("In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); - while(Window::handleEvent()) { + while(Window::handleEvent() && showMsg->wantExit() == false) { loop(); } @@ -360,7 +364,8 @@ void Program::showMessage(const char *msg) { //if(Socket::enableDebugText) printf("In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); - init(window); + //MainWindow *mainWindow= new MainWindow(this); + init(this->window); setState(originalState); //this->programState = originalState; diff --git a/source/glest_game/main/program.h b/source/glest_game/main/program.h index ae75debd5..d23ea7122 100644 --- a/source/glest_game/main/program.h +++ b/source/glest_game/main/program.h @@ -56,7 +56,7 @@ public: virtual void mouseUpLeft(int x, int y){}; virtual void mouseDownRight(int x, int y){}; virtual void mouseDoubleClickLeft(int x, int y){}; - virtual void mouseMove(int x, int y, const MouseState *mouseState){}; + virtual void mouseMove(int x, int y, const MouseState *mouseState) {}; virtual void keyDown(char key){}; virtual void keyUp(char key){}; virtual void keyPress(char c){}; @@ -76,6 +76,7 @@ private: int mouseY; int mouse2dAnim; string msg; + bool userWantsExit; public: ShowMessageProgramState(Program *program, const char *msg); @@ -84,6 +85,7 @@ private: virtual void mouseDownLeft(int x, int y); virtual void mouseMove(int x, int y, const MouseState &mouseState); virtual void update(); + virtual bool wantExit() { return userWantsExit; } };