Changed: Changes from last patch

This commit is contained in:
kervala 2011-03-11 18:40:06 +01:00
parent a221b39585
commit eaf5f1179b
3 changed files with 50 additions and 31 deletions

View file

@ -592,6 +592,21 @@ void CChatGroupWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CC
{ {
gl = gl2; gl = gl2;
// Add dyn chan number before string
ucstring prefix("[" + NLMISC::toString(dynamicChatDbIndex) + "]");
// Find position to put the new string
// After timestamp?
size_t pos = newmsg.find(ucstring("]"));
size_t colonpos = newmsg.find(ucstring(": @{"));
// If no ] found or if found but after the colon (so part of the user chat)
if (pos == ucstring::npos || (colonpos < pos))
{
// No timestamp, so put it right after the color and add a space
pos = newmsg.find(ucstring("}"));;
prefix += " ";
}
newmsg = newmsg.substr(0, pos + 1) + prefix + newmsg.substr(pos + 1);
// Add dynchannel number and optionally name before text if user channel // Add dynchannel number and optionally name before text if user channel
CCDBNodeLeaf* node = CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_DYN_CHANNEL_NAME_IN_CHAT_CB", false); CCDBNodeLeaf* node = CInterfaceManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_DYN_CHANNEL_NAME_IN_CHAT_CB", false);
if (node && node->getValueBool()) if (node && node->getValueBool())
@ -599,16 +614,11 @@ void CChatGroupWindow::displayMessage(const ucstring &msg, NLMISC::CRGBA col, CC
uint32 textId = ChatMngr.getDynamicChannelNameFromDbIndex(dynamicChatDbIndex); uint32 textId = ChatMngr.getDynamicChannelNameFromDbIndex(dynamicChatDbIndex);
ucstring title; ucstring title;
STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title);
if ( ! title.empty()) prefix = title.empty() ? ucstring("") : ucstring(" ") + title;
{ pos = newmsg.find(ucstring("] "));
prefix = " " + title;
}
}
// Put the new prefix in the correct position
size_t pos = newmsg.find(ucstring("] "));
newmsg = newmsg.substr(0, pos) + prefix + newmsg.substr(pos); newmsg = newmsg.substr(0, pos) + prefix + newmsg.substr(pos);
} }
}
break; break;
// NB: the yubo chat cannot be in a user chat // NB: the yubo chat cannot be in a user chat

View file

@ -764,37 +764,39 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c
sint32 dbIndex= ChatMngr.getDynamicChannelDbIndexFromId(dynChatId); sint32 dbIndex= ChatMngr.getDynamicChannelDbIndexFromId(dynChatId);
// if found, display, else discarded // if found, display, else discarded
if(dbIndex >= 0 && dbIndex < CChatGroup::MaxDynChanPerPlayer) if(dbIndex >= 0 && dbIndex < CChatGroup::MaxDynChanPerPlayer)
{
PeopleInterraction.ChatInput.DynamicChat[dbIndex].displayMessage(finalString, col, 2, &windowVisible);
// Add dynchannel info before text so that the chat log will show the correct string.
CCDBNodeLeaf* node = pIM->getDbProp("UI:SAVE:CHAT:SHOW_DYN_CHANNEL_NAME_IN_CHAT_CB", false);
if (pIM->getLogState())
{ {
// Add dyn chan number before string // Add dyn chan number before string
ucstring prefix = "[" + NLMISC::toString(dbIndex) + "]"; ucstring prefix("[" + NLMISC::toString(dbIndex) + "]");
// Find position to put the new string // Find position to put the new string
// After timestamp? // After timestamp?
size_t pos = finalString.find(ucstring("]")); size_t pos = finalString.find(ucstring("]"));
if (pos == ucstring::npos) size_t colonpos = finalString.find(ucstring(": @{"));
// If no ] found or if found but after the colon (so part of the user chat)
if (pos == ucstring::npos || (colonpos < pos))
{ {
// No timestamp, so put it right after the color and add a space // No timestamp, so put it right after the color and add a space
pos = finalString.find(ucstring("}")); pos = finalString.find(ucstring("}"));;
prefix += " "; prefix += " ";
} }
finalString = finalString.substr(0, pos + 1) + prefix + finalString.substr(pos + 1); finalString = finalString.substr(0, pos + 1) + prefix + finalString.substr(pos + 1);
PeopleInterraction.ChatInput.DynamicChat[dbIndex].displayMessage(finalString, col, 2, &windowVisible);
// Add optionally dynchannel name before text so that the chat log if (node && node->getValueBool())
// will show the correct string if enabled.
CCDBNodeLeaf* node = pIM->getDbProp("UI:SAVE:CHAT:SHOW_DYN_CHANNEL_NAME_IN_CHAT_CB", false);
if (node && pIM->getLogState() && node->getValueBool())
{ {
uint32 textId = ChatMngr.getDynamicChannelNameFromDbIndex(dbIndex); uint32 textId = ChatMngr.getDynamicChannelNameFromDbIndex(dbIndex);
ucstring title; ucstring title;
STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title); STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title);
if ( ! title.empty()) prefix = title.empty() ? ucstring("") : ucstring(" ") + title;
{ pos = finalString.find(ucstring("] "));
prefix = " " + title;
}
// Put the new prefix in the correct position
size_t pos = finalString.find(ucstring("] "));
finalString = finalString.substr(0, pos) + prefix + finalString.substr(pos); finalString = finalString.substr(0, pos) + prefix + finalString.substr(pos);
} }
} }
}
else else
{ {
nlwarning("Dynamic chat %s not found for message: %s", dynChatId.toString().c_str(), finalString.toString().c_str()); nlwarning("Dynamic chat %s not found for message: %s", dynChatId.toString().c_str(), finalString.toString().c_str());

View file

@ -1387,6 +1387,13 @@ const ucchar * CStringManagerClient::getSpecialWord(const std::string &label, bo
return emptyString.c_str(); return emptyString.c_str();
} }
if (label[0] == '#')
{
static ucstring rawString;
rawString = label.substr(1, label.size()-1);
return rawString.c_str();
}
// avoid case problems // avoid case problems
static std::string lwrLabel; static std::string lwrLabel;
lwrLabel = label; lwrLabel = label;