chat highlighting, and more features related to chat

This commit is contained in:
Titus Tscharntke
2011-01-01 20:31:25 +00:00
parent 42fa56d464
commit 13c6fb49b3
11 changed files with 82 additions and 54 deletions

View File

@@ -94,13 +94,16 @@ void ChatManager::keyDown(char key) {
key == configKeys.getCharKey("ChatTeamMode")) { key == configKeys.getCharKey("ChatTeamMode")) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
if (!inMenu) {
if (teamMode == true) { if (teamMode == true) {
teamMode = false; teamMode = false;
console->addLine(lang.get("ChatMode") + ": " + lang.get("All")); console->addLine(lang.get("ChatMode") + ": " + lang.get(
} "All"));
else { } else {
teamMode = true; teamMode = true;
console->addLine(lang.get("ChatMode") + ": " + lang.get("Team")); console->addLine(lang.get("ChatMode") + ": " + lang.get(
"Team"));
}
} }
} }

View File

@@ -55,6 +55,7 @@ public:
bool getEditEnabled() const {return editEnabled;} bool getEditEnabled() const {return editEnabled;}
bool getTeamMode() const {return teamMode;} bool getTeamMode() const {return teamMode;}
bool getInMenu() const {return inMenu;}
string getText() const {return text;} string getText() const {return text;}
int getXPos() const {return xPos;} int getXPos() const {return xPos;}
void setXPos(int xPos) {this->xPos= xPos;} void setXPos(int xPos) {this->xPos= xPos;}

View File

@@ -55,6 +55,7 @@ private:
float timeElapsed; float timeElapsed;
Lines lines; Lines lines;
Lines storedLines; Lines storedLines;
string stringToHighlight;
//config //config
int maxLines; int maxLines;
@@ -78,6 +79,10 @@ public:
void setLineHeight(int lineHeight) {this->lineHeight= lineHeight;} void setLineHeight(int lineHeight) {this->lineHeight= lineHeight;}
Font2D *getFont() const {return font;} Font2D *getFont() const {return font;}
void setFont(Font2D *font) {this->font= font;} void setFont(Font2D *font) {this->font= font;}
string getStringToHighlight() const { return stringToHighlight;}
void setStringToHighlight(string stringToHighlight) { this->stringToHighlight = stringToHighlight;}
string getLine(int i) const; string getLine(int i) const;
string getStoredLine(int i) const; string getStoredLine(int i) const;

View File

@@ -186,6 +186,7 @@ void CoreData::load() {
clickSoundB.load(dir+"/menu/sound/click_b.wav"); clickSoundB.load(dir+"/menu/sound/click_b.wav");
clickSoundC.load(dir+"/menu/sound/click_c.wav"); clickSoundC.load(dir+"/menu/sound/click_c.wav");
attentionSound.load(dir+"/menu/sound/attention.wav"); attentionSound.load(dir+"/menu/sound/attention.wav");
highlightSound.load(dir+"/menu/sound/highlight.wav");
introMusic.open(dir+"/menu/music/intro_music.ogg"); introMusic.open(dir+"/menu/music/intro_music.ogg");
introMusic.setNext(&menuMusic); introMusic.setNext(&menuMusic);
menuMusic.open(dir+"/menu/music/menu_music.ogg"); menuMusic.open(dir+"/menu/music/menu_music.ogg");

View File

@@ -42,6 +42,7 @@ private:
StaticSound clickSoundB; StaticSound clickSoundB;
StaticSound clickSoundC; StaticSound clickSoundC;
StaticSound attentionSound; StaticSound attentionSound;
StaticSound highlightSound;
SoundContainer waterSounds; SoundContainer waterSounds;
Texture2D *logoTexture; Texture2D *logoTexture;
@@ -93,6 +94,7 @@ public:
StaticSound *getClickSoundB() {return &clickSoundB;} StaticSound *getClickSoundB() {return &clickSoundB;}
StaticSound *getClickSoundC() {return &clickSoundC;} StaticSound *getClickSoundC() {return &clickSoundC;}
StaticSound *getAttentionSound() {return &attentionSound;} StaticSound *getAttentionSound() {return &attentionSound;}
StaticSound *getHighlightSound() {return &highlightSound;}
StaticSound *getWaterSound() {return waterSounds.getRandSound();} StaticSound *getWaterSound() {return waterSounds.getRandSound();}
Font2D *getDisplayFont() const {return displayFont;} Font2D *getDisplayFont() const {return displayFont;}

View File

@@ -836,7 +836,7 @@ void Renderer::renderTextureQuad(int x, int y, int w, int h, const Texture2D *te
} }
void Renderer::renderConsoleLine(int lineIndex, int xPosition, int yPosition, int lineHeight, void Renderer::renderConsoleLine(int lineIndex, int xPosition, int yPosition, int lineHeight,
const Font2D* font, const ConsoleLineInfo *lineInfo) { const Font2D* font, string stringToHightlight, const ConsoleLineInfo *lineInfo) {
Vec4f fontColor; Vec4f fontColor;
const Metrics &metrics= Metrics::getInstance(); const Metrics &metrics= Metrics::getInstance();
const FontMetrics *fontMetrics= font->getMetrics(); const FontMetrics *fontMetrics= font->getMetrics();
@@ -909,6 +909,9 @@ void Renderer::renderConsoleLine(int lineIndex, int xPosition, int yPosition, in
fontColor = defaultFontColor; fontColor = defaultFontColor;
} }
if(lineInfo->text.find(stringToHightlight)!=string::npos){
fontColor=Vec4f(1.f, 0.5f, 0.5f, 0.0f);
}
renderTextShadow( renderTextShadow(
lineInfo->text, lineInfo->text,
font, font,
@@ -928,21 +931,21 @@ void Renderer::renderConsole(const Console *console,const bool showFullConsole,c
for(int i = 0; i < console->getStoredLineCount(); ++i) { for(int i = 0; i < console->getStoredLineCount(); ++i) {
const ConsoleLineInfo &lineInfo = console->getStoredLineItem(i); const ConsoleLineInfo &lineInfo = console->getStoredLineItem(i);
renderConsoleLine(i, console->getXPos(), console->getYPos(), renderConsoleLine(i, console->getXPos(), console->getYPos(),
console->getLineHeight(), console->getFont(), &lineInfo); console->getLineHeight(), console->getFont(), console->getStringToHighlight(), &lineInfo);
} }
} }
else if(showMenuConsole) { else if(showMenuConsole) {
for(int i = 0; i < console->getStoredLineCount() && i < maxConsoleLines; ++i) { for(int i = 0; i < console->getStoredLineCount() && i < maxConsoleLines; ++i) {
const ConsoleLineInfo &lineInfo = console->getStoredLineItem(i); const ConsoleLineInfo &lineInfo = console->getStoredLineItem(i);
renderConsoleLine(i, console->getXPos(), console->getYPos(), renderConsoleLine(i, console->getXPos(), console->getYPos(),
console->getLineHeight(), console->getFont(), &lineInfo); console->getLineHeight(), console->getFont(), console->getStringToHighlight(), &lineInfo);
} }
} }
else { else {
for(int i = 0; i < console->getLineCount(); ++i) { for(int i = 0; i < console->getLineCount(); ++i) {
const ConsoleLineInfo &lineInfo = console->getLineItem(i); const ConsoleLineInfo &lineInfo = console->getLineItem(i);
renderConsoleLine(i, console->getXPos(), console->getYPos(), renderConsoleLine(i, console->getXPos(), console->getYPos(),
console->getLineHeight(), console->getFont(), &lineInfo); console->getLineHeight(), console->getFont(), console->getStringToHighlight(), &lineInfo);
} }
} }
glPopAttrib(); glPopAttrib();
@@ -955,7 +958,10 @@ void Renderer::renderChatManager(const ChatManager *chatManager) {
if(chatManager->getEditEnabled()) { if(chatManager->getEditEnabled()) {
string text=""; string text="";
if(chatManager->getTeamMode()) { if(chatManager->getInMenu()){
text += lang.get("Chat");
}
else if(chatManager->getTeamMode()) {
text += lang.get("Team"); text += lang.get("Team");
} }
else { else {
@@ -981,6 +987,15 @@ void Renderer::renderChatManager(const ChatManager *chatManager) {
//textRenderer->render(text, 300, 150); //textRenderer->render(text, 300, 150);
//textRenderer->end(); //textRenderer->end();
} }
else
{
if (chatManager->getInMenu()) {
string text = ">> "+lang.get("PressEnterToChat")+" <<";
fontColor = Vec4f(0.5f, 0.5f, 0.5f, 0.5f);
renderTextShadow(text, chatManager->getFont(), fontColor,
chatManager->getXPos(), chatManager->getYPos());
}
}
} }
void Renderer::renderResourceStatus(){ void Renderer::renderResourceStatus(){

View File

@@ -312,7 +312,7 @@ public:
void renderBackground(const Texture2D *texture); void renderBackground(const Texture2D *texture);
void renderTextureQuad(int x, int y, int w, int h, const Texture2D *texture, float alpha=1.f,const Vec3f *color=NULL); void renderTextureQuad(int x, int y, int w, int h, const Texture2D *texture, float alpha=1.f,const Vec3f *color=NULL);
void renderConsole(const Console *console, const bool showAll=false, const bool showMenuConsole=false); void renderConsole(const Console *console, const bool showAll=false, const bool showMenuConsole=false);
void renderConsoleLine(int lineIndex, int xPosition, int yPosition, int lineHeight, const Font2D* font,const ConsoleLineInfo *lineInfo); void renderConsoleLine(int lineIndex, int xPosition, int yPosition, int lineHeight, const Font2D* font, string stringToHightlight, const ConsoleLineInfo *lineInfo);
void renderChatManager(const ChatManager *chatManager); void renderChatManager(const ChatManager *chatManager);
void renderResourceStatus(); void renderResourceStatus();
void renderSelectionQuad(); void renderSelectionQuad();

View File

@@ -232,6 +232,8 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
string netPlayerName=Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()); string netPlayerName=Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str());
string ircname=netPlayerName.substr(0,9); string ircname=netPlayerName.substr(0,9);
sprintf(szIRCNick,"MG_%s_%d",ircname.c_str(),randomNickId); sprintf(szIRCNick,"MG_%s_%d",ircname.c_str(),randomNickId);
currentIrcNick=ircname;
consoleIRC.setStringToHighlight(currentIrcNick);
lines[2].init(0,consoleIRC.getYPos()-10,userButtonsXBase,5); lines[2].init(0,consoleIRC.getYPos()-10,userButtonsXBase,5);
chatManager.init(&consoleIRC, -1, true, szIRCNick); chatManager.init(&consoleIRC, -1, true, szIRCNick);
@@ -283,6 +285,13 @@ void MenuStateMasterserver::IRC_CallbackEvent(IRCEventType evt, const char* orig
char szBuf[4096]=""; char szBuf[4096]="";
sprintf(szBuf,"%s: %s",origin ? origin : "someone",params[1]); sprintf(szBuf,"%s: %s",origin ? origin : "someone",params[1]);
string helpSTr=szBuf;
if(helpSTr.find(currentIrcNick)!=string::npos){
CoreData &coreData= CoreData::getInstance();
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
soundRenderer.playFx(coreData.getHighlightSound());
}
consoleIRC.addLine(szBuf); consoleIRC.addLine(szBuf);
} }
} }
@@ -524,9 +533,11 @@ void MenuStateMasterserver::mouseMove(int x, int y, const MouseState *ms){
buttonCreateGame.mouseMove(x, y); buttonCreateGame.mouseMove(x, y);
if (ms->get(mbLeft)) { if (ms->get(mbLeft)) {
userScrollBar.mouseDown(x, y); userScrollBar.mouseDown(x, y);
} serverScrollBar.mouseDown(x, y);
else } else {
userScrollBar.mouseMove(x, y); userScrollBar.mouseMove(x, y);
serverScrollBar.mouseMove(x, y);
}
listBoxAutoRefresh.mouseMove(x, y); listBoxAutoRefresh.mouseMove(x, y);
if(serverScrollBar.getElementCount()!=0 ) { if(serverScrollBar.getElementCount()!=0 ) {
@@ -650,13 +661,16 @@ void MenuStateMasterserver::update() {
consoleIRC.update(); consoleIRC.update();
MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient); MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient);
safeMutexIRCPtr.Lock();
if(ircClient != NULL) { if(ircClient != NULL) {
std::vector<string> nickList = ircClient->getNickList(); std::vector<string> nickList = ircClient->getNickList();
bool isNew=false; bool isNew=false;
//check if there is something new //check if there is something new
if( oldNickList.size()!=nickList.size()) { if( oldNickList.size()!=nickList.size()) {
isNew=true; isNew=true;
if(currentIrcNick!=ircClient->getNick()){
currentIrcNick=ircClient->getNick();
consoleIRC.setStringToHighlight(currentIrcNick);
}
} }
else { else {
for(int i = 0; i < nickList.size(); ++i) { for(int i = 0; i < nickList.size(); ++i) {

View File

@@ -76,7 +76,7 @@ private:
SimpleTaskThread *updateFromMasterserverThread; SimpleTaskThread *updateFromMasterserverThread;
bool playServerFoundSound; bool playServerFoundSound;
ServerLines serverLines; ServerLines serverLines;
std::string serverInfoString; string serverInfoString;
int serverLinesToRender; int serverLinesToRender;
int serverLinesYBase; int serverLinesYBase;
int serverLinesLineHeight; int serverLinesLineHeight;
@@ -90,6 +90,7 @@ private:
int userButtonsLineHeight; int userButtonsLineHeight;
int userButtonsHeight; int userButtonsHeight;
int userButtonsWidth; int userButtonsWidth;
string currentIrcNick;
//Console console; //Console console;

View File

@@ -42,14 +42,10 @@ ServerLine::ServerLine( MasterServerInfo *mServerInfo, int lineIndex, int baseY,
//general info: //general info:
i+=10; i+=10;
glestVersionLabel.registerGraphicComponent(containerName,"glestVersionLabel" + intToStr(lineIndex));
registeredObjNameList.push_back("glestVersionLabel" + intToStr(lineIndex));
glestVersionLabel.init(i,baseY-lineOffset); glestVersionLabel.init(i,baseY-lineOffset);
glestVersionLabel.setText(masterServerInfo.getGlestVersion()); glestVersionLabel.setText(masterServerInfo.getGlestVersion());
i+=80; i+=80;
registeredObjNameList.push_back("platformLabel" + intToStr(lineIndex));
platformLabel.registerGraphicComponent(containerName,"platformLabel" + intToStr(lineIndex));
platformLabel.init(i,baseY-lineOffset); platformLabel.init(i,baseY-lineOffset);
platformLabel.setText(masterServerInfo.getPlatform()); platformLabel.setText(masterServerInfo.getPlatform());
@@ -61,71 +57,55 @@ ServerLine::ServerLine( MasterServerInfo *mServerInfo, int lineIndex, int baseY,
//game info: //game info:
i+=80; i+=80;
registeredObjNameList.push_back("serverTitleLabel" + intToStr(lineIndex));
serverTitleLabel.registerGraphicComponent(containerName,"serverTitleLabel" + intToStr(lineIndex));
serverTitleLabel.init(i,baseY-lineOffset); serverTitleLabel.init(i,baseY-lineOffset);
serverTitleLabel.setText(masterServerInfo.getServerTitle()); serverTitleLabel.setText(masterServerInfo.getServerTitle());
i+=200; i+=200;
registeredObjNameList.push_back("ipAddressLabel" + intToStr(lineIndex));
ipAddressLabel.registerGraphicComponent(containerName,"ipAddressLabel" + intToStr(lineIndex));
ipAddressLabel.init(i,baseY-lineOffset); ipAddressLabel.init(i,baseY-lineOffset);
ipAddressLabel.setText(masterServerInfo.getIpAddress()); ipAddressLabel.setText(masterServerInfo.getIpAddress());
wrongVersionLabel.init(i,baseY-lineOffset);
wrongVersionLabel.setText(lang.get("IncompatibleVersion"));
//game setup info: //game setup info:
i+=120; i+=120;
registeredObjNameList.push_back("techLabel" + intToStr(lineIndex));
techLabel.registerGraphicComponent(containerName,"techLabel" + intToStr(lineIndex));
techLabel.init(i,baseY-lineOffset); techLabel.init(i,baseY-lineOffset);
techLabel.setText(masterServerInfo.getTech()); techLabel.setText(masterServerInfo.getTech());
i+=100; i+=100;
registeredObjNameList.push_back("mapLabel" + intToStr(lineIndex));
mapLabel.registerGraphicComponent(containerName,"mapLabel" + intToStr(lineIndex));
mapLabel.init(i,baseY-lineOffset); mapLabel.init(i,baseY-lineOffset);
mapLabel.setText(masterServerInfo.getMap()); mapLabel.setText(masterServerInfo.getMap());
i+=100; i+=100;
registeredObjNameList.push_back("tilesetLabel" + intToStr(lineIndex));
tilesetLabel.registerGraphicComponent(containerName,"tilesetLabel" + intToStr(lineIndex));
tilesetLabel.init(i,baseY-lineOffset); tilesetLabel.init(i,baseY-lineOffset);
tilesetLabel.setText(masterServerInfo.getTileset()); tilesetLabel.setText(masterServerInfo.getTileset());
i+=100; i+=100;
registeredObjNameList.push_back("activeSlotsLabel" + intToStr(lineIndex));
activeSlotsLabel.registerGraphicComponent(containerName,"activeSlotsLabel" + intToStr(lineIndex));
activeSlotsLabel.init(i,baseY-lineOffset); activeSlotsLabel.init(i,baseY-lineOffset);
activeSlotsLabel.setText(intToStr(masterServerInfo.getActiveSlots())+"/"+intToStr(masterServerInfo.getNetworkSlots())+"/"+intToStr(masterServerInfo.getConnectedClients())); activeSlotsLabel.setText(intToStr(masterServerInfo.getActiveSlots())+"/"+intToStr(masterServerInfo.getNetworkSlots())+"/"+intToStr(masterServerInfo.getConnectedClients()));
i+=50; i+=50;
registeredObjNameList.push_back("externalConnectPort" + intToStr(lineIndex));
externalConnectPort.registerGraphicComponent(containerName,"externalConnectPort" + intToStr(lineIndex));
externalConnectPort.init(i,baseY-lineOffset); externalConnectPort.init(i,baseY-lineOffset);
externalConnectPort.setText(intToStr(masterServerInfo.getExternalConnectPort())); externalConnectPort.setText(intToStr(masterServerInfo.getExternalConnectPort()));
i+=50; i+=50;
registeredObjNameList.push_back("selectButton" + intToStr(lineIndex));
selectButton.registerGraphicComponent(containerName,"selectButton" + intToStr(lineIndex));
selectButton.init(i, baseY-lineOffset, 30); selectButton.init(i, baseY-lineOffset, 30);
selectButton.setText(">"); selectButton.setText(">");
//printf("glestVersionString [%s] masterServerInfo->getGlestVersion() [%s]\n",glestVersionString.c_str(),masterServerInfo->getGlestVersion().c_str()); //printf("glestVersionString [%s] masterServerInfo->getGlestVersion() [%s]\n",glestVersionString.c_str(),masterServerInfo->getGlestVersion().c_str());
bool compatible = checkVersionComptability(glestVersionString, masterServerInfo.getGlestVersion()); compatible = checkVersionComptability(glestVersionString, masterServerInfo.getGlestVersion());
selectButton.setEnabled(compatible); selectButton.setEnabled(compatible);
selectButton.setEditable(compatible); selectButton.setEditable(compatible);
registeredObjNameList.push_back("gameFull" + intToStr(lineIndex));
gameFull.registerGraphicComponent(containerName,"gameFull" + intToStr(lineIndex));
gameFull.init(i, baseY-lineOffset); gameFull.init(i, baseY-lineOffset);
gameFull.setText(lang.get("MGGameSlotsFull")); gameFull.setText(lang.get("MGGameSlotsFull"));
gameFull.setEnabled(!compatible); gameFull.setEnabled(!compatible);
gameFull.setEditable(!compatible); gameFull.setEditable(!compatible);
GraphicComponent::applyAllCustomProperties(containerName);
} }
ServerLine::~ServerLine() { ServerLine::~ServerLine() {
GraphicComponent::clearRegisterGraphicComponent(containerName, registeredObjNameList);
//delete masterServerInfo; //delete masterServerInfo;
} }
@@ -168,6 +148,7 @@ void ServerLine::render() {
//game info: //game info:
renderer.renderLabel(&serverTitleLabel); renderer.renderLabel(&serverTitleLabel);
if(!gameFull.getEnabled()){ if(!gameFull.getEnabled()){
if (compatible) {
renderer.renderLabel(&ipAddressLabel); renderer.renderLabel(&ipAddressLabel);
//game setup info: //game setup info:
@@ -177,6 +158,11 @@ void ServerLine::render() {
renderer.renderLabel(&activeSlotsLabel); renderer.renderLabel(&activeSlotsLabel);
renderer.renderLabel(&externalConnectPort); renderer.renderLabel(&externalConnectPort);
} }
else {
renderer.renderLabel(&wrongVersionLabel);
}
}
} }
void ServerLine::setY(int y) { void ServerLine::setY(int y) {

View File

@@ -31,8 +31,10 @@ private:
MasterServerInfo masterServerInfo; MasterServerInfo masterServerInfo;
int lineHeight; int lineHeight;
int baseY; int baseY;
bool compatible;
GraphicButton selectButton; GraphicButton selectButton;
GraphicLabel gameFull; GraphicLabel gameFull;
GraphicLabel wrongVersionLabel;
//general info: //general info:
GraphicLabel glestVersionLabel; GraphicLabel glestVersionLabel;
@@ -52,7 +54,6 @@ private:
GraphicLabel externalConnectPort; GraphicLabel externalConnectPort;
const char * containerName; const char * containerName;
std::vector<std::string> registeredObjNameList;
public: public:
ServerLine( MasterServerInfo *mServerInfo, int lineIndex, int baseY, int lineHeight, const char *containerName); ServerLine( MasterServerInfo *mServerInfo, int lineIndex, int baseY, int lineHeight, const char *containerName);
@@ -64,7 +65,6 @@ public:
void setY(int y); void setY(int y);
//void setIndex(int value); //void setIndex(int value);
void render(); void render();
}; };
}}//end namespace }}//end namespace