Masterserver messages are highlighted in yellow now; console lines now can have individual colors (if not in game)!

This commit is contained in:
Titus Tscharntke 2011-03-26 17:17:34 +00:00
parent 8f2613e216
commit 5ccfc59819
5 changed files with 18 additions and 30 deletions

View File

@ -19,12 +19,14 @@
#include "font.h" #include "font.h"
#include "texture.h" #include "texture.h"
#include "leak_dumper.h" #include "leak_dumper.h"
#include "vec.h"
using std::string; using std::string;
using std::vector; using std::vector;
using Shared::Graphics::Font2D; using Shared::Graphics::Font2D;
using namespace Shared::Graphics; using namespace Shared::Graphics;
using Shared::Graphics::Vec3f;
namespace Glest{ namespace Game{ namespace Glest{ namespace Game{

View File

@ -46,35 +46,16 @@ void Console::addStdMessage(const string &s) {
addLine(Lang::getInstance().get(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 { try {
if(playSound == true) { string playername="";
SoundRenderer::getInstance().playFx(CoreData::getInstance().getClickSoundA());
}
ConsoleLineInfo info;
info.text = line;
info.timeStamp = timeElapsed;
info.PlayerIndex = playerIndex;
info.originalPlayerName = "";
if(playerIndex >= 0) { if(playerIndex >= 0) {
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface(); GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
if(gameNetworkInterface != NULL) { if(gameNetworkInterface != NULL) {
info.originalPlayerName = gameNetworkInterface->getGameSettings()->getNetworkPlayerNameByPlayerIndex(playerIndex); playername=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());
//}
} }
} }
//printf("info.PlayerIndex = %d, line [%s]\n",info.PlayerIndex,info.originalPlayerName.c_str()); addLine(line, playSound,playername, textColor);
lines.insert(lines.begin(), info);
if(lines.size() > maxLines) {
lines.pop_back();
}
storedLines.insert(storedLines.begin(), info);
if(storedLines.size() > maxStoredLines) {
storedLines.pop_back();
}
} }
catch(const exception &ex) { catch(const exception &ex) {
char szBuf[1024]=""; 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 { try {
if(playSound == true) { if(playSound == true) {
SoundRenderer::getInstance().playFx(CoreData::getInstance().getClickSoundA()); SoundRenderer::getInstance().playFx(CoreData::getInstance().getClickSoundA());
@ -94,6 +75,7 @@ void Console::addLine(string line, bool playSound, string playerName) {
info.timeStamp = timeElapsed; info.timeStamp = timeElapsed;
info.PlayerIndex = -1; info.PlayerIndex = -1;
info.originalPlayerName = ""; info.originalPlayerName = "";
info.color = textColor;
if(playerName != "") { if(playerName != "") {
info.originalPlayerName = playerName; info.originalPlayerName = playerName;
} }

View File

@ -18,6 +18,7 @@
#include <stdexcept> #include <stdexcept>
#include "font.h" #include "font.h"
#include "leak_dumper.h" #include "leak_dumper.h"
#include "vec.h"
using std::string; using std::string;
using std::vector; using std::vector;
@ -27,7 +28,7 @@ using namespace std;
namespace Glest { namespace Game { namespace Glest { namespace Game {
using Shared::Graphics::Font2D; using Shared::Graphics::Font2D;
using Shared::Graphics::Vec3f;
// ===================================================== // =====================================================
// class Console // class Console
// //
@ -40,6 +41,7 @@ public:
float timeStamp; float timeStamp;
int PlayerIndex; int PlayerIndex;
string originalPlayerName; string originalPlayerName;
Vec3f color;
}; };
class Console { class Console {
@ -91,8 +93,9 @@ public:
void clearStoredLines(); void clearStoredLines();
void addStdMessage(const string &s); void addStdMessage(const string &s);
void addLine(string line, bool playSound= false,int playerIndex=-1); 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); 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(); void update();
bool isEmpty(); bool isEmpty();
}; };

View File

@ -908,7 +908,8 @@ void Renderer::renderConsoleLine(int lineIndex, int xPosition, int yPosition, in
} }
else { else {
// white shadowed is default ( in the menu for example ) // 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; Vec4f defaultFontColor = fontColor;

View File

@ -740,7 +740,7 @@ void MenuStateMasterserver::simpleTask(BaseThread *callingThread) {
size_t lastIndex=0; size_t lastIndex=0;
//announcementLabel.setText(announcementTxt); //announcementLabel.setText(announcementTxt);
consoleIRC.addLine(announcementTxt); consoleIRC.addLine(announcementTxt, true, Vec3f(1.0f,1.0f,0.0f));
while(true) { while(true) {
lastIndex=announcementTxt.find("\n",lastIndex+1); lastIndex=announcementTxt.find("\n",lastIndex+1);
@ -775,7 +775,7 @@ void MenuStateMasterserver::simpleTask(BaseThread *callingThread) {
size_t lastIndex=0; size_t lastIndex=0;
//versionInfoLabel.setText(versionTxt); //versionInfoLabel.setText(versionTxt);
consoleIRC.addLine(versionTxt); consoleIRC.addLine(versionTxt, true, Vec3f(1.0f,0.0f,0.0f));
while(true) { while(true) {
lastIndex=versionTxt.find("\n",lastIndex+1); lastIndex=versionTxt.find("\n",lastIndex+1);