Merge with develop
--HG-- branch : compatibility-develop
This commit is contained in:
commit
700b75f44a
8 changed files with 130 additions and 299 deletions
|
@ -262,7 +262,10 @@ bool CCmdArgs::parse(const std::vector<std::string> &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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<pathContent.size(); ++i)
|
||||
{
|
||||
if (keepFile(pathContent[i]))
|
||||
{
|
||||
if (gBNPHeader.appendFile(pathContent[i]))
|
||||
{
|
||||
printf("adding %s\n", pathContent[i].c_str());
|
||||
printf("Adding %s\n", pathContent[i].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("error cannot open %s\n", pathContent[i].c_str());
|
||||
printf("Error: cannot open %s\n", pathContent[i].c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
|
||||
#include "stdpch.h"
|
||||
|
||||
#include "user_agent.h"
|
||||
|
||||
//////////////
|
||||
// INCLUDES //
|
||||
|
@ -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
|
||||
|
@ -141,213 +142,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
|
||||
|
@ -373,19 +170,50 @@ 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 <login> <password> [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<uint32>::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 <login> <password> [shardId]
|
||||
vector<string> 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. //
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<std::string> &paths, bool recurse)
|
||||
{
|
||||
// all prefixes for paths
|
||||
|
@ -625,19 +629,19 @@ static void addPaths(IProgressCallback &progress, const std::vector<std::string>
|
|||
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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<CGroupMenu*>(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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue