diff --git a/source/glest_game/facilities/components.h b/source/glest_game/facilities/components.h index d308f49f..33da92dd 100644 --- a/source/glest_game/facilities/components.h +++ b/source/glest_game/facilities/components.h @@ -19,12 +19,14 @@ #include "font.h" #include "texture.h" #include "leak_dumper.h" +#include "vec.h" using std::string; using std::vector; using Shared::Graphics::Font2D; using namespace Shared::Graphics; +using Shared::Graphics::Vec3f; namespace Glest{ namespace Game{ diff --git a/source/glest_game/game/console.cpp b/source/glest_game/game/console.cpp index 7bb5e3a2..f61834bc 100644 --- a/source/glest_game/game/console.cpp +++ b/source/glest_game/game/console.cpp @@ -46,35 +46,16 @@ void Console::addStdMessage(const string &s) { addLine(Lang::getInstance().get(s)); } -void Console::addLine(string line, bool playSound, int playerIndex) { +void Console::addLine(string line, bool playSound,int playerIndex, Vec3f textColor) { try { - if(playSound == true) { - SoundRenderer::getInstance().playFx(CoreData::getInstance().getClickSoundA()); - } - ConsoleLineInfo info; - info.text = line; - info.timeStamp = timeElapsed; - info.PlayerIndex = playerIndex; - info.originalPlayerName = ""; + string playername=""; if(playerIndex >= 0) { GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface(); if(gameNetworkInterface != NULL) { - info.originalPlayerName = gameNetworkInterface->getGameSettings()->getNetworkPlayerNameByPlayerIndex(playerIndex); - //for(int i = 0; i < GameConstants::maxPlayers; ++i) { - // printf("i = %d, playerName = [%s]\n",i,gameNetworkInterface->getGameSettings()->getNetworkPlayerName(i).c_str()); - //} + playername=gameNetworkInterface->getGameSettings()->getNetworkPlayerNameByPlayerIndex(playerIndex); } } - //printf("info.PlayerIndex = %d, line [%s]\n",info.PlayerIndex,info.originalPlayerName.c_str()); - - lines.insert(lines.begin(), info); - if(lines.size() > maxLines) { - lines.pop_back(); - } - storedLines.insert(storedLines.begin(), info); - if(storedLines.size() > maxStoredLines) { - storedLines.pop_back(); - } + addLine(line, playSound,playername, textColor); } catch(const exception &ex) { char szBuf[1024]=""; @@ -84,7 +65,7 @@ void Console::addLine(string line, bool playSound, int playerIndex) { } } -void Console::addLine(string line, bool playSound, string playerName) { +void Console::addLine(string line, bool playSound, string playerName, Vec3f textColor) { try { if(playSound == true) { SoundRenderer::getInstance().playFx(CoreData::getInstance().getClickSoundA()); @@ -94,6 +75,7 @@ void Console::addLine(string line, bool playSound, string playerName) { info.timeStamp = timeElapsed; info.PlayerIndex = -1; info.originalPlayerName = ""; + info.color = textColor; if(playerName != "") { info.originalPlayerName = playerName; } diff --git a/source/glest_game/game/console.h b/source/glest_game/game/console.h index 30780972..589aaf43 100644 --- a/source/glest_game/game/console.h +++ b/source/glest_game/game/console.h @@ -18,6 +18,7 @@ #include #include "font.h" #include "leak_dumper.h" +#include "vec.h" using std::string; using std::vector; @@ -27,7 +28,7 @@ using namespace std; namespace Glest { namespace Game { using Shared::Graphics::Font2D; - +using Shared::Graphics::Vec3f; // ===================================================== // class Console // @@ -40,6 +41,7 @@ public: float timeStamp; int PlayerIndex; string originalPlayerName; + Vec3f color; }; class Console { @@ -91,8 +93,9 @@ public: void clearStoredLines(); void addStdMessage(const string &s); - void addLine(string line, bool playSound= false,int playerIndex=-1); - void addLine(string line, bool playSound,string playerName); + void addLine(string line, bool playSound= false,int playerIndex=-1,Vec3f textColor=Vec3f(1.f, 1.f, 1.f)); + void addLine(string line, bool playSound,string playerName, Vec3f textColor=Vec3f(1.f, 1.f, 1.f)); + void addLine(string line, bool playSound, Vec3f textColor){addLine(line,playSound,"",textColor);} void update(); bool isEmpty(); }; diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index fb3d5af3..f266f898 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -908,7 +908,8 @@ void Renderer::renderConsoleLine(int lineIndex, int xPosition, int yPosition, in } else { // white shadowed is default ( in the menu for example ) - fontColor=Vec4f(1.f, 1.f, 1.f, 0.0f); + //fontColor=Vec4f(1.f, 1.f, 1.f, 0.0f); + fontColor=Vec4f(lineInfo->color.x,lineInfo->color.y,lineInfo->color.z, 0.0f); } Vec4f defaultFontColor = fontColor; diff --git a/source/glest_game/menu/menu_state_masterserver.cpp b/source/glest_game/menu/menu_state_masterserver.cpp index c08e4895..636c8c3c 100644 --- a/source/glest_game/menu/menu_state_masterserver.cpp +++ b/source/glest_game/menu/menu_state_masterserver.cpp @@ -740,7 +740,7 @@ void MenuStateMasterserver::simpleTask(BaseThread *callingThread) { size_t lastIndex=0; //announcementLabel.setText(announcementTxt); - consoleIRC.addLine(announcementTxt); + consoleIRC.addLine(announcementTxt, true, Vec3f(1.0f,1.0f,0.0f)); while(true) { lastIndex=announcementTxt.find("\n",lastIndex+1); @@ -775,7 +775,7 @@ void MenuStateMasterserver::simpleTask(BaseThread *callingThread) { size_t lastIndex=0; //versionInfoLabel.setText(versionTxt); - consoleIRC.addLine(versionTxt); + consoleIRC.addLine(versionTxt, true, Vec3f(1.0f,0.0f,0.0f)); while(true) { lastIndex=versionTxt.find("\n",lastIndex+1);