From 0505395fd1970c170cf621a072cf20ab378cb78c Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 23 Jan 2016 18:48:25 +0100 Subject: [PATCH 01/10] Fixed: toLower shouldn't transform a eszett to s --HG-- branch : develop --- code/nel/src/misc/unicode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/src/misc/unicode.cpp b/code/nel/src/misc/unicode.cpp index 00bf6a226..47a4cdfde 100644 --- a/code/nel/src/misc/unicode.cpp +++ b/code/nel/src/misc/unicode.cpp @@ -84,7 +84,7 @@ static const ucchar UnicodeUpperToLower[]= 0x00DC, 0x00FC, // LATIN CAPITAL LETTER U WITH DIAERESIS 0x00DD, 0x00FD, // LATIN CAPITAL LETTER Y WITH ACUTE 0x00DE, 0x00FE, // LATIN CAPITAL LETTER THORN - 0x00DF, 0x0073 , // # LATIN SMALL LETTER SHARP S + 0x00DF, 0x00DF , // # LATIN SMALL LETTER SHARP S 0x0100, 0x0101, // LATIN CAPITAL LETTER A WITH MACRON 0x0102, 0x0103, // LATIN CAPITAL LETTER A WITH BREVE 0x0104, 0x0105, // LATIN CAPITAL LETTER A WITH OGONEK From 222544f9026cf934d13f842b1843d6c5a77e3423 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 23 Jan 2016 18:49:10 +0100 Subject: [PATCH 02/10] Fixed: Display an error if adding more than once the same filename in BNP --HG-- branch : develop --- code/nel/tools/misc/bnp_make/main.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/code/nel/tools/misc/bnp_make/main.cpp b/code/nel/tools/misc/bnp_make/main.cpp index edab782b0..98ddf84d6 100644 --- a/code/nel/tools/misc/bnp_make/main.cpp +++ b/code/nel/tools/misc/bnp_make/main.cpp @@ -92,22 +92,32 @@ void packSubRecurse(const std::string &srcDirectory) printf ("Treating directory: %s\n", srcDirectory.c_str()); CPath::getPathContent(srcDirectory, true, false, true, pathContent); - // TODO: remove duplicate files + if (pathContent.empty()) return; // Sort filename sort (pathContent.begin(), pathContent.end(), i_comp); + // check for files with same name + for(uint i = 1, len = pathContent.size(); i < len; ++i) + { + if (toLower(CFile::getFilename(pathContent[i-1])) == toLower(CFile::getFilename(pathContent[i]))) + { + nlerror("File %s is not unique in BNP!", CFile::getFilename(pathContent[i]).c_str()); + return; + } + } + for (uint i=0; i Date: Sat, 23 Jan 2016 18:50:17 +0100 Subject: [PATCH 03/10] Changed: Make absolute program path (useful if launched from current directory under Linux) Changed: Set process name for logs --HG-- branch : develop --- code/nel/src/misc/cmd_args.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/nel/src/misc/cmd_args.cpp b/code/nel/src/misc/cmd_args.cpp index 9140778b8..13d08428b 100644 --- a/code/nel/src/misc/cmd_args.cpp +++ b/code/nel/src/misc/cmd_args.cpp @@ -262,7 +262,10 @@ bool CCmdArgs::parse(const std::vector &argv) // first argument is always the program name _ProgramName = CFile::getFilename(argv.front()); - _ProgramPath = CPath::standardizePath(CFile::getPath(argv.front())); + _ProgramPath = CPath::makePathAbsolute(CPath::standardizePath(CFile::getPath(argv.front())), CPath::getCurrentPath(), true); + + // set process name for logs + CLog::setProcessName(_ProgramName); // arguments count uint argc = argv.size(); From ded0b3a2529bd7033527f6f70152bcd40c8df461 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 23 Jan 2016 18:55:56 +0100 Subject: [PATCH 04/10] Changed: Remove commented old crash report code --HG-- branch : develop --- code/ryzom/client/src/client.cpp | 210 +------------------------------ 1 file changed, 3 insertions(+), 207 deletions(-) diff --git a/code/ryzom/client/src/client.cpp b/code/ryzom/client/src/client.cpp index 61b30b4c9..8f4429f35 100644 --- a/code/ryzom/client/src/client.cpp +++ b/code/ryzom/client/src/client.cpp @@ -17,7 +17,7 @@ #include "stdpch.h" - +#include "user_agent.h" ////////////// // INCLUDES // @@ -141,213 +141,9 @@ INT_PTR CALLBACK MyDialogProc( HWND SlashScreen = NULL; HINSTANCE HInstance; -/* -static bool connect() -{ - string server = "crashcounter.nevrax.com"; - if(CrashCounterSock.connected()) - return true; - - try - { - // add the default port if no port in the cfg - if(server.find(':') == string::npos) - server+=":80"; - CrashCounterSock.connect(CInetAddress(server)); - if(!CrashCounterSock.connected()) - { - nlwarning("Can't connect to web server '%s'", server.c_str()); - goto end; - } - } - catch(const Exception &e) - { - nlwarning("Can't connect to web server '%s': %s", server.c_str(), e.what()); - goto end; - } - - return true; - -end: - - if(CrashCounterSock.connected()) - CrashCounterSock.close (); - - return false; -} - -// *************************************************************************** -static bool send(const string &url) -{ - if (CrashCounterSock.connected()) - { - string buffer = "GET " + url + - " HTTP/1.0\n" - "Host: crashcounter.nevrax.com\n" - "User-agent: Ryzom\n" - "\n"; - uint32 size = (uint32)buffer.size(); - if(!url.empty()) - { - if(CrashCounterSock.send((uint8 *)buffer.c_str(), size, false) != CSock::Ok) - { - nlwarning ("Can't send data to the server"); - return false; - } - } - return true; - } - return false; -} - -// *************************************************************************** -static bool receive(string &res) -{ - if (CrashCounterSock.connected()) - { - uint32 size; - res = ""; - - uint8 buf[1024]; - - for(;;) - { - size = 1023; - - if (CrashCounterSock.receive((uint8*)buf, size, false) == CSock::Ok) - { - buf[1023] = '\0'; - res += (char*)buf; - //nlinfo("block received '%s'", buf); - } - else - { - buf[size] = '\0'; - res += (char*)buf; - //nlwarning ("server connection closed"); - break; - } - } - //nlinfo("all received '%s'", res.c_str()); - return true; - } - else - return false; -} - -string CrashFeedback = "CRASHED"; - -INT_PTR CALLBACK ReportDialogProc( - HWND hwndDlg, // handle to dialog box - UINT uMsg, // message - WPARAM wParam, // first message parameter - LPARAM lParam // second message parameter -) -{ - switch (uMsg) - { - case WM_INITDIALOG: - { - RECT rect; - RECT rectDesktop; - GetWindowRect (hwndDlg, &rect); - GetWindowRect (GetDesktopWindow (), &rectDesktop); - SetWindowPos (hwndDlg, HWND_TOPMOST, (rectDesktop.right-rectDesktop.left-rect.right+rect.left)/2, (rectDesktop.bottom-rectDesktop.top-rect.bottom+rect.top)/2, 0, 0, SWP_NOSIZE); - } - break; - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case FROZEN: - CrashFeedback = "USER_FROZEN"; - EndDialog (hwndDlg, IDOK); - break; - case REBOOTED: - CrashFeedback = "USER_REBOOTED"; - EndDialog (hwndDlg, IDOK); - break; - case WINDOWED: - CrashFeedback = "USER_WINDOWED"; - EndDialog (hwndDlg, IDOK); - break; - case NO_WINDOW: - CrashFeedback = "USER_NO_WINDOW"; - EndDialog (hwndDlg, IDOK); - break; - case KILLED: - CrashFeedback = "USER_KILLED"; - EndDialog (hwndDlg, IDOK); - break; - case NOT_CRASHED: - CrashFeedback = "USER_NOT_CRASHED"; - EndDialog (hwndDlg, IDOK); - break; - case CRASHED: - CrashFeedback = "CRASHED"; - EndDialog (hwndDlg, IDOK); - break; - } - break; - } - return FALSE; -} - -void initCrashReport () -{ - // - bool crashed = CFile::isExists (getLogDirectory() + "ryzom_started"); - bool during_release = false; - bool exception_catched = false; - bool breakpointed = false; - bool dumped = false; - bool report_failed = false; - bool report_refused = false; - bool report_sent = false; - if (crashed && CFile::isExists (getLogDirectory() + "during_release")) - during_release = CFile::getFileModificationDate (getLogDirectory() + "ryzom_started") <= CFile::getFileModificationDate (getLogDirectory() + "during_release"); - if (crashed && CFile::isExists (getLogDirectory() + "exception_catched")) - exception_catched = CFile::getFileModificationDate (getLogDirectory() + "ryzom_started") <= CFile::getFileModificationDate (getLogDirectory() + "exception_catched"); - if (crashed && CFile::isExists (getLogDirectory() + "breakpointed")) - breakpointed = CFile::getFileModificationDate ("ryzom_started") <= CFile::getFileModificationDate (getLogDirectory() + "breakpointed"); - if (crashed && CFile::isExists (getLogDirectory() + "nel_debug.dmp")) - dumped = CFile::getFileModificationDate (getLogDirectory() + "ryzom_started") <= CFile::getFileModificationDate (getLogDirectory() + "nel_debug.dmp"); - if (crashed && CFile::isExists (getLogDirectory() + "report_failed")) - report_failed = CFile::getFileModificationDate (getLogDirectory() + "ryzom_started") <= CFile::getFileModificationDate (getLogDirectory() + "report_failed"); - if (crashed && CFile::isExists (getLogDirectory() + "report_refused")) - report_refused = CFile::getFileModificationDate (getLogDirectory() + "ryzom_started") <= CFile::getFileModificationDate (getLogDirectory() + "report_refused"); - if (crashed && CFile::isExists (getLogDirectory() + "report_sent")) - report_sent = CFile::getFileModificationDate (getLogDirectory() + "ryzom_started") <= CFile::getFileModificationDate (getLogDirectory() + "report_sent"); - CFile::createEmptyFile(getLogDirectory() + "ryzom_started"); - connect(); - if (report_sent) - send("/?crashtype=REPORT_SENT"); - else if (report_refused) - send("/?crashtype=REPORT_REFUSED"); - else if (report_failed) - send("/?crashtype=REPORT_FAILED"); - else if (dumped) - send("/?crashtype=DUMPED"); - else if (breakpointed) - send("/?crashtype=BREAKPOINTED"); - else if (exception_catched) - send("/?crashtype=EXCEPTION_CATCHED"); - else if (during_release) - send("/?crashtype=DURING_RELEASE"); - else if (crashed) - { - //DialogBox (HInstance, MAKEINTRESOURCE(IDD_CRASH_INFORMATION), NULL, ReportDialogProc); - //send("/?crashtype="+CrashFeedback); - send("/?crashtype=CRASHED"); - } - else - send("/?crashtype=NOT_CRASHED"); - string res; - receive(res); -#ifdef TEST_CRASH_COUNTER - MessageBox (NULL, res.c_str(), res.c_str(), MB_OK); -#endif // TEST_CRASH_COUNTER -}*/ +// make it global if other classes/functions want to access to it +NLMISC::CCmdArgs Args; int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR cmdline, int /* nCmdShow */) #else From 895df72e3f32ececbc0d9a1a1e3a7d2ebccca21b Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 23 Jan 2016 18:57:32 +0100 Subject: [PATCH 05/10] Changed: Use CCmdArgs to parse client command-line --HG-- branch : develop --- code/ryzom/client/src/client.cpp | 92 +++++++++++--------------------- 1 file changed, 32 insertions(+), 60 deletions(-) diff --git a/code/ryzom/client/src/client.cpp b/code/ryzom/client/src/client.cpp index 8f4429f35..61a157262 100644 --- a/code/ryzom/client/src/client.cpp +++ b/code/ryzom/client/src/client.cpp @@ -41,6 +41,7 @@ #include "nel/misc/debug.h" #include "nel/misc/command.h" #include "nel/net/tcp_sock.h" +#include "nel/misc/cmd_args.h" //#define TEST_CRASH_COUNTER #ifdef TEST_CRASH_COUNTER @@ -169,6 +170,36 @@ int main(int argc, char **argv) INelContext::getInstance().getWarningLog()->removeDisplayer("DEFAULT_SD"); #endif // NL_DEBUG + Args.setVersion(getDisplayVersion()); + Args.setDescription("Ryzom client"); + Args.addArg("c", "config", "id", "Use this configuration to determine what directory to use by default"); + Args.addAdditionalArg("login", "Login to use", true, false); + Args.addAdditionalArg("password", "Password to use", true, false); + Args.addAdditionalArg("shard_id", "Shard ID to use", true, false); + +#ifdef NL_OS_WINDOWS + if (!Args.parse(cmdline)) return 1; +#else + if (!Args.parse(argc, argv)) return 1; +#endif + + // extract the 2 or 3 first param (argv[1], argv[2] and argv[3]) it must be [shardId] + + // no shard id in ring mode + std::string sLoginShardId; + + if (Args.haveAdditionalArg("login") && Args.haveAdditionalArg("password")) + { + LoginLogin = Args.getAdditionalArg("login").front(); + LoginPassword = Args.getAdditionalArg("password").front(); + + if (Args.haveAdditionalArg("shard_id")) + sLoginShardId = Args.getAdditionalArg("shard_id").front(); + } + + if (sLoginShardId.empty() || !fromString(sLoginShardId, LoginShardId)) + LoginShardId = std::numeric_limits::max(); + // if client_default.cfg is not in current directory, use application default directory if (!CFile::isExists("client_default.cfg")) { @@ -179,9 +210,6 @@ int main(int argc, char **argv) CPath::setCurrentPath(currentPath); } - // temporary buffer to store Ryzom full path - char filename[1024]; - #ifdef NL_OS_MAC struct rlimit rlp, rlp2, rlp3; @@ -201,24 +229,6 @@ int main(int argc, char **argv) #if defined(NL_OS_WINDOWS) - /* Windows bug: When the Window IconeMode is in "ThumbNails" mode, the current path is set to - "document settings"..... Force the path to be the path of the exe - */ - { -#ifdef FINAL_VERSION - char str[4096]; - uint len= GetModuleFileName(NULL, str, 4096); - if(len && len<4096) - { - str[len]= 0; - string path= CFile::getPath(str); -// if(!path.empty()) -// CPath::setCurrentPath(path.c_str()); - } -#endif // FINAL_VERSION - } - - string sCmdLine = cmdline; #if FINAL_VERSION //if (sCmdLine.find("/multi") == string::npos) // If '/multi' not found //{ @@ -267,26 +277,6 @@ int main(int argc, char **argv) pump (); - // extract the 2 or 3 first param (argv[1], argv[2] and argv[3]) it must be [shardId] - vector res; - explode(sCmdLine, std::string(" "), res, true); - - // no shard id in ring mode - if (res.size() >= 3) - { - LoginLogin = res[0]; - LoginPassword = res[1]; - if (!fromString(res[2], LoginShardId)) LoginShardId = -1; - } - else if (res.size() >= 2) - { - LoginLogin = res[0]; - LoginPassword = res[1]; - LoginShardId = -1; - } - - GetModuleFileName(GetModuleHandle(NULL), filename, 1024); - // Delete the .bat file because it s not useful anymore if (NLMISC::CFile::fileExists("updt_nl.bat")) NLMISC::CFile::deleteFile("updt_nl.bat"); @@ -317,24 +307,6 @@ int main(int argc, char **argv) // TODO for Linux : splashscreen - if (argc >= 4) - { - LoginLogin = argv[1]; - LoginPassword = argv[2]; - if (!fromString(argv[3], LoginShardId)) LoginShardId = -1; - } - else if (argc >= 3) - { - LoginLogin = argv[1]; - LoginPassword = argv[2]; - LoginShardId = -1; - } - - strcpy(filename, argv[0]); - - // set process name for logs - CLog::setProcessName(filename); - // Delete the .sh file because it s not useful anymore if (NLMISC::CFile::fileExists("updt_nl.sh")) NLMISC::CFile::deleteFile("updt_nl.sh"); @@ -342,7 +314,7 @@ int main(int argc, char **argv) // initialize patch manager and set the ryzom full path, before it's used CPatchManager *pPM = CPatchManager::getInstance(); - pPM->setRyzomFilename(filename); + pPM->setRyzomFilename(Args.getProgramPath() + Args.getProgramName()); ///////////////////////////////// // Initialize the application. // From 61fb66d3afbcfcad56839bf26e4688b76b93e797 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 23 Jan 2016 18:58:58 +0100 Subject: [PATCH 06/10] Changed: Support -config/-c parameter passed by Ryzom Installer --HG-- branch : develop --- code/ryzom/client/src/client.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/ryzom/client/src/client.cpp b/code/ryzom/client/src/client.cpp index 61a157262..d357f65ca 100644 --- a/code/ryzom/client/src/client.cpp +++ b/code/ryzom/client/src/client.cpp @@ -205,6 +205,10 @@ int main(int argc, char **argv) { std::string currentPath = CPath::getApplicationDirectory("Ryzom"); + // append config ID to directory + if (Args.haveArg("c")) + currentPath = NLMISC::CPath::standardizePath(currentPath) + Args.getArg("c").front(); + if (!CFile::isExists(currentPath)) CFile::createDirectory(currentPath); CPath::setCurrentPath(currentPath); From dcd38de3f2646d78b2360a09bed1762ae3beb37b Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 23 Jan 2016 18:59:20 +0100 Subject: [PATCH 07/10] Changed: Minor changes --HG-- branch : develop --- code/ryzom/client/src/client.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/code/ryzom/client/src/client.cpp b/code/ryzom/client/src/client.cpp index d357f65ca..27976895d 100644 --- a/code/ryzom/client/src/client.cpp +++ b/code/ryzom/client/src/client.cpp @@ -234,13 +234,6 @@ int main(int argc, char **argv) #if defined(NL_OS_WINDOWS) #if FINAL_VERSION - //if (sCmdLine.find("/multi") == string::npos) // If '/multi' not found - //{ - // HANDLE mutex = CreateMutex (NULL, false, "RyzomClient"); - // if (mutex && GetLastError() == ERROR_ALREADY_EXISTS) - // exit (0); - //} - //initCrashReport (); #endif // FINAL_VERSION @@ -308,7 +301,6 @@ int main(int argc, char **argv) } #else - // TODO for Linux : splashscreen // Delete the .sh file because it s not useful anymore From 482b1ba73a405d0003af3ccab1275c366539953f Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 23 Jan 2016 19:04:07 +0100 Subject: [PATCH 08/10] Fixed: Display wrong commands with UTF-8 characters --HG-- branch : develop --- code/ryzom/client/src/client_chat_manager.cpp | 2 +- code/ryzom/client/src/interface_v3/chat_window.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/ryzom/client/src/client_chat_manager.cpp b/code/ryzom/client/src/client_chat_manager.cpp index 1d0fb3f81..1bf6227d9 100644 --- a/code/ryzom/client/src/client_chat_manager.cpp +++ b/code/ryzom/client/src/client_chat_manager.cpp @@ -1370,7 +1370,7 @@ class CHandlerTalk : public IActionHandler else { CInterfaceManager *im = CInterfaceManager::getInstance(); - im->displaySystemInfo (ucstring(cmd+": ")+CI18N::get ("uiCommandNotExists")); + im->displaySystemInfo (ucstring::makeFromUtf8(cmd) + ": " + CI18N::get ("uiCommandNotExists")); } } else diff --git a/code/ryzom/client/src/interface_v3/chat_window.cpp b/code/ryzom/client/src/interface_v3/chat_window.cpp index af0942bc9..207f09aba 100644 --- a/code/ryzom/client/src/interface_v3/chat_window.cpp +++ b/code/ryzom/client/src/interface_v3/chat_window.cpp @@ -1308,7 +1308,7 @@ public: else { CInterfaceManager *im = CInterfaceManager::getInstance(); - im->displaySystemInfo (ucstring(cmd+": ")+CI18N::get ("uiCommandNotExists")); + im->displaySystemInfo (ucstring::makeFromUtf8(cmd) + ": " + CI18N::get ("uiCommandNotExists")); } } else From ba7b4094ef3200f548d4af337125fa291cee62e0 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 23 Jan 2016 19:04:52 +0100 Subject: [PATCH 09/10] Changed: Use CCmdArgs to get program path and search data there --HG-- branch : develop --- code/ryzom/client/src/init.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 4f9f2aa09..94376cd3f 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -34,6 +34,7 @@ #include "nel/misc/system_info.h" #include "nel/misc/block_memory.h" #include "nel/misc/system_utils.h" +#include "nel/misc/cmd_args.h" // 3D Interface. #include "nel/3d/bloom_effect.h" #include "nel/3d/u_driver.h" @@ -616,6 +617,9 @@ void initStereoDisplayDevice() IStereoDisplay::releaseUnusedLibraries(); } +// we want to get executable directory +extern NLMISC::CCmdArgs Args; + static void addPaths(IProgressCallback &progress, const std::vector &paths, bool recurse) { // all prefixes for paths @@ -625,19 +629,19 @@ static void addPaths(IProgressCallback &progress, const std::vector directoryPrefixes.push_back(""); #if defined(NL_OS_WINDOWS) - char path[MAX_PATH]; - GetModuleFileNameA(GetModuleHandleA(NULL), path, MAX_PATH); - // check in same directory as executable - directoryPrefixes.push_back(CPath::standardizePath(CFile::getPath(path))); + directoryPrefixes.push_back(Args.getProgramPath()); #elif defined(NL_OS_MAC) // check in bundle (Installer) - directoryPrefixes.push_back(CPath::standardizePath(getAppBundlePath() + "/Contents/Resources")); + directoryPrefixes.push_back(getAppBundlePath() + "/Contents/Resources/"); // check in same directory as bundle (Steam) - directoryPrefixes.push_back(CPath::standardizePath(getAppBundlePath() + "/..")); + directoryPrefixes.push_back(CPath::makePathAbsolute(getAppBundlePath() + "/..", ".", true)); #elif defined(NL_OS_UNIX) - // TODO: check in same directory as executable + // check in same directory as executable + directoryPrefixes.push_back(Args.getProgramPath()); + + // check in installed directory if (CFile::isDirectory(getRyzomSharePrefix())) directoryPrefixes.push_back(CPath::standardizePath(getRyzomSharePrefix())); #endif From be92ac8e60a2e90e1417a95e2deaac2bb4097c92 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 23 Jan 2016 19:06:28 +0100 Subject: [PATCH 10/10] Fixed: Display of emotes using the same character case as in translations and showing corresponding command to type --HG-- branch : develop --- .../src/interface_v3/interface_manager.cpp | 70 ++++++++++++++++--- 1 file changed, 60 insertions(+), 10 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 44aeaa7d6..08137e140 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -2904,6 +2904,32 @@ struct CEmoteEntry } }; +static bool translateEmote(const std::string &id, ucstring &translatedName, std::string &commandName, std::string &commandNameAlt) +{ + if (CI18N::hasTranslation(id)) + { + translatedName = CI18N::get(id); + + // convert command to utf8 since emote translation can have strange chars + commandName = toLower(translatedName).toUtf8(); + + // replace all spaces by _ + while (strFindReplace(commandName, " ", "_")); + + // TODO: remove accents + commandNameAlt = commandName; + + if (commandNameAlt == commandName) commandNameAlt.clear(); + + return true; + } + + translatedName = id; + commandName = id; + + return false; +} + // *************************************************************************** void CInterfaceManager::initEmotes() { @@ -2979,11 +3005,16 @@ void CInterfaceManager::initEmotes() nbToken++; CGroupMenu *pRootMenu = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:user_chat_emote_menu")); + pRootMenu->setProperty("case_mode", "0"); nlassert(pRootMenu); CGroupSubMenu *pMenu = pRootMenu->getRootMenu(); nlassert(pMenu); + ucstring sTranslatedName; + std::string sCommandName; + std::string sCommandNameAlt; + // Add to the game context menu // ---------------------------- for (i = 0; i < nbToken; ++i) @@ -3021,8 +3052,10 @@ void CInterfaceManager::initEmotes() } else { + translateEmote(sTmp, sTranslatedName, sCommandName, sCommandNameAlt); + // Create a line - pMenu->addLine ("/" + CI18N::get(sTmp), "emote", + pMenu->addLine (sTranslatedName + " (/" + ucstring::makeFromUtf8(sCommandName) + ")", "emote", "nb="+toString(nEmoteNb)+"|behav="+toString(nBehav), sTmp); } } @@ -3035,25 +3068,42 @@ void CInterfaceManager::initEmotes() } } + if (sTranslatedName.empty()) + translateEmote(sName, sTranslatedName, sCommandName, sCommandNameAlt); + // Create new command // ------------------ - if (CI18N::hasTranslation(sName)) + if (!sTranslatedName.empty()) { - CGroupSubMenu *pMenu = pRootMenu->getRootMenu(); - - // convert command to utf8 since emote translation can have strange chars - string cmdName = (toLower(CI18N::get(sName))).toUtf8(); - if(ICommand::exists(cmdName)) + if(ICommand::exists(sCommandName)) { - nlwarning("Translation for emote %s already exist: '%s' exist twice", sName.c_str(), cmdName.c_str()); + nlwarning("Translation for emote %s already exist: '%s' exist twice", sName.c_str(), sCommandName.c_str()); } else { - CEmoteCmd *pNewCmd = new CEmoteCmd(cmdName.c_str(), "", ""); + CEmoteCmd *pNewCmd = new CEmoteCmd(sCommandName.c_str(), "", ""); pNewCmd->EmoteNb = nEmoteNb; pNewCmd->Behaviour = nBehav; _EmoteCmds.push_back(pNewCmd); + // add alternative command if defined + if (!sCommandNameAlt.empty()) + { + if(ICommand::exists(sCommandNameAlt)) + { + nlwarning("Translation for emote %s already exist: '%s' exist twice", sName.c_str(), sCommandName.c_str()); + } + else + { + CEmoteCmd *pNewCmd = new CEmoteCmd(sCommandNameAlt.c_str(), "", ""); + pNewCmd->EmoteNb = nEmoteNb; + pNewCmd->Behaviour = nBehav; + _EmoteCmds.push_back(pNewCmd); + } + } + + CGroupSubMenu *pMenu = pRootMenu->getRootMenu(); + // Quick-Emote too ? for (i = 0; i< pMenu->getNumLine (); i++) { @@ -3061,7 +3111,7 @@ void CInterfaceManager::initEmotes() { // Yeah that's a quick emote too; set command pMenu->addLineAtIndex (i, - "@{FFFF}/" + toLower(CI18N::get(sName)), + "@{FFFF}/" + ucstring::makeFromUtf8(sCommandName), "emote", "nb="+toString(nEmoteNb)+"|behav="+toString(nBehav), "", "", "", false, false, true);