chat highlighting, and more features related to chat
This commit is contained in:
parent
42fa56d464
commit
13c6fb49b3
|
@ -94,13 +94,16 @@ void ChatManager::keyDown(char key) {
|
|||
key == configKeys.getCharKey("ChatTeamMode")) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
||||
|
||||
if(teamMode == true) {
|
||||
teamMode= false;
|
||||
console->addLine(lang.get("ChatMode") + ": " + lang.get("All"));
|
||||
}
|
||||
else {
|
||||
teamMode= true;
|
||||
console->addLine(lang.get("ChatMode") + ": " + lang.get("Team"));
|
||||
if (!inMenu) {
|
||||
if (teamMode == true) {
|
||||
teamMode = false;
|
||||
console->addLine(lang.get("ChatMode") + ": " + lang.get(
|
||||
"All"));
|
||||
} else {
|
||||
teamMode = true;
|
||||
console->addLine(lang.get("ChatMode") + ": " + lang.get(
|
||||
"Team"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
|
||||
bool getEditEnabled() const {return editEnabled;}
|
||||
bool getTeamMode() const {return teamMode;}
|
||||
bool getInMenu() const {return inMenu;}
|
||||
string getText() const {return text;}
|
||||
int getXPos() const {return xPos;}
|
||||
void setXPos(int xPos) {this->xPos= xPos;}
|
||||
|
|
|
@ -55,6 +55,7 @@ private:
|
|||
float timeElapsed;
|
||||
Lines lines;
|
||||
Lines storedLines;
|
||||
string stringToHighlight;
|
||||
|
||||
//config
|
||||
int maxLines;
|
||||
|
@ -78,6 +79,10 @@ public:
|
|||
void setLineHeight(int lineHeight) {this->lineHeight= lineHeight;}
|
||||
Font2D *getFont() const {return 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 getStoredLine(int i) const;
|
||||
|
|
|
@ -186,6 +186,7 @@ void CoreData::load() {
|
|||
clickSoundB.load(dir+"/menu/sound/click_b.wav");
|
||||
clickSoundC.load(dir+"/menu/sound/click_c.wav");
|
||||
attentionSound.load(dir+"/menu/sound/attention.wav");
|
||||
highlightSound.load(dir+"/menu/sound/highlight.wav");
|
||||
introMusic.open(dir+"/menu/music/intro_music.ogg");
|
||||
introMusic.setNext(&menuMusic);
|
||||
menuMusic.open(dir+"/menu/music/menu_music.ogg");
|
||||
|
|
|
@ -42,6 +42,7 @@ private:
|
|||
StaticSound clickSoundB;
|
||||
StaticSound clickSoundC;
|
||||
StaticSound attentionSound;
|
||||
StaticSound highlightSound;
|
||||
SoundContainer waterSounds;
|
||||
|
||||
Texture2D *logoTexture;
|
||||
|
@ -93,6 +94,7 @@ public:
|
|||
StaticSound *getClickSoundB() {return &clickSoundB;}
|
||||
StaticSound *getClickSoundC() {return &clickSoundC;}
|
||||
StaticSound *getAttentionSound() {return &attentionSound;}
|
||||
StaticSound *getHighlightSound() {return &highlightSound;}
|
||||
StaticSound *getWaterSound() {return waterSounds.getRandSound();}
|
||||
|
||||
Font2D *getDisplayFont() const {return displayFont;}
|
||||
|
|
|
@ -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,
|
||||
const Font2D* font, const ConsoleLineInfo *lineInfo) {
|
||||
const Font2D* font, string stringToHightlight, const ConsoleLineInfo *lineInfo) {
|
||||
Vec4f fontColor;
|
||||
const Metrics &metrics= Metrics::getInstance();
|
||||
const FontMetrics *fontMetrics= font->getMetrics();
|
||||
|
@ -909,6 +909,9 @@ void Renderer::renderConsoleLine(int lineIndex, int xPosition, int yPosition, in
|
|||
fontColor = defaultFontColor;
|
||||
}
|
||||
|
||||
if(lineInfo->text.find(stringToHightlight)!=string::npos){
|
||||
fontColor=Vec4f(1.f, 0.5f, 0.5f, 0.0f);
|
||||
}
|
||||
renderTextShadow(
|
||||
lineInfo->text,
|
||||
font,
|
||||
|
@ -928,21 +931,21 @@ void Renderer::renderConsole(const Console *console,const bool showFullConsole,c
|
|||
for(int i = 0; i < console->getStoredLineCount(); ++i) {
|
||||
const ConsoleLineInfo &lineInfo = console->getStoredLineItem(i);
|
||||
renderConsoleLine(i, console->getXPos(), console->getYPos(),
|
||||
console->getLineHeight(), console->getFont(), &lineInfo);
|
||||
console->getLineHeight(), console->getFont(), console->getStringToHighlight(), &lineInfo);
|
||||
}
|
||||
}
|
||||
else if(showMenuConsole) {
|
||||
for(int i = 0; i < console->getStoredLineCount() && i < maxConsoleLines; ++i) {
|
||||
const ConsoleLineInfo &lineInfo = console->getStoredLineItem(i);
|
||||
renderConsoleLine(i, console->getXPos(), console->getYPos(),
|
||||
console->getLineHeight(), console->getFont(), &lineInfo);
|
||||
console->getLineHeight(), console->getFont(), console->getStringToHighlight(), &lineInfo);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(int i = 0; i < console->getLineCount(); ++i) {
|
||||
const ConsoleLineInfo &lineInfo = console->getLineItem(i);
|
||||
renderConsoleLine(i, console->getXPos(), console->getYPos(),
|
||||
console->getLineHeight(), console->getFont(), &lineInfo);
|
||||
console->getLineHeight(), console->getFont(), console->getStringToHighlight(), &lineInfo);
|
||||
}
|
||||
}
|
||||
glPopAttrib();
|
||||
|
@ -955,7 +958,10 @@ void Renderer::renderChatManager(const ChatManager *chatManager) {
|
|||
if(chatManager->getEditEnabled()) {
|
||||
string text="";
|
||||
|
||||
if(chatManager->getTeamMode()) {
|
||||
if(chatManager->getInMenu()){
|
||||
text += lang.get("Chat");
|
||||
}
|
||||
else if(chatManager->getTeamMode()) {
|
||||
text += lang.get("Team");
|
||||
}
|
||||
else {
|
||||
|
@ -981,6 +987,15 @@ void Renderer::renderChatManager(const ChatManager *chatManager) {
|
|||
//textRenderer->render(text, 300, 150);
|
||||
//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(){
|
||||
|
|
|
@ -312,7 +312,7 @@ public:
|
|||
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 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 renderResourceStatus();
|
||||
void renderSelectionQuad();
|
||||
|
|
|
@ -232,6 +232,8 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
|
|||
string netPlayerName=Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str());
|
||||
string ircname=netPlayerName.substr(0,9);
|
||||
sprintf(szIRCNick,"MG_%s_%d",ircname.c_str(),randomNickId);
|
||||
currentIrcNick=ircname;
|
||||
consoleIRC.setStringToHighlight(currentIrcNick);
|
||||
|
||||
lines[2].init(0,consoleIRC.getYPos()-10,userButtonsXBase,5);
|
||||
chatManager.init(&consoleIRC, -1, true, szIRCNick);
|
||||
|
@ -283,6 +285,13 @@ void MenuStateMasterserver::IRC_CallbackEvent(IRCEventType evt, const char* orig
|
|||
|
||||
char szBuf[4096]="";
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -522,11 +531,13 @@ void MenuStateMasterserver::mouseMove(int x, int y, const MouseState *ms){
|
|||
buttonRefresh.mouseMove(x, y);
|
||||
buttonReturn.mouseMove(x, y);
|
||||
buttonCreateGame.mouseMove(x, y);
|
||||
if(ms->get(mbLeft)){
|
||||
userScrollBar.mouseDown(x, y);
|
||||
}
|
||||
else
|
||||
userScrollBar.mouseMove(x, y);
|
||||
if (ms->get(mbLeft)) {
|
||||
userScrollBar.mouseDown(x, y);
|
||||
serverScrollBar.mouseDown(x, y);
|
||||
} else {
|
||||
userScrollBar.mouseMove(x, y);
|
||||
serverScrollBar.mouseMove(x, y);
|
||||
}
|
||||
listBoxAutoRefresh.mouseMove(x, y);
|
||||
|
||||
if(serverScrollBar.getElementCount()!=0 ) {
|
||||
|
@ -650,13 +661,16 @@ void MenuStateMasterserver::update() {
|
|||
consoleIRC.update();
|
||||
|
||||
MutexSafeWrapper safeMutexIRCPtr(&mutexIRCClient);
|
||||
safeMutexIRCPtr.Lock();
|
||||
if(ircClient != NULL) {
|
||||
std::vector<string> nickList = ircClient->getNickList();
|
||||
bool isNew=false;
|
||||
//check if there is something new
|
||||
if( oldNickList.size()!=nickList.size()) {
|
||||
isNew=true;
|
||||
if(currentIrcNick!=ircClient->getNick()){
|
||||
currentIrcNick=ircClient->getNick();
|
||||
consoleIRC.setStringToHighlight(currentIrcNick);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(int i = 0; i < nickList.size(); ++i) {
|
||||
|
|
|
@ -76,7 +76,7 @@ private:
|
|||
SimpleTaskThread *updateFromMasterserverThread;
|
||||
bool playServerFoundSound;
|
||||
ServerLines serverLines;
|
||||
std::string serverInfoString;
|
||||
string serverInfoString;
|
||||
int serverLinesToRender;
|
||||
int serverLinesYBase;
|
||||
int serverLinesLineHeight;
|
||||
|
@ -90,6 +90,7 @@ private:
|
|||
int userButtonsLineHeight;
|
||||
int userButtonsHeight;
|
||||
int userButtonsWidth;
|
||||
string currentIrcNick;
|
||||
|
||||
|
||||
//Console console;
|
||||
|
|
|
@ -42,14 +42,10 @@ ServerLine::ServerLine( MasterServerInfo *mServerInfo, int lineIndex, int baseY,
|
|||
|
||||
//general info:
|
||||
i+=10;
|
||||
glestVersionLabel.registerGraphicComponent(containerName,"glestVersionLabel" + intToStr(lineIndex));
|
||||
registeredObjNameList.push_back("glestVersionLabel" + intToStr(lineIndex));
|
||||
glestVersionLabel.init(i,baseY-lineOffset);
|
||||
glestVersionLabel.setText(masterServerInfo.getGlestVersion());
|
||||
|
||||
i+=80;
|
||||
registeredObjNameList.push_back("platformLabel" + intToStr(lineIndex));
|
||||
platformLabel.registerGraphicComponent(containerName,"platformLabel" + intToStr(lineIndex));
|
||||
platformLabel.init(i,baseY-lineOffset);
|
||||
platformLabel.setText(masterServerInfo.getPlatform());
|
||||
|
||||
|
@ -61,71 +57,55 @@ ServerLine::ServerLine( MasterServerInfo *mServerInfo, int lineIndex, int baseY,
|
|||
|
||||
//game info:
|
||||
i+=80;
|
||||
registeredObjNameList.push_back("serverTitleLabel" + intToStr(lineIndex));
|
||||
serverTitleLabel.registerGraphicComponent(containerName,"serverTitleLabel" + intToStr(lineIndex));
|
||||
serverTitleLabel.init(i,baseY-lineOffset);
|
||||
serverTitleLabel.setText(masterServerInfo.getServerTitle());
|
||||
|
||||
i+=200;
|
||||
registeredObjNameList.push_back("ipAddressLabel" + intToStr(lineIndex));
|
||||
ipAddressLabel.registerGraphicComponent(containerName,"ipAddressLabel" + intToStr(lineIndex));
|
||||
ipAddressLabel.init(i,baseY-lineOffset);
|
||||
ipAddressLabel.setText(masterServerInfo.getIpAddress());
|
||||
|
||||
|
||||
wrongVersionLabel.init(i,baseY-lineOffset);
|
||||
wrongVersionLabel.setText(lang.get("IncompatibleVersion"));
|
||||
|
||||
//game setup info:
|
||||
i+=120;
|
||||
registeredObjNameList.push_back("techLabel" + intToStr(lineIndex));
|
||||
techLabel.registerGraphicComponent(containerName,"techLabel" + intToStr(lineIndex));
|
||||
techLabel.init(i,baseY-lineOffset);
|
||||
techLabel.setText(masterServerInfo.getTech());
|
||||
|
||||
i+=100;
|
||||
registeredObjNameList.push_back("mapLabel" + intToStr(lineIndex));
|
||||
mapLabel.registerGraphicComponent(containerName,"mapLabel" + intToStr(lineIndex));
|
||||
mapLabel.init(i,baseY-lineOffset);
|
||||
mapLabel.setText(masterServerInfo.getMap());
|
||||
|
||||
i+=100;
|
||||
registeredObjNameList.push_back("tilesetLabel" + intToStr(lineIndex));
|
||||
tilesetLabel.registerGraphicComponent(containerName,"tilesetLabel" + intToStr(lineIndex));
|
||||
tilesetLabel.init(i,baseY-lineOffset);
|
||||
tilesetLabel.setText(masterServerInfo.getTileset());
|
||||
|
||||
i+=100;
|
||||
registeredObjNameList.push_back("activeSlotsLabel" + intToStr(lineIndex));
|
||||
activeSlotsLabel.registerGraphicComponent(containerName,"activeSlotsLabel" + intToStr(lineIndex));
|
||||
activeSlotsLabel.init(i,baseY-lineOffset);
|
||||
activeSlotsLabel.setText(intToStr(masterServerInfo.getActiveSlots())+"/"+intToStr(masterServerInfo.getNetworkSlots())+"/"+intToStr(masterServerInfo.getConnectedClients()));
|
||||
|
||||
i+=50;
|
||||
registeredObjNameList.push_back("externalConnectPort" + intToStr(lineIndex));
|
||||
externalConnectPort.registerGraphicComponent(containerName,"externalConnectPort" + intToStr(lineIndex));
|
||||
externalConnectPort.init(i,baseY-lineOffset);
|
||||
externalConnectPort.setText(intToStr(masterServerInfo.getExternalConnectPort()));
|
||||
|
||||
i+=50;
|
||||
registeredObjNameList.push_back("selectButton" + intToStr(lineIndex));
|
||||
selectButton.registerGraphicComponent(containerName,"selectButton" + intToStr(lineIndex));
|
||||
selectButton.init(i, baseY-lineOffset, 30);
|
||||
selectButton.setText(">");
|
||||
|
||||
//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.setEditable(compatible);
|
||||
|
||||
registeredObjNameList.push_back("gameFull" + intToStr(lineIndex));
|
||||
gameFull.registerGraphicComponent(containerName,"gameFull" + intToStr(lineIndex));
|
||||
gameFull.init(i, baseY-lineOffset);
|
||||
gameFull.setText(lang.get("MGGameSlotsFull"));
|
||||
gameFull.setEnabled(!compatible);
|
||||
gameFull.setEditable(!compatible);
|
||||
|
||||
GraphicComponent::applyAllCustomProperties(containerName);
|
||||
}
|
||||
|
||||
ServerLine::~ServerLine() {
|
||||
GraphicComponent::clearRegisterGraphicComponent(containerName, registeredObjNameList);
|
||||
//delete masterServerInfo;
|
||||
}
|
||||
|
||||
|
@ -168,14 +148,20 @@ void ServerLine::render() {
|
|||
//game info:
|
||||
renderer.renderLabel(&serverTitleLabel);
|
||||
if(!gameFull.getEnabled()){
|
||||
renderer.renderLabel(&ipAddressLabel);
|
||||
if (compatible) {
|
||||
renderer.renderLabel(&ipAddressLabel);
|
||||
|
||||
//game setup info:
|
||||
renderer.renderLabel(&techLabel);
|
||||
renderer.renderLabel(&mapLabel);
|
||||
renderer.renderLabel(&tilesetLabel);
|
||||
renderer.renderLabel(&activeSlotsLabel);
|
||||
renderer.renderLabel(&externalConnectPort);
|
||||
}
|
||||
else {
|
||||
renderer.renderLabel(&wrongVersionLabel);
|
||||
}
|
||||
|
||||
//game setup info:
|
||||
renderer.renderLabel(&techLabel);
|
||||
renderer.renderLabel(&mapLabel);
|
||||
renderer.renderLabel(&tilesetLabel);
|
||||
renderer.renderLabel(&activeSlotsLabel);
|
||||
renderer.renderLabel(&externalConnectPort);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,10 @@ private:
|
|||
MasterServerInfo masterServerInfo;
|
||||
int lineHeight;
|
||||
int baseY;
|
||||
bool compatible;
|
||||
GraphicButton selectButton;
|
||||
GraphicLabel gameFull;
|
||||
GraphicLabel wrongVersionLabel;
|
||||
|
||||
//general info:
|
||||
GraphicLabel glestVersionLabel;
|
||||
|
@ -52,7 +54,6 @@ private:
|
|||
GraphicLabel externalConnectPort;
|
||||
|
||||
const char * containerName;
|
||||
std::vector<std::string> registeredObjNameList;
|
||||
|
||||
public:
|
||||
ServerLine( MasterServerInfo *mServerInfo, int lineIndex, int baseY, int lineHeight, const char *containerName);
|
||||
|
@ -64,7 +65,6 @@ public:
|
|||
void setY(int y);
|
||||
//void setIndex(int value);
|
||||
void render();
|
||||
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
|
Loading…
Reference in New Issue