From b9a761925b410ea3024796d906bf07925a8cc312 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 23 Jan 2016 19:07:13 +0100 Subject: [PATCH] Merge with develop --- code/nel/src/misc/cmd_args.cpp | 5 +- code/nel/src/misc/unicode.cpp | 2 +- code/nel/tools/misc/bnp_make/main.cpp | 16 +- code/ryzom/client/src/client.cpp | 314 +++--------------- code/ryzom/client/src/client_chat_manager.cpp | 2 +- code/ryzom/client/src/init.cpp | 18 +- .../client/src/interface_v3/chat_window.cpp | 2 +- .../src/interface_v3/interface_manager.cpp | 70 +++- 8 files changed, 130 insertions(+), 299 deletions(-) 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(); 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 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; iremoveDisplayer("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")) { 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); } - // temporary buffer to store Ryzom full path - char filename[1024]; - #ifdef NL_OS_MAC struct rlimit rlp, rlp2, rlp3; @@ -405,32 +233,7 @@ 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 - //{ - // HANDLE mutex = CreateMutex (NULL, false, "RyzomClient"); - // if (mutex && GetLastError() == ERROR_ALREADY_EXISTS) - // exit (0); - //} - //initCrashReport (); #endif // FINAL_VERSION @@ -471,26 +274,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"); @@ -518,27 +301,8 @@ int main(int argc, char **argv) } #else - // 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"); @@ -546,7 +310,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. // 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/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 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 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);