diff --git a/mk/linux/glestkeys.ini b/mk/linux/glestkeys.ini index ee6b2c28..7e087557 100644 --- a/mk/linux/glestkeys.ini +++ b/mk/linux/glestkeys.ini @@ -43,6 +43,7 @@ ChatTeamMode=H ToggleMusic=K SaveGUILayout=vkF11 ReloadINI=vkF5 +TogglePhotoMode=vkF8 ; === propertyMap File === diff --git a/source/glest_game/facilities/components.cpp b/source/glest_game/facilities/components.cpp index 25441d8d..259ee391 100644 --- a/source/glest_game/facilities/components.cpp +++ b/source/glest_game/facilities/components.cpp @@ -359,7 +359,7 @@ bool GraphicListBox::mouseClick(int x, int y){ const int GraphicMessageBox::defH= 240; const int GraphicMessageBox::defW= 350; -void GraphicMessageBox::init(const string &button1Str, const string &button2Str){ +void GraphicMessageBox::init(const string &button1Str, const string &button2Str) { init(button1Str); button1.init(x+(w-GraphicButton::defW)/4, y+25); @@ -369,7 +369,21 @@ void GraphicMessageBox::init(const string &button1Str, const string &button2Str) buttonCount= 2; } -void GraphicMessageBox::init(const string &button1Str){ +void GraphicMessageBox::setX(int x) { + this->x= x; + + button1.init(x+(w-GraphicButton::defW)/4, y+25); + button2.init(x+3*(w-GraphicButton::defW)/4, y+25); +} + +void GraphicMessageBox::setY(int y) { + this->y= y; + + button1.init(x+(w-GraphicButton::defW)/4, y+25); + button2.init(x+3*(w-GraphicButton::defW)/4, y+25); +} + +void GraphicMessageBox::init(const string &button1Str) { font= CoreData::getInstance().getMenuFontNormal(); h= defH; diff --git a/source/glest_game/facilities/components.h b/source/glest_game/facilities/components.h index 4a819f04..7da7ea5b 100644 --- a/source/glest_game/facilities/components.h +++ b/source/glest_game/facilities/components.h @@ -59,33 +59,33 @@ public: virtual ~GraphicComponent(){} static void clearRegisteredComponents(std::string containerName=""); - void registerGraphicComponent(std::string containerName, std::string objName); + virtual void registerGraphicComponent(std::string containerName, std::string objName); static GraphicComponent * findRegisteredComponent(std::string containerName, std::string objName); static void applyAllCustomProperties(std::string containerName); - void applyCustomProperties(std::string containerName); + virtual void applyCustomProperties(std::string containerName); static bool saveAllCustomProperties(std::string containerName); - bool saveCustomProperties(std::string containerName); + virtual bool saveCustomProperties(std::string containerName); - void init(int x, int y, int w, int h); + virtual void init(int x, int y, int w, int h); - int getX() const {return x;} - int getY() const {return y;} - int getW() const {return w;} - int getH() const {return h;} - const string &getText() const {return text;} - const Font2D *getFont() const {return font;} - bool getEnabled() const {return enabled;} - bool getEditable() const {return editable;} - bool getVisible() const {return visible;} + virtual int getX() const {return x;} + virtual int getY() const {return y;} + virtual int getW() const {return w;} + virtual int getH() const {return h;} + virtual const string &getText() const {return text;} + virtual const Font2D *getFont() const {return font;} + virtual bool getEnabled() const {return enabled;} + virtual bool getEditable() const {return editable;} + virtual bool getVisible() const {return visible;} - void setX(int x) {this->x= x;} - void setY(int y) {this->y= y;} - void setText(const string &text) {this->text= text;} - void setFont(const Font2D *font) {this->font= font;} - void setEnabled(bool enabled) {this->enabled= enabled;} - void setEditable(bool editable) {this->editable= editable;} - void setVisible(bool value) {this->visible = value;} + virtual void setX(int x) {this->x= x;} + virtual void setY(int y) {this->y= y;} + virtual void setText(const string &text) {this->text= text;} + virtual void setFont(const Font2D *font) {this->font= font;} + virtual void setEnabled(bool enabled) {this->enabled= enabled;} + virtual void setEditable(bool editable) {this->editable= editable;} + virtual void setVisible(bool value) {this->visible = value;} virtual bool mouseMove(int x, int y); virtual bool mouseClick(int x, int y); @@ -194,6 +194,9 @@ public: const GraphicButton *getButton1() const {return &button1;} const GraphicButton *getButton2() const {return &button2;} string getHeader() const {return header;} + + virtual void setX(int x); + virtual void setY(int y); void setHeader(string header) {this->header= header;} diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index b9dae830..80f31033 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -49,8 +49,6 @@ Game::Game(Program *program, const GameSettings *gameSettings): original_updateFps = GameConstants::updateFps; original_cameraFps = GameConstants::cameraFps; -// GameConstants::updateFps= 20; -// GameConstants::cameraFps= 50; GameConstants::updateFps= 40; GameConstants::cameraFps= 100; captureAvgTestStatus = false; @@ -63,7 +61,7 @@ Game::Game(Program *program, const GameSettings *gameSettings): this->gameSettings= *gameSettings; scrollSpeed = Config::getInstance().getFloat("UiScrollSpeed","1.5"); - + photoModeEnabled = Config::getInstance().getBool("PhotoMode","false"); //MIN_RENDER_FPS_ALLOWED = Config::getInstance().getInt("MIN_RENDER_FPS_ALLOWED",intToStr(MIN_RENDER_FPS_ALLOWED).c_str()); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] MIN_RENDER_FPS_ALLOWED = %d\n",__FILE__,__FUNCTION__,__LINE__,MIN_RENDER_FPS_ALLOWED); @@ -528,6 +526,7 @@ void Game::init() //mesage box errorMessageBox.init(lang.get("Ok")); errorMessageBox.setEnabled(false); + errorMessageBox.setY(mainMessageBox.getY() - mainMessageBox.getH() - 10); //init world, and place camera commander.init(&world); @@ -1113,7 +1112,7 @@ void Game::eventMouseWheel(int x, int y, int zDelta) { } } -void Game::keyDown(char key){ +void Game::keyDown(char key) { try { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key); @@ -1123,7 +1122,7 @@ void Game::keyDown(char key){ //send key to the chat manager chatManager.keyDown(key); - if(!chatManager.getEditEnabled()){ + if(chatManager.getEditEnabled() == false) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = %d\n",__FILE__,__FUNCTION__,__LINE__,key); Config &configKeys = Config::getInstance(std::pair(cfgMainKeys,cfgUserKeys)); @@ -1134,6 +1133,9 @@ void Game::keyDown(char key){ else if(key == configKeys.getCharKey("ShowFullConsole")) { showFullConsole= true; } + else if(key == configKeys.getCharKey("TogglePhotoMode")) { + photoModeEnabled = !photoModeEnabled; + } //Toggle music else if(key == configKeys.getCharKey("ToggleMusic")) { Config &config = Config::getInstance(); @@ -1274,6 +1276,8 @@ void Game::keyDown(char key){ } } } + + //throw runtime_error("Test Error!"); } catch(const exception &ex) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); @@ -1287,17 +1291,14 @@ void Game::keyDown(char key){ void Game::keyUp(char key){ try { - if(chatManager.getEditEnabled()){ + if(chatManager.getEditEnabled()) { //send key to the chat manager chatManager.keyUp(key); } else { Config &configKeys = Config::getInstance(std::pair(cfgMainKeys,cfgUserKeys)); - if(key == configKeys.getCharKey("RenderNetworkStatus")) { - //renderNetworkStatus= false; - } - else if(key == configKeys.getCharKey("ShowFullConsole")) { + if(key == configKeys.getCharKey("ShowFullConsole")) { showFullConsole= false; } else if(key == configKeys.getCharKey("CameraRotateLeft") || @@ -1469,7 +1470,7 @@ void Game::render2d(){ renderer.renderDisplay(); //minimap - if(!config.getBool("PhotoMode")){ + if(photoModeEnabled == false) { renderer.renderMinimap(); } @@ -1477,12 +1478,12 @@ void Game::render2d(){ renderer.renderSelectionQuad(); //exit message box - if(mainMessageBox.getEnabled()){ - renderer.renderMessageBox(&mainMessageBox); - } - if(errorMessageBox.getEnabled()){ + if(errorMessageBox.getEnabled()) { renderer.renderMessageBox(&errorMessageBox); } + if(mainMessageBox.getEnabled()) { + renderer.renderMessageBox(&mainMessageBox); + } //script message box if( mainMessageBox.getEnabled() == false && @@ -1656,7 +1657,7 @@ void Game::render2d(){ } //resource info - if(config.getBool("PhotoMode") == false) { + if(photoModeEnabled == false) { renderer.renderResourceStatus(); renderer.renderConsole(&console,showFullConsole); } @@ -1799,11 +1800,11 @@ void Game::checkWinnerStandard(){ } } -void Game::checkWinnerScripted(){ - if(scriptManager.getGameOver()){ +void Game::checkWinnerScripted() { + if(scriptManager.getGameOver()) { gameOver= true; - for(int i= 0; igetWinner()){ + for(int i= 0; igetWinner()) { world.getStats()->setVictorious(i); } } diff --git a/source/glest_game/game/game.h b/source/glest_game/game/game.h index e4fe18bb..b51bba62 100644 --- a/source/glest_game/game/game.h +++ b/source/glest_game/game/game.h @@ -95,6 +95,8 @@ private: int updateFpsAvgTest; int renderFpsAvgTest; + bool photoModeEnabled; + public: Game(Program *program, const GameSettings *gameSettings); ~Game();