Include chat message channel/type to chatlog file

--HG--
branch : issue-221
This commit is contained in:
Nimetu 2015-01-15 20:08:28 +02:00
parent b26e7f4c1b
commit 53f6adb041
6 changed files with 30 additions and 9 deletions

View file

@ -1204,7 +1204,7 @@ class CHandlerTell : public IActionHandler
ucstring s = CI18N::get("youTellPlayer");
strFindReplace(s, "%name", receiver);
strFindReplace(finalMsg, CI18N::get("youTell"), s);
CInterfaceManager::getInstance()->log(finalMsg);
CInterfaceManager::getInstance()->log(finalMsg, CChatGroup::groupTypeToString(CChatGroup::tell));
}
};
REGISTER_ACTION_HANDLER( CHandlerTell, "tell");

View file

@ -483,7 +483,7 @@ void CChatWindow::displayLocalPlayerTell(const ucstring &receiver, const ucstrin
strFindReplace(s, "%name", receiver);
strFindReplace(finalMsg, CI18N::get("youTell"), s);
displayMessage(finalMsg, prop.getRGBA(), CChatGroup::tell, 0, numBlinks);
CInterfaceManager::getInstance()->log(finalMsg);
CInterfaceManager::getInstance()->log(finalMsg, CChatGroup::groupTypeToString(CChatGroup::tell));
}
void CChatWindow::encodeColorTag(const NLMISC::CRGBA &color, ucstring &text, bool append)

View file

@ -2684,7 +2684,7 @@ bool CInterfaceManager::deletePlayerKeys (const std::string &playerFileIdent)
}
// ***************************************************************************
void CInterfaceManager::log(const ucstring &str)
void CInterfaceManager::log(const ucstring &str, const std::string &cat)
{
if (_LogState)
{
@ -2693,7 +2693,7 @@ void CInterfaceManager::log(const ucstring &str)
FILE *f = fopen(fileName.c_str(), "at");
if (f != NULL)
{
const string finalString = string(NLMISC::IDisplayer::dateToHumanString()) + " * " + str.toUtf8();
const string finalString = string(NLMISC::IDisplayer::dateToHumanString()) + " (" + NLMISC::toUpper(cat) + ") * " + str.toUtf8();
fprintf(f, "%s\n", finalString.c_str());
}
fclose(f);

View file

@ -218,7 +218,7 @@ public:
// Log system (all chat/tell
void setLogState(bool state) { _LogState = state; }
bool getLogState() const { return _LogState; }
void log(const ucstring &str);
void log(const ucstring &str, const std::string &cat = "");
/// Text from here and from server

View file

@ -478,7 +478,7 @@ void CPeopleList::displayLocalPlayerTell(const ucstring &receiver, uint index, c
strFindReplace(s, "%name", receiver);
strFindReplace(finalMsg, CI18N::get("youTell"), s);
gl->addChild(getChatTextMngr().createMsgText(finalMsg, prop.getRGBA()));
CInterfaceManager::getInstance()->log(finalMsg);
CInterfaceManager::getInstance()->log(finalMsg, CChatGroup::groupTypeToString(CChatGroup::tell));
// if the group is closed, make it blink
if (!gc->isOpen())
@ -946,7 +946,7 @@ class CHandlerContactEntry : public IActionHandler
ucstring s = CI18N::get("youTellPlayer");
strFindReplace(s, "%name", pWin->getFreeTellerName(str));
strFindReplace(final, CI18N::get("youTell"), s);
CInterfaceManager::getInstance()->log(final);
CInterfaceManager::getInstance()->log(final, CChatGroup::groupTypeToString(CChatGroup::tell));
}
}
}

View file

@ -879,7 +879,28 @@ void CInterfaceChatDisplayer::displayChat(TDataSetIndex compressedSenderIndex, c
}
// Log
pIM->log (finalString);
string channel;
if (mode == CChatGroup::dyn_chat)
{
sint32 dbIndex = ChatMngr.getDynamicChannelDbIndexFromId(dynChatId);
clamp(dbIndex, (sint32)0 , (sint32)CChatGroup::MaxDynChanPerPlayer);
channel = "dyn" + toString(dbIndex);
}
else
{
channel = CChatGroup::groupTypeToString(mode);
if (channel.empty())
{
channel = "#" + toString((uint32)mode);
}
}
if (!stringCategory.empty() && NLMISC::toUpper(stringCategory) != "SYS")
{
channel = channel + "/" + stringCategory;
}
pIM->log (finalString, channel);
}
@ -911,7 +932,7 @@ void CInterfaceChatDisplayer::displayTell(/*TDataSetIndex senderIndex, */const u
colorizeSender(finalString, senderPart, prop.getRGBA());
PeopleInterraction.ChatInput.Tell.displayTellMessage(/*senderIndex, */finalString, goodSenderName, prop.getRGBA(), 2, &windowVisible);
CInterfaceManager::getInstance()->log(finalString);
CInterfaceManager::getInstance()->log(finalString, CChatGroup::groupTypeToString(CChatGroup::tell));
// Open the free teller window
CChatGroupWindow *pCGW = PeopleInterraction.getChatGroupWindow();