From 5648080095e54a67cf865c0c777c3d5fd2c35897 Mon Sep 17 00:00:00 2001 From: Titus Tscharntke Date: Sat, 26 Mar 2011 13:40:22 +0000 Subject: [PATCH] Ready/not Ready/brb in colors; labels can have colors now --- source/glest_game/facilities/components.cpp | 3 +- source/glest_game/facilities/components.h | 6 +- source/glest_game/graphics/renderer.cpp | 5 +- .../menu/menu_state_connected_game.cpp | 99 ++++++++----------- .../menu/menu_state_connected_game.h | 1 - .../menu/menu_state_custom_game.cpp | 8 ++ 6 files changed, 58 insertions(+), 64 deletions(-) diff --git a/source/glest_game/facilities/components.cpp b/source/glest_game/facilities/components.cpp index 89e94e0f..99374a71 100644 --- a/source/glest_game/facilities/components.cpp +++ b/source/glest_game/facilities/components.cpp @@ -247,9 +247,10 @@ void GraphicComponent::resetFade(){ const int GraphicLabel::defH= 20; const int GraphicLabel::defW= 70; -void GraphicLabel::init(int x, int y, int w, int h, bool centered){ +void GraphicLabel::init(int x, int y, int w, int h, bool centered, Vec3f textColor){ GraphicComponent::init(x, y, w, h); this->centered= centered; + this->textColor=textColor; } // ===================================================== diff --git a/source/glest_game/facilities/components.h b/source/glest_game/facilities/components.h index 45949458..d308f49f 100644 --- a/source/glest_game/facilities/components.h +++ b/source/glest_game/facilities/components.h @@ -113,13 +113,15 @@ public: private: bool centered; + Vec3f textColor; public: - void init(int x, int y, int w=defW, int h=defH, bool centered= false); + void init(int x, int y, int w=defW, int h=defH, bool centered= false, Vec3f textColor=Vec3f(1.f, 1.f, 1.f)); bool getCentered() const {return centered;} - void setCentered(bool centered) {this->centered= centered;} + Vec3f getTextColor() const {return textColor;} + void setTextColor(Vec3f color) {this->textColor= color;} }; // =========================================================== diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 3e90b2df..fb3d5af3 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -1243,8 +1243,9 @@ void Renderer::renderTextShadow(const string &text, const Font2D *font,const Vec // ============= COMPONENTS ============================= void Renderer::renderLabel(const GraphicLabel *label) { - Vec4f *colorWithAlpha = NULL; - renderLabel(label,colorWithAlpha); + Vec3f labelColor=label->getTextColor(); + Vec4f colorWithAlpha = Vec4f(labelColor.x,labelColor.y,labelColor.z,GraphicComponent::getFade()); + renderLabel(label,&colorWithAlpha); } void Renderer::renderLabel(const GraphicLabel *label,const Vec3f *color) { diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index 68de3a29..577e8468 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -138,10 +138,9 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM //create buttonDisconnect.registerGraphicComponent(containerName,"buttonDisconnect"); - buttonDisconnect.init(450, 180, 125); + buttonDisconnect.init(350, 180, 125); + - buttonPlayNow.registerGraphicComponent(containerName,"buttonPlayNow"); - buttonPlayNow.init(525, 180, 125); xoffset=170; @@ -281,7 +280,8 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM listBoxPlayerStatus.registerGraphicComponent(containerName,"listBoxPlayerStatus"); - listBoxPlayerStatus.init(10, 600, 150); + //listBoxPlayerStatus.init(10, 600, 150); + listBoxPlayerStatus.init(525, 180, 125); playerStatuses.push_back(lang.get("PlayerStatusSetup")); playerStatuses.push_back(lang.get("PlayerStatusBeRightBack")); playerStatuses.push_back(lang.get("PlayerStatusReady")); @@ -348,7 +348,6 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM //texts buttonDisconnect.setText(lang.get("Return")); - buttonPlayNow.setText(lang.get("PlayNow")); controlItems.push_back(lang.get("Closed")); controlItems.push_back(lang.get("CpuEasy")); @@ -576,84 +575,66 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){ if (initialSettingsReceivedFromServer == false) return; // Only allow changes after we get game settings from the server - if(clientInterface->isConnected() == true) { - if(buttonPlayNow.mouseClick(x,y) && buttonPlayNow.getEnabled()) { - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); - soundRenderer.playFx(coreData.getClickSoundC()); - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); - } - else { - int myCurrentIndex=-1; - for(int i=0; iisConnected() == true){ + int myCurrentIndex= -1; + for(int i= 0; i < GameConstants::maxPlayers; ++i){// find my current index by looking at editable listBoxes + if(listBoxFactions[i].getEditable()){ + myCurrentIndex= i; } - if (myCurrentIndex!=-1) - for(int i=0; iisConnected()) { + if(clientInterface->isConnected()){ clientInterface->setGameSettingsReceived(false); - clientInterface->sendSwitchSetupRequest( - listBoxFactions[i].getSelectedItem(),i,-1, - listBoxTeams[i].getSelectedItemIndex(), - getHumanPlayerName(), - getNetworkPlayerStatus(), - switchSetupRequestFlagType); - switchSetupRequestFlagType=ssrft_None; + clientInterface->sendSwitchSetupRequest(listBoxFactions[i].getSelectedItem(), i, -1, + listBoxTeams[i].getSelectedItemIndex(), getHumanPlayerName(), + getNetworkPlayerStatus(), switchSetupRequestFlagType); + switchSetupRequestFlagType= ssrft_None; } break; } } - if(listBoxTeams[i].getEditable()) { - if(listBoxTeams[i].mouseClick(x, y)) { + if(listBoxTeams[i].getEditable()){ + if(listBoxTeams[i].mouseClick(x, y)){ soundRenderer.playFx(coreData.getClickSoundA()); - if(clientInterface->isConnected()) { + if(clientInterface->isConnected()){ clientInterface->setGameSettingsReceived(false); - clientInterface->sendSwitchSetupRequest( - listBoxFactions[i].getSelectedItem(),i,-1, - listBoxTeams[i].getSelectedItemIndex(), - getHumanPlayerName(), - getNetworkPlayerStatus(), - switchSetupRequestFlagType); - switchSetupRequestFlagType=ssrft_None; + clientInterface->sendSwitchSetupRequest(listBoxFactions[i].getSelectedItem(), i, -1, + listBoxTeams[i].getSelectedItemIndex(), getHumanPlayerName(), + getNetworkPlayerStatus(), switchSetupRequestFlagType); + switchSetupRequestFlagType= ssrft_None; } break; } } - if((listBoxControls[i].getSelectedItemIndex() == ctNetwork) && - (labelNetStatus[i].getText() == GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME)) { - if(grabSlotButton[i].mouseClick(x, y) ) { + if((listBoxControls[i].getSelectedItemIndex() == ctNetwork) && (labelNetStatus[i].getText() + == GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME)){ + if(grabSlotButton[i].mouseClick(x, y)){ soundRenderer.playFx(coreData.getClickSoundA()); clientInterface->setGameSettingsReceived(false); - settingsReceivedFromServer=false; + settingsReceivedFromServer= false; SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] sending a switchSlot request from %d to %d\n",__FILE__,__FUNCTION__,__LINE__,clientInterface->getGameSettings()->getThisFactionIndex(),i); - clientInterface->sendSwitchSetupRequest( - listBoxFactions[myCurrentIndex].getSelectedItem(), - myCurrentIndex,i, - listBoxTeams[myCurrentIndex].getSelectedItemIndex(), - labelPlayerNames[myCurrentIndex].getText(), - getNetworkPlayerStatus(), - switchSetupRequestFlagType); + clientInterface->sendSwitchSetupRequest(listBoxFactions[myCurrentIndex].getSelectedItem(), + myCurrentIndex, i, listBoxTeams[myCurrentIndex].getSelectedItemIndex(), + labelPlayerNames[myCurrentIndex].getText(), getNetworkPlayerStatus(), + switchSetupRequestFlagType); labelPlayerNames[myCurrentIndex].setText(""); labelPlayerNames[i].setText(""); - switchSetupRequestFlagType=ssrft_None; + switchSetupRequestFlagType= ssrft_None; break; } } - if(labelPlayerNames[i].mouseClick(x, y) && ( activeInputLabel != &labelPlayerNames[i] )){ - if(i == clientInterface->getPlayerIndex()) { + if(labelPlayerNames[i].mouseClick(x, y) && (activeInputLabel != &labelPlayerNames[i])){ + if(i == clientInterface->getPlayerIndex()){ setActiveInputLabel(&labelPlayerNames[i]); } } } - } if(listBoxPlayerStatus.mouseClick(x,y)) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -708,7 +689,6 @@ void MenuStateConnectedGame::mouseMove(int x, int y, const MouseState *ms) { } buttonDisconnect.mouseMove(x, y); - buttonPlayNow.mouseMove(x, y); bool editingPlayerName = false; for(int i = 0; i < GameConstants::maxPlayers; ++i) { @@ -731,6 +711,7 @@ void MenuStateConnectedGame::mouseMove(int x, int y, const MouseState *ms) { listBoxAllowObservers.mouseMove(x, y); listBoxTileset.mouseMove(x, y); listBoxTechTree.mouseMove(x, y); + listBoxPlayerStatus.mouseMove(x,y); } void MenuStateConnectedGame::render() { @@ -755,7 +736,6 @@ void MenuStateConnectedGame::render() { //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); renderer.renderButton(&buttonDisconnect); - //renderer.renderButton(&buttonPlayNow); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -1512,12 +1492,15 @@ void MenuStateConnectedGame::update() { switch(gameSettings->getNetworkPlayerStatuses(i)) { case npst_BeRightBack: labelPlayerStatus[slot].setText(lang.get("PlayerStatusBeRightBack")); + labelPlayerStatus[slot].setTextColor(Vec3f(1.f, 0.8f, 0.f)); break; case npst_Ready: labelPlayerStatus[slot].setText(lang.get("PlayerStatusReady")); + labelPlayerStatus[slot].setTextColor(Vec3f(0.f, 1.f, 0.f)); break; case npst_PickSettings: labelPlayerStatus[slot].setText(lang.get("PlayerStatusSetup")); + labelPlayerStatus[slot].setTextColor(Vec3f(1.f, 0.f, 0.f)); break; default: labelPlayerStatus[slot].setText(""); diff --git a/source/glest_game/menu/menu_state_connected_game.h b/source/glest_game/menu/menu_state_connected_game.h index 93dff0a6..3d233c55 100644 --- a/source/glest_game/menu/menu_state_connected_game.h +++ b/source/glest_game/menu/menu_state_connected_game.h @@ -41,7 +41,6 @@ enum FTPMessageType { class MenuStateConnectedGame: public MenuState, public FTPClientCallbackInterface { private: GraphicButton buttonDisconnect; - GraphicButton buttonPlayNow; GraphicLabel labelControl; GraphicLabel labelRMultiplier; GraphicLabel labelFaction; diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index a134f0e5..f5d5c6dd 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -527,6 +527,8 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b playerStatuses.push_back(lang.get("PlayerStatusBeRightBack")); playerStatuses.push_back(lang.get("PlayerStatusReady")); listBoxPlayerStatus.setItems(playerStatuses); + listBoxPlayerStatus.setSelectedItemIndex(2,true); + listBoxPlayerStatus.setVisible(false); // write hint to console: Config &configKeys = Config::getInstance(std::pair(cfgMainKeys,cfgUserKeys)); @@ -1559,12 +1561,15 @@ void MenuStateCustomGame::update() { switch(gameSettings.getNetworkPlayerStatuses(slotIndex)) { case npst_BeRightBack: labelPlayerStatus[i].setText(lang.get("PlayerStatusBeRightBack")); + labelPlayerStatus[i].setTextColor(Vec3f(1.f, 0.8f, 0.f)); break; case npst_Ready: labelPlayerStatus[i].setText(lang.get("PlayerStatusReady")); + labelPlayerStatus[i].setTextColor(Vec3f(0.f, 1.f, 0.f)); break; case npst_PickSettings: labelPlayerStatus[i].setText(lang.get("PlayerStatusSetup")); + labelPlayerStatus[i].setTextColor(Vec3f(1.f, 0.f, 0.f)); break; default: labelPlayerStatus[i].setText(""); @@ -1595,13 +1600,16 @@ void MenuStateCustomGame::update() { switch(serverInterface->getSlot(i)->getNetworkPlayerStatus()) { case npst_BeRightBack: labelPlayerStatus[i].setText(lang.get("PlayerStatusBeRightBack")); + labelPlayerStatus[i].setTextColor(Vec3f(1.f, 0.8f, 0.f)); break; case npst_Ready: labelPlayerStatus[i].setText(lang.get("PlayerStatusReady")); + labelPlayerStatus[i].setTextColor(Vec3f(0.f, 1.f, 0.f)); break; case npst_PickSettings: default: labelPlayerStatus[i].setText(lang.get("PlayerStatusSetup")); + labelPlayerStatus[i].setTextColor(Vec3f(1.f, 0.f, 0.f)); break; } }