develop
kaetemi 4 years ago
parent 72d9f8ea4f
commit d201b8a392

@ -15,7 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#if 0
#ifndef CL_CANDIDATE_H
#define CL_CANDIDATE_H
@ -39,3 +39,4 @@ struct Candidate
#endif // CL_CANDIDATE_H
#endif

@ -809,9 +809,9 @@ bool CCharacterCL::build(const CEntitySheet *sheet) // virtual
if (Type == Fauna)
{
// Get the fauna name in the sheet
const ucstring creatureName(STRING_MANAGER::CStringManagerClient::getCreatureLocalizedName(_Sheet->Id));
if (creatureName.find(ucstring("<NotExist:")) != 0)
_EntityName = creatureName.toUtf8();
const char *creatureName = STRING_MANAGER::CStringManagerClient::getCreatureLocalizedName(_Sheet->Id);
if (!FINAL_VERSION || !NLMISC::startsWith(creatureName, "<NotExist:"))
_EntityName = creatureName;
}
else
{
@ -7589,7 +7589,7 @@ void CCharacterCL::displayName()
//---------------------------------------------------
void CCharacterCL::drawName(const NLMISC::CMatrix &mat) // virtual
{
const ucstring &ucname = getEntityName();
const string &ucname = getEntityName();
if(!getEntityName().empty())
{
// If there is no extended name, just display the name
@ -7616,8 +7616,8 @@ void CCharacterCL::drawName(const NLMISC::CMatrix &mat) // virtual
{
if(_Sheet != 0)
{
const ucstring name(STRING_MANAGER::CStringManagerClient::getCreatureLocalizedName(_Sheet->Id));
if (name.find(ucstring("<NotExist:")) != 0)
const char *name = STRING_MANAGER::CStringManagerClient::getCreatureLocalizedName(_Sheet->Id);
if (!FINAL_VERSION || !NLMISC::startsWith(name, "<NotExist:"))
TextContext->render3D(mat, name);
}
}
@ -7674,9 +7674,9 @@ void CCharacterCL::displayModifiers() // virtual
}
else if (TimeInSec >= mod.Time)
{
ucstring hpModifier;
string hpModifier;
if (mod.Text.empty())
hpModifier = ucstring(toString("%d", mod.Value));
hpModifier = toString("%d", mod.Value);
else
hpModifier = mod.Text;
double t = TimeInSec-mod.Time;

@ -2278,14 +2278,13 @@ string CClientConfig::getHtmlLanguageCode() const
}
// ***************************************************************************
ucstring CClientConfig::buildLoadingString( const ucstring& ucstr ) const
string CClientConfig::buildLoadingString( const string& ucstr ) const
{
if( LoadingStringCount > 0 )
{
uint index = rand()%LoadingStringCount;
string tipId = "uiLoadingString"+toString(index);
ucstring randomUCStr = CI18N::get(tipId);
return randomUCStr;
string tipId = "uiLoadingString" + toString(index);
return CI18N::get(tipId);
}
else
return ucstr;

@ -893,10 +893,10 @@ public:
float getActualLandscapeThreshold() const;
// Return LanguageCode but if "wk", then return "en"
string getHtmlLanguageCode() const;
std::string getHtmlLanguageCode() const;
// return a random loading tip or, if there are not, return the string in argument
ucstring buildLoadingString( const ucstring& ucstr ) const;
std::string buildLoadingString(const std::string &ucstr) const;
/// get the path to client_default.cfg including the filename itself.
bool getDefaultConfigLocation(std::string& fileLocation) const;

@ -285,11 +285,11 @@ void CClientChatManager::init( const string& /* staticDBFileName */ )
void CClientChatManager::chat( const string& strIn, bool isChatTeam )
{
// Truncate to 255 chars max (because of server restriction)
ucstring str= ucstring(strIn).substr(0,255);
ucstring str= ucstring(strIn).substr(0,255); // FIXME: UTF-8 (serial)
// send str to IOS
CBitMemStream bms;
string msgType;
const char *msgType;
if (isChatTeam)
{
@ -303,13 +303,13 @@ void CClientChatManager::chat( const string& strIn, bool isChatTeam )
if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) )
{
bms.serial( str ); // FIXME: UTF-8
bms.serial( str ); // FIXME: UTF-8 (serial)
NetMngr.push( bms );
//nlinfo("impulseCallBack : %s %s sent", msgType.c_str(), str.toString().c_str());
}
else
{
nlwarning("<CClientChatManager::chat> unknown message name : %s", msgType.c_str());
nlwarning("<CClientChatManager::chat> unknown message name : %s", msgType);
}
if (UserEntity != NULL) UserEntity->setAFK(false);
@ -324,8 +324,8 @@ void CClientChatManager::chat( const string& strIn, bool isChatTeam )
void CClientChatManager::tell( const string& receiverIn, const string& strIn )
{
// Truncate to 255 chars max (because of server restriction)
string receiver= receiverIn.substr(0,255);
ucstring str= ucstring(strIn).substr(0,255);
string receiver= receiverIn.substr(0,255); // FIXME: UTF-8 (serial)
ucstring str= ucstring(strIn).substr(0,255); // FIXME: UTF-8 (serial)
// *** send str
CBitMemStream bms;
@ -454,7 +454,7 @@ void CClientChatManager::processTellString(NLMISC::CBitMemStream& bms, IChatDisp
// Serial. For tell message, there is no chat mode, coz we know we are in tell mode !
bms.serial (chatMsg.CompressedIndex);
bms.serial (chatMsg.SenderNameId);
bms.serial (chatMsg.Content); // FIXME: UTF-8
bms.serial (chatMsg.Content); // FIXME: UTF-8 (serial)
if (PermanentlyBanned) return;
@ -718,7 +718,7 @@ string CClientChatManager::getString( CBitMemStream& bms, string& ucstr )
string::size_type idx = ucstr.find(ucstrTmp);
// if there's a parameter in the string
if( idx != ucstring::npos )
if( idx != string::npos )
{
char c = (char)ucstr[idx+ucstrTmp.size()];
switch( c )
@ -967,8 +967,8 @@ void CClientChatManager::buildTellSentence(const string &sender, const string &m
name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender), bWoman);
{
// Sometimes translation contains another title
ucstring::size_type pos = name.find('$');
if (pos != ucstring::npos)
string::size_type pos = name.find('$');
if (pos != string::npos)
{
name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(name), bWoman);
}
@ -1048,8 +1048,8 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde
senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender), bWoman);
{
// Sometimes translation contains another title
ucstring::size_type pos = senderName.find('$');
if (pos != ucstring::npos)
string::size_type pos = senderName.find('$');
if (pos != string::npos)
{
senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(senderName), bWoman);
}

@ -304,7 +304,7 @@ private :
uint8 ChatMode;
NLMISC::CEntityId DynChatChanID;
// For Chat and Tell messages
ucstring Content;
ucstring Content; // FIXME: UTF-8 (serial)
// For Chat2 and Tell2 messages
uint32 PhraseId;
// Use PhraseId or Content?

@ -924,9 +924,7 @@ NLMISC_COMMAND(a, "Execute an admin command on you","<cmd> <arg>")
cmd = args[0];
for (uint i = 1; i < args.size(); i++)
{
// temporary fix for utf-8
// servers commands are not decoded so convert them to ansi
std::string tmp = ucstring::makeFromUtf8(args[i]).toString();
std::string tmp = args[i];
if (!arg.empty())
arg += ' ';
@ -968,9 +966,7 @@ NLMISC_COMMAND(b, "Execute an admin command on your target","<cmd> <arg>")
cmd = args[0];
for (uint i = 1; i < args.size(); i++)
{
// temporary fix for utf-8
// servers commands are not decoded so convert them to ansi
std::string tmp = ucstring::makeFromUtf8(args[i]).toString();
std::string tmp = args[i];
if (!arg.empty())
arg += ' ';
@ -1015,9 +1011,7 @@ NLMISC_COMMAND(c, "Execute an admin command on character name","<Character Name>
cmd = args[1];
for (uint i = 2; i < args.size(); i++)
{
// temporary fix for utf-8
// servers commands are not decoded so convert them to ansi
std::string tmp = ucstring::makeFromUtf8(args[i]).toString();
std::string tmp = args[i];
if (!arg.empty())
arg += ' ';
@ -3863,7 +3857,7 @@ NLMISC_COMMAND(testLongBubble, "To display a bubble with a long text", "<entity>
fromString(args[0], entityId);
CInterfaceManager *pIM = CInterfaceManager::getInstance();
ucstring text("test\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\n");
string text("test\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\n");
uint duration = CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionTimeoutBubbles).getValSInt32();
CEntityCL *entity = EntitiesMngr.entity(entityId);

@ -360,7 +360,7 @@ bool connection (const string &cookie, const string &fsaddr)
// Preload continents
{
const ucstring nmsg("Loading continents...");
const string nmsg("Loading continents...");
ProgressBar.newMessage (ClientCfg.buildLoadingString(nmsg) );
ContinentMngr.preloadSheets();
@ -398,7 +398,7 @@ bool connection (const string &cookie, const string &fsaddr)
// Init out game
setOutGameFullScreen();
ucstring nmsg("Initializing outgame...");
string nmsg("Initializing outgame...");
ProgressBar.newMessage (ClientCfg.buildLoadingString(nmsg) );
pIM->initOutGame();
@ -542,7 +542,7 @@ bool reconnection()
// Preload continents
{
const ucstring nmsg ("Loading continents...");
const string nmsg ("Loading continents...");
ProgressBar.newMessage (ClientCfg.buildLoadingString(nmsg) );
ContinentMngr.preloadSheets();
}

@ -109,7 +109,7 @@ public:
};
NLMISC::CVector2f Pos; // Pos in local map
ucstring Title;
ucstring Title; // FIXME: UTF-8 (serial)
uint8 Type;
//User LandMarks Colors

@ -2268,7 +2268,7 @@ void CEntityManager::dumpXML(class NLMISC::IStream &f)
f.xmlPushBegin("Name");
// Set a property name
f.xmlSetAttrib ("string");
ucstring n = _Entities[i]->getEntityName();
string n = _Entities[i]->getEntityName();
f.serial(n);
// Close the new node header
f.xmlPushEnd();
@ -2361,11 +2361,11 @@ CEntityCL *CEntityManager::getEntityByName (uint32 stringId) const
}
//-----------------------------------------------
CEntityCL *CEntityManager::getEntityByKeywords (const std::vector<ucstring> &keywords, bool onlySelectable) const
CEntityCL *CEntityManager::getEntityByKeywords (const std::vector<string> &keywords, bool onlySelectable) const
{
if (keywords.empty()) return NULL;
std::vector<ucstring> lcKeywords;
std::vector<string> lcKeywords;
lcKeywords.resize(keywords.size());
for(uint k = 0; k < keywords.size(); k++)
{
@ -2382,14 +2382,13 @@ CEntityCL *CEntityManager::getEntityByKeywords (const std::vector<ucstring> &key
if (onlySelectable && !_Entities[i]->properties().selectable()) continue;
ucstring lcName;
lcName = toLower(_Entities[i]->getDisplayName());
string lcName = toLower(_Entities[i]->getDisplayName());
if (lcName.empty()) continue;
bool match = true;
for (uint k = 0; k < lcKeywords.size(); ++k)
{
if (lcName.find(lcKeywords[k]) == ucstring::npos)
if (lcName.find(lcKeywords[k]) == string::npos)
{
match = false;
break;
@ -2418,9 +2417,9 @@ CEntityCL *CEntityManager::getEntityByKeywords (const std::vector<ucstring> &key
}
//-----------------------------------------------
CEntityCL *CEntityManager::getEntityByName (const ucstring &name, bool caseSensitive, bool complete) const
CEntityCL *CEntityManager::getEntityByName (const string &name, bool caseSensitive, bool complete) const
{
ucstring source = name;
string source = name;
const uint size = (uint)source.size();
if (!caseSensitive)
{
@ -2438,7 +2437,7 @@ CEntityCL *CEntityManager::getEntityByName (const ucstring &name, bool caseSensi
{
if(_Entities[i])
{
ucstring value = _Entities[i]->getDisplayName();
string value = _Entities[i]->getDisplayName();
bool foundEntity = false;
uint j;

@ -308,13 +308,13 @@ public:
* \param caseSensitive type of test to perform
* \param complete : if true, the name must match the full name of the entity.
*/
CEntityCL *getEntityByName (const ucstring &name, bool caseSensitive, bool complete) const;
CEntityCL *getEntityByName (const std::string &name, bool caseSensitive, bool complete) const;
/**
* Case insensitive match against entity name. All listed keywords must match.
* \param keywords to match
* \param onlySelectable : if true, match only entity that can be selected
*/
CEntityCL *getEntityByKeywords (const std::vector<ucstring> &keywords, bool onlySelectable) const;
CEntityCL *getEntityByKeywords (const std::vector<std::string> &keywords, bool onlySelectable) const;
CEntityCL *getEntityBySheetName (const std::string &sheet) const;
/// Get an entity by dataset index. Returns NULL if the entity is not found.
CEntityCL *getEntityByCompressedIndex(TDataSetIndex compressedIndex) const;

@ -2276,11 +2276,11 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const std::string &value)
// check if there is any replacement tag in the string
string::size_type p1 = _EntityName.find('$');
if (p1 != ucstring::npos)
if (p1 != string::npos)
{
// we found a replacement point begin tag
string::size_type p2 = _EntityName.find('$', p1+1);
if (p2 != ucstring::npos)
if (p2 != string::npos)
{
// ok, we have the second replacement point!
// extract the replacement id
@ -2300,7 +2300,7 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const std::string &value)
// Sometimes translation contains another title
{
string::size_type pos = replacement.find('$');
if (pos != ucstring::npos)
if (pos != string::npos)
{
_EntityName = _EntityName = STRING_MANAGER::CStringManagerClient::getLocalizedName(sn.substr(0, pos));
string::size_type pos2 = replacement.find('$', pos + 1);
@ -2318,7 +2318,7 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const std::string &value)
_EntityName = STRING_MANAGER::CStringManagerClient::getLocalizedName(_EntityName.substr(0, p1)); // + _Name.substr(p2+1)
// Get extended name
_NameEx = replacement;
newtitle = _NameEx.toUtf8();
newtitle = _NameEx;
}
CHARACTER_TITLE::ECharacterTitle titleEnum = CHARACTER_TITLE::toCharacterTitle( _TitleRaw );
if ( titleEnum >= CHARACTER_TITLE::BeginGmTitle && titleEnum <= CHARACTER_TITLE::EndGmTitle )
@ -2372,7 +2372,7 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const std::string &value)
std::string CEntityCL::getTitleFromName(const std::string &name)
{
std::string::size_type p1 = name.find('$');
if (p1 != ucstring::npos)
if (p1 != string::npos)
{
std::string::size_type p2 = name.find('$', p1 + 1);
if (p2 != std::string::npos)
@ -2388,14 +2388,14 @@ std::string CEntityCL::getTitleFromName(const std::string &name)
std::string CEntityCL::removeTitleFromName(const std::string &name)
{
std::string::size_type p1 = name.find('$');
if (p1 == ucstring::npos)
if (p1 == string::npos)
{
return name;
}
else
{
std::string::size_type p2 = name.find('$', p1 + 1);
if (p2 != ucstring::npos)
if (p2 != string::npos)
{
return name.substr(0, p1) + name.substr(p2 + 1);
}

@ -638,7 +638,7 @@ public:
// Add hit points gain/lost by this entity.
void addHPOutput(sint16 hp, NLMISC::CRGBA color, float dt=0.0f) { if(_HPModifiers.size()<20) _HPModifiers.push_back(CHPModifier(hp,color,dt));}
void addHPOutput(const ucstring &text, NLMISC::CRGBA color, float dt=0.0f) { if(_HPModifiers.size()<20 && !text.empty()) _HPModifiers.push_back(CHPModifier(text,color,dt));}
void addHPOutput(const std::string &text, NLMISC::CRGBA color, float dt=0.0f) { if(_HPModifiers.size()<20 && !text.empty()) _HPModifiers.push_back(CHPModifier(text,color,dt));}
/// Return the entity sheet scale. (return 1.0 if there is any problem).
virtual float getSheetScale() const {return 1.0f;}
@ -944,7 +944,7 @@ protected:
bool _HasReservedTitle;
// Extended Name
ucstring _NameEx;
std::string _NameEx;
// String ID
uint32 _NameId;
// Primitive used for the collision in PACS
@ -995,10 +995,10 @@ protected:
CHPModifier() {}
virtual ~CHPModifier() {}
CHPModifier (sint16 value, NLMISC::CRGBA color, float dt) : Value(value), Color(color), DeltaT(dt) {}
CHPModifier (const ucstring &text, NLMISC::CRGBA color, float dt) : Text(text), Color(color), DeltaT(dt) {}
CHPModifier (const std::string &text, NLMISC::CRGBA color, float dt) : Text(text), Color(color), DeltaT(dt) {}
sint16 Value; // If Text.empty(), take the Value
ucstring Text;
std::string Text;
NLMISC::CRGBA Color;
float DeltaT;
};

@ -927,7 +927,7 @@ retryJoinEdit:
}
}
pIM->messageBoxWithHelp(
CI18N::get(requestRetToMainland ? "uiSessionVanishedFarTP" : "uiSessionUnreachable") + ucstring(errorMsg),
CI18N::get(requestRetToMainland ? "uiSessionVanishedFarTP" : "uiSessionUnreachable") + errorMsg,
letReturnToCharSelect ? "ui:outgame:charsel" : "ui:interface");
// Info in the log
@ -1117,7 +1117,7 @@ void CFarTP::disconnectFromPreviousShard()
// Start progress bar and display background
ProgressBar.reset (BAR_STEP_TP);
ucstring nmsg("Loading...");
string nmsg("Loading...");
ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) );
ProgressBar.progress(0);

@ -623,7 +623,7 @@ void CForageSourceCL::displayModifiers()
{
uint16 qttyDelta = ((uint16)mod.Value) & 0xFF;
uint16 qlty = ((uint16)mod.Value) >> 8;
ucstring hpModifier = ucstring(toString("%u ", qttyDelta) + CI18N::get("uittQualityAbbrev") + toString(" %u", qlty));
string hpModifier = toString("%u ", qttyDelta) + CI18N::get("uittQualityAbbrev") + toString(" %u", qlty);
double t = TimeInSec-mod.Time;
// Compute the position for the Modifier.
CVector pos= namePos + CVector(0.0f, 0.0f, 0.3f+(float)t*1.0f/totalDuration);

@ -262,7 +262,7 @@ char *XmlStrdup4NeL (const char *str)
#ifdef NL_OS_WINDOWS
static ucstring CurrentErrorMessage;
static std::wstring CurrentErrorMessage;
static INT_PTR CALLBACK ExitClientErrorDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM /* lParam */)
{
@ -338,7 +338,7 @@ void ExitClientError (const char *format, ...)
}
#ifdef NL_OS_WINDOWS
CurrentErrorMessage.fromUtf8(str);
CurrentErrorMessage = NLMISC::utf8ToWide(str);
DialogBox(HInstance, MAKEINTRESOURCE(IDD_ERROR_HELP_MESSAGE_BOX), NULL, ExitClientErrorDialogProc);
/*
ucstring ucstr;
@ -937,7 +937,7 @@ void prelogInit()
initDebugMemory();
// Load the application configuration.
ucstring nmsg("Loading config file...");
string nmsg("Loading config file...");
ProgressBar.newMessage (nmsg);
ClientCfg.init(ConfigFileName);
@ -1532,7 +1532,7 @@ void postlogInit()
Driver->clearBuffers(CRGBA::Black);
Driver->swapBuffers();
CNiceInputAuto niceInputs;
ucstring nmsg;
string nmsg;
try
{

@ -469,7 +469,7 @@ void initMainLoop()
// Progress bar for init_main_loop()
ProgressBar.reset (BAR_STEP_INIT_MAIN_LOOP);
ucstring nmsg;
string nmsg;
FPU_CHECKER_ONCE
@ -1017,7 +1017,7 @@ void initMainLoop()
// PreLoad Fauna and Characters
if (!ClientCfg.Light && ClientCfg.PreCacheShapes)
{
ucstring nmsg("Loading character shapes ...");
string nmsg("Loading character shapes ...");
ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) );

@ -192,9 +192,9 @@ public:
CEntityCL *selection = EntitiesMngr.entity(UserEntity->selection());
if (selection && selection->Type == CEntityCL::Player)
{
ucstring name = CEntityCL::removeTitleAndShardFromName(selection->getEntityName());
string name = CEntityCL::removeTitleAndShardFromName(selection->getEntityName());
if (name.empty()) return;
CAHManager::getInstance()->runActionHandler("enter_tell", pCaller, "player=" + name.toString());
CAHManager::getInstance()->runActionHandler("enter_tell", pCaller, "player=" + name);
}
}
protected:
@ -1963,7 +1963,7 @@ public:
// Sometimes translation contains another title
string::size_type pos = copyInout.find('$');
if (pos != ucstring::npos)
if (pos != string::npos)
{
copyInout = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(copyInout), womanTitle);
}
@ -2038,8 +2038,8 @@ class CActionHandlerSetTargetName : public IActionHandler
{
sint32 nSlot = (sint32)evValue.getInteger();
ucstring TargetName;
ucstring TargetTitle;
string TargetName;
string TargetTitle;
// Get from nSlot
if (nSlot > -1)
@ -2074,9 +2074,9 @@ class CActionHandlerSetTargetName : public IActionHandler
// Set to target
CInterfaceExprValue evUCStr;
TargetName = STRING_MANAGER::CStringManagerClient::getLocalizedName(TargetName);
evUCStr.setString(TargetName.toUtf8());
evUCStr.setString(TargetName);
CInterfaceLink::setTargetProperty(sNameTarget, evUCStr);
evUCStr.setString(TargetTitle.toUtf8());
evUCStr.setString(TargetTitle);
CInterfaceLink::setTargetProperty(sTitleTarget, evUCStr);
}
}
@ -2424,28 +2424,27 @@ class CAHTarget : public IActionHandler
{
virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
{
ucstring entityName;
entityName.fromUtf8(getParam(Params, "entity"));
string entityName = getParam(Params, "entity");
if (entityName.empty()) return;
string completeMatch = getParam(Params, "prefer_complete_match");
bool quiet = (getParam (Params, "quiet") == "true");
vector<ucstring> keywords;
NLMISC::splitUCString(entityName, ucstring(" "), keywords);
if (!keywords.empty() && keywords[0].size() > 0 && keywords[0][0] == (ucchar)'"')
vector<string> keywords;
NLMISC::splitString(entityName, " ", keywords);
if (!keywords.empty() && keywords[0].size() > 0 && keywords[0][0] == '"')
{
// entity name is in quotes, do old style match with 'starts with' filter
// search for optional second parameter from old command for prefer_complete_match param
keywords.clear();
ucstring::size_type lastOf = entityName.rfind(ucstring("\""));
string::size_type lastOf = entityName.rfind("\"");
if (lastOf == 0)
lastOf = ucstring::npos;
lastOf = string::npos;
// override the value only when there is no 'prefer_complete_match' parameter set
if (completeMatch.empty() && lastOf < entityName.size())
completeMatch = trim(entityName.substr(lastOf+1).toUtf8());
completeMatch = trim(entityName.substr(lastOf+1));
entityName = entityName.substr(1, lastOf-1);
}
@ -2474,7 +2473,7 @@ class CAHTarget : public IActionHandler
if (entity == NULL)
{
//Get the entity with a sheetName
entity = EntitiesMngr.getEntityBySheetName(entityName.toUtf8());
entity = EntitiesMngr.getEntityBySheetName(entityName);
}
if (entity && entity->properties().selectable() && !entity->getDisplayName().empty())
@ -2758,8 +2757,7 @@ class CAHAssist : public IActionHandler
virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
{
// Get the entity name to target
ucstring entityName;
entityName.fromUtf8 (getParam (Params, "entity"));
string entityName = getParam (Params, "entity");
if (!entityName.empty())
{
// Get the entity
@ -4026,7 +4024,7 @@ REGISTER_ACTION_HANDLER(CHandlerSelectProtectedSlot, "select_protected_slot");
// ***************************************************************************
// Common code
//static void fillPlayerBarText(ucstring &str, const string &dbScore, const string &dbScoreMax, const string &ttFormat)
static void fillPlayerBarText(ucstring &str, const string &dbScore, SCORES::TScores score, const string &ttFormat)
static void fillPlayerBarText(std::string &str, const string &dbScore, SCORES::TScores score, const string &ttFormat)
{
CInterfaceManager *pIM= CInterfaceManager::getInstance();
CCDBNodeLeaf *node;
@ -4056,10 +4054,10 @@ public:
{
CInterfaceManager *pIM= CInterfaceManager::getInstance();
ucstring str;
string str;
fillPlayerBarText(str, "HP", SCORES::hit_points, "uittPlayerLifeFormat");
CWidgetManager::getInstance()->setContextHelpText(str.toUtf8());
CWidgetManager::getInstance()->setContextHelpText(str);
}
};
REGISTER_ACTION_HANDLER(CHandlerPlayerTTLife, "player_tt_life");
@ -4073,10 +4071,10 @@ public:
{
CInterfaceManager *pIM= CInterfaceManager::getInstance();
ucstring str;
string str;
fillPlayerBarText(str, "STA", SCORES::stamina, "uittPlayerStaminaFormat");
CWidgetManager::getInstance()->setContextHelpText(str.toUtf8());
CWidgetManager::getInstance()->setContextHelpText(str);
}
};
REGISTER_ACTION_HANDLER(CHandlerPlayerTTStamina, "player_tt_stamina");
@ -4090,10 +4088,10 @@ public:
{
CInterfaceManager *pIM= CInterfaceManager::getInstance();
ucstring str;
string str;
fillPlayerBarText(str, "SAP", SCORES::sap, "uittPlayerSapFormat");
CWidgetManager::getInstance()->setContextHelpText(str.toUtf8());
CWidgetManager::getInstance()->setContextHelpText(str);
}
};
REGISTER_ACTION_HANDLER(CHandlerPlayerTTSap, "player_tt_sap");
@ -4107,10 +4105,10 @@ public:
{
CInterfaceManager *pIM= CInterfaceManager::getInstance();
ucstring str;
string str;
fillPlayerBarText(str, "FOCUS", SCORES::focus, "uittPlayerFocusFormat");
CWidgetManager::getInstance()->setContextHelpText(str.toUtf8());
CWidgetManager::getInstance()->setContextHelpText(str);
}
};
REGISTER_ACTION_HANDLER(CHandlerPlayerTTFocus, "player_tt_focus");
@ -4137,10 +4135,10 @@ public:
maxVal= node->getValue32();
// Replace in the formated text
ucstring str= CI18N::get("uittBulkFormat");
string str= CI18N::get("uittBulkFormat");
strFindReplace(str, "%v", toString("%.2f", val) );
strFindReplace(str, "%m", toString(maxVal) );
CWidgetManager::getInstance()->setContextHelpText(str.toUtf8());
CWidgetManager::getInstance()->setContextHelpText(str);
}
};
REGISTER_ACTION_HANDLER(CHandlerGetTTBulk, "get_tt_bulk");
@ -4552,7 +4550,7 @@ public:
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
ucstring ucstr;
ucstring ucstr; // FIXME: UTF-8 (serial)
ucstr.fromUtf8(sCustomPhrase);
if( sCustomPhrase == "none" )

@ -121,7 +121,7 @@ void CFlyingTextManager::releaseInGame()
}
// ***************************************************************************
void CFlyingTextManager::addFlyingText(void *key, const ucstring &text, const NLMISC::CVector &pos, CRGBA color, float scale, sint offsetX)
void CFlyingTextManager::addFlyingText(void *key, const string &text, const NLMISC::CVector &pos, CRGBA color, float scale, sint offsetX)
{
// key exist in the map?
TInSceneCurrentMap::iterator it= _InSceneCurrent.find(key);
@ -144,7 +144,7 @@ void CFlyingTextManager::addFlyingText(void *key, const ucstring &text, const NL
gi.UsedThisFrame= true;
// update infos
gi.ViewText->setText(text.toUtf8());
gi.ViewText->setText(text);
gi.ViewText->setColor(color);
gi.GroupInScene->Position= pos;
gi.GroupInScene->Scale= scale;

@ -49,7 +49,7 @@ public:
/** add a flying text at a position (called during entity display). NB: may fail if no more free groups
* \param offsetx: screen offsetx of the group in scene
*/
void addFlyingText(void *key, const ucstring &text, const NLMISC::CVector &pos, NLMISC::CRGBA color, float scale, sint offsetX=0);
void addFlyingText(void *key, const std::string &text, const NLMISC::CVector &pos, NLMISC::CRGBA color, float scale, sint offsetX=0);
/// release no more used flying text (called by CEntityManager at each draw)
void releaseNotUsedFlyingText();

@ -488,7 +488,7 @@ void CGroupInSceneBubbleManager::update ()
// ***************************************************************************
CGroupInSceneBubble *CGroupInSceneBubbleManager::newBubble (const ucstring &text)
CGroupInSceneBubble *CGroupInSceneBubbleManager::newBubble (const string &text)
{
if (!text.empty() && !_Bubbles.empty())
{
@ -576,7 +576,7 @@ void CGroupInSceneBubbleManager::addSkillPopup (uint skillId, sint delta, uint t
// ***************************************************************************
void CGroupInSceneBubbleManager::addMessagePopup (const ucstring &message, CRGBA color, uint time)
void CGroupInSceneBubbleManager::addMessagePopup (const string &message, CRGBA color, uint time)
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
@ -599,7 +599,7 @@ void CGroupInSceneBubbleManager::addMessagePopup (const ucstring &message, CRGBA
CViewText *pViewName = dynamic_cast<CViewText*>(group->getView("name"));
if (pViewName != NULL)
{
pViewName->setText (message.toUtf8());
pViewName->setText (message);
pViewName->setColor (color);
}
@ -625,7 +625,7 @@ void CGroupInSceneBubbleManager::addMessagePopup (const ucstring &message, CRGBA
// ***************************************************************************
void CGroupInSceneBubbleManager::addMessagePopupCenter (const ucstring &message, CRGBA color, uint time)
void CGroupInSceneBubbleManager::addMessagePopupCenter (const string &message, CRGBA color, uint time)
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
@ -648,7 +648,7 @@ void CGroupInSceneBubbleManager::addMessagePopupCenter (const ucstring &message,
CViewText *pViewName = dynamic_cast<CViewText*>(group->getView("name"));
if (pViewName != NULL)
{
pViewName->setTextFormatTaged(message.toUtf8());
pViewName->setTextFormatTaged(message);
pViewName->setColor (color);
}
@ -757,9 +757,9 @@ CGroupInSceneBubbleManager::CPopupContext *CGroupInSceneBubbleManager::buildCont
// ***************************************************************************
void CGroupInSceneBubbleManager::addContextHelp (const ucstring &message, const string &targetName, uint time)
void CGroupInSceneBubbleManager::addContextHelp (const string &message, const string &targetName, uint time)
{
std::string finalMessage = message.toUtf8();
std::string finalMessage = message;
CInterfaceElement *target;
CPopupContext *context = CGroupInSceneBubbleManager::buildContextHelp ("context_help_", targetName, target, time);
if (context)
@ -835,7 +835,7 @@ void CGroupInSceneBubbleManager::ignoreContextHelp (CInterfaceGroup *groupToRemo
// ***************************************************************************
void CGroupInSceneBubbleManager::chatOpen (uint32 nUID, const ucstring &ucsText, uint bubbleTimer)
void CGroupInSceneBubbleManager::chatOpen (uint32 nUID, const std::string &ucsText, uint bubbleTimer)
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
@ -1065,9 +1065,7 @@ void CGroupInSceneBubbleManager::webIgChatOpen (uint32 nBotUID, string text, con
// Update the bubble's texts
ucstring ucText;
ucText.fromUtf8(text);
bubble->setText(ucText);
bubble->setText(text);
id = bubble->getId() + ":header_opened:window:";
CViewText *pVT;
CCtrlLink *pCL;
@ -1092,9 +1090,8 @@ void CGroupInSceneBubbleManager::webIgChatOpen (uint32 nBotUID, string text, con
if (pVT != NULL)
{
pVT->setActive(true);
ucstring optionText;
optionText.fromUtf8(strs[j]);
pVT->setText(optionText.toUtf8());
string optionText = strs[j];
pVT->setText(optionText);
pCL = dynamic_cast<CCtrlLink*>(bubble->getElement(id+"optb"+toString(j)));
if (pCL != NULL)
{
@ -1425,19 +1422,19 @@ void CGroupInSceneBubble::unlink ()
// ***************************************************************************
void CGroupInSceneBubble::setText (const ucstring &text)
void CGroupInSceneBubble::setText (const string &text)
{
if (text.empty()) return;
_TextParts.clear();
// Look for "{break}" in the message
ucstring finalMsg = text;
ucstring tmpMsg;
string finalMsg = text;
string tmpMsg;
for(;;)
{
ucstring::size_type index = finalMsg.find (ucstring("{break}"));
if (index == ucstring::npos) break;
string::size_type index = finalMsg.find ("{break}");
if (index == string::npos) break;
tmpMsg = finalMsg.substr (0, index);
if (!tmpMsg.empty())
_TextParts.push_back(tmpMsg);
@ -1478,14 +1475,14 @@ void CGroupInSceneBubble::skip()
// ***************************************************************************
void CGroupInSceneBubble::setRawText (const ucstring &text)
void CGroupInSceneBubble::setRawText (const string &text)
{
_CanBeShown = !text.empty();
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CInterfaceElement *pVTIE = CWidgetManager::getInstance()->getElementFromId(getId()+":header_opened:window:text");
CViewText *pVT= dynamic_cast<CViewText*>(pVTIE);
if (pVT != NULL)
pVT->setText(text.toUtf8());
pVT->setText(text);
}
// ***************************************************************************
@ -1584,8 +1581,7 @@ class CHandlerCharacterBubble : public IActionHandler
CInterfaceManager *pIM = CInterfaceManager::getInstance();
uint entityId;
fromString(getParam (sParams, "entity"), entityId);
ucstring text;
text.fromUtf8(getParam (sParams, "text"));
string text = getParam (sParams, "text");
string sTime = getParam (sParams, "time");
uint duration;
if (sTime.empty())
@ -1633,10 +1629,8 @@ class CHandlerMessagePopup : public IActionHandler
void execute (CCtrlBase * /* pCaller */, const std::string &sParams)
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
ucstring text0;
text0.fromUtf8(getParam (sParams, "text0").c_str());
ucstring text1;
text1.fromUtf8(getParam (sParams, "text1").c_str());
string text0 = getParam (sParams, "text0");
string text1 = getParam (sParams, "text1");
string sTime = getParam (sParams, "time");
uint duration;
if (sTime.empty())
@ -1660,8 +1654,7 @@ class CHandlerContextHelp : public IActionHandler
string targetName = getParam (sParams, "target");
string text = getParam (sParams, "text");
ucstring itext;
itext.fromUtf8 (getParam (sParams, "itext"));
string itext = getParam (sParams, "itext");
if (itext.empty())
itext = CI18N::get(text);

@ -39,19 +39,19 @@ public:
void update ();
// Get a CGroupBubble
class CGroupInSceneBubble *newBubble (const ucstring &text);
class CGroupInSceneBubble *newBubble (const std::string &text);
// Add a message popup. if 0, get the OptionTimeoutMessages
void addMessagePopup (const ucstring &message, NLMISC::CRGBA col = CRGBA::White, uint time = 0);
void addMessagePopup (const std::string &message, NLMISC::CRGBA col = CRGBA::White, uint time = 0);
// The same as previous but centered in the screen. if 0, get the OptionTimeoutMessages
void addMessagePopupCenter (const ucstring &message, NLMISC::CRGBA col = CRGBA::White, uint time = 0);
void addMessagePopupCenter (const std::string &message, NLMISC::CRGBA col = CRGBA::White, uint time = 0);
// Add a skill popup
void addSkillPopup (uint skillId, sint delta, uint time);
// Add a context help with a string
void addContextHelp (const ucstring &message, const std::string &target, uint time);
void addContextHelp (const std::string &message, const std::string &target, uint time);
// Add a context help
void addContextHelpHTML (const std::string &filename, const std::string &target, uint time);
@ -60,7 +60,7 @@ public:
void ignoreContextHelp (CInterfaceGroup *groupToRemove);
// Open a bubble chat (with next and skip button)
void chatOpen (uint32 nUID, const ucstring &ucsText, uint bubbleTimer = 0);
void chatOpen (uint32 nUID, const std::string &ucsText, uint bubbleTimer = 0);
// Dynamic Chat
@ -199,7 +199,7 @@ public:
void unlink ();
// Set text
void setText (const ucstring &text);
void setText (const std::string &text);
// Called from action handler
void next();
@ -217,7 +217,7 @@ public:
private:
void setRawText (const ucstring &text);
void setRawText (const std::string &text);
void displayNextAndSkip (bool show);
private:
@ -233,7 +233,7 @@ private:
CCharacterCL *_Character;
// Multi part bubble
std::vector<ucstring> _TextParts;
std::vector<std::string> _TextParts;
uint32 _CurrentPart;
};

@ -1124,7 +1124,7 @@ bool mainLoop()
//
#define BAR_STEP_TP 2
ProgressBar.reset (BAR_STEP_TP);
ucstring nmsg("Loading...");
string nmsg("Loading...");
ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) );
ProgressBar.progress(0);
ContinentMngr.select(UserEntity->pos(), ProgressBar);

@ -1527,7 +1527,7 @@ void impulseTPCommon2(NLMISC::CBitMemStream &impulse, bool hasSeason)
// start progress bar and display background
ProgressBar.reset (BAR_STEP_TP);
ucstring nmsg("Loading...");
string nmsg("Loading...");
ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) );
@ -3463,7 +3463,7 @@ void impulseCombatFlyingHpDelta(NLMISC::CBitMemStream &impulse)
CRGBA color((uint8)(rgba>>24&255), (uint8)(rgba>>16&255), (uint8)(rgba>>8&255), (uint8)(rgba&255));
CEntityCL *entity = EntitiesMngr.getEntityByCompressedIndex(entityID);
if (entity)
entity->addHPOutput(ucstring(toString("%d", hpDelta)), color);
entity->addHPOutput(toString("%d", hpDelta), color);
}
void impulseCombatFlyingTextItemSpecialEffectProc(NLMISC::CBitMemStream &impulse)
@ -3477,7 +3477,7 @@ void impulseCombatFlyingTextItemSpecialEffectProc(NLMISC::CBitMemStream &impulse
impulse.serial(effect);
impulse.serial(param);
CRGBA color((uint8)(rgba>>24&255), (uint8)(rgba>>16&255), (uint8)(rgba>>8&255), (uint8)(rgba&255));
ucstring text = CI18N::get(toString("uiItemSpecialEffectFlyingText%s", ITEM_SPECIAL_EFFECT::toString((ITEM_SPECIAL_EFFECT::TItemSpecialEffect)effect).c_str()));
string text = CI18N::get(toString("uiItemSpecialEffectFlyingText%s", ITEM_SPECIAL_EFFECT::toString((ITEM_SPECIAL_EFFECT::TItemSpecialEffect)effect).c_str()));
strFindReplace(text, "%param", toString("%d", param));
CEntityCL *entity = EntitiesMngr.getEntityByCompressedIndex(entityID);
if (entity)
@ -3493,7 +3493,7 @@ void impulseCombatFlyingText(NLMISC::CBitMemStream &impulse)
COMBAT_FLYING_TEXT::TCombatFlyingText type = (COMBAT_FLYING_TEXT::TCombatFlyingText)tmp;
CRGBA color(255, 255, 255);
ucstring text("");
string text("");
float dt = 0.0f;
switch (type)

@ -1868,7 +1868,7 @@ void CClientEditionModule::onTpPositionSimulated(NLNET::IModuleProxy * /* sender
beginLoading (LoadingBackground);
#define BAR_STEP_TP 2 // fixme : this define is duplicated....
ProgressBar.reset (BAR_STEP_TP);
ucstring nmsg("Loading...");
string nmsg("Loading...");
ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) );
ProgressBar.progress(0);
ContinentMngr.select(dest, ProgressBar);

@ -64,11 +64,9 @@ public:
void flushStringCache();
bool getString(uint32 stringId, std::string &result);
// bool getString(uint32 stringId, ucstring &result) { std::string temp; bool res = getString(stringId, temp); result.fromUtf8(temp); return res; } // FIXME: UTF-8
void waitString(uint32 stringId, const IStringWaiterRemover *premover, std::string *result);
void waitString(uint32 stringId, IStringWaitCallback *pcallback);
bool getDynString(uint32 dynStringId, std::string &result);
// bool getDynString(uint32 dynStringId, ucstring &result) { std::string temp; bool res = getString(dynStringId, temp); result.fromUtf8(temp); return res; } // FIXME: UTF-8
void waitDynString(uint32 stringId, const IStringWaiterRemover *premover, std::string *result);
void waitDynString(uint32 stringId, IStringWaitCallback *pcallback);

@ -159,6 +159,16 @@ bool CGenericXmlMsgHeaderManager::pushNameToStream(const string &msgName, CBitMe
return res;
}
//
bool CGenericXmlMsgHeaderManager::pushNameToStream(const char *msgName, CBitMemStream &strm)
{
bool res = (_Root->select(msgName, strm) != NULL);
if (!res) nlwarning("pushNameToStream failed: Unknown message name '%s'", msgName);
return res;
}
//
void CGenericXmlMsgHeaderManager::popNameFromStream(string &resultName, CBitMemStream &strm)
{

@ -231,6 +231,14 @@ public:
*/
bool pushNameToStream(const std::string &msgName, NLMISC::CBitMemStream &strm);
/**
* Convert and write a Message Name into a stream.
* \param string msgName : Message Name to convert and write into the stream.
* \param CBitMemStream strm : the stream to receive the Message Name.
* \return bool : 'false' if the method cannot write the message Name into the stream (probably because de message name is wrong).
*/
bool pushNameToStream(const char *msgName, NLMISC::CBitMemStream &strm);
/**
* Convert and return the Message Name from a stream.
* \param string resultName: The result for the Message Name.

Loading…
Cancel
Save