From 14a0c5d471d1facf279a43be2d0661015182f5c0 Mon Sep 17 00:00:00 2001
From: Xtarsia <69606701+Xtarsia@users.noreply.github.com>
Date: Sat, 22 Aug 2020 22:46:24 +0100
Subject: [PATCH 001/205] Update inventory.xml
Remove Special items from inventory.
---
.../data/gamedev/interfaces_v3/inventory.xml | 25 -------------------
1 file changed, 25 deletions(-)
diff --git a/ryzom/client/data/gamedev/interfaces_v3/inventory.xml b/ryzom/client/data/gamedev/interfaces_v3/inventory.xml
index 9d59a3ea0..22b6ad7ed 100644
--- a/ryzom/client/data/gamedev/interfaces_v3/inventory.xml
+++ b/ryzom/client/data/gamedev/interfaces_v3/inventory.xml
@@ -23,16 +23,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -122,7 +112,6 @@
@@ -272,19 +260,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
From e3ec67a69809561152d9bed30668e12f18dab732 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Thu, 22 Oct 2020 06:14:46 +0800
Subject: [PATCH 002/205] Disable R2 MD5 check, it's useless now, fix
kaetemi/ryzomclassic#147
---
ryzom/client/client_default.cfg | 2 +-
ryzom/client/src/client_cfg.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/ryzom/client/client_default.cfg b/ryzom/client/client_default.cfg
index 3241fdae1..82709677a 100644
--- a/ryzom/client/client_default.cfg
+++ b/ryzom/client/client_default.cfg
@@ -466,7 +466,7 @@ R2EDExtendedDebug = 0;
R2EDLightPalette = 0;
R2ClientGw = "r2linux01";
LoadLuaDebugger = 0;
-CheckR2ScenarioMD5 = 1;
+CheckR2ScenarioMD5 = 0;
LevelDesignEnabled = 0;
DmCameraDistMax = 25;
diff --git a/ryzom/client/src/client_cfg.cpp b/ryzom/client/src/client_cfg.cpp
index 011efb01e..e12f8f1e8 100644
--- a/ryzom/client/src/client_cfg.cpp
+++ b/ryzom/client/src/client_cfg.cpp
@@ -721,7 +721,7 @@ CClientConfig::CClientConfig()
R2EDLoadDynamicFeatures = 0;
- CheckR2ScenarioMD5 = true;
+ CheckR2ScenarioMD5 = false;
DisplayTPReason = false;
From 4a7a153a3edc7ebdb40cf3066852dfb07618d2ce Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Thu, 22 Oct 2020 08:00:38 +0800
Subject: [PATCH 003/205] Disable check for OtherCharAccess if
CheckR2ScenarioMD5 is false, kaetemi/ryzomclassic#151
---
ryzom/client/src/r2/dmc/client_edition_module.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ryzom/client/src/r2/dmc/client_edition_module.cpp b/ryzom/client/src/r2/dmc/client_edition_module.cpp
index f58a9f669..5f7aa9a43 100644
--- a/ryzom/client/src/r2/dmc/client_edition_module.cpp
+++ b/ryzom/client/src/r2/dmc/client_edition_module.cpp
@@ -2455,7 +2455,7 @@ void CClientEditionModule::loadScenarioSucceded(const std::string& filename, con
}
- if (!modifiedByMD5.empty() && !locked.empty() && locked == "RunOnly")
+ if (ClientCfg.CheckR2ScenarioMD5 && !modifiedByMD5.empty() && !locked.empty() && locked == "RunOnly")
{
bool ok = hasCharacterSameCharacterIdMd5(modifiedByMD5);
if (!ok)
From ccb141672f32348593c6f6654d6ea5c2952ce64f Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Thu, 22 Oct 2020 20:23:18 +0800
Subject: [PATCH 004/205] Avoid some unnecessary string operations when not
recording history, cleanup, debug crash in `fullName`
kaetemi/ryzomclassic#152
---
ryzom/server/src/ai_service/debug_history.h | 25 ++++++++++----------
ryzom/server/src/ai_service/state_instance.h | 16 +++++++++----
2 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/ryzom/server/src/ai_service/debug_history.h b/ryzom/server/src/ai_service/debug_history.h
index e5553bae1..a86763484 100644
--- a/ryzom/server/src/ai_service/debug_history.h
+++ b/ryzom/server/src/ai_service/debug_history.h
@@ -23,36 +23,37 @@ private:
typedef std::deque THistoryContainer;
public:
explicit CDebugHistory()
- : _Recording(false)
+ : m_Recording(false)
{
}
virtual ~CDebugHistory() { }
void addHistory(std::string const& txt)
{
- if (_Recording)
- _History.push_back(txt);
+ if (m_Recording)
+ m_History.push_back(txt);
}
void addHistory(char const* txt)
{
- if (_Recording)
+ if (m_Recording)
addHistory(NLMISC::toString(txt));
}
template
- void addHistory(char const* txt, A a) { if (_Recording) addHistory(NLMISC::toString(txt, a)); }
+ void addHistory(char const* txt, A a) { if (m_Recording) addHistory(NLMISC::toString(txt, a)); }
template
- void addHistory(char const* txt, A a, B b) { if (_Recording) addHistory(NLMISC::toString(txt, a, b)); }
+ void addHistory(char const* txt, A a, B b) { if (m_Recording) addHistory(NLMISC::toString(txt, a, b)); }
template
- void addHistory(char const* txt, A a, B b, C c) { if (_Recording) addHistory(NLMISC::toString(txt, a, b, c)); }
+ void addHistory(char const* txt, A a, B b, C c) { if (m_Recording) addHistory(NLMISC::toString(txt, a, b, c)); }
template
- void addHistory(char const* txt, A a, B b, C c, D d) { if (_Recording) addHistory(NLMISC::toString(txt, a, b, c, d)); }
+ void addHistory(char const* txt, A a, B b, C c, D d) { if (m_Recording) addHistory(NLMISC::toString(txt, a, b, c, d)); }
- void setRecording(bool val) { _Recording = val; }
+ void setRecording(bool val) { m_Recording = val; }
+ inline bool isRecording() { return m_Recording; }
void writeAsInfo()
{
int j = 0;
- FOREACH(itHistory, THistoryContainer, _History)
+ FOREACH(itHistory, THistoryContainer, m_History)
{
nlinfo("HIST %3i: %s", j, itHistory->c_str());
++j;
@@ -60,8 +61,8 @@ public:
}
private:
- bool _Recording;
- THistoryContainer _History;
+ bool m_Recording;
+ THistoryContainer m_History;
};
#endif
diff --git a/ryzom/server/src/ai_service/state_instance.h b/ryzom/server/src/ai_service/state_instance.h
index 916b6bc47..cdb13f391 100644
--- a/ryzom/server/src/ai_service/state_instance.h
+++ b/ryzom/server/src/ai_service/state_instance.h
@@ -503,18 +503,23 @@ void CStateInstance::processStateEvent(CAIEvent const& stateEvent, CAIState cons
if (!reaction.testCompatibility(this,state))
continue;
- getDebugHistory()->addHistory("STATE: '%s' EVENT: '%s' REACTION: '%s'", state->getAliasNode()->fullName().c_str(),
- stateEvent.getName().c_str(), reaction.getAliasNode()->fullName().c_str());
+ if (getDebugHistory()->isRecording())
+ {
+ getDebugHistory()->addHistory("STATE: '%s' EVENT: '%s' REACTION: '%s'", state->getAliasNode()->fullName().c_str(),
+ stateEvent.getName().c_str(), reaction.getAliasNode()->fullName().c_str());
+ }
foundReaction=true;
if (!reaction.getAction())
{
+ nldebug("Failed to find action for event");
nlwarning("Failed to find action for event: %s",reaction.getAliasNode()->fullName().c_str());
continue;
}
if (!reaction.getAction()->executeAction(this, NULL))
{
+ nldebug("Failed to execute action for event");
nlwarning("Failed to execute action for event '%s': for stateInstance:'%s' in state:'%s'", stateEvent.getName().c_str(),
aliasTreeOwner()->getAliasNode()->fullName().c_str(), state->getAliasNode()->fullName().c_str());
continue;
@@ -523,8 +528,11 @@ void CStateInstance::processStateEvent(CAIEvent const& stateEvent, CAIState cons
}
if (!foundReaction)
{
- getDebugHistory()->addHistory("STATE: '%s' EVENT: '%s' NO REACTION", state->getAliasNode()->fullName().c_str(),
- stateEvent.getName().c_str());
+ if (getDebugHistory()->isRecording())
+ {
+ getDebugHistory()->addHistory("STATE: '%s' EVENT: '%s' NO REACTION", state->getAliasNode()->fullName().c_str(),
+ stateEvent.getName().c_str());
+ }
}
}
From c71f516ed2249761a3fdafb1a096050ecdf1473a Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Thu, 22 Oct 2020 20:25:49 +0800
Subject: [PATCH 005/205] Avoid more useless `fullName` calls,
kaetemi/ryzomclassic#152
---
.../src/ai_service/generic_logic_action.cpp | 34 +++++++++++++------
1 file changed, 23 insertions(+), 11 deletions(-)
diff --git a/ryzom/server/src/ai_service/generic_logic_action.cpp b/ryzom/server/src/ai_service/generic_logic_action.cpp
index 30edfb460..947da6400 100644
--- a/ryzom/server/src/ai_service/generic_logic_action.cpp
+++ b/ryzom/server/src/ai_service/generic_logic_action.cpp
@@ -131,9 +131,12 @@ public:
nlassert(randVal<=_weights[i]); // "BUG: Random value outside random range!"
#endif
- entity->getDebugHistory()->addHistory("GRP State Change: %s => %s",
- entity->getState()->getAliasNode()->fullName().c_str(),
- _states[i]->getAliasNode()->fullName().c_str());
+ if (entity->getDebugHistory()->isRecording())
+ {
+ entity->getDebugHistory()->addHistory("GRP State Change: %s => %s",
+ entity->getState()->getAliasNode()->fullName().c_str(),
+ _states[i]->getAliasNode()->fullName().c_str());
+ }
entity->setNextState(_states[i]);
return true;
@@ -198,9 +201,12 @@ public:
}
uint i=CAIS::rand16((uint32)_states.size());
- entity->getDebugHistory()->addHistory("GRP State Change: %s => %s",
- entity->getState()->getAliasNode()->fullName().c_str(),
- _states[i]->getAliasNode()->fullName().c_str());
+ if (entity->getDebugHistory()->isRecording())
+ {
+ entity->getDebugHistory()->addHistory("GRP State Change: %s => %s",
+ entity->getState()->getAliasNode()->fullName().c_str(),
+ _states[i]->getAliasNode()->fullName().c_str());
+ }
entity->setNextState(_states[i]);
return true;
@@ -514,9 +520,12 @@ public:
nlwarning("begin_punctual_state failed because state list is empty");
return false;
}
- entity->setNextPunctualState(_states[CAIS::rand16((uint32)_states.size())]);
- entity->getDebugHistory()->addHistory("GRP BeginPunctual State: %s",
- entity->getNextPunctualState()->getAliasNode()->fullName().c_str());
+ entity->setNextPunctualState(_states[CAIS::rand16((uint32)_states.size())]);
+ if (entity->getDebugHistory()->isRecording())
+ {
+ entity->getDebugHistory()->addHistory("GRP BeginPunctual State: %s",
+ entity->getNextPunctualState()->getAliasNode()->fullName().c_str());
+ }
return true;
}
@@ -548,8 +557,11 @@ public:
// depending on the whim of the level designers
virtual bool executeAction(CStateInstance *entity,const IAIEvent *event)
{
- entity->getDebugHistory()->addHistory("GRP End Punctual State: %s",
- entity->getPunctualState()->getAliasNode()->fullName().c_str());
+ if (entity->getDebugHistory()->isRecording())
+ {
+ entity->getDebugHistory()->addHistory("GRP End Punctual State: %s",
+ entity->getPunctualState()->getAliasNode()->fullName().c_str());
+ }
entity->cancelPunctualState();
return true;
From 6853098df996d4b3a7ccb23a371b2ccd782e113f Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Thu, 22 Oct 2020 20:34:06 +0800
Subject: [PATCH 006/205] Additional debugging, kaetemi/ryzomclassic#152
---
ryzom/server/src/ai_service/ai_outpost.cpp | 1 +
ryzom/server/src/ai_service/state_instance.h | 6 ++++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/ryzom/server/src/ai_service/ai_outpost.cpp b/ryzom/server/src/ai_service/ai_outpost.cpp
index 43994c245..eb3a7661e 100644
--- a/ryzom/server/src/ai_service/ai_outpost.cpp
+++ b/ryzom/server/src/ai_service/ai_outpost.cpp
@@ -880,6 +880,7 @@ void COutpost::createSquad(CGroupDesc const* groupDesc, COu
grp->_UpdateNbTicks = 10;
grp->respawnTime() = respawTimeGC;
+ grp->getDebugHistory()->setRecording(true); // FIXME: https://github.com/kaetemi/ryzomclassic/issues/152
grp->updateStateInstance(); // Directly call his first state (to retrieve associated params).
if (createOrder!=0)
diff --git a/ryzom/server/src/ai_service/state_instance.h b/ryzom/server/src/ai_service/state_instance.h
index cdb13f391..8f472702b 100644
--- a/ryzom/server/src/ai_service/state_instance.h
+++ b/ryzom/server/src/ai_service/state_instance.h
@@ -505,6 +505,7 @@ void CStateInstance::processStateEvent(CAIEvent const& stateEvent, CAIState cons
if (getDebugHistory()->isRecording())
{
+ nldebug("Reaction for event"); // FIXME: https://github.com/kaetemi/ryzomclassic/issues/152
getDebugHistory()->addHistory("STATE: '%s' EVENT: '%s' REACTION: '%s'", state->getAliasNode()->fullName().c_str(),
stateEvent.getName().c_str(), reaction.getAliasNode()->fullName().c_str());
}
@@ -513,13 +514,13 @@ void CStateInstance::processStateEvent(CAIEvent const& stateEvent, CAIState cons
if (!reaction.getAction())
{
- nldebug("Failed to find action for event");
+ nldebug("Failed to find action for event"); // FIXME: https://github.com/kaetemi/ryzomclassic/issues/152
nlwarning("Failed to find action for event: %s",reaction.getAliasNode()->fullName().c_str());
continue;
}
if (!reaction.getAction()->executeAction(this, NULL))
{
- nldebug("Failed to execute action for event");
+ nldebug("Failed to execute action for event"); // FIXME: https://github.com/kaetemi/ryzomclassic/issues/152
nlwarning("Failed to execute action for event '%s': for stateInstance:'%s' in state:'%s'", stateEvent.getName().c_str(),
aliasTreeOwner()->getAliasNode()->fullName().c_str(), state->getAliasNode()->fullName().c_str());
continue;
@@ -530,6 +531,7 @@ void CStateInstance::processStateEvent(CAIEvent const& stateEvent, CAIState cons
{
if (getDebugHistory()->isRecording())
{
+ nldebug("No reaction for event"); // FIXME: https://github.com/kaetemi/ryzomclassic/issues/152
getDebugHistory()->addHistory("STATE: '%s' EVENT: '%s' NO REACTION", state->getAliasNode()->fullName().c_str(),
stateEvent.getName().c_str());
}
From 2859693c1e30cb1ff418eb95c071551080f3b3b9 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Thu, 22 Oct 2020 20:56:07 +0800
Subject: [PATCH 007/205] Remove OtherCharAccess toggle from Scenario window
when MD5 checks are disabled, close kaetemi/ryzomclassic#151
---
nel/include/nel/gui/interface_element.h | 4 +++-
nel/src/gui/interface_element.cpp | 8 ++++++++
ryzom/common/data_common/r2/r2_ui_scenario.lua | 7 +++++++
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/nel/include/nel/gui/interface_element.h b/nel/include/nel/gui/interface_element.h
index 47025f155..60f6ae7b8 100644
--- a/nel/include/nel/gui/interface_element.h
+++ b/nel/include/nel/gui/interface_element.h
@@ -382,7 +382,6 @@ namespace NLGUI
void dummySet(const std::string &value);
public:
-
// export some properties
REFLECT_EXPORT_START(CInterfaceElement, CReflectable)
REFLECT_BOOL ("active", getActive, setActive);
@@ -397,6 +396,7 @@ namespace NLGUI
REFLECT_SINT32 ("h_real", getHReal, dummySet);
REFLECT_STRING ("id", getIdByValue, dummySet);
REFLECT_STRING ("sizeref", getSizeRefAsString, setSizeRef);
+ REFLECT_STRING ("posparent", getPosParent, setPosParent);
REFLECT_LUA_METHOD("updateCoords", luaUpdateCoords);
REFLECT_LUA_METHOD("invalidateCoords", luaInvalidateCoords);
REFLECT_LUA_METHOD("invalidateContent", luaInvalidateContent);
@@ -523,6 +523,8 @@ namespace NLGUI
void parseSizeParent( const std::string &id );
void setSizeParent( const std::string &id );
void getSizeParent( std::string &id ) const;
+
+ std::string getPosParent() const;
void setSerializable( bool b ){ serializable = b; }
bool IsSerializable() const{ return serializable; }
diff --git a/nel/src/gui/interface_element.cpp b/nel/src/gui/interface_element.cpp
index cf5646077..4d21555e7 100644
--- a/nel/src/gui/interface_element.cpp
+++ b/nel/src/gui/interface_element.cpp
@@ -437,6 +437,14 @@ namespace NLGUI
parseSizeRef(sizeref.c_str());
}
+ // ------------------------------------------------------------------------------------------------
+ std::string CInterfaceElement::getPosParent() const
+ {
+ std::string id;
+ getPosParent(id);
+ return id;
+ }
+
// ------------------------------------------------------------------------------------------------
std::string CInterfaceElement::getSizeRefAsString() const
{
diff --git a/ryzom/common/data_common/r2/r2_ui_scenario.lua b/ryzom/common/data_common/r2/r2_ui_scenario.lua
index d627ab7b7..5a925d9a4 100644
--- a/ryzom/common/data_common/r2/r2_ui_scenario.lua
+++ b/ryzom/common/data_common/r2/r2_ui_scenario.lua
@@ -78,6 +78,13 @@ function r2.ScenarioWindow:initScenarioWindow()
for k, type in pairs(tmp) do
lockCB:addText(type)
end
+
+ if config.CheckR2ScenarioMD5 == 0 then
+ local lockGrp = scenarioWnd:find("locked")
+ local titleGrp = scenarioWnd:find("title")
+ lockGrp.active = false -- Hide lock group
+ titleGrp.posparent = lockGrp.posparent -- Rearrange
+ end
end
From b4dc60f1632121ff4b96012bdc77146d8cd306af Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Fri, 23 Oct 2020 00:19:07 +0800
Subject: [PATCH 008/205] Fix double undo stack actions,
kaetemi/ryzomclassic#87
---
.../data_common/r2/r2_features_default.lua | 4 ++--
.../data_common/r2/r2_ui_displayer_npc.lua | 19 +++++++++++++------
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/ryzom/common/data_common/r2/r2_features_default.lua b/ryzom/common/data_common/r2/r2_features_default.lua
index d94e2f656..44afdc6c2 100644
--- a/ryzom/common/data_common/r2/r2_features_default.lua
+++ b/ryzom/common/data_common/r2/r2_features_default.lua
@@ -405,7 +405,7 @@ local registerFeature = function ()
{Name="Aggro", Type="Number", Min="0", Max="120", DefaultValue="30", DefaultInBase=1,
Visible=function(this) return this:isGroupedAndLeader() or not this:isGrouped() and not this:isBotObject() end
},
- {Name="TypeNPC", Type="Number", WidgetStyle="EnumDropDown", SecondRequestFunc=r2.updateType,
+ {Name="TypeNPC", Type="Number", WidgetStyle="EnumDropDown", SecondRequestFunc=function(value) r2:updateType(true) end,
Enum= {}, Visible=true, DefaultValue="-1",
},
@@ -858,7 +858,7 @@ local registerFeature = function ()
Visible=true
},
{Name="Level", Type="Number", WidgetStyle="EnumDropDown", Category="uiR2EDRollout_NpcCustom",
- Enum= { "uiR2EDLowLevel", "uiR2EDAverageLevel", "uiR2EDHighLevel", "uiR2EDVeryHighLevel"}, SecondRequestFunc=r2.updateLevel,
+ Enum= { "uiR2EDLowLevel", "uiR2EDAverageLevel", "uiR2EDHighLevel", "uiR2EDVeryHighLevel"}, SecondRequestFunc=function(value) r2.updateLevel(value, true) end,
Visible=function(this) return this:isGroupedAndLeader() or not this:isGrouped() and not this:isBotObject() end
},
},
diff --git a/ryzom/common/data_common/r2/r2_ui_displayer_npc.lua b/ryzom/common/data_common/r2/r2_ui_displayer_npc.lua
index 0f625e24e..2d0bbb70a 100644
--- a/ryzom/common/data_common/r2/r2_ui_displayer_npc.lua
+++ b/ryzom/common/data_common/r2/r2_ui_displayer_npc.lua
@@ -401,7 +401,8 @@ function r2:initTypeUI(instance)
if tostring(instance.TypeNPC)=="-1" then
-- TypeNPC
- r2:setNpcAttribute(instance.InstanceId, "TypeNPC", place)
+ debugInfo("FIXME: TypeNPC is not initialized, it should be a local value only as it's a convenience switch, verify against older versions");
+ r2.requestSetGhostNode(instance.InstanceId, "TypeNPC", place)
end
end
end
@@ -1245,7 +1246,7 @@ function r2:updateSex()
end
-- UPDATE SEX ---------------------------------------------------------------------------------
-function r2:updateType()
+function r2:updateType(existingAction)
local selection = r2:getSelectedInstance()
if selection == nil then return end
@@ -1256,7 +1257,9 @@ function r2:updateType()
local base = r2.sheetTypeCB[typeNPC].Id
local typeElement = r2.getPaletteElement(base)
- r2.requestNewAction(i18n.get("uiR2EDUpdateNpcTypeAction"))
+ if not existingAction then
+ r2.requestNewAction(i18n.get("uiR2EDUpdateNpcTypeAction"))
+ end
-- TypeNPC
r2:setNpcAttribute(selection.InstanceId, "TypeNPC", typeNPC)
@@ -1350,7 +1353,9 @@ function r2:updateType()
end
end
- r2.requestEndAction()
+ if not existingAction then
+ r2.requestEndAction()
+ end
end
-- UPDATE FUCNTION ----------------------------------------------------------------------------
@@ -1368,7 +1373,7 @@ function r2:updateFunction()
end
-- UPDATE LEVEL ------------------------------------------------------------------------------
-r2.updateLevel = function(value)
+r2.updateLevel = function(value, existingAction)
local selection = r2:getSelectedInstance()
assert(selection)
@@ -1380,7 +1385,9 @@ r2.updateLevel = function(value)
local firstPart = string.sub(sheet, 1, s-2)
local newSheet = firstPart .. level .. ".creature"
- r2.requestNewAction(i18n.get("uiR2EDUpdateNpcLevelAction"))
+ if not existingAction then
+ r2.requestNewAction(i18n.get("uiR2EDUpdateNpcLevelAction"))
+ end
r2:setNpcAttribute(selection.InstanceId, "Sheet", newSheet)
end
From f5553dfb59b9a3076c2d39b8c4355ae11aa6cb05 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Fri, 23 Oct 2020 00:38:22 +0800
Subject: [PATCH 009/205] Better handling of TypeNPC initialization,
kaetemi/ryzomclassic#87
---
ryzom/common/data_common/r2/r2_ui_displayer_npc.lua | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/ryzom/common/data_common/r2/r2_ui_displayer_npc.lua b/ryzom/common/data_common/r2/r2_ui_displayer_npc.lua
index 2d0bbb70a..cc4b12c33 100644
--- a/ryzom/common/data_common/r2/r2_ui_displayer_npc.lua
+++ b/ryzom/common/data_common/r2/r2_ui_displayer_npc.lua
@@ -399,9 +399,9 @@ function r2:initTypeUI(instance)
end
end
- if tostring(instance.TypeNPC)=="-1" then
- -- TypeNPC
- debugInfo("FIXME: TypeNPC is not initialized, it should be a local value only as it's a convenience switch, verify against older versions");
+ if instance.TypeNPC != place then
+ -- TypeNPC does not remain valid between versions, it actually shouldn't be saved...
+ debugInfo("Initialize or update TypeNPC");
r2.requestSetGhostNode(instance.InstanceId, "TypeNPC", place)
end
end
From a51597cf0ba59f8464bf8f2f0507a645e0efcfe1 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Fri, 23 Oct 2020 00:54:24 +0800
Subject: [PATCH 010/205] Typo, kaetemi/ryzomclassic#87
---
ryzom/common/data_common/r2/r2_ui_displayer_npc.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ryzom/common/data_common/r2/r2_ui_displayer_npc.lua b/ryzom/common/data_common/r2/r2_ui_displayer_npc.lua
index cc4b12c33..43b549b72 100644
--- a/ryzom/common/data_common/r2/r2_ui_displayer_npc.lua
+++ b/ryzom/common/data_common/r2/r2_ui_displayer_npc.lua
@@ -399,7 +399,7 @@ function r2:initTypeUI(instance)
end
end
- if instance.TypeNPC != place then
+ if instance.TypeNPC ~= place then
-- TypeNPC does not remain valid between versions, it actually shouldn't be saved...
debugInfo("Initialize or update TypeNPC");
r2.requestSetGhostNode(instance.InstanceId, "TypeNPC", place)
From 91a44fd5b5ff6e5f73b6a9bc3f4683f9e6fe1819 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Fri, 23 Oct 2020 03:32:55 +0800
Subject: [PATCH 011/205] Disable TypeNPC for now, kaetemi/ryzomclassic#154
---
ryzom/common/data_common/r2/r2_features_default.lua | 8 +++++---
ryzom/common/data_common/r2/r2_ui_displayer_npc.lua | 6 ++++--
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/ryzom/common/data_common/r2/r2_features_default.lua b/ryzom/common/data_common/r2/r2_features_default.lua
index 44afdc6c2..e1de396d2 100644
--- a/ryzom/common/data_common/r2/r2_features_default.lua
+++ b/ryzom/common/data_common/r2/r2_features_default.lua
@@ -405,9 +405,11 @@ local registerFeature = function ()
{Name="Aggro", Type="Number", Min="0", Max="120", DefaultValue="30", DefaultInBase=1,
Visible=function(this) return this:isGroupedAndLeader() or not this:isGrouped() and not this:isBotObject() end
},
- {Name="TypeNPC", Type="Number", WidgetStyle="EnumDropDown", SecondRequestFunc=function(value) r2:updateType(true) end,
- Enum= {}, Visible=true, DefaultValue="-1",
- },
+
+ -- FIXME: https://github.com/kaetemi/ryzomclassic/issues/154
+ --{Name="TypeNPC", Type="Number", WidgetStyle="EnumDropDown", SecondRequestFunc=function(value) r2:updateType(true) end,
+ -- Enum= {}, Visible=true, DefaultValue="-1",
+ --},
--
--
diff --git a/ryzom/common/data_common/r2/r2_ui_displayer_npc.lua b/ryzom/common/data_common/r2/r2_ui_displayer_npc.lua
index 43b549b72..5bc08e502 100644
--- a/ryzom/common/data_common/r2/r2_ui_displayer_npc.lua
+++ b/ryzom/common/data_common/r2/r2_ui_displayer_npc.lua
@@ -692,7 +692,8 @@ function npcPropertySheetDisplayerTable:onSelect(instance, isSelected)
r2:activeLogicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
- r2:initTypeUI(instance)
+ -- FIXME: https://github.com/kaetemi/ryzomclassic/issues/154
+ -- r2:initTypeUI(instance)
end
------------------------------------------------
@@ -1262,7 +1263,8 @@ function r2:updateType(existingAction)
end
-- TypeNPC
- r2:setNpcAttribute(selection.InstanceId, "TypeNPC", typeNPC)
+ -- FIXME: https://github.com/kaetemi/ryzomclassic/issues/154
+ -- r2:setNpcAttribute(selection.InstanceId, "TypeNPC", typeNPC)
-- RingAccess
r2:setNpcAttribute(selection.InstanceId, "RingAccess", typeElement.RingAccess)
From 5056d3a72a063e1fd120efe9185c97e2ade4e88a Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Fri, 23 Oct 2020 03:39:06 +0800
Subject: [PATCH 012/205] Disable CustomNpc Level prop for now,
kaetemi/ryzomclassic#154
---
ryzom/common/data_common/r2/r2_features_default.lua | 8 ++++----
ryzom/common/src/game_share/object.cpp | 4 ++--
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/ryzom/common/data_common/r2/r2_features_default.lua b/ryzom/common/data_common/r2/r2_features_default.lua
index e1de396d2..d6cbd7bda 100644
--- a/ryzom/common/data_common/r2/r2_features_default.lua
+++ b/ryzom/common/data_common/r2/r2_features_default.lua
@@ -859,10 +859,10 @@ local registerFeature = function ()
Enum= { "uiR2EDWalk", "uiR2EDRun"},
Visible=true
},
- {Name="Level", Type="Number", WidgetStyle="EnumDropDown", Category="uiR2EDRollout_NpcCustom",
- Enum= { "uiR2EDLowLevel", "uiR2EDAverageLevel", "uiR2EDHighLevel", "uiR2EDVeryHighLevel"}, SecondRequestFunc=function(value) r2.updateLevel(value, true) end,
- Visible=function(this) return this:isGroupedAndLeader() or not this:isGrouped() and not this:isBotObject() end
- },
+ --{Name="Level", Type="Number", WidgetStyle="EnumDropDown", Category="uiR2EDRollout_NpcCustom",
+ -- Enum= { "uiR2EDLowLevel", "uiR2EDAverageLevel", "uiR2EDHighLevel", "uiR2EDVeryHighLevel"}, SecondRequestFunc=function(value) r2.updateLevel(value, true) end,
+ -- Visible=function(this) return this:isGroupedAndLeader() or not this:isGrouped() and not this:isBotObject() end
+ --},
},
-- from "BaseClass"
getAvailableCommands = function(this, dest)
diff --git a/ryzom/common/src/game_share/object.cpp b/ryzom/common/src/game_share/object.cpp
index bb92c4936..bed87409e 100644
--- a/ryzom/common/src/game_share/object.cpp
+++ b/ryzom/common/src/game_share/object.cpp
@@ -2618,7 +2618,7 @@ CNpcSerializer::CNpcSerializer()
static const char* optionalProp[] = { "GabaritHeight", "GabaritTorsoWidth","GabaritArmsWidth", "GabaritLegsWidth", "GabaritBreastSize",
"HairType", "HairColor", "Tattoo", "EyesColor", "MorphTarget1", "MorphTarget2", "MorphTarget3", "MorphTarget4", "MorphTarget5",
"MorphTarget6", "MorphTarget7", "MorphTarget8", "Sex", "JacketModel", "TrouserModel", "FeetModel", "HandsModel", "ArmModel",
- "WeaponRightHand", "WeaponLeftHand", "JacketColor", "ArmColor", "HandsColor", "TrouserColor", "FeetColor", "Function","Level",
+ "WeaponRightHand", "WeaponLeftHand", "JacketColor", "ArmColor", "HandsColor", "TrouserColor", "FeetColor", "Function",
"Profile", "Speed", "Aggro", "PlayerAttackable", "BotAttackable" };
_ClassName = "Npc";
@@ -2654,7 +2654,7 @@ CNpcCustomSerializer::CNpcCustomSerializer()
"MorphTarget6", "MorphTarget7", "MorphTarget8", "JacketModel", "TrouserModel", "FeetModel", "HandsModel", "ArmModel",
"JacketColor", "ArmColor", "HandsColor", "TrouserColor", "FeetColor" };
static const char* optionalProp[] = {
- "Name", "Profile", "Speed", "Aggro", "PlayerAttackable", "BotAttackable", "Function", "Level", "WeaponRightHand", "WeaponLeftHand", "Sex" };
+ "Name", "Profile", "Speed", "Aggro", "PlayerAttackable", "BotAttackable", "Function", "WeaponRightHand", "WeaponLeftHand", "Sex" };
_ClassName = "NpcCustom";
_Type = ObjectTableNpcCustom;
From 8bf18d2e1da6ee7c57383bbf57d10326d5a6bfb4 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Fri, 23 Oct 2020 05:07:09 +0800
Subject: [PATCH 013/205] Improve error message, kaetemi/ryzomclassic#120
---
nel/include/nel/gui/lua_helper_inline.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/nel/include/nel/gui/lua_helper_inline.h b/nel/include/nel/gui/lua_helper_inline.h
index 0d380bbf1..5dbc3cef4 100644
--- a/nel/include/nel/gui/lua_helper_inline.h
+++ b/nel/include/nel/gui/lua_helper_inline.h
@@ -263,8 +263,8 @@ inline lua_Integer CLuaState::toInteger(int index)
if (!isnum)
{
lua_Number d = lua_tonumber(_State, index);
- nlwarning("Lua: Unable to convert Lua number %lf to integer", d);
res = (lua_Integer)d;
+ nlwarning("Lua: Converting lua_Number %lf to lua_Integer %i", d, (int)res);
}
return res;
#else
From 357bb28ef28ac24444fe2e8ee44cb5eeffa276d0 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Fri, 23 Oct 2020 05:37:46 +0800
Subject: [PATCH 014/205] Recycling an ucstring from i18n.get is not allowed,
it's const, fix kaetemi/ryzomclassic#134
---
ryzom/common/data_common/r2/r2_dialogs.lua | 6 ++++--
ryzom/common/data_common/r2/r2_ui_scenario.lua | 3 +--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/ryzom/common/data_common/r2/r2_dialogs.lua b/ryzom/common/data_common/r2/r2_dialogs.lua
index 286cf2a34..06d72d258 100644
--- a/ryzom/common/data_common/r2/r2_dialogs.lua
+++ b/ryzom/common/data_common/r2/r2_dialogs.lua
@@ -449,6 +449,7 @@ function r2.dialogs:updateElementEditor()
-- to who
local toWhoInst = r2:getInstanceFromId(tostring(instanceChat.Actions[0].Facing))
if toWhoInst then
+ uc_chat = ucstring()
uc_chat:fromUtf8(toWhoInst.Name)
else
uc_chat = i18n.get("uiR2EdNobody")
@@ -458,6 +459,7 @@ function r2.dialogs:updateElementEditor()
-- emote
local emoteName = self.fromEmoteIdToName[instanceChat.Actions[0].Emote]
if emoteName then
+ uc_chat = ucstring()
uc_chat:fromUtf8(emoteName)
else
uc_chat = i18n.get("uiR2EdNoElt")
@@ -469,8 +471,8 @@ function r2.dialogs:updateElementEditor()
uc_chat:fromUtf8(self.elementInitialName.." : ")
chatName.uc_hardtext = uc_chat
- minutesText.uc_hardtext = tostring(0)
- secondsText.uc_hardtext = tostring(0)
+ minutesText.uc_hardtext = "0"
+ secondsText.uc_hardtext = "0"
whoMenuText.uc_hardtext = ""
diff --git a/ryzom/common/data_common/r2/r2_ui_scenario.lua b/ryzom/common/data_common/r2/r2_ui_scenario.lua
index 5a925d9a4..4ed11ec63 100644
--- a/ryzom/common/data_common/r2/r2_ui_scenario.lua
+++ b/ryzom/common/data_common/r2/r2_ui_scenario.lua
@@ -598,9 +598,8 @@ function r2.ScenarioWindow:updateActProperties()
}
local season = actGr:find("season_name")
assert(season)
- local uc_season = ucstring()
local seasonStr = seasons[location.Season]
- uc_season:fromUtf8(i18n.get(seasonStr):toUtf8())
+ local uc_season = i18n.get(seasonStr)
season.uc_hardtext = uc_season
-- manual weather
From 8594b479e25cf3719754421fa407e5fda2b920bd Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Fri, 23 Oct 2020 23:56:23 +0800
Subject: [PATCH 015/205] Fix bad escaping of < and >, fix
kaetemi/ryzomclassic#150
---
ryzom/common/data_common/r2/r2_misc.lua | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ryzom/common/data_common/r2/r2_misc.lua b/ryzom/common/data_common/r2/r2_misc.lua
index 2402ff1fd..293e9b33c 100644
--- a/ryzom/common/data_common/r2/r2_misc.lua
+++ b/ryzom/common/data_common/r2/r2_misc.lua
@@ -191,9 +191,9 @@ end
-------------------------------------------------------------------------------------------------
-- enclose a string by double quotes
function strifyXml(str)
- local strxml = string.gsub(tostring(str), ">", ">")
+ local strxml = string.gsub(tostring(str), "&", "&")
strxml = string.gsub(strxml, "<", "<")
- strxml = string.gsub(strxml, "&", "&")
+ strxml = string.gsub(strxml, ">", ">")
strxml = string.gsub(strxml, "'", "'")
strxml = string.gsub(strxml, '"', """)
return [["]] .. strxml .. [["]]
From c4b142f770df2cbc4c2319c141f230708686aec2 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Fri, 23 Oct 2020 22:27:36 +0800
Subject: [PATCH 016/205] Load the Lua socket library dynamically if it's
available, necessary for MobDebug
---
nel/include/nel/gui/lua_helper.h | 4 +++
nel/src/gui/lua_helper.cpp | 53 ++++++++++++++++++++++++++++++--
2 files changed, 54 insertions(+), 3 deletions(-)
diff --git a/nel/include/nel/gui/lua_helper.h b/nel/include/nel/gui/lua_helper.h
index da5c33e6a..8a0f985a6 100644
--- a/nel/include/nel/gui/lua_helper.h
+++ b/nel/include/nel/gui/lua_helper.h
@@ -379,6 +379,10 @@ namespace NLGUI
TSmallScriptCache _SmallScriptCache;
static const char * _NELSmallScriptTableName;
+#ifdef _WIN32
+ HMODULE m_LuaSocket;
+#endif
+
private:
// this object isn't intended to be copied
CLuaState(const CLuaState &/* other */):NLMISC::CRefCount() { nlassert(0); }
diff --git a/nel/src/gui/lua_helper.cpp b/nel/src/gui/lua_helper.cpp
index d2b6a68d3..c27c6aeba 100644
--- a/nel/src/gui/lua_helper.cpp
+++ b/nel/src/gui/lua_helper.cpp
@@ -216,16 +216,55 @@ namespace NLGUI
// *** Load base libs
{
CLuaStackChecker lsc(this);
- #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501
+#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501
luaL_openlibs(_State);
- #else
+#else
luaopen_base (_State);
luaopen_table (_State);
luaopen_io (_State);
luaopen_string (_State);
luaopen_math (_State);
luaopen_debug (_State);
- #endif
+#endif
+
+#ifdef _WIN32
+ // Lua socket library for MobDebug, optional
+ if (NLMISC::CFile::fileExists("socket\\core.dll"))
+ {
+ // Load socket\core.dll dynamically
+ m_LuaSocket = LoadLibraryW(L"socket\\core.dll");
+ if (!m_LuaSocket)
+ {
+ nlwarning("Lua socket library found, but failed to load");
+ }
+ else
+ {
+ void *luaopen_socket_core = (void *)GetProcAddress(m_LuaSocket, "luaopen_socket_core");
+ if (!luaopen_socket_core)
+ {
+ nlwarning("Lua socket library loaded, but `luaopen_socket_core` not found");
+ FreeLibrary(m_LuaSocket);
+ m_LuaSocket = NULL;
+ }
+ else
+ {
+ // preload['socket.core'] = luaopen_socket_core
+#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501
+ lua_getglobal(_State, "package");
+ lua_getfield(_State, -1, "preload");
+ lua_pushcfunction(_State, (lua_CFunction)luaopen_socket_core);
+ lua_setfield(_State, -2, "socket.core");
+ lua_pop(_State, 2);
+ nlinfo("Lua socket library preloaded");
+#endif
+ }
+ }
+ }
+ else
+ {
+ m_LuaSocket = NULL;
+ }
+#endif
// open are buggy????
clear();
@@ -313,6 +352,14 @@ namespace NLGUI
// Clear Small Script Cache
_SmallScriptPool= 0;
_SmallScriptCache.clear();
+
+#ifdef _WIN32
+ if (m_LuaSocket)
+ {
+ FreeLibrary(m_LuaSocket);
+ m_LuaSocket = NULL;
+ }
+#endif
}
// ***************************************************************************
From 6531fb0a2eb1e40f4cd792de0916b8203ae1b8b2 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Fri, 23 Oct 2020 23:18:20 +0800
Subject: [PATCH 017/205] Lua debugger requires properly standardized paths
---
nel/src/gui/lua_helper.cpp | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/nel/src/gui/lua_helper.cpp b/nel/src/gui/lua_helper.cpp
index c27c6aeba..a07ba3b71 100644
--- a/nel/src/gui/lua_helper.cpp
+++ b/nel/src/gui/lua_helper.cpp
@@ -511,7 +511,23 @@ namespace NLGUI
// execute the script text, with dbgSrc==filename (use @ for lua internal purpose)
- executeScriptInternal(script, string("@") + CFile::getFilename(pathName));
+#ifdef _WIN32
+ // Paths need to be correct for debugging to work
+ std::string pathNameStandardized = pathName;
+ if (pathNameStandardized.size() > 1)
+ {
+ if (pathNameStandardized[1] == ':' && pathNameStandardized[0] >= 'a' && pathNameStandardized[0] <= 'z')
+ pathNameStandardized[0] -= 'a' - 'A';
+ for (ptrdiff_t i = 0; i < (ptrdiff_t)pathNameStandardized.size(); ++i)
+ {
+ if (pathNameStandardized[i] == '/')
+ pathNameStandardized[i] = '\\';
+ }
+ }
+#else
+ const std::string &pathNameStandardized = pathName;
+#endif
+ executeScriptInternal(script, string("@") + pathNameStandardized);
return true;
}
From d2900df0f6d8f1636cc18d59935ef86f118090c7 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sat, 24 Oct 2020 00:32:47 +0800
Subject: [PATCH 018/205] Add debug break hook for Lua
---
ryzom/common/data_common/r2/r2_debug.lua | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/ryzom/common/data_common/r2/r2_debug.lua b/ryzom/common/data_common/r2/r2_debug.lua
index 78501dcab..f32a75017 100644
--- a/ryzom/common/data_common/r2/r2_debug.lua
+++ b/ryzom/common/data_common/r2/r2_debug.lua
@@ -132,6 +132,11 @@ end
-- INIT --
----------
+if debugBreak == nil then
+ -- replace this at runtime with the debugger break functions
+ debugBreak = function()
+ end
+end
-- replace the assert function with a more verbose one
if oldAssert == nil then
@@ -142,7 +147,8 @@ function assert(cond)
if not cond then
-- rawDebugInfo(colorTag(255, 0, 255) .. "ASSERTION FAILED !! ")
rawDebugInfo("@{FOFF}ASSERTION FAILED !! ")
- dumpCallStack(2);
+ dumpCallStack(2)
+ debugBreak()
error("")
end
end
From 9580bd5ec07433de1a07022ab1dfed7d0a2dbcb4 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sat, 24 Oct 2020 01:27:02 +0800
Subject: [PATCH 019/205] Failed to detect ecosystem of selected island, fix
missing plants in palette, kaetemi/ryzomclassic#132
---
ryzom/common/data_common/r2/r2_ui_acts.lua | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/ryzom/common/data_common/r2/r2_ui_acts.lua b/ryzom/common/data_common/r2/r2_ui_acts.lua
index 51b7675df..37edb9325 100644
--- a/ryzom/common/data_common/r2/r2_ui_acts.lua
+++ b/ryzom/common/data_common/r2/r2_ui_acts.lua
@@ -1240,9 +1240,11 @@ function r2.acts:updatePaletteFromEcosystem()
-- search for ecosystem of current location
local islandEcosystem
for ecoName, v in pairs(self.islands) do
- if self.islands[ecoName][self:getIslandNb(currentLocation.IslandName)].name==currentLocation.IslandName then
- islandEcosystem = ecoName
- break
+ if self.islands[ecoName][self:getIslandNb(currentLocation.IslandName)] then
+ if self.islands[ecoName][self:getIslandNb(currentLocation.IslandName)].name==currentLocation.IslandName then
+ islandEcosystem = ecoName
+ break
+ end
end
end
From bbf4a0ac8a0eb676f87de8a04b97e4986fc1d399 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sat, 24 Oct 2020 01:25:20 +0800
Subject: [PATCH 020/205] Fix editor not returning to initial act,
kaetemi/ryzomclassic#80
---
ryzom/client/src/r2/editor.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ryzom/client/src/r2/editor.cpp b/ryzom/client/src/r2/editor.cpp
index 457cee562..8e146e9ad 100644
--- a/ryzom/client/src/r2/editor.cpp
+++ b/ryzom/client/src/r2/editor.cpp
@@ -5785,7 +5785,7 @@ void CEditor::scenarioUpdated(CObject* highLevel, bool willTP, uint32 initialAct
}
//
projectInLua(_Scenario); // push on the lua stack
- getLua().push(float(initialActIndex)); // example reconnect after test in act4
+ getLua().push(initialActIndex); // example reconnect after test in act4
// update value in the framework
callEnvFunc("onScenarioUpdated", 2);
//nlwarning("Instance list now is :");
From a2b68113ecf63e241216c5f159bbb318f9632d86 Mon Sep 17 00:00:00 2001
From: Xtarsia <69606701+Xtarsia@users.noreply.github.com>
Date: Fri, 23 Oct 2020 21:54:17 +0100
Subject: [PATCH 021/205] Remove Patcher UI elements
Remove Patcher UI elements
---
ryzom/client/data/gamedev/interfaces_v3/actions.xml | 1 -
ryzom/client/data/gamedev/interfaces_v3/config.xml | 1 -
ryzom/client/data/gamedev/interfaces_v3/taskbar.xml | 8 --------
3 files changed, 10 deletions(-)
diff --git a/ryzom/client/data/gamedev/interfaces_v3/actions.xml b/ryzom/client/data/gamedev/interfaces_v3/actions.xml
index 42c931e29..c74007a79 100644
--- a/ryzom/client/data/gamedev/interfaces_v3/actions.xml
+++ b/ryzom/client/data/gamedev/interfaces_v3/actions.xml
@@ -58,7 +58,6 @@
-
diff --git a/ryzom/client/data/gamedev/interfaces_v3/config.xml b/ryzom/client/data/gamedev/interfaces_v3/config.xml
index 2f7b6d0f4..d14d799ef 100644
--- a/ryzom/client/data/gamedev/interfaces_v3/config.xml
+++ b/ryzom/client/data/gamedev/interfaces_v3/config.xml
@@ -1639,7 +1639,6 @@ This MUST follow the Enum MISSION_DESC::TIconId
-
diff --git a/ryzom/client/data/gamedev/interfaces_v3/taskbar.xml b/ryzom/client/data/gamedev/interfaces_v3/taskbar.xml
index 7c23dd607..4d30e0be4 100644
--- a/ryzom/client/data/gamedev/interfaces_v3/taskbar.xml
+++ b/ryzom/client/data/gamedev/interfaces_v3/taskbar.xml
@@ -818,11 +818,6 @@
-
-
-
@@ -1158,9 +1153,6 @@
-
-
From 3dddc5ab4062b89c55cfbf6c35eb456a7fc54ff6 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sat, 24 Oct 2020 03:57:15 +0800
Subject: [PATCH 022/205] Move ucstring utf8 implementation to header
---
nel/include/nel/misc/ucstring.h | 132 +--------------------------
nel/src/misc/ucstring.cpp | 152 ++++++++++++++++++++++++++++++++
2 files changed, 155 insertions(+), 129 deletions(-)
create mode 100644 nel/src/misc/ucstring.cpp
diff --git a/nel/include/nel/misc/ucstring.h b/nel/include/nel/misc/ucstring.h
index b3dc1294f..8cedb04ec 100644
--- a/nel/include/nel/misc/ucstring.h
+++ b/nel/include/nel/misc/ucstring.h
@@ -149,43 +149,7 @@ public:
}
/// Convert this ucstring (16bits char) into a utf8 string
- std::string toUtf8() const
- {
- std::string res;
- ucstring::const_iterator first(begin()), last(end());
- for (; first != last; ++first)
- {
- //ucchar c = *first;
- uint nbLoop = 0;
- if (*first < 0x80)
- res += char(*first);
- else if (*first < 0x800)
- {
- ucchar c = *first;
- c = c >> 6;
- c = c & 0x1F;
- res += char(c) | 0xC0;
- nbLoop = 1;
- }
- else /*if (*first < 0x10000)*/
- {
- ucchar c = *first;
- c = c >> 12;
- c = c & 0x0F;
- res += char(c) | 0xE0;
- nbLoop = 2;
- }
-
- for (uint i=0; i> ((nbLoop - i - 1) * 6);
- c = c & 0x3F;
- res += char(c) | 0x80;
- }
- }
- return res;
- }
+ std::string toUtf8() const;
ucstring substr(size_type pos = 0, size_type n = npos) const
{
@@ -199,86 +163,7 @@ public:
}
/// Convert the utf8 string into this ucstring (16 bits char)
- void fromUtf8(const std::string &stringUtf8)
- {
- // clear the string
- erase();
-
- uint8 c;
- ucchar code;
- sint iterations = 0;
-
- std::string::const_iterator first(stringUtf8.begin()), last(stringUtf8.end());
- for (; first != last; )
- {
- c = *first++;
- code = c;
-
- if ((code & 0xFE) == 0xFC)
- {
- code &= 0x01;
- iterations = 5;
- }
- else if ((code & 0xFC) == 0xF8)
- {
- code &= 0x03;
- iterations = 4;
- }
- else if ((code & 0xF8) == 0xF0)
- {
- code &= 0x07;
- iterations = 3;
- }
- else if ((code & 0xF0) == 0xE0)
- {
- code &= 0x0F;
- iterations = 2;
- }
- else if ((code & 0xE0) == 0xC0)
- {
- code &= 0x1F;
- iterations = 1;
- }
- else if ((code & 0x80) == 0x80)
- {
- // If it's not a valid UTF8 string, just copy the line without utf8 conversion
- rawCopy(stringUtf8);
- return;
- }
- else
- {
- push_back(code);
- iterations = 0;
- }
-
- if (iterations)
- {
- for (sint i = 0; i < iterations; i++)
- {
- if (first == last)
- {
- // If it's not a valid UTF8 string, just copy the line without utf8 conversion
- rawCopy(stringUtf8);
- return;
- }
-
- uint8 ch;
- ch = *first ++;
-
- if ((ch & 0xC0) != 0x80)
- {
- // If it's not a valid UTF8 string, just copy the line without utf8 conversion
- rawCopy(stringUtf8);
- return;
- }
-
- code <<= 6;
- code |= (ucchar)(ch & 0x3F);
- }
- push_back(code);
- }
- }
- }
+ void fromUtf8(const std::string &stringUtf8);
static ucstring makeFromUtf8(const std::string &stringUtf8)
{
@@ -289,19 +174,8 @@ public:
}
private:
+ void rawCopy(const std::string &str);
- void rawCopy(const std::string &str)
- {
- // We need to convert the char into 8bits unsigned int before promotion to 16 bits
- // otherwise, as char are signed on some compiler (MSCV for ex), the sign bit is extended to 16 bits.
- resize(str.size());
- std::string::const_iterator first(str.begin()), last(str.end());
- iterator dest(begin());
- for (;first != last; ++first, ++dest)
- {
- *dest = uint8(*first);
- }
- }
};
inline ucstring operator+(const ucstringbase &ucstr, ucchar c)
diff --git a/nel/src/misc/ucstring.cpp b/nel/src/misc/ucstring.cpp
new file mode 100644
index 000000000..5d7112114
--- /dev/null
+++ b/nel/src/misc/ucstring.cpp
@@ -0,0 +1,152 @@
+// NeL - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+#include "stdmisc.h"
+#include "nel/misc/ucstring.h"
+
+std::string ucstring::toUtf8() const
+{
+ std::string res;
+ ucstring::const_iterator first(begin()), last(end());
+ for (; first != last; ++first)
+ {
+ //ucchar c = *first;
+ uint nbLoop = 0;
+ if (*first < 0x80)
+ res += char(*first);
+ else if (*first < 0x800)
+ {
+ ucchar c = *first;
+ c = c >> 6;
+ c = c & 0x1F;
+ res += char(c) | 0xC0;
+ nbLoop = 1;
+ }
+ else /*if (*first < 0x10000)*/
+ {
+ ucchar c = *first;
+ c = c >> 12;
+ c = c & 0x0F;
+ res += char(c) | 0xE0;
+ nbLoop = 2;
+ }
+
+ for (uint i=0; i> ((nbLoop - i - 1) * 6);
+ c = c & 0x3F;
+ res += char(c) | 0x80;
+ }
+ }
+ return res;
+}
+
+void ucstring::fromUtf8(const std::string &stringUtf8)
+{
+ // clear the string
+ erase();
+
+ uint8 c;
+ ucchar code;
+ sint iterations = 0;
+
+ std::string::const_iterator first(stringUtf8.begin()), last(stringUtf8.end());
+ for (; first != last; )
+ {
+ c = *first++;
+ code = c;
+
+ if ((code & 0xFE) == 0xFC)
+ {
+ code &= 0x01;
+ iterations = 5;
+ }
+ else if ((code & 0xFC) == 0xF8)
+ {
+ code &= 0x03;
+ iterations = 4;
+ }
+ else if ((code & 0xF8) == 0xF0)
+ {
+ code &= 0x07;
+ iterations = 3;
+ }
+ else if ((code & 0xF0) == 0xE0)
+ {
+ code &= 0x0F;
+ iterations = 2;
+ }
+ else if ((code & 0xE0) == 0xC0)
+ {
+ code &= 0x1F;
+ iterations = 1;
+ }
+ else if ((code & 0x80) == 0x80)
+ {
+ // If it's not a valid UTF8 string, just copy the line without utf8 conversion
+ rawCopy(stringUtf8);
+ return;
+ }
+ else
+ {
+ push_back(code);
+ iterations = 0;
+ }
+
+ if (iterations)
+ {
+ for (sint i = 0; i < iterations; i++)
+ {
+ if (first == last)
+ {
+ // If it's not a valid UTF8 string, just copy the line without utf8 conversion
+ rawCopy(stringUtf8);
+ return;
+ }
+
+ uint8 ch;
+ ch = *first ++;
+
+ if ((ch & 0xC0) != 0x80)
+ {
+ // If it's not a valid UTF8 string, just copy the line without utf8 conversion
+ rawCopy(stringUtf8);
+ return;
+ }
+
+ code <<= 6;
+ code |= (ucchar)(ch & 0x3F);
+ }
+ push_back(code);
+ }
+ }
+}
+
+void ucstring::rawCopy(const std::string &str)
+{
+ // We need to convert the char into 8bits unsigned int before promotion to 16 bits
+ // otherwise, as char are signed on some compiler (MSCV for ex), the sign bit is extended to 16 bits.
+ resize(str.size());
+ std::string::const_iterator first(str.begin()), last(str.end());
+ iterator dest(begin());
+ for (;first != last; ++first, ++dest)
+ {
+ *dest = uint8(*first);
+ }
+}
+
+/* end of file */
From 1300d5d4d4efd188ebfca26fb9cc31b8d6a388ce Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sat, 24 Oct 2020 04:02:02 +0800
Subject: [PATCH 023/205] Move ucstring utf8 implementation to header
---
nel/include/nel/misc/ucstring.h | 12 +-----------
nel/src/misc/ucstring.cpp | 12 ++++++++++++
2 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/nel/include/nel/misc/ucstring.h b/nel/include/nel/misc/ucstring.h
index 8cedb04ec..5f0616d8f 100644
--- a/nel/include/nel/misc/ucstring.h
+++ b/nel/include/nel/misc/ucstring.h
@@ -128,17 +128,7 @@ public:
}
/// Converts the controlled ucstring to a string str
- void toString (std::string &str) const
- {
- str.resize (size ());
- for (uint i = 0; i < str.size (); i++)
- {
- if (operator[](i) > 255)
- str[i] = '?';
- else
- str[i] = (char) operator[](i);
- }
- }
+ void toString(std::string &str) const;
/// Converts the controlled ucstring and returns the resulting string
std::string toString () const
diff --git a/nel/src/misc/ucstring.cpp b/nel/src/misc/ucstring.cpp
index 5d7112114..df8f52406 100644
--- a/nel/src/misc/ucstring.cpp
+++ b/nel/src/misc/ucstring.cpp
@@ -17,6 +17,18 @@
#include "stdmisc.h"
#include "nel/misc/ucstring.h"
+void ucstring::toString(std::string &str) const
+{
+ str.resize(size());
+ for (uint i = 0; i < str.size (); i++)
+ {
+ if (operator[](i) > 255)
+ str[i] = '?';
+ else
+ str[i] = (char) operator[](i);
+ }
+}
+
std::string ucstring::toUtf8() const
{
std::string res;
From dd281306178fa10451569341b60e6e62d1c9bbeb Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sat, 24 Oct 2020 04:17:36 +0800
Subject: [PATCH 024/205] Format ucstring source
---
nel/include/nel/misc/ucstring.h | 119 +++++++++++++++++---------------
nel/src/misc/ucstring.cpp | 16 ++---
2 files changed, 70 insertions(+), 65 deletions(-)
diff --git a/nel/include/nel/misc/ucstring.h b/nel/include/nel/misc/ucstring.h
index 5f0616d8f..28afcdb9a 100644
--- a/nel/include/nel/misc/ucstring.h
+++ b/nel/include/nel/misc/ucstring.h
@@ -35,95 +35,98 @@ typedef std::basic_string ucstringbase;
class ucstring : public ucstringbase
{
public:
+ ucstring() { }
- ucstring () {}
-
- ucstring (const ucstringbase &str) : ucstringbase (str) {}
+ ucstring(const ucstringbase &str)
+ : ucstringbase(str)
+ {
+ }
- ucstring (const std::string &str) : ucstringbase ()
+ ucstring(const std::string &str)
+ : ucstringbase()
{
rawCopy(str);
}
- ~ucstring () {}
+ ~ucstring() { }
- ucstring &operator= (ucchar c)
+ ucstring &operator=(ucchar c)
{
- resize (1);
+ resize(1);
operator[](0) = c;
return *this;
}
- ucstring &operator= (const char *str)
+ ucstring &operator=(const char *str)
{
- resize (strlen (str));
- for (uint i = 0; i < strlen (str); i++)
+ resize(strlen(str));
+ for (uint i = 0; i < strlen(str); i++)
{
operator[](i) = uint8(str[i]);
}
return *this;
}
- ucstring &operator= (const std::string &str)
+ ucstring &operator=(const std::string &str)
{
- resize (str.size ());
- for (uint i = 0; i < str.size (); i++)
+ resize(str.size());
+ for (uint i = 0; i < str.size(); i++)
{
operator[](i) = uint8(str[i]);
}
return *this;
}
- ucstring &operator= (const ucstringbase &str)
+ ucstring &operator=(const ucstringbase &str)
{
- ucstringbase::operator =(str);
+ ucstringbase::operator=(str);
return *this;
}
- ucstring& operator= (const ucchar *str)
+ ucstring &operator=(const ucchar *str)
{
- ucstringbase::operator =(str);
+ ucstringbase::operator=(str);
return *this;
}
- ucstring &operator+= (ucchar c)
+ ucstring &operator+=(ucchar c)
{
- resize (size() + 1);
- operator[](size()-1) = c;
+ resize(size() + 1);
+ operator[](size() - 1) = c;
return *this;
}
- ucstring &operator+= (const char *str)
+ ucstring &operator+=(const char *str)
{
size_t s = size();
- resize (s + strlen(str));
+ resize(s + strlen(str));
for (uint i = 0; i < strlen(str); i++)
{
- operator[](s+i) = uint8(str[i]);
+ operator[](s + i) = uint8(str[i]);
}
return *this;
}
- ucstring &operator+= (const std::string &str)
+ ucstring &operator+=(const std::string &str)
{
size_t s = size();
- resize (s + str.size());
+ resize(s + str.size());
for (uint i = 0; i < str.size(); i++)
{
- operator[](s+i) = uint8(str[i]);
+ operator[](s + i) = uint8(str[i]);
}
return *this;
}
- ucstring &operator+= (const ucstringbase &str)
+ ucstring &operator+=(const ucstringbase &str)
{
- ucstringbase::operator +=(str);
+ ucstringbase::operator+=(str);
return *this;
}
const ucchar *c_str() const
{
const ucchar *tmp = ucstringbase::c_str();
- const_cast(tmp)[size()] = 0;
+ const_cast(tmp)[size()] = 0;
return tmp;
}
@@ -131,7 +134,7 @@ public:
void toString(std::string &str) const;
/// Converts the controlled ucstring and returns the resulting string
- std::string toString () const
+ std::string toString() const
{
std::string str;
toString(str);
@@ -165,70 +168,72 @@ public:
private:
void rawCopy(const std::string &str);
-
};
inline ucstring operator+(const ucstringbase &ucstr, ucchar c)
{
- ucstring ret;
- ret= ucstr;
- ret+= c;
+ ucstring ret;
+ ret = ucstr;
+ ret += c;
return ret;
}
inline ucstring operator+(const ucstringbase &ucstr, const char *c)
{
- ucstring ret;
- ret= ucstr;
- ret+= c;
+ ucstring ret;
+ ret = ucstr;
+ ret += c;
return ret;
}
inline ucstring operator+(const ucstringbase &ucstr, const std::string &c)
{
- ucstring ret;
- ret= ucstr;
- ret+= c;
+ ucstring ret;
+ ret = ucstr;
+ ret += c;
return ret;
}
inline ucstring operator+(ucchar c, const ucstringbase &ucstr)
{
- ucstring ret;
- ret= c;
+ ucstring ret;
+ ret = c;
ret += ucstr;
return ret;
}
inline ucstring operator+(const char *c, const ucstringbase &ucstr)
{
- ucstring ret;
- ret= c;
+ ucstring ret;
+ ret = c;
ret += ucstr;
return ret;
}
inline ucstring operator+(const std::string &c, const ucstringbase &ucstr)
{
- ucstring ret;
- ret= c;
+ ucstring ret;
+ ret = c;
ret += ucstr;
return ret;
}
-namespace NLMISC
-{
+namespace NLMISC {
// Traits for hash_map using CEntityId
struct CUCStringHashMapTraits
{
- enum { bucket_size = 4, min_buckets = 8 };
+ enum
+ {
+ bucket_size = 4,
+ min_buckets = 8
+ };
CUCStringHashMapTraits() { }
- size_t operator() (const ucstring &id ) const
+ size_t operator()(const ucstring &id) const
{
return id.size();
}
- bool operator() (const ucstring &id1, const ucstring &id2) const
+ bool operator()(const ucstring &id1, const ucstring &id2) const
{
return id1 < id2;
}
@@ -239,18 +244,18 @@ struct CUCStringHashMapTraits
* \param a string or a char to transform to lower case
*/
-ucstring toLower (const ucstring &str);
-void toLower (ucchar *str);
-ucchar toLower (ucchar c);
+ucstring toLower(const ucstring &str);
+void toLower(ucchar *str);
+ucchar toLower(ucchar c);
/** Convert an unicode string in upper case.
* Characters with accent are converted in a uppercase character without accent
* \param a string or a char to transform to upper case
*/
-ucstring toUpper (const ucstring &str);
-void toUpper (ucchar *str);
-ucchar toUpper (ucchar c);
+ucstring toUpper(const ucstring &str);
+void toUpper(ucchar *str);
+ucchar toUpper(ucchar c);
};
diff --git a/nel/src/misc/ucstring.cpp b/nel/src/misc/ucstring.cpp
index df8f52406..8f81cbea1 100644
--- a/nel/src/misc/ucstring.cpp
+++ b/nel/src/misc/ucstring.cpp
@@ -20,18 +20,18 @@
void ucstring::toString(std::string &str) const
{
str.resize(size());
- for (uint i = 0; i < str.size (); i++)
+ for (uint i = 0; i < str.size(); i++)
{
if (operator[](i) > 255)
str[i] = '?';
else
- str[i] = (char) operator[](i);
+ str[i] = (char)operator[](i);
}
}
std::string ucstring::toUtf8() const
{
- std::string res;
+ std::string res;
ucstring::const_iterator first(begin()), last(end());
for (; first != last; ++first)
{
@@ -56,9 +56,9 @@ std::string ucstring::toUtf8() const
nbLoop = 2;
}
- for (uint i=0; i> ((nbLoop - i - 1) * 6);
c = c & 0x3F;
res += char(c) | 0x80;
@@ -77,7 +77,7 @@ void ucstring::fromUtf8(const std::string &stringUtf8)
sint iterations = 0;
std::string::const_iterator first(stringUtf8.begin()), last(stringUtf8.end());
- for (; first != last; )
+ for (; first != last;)
{
c = *first++;
code = c;
@@ -131,7 +131,7 @@ void ucstring::fromUtf8(const std::string &stringUtf8)
}
uint8 ch;
- ch = *first ++;
+ ch = *first++;
if ((ch & 0xC0) != 0x80)
{
@@ -155,7 +155,7 @@ void ucstring::rawCopy(const std::string &str)
resize(str.size());
std::string::const_iterator first(str.begin()), last(str.end());
iterator dest(begin());
- for (;first != last; ++first, ++dest)
+ for (; first != last; ++first, ++dest)
{
*dest = uint8(*first);
}
From 771248fcf4e021ba6e1fca9afd39f119de7bb6ca Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sat, 24 Oct 2020 04:18:25 +0800
Subject: [PATCH 025/205] Use platform implementation in ucstring for UTF-8
conversion on Windows to get valid UTF-16
---
nel/include/nel/misc/stream.h | 7 +++++++
nel/include/nel/misc/types_nl.h | 4 ++++
nel/include/nel/misc/ucstring.h | 4 ++++
nel/src/misc/seven_zip.cpp | 4 ++--
nel/src/misc/string_common.cpp | 2 +-
nel/src/misc/ucstring.cpp | 17 +++++++++++++++++
6 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/nel/include/nel/misc/stream.h b/nel/include/nel/misc/stream.h
index 89db78a1c..35b6c3f26 100644
--- a/nel/include/nel/misc/stream.h
+++ b/nel/include/nel/misc/stream.h
@@ -300,6 +300,13 @@ public:
virtual void serial(bool &b) ;
#ifndef NL_OS_CYGWIN
virtual void serial(char &b) ;
+#endif
+#ifdef NL_OS_WINDOWS
+ inline void serial(wchar_t &b)
+ {
+ nlctassert(sizeof(wchar_t) == sizeof(uint16));
+ serial(reinterpret_cast(b));
+ }
#endif
virtual void serial(std::string &b) ;
virtual void serial(ucstring &b) ;
diff --git a/nel/include/nel/misc/types_nl.h b/nel/include/nel/misc/types_nl.h
index 445882c34..73c05b3a5 100644
--- a/nel/include/nel/misc/types_nl.h
+++ b/nel/include/nel/misc/types_nl.h
@@ -546,7 +546,11 @@ template<> struct hash
* \typedef ucchar
* An Unicode character (16 bits)
*/
+#if defined(NL_OS_WINDOWS)
+typedef wchar_t ucchar;
+#else
typedef uint16 ucchar;
+#endif
#ifndef NL_OVERRIDE
#define NL_OVERRIDE override
diff --git a/nel/include/nel/misc/ucstring.h b/nel/include/nel/misc/ucstring.h
index 28afcdb9a..8859a21d9 100644
--- a/nel/include/nel/misc/ucstring.h
+++ b/nel/include/nel/misc/ucstring.h
@@ -30,7 +30,11 @@
* An unicode string class (16 bits per character).
* Add features to convert and assign \c ucstring to \c string and \c string to \c ucstring.
*/
+#if defined(NL_OS_WINDOWS)
+typedef std::wstring ucstringbase;
+#else
typedef std::basic_string ucstringbase;
+#endif
class ucstring : public ucstringbase
{
diff --git a/nel/src/misc/seven_zip.cpp b/nel/src/misc/seven_zip.cpp
index ff226af7d..ad07bf3cc 100644
--- a/nel/src/misc/seven_zip.cpp
+++ b/nel/src/misc/seven_zip.cpp
@@ -172,8 +172,8 @@ bool unpack7Zip(const std::string &sevenZipFile, const std::string &destFileName
filename.resize(nameLen);
// write filename into ucstring
- SzArEx_GetFileNameUtf16(&db, 0, &filename[0]);
-
+ SzArEx_GetFileNameUtf16(&db, 0, reinterpret_cast(&filename[0]));
+
// write the extracted file
FILE *outputHandle = nlfopen(destFileName, "wb+");
diff --git a/nel/src/misc/string_common.cpp b/nel/src/misc/string_common.cpp
index a0fb40942..93122cc70 100644
--- a/nel/src/misc/string_common.cpp
+++ b/nel/src/misc/string_common.cpp
@@ -244,7 +244,7 @@ std::wstring utf8ToWide(const char *str, size_t len)
#if defined(NL_OS_WINDOWS)
return winCpToWide(str, len, CP_UTF8);
#else
- // TODO: UTF-32 to UTF-8
+ // TODO: UTF-8 to UTF-32
nlassert(false);
#endif
}
diff --git a/nel/src/misc/ucstring.cpp b/nel/src/misc/ucstring.cpp
index 8f81cbea1..5fad643ce 100644
--- a/nel/src/misc/ucstring.cpp
+++ b/nel/src/misc/ucstring.cpp
@@ -31,6 +31,12 @@ void ucstring::toString(std::string &str) const
std::string ucstring::toUtf8() const
{
+#if defined(NL_OS_WINDOWS)
+ // Use OS implementation
+ nlctassert(sizeof(wchar_t) == sizeof(ucchar));
+ nlctassert(sizeof(wchar_t) == sizeof(uint16));
+ return NLMISC::wideToUtf8(static_cast(*this));
+#else
std::string res;
ucstring::const_iterator first(begin()), last(end());
for (; first != last; ++first)
@@ -65,10 +71,20 @@ std::string ucstring::toUtf8() const
}
}
return res;
+#endif
}
void ucstring::fromUtf8(const std::string &stringUtf8)
{
+#if defined(NL_OS_WINDOWS)
+ // Use OS implementation
+ nlctassert(sizeof(wchar_t) == sizeof(ucchar));
+ nlctassert(sizeof(wchar_t) == sizeof(uint16));
+ nlctassert(sizeof(std::wstring) == sizeof(ucstring)); // These can be swapped on Windows
+ static_cast(*this) = nlmove(NLMISC::utf8ToWide(stringUtf8));
+ if (stringUtf8.size() && !size())
+ rawCopy(stringUtf8);
+#else
// clear the string
erase();
@@ -146,6 +162,7 @@ void ucstring::fromUtf8(const std::string &stringUtf8)
push_back(code);
}
}
+#endif
}
void ucstring::rawCopy(const std::string &str)
From 8be138931d8d14d5bb3c026cf839ce6412df92ef Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sat, 24 Oct 2020 04:33:08 +0800
Subject: [PATCH 026/205] Fix pCB NULL
---
ryzom/client/src/login.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/ryzom/client/src/login.cpp b/ryzom/client/src/login.cpp
index cb6117744..2da407ecb 100644
--- a/ryzom/client/src/login.cpp
+++ b/ryzom/client/src/login.cpp
@@ -1211,9 +1211,10 @@ void initShardDisplay()
{
CCtrlButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_SHARD ":s0:but"));
if (pCB != NULL)
+ {
pCB->setPushed(true);
- CAHManager::getInstance()->runActionHandler (pCB->getActionOnLeftClick(), pCB, pCB->getParamsOnLeftClick());
-
+ CAHManager::getInstance()->runActionHandler(pCB->getActionOnLeftClick(), pCB, pCB->getParamsOnLeftClick());
+ }
}
pList->invalidateCoords();
}
From 0367e4f7c3adc0db9e762716f00d3dad334703c3 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sat, 24 Oct 2020 04:35:18 +0800
Subject: [PATCH 027/205] Fix build warnings
---
ryzom/common/src/game_share/visual_slot_manager.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ryzom/common/src/game_share/visual_slot_manager.h b/ryzom/common/src/game_share/visual_slot_manager.h
index 4fd46cd81..135e729a8 100644
--- a/ryzom/common/src/game_share/visual_slot_manager.h
+++ b/ryzom/common/src/game_share/visual_slot_manager.h
@@ -53,7 +53,7 @@ public:
static void releaseInstance();
public:
- typedef struct
+ typedef struct TElement
{
uint32 Index;
NLMISC::CSheetId SheetId;
@@ -66,7 +66,7 @@ public:
}
} TElement;
- typedef struct
+ typedef struct TElementList
{
// elements list for a visual slot.
std::vector Element;
From 9896eae64d55585ff6a94109c3736da5816eb0b8 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sat, 24 Oct 2020 06:05:22 +0800
Subject: [PATCH 028/205] Fix build warnings
---
.../3d/driver/direct3d/driver_direct3d.cpp | 2 +-
.../driver_opengl_vertex_buffer_hard.cpp | 9 +-
nel/src/3d/render_trav.cpp | 2 +-
nel/src/3d/scene.cpp | 4 +-
nel/src/3d/shadow_map_manager.cpp | 4 +-
nel/src/3d/shape_bank.cpp | 3 +-
nel/src/3d/surface_light_grid.cpp | 23 ++---
nel/src/3d/tessellation.cpp | 6 ++
nel/src/gui/group_header.cpp | 21 +++--
nel/src/logic/logic_state_machine.cpp | 2 +-
nel/src/misc/big_file.cpp | 10 ++-
nel/src/misc/bitmap.cpp | 2 +-
nel/src/misc/cdb_branch.cpp | 2 +-
nel/src/misc/debug.cpp | 2 +
nel/src/misc/eval_num_expr.cpp | 6 +-
nel/src/misc/i18n.cpp | 28 ++++---
nel/src/misc/mem_displayer.cpp | 2 +
nel/src/misc/object_arena_allocator.cpp | 29 ++++---
nel/src/misc/path.cpp | 9 +-
nel/src/misc/system_utils.cpp | 28 ++++---
nel/src/misc/win_thread.cpp | 2 +-
ryzom/client/src/client_chat_manager.cpp | 10 ++-
ryzom/client/src/continent.cpp | 1 +
ryzom/client/src/forage_source_cl.cpp | 2 +-
ryzom/client/src/fx_cl.cpp | 2 +-
.../src/interface_v3/action_handler_game.cpp | 2 +-
.../interface_v3/action_handler_phrase.cpp | 83 ++++++++++---------
.../interface_v3/dbgroup_list_sheet_trade.cpp | 2 +-
.../src/interface_v3/interface_manager.cpp | 2 +-
.../src/interface_v3/sphrase_manager.cpp | 11 ++-
.../client/src/r2/displayer_visual_group.cpp | 2 +-
.../src/r2/dmc/client_edition_module.cpp | 1 +
ryzom/client/src/r2/editor.cpp | 2 +-
ryzom/client/src/r2/prim_render.cpp | 2 +-
ryzom/client/src/timed_fx_manager.cpp | 2 +-
.../time_weather_season/weather_function.cpp | 2 +-
36 files changed, 181 insertions(+), 141 deletions(-)
diff --git a/nel/src/3d/driver/direct3d/driver_direct3d.cpp b/nel/src/3d/driver/direct3d/driver_direct3d.cpp
index 3a4f67aee..fc853602f 100644
--- a/nel/src/3d/driver/direct3d/driver_direct3d.cpp
+++ b/nel/src/3d/driver/direct3d/driver_direct3d.cpp
@@ -1173,7 +1173,7 @@ void D3DWndProc(CDriverD3D *driver, HWND hWnd, UINT message, WPARAM wParam, LPAR
}
}
- if (driver->_EventEmitter.getNumEmitters() > 0)
+ if (driver && driver->_EventEmitter.getNumEmitters() > 0)
{
CWinEventEmitter *we = NLMISC::safe_cast(driver->_EventEmitter.getEmitter(0));
// Process the message by the emitter
diff --git a/nel/src/3d/driver/opengl/driver_opengl_vertex_buffer_hard.cpp b/nel/src/3d/driver/opengl/driver_opengl_vertex_buffer_hard.cpp
index 689c37ba5..8e539afd7 100644
--- a/nel/src/3d/driver/opengl/driver_opengl_vertex_buffer_hard.cpp
+++ b/nel/src/3d/driver/opengl/driver_opengl_vertex_buffer_hard.cpp
@@ -1373,10 +1373,11 @@ CVertexBufferHardARB::~CVertexBufferHardARB()
}
}
#ifdef NL_DEBUG
- if (_VertexPtr)
- {
- _VertexArrayRange->_MappedVBList.erase(_IteratorInMappedVBList);
- }
+ if (_VertexPtr)
+ {
+ nlassert(_VertexArrayRange);
+ _VertexArrayRange->_MappedVBList.erase(_IteratorInMappedVBList);
+ }
#endif
#ifdef USE_OPENGLES
diff --git a/nel/src/3d/render_trav.cpp b/nel/src/3d/render_trav.cpp
index 0a071303f..355ceb7ab 100644
--- a/nel/src/3d/render_trav.cpp
+++ b/nel/src/3d/render_trav.cpp
@@ -921,7 +921,7 @@ void CRenderTrav::changeVPLightSetupMaterial(const CMaterial &mat, bool exclude
Driver->setUniform4f(IDriver::VertexProgram, program->idxLighted().Diffuse[i], color);
}
-
+ nlassert(_VPNumLights < MaxVPLight);
if (i != _VPNumLights)
{
color= _VPLightDiffuse[i] * matDiff;
diff --git a/nel/src/3d/scene.cpp b/nel/src/3d/scene.cpp
index 7f1263ea1..db8a629ff 100644
--- a/nel/src/3d/scene.cpp
+++ b/nel/src/3d/scene.cpp
@@ -775,9 +775,9 @@ CTransformShape *CScene::createInstance(const string &shapeName)
// Look if this instance get lightmap information
#if defined(__GNUC__) && __GNUC__ < 3
- CMeshBase *pMB = (CMeshBase*)((IShape*)(pTShp->Shape));
+ CMeshBase *pMB = pTShp ? (CMeshBase*)((IShape*)(pTShp->Shape)) : NULL;
#else // not GNUC
- CMeshBase *pMB = dynamic_cast((IShape*)(pTShp->Shape));
+ CMeshBase *pMB = pTShp ? dynamic_cast((IShape*)(pTShp->Shape)) : NULL;
#endif // not GNUC
CMeshBaseInstance *pMBI = dynamic_cast( pTShp );
if( ( pMB != NULL ) && ( pMBI != NULL ) )
diff --git a/nel/src/3d/shadow_map_manager.cpp b/nel/src/3d/shadow_map_manager.cpp
index a8400ce0b..e6a7cfe50 100644
--- a/nel/src/3d/shadow_map_manager.cpp
+++ b/nel/src/3d/shadow_map_manager.cpp
@@ -256,14 +256,14 @@ void CShadowMapManager::renderGenerate(CScene *scene)
garbageShadowTextures(scene);
IDriver *driverForShadowGeneration= scene->getRenderTrav().getAuxDriver();
+ nlassert(driverForShadowGeneration);
CSmartPtr previousRenderTarget = driverForShadowGeneration->getRenderTarget();
// Init
// ********
uint32 wndW= _BlurTextureW, wndH= _BlurTextureH;
// get some text/screen size.
- if(driverForShadowGeneration)
- driverForShadowGeneration->getWindowSize(wndW, wndH);
+ driverForShadowGeneration->getWindowSize(wndW, wndH);
uint baseTextureSize= scene->getShadowMapTextureSize();
// Minimize the Dest Texture size, so the blurTexture don't get too heavy in VRAM.
uint32 textDestW= min(wndW, (uint32)NL3D_SMM_MAX_TEXTDEST_SIZE);
diff --git a/nel/src/3d/shape_bank.cpp b/nel/src/3d/shape_bank.cpp
index 61a65c423..a7c60cd03 100644
--- a/nel/src/3d/shape_bank.cpp
+++ b/nel/src/3d/shape_bank.cpp
@@ -683,8 +683,7 @@ void CShapeBank::reset()
while( scmIt != ShapeCacheNameToShapeCache.end() )
{
CShapeCache *pShpCache = getShapeCachePtrFromShapeCacheName( scmIt->first );
- if( pShpCache == NULL )
- nlstop; // Should never happen
+ nlassert(pShpCache);
pShpCache->MaxSize = 0;
checkShapeCache( pShpCache );
diff --git a/nel/src/3d/surface_light_grid.cpp b/nel/src/3d/surface_light_grid.cpp
index deec090a4..b30abe730 100644
--- a/nel/src/3d/surface_light_grid.cpp
+++ b/nel/src/3d/surface_light_grid.cpp
@@ -121,17 +121,20 @@ void CSurfaceLightGrid::getStaticLightSetup(NLMISC::CRGBA sunAmbient, const CVe
CLightInfluenceInterpolator::CCorner &corner= interp.Corners[y*2 + x];
// For all lights
uint lid;
- for(lid= 0; lid leave color and alpha To 0.
- if(cellCorner.LocalAmbientId!=0xFF)
+ if(igPointLights && cellCorner.LocalAmbientId!=0xFF)
{
CPointLight &pl= igPointLights[cellCorner.LocalAmbientId];
// take current ambient from pointLight
diff --git a/nel/src/3d/tessellation.cpp b/nel/src/3d/tessellation.cpp
index 451e1013b..9dbc12296 100644
--- a/nel/src/3d/tessellation.cpp
+++ b/nel/src/3d/tessellation.cpp
@@ -2678,6 +2678,8 @@ void CTessFace::updateBindAndSplit()
}
else
{
+ nlassert(f0);
+ nlassert(f1);
// multipatch face case are detected when face->Patch==NULL !!!
if(f0->FLeft && f0->FLeft->Patch==NULL)
{
@@ -2710,6 +2712,8 @@ void CTessFace::updateBindAndSplit()
}
else
{
+ nlassert(f0);
+ nlassert(f1);
if(f0->FLeft)
{
while(f0->FLeft->isLeaf())
@@ -2781,6 +2785,8 @@ void CTessFace::updateBindAndSplit()
{
CTessFace *f;
sint i;
+ nlassert(f0);
+ nlassert(f1);
// Same reasoning for rectangular patchs, as above.
for(i=0;i<2;i++)
diff --git a/nel/src/gui/group_header.cpp b/nel/src/gui/group_header.cpp
index 03d688921..5fec1d4be 100644
--- a/nel/src/gui/group_header.cpp
+++ b/nel/src/gui/group_header.cpp
@@ -161,8 +161,14 @@ namespace NLGUI
// ...
limitingParent = limitingParent->getParent();
}
-
- getParentContainer()->setW(totalWidth + getParentContainer()->getWReal() - limitingParent->getWReal());
+ if (limitingParent)
+ {
+ getParentContainer()->setW(totalWidth + getParentContainer()->getWReal() - limitingParent->getWReal());
+ }
+ else
+ {
+ nlwarning("No limiting parent for width");
+ }
}
// resize H
@@ -178,9 +184,14 @@ namespace NLGUI
CInterfaceGroup *limitingParent = colEnclosing->getParent();
while (limitingParent && (limitingParent->getResizeFromChildH() || dynamic_cast(limitingParent)))
limitingParent = limitingParent->getParent();
-
- nlassert(limitingParent);
- getParentContainer()->setH(col->getH() + getParentContainer()->getHReal() - limitingParent->getHReal());
+ if (limitingParent)
+ {
+ getParentContainer()->setH(col->getH() + getParentContainer()->getHReal() - limitingParent->getHReal());
+ }
+ else
+ {
+ nlwarning("No limiting parent for height");
+ }
}
}
}
diff --git a/nel/src/logic/logic_state_machine.cpp b/nel/src/logic/logic_state_machine.cpp
index ff99255d2..3d55be849 100644
--- a/nel/src/logic/logic_state_machine.cpp
+++ b/nel/src/logic/logic_state_machine.cpp
@@ -50,7 +50,7 @@ void xmlCheckNodeName (xmlNodePtr &node, const char *nodeName)
// Make an error message
char tmp[512];
smprintf (tmp, 512, "LogicStateMachine STATE_MACHINE XML Syntax error in block line %d, node %s should be %s",
- node ? (int)node->line:-1, node->name, nodeName);
+ node ? (int)node->line:-1, node ? (const char *)node->name : "NULL", nodeName);
nlinfo (tmp);
nlstop;
diff --git a/nel/src/misc/big_file.cpp b/nel/src/misc/big_file.cpp
index 9713610cb..f01bbf297 100644
--- a/nel/src/misc/big_file.cpp
+++ b/nel/src/misc/big_file.cpp
@@ -75,7 +75,7 @@ CBigFile::CHandleFile &CBigFile::CThreadFileArray::get(uint32 index)
// if the vector is not allocated, allocate it (empty entries filled with NULL => not opened FILE* in this thread)
if(index>=ptr->size())
{
- ptr->resize(index+1);
+ ptr->resize((ptrdiff_t)index + 1);
}
return (*ptr)[index];
@@ -278,11 +278,13 @@ bool CBigFile::BNP::readHeader(FILE *file)
}
char sFileName[256];
- if (fread (sFileName, 1, nStringSize, file) != nStringSize)
+ if (nStringSize)
{
- return false;
+ if (fread(sFileName, 1, nStringSize, file) != nStringSize)
+ {
+ return false;
+ }
}
-
sFileName[nStringSize] = 0;
uint32 nFileSize2;
diff --git a/nel/src/misc/bitmap.cpp b/nel/src/misc/bitmap.cpp
index 015a9c4c4..967cc325e 100644
--- a/nel/src/misc/bitmap.cpp
+++ b/nel/src/misc/bitmap.cpp
@@ -4325,7 +4325,7 @@ void CBitmap::blend(CBitmap &Bm0, CBitmap &Bm1, uint16 factor, bool inputBitmapI
else
#endif //#ifdef NL_OS_WINDOWS
{
- uint8 *endPix = dest + (numPix << 2);
+ uint8 *endPix = dest + ((ptrdiff_t)numPix << 2);
// no mmx version
uint blendFact = (uint) factor;
uint invblendFact = 256 - blendFact;
diff --git a/nel/src/misc/cdb_branch.cpp b/nel/src/misc/cdb_branch.cpp
index 5f5cea571..f3e4f7de5 100644
--- a/nel/src/misc/cdb_branch.cpp
+++ b/nel/src/misc/cdb_branch.cpp
@@ -215,7 +215,7 @@ void CCDBNodeBranch::init( xmlNodePtr node, IProgressCallback &progressCallBack,
else
{
if (!_Nodes.empty())
- for ( _IdBits=1; _Nodes.size() > unsigned(1<<_IdBits) ; _IdBits++ ) {}
+ for ( _IdBits=1; _Nodes.size() > ((size_t)1 <<_IdBits) ; _IdBits++ ) {}
else
_IdBits = 0;
}
diff --git a/nel/src/misc/debug.cpp b/nel/src/misc/debug.cpp
index 1f7cf38db..6a40d3b0b 100644
--- a/nel/src/misc/debug.cpp
+++ b/nel/src/misc/debug.cpp
@@ -807,6 +807,8 @@ public:
DWORD symSize = 10000;
PIMAGEHLP_SYMBOL sym = (PIMAGEHLP_SYMBOL) GlobalAlloc (GMEM_FIXED, symSize);
+ if (!sym) return str;
+
::ZeroMemory (sym, symSize);
sym->SizeOfStruct = symSize;
sym->MaxNameLength = symSize - sizeof(IMAGEHLP_SYMBOL);
diff --git a/nel/src/misc/eval_num_expr.cpp b/nel/src/misc/eval_num_expr.cpp
index 52dce523f..5d19e22a1 100644
--- a/nel/src/misc/eval_num_expr.cpp
+++ b/nel/src/misc/eval_num_expr.cpp
@@ -773,7 +773,7 @@ CEvalNumExpr::TReturnState CEvalNumExpr::evalExpression (double &finalResult, TT
case Exponent:
{
int exponent;
- frexp( arg0, &exponent);
+ (void)frexp( arg0, &exponent);
value = (double)exponent;
}
break;
@@ -1032,13 +1032,13 @@ CEvalNumExpr::TReturnState CEvalNumExpr::evalExpression (double &finalResult, TT
v0 -= v1;
break;
case ULeftShift:
- v0 = (double)(((uint)floor (v0 + 0.5))<<((uint)floor (v1 + 0.5)));
+ v0 = (double)(uint)(((uint)floor (v0 + 0.5))<<((uint)floor (v1 + 0.5)));
break;
case URightShift:
v0 = (double)(((uint)floor (v0 + 0.5))>>((uint)floor (v1 + 0.5)));
break;
case SLeftShift:
- v0 = (double)(((sint)floor (v0 + 0.5))<<((sint)floor (v1 + 0.5)));
+ v0 = (double)(sint)(((sint)floor (v0 + 0.5))<<((sint)floor (v1 + 0.5)));
break;
case SRightShift:
v0 = (double)(((sint)floor (v0 + 0.5))>>((sint)floor (v1 + 0.5)));
diff --git a/nel/src/misc/i18n.cpp b/nel/src/misc/i18n.cpp
index f692fd849..27a47c2e4 100644
--- a/nel/src/misc/i18n.cpp
+++ b/nel/src/misc/i18n.cpp
@@ -339,21 +339,25 @@ std::string CI18N::getSystemLanguageCode ()
typedef int (WINAPI* GetUserDefaultLocaleNamePtr)(LPWSTR lpLocaleName, int cchLocaleName);
// get pointer on GetUserDefaultLocaleName, kernel32.dll is always in memory so no need to call LoadLibrary
- GetUserDefaultLocaleNamePtr nlGetUserDefaultLocaleName = (GetUserDefaultLocaleNamePtr)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetUserDefaultLocaleName");
-
- // only use it if found
- if (nlGetUserDefaultLocaleName)
+ HMODULE hKernel32 = GetModuleHandleA("kernel32.dll");
+ if (hKernel32)
{
- // get user locale
- wchar_t buffer[LOCALE_NAME_MAX_LENGTH];
- sint res = nlGetUserDefaultLocaleName(buffer, LOCALE_NAME_MAX_LENGTH);
+ GetUserDefaultLocaleNamePtr nlGetUserDefaultLocaleName = (GetUserDefaultLocaleNamePtr)GetProcAddress(hKernel32, "GetUserDefaultLocaleName");
- // convert wide string to std::string
- std::string lang = wideToUtf8(buffer);
+ // only use it if found
+ if (nlGetUserDefaultLocaleName)
+ {
+ // get user locale
+ wchar_t buffer[LOCALE_NAME_MAX_LENGTH];
+ sint res = nlGetUserDefaultLocaleName(buffer, LOCALE_NAME_MAX_LENGTH);
- // only keep 2 first characters
- if (lang.size() > 1)
- _SystemLanguageCode = lang.substr(0, 2);
+ // convert wide string to std::string
+ std::string lang = wideToUtf8(buffer);
+
+ // only keep 2 first characters
+ if (lang.size() > 1)
+ _SystemLanguageCode = lang.substr(0, 2);
+ }
}
}
#endif
diff --git a/nel/src/misc/mem_displayer.cpp b/nel/src/misc/mem_displayer.cpp
index 04e5c71dd..0250fc4c6 100644
--- a/nel/src/misc/mem_displayer.cpp
+++ b/nel/src/misc/mem_displayer.cpp
@@ -58,6 +58,8 @@ static string getFuncInfo (DWORD_TYPE funcAddr, DWORD_TYPE stackAddr)
DWORD symSize = 10000;
PIMAGEHLP_SYMBOL sym = (PIMAGEHLP_SYMBOL) GlobalAlloc (GMEM_FIXED, symSize);
+ if (!sym) return str;
+
::ZeroMemory (sym, symSize);
sym->SizeOfStruct = symSize;
sym->MaxNameLength = symSize - sizeof(IMAGEHLP_SYMBOL);
diff --git a/nel/src/misc/object_arena_allocator.cpp b/nel/src/misc/object_arena_allocator.cpp
index bd00affc9..ba2c81148 100644
--- a/nel/src/misc/object_arena_allocator.cpp
+++ b/nel/src/misc/object_arena_allocator.cpp
@@ -60,22 +60,23 @@ CObjectArenaAllocator::~CObjectArenaAllocator()
void *CObjectArenaAllocator::alloc(uint size)
{
#ifdef NL_DEBUG
- if (_WantBreakOnAlloc)
+ if (_WantBreakOnAlloc)
+ {
+ if (_AllocID == _BreakAllocID)
{
- if (_AllocID == _BreakAllocID)
- {
- nlassert(0);
- }
+ nlassert(0);
}
+ }
#endif
if (size >= _MaxAllocSize)
{
// use standard allocator
nlctassert(NL_DEFAULT_MEMORY_ALIGNMENT >= sizeof(uint));
- uint8 *block = (uint8 *)aligned_malloc(NL_DEFAULT_MEMORY_ALIGNMENT + size, NL_DEFAULT_MEMORY_ALIGNMENT); //new uint8[size + sizeof(uint)]; // an additionnal uint is needed to store size of block
- if (!block) return NULL;
+ uint8 *block = (uint8 *)aligned_malloc(NL_DEFAULT_MEMORY_ALIGNMENT + (ptrdiff_t)size, NL_DEFAULT_MEMORY_ALIGNMENT); //new uint8[size + sizeof(uint)]; // an additionnal uint is needed to store size of block
+ if (!block) throw std::bad_alloc();
#ifdef NL_DEBUG
- _MemBlockToAllocID[block] = _AllocID;
+ _MemBlockToAllocID[block] = _AllocID;
+ ++_AllocID;
#endif
*(uint *) block = size;
return block + NL_DEFAULT_MEMORY_ALIGNMENT;
@@ -87,16 +88,14 @@ void *CObjectArenaAllocator::alloc(uint size)
_ObjectSizeToAllocator[entry] = new CFixedSizeAllocator(entry * _Granularity + NL_DEFAULT_MEMORY_ALIGNMENT, _MaxAllocSize / size); // an additionnal uint is needed to store size of block
}
void *block = _ObjectSizeToAllocator[entry]->alloc();
+ if (!block) throw std::bad_alloc();
nlassert(((uintptr_t)block % NL_DEFAULT_MEMORY_ALIGNMENT) == 0);
#ifdef NL_DEBUG
- if (block)
- {
- _MemBlockToAllocID[block] = _AllocID;
- }
- ++_AllocID;
+ _MemBlockToAllocID[block] = _AllocID;
+ ++_AllocID;
#endif
- *(uint *) block = size;
- return (void *) ((uint8 *) block + NL_DEFAULT_MEMORY_ALIGNMENT);
+ *(uint *)block = size;
+ return (void *)((uint8 *)block + NL_DEFAULT_MEMORY_ALIGNMENT);
}
// *****************************************************************************************************************
diff --git a/nel/src/misc/path.cpp b/nel/src/misc/path.cpp
index cdc71c1eb..a2f817210 100644
--- a/nel/src/misc/path.cpp
+++ b/nel/src/misc/path.cpp
@@ -1341,10 +1341,13 @@ void CFileContainer::addSearchBigFile (const string &sBigFilename, bool recurse,
fclose(Handle);
return;
}
- if (fread (FileName, 1, nStringSize, Handle) != nStringSize)
+ if (nStringSize)
{
- fclose(Handle);
- return;
+ if (fread(FileName, 1, nStringSize, Handle) != nStringSize)
+ {
+ fclose(Handle);
+ return;
+ }
}
FileName[nStringSize] = 0;
uint32 nFileSize2;
diff --git a/nel/src/misc/system_utils.cpp b/nel/src/misc/system_utils.cpp
index 8e6a1feae..45da347bd 100644
--- a/nel/src/misc/system_utils.cpp
+++ b/nel/src/misc/system_utils.cpp
@@ -173,23 +173,25 @@ bool CSystemUtils::copyTextToClipboard(const ucstring &text)
{
// create a lock on this buffer
void *hLock = GlobalLock(mem);
+ if (hLock)
+ {
+ // copy text to this buffer
+ if (isUnicode)
+ wcscpy((wchar_t *)hLock, (const wchar_t *)text.c_str());
+ else
+ strcpy((char *)hLock, text.toString().c_str());
- // copy text to this buffer
- if (isUnicode)
- wcscpy((wchar_t*)hLock, (const wchar_t*)text.c_str());
- else
- strcpy((char*)hLock, text.toString().c_str());
-
- // unlock buffer
- GlobalUnlock(mem);
+ // unlock buffer
+ GlobalUnlock(mem);
- // empty clipboard
- EmptyClipboard();
+ // empty clipboard
+ EmptyClipboard();
- // set new data to clipboard in the right format
- SetClipboardData(isUnicode ? CF_UNICODETEXT:CF_TEXT, mem);
+ // set new data to clipboard in the right format
+ SetClipboardData(isUnicode ? CF_UNICODETEXT : CF_TEXT, mem);
- res = true;
+ res = true;
+ }
}
CloseClipboard();
diff --git a/nel/src/misc/win_thread.cpp b/nel/src/misc/win_thread.cpp
index 0de191d55..c3624c161 100644
--- a/nel/src/misc/win_thread.cpp
+++ b/nel/src/misc/win_thread.cpp
@@ -209,11 +209,11 @@ void CWinThread::start ()
ThreadHandle = (void *) ::CreateThread (NULL, 0, ProxyFunc, this, 0, (DWORD *)&ThreadId);
// nldebug("NLMISC: thread %x started for runnable '%x'", typeid( Runnable ).name());
// OutputDebugString(toString(NL_LOC_MSG " NLMISC: thread %x started for runnable '%s'\n", ThreadId, typeid( *Runnable ).name()).c_str());
- SetThreadPriorityBoost (ThreadHandle, TRUE); // FALSE == Enable Priority Boost
if (ThreadHandle == NULL)
{
throw EThread ( "Cannot create new thread" );
}
+ SetThreadPriorityBoost (ThreadHandle, TRUE); // FALSE == Enable Priority Boost
_SuspendCount = 0;
}
diff --git a/ryzom/client/src/client_chat_manager.cpp b/ryzom/client/src/client_chat_manager.cpp
index 9d222a1b7..a61c21701 100644
--- a/ryzom/client/src/client_chat_manager.cpp
+++ b/ryzom/client/src/client_chat_manager.cpp
@@ -1230,11 +1230,13 @@ class CHandlerEnterTell : public IActionHandler
{
CGroupContainer *pGC = pCGW->createFreeTeller(receiver);
if (pGC != NULL)
- pGC->setActive(true);
- CGroupEditBox *eb = dynamic_cast(pGC->getGroup("eb"));
- if (eb)
{
- CWidgetManager::getInstance()->setCaptureKeyboard(eb);
+ pGC->setActive(true);
+ CGroupEditBox *eb = dynamic_cast(pGC->getGroup("eb"));
+ if (eb)
+ {
+ CWidgetManager::getInstance()->setCaptureKeyboard(eb);
+ }
}
}
}
diff --git a/ryzom/client/src/continent.cpp b/ryzom/client/src/continent.cpp
index 03b9a1fce..6bd22741a 100644
--- a/ryzom/client/src/continent.cpp
+++ b/ryzom/client/src/continent.cpp
@@ -956,6 +956,7 @@ void CContinent::unselect()
// Setup the Root scene.
if (BackgroundIG)
{
+ nlassert(SceneRoot);
BackgroundIG->removeFromScene (*SceneRoot);
SceneRoot->deleteInstanceGroup (BackgroundIG);
BackgroundIG = NULL;
diff --git a/ryzom/client/src/forage_source_cl.cpp b/ryzom/client/src/forage_source_cl.cpp
index 4e673caaf..be41c0e75 100644
--- a/ryzom/client/src/forage_source_cl.cpp
+++ b/ryzom/client/src/forage_source_cl.cpp
@@ -101,7 +101,7 @@ bool CForageSourceCL::build( const CEntitySheet *sheet )
const CForageSourceSheet *forageSourceSheet = dynamic_cast(sheet);
if ( ! forageSourceSheet )
{
- nlwarning( "Bad sheet %s for forage source", sheet->Id.toString().c_str() );
+ nlwarning( "Bad sheet %s for forage source", sheet ? sheet->Id.toString().c_str() : "NULL" );
return false;
}
if ( ! setFx( forageSourceSheet->FxFilename ) )
diff --git a/ryzom/client/src/fx_cl.cpp b/ryzom/client/src/fx_cl.cpp
index e1f29fd77..aeb3ddcba 100644
--- a/ryzom/client/src/fx_cl.cpp
+++ b/ryzom/client/src/fx_cl.cpp
@@ -75,7 +75,7 @@ bool CFxCL::build( const CEntitySheet *sheet )
if ( (! _FXSheet) || (_FXSheet->PSList.empty()) )
{
_BadBuild = true;
- nlwarning( "Bad sheet %s for fx", sheet->Id.toString().c_str() );
+ nlwarning( "Bad sheet %s for fx", sheet ? sheet->Id.toString().c_str() : "NULL" );
return false;
}
diff --git a/ryzom/client/src/interface_v3/action_handler_game.cpp b/ryzom/client/src/interface_v3/action_handler_game.cpp
index 5af8485d6..bbb392131 100644
--- a/ryzom/client/src/interface_v3/action_handler_game.cpp
+++ b/ryzom/client/src/interface_v3/action_handler_game.cpp
@@ -1334,7 +1334,7 @@ class CSelectItemSheet : public IActionHandler
// check if user has the level to use the item (applies to item & plans)
if (ctrlSheet->getSheetCategory() == CDBCtrlSheet::Item)
{
- if (csg->getName() == "buy_selection")
+ if (csg && csg->getName() == "buy_selection")
{
const CItemSheet *is = ctrlSheet->asItemSheet();
if (is)
diff --git a/ryzom/client/src/interface_v3/action_handler_phrase.cpp b/ryzom/client/src/interface_v3/action_handler_phrase.cpp
index 8a94a4c16..dcc55f9ea 100644
--- a/ryzom/client/src/interface_v3/action_handler_phrase.cpp
+++ b/ryzom/client/src/interface_v3/action_handler_phrase.cpp
@@ -1191,57 +1191,60 @@ public:
if( pPM->avoidCyclicForPhrase(phraseCom) )
cyclic= false;
- // **** Launch the cast
- // Cast only if their is a target, or if it is not a combat action
- CEntityCL *target = EntitiesMngr.entity(UserEntity->targetSlot());
- if(target || !rootBrick->isCombat())
+ if (UserEntity)
{
- // combat (may moveTo before) ?
- if(rootBrick->isCombat())
+ // **** Launch the cast
+ // Cast only if their is a target, or if it is not a combat action
+ CEntityCL *target = EntitiesMngr.entity(UserEntity->targetSlot());
+ if (target || !rootBrick->isCombat())
{
- if( !UserEntity->canEngageCombat() )
- return;
+ // combat (may moveTo before) ?
+ if (rootBrick->isCombat())
+ {
+ if (!UserEntity->canEngageCombat())
+ return;
- UserEntity->executeCombatWithPhrase(target, memoryLine, memoryIndex, cyclic);
- }
- // else can cast soon!
- else if ( rootBrick->isForageExtraction() && (! UserEntity->isRiding()) ) // if mounted, send directly to server (without moving) to receive the error message
- {
- // Yoyo: TEMP if a target selected, must be a forage source
- if(!target || target->isForageSource())
+ UserEntity->executeCombatWithPhrase(target, memoryLine, memoryIndex, cyclic);
+ }
+ // else can cast soon!
+ else if (rootBrick->isForageExtraction() && (!UserEntity->isRiding())) // if mounted, send directly to server (without moving) to receive the error message
+ {
+ // Yoyo: TEMP if a target selected, must be a forage source
+ if (!target || target->isForageSource())
+ {
+ // Cancel any follow
+ UserEntity->disableFollow();
+ // reset any moveTo also (if target==NULL, moveToExtractionPhrase() and therefore resetAnyMoveTo() not called)
+ // VERY important if previous MoveTo was a SPhrase MoveTo (because cancelClientExecute() must be called)
+ UserEntity->resetAnyMoveTo();
+
+ // Move to targetted source
+ if (target)
+ UserEntity->moveToExtractionPhrase(target->slot(), MaxExtractionDistance, memoryLine, memoryIndex, cyclic);
+
+ // start client execution
+ pPM->clientExecute(memoryLine, memoryIndex, cyclic);
+
+ if (!target)
+ {
+ // inform Server of phrase cast
+ pPM->sendExecuteToServer(memoryLine, memoryIndex, cyclic);
+ }
+ }
+ }
+ else
{
- // Cancel any follow
- UserEntity->disableFollow();
- // reset any moveTo also (if target==NULL, moveToExtractionPhrase() and therefore resetAnyMoveTo() not called)
+ // Cancel any moveTo(), because don't want to continue reaching the prec entity
// VERY important if previous MoveTo was a SPhrase MoveTo (because cancelClientExecute() must be called)
UserEntity->resetAnyMoveTo();
- // Move to targetted source
- if ( target )
- UserEntity->moveToExtractionPhrase( target->slot(), MaxExtractionDistance, memoryLine, memoryIndex, cyclic );
-
- // start client execution
+ // start client execution: NB: start client execution even if it
pPM->clientExecute(memoryLine, memoryIndex, cyclic);
- if ( ! target )
- {
- // inform Server of phrase cast
- pPM->sendExecuteToServer(memoryLine, memoryIndex, cyclic);
- }
+ // inform Server of phrase cast
+ pPM->sendExecuteToServer(memoryLine, memoryIndex, cyclic);
}
}
- else
- {
- // Cancel any moveTo(), because don't want to continue reaching the prec entity
- // VERY important if previous MoveTo was a SPhrase MoveTo (because cancelClientExecute() must be called)
- UserEntity->resetAnyMoveTo();
-
- // start client execution: NB: start client execution even if it
- pPM->clientExecute(memoryLine, memoryIndex, cyclic);
-
- // inform Server of phrase cast
- pPM->sendExecuteToServer(memoryLine, memoryIndex, cyclic);
- }
}
}
}
diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp
index 4a7ef5701..ce7f2fcf5 100644
--- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp
+++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp
@@ -475,7 +475,7 @@ bool CDBGroupListSheetTrade::CSheetChildTrade::isSheetValid(CDBGroupListSheetTex
if ((pIS != NULL) && (!pIS->DropOrSell))
return false;
// test if this whole family of items can be sold
- if( !ITEMFAMILY::isSellableByPlayer(pIS->Family) )
+ if((pIS != NULL) && !ITEMFAMILY::isSellableByPlayer(pIS->Family) )
return false;
}
diff --git a/ryzom/client/src/interface_v3/interface_manager.cpp b/ryzom/client/src/interface_v3/interface_manager.cpp
index 23440218e..5737e50a0 100644
--- a/ryzom/client/src/interface_v3/interface_manager.cpp
+++ b/ryzom/client/src/interface_v3/interface_manager.cpp
@@ -2980,8 +2980,8 @@ void CInterfaceManager::log(const ucstring &str, const std::string &cat)
{
const string finalString = string(NLMISC::IDisplayer::dateToHumanString()) + " (" + NLMISC::toUpper(cat) + ") * " + str.toUtf8();
fprintf(f, "%s\n", finalString.c_str());
+ fclose(f);
}
- fclose(f);
}
}
diff --git a/ryzom/client/src/interface_v3/sphrase_manager.cpp b/ryzom/client/src/interface_v3/sphrase_manager.cpp
index 5ebf3eee9..dc605d11d 100644
--- a/ryzom/client/src/interface_v3/sphrase_manager.cpp
+++ b/ryzom/client/src/interface_v3/sphrase_manager.cpp
@@ -3576,13 +3576,12 @@ void CSPhraseManager::updatePhraseProgressionDB()
break;
}
}
- }
-
- // if show, but only if full learnt, skip it if not fully learnt
- if(phrase->ShowInAPOnlyIfLearnt && !known)
- {
- continue;
+ // if show, but only if full learnt, skip it if not fully learnt
+ if (phrase->ShowInAPOnlyIfLearnt && !known)
+ {
+ continue;
+ }
}
diff --git a/ryzom/client/src/r2/displayer_visual_group.cpp b/ryzom/client/src/r2/displayer_visual_group.cpp
index 05e120e66..0edc18880 100644
--- a/ryzom/client/src/r2/displayer_visual_group.cpp
+++ b/ryzom/client/src/r2/displayer_visual_group.cpp
@@ -98,7 +98,7 @@ protected:
{
CGroupMap *gm = CTool::getWorldMap();
if (!gm) dest = CVector::Null;
- gm->worldToWindow(dest, src);
+ else gm->worldToWindow(dest, src);
}
};
diff --git a/ryzom/client/src/r2/dmc/client_edition_module.cpp b/ryzom/client/src/r2/dmc/client_edition_module.cpp
index f58a9f669..6740dabfe 100644
--- a/ryzom/client/src/r2/dmc/client_edition_module.cpp
+++ b/ryzom/client/src/r2/dmc/client_edition_module.cpp
@@ -2227,6 +2227,7 @@ void CClientEditionModule::addToSaveList(const std::string& filename, const std:
if (!ok)
{
delete sv;
+ return;
}
else
{
diff --git a/ryzom/client/src/r2/editor.cpp b/ryzom/client/src/r2/editor.cpp
index 8e146e9ad..96b935e34 100644
--- a/ryzom/client/src/r2/editor.cpp
+++ b/ryzom/client/src/r2/editor.cpp
@@ -6302,7 +6302,7 @@ CInstance *CEditor::getInstanceUnderPos(float x, float y, float distSelection, b
objectSelected= precInstanceUnderPos->getDisplayerVisual();
}
- if (objectSelected->getSelectionType() == ISelectableObject::GroundProjected)
+ if (objectSelected && objectSelected->getSelectionType() == ISelectableObject::GroundProjected)
{
if (borderSelected && borderSelected != objectSelected)
{
diff --git a/ryzom/client/src/r2/prim_render.cpp b/ryzom/client/src/r2/prim_render.cpp
index 59b05e1c4..f4b6cb8a9 100644
--- a/ryzom/client/src/r2/prim_render.cpp
+++ b/ryzom/client/src/r2/prim_render.cpp
@@ -202,7 +202,7 @@ CCtrlPolygon *CPrimRender::newCtrlPolygon() const
{
CGroupMap *gm = CTool::getWorldMap();
if (!gm) dest = CVector::Null;
- gm->worldToWindow(dest, src);
+ else gm->worldToWindow(dest, src);
}
};
CViewBase::TCtorParam param;
diff --git a/ryzom/client/src/timed_fx_manager.cpp b/ryzom/client/src/timed_fx_manager.cpp
index b316f0ab5..6f46d6712 100644
--- a/ryzom/client/src/timed_fx_manager.cpp
+++ b/ryzom/client/src/timed_fx_manager.cpp
@@ -204,7 +204,7 @@ CTimedFXManager::TFXGroupHandle CTimedFXManager::add(const std::vector
//sint32 debugDay;
if (!(fi.FXSheet && fi.FXSheet->Mode == CSeasonFXSheet::AlwaysStarted))
{
- if (fi.FXSheet->Mode == CSeasonFXSheet::Spawn)
+ if (fi.FXSheet && fi.FXSheet->Mode == CSeasonFXSheet::Spawn)
{
// compute next spawn date
float cycleLength = fi.FXSheet ? fi.FXSheet->CycleDuration : _DayLength;
diff --git a/ryzom/common/src/game_share/time_weather_season/weather_function.cpp b/ryzom/common/src/game_share/time_weather_season/weather_function.cpp
index 02432142f..f62a5a244 100644
--- a/ryzom/common/src/game_share/time_weather_season/weather_function.cpp
+++ b/ryzom/common/src/game_share/time_weather_season/weather_function.cpp
@@ -37,7 +37,7 @@ CWeatherFunction::CWeatherFunction()
void CWeatherFunction::buildFromSheet(const CWeatherFunctionSheet &sheet, const CWeatherManager &wm)
{
// copy common part of objects (parameters)
- *static_cast(this) = *static_cast(&sheet);
+ static_cast(*this) = static_cast(sheet);
// get pointer on the setup from their names
_WeatherSetups.resize(sheet.SetupNames.size());
nlassert(sheet.SetupWeights.size() == sheet.SetupNames.size());
From 7a9accde1166ec27531d8deb078f08062e7c8ff3 Mon Sep 17 00:00:00 2001
From: Xtarsia <69606701+Xtarsia@users.noreply.github.com>
Date: Sat, 24 Oct 2020 01:13:19 +0100
Subject: [PATCH 029/205] Update info_player.xml
closes #160
---
.../gamedev/interfaces_v3/info_player.xml | 50 +++++++++----------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/ryzom/client/data/gamedev/interfaces_v3/info_player.xml b/ryzom/client/data/gamedev/interfaces_v3/info_player.xml
index 2d248087f..98dab16a8 100644
--- a/ryzom/client/data/gamedev/interfaces_v3/info_player.xml
+++ b/ryzom/client/data/gamedev/interfaces_v3/info_player.xml
@@ -513,7 +513,7 @@
-
+
@@ -581,13 +581,13 @@
-
+
-
-
-
+
+
+
@@ -606,7 +606,7 @@
-
+
@@ -624,21 +624,21 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
-
-
+
+
+
@@ -656,7 +656,7 @@
-
+
@@ -672,17 +672,17 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
-
+
+
From c68c3746dd1554fdd3b31a7cff7d7c4f93c7ff34 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sat, 24 Oct 2020 19:07:41 +0800
Subject: [PATCH 030/205] Build fix
---
nel/tools/3d/panoply_preview/main_window.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/nel/tools/3d/panoply_preview/main_window.cpp b/nel/tools/3d/panoply_preview/main_window.cpp
index 1b743d439..1ef144a14 100644
--- a/nel/tools/3d/panoply_preview/main_window.cpp
+++ b/nel/tools/3d/panoply_preview/main_window.cpp
@@ -53,7 +53,7 @@ namespace {
QString nli18n(const char *label)
{
- return QString::fromUtf16(CI18N::get(label).c_str());
+ return QString::fromUtf16((const ushort *)CI18N::get(label).c_str());
}
} /* anonymous namespace */
From c068d757eb2442692f47201e9124afbab6c2f523 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sat, 24 Oct 2020 19:23:11 +0800
Subject: [PATCH 031/205] Build fix
---
nel/include/nel/misc/string_common.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/nel/include/nel/misc/string_common.h b/nel/include/nel/misc/string_common.h
index 9f6d59aae..6021b8159 100644
--- a/nel/include/nel/misc/string_common.h
+++ b/nel/include/nel/misc/string_common.h
@@ -193,6 +193,10 @@ inline std::string toString(const sint32 &val) { return toString("%d", val); }
inline std::string toString(const uint64 &val) { return toString("%" NL_I64 "u", val); }
inline std::string toString(const sint64 &val) { return toString("%" NL_I64 "d", val); }
+#ifdef NL_OS_WINDOWS
+inline std::string toString(const wchar_t &val) { return toString(reinterpret_cast(val)); }
+#endif
+
#ifdef NL_COMP_GCC
# if GCC_VERSION == 40102
@@ -246,6 +250,10 @@ inline bool fromString(const std::string &str, sint64 &val) { bool ret = sscanf(
inline bool fromString(const std::string &str, float &val) { bool ret = sscanf(str.c_str(), "%f", &val) == 1; if (!ret) val = 0.0f; return ret; }
inline bool fromString(const std::string &str, double &val) { bool ret = sscanf(str.c_str(), "%lf", &val) == 1; if (!ret) val = 0.0; return ret; }
+#ifdef NL_OS_WINDOWS
+inline bool fromString(const std::string &str, wchar_t &val) { return fromString(str, reinterpret_cast(val)); }
+#endif
+
// Fast string to bool, reliably defined for strings starting with 0, 1, t, T, f, F, y, Y, n, N, anything else is undefined.
// (str[0] == '1' || (str[0] & 0xD2) == 0x50)
// - Kaetemi
From 8d94baaf14a9ba71ffbca056df6673383e3cd7ae Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sat, 24 Oct 2020 21:17:22 +0800
Subject: [PATCH 032/205] More consistent unicode behaviour for text
---
nel/include/nel/gui/group_editbox.h | 4 +-
nel/src/gui/ctrl_base.cpp | 52 ++++++++++---------
nel/src/gui/ctrl_text_button.cpp | 8 +--
nel/src/gui/dbgroup_combo_box.cpp | 2 +-
nel/src/gui/dbview_quantity.cpp | 7 +--
nel/src/gui/group_editbox.cpp | 20 +------
nel/src/gui/group_html.cpp | 4 +-
nel/src/gui/group_list.cpp | 9 ++--
nel/src/gui/group_menu.cpp | 7 +--
nel/src/gui/group_paragraph.cpp | 9 ++--
nel/src/gui/group_tree.cpp | 7 +--
nel/src/gui/lua_ihm.cpp | 6 +--
nel/src/gui/view_text.cpp | 12 ++---
nel/src/gui/view_text_formated.cpp | 38 +++++++-------
nel/src/gui/view_text_id_formated.cpp | 27 +++++-----
nel/src/misc/system_utils.cpp | 21 +++++---
.../src/interface_v3/macrocmd_manager.cpp | 10 ++--
ryzom/client/src/login.cpp | 4 +-
18 files changed, 121 insertions(+), 126 deletions(-)
diff --git a/nel/include/nel/gui/group_editbox.h b/nel/include/nel/gui/group_editbox.h
index 096f3daa0..dc343410b 100644
--- a/nel/include/nel/gui/group_editbox.h
+++ b/nel/include/nel/gui/group_editbox.h
@@ -79,8 +79,6 @@ namespace NLGUI
sint64 getInputStringAsInt64() const;
void setInputStringAsFloat(float val);
float getInputStringAsFloat() const;
- void setInputStringAsStdString(const std::string &str);
- std::string getInputStringAsStdString() const;
void setInputStringAsUtf8(const std::string &str);
std::string getInputStringAsUtf8() const;
void setColor(NLMISC::CRGBA col);
@@ -189,7 +187,7 @@ namespace NLGUI
REFLECT_LUA_METHOD("setSelectionAll", luaSetSelectionAll);
REFLECT_LUA_METHOD("setFocusOnText", luaSetFocusOnText);
REFLECT_LUA_METHOD("cancelFocusOnText", luaCancelFocusOnText);
- REFLECT_STRING("input_string", getInputStringAsStdString, setInputStringAsStdString);
+ REFLECT_STRING("input_string", getInputStringAsUtf8, setInputStringAsUtf8);
REFLECT_UCSTRING("uc_input_string", getInputString, setInputString);
REFLECT_EXPORT_END
diff --git a/nel/src/gui/ctrl_base.cpp b/nel/src/gui/ctrl_base.cpp
index 2d67ccc30..0124bfdee 100644
--- a/nel/src/gui/ctrl_base.cpp
+++ b/nel/src/gui/ctrl_base.cpp
@@ -122,30 +122,26 @@ namespace NLGUI
CXMLAutoPtr prop;
// get static toolTip
- prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip" );
- if (prop)
+ prop = (char *)xmlGetProp(cur, (xmlChar *)"tooltip_i18n");
+ if ((bool)prop && strlen((const char *)prop) > 0)
{
- const char *propPtr = prop;
- if (strlen(propPtr) > 2 && propPtr[0] == 'u' && propPtr[1] == ':')
- _ContextHelp = ucstring::makeFromUtf8(std::string(propPtr).substr(2));
+ // Force I18N tooltip
+ if (!editorMode)
+ _ContextHelp = CI18N::get((const char *)prop);
else
- _ContextHelp = ucstring(propPtr);
-
-
- if( !editorMode && ( strlen(propPtr) > 2 ) )
- {
- if ((propPtr[0] == 'u') && (propPtr[1] == 'i'))
- _ContextHelp = CI18N::get ((const char *) prop);
- }
+ _ContextHelp.fromUtf8((const char *)prop);
}
- // Force I18N tooltip
- prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_i18n" );
- if ((bool)prop && strlen((const char*)prop)>0)
+ else
{
- if( !editorMode )
- _ContextHelp = CI18N::get ((const char *) prop);
- else
- _ContextHelp = (const char*)prop;
+ // get static toolTip
+ prop = (char *)xmlGetProp(cur, (xmlChar *)"tooltip");
+ if (prop)
+ {
+ if (!editorMode && NLMISC::startsWith((const char *)prop, "ui"))
+ _ContextHelp = CI18N::get((const char *)prop);
+ else
+ _ContextHelp.fromUtf8((const char *)prop);
+ }
}
// get dynamic toolTip ActionHandler
@@ -173,7 +169,7 @@ namespace NLGUI
_ToolTipSpecialParent= CStringShared();
if(prop)
{
- _ToolTipSpecialParent= std::string((const char*)prop);
+ _ToolTipSpecialParent= (const char*)prop;
}
// Tooltip posref
@@ -201,12 +197,12 @@ namespace NLGUI
{
if( name == "tooltip" )
{
- return _ContextHelp.toString();
+ return _ContextHelp.toUtf8();
}
else
if( name == "tooltip_i18n" )
{
- return _ContextHelp.toString();
+ return _ContextHelp.toUtf8();
}
else
if( name == "on_tooltip" )
@@ -262,13 +258,19 @@ namespace NLGUI
{
if( name == "tooltip" )
{
- _ContextHelp = ucstring::makeFromUtf8(value);
+ if (!editorMode && NLMISC::startsWith(value, "ui"))
+ _ContextHelp = CI18N::get(value);
+ else
+ _ContextHelp.fromUtf8(value);
return;
}
else
if( name == "tooltip_i18n" )
{
- _ContextHelp = value;
+ if (!editorMode)
+ _ContextHelp = CI18N::get(value);
+ else
+ _ContextHelp.fromUtf8(value);
return;
}
else
diff --git a/nel/src/gui/ctrl_text_button.cpp b/nel/src/gui/ctrl_text_button.cpp
index de01174ed..942dd11f8 100644
--- a/nel/src/gui/ctrl_text_button.cpp
+++ b/nel/src/gui/ctrl_text_button.cpp
@@ -596,9 +596,11 @@ namespace NLGUI
if (prop)
{
const char *propPtr = prop;
- ucstring text = ucstring(propPtr);
- if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i'))
- text = CI18N::get (propPtr);
+ ucstring text;
+ if (NLMISC::startsWith(propPtr, "ui"))
+ text = CI18N::get(propPtr);
+ else
+ text.fromUtf8(propPtr);
_ViewText->setText(text);
}
}
diff --git a/nel/src/gui/dbgroup_combo_box.cpp b/nel/src/gui/dbgroup_combo_box.cpp
index 834d2d5bf..59a8b03c8 100644
--- a/nel/src/gui/dbgroup_combo_box.cpp
+++ b/nel/src/gui/dbgroup_combo_box.cpp
@@ -467,7 +467,7 @@ namespace NLGUI
void CDBGroupComboBox::setViewText(const ucstring & text)
{
_IsExternViewText = true;
- _ExternViewText = ucstring(text);
+ _ExternViewText = text;
_ViewText->setText(_ExternViewText);
}
diff --git a/nel/src/gui/dbview_quantity.cpp b/nel/src/gui/dbview_quantity.cpp
index cac772c96..0b01f14f0 100644
--- a/nel/src/gui/dbview_quantity.cpp
+++ b/nel/src/gui/dbview_quantity.cpp
@@ -147,9 +147,10 @@ namespace NLGUI
if(ptr)
{
const char *propPtr = ptr;
- _EmptyText = ucstring(propPtr);
- if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i'))
- _EmptyText = CI18N::get (propPtr);
+ if (NLMISC::startsWith(propPtr, "ui"))
+ _EmptyText = CI18N::get(propPtr);
+ else
+ _EmptyText.fromUtf8(propPtr);
}
// init cache.
diff --git a/nel/src/gui/group_editbox.cpp b/nel/src/gui/group_editbox.cpp
index 136909f63..2879a62af 100644
--- a/nel/src/gui/group_editbox.cpp
+++ b/nel/src/gui/group_editbox.cpp
@@ -1229,7 +1229,7 @@ namespace NLGUI
{
makeTopWindow();
// for french, deutsch and russian, be aware of unicode
- std::string command = ucstring(_InputString.substr(1)).toUtf8();
+ std::string command = _InputString.substr(1).toUtf8();
ICommand::expand(command);
// then back to ucstring
_InputString.fromUtf8(command);
@@ -1735,26 +1735,10 @@ namespace NLGUI
CInterfaceGroup::setActive(active);
}
- // ***************************************************************************
- void CGroupEditBox::setInputStringAsStdString(const std::string &str)
- {
- setInputString(ucstring(str));
- }
-
- // ***************************************************************************
- std::string CGroupEditBox::getInputStringAsStdString() const
- {
- std::string result;
- _InputString.toString(result);
- return result;
- }
-
// ***************************************************************************
void CGroupEditBox::setInputStringAsUtf8(const std::string &str)
{
- ucstring tmp;
- tmp.fromUtf8(str);
- setInputString(tmp);
+ setInputString(ucstring::makeFromUtf8(str));
}
// ***************************************************************************
diff --git a/nel/src/gui/group_html.cpp b/nel/src/gui/group_html.cpp
index 50b381a3c..0c294c766 100644
--- a/nel/src/gui/group_html.cpp
+++ b/nel/src/gui/group_html.cpp
@@ -4716,7 +4716,7 @@ namespace NLGUI
const char *funcName = "addString";
CLuaIHM::checkArgCount(ls, funcName, 1);
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING);
- addString(ucstring(ls.toString(1)));
+ addString(ucstring::makeFromUtf8(ls.toString(1)));
return 0;
}
@@ -5470,7 +5470,7 @@ namespace NLGUI
}
else
{
- ctrlButton->setDefaultContextHelp(ucstring(tooltip));
+ ctrlButton->setDefaultContextHelp(ucstring::makeFromUtf8(tooltip));
}
}
diff --git a/nel/src/gui/group_list.cpp b/nel/src/gui/group_list.cpp
index b49eed7cc..d619a8146 100644
--- a/nel/src/gui/group_list.cpp
+++ b/nel/src/gui/group_list.cpp
@@ -518,11 +518,10 @@ namespace NLGUI
{
_HardText = std::string( (const char*)ptr );
const char *propPtr = ptr;
- ucstring Text = ucstring(propPtr);
- if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i'))
- Text = CI18N::get (propPtr);
-
- addTextChild(Text);
+ if (NLMISC::startsWith(propPtr, "ui"))
+ addTextChild(CI18N::get(propPtr));
+ else
+ addTextChild(ucstring::makeFromUtf8(propPtr));
}
else
{
diff --git a/nel/src/gui/group_menu.cpp b/nel/src/gui/group_menu.cpp
index 3fc8d0bbb..830b74fb9 100644
--- a/nel/src/gui/group_menu.cpp
+++ b/nel/src/gui/group_menu.cpp
@@ -283,9 +283,10 @@ namespace NLGUI
if (name)
{
const char *ptrName = (const char*)name;
- ucstrName = ucstring(ptrName);
- if ((strlen(ptrName)>2) && (ptrName[0] == 'u') && (ptrName[1] == 'i'))
- ucstrName = CI18N::get (ptrName);
+ if (NLMISC::startsWith(ptrName, "ui"))
+ ucstrName = CI18N::get(ptrName);
+ else
+ ucstrName.fromUtf8(ptrName);
}
CXMLAutoPtr ah((const char*) xmlGetProp (cur, (xmlChar*)"handler"));
diff --git a/nel/src/gui/group_paragraph.cpp b/nel/src/gui/group_paragraph.cpp
index 9424c0218..f772309a6 100644
--- a/nel/src/gui/group_paragraph.cpp
+++ b/nel/src/gui/group_paragraph.cpp
@@ -476,11 +476,10 @@ namespace NLGUI
{
_HardText = std::string( (const char*)ptr );
const char *propPtr = ptr;
- ucstring Text = ucstring(propPtr);
- if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i'))
- Text = CI18N::get (propPtr);
-
- addTextChild(Text);
+ if (NLMISC::startsWith(propPtr, "ui"))
+ addTextChild(CI18N::get(propPtr));
+ else
+ addTextChild(ucstring::makeFromUtf8(propPtr));
}
else
{
diff --git a/nel/src/gui/group_tree.cpp b/nel/src/gui/group_tree.cpp
index 83c080b5e..9fad363f0 100644
--- a/nel/src/gui/group_tree.cpp
+++ b/nel/src/gui/group_tree.cpp
@@ -306,9 +306,10 @@ namespace NLGUI
if (name)
{
const char *ptrName = (const char*)name;
- Text = ucstring(ptrName);
- if ((strlen(ptrName)>2) && (ptrName[0] == 'u') && (ptrName[1] == 'i'))
- Text = CI18N::get (ptrName);
+ if (NLMISC::startsWith(ptrName, "ui"))
+ Text = CI18N::get(ptrName);
+ else
+ ucstring::makeFromUtf8(ptrName);
}
CXMLAutoPtr color((const char*) xmlGetProp (cur, (xmlChar*)"color"));
diff --git a/nel/src/gui/lua_ihm.cpp b/nel/src/gui/lua_ihm.cpp
index 946baa560..cf60444a6 100644
--- a/nel/src/gui/lua_ihm.cpp
+++ b/nel/src/gui/lua_ihm.cpp
@@ -1880,21 +1880,21 @@ namespace NLGUI
ucstring CLuaIHM::findReplaceAll(const ucstring &str, const std::string &search, const std::string &replace)
{
//H_AUTO(Lua_CLuaIHM_findReplaceAll)
- return findReplaceAll(str, ucstring(search), ucstring(replace));
+ return findReplaceAll(str, ucstring::makeFromUtf8(search), ucstring::makeFromUtf8(replace));
}
// ***************************************************************************
ucstring CLuaIHM::findReplaceAll(const ucstring &str, const std::string &search, const ucstring &replace)
{
//H_AUTO(Lua_CLuaIHM_findReplaceAll)
- return findReplaceAll(str, ucstring(search), ucstring(replace));
+ return findReplaceAll(str, ucstring::makeFromUtf8(search), replace);
}
// ***************************************************************************
ucstring CLuaIHM::findReplaceAll(const ucstring &str, const ucstring &search, const std::string &replace)
{
//H_AUTO(Lua_CLuaIHM_findReplaceAll)
- return findReplaceAll(str, ucstring(search), ucstring(replace));
+ return findReplaceAll(str, search, ucstring::makeFromUtf8(replace));
}
diff --git a/nel/src/gui/view_text.cpp b/nel/src/gui/view_text.cpp
index dab618ff8..1b7d3f457 100644
--- a/nel/src/gui/view_text.cpp
+++ b/nel/src/gui/view_text.cpp
@@ -982,11 +982,11 @@ namespace NLGUI
if (prop)
{
const char *propPtr = prop;
- _Text = ucstring(propPtr);
-
- if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i'))
- _Text = CI18N::get (propPtr);
- setCase (_Text, _CaseMode);
+ if (NLMISC::startsWith(propPtr, "ui"))
+ _Text = CI18N::get(propPtr);
+ else
+ _Text.fromUtf8(propPtr);
+ setCase(_Text, _CaseMode);
}
prop = (char*) xmlGetProp( cur, (xmlChar*)"hardtext_format" );
@@ -2155,7 +2155,7 @@ namespace NLGUI
float dotWidth = 0.f;
if (_OverflowText.size() > 0)
{
- si = TextContext->getStringInfo (ucstring(_OverflowText));
+ si = TextContext->getStringInfo(_OverflowText);
dotWidth = si.StringWidth;
}
diff --git a/nel/src/gui/view_text_formated.cpp b/nel/src/gui/view_text_formated.cpp
index ac9263936..aa948e986 100644
--- a/nel/src/gui/view_text_formated.cpp
+++ b/nel/src/gui/view_text_formated.cpp
@@ -34,26 +34,26 @@ namespace NLGUI
CViewTextFormated::IViewTextFormatter *CViewTextFormated::textFormatter = NULL;
- std::string CViewTextFormated::getProperty( const std::string &name ) const
- {
- if( name == "format" )
- {
- return getFormatString().toString();
- }
- else
- return CViewText::getProperty( name );
- }
-
- void CViewTextFormated::setProperty( const std::string &name, const std::string &value )
- {
- if( name == "format" )
+ std::string CViewTextFormated::getProperty(const std::string &name) const
+ {
+ if (name == "format")
{
- setFormatString( value );
- return;
+ return getFormatString().toUtf8();
}
else
- CViewText::setProperty( name, value );
- }
+ return CViewText::getProperty(name);
+ }
+
+ void CViewTextFormated::setProperty(const std::string &name, const std::string &value)
+ {
+ if (name == "format")
+ {
+ setFormatString(ucstring::makeFromUtf8(value));
+ return;
+ }
+ else
+ CViewText::setProperty(name, value);
+ }
xmlNodePtr CViewTextFormated::serialize( xmlNodePtr parentNode, const char *type ) const
{
@@ -62,7 +62,7 @@ namespace NLGUI
return NULL;
xmlSetProp( node, BAD_CAST "type", BAD_CAST "text_formated" );
- xmlSetProp( node, BAD_CAST "format", BAD_CAST getFormatString().c_str() );
+ xmlSetProp( node, BAD_CAST "format", BAD_CAST getFormatString().toUtf8().c_str() );
return NULL;
}
@@ -73,7 +73,7 @@ namespace NLGUI
if (!CViewText::parse(cur, parentGroup)) return false;
CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"format" ));
if (prop)
- setFormatString(ucstring((const char *) prop));
+ setFormatString(ucstring::makeFromUtf8((const char *)prop));
else
setFormatString(ucstring("$t"));
return true;
diff --git a/nel/src/gui/view_text_id_formated.cpp b/nel/src/gui/view_text_id_formated.cpp
index 28998cee0..5304e9e5c 100644
--- a/nel/src/gui/view_text_id_formated.cpp
+++ b/nel/src/gui/view_text_id_formated.cpp
@@ -33,36 +33,35 @@ NLMISC_REGISTER_OBJECT(CViewBase, CViewTextIDFormated, std::string, "text_id_for
namespace NLGUI
{
- std::string CViewTextIDFormated::getProperty( const std::string &name ) const
+ std::string CViewTextIDFormated::getProperty(const std::string &name) const
{
- if( name == "format" )
+ if (name == "format")
{
- return getFormatString().toString();
+ return getFormatString().toUtf8();
}
else
- return CViewTextID::getProperty( name );
+ return CViewTextID::getProperty(name);
}
-
- void CViewTextIDFormated::setProperty( const std::string &name, const std::string &value )
+ void CViewTextIDFormated::setProperty(const std::string &name, const std::string &value)
{
- if( name == "format" )
+ if (name == "format")
{
- setFormatString( value );
+ setFormatString(ucstring::makeFromUtf8(value));
return;
}
else
- CViewTextID::setProperty( name, value );
+ CViewTextID::setProperty(name, value);
}
- xmlNodePtr CViewTextIDFormated::serialize( xmlNodePtr parentNode, const char *type ) const
+ xmlNodePtr CViewTextIDFormated::serialize(xmlNodePtr parentNode, const char *type) const
{
- xmlNodePtr node = CViewTextID::serialize( parentNode, type );
- if( node == NULL )
+ xmlNodePtr node = CViewTextID::serialize(parentNode, type);
+ if (node == NULL)
return NULL;
xmlSetProp( node, BAD_CAST "type", BAD_CAST "text_id_formated" );
- xmlSetProp( node, BAD_CAST "format", BAD_CAST getFormatString().c_str() );
+ xmlSetProp( node, BAD_CAST "format", BAD_CAST getFormatString().toUtf8().c_str() );
return node;
}
@@ -73,7 +72,7 @@ namespace NLGUI
if (!CViewTextID::parse(cur, parentGroup)) return false;
CXMLAutoPtr prop((const char*) xmlGetProp( cur, (xmlChar*)"format" ));
if (prop)
- setFormatString(ucstring((const char *) prop));
+ setFormatString(ucstring::makeFromUtf8((const char *)prop));
else
setFormatString(ucstring("$t"));
return true;
diff --git a/nel/src/misc/system_utils.cpp b/nel/src/misc/system_utils.cpp
index 45da347bd..42fe63fca 100644
--- a/nel/src/misc/system_utils.cpp
+++ b/nel/src/misc/system_utils.cpp
@@ -167,7 +167,10 @@ bool CSystemUtils::copyTextToClipboard(const ucstring &text)
bool isUnicode = (IsClipboardFormatAvailable(CF_UNICODETEXT) == TRUE);
// allocates a buffer to copy text in global memory
- HGLOBAL mem = GlobalAlloc(GHND|GMEM_DDESHARE, (text.size()+1) * (isUnicode ? 2:1));
+ std::string textLocal;
+ if (!isUnicode) textLocal = NLMISC::wideToMbcs(text);
+ if (text.size() && !textLocal.size()) textLocal = text.toString();
+ HGLOBAL mem = GlobalAlloc(GHND | GMEM_DDESHARE, isUnicode ? ((text.size() + 1) * sizeof(wchar_t)) : textLocal.size());
if (mem)
{
@@ -179,7 +182,7 @@ bool CSystemUtils::copyTextToClipboard(const ucstring &text)
if (isUnicode)
wcscpy((wchar_t *)hLock, (const wchar_t *)text.c_str());
else
- strcpy((char *)hLock, text.toString().c_str());
+ strcpy((char *)hLock, textLocal.c_str());
// unlock buffer
GlobalUnlock(mem);
@@ -213,7 +216,7 @@ bool CSystemUtils::pasteTextFromClipboard(ucstring &text)
// get data from clipboard (if not of this type, they are converted)
// warning, this code can't be debuggued in VC++ IDE, hObj will be always NULL
- HANDLE hObj = GetClipboardData(isUnicode ? CF_UNICODETEXT:CF_TEXT);
+ HANDLE hObj = GetClipboardData(isUnicode ? CF_UNICODETEXT : CF_TEXT);
if (hObj)
{
@@ -224,9 +227,15 @@ bool CSystemUtils::pasteTextFromClipboard(ucstring &text)
{
// retrieve clipboard data
if (isUnicode)
- text = (const ucchar*)hLock;
- else
- text = (const char*)hLock;
+ {
+ text = (const ucchar *)hLock;
+ }
+ else
+ {
+ static_cast(text) = NLMISC::mbcsToWide((const char *)hLock);
+ if (!text.size() && ((const char *)hLock)[0])
+ text = (const char *)hLock;
+ }
// unlock data
GlobalUnlock(hObj);
diff --git a/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/ryzom/client/src/interface_v3/macrocmd_manager.cpp
index 4ffb2bb17..6aa831eac 100644
--- a/ryzom/client/src/interface_v3/macrocmd_manager.cpp
+++ b/ryzom/client/src/interface_v3/macrocmd_manager.cpp
@@ -636,7 +636,7 @@ public:
CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(Params));
if (pCS == NULL) return;
- pCS->setMacroText(pEB->getInputStringAsStdString());
+ pCS->setMacroText(pEB->getInputStringAsUtf8());
}
};
REGISTER_ACTION_HANDLER( CHandlerEBUpdateMacroText, "eb_update_macro_text");
@@ -703,10 +703,10 @@ public:
CGroupEditBox *pEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_MACROICONCREATION_EDITTEXT));
if (pEB != NULL)
{
- pEB->setInputStringAsStdString(pMCM->CurrentEditMacro.DispText);
+ pEB->setInputStringAsUtf8(pMCM->CurrentEditMacro.DispText);
CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_MACROICONCREATION_ICON));
if (pCS != NULL)
- pCS->setMacroText(pEB->getInputStringAsStdString());
+ pCS->setMacroText(pEB->getInputStringAsUtf8());
}
CAHManager::getInstance()->runActionHandler("set_macro_back", NULL, string("target=")+CTRL_MACROICONCREATION_ICON+"|value="+toString(back));
@@ -862,11 +862,11 @@ public:
if (pEB == NULL) return;
CMacroCmdManager *pMCM = CMacroCmdManager::getInstance();
- pMCM->CurrentEditMacro.Name = pEB->getInputStringAsStdString();
+ pMCM->CurrentEditMacro.Name = pEB->getInputStringAsUtf8();
if ((pMCM->CurrentEditMacro.Name.size() >= 2) &&
(pMCM->CurrentEditMacro.Name[0] == 'u') && (pMCM->CurrentEditMacro.Name[1] == 'i'))
pMCM->CurrentEditMacro.Name[0] = 'U';
- pEB->setInputString(pMCM->CurrentEditMacro.Name);
+ pEB->setInputStringAsUtf8(pMCM->CurrentEditMacro.Name);
}
};
REGISTER_ACTION_HANDLER( CHandlerNewMacroEnterName, "new_macro_enter_name");
diff --git a/ryzom/client/src/login.cpp b/ryzom/client/src/login.cpp
index 2da407ecb..96922d399 100644
--- a/ryzom/client/src/login.cpp
+++ b/ryzom/client/src/login.cpp
@@ -1379,8 +1379,8 @@ class CAHOnLogin : public IActionHandler
return;
}
- LoginLogin = pGEBLog->getInputStringAsStdString();
- LoginPassword = pGEBPwd->getInputStringAsStdString();
+ LoginLogin = pGEBLog->getInputString().toString(); // FIXME: Unicode login
+ LoginPassword = pGEBPwd->getInputString().toString();
onlogin();
}
From 639b4328171882c35d48fa0bfd7bb6ade71d1f87 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sat, 24 Oct 2020 21:17:44 +0800
Subject: [PATCH 033/205] Match GL behaviour in D3D for screensaver
---
.../3d/driver/direct3d/driver_direct3d.cpp | 23 ++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/nel/src/3d/driver/direct3d/driver_direct3d.cpp b/nel/src/3d/driver/direct3d/driver_direct3d.cpp
index fc853602f..211ed27fd 100644
--- a/nel/src/3d/driver/direct3d/driver_direct3d.cpp
+++ b/nel/src/3d/driver/direct3d/driver_direct3d.cpp
@@ -1225,12 +1225,29 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
D3DWndProc (pDriver, hWnd, message, wParam, lParam);
}
+ if (message == WM_SYSCOMMAND)
+ {
+ switch (wParam)
+ {
#ifdef NL_DISABLE_MENU
- // disable menu (F10, ALT and ALT+SPACE key doesn't freeze or open the menu)
- if(message == WM_SYSCOMMAND && wParam == SC_KEYMENU)
- return 0;
+ // disable menu (F10, ALT and ALT+SPACE key doesn't freeze or open the menu)
+ case SC_KEYMENU:
#endif // NL_DISABLE_MENU
+ // Screensaver Trying To Start?
+ case SC_SCREENSAVE:
+
+ // Monitor Trying To Enter Powersave?
+ case SC_MONITORPOWER:
+
+ // Prevent From Happening
+ return 0;
+
+ default:
+ break;
+ }
+ }
+
// ace: if we receive close, exit now or it'll assert after
if(message == WM_CLOSE)
{
From 8c6609943b1217735eaabcf77b273bee77554f89 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sun, 25 Oct 2020 01:23:14 +0800
Subject: [PATCH 034/205] Dump scenario, kaetemi/ryzomclassic#155
---
ryzom/client/src/r2/dmc/client_edition_module.cpp | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/ryzom/client/src/r2/dmc/client_edition_module.cpp b/ryzom/client/src/r2/dmc/client_edition_module.cpp
index 6740dabfe..e388707ca 100644
--- a/ryzom/client/src/r2/dmc/client_edition_module.cpp
+++ b/ryzom/client/src/r2/dmc/client_edition_module.cpp
@@ -1154,6 +1154,15 @@ void CClientEditionModule::startingScenario(class NLNET::IModuleProxy * /* serve
{
ok = true;
connectionState = "uiR2EDUploadScenario";
+
+#if !FINAL_VERSION
+ string filename = CFile::findNewFile("scenario.rt.txt");
+ COFile output(filename);
+ std::string ss;
+ rtDataPtr->serialize(ss);
+ output.serialBuffer((uint8*)ss.c_str(),(uint)ss.size());
+ output.flush();
+#endif
}
else
{
From 78917354d9bd23f279bd07f6feb01e2e1501f6c3 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sun, 25 Oct 2020 01:23:29 +0800
Subject: [PATCH 035/205] Disable tmp debug feature
---
ryzom/client/src/connection.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ryzom/client/src/connection.cpp b/ryzom/client/src/connection.cpp
index 47c45984d..38a10d7e4 100644
--- a/ryzom/client/src/connection.cpp
+++ b/ryzom/client/src/connection.cpp
@@ -981,7 +981,7 @@ TInterfaceState globalMenu()
while (PlayerWantToGoInGame == false)
{
- #if defined(NL_OS_WINDOWS) && defined(NL_DEBUG)
+ #if defined(NL_OS_WINDOWS) && defined(NL_DEBUG) && 0
// tmp for debug
if (::GetAsyncKeyState(VK_SPACE))
{
@@ -1067,7 +1067,7 @@ TInterfaceState globalMenu()
nlSleep(ClientCfg.Sleep);
}
- #if defined(NL_OS_WINDOWS) && defined(NL_DEBUG)
+ #if defined(NL_OS_WINDOWS) && defined(NL_DEBUG) && 0
if (::GetAsyncKeyState(VK_CONTROL))
{
pIM->displayUIViewBBoxs("");
From 06b430349c0b3d5150747c9f0f375fcc52517668 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sun, 25 Oct 2020 01:55:35 +0800
Subject: [PATCH 036/205] Disconnect if UDP Login fails, ryzom/ryzomcore#622
---
ryzom/client/src/network_connection.cpp | 12 ++++++++++++
ryzom/client/src/network_connection.h | 1 +
2 files changed, 13 insertions(+)
diff --git a/ryzom/client/src/network_connection.cpp b/ryzom/client/src/network_connection.cpp
index 731677043..c1e9d8975 100644
--- a/ryzom/client/src/network_connection.cpp
+++ b/ryzom/client/src/network_connection.cpp
@@ -680,6 +680,7 @@ bool CNetworkConnection::connect(string &result)
_LatestLoginTime = ryzomGetLocalTime ();
_LatestSyncTime = _LatestLoginTime;
_LatestProbeTime = _LatestLoginTime;
+ m_LoginAttempts = 0;
nlinfo("CNET[%p]: Client connected to shard, attempting login", this);
return true;
@@ -1091,6 +1092,17 @@ bool CNetworkConnection::stateLogin()
{
sendSystemLogin();
_LatestLoginTime = _UpdateTime;
+ if (m_LoginAttempts > 24)
+ {
+ m_LoginAttempts = 0;
+ disconnect(); // will send disconnection message
+ nlwarning("CNET[%p]: Too many LOGIN attempts, connection problem", this);
+ return false; // exit now from loop, don't expect a new state
+ }
+ else
+ {
+ ++m_LoginAttempts;
+ }
}
return false;
diff --git a/ryzom/client/src/network_connection.h b/ryzom/client/src/network_connection.h
index d11702682..84bb26d43 100644
--- a/ryzom/client/src/network_connection.h
+++ b/ryzom/client/src/network_connection.h
@@ -822,6 +822,7 @@ private:
void sendSystemLogin();
bool stateLogin();
NLMISC::TTime _LatestLoginTime;
+ int m_LoginAttempts;
//
void receiveSystemSync(NLMISC::CBitMemStream &msgin);
From 2568b6f321507c9d5b8178d55eed8385fca6fd48 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sun, 25 Oct 2020 01:56:10 +0800
Subject: [PATCH 037/205] Don't probe if normal received in probe state,
otherwise server will not enter probe state, ryzom/ryzomcore#622,
ryzom/ryzomcore#133
---
ryzom/client/src/network_connection.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/ryzom/client/src/network_connection.cpp b/ryzom/client/src/network_connection.cpp
index c1e9d8975..4778641c0 100644
--- a/ryzom/client/src/network_connection.cpp
+++ b/ryzom/client/src/network_connection.cpp
@@ -2320,6 +2320,7 @@ bool CNetworkConnection::stateProbe()
else
{
nlwarning("CNET[%p]: received normal in state Probe", this);
+ _LatestProbeTime = _UpdateTime;
}
}
}
From c252b56c93e5d7f18e66ace296d6a46fb84b93c3 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sun, 25 Oct 2020 04:18:56 +0800
Subject: [PATCH 038/205] Fix crash on save file corruption
---
ryzom/client/src/item_group_manager.cpp | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/ryzom/client/src/item_group_manager.cpp b/ryzom/client/src/item_group_manager.cpp
index fddba873f..83c8b4f5a 100644
--- a/ryzom/client/src/item_group_manager.cpp
+++ b/ryzom/client/src/item_group_manager.cpp
@@ -301,10 +301,18 @@ bool CItemGroupManager::loadGroups()
NLMISC::CIFile f;
f.open(userGroupFileName);
NLMISC::CIXml xmlStream;
- xmlStream.init(f);
- // Actual loading
xmlNodePtr globalEnclosing;
- globalEnclosing = xmlStream.getRootNode();
+ try
+ {
+ xmlStream.init(f);
+ // Actual loading
+ globalEnclosing = xmlStream.getRootNode();
+ }
+ catch (const NLMISC::EXmlParsingError &ex)
+ {
+ nlwarning("Failed to parse '%s', skip", userGroupFileName.c_str());
+ return false;
+ }
if(!globalEnclosing)
{
nlwarning("no root element in item_group xml, skipping xml parsing");
From a3780e307ed084223b87af505d613bb2a61ed468 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sun, 25 Oct 2020 05:44:08 +0800
Subject: [PATCH 039/205] Fix missing ghost components in animation loading
mode, kaetemi/ryzomclassic#155
---
ryzom/client/src/r2/editor.cpp | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/ryzom/client/src/r2/editor.cpp b/ryzom/client/src/r2/editor.cpp
index 96b935e34..036e77b21 100644
--- a/ryzom/client/src/r2/editor.cpp
+++ b/ryzom/client/src/r2/editor.cpp
@@ -212,14 +212,24 @@ CDynamicMapClient(eid, clientGateway, luaState)
void CDynamicMapClientEventForwarder::nodeErased(const std::string& instanceId, const std::string& attrName, sint32 position)
{
//H_AUTO(R2_CDynamicMapClientEventForwarder_nodeErased)
- if (getEditor().getMode() != CEditor::EditionMode) return;
+ if (getEditor().getMode() != CEditor::EditionMode)
+ {
+ nlassert(getEditor().getMode() != CEditor::AnimationModeLoading); /* Probably should not happen */
+ nldebug("Node erased, but not in edition mode");
+ return;
+ }
getEditor().nodeErased(instanceId, attrName, position);
}
void CDynamicMapClientEventForwarder::nodeSet(const std::string& instanceId, const std::string& attrName, CObject* value)
{
//H_AUTO(R2_CDynamicMapClientEventForwarder_nodeSet)
- if (getEditor().getMode() != CEditor::EditionMode) return;
+ if (getEditor().getMode() != CEditor::EditionMode
+ && getEditor().getMode() != CEditor::AnimationModeLoading /* Loading animation scenario from terminal, ghost nodes created by translator */)
+ {
+ nldebug("Node set, but not in edition mode");
+ return;
+ }
getEditor().nodeSet(instanceId, attrName, value);
}
@@ -227,7 +237,12 @@ void CDynamicMapClientEventForwarder::nodeInserted(const std::string& instanceId
const std::string& key, CObject* value)
{
//H_AUTO(R2_CDynamicMapClientEventForwarder_nodeInserted)
- if (getEditor().getMode() != CEditor::EditionMode) return;
+ if (getEditor().getMode() != CEditor::EditionMode
+ && getEditor().getMode() != CEditor::AnimationModeLoading /* Loading animation scenario from terminal, ghost nodes created by translator */)
+ {
+ nldebug("Node inserted, but not in edition mode");
+ return;
+ }
getEditor().nodeInserted(instanceId, attrName, position, key, value);
}
@@ -236,7 +251,12 @@ void CDynamicMapClientEventForwarder::nodeMoved(
const std::string& destInstanceId, const std::string& destAttrName, sint32 destPosition)
{
//H_AUTO(R2_CDynamicMapClientEventForwarder_nodeMoved)
- if (getEditor().getMode() != CEditor::EditionMode) return;
+ if (getEditor().getMode() != CEditor::EditionMode)
+ {
+ nlassert(getEditor().getMode() != CEditor::AnimationModeLoading); /* Probably should not happen */
+ nldebug("Node moved, but not in edition mode");
+ return;
+ }
getEditor().nodeMoved(instanceId, attrName, position, destInstanceId, destAttrName, destPosition);
}
From b61ad76ac2dae962c42b7a85a43e8f44d6335df7 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sat, 24 Oct 2020 23:14:45 +0800
Subject: [PATCH 040/205] Fix R2 feature info checkbox,
kaetemi/ryzomclassic#158
---
ryzom/client/data/gamedev/interfaces_v3/r2ed.xml | 4 ++--
ryzom/common/data_common/r2/r2_features.lua | 14 +++++++-------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/ryzom/client/data/gamedev/interfaces_v3/r2ed.xml b/ryzom/client/data/gamedev/interfaces_v3/r2ed.xml
index 54021b5bf..a522c9df0 100644
--- a/ryzom/client/data/gamedev/interfaces_v3/r2ed.xml
+++ b/ryzom/client/data/gamedev/interfaces_v3/r2ed.xml
@@ -3064,13 +3064,13 @@ text_y="-2"
-
-
+
diff --git a/ryzom/common/data_common/r2/r2_features.lua b/ryzom/common/data_common/r2/r2_features.lua
index e354c1280..53a63f6d9 100644
--- a/ryzom/common/data_common/r2/r2_features.lua
+++ b/ryzom/common/data_common/r2/r2_features.lua
@@ -1027,9 +1027,9 @@ r2.displayFeatureHelp = function(className)
assert(nil)
end
- local checkBox = getUI("ui:interface:feature_help:content:custom_bbox_enabled")
+ local checkBox = getUI("ui:interface:feature_help:content:show_again")
assert(checkBox)
- local chkBoxText = getUI("ui:interface:feature_help:content:text_custom")
+ local chkBoxText = getUI("ui:interface:feature_help:content:show_again_label")
assert(chkBoxText)
if className == "Npc" then
@@ -1082,21 +1082,21 @@ end
function r2.setFeatureDisplayHelp()
- local checkBox = getUI("ui:interface:feature_help:content:custom_bbox_enabled")
+ local checkBox = getUI("ui:interface:feature_help:content:show_again")
assert(checkBox)
- local isChecked = checkBox.pushed
- debugInfo("checked: " ..tostring(isChecked))
+ local showAgain = checkBox.pushed
+ --debugInfo("checked: " ..tostring(showAgain))
local ui = getUI("ui:interface:feature_help")
local name = ui.Env.uc_title
local len = string.len(name) - 10 - 6
local className = string.sub(name, -10-len, 6+len) --removing uiR2Ed and _HelpTitle
--formName = formName .."Form"
-
+
assert(className)
--debugInfo("Form name: " ..formName)
- if isChecked == false then
+ if showAgain then
r2.setDisplayInfo(className, 1)
else r2.setDisplayInfo(className, 0) end
From 92ee96a783dca7d5bb468dc1165425c5a500b531 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Sat, 24 Oct 2020 23:19:37 +0800
Subject: [PATCH 041/205] Log the recorded history, kaetemi/ryzomclassic#152
---
ryzom/server/src/ai_service/state_instance.h | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/ryzom/server/src/ai_service/state_instance.h b/ryzom/server/src/ai_service/state_instance.h
index 8f472702b..c38b7530d 100644
--- a/ryzom/server/src/ai_service/state_instance.h
+++ b/ryzom/server/src/ai_service/state_instance.h
@@ -505,7 +505,9 @@ void CStateInstance::processStateEvent(CAIEvent const& stateEvent, CAIState cons
if (getDebugHistory()->isRecording())
{
- nldebug("Reaction for event"); // FIXME: https://github.com/kaetemi/ryzomclassic/issues/152
+ nldebug("Reaction for event"); // FIXME: https://github.com/kaetemi/ryzomclassic/issues/152
+ nldebug("STATE: '%s' EVENT: '%s' REACTION: '%s'", state->getAliasNode()->fullName().c_str(),
+ stateEvent.getName().c_str(), reaction.getAliasNode()->fullName().c_str()); // FIXME: https://github.com/kaetemi/ryzomclassic/issues/152
getDebugHistory()->addHistory("STATE: '%s' EVENT: '%s' REACTION: '%s'", state->getAliasNode()->fullName().c_str(),
stateEvent.getName().c_str(), reaction.getAliasNode()->fullName().c_str());
}
@@ -514,13 +516,13 @@ void CStateInstance::processStateEvent(CAIEvent const& stateEvent, CAIState cons
if (!reaction.getAction())
{
- nldebug("Failed to find action for event"); // FIXME: https://github.com/kaetemi/ryzomclassic/issues/152
+ nldebug("Failed to find action for event"); // FIXME: https://github.com/kaetemi/ryzomclassic/issues/152
nlwarning("Failed to find action for event: %s",reaction.getAliasNode()->fullName().c_str());
continue;
}
if (!reaction.getAction()->executeAction(this, NULL))
{
- nldebug("Failed to execute action for event"); // FIXME: https://github.com/kaetemi/ryzomclassic/issues/152
+ nldebug("Failed to execute action for event"); // FIXME: https://github.com/kaetemi/ryzomclassic/issues/152
nlwarning("Failed to execute action for event '%s': for stateInstance:'%s' in state:'%s'", stateEvent.getName().c_str(),
aliasTreeOwner()->getAliasNode()->fullName().c_str(), state->getAliasNode()->fullName().c_str());
continue;
@@ -531,7 +533,9 @@ void CStateInstance::processStateEvent(CAIEvent const& stateEvent, CAIState cons
{
if (getDebugHistory()->isRecording())
{
- nldebug("No reaction for event"); // FIXME: https://github.com/kaetemi/ryzomclassic/issues/152
+ nldebug("No reaction for event"); // FIXME: https://github.com/kaetemi/ryzomclassic/issues/152
+ nldebug("STATE: '%s' EVENT: '%s' NO REACTION", state->getAliasNode()->fullName().c_str(),
+ stateEvent.getName().c_str()); // FIXME: https://github.com/kaetemi/ryzomclassic/issues/152
getDebugHistory()->addHistory("STATE: '%s' EVENT: '%s' NO REACTION", state->getAliasNode()->fullName().c_str(),
stateEvent.getName().c_str());
}
From 277a854f8da809bb4482e8bc8ca86f5e4473a79a Mon Sep 17 00:00:00 2001
From: Xtarsia <69606701+Xtarsia@users.noreply.github.com>
Date: Mon, 26 Oct 2020 15:00:30 +0000
Subject: [PATCH 042/205] Update widgets.xml
Closes #157
---
ryzom/client/data/gamedev/interfaces_v3/widgets.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ryzom/client/data/gamedev/interfaces_v3/widgets.xml b/ryzom/client/data/gamedev/interfaces_v3/widgets.xml
index b78ee1ff1..40ecda46f 100644
--- a/ryzom/client/data/gamedev/interfaces_v3/widgets.xml
+++ b/ryzom/client/data/gamedev/interfaces_v3/widgets.xml
@@ -1384,7 +1384,7 @@
-
+
From 973531f461d46ded593c4615c6575a96cb09c1a7 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Mon, 26 Oct 2020 03:55:36 +0800
Subject: [PATCH 043/205] UTF string view base, ryzom/ryzomcore#335
---
nel/include/nel/misc/types_nl.h | 8 +++
nel/include/nel/misc/utf_string_view.h | 95 ++++++++++++++++++++++++++
nel/src/misc/utf_string_view.cpp | 76 +++++++++++++++++++++
3 files changed, 179 insertions(+)
create mode 100644 nel/include/nel/misc/utf_string_view.h
create mode 100644 nel/src/misc/utf_string_view.cpp
diff --git a/nel/include/nel/misc/types_nl.h b/nel/include/nel/misc/types_nl.h
index 73c05b3a5..b8fe8270a 100644
--- a/nel/include/nel/misc/types_nl.h
+++ b/nel/include/nel/misc/types_nl.h
@@ -552,6 +552,14 @@ typedef wchar_t ucchar;
typedef uint16 ucchar;
#endif
+#ifdef NL_CPP14
+typedef char32_t u32char;
+typedef std::u32string u32string;
+#else
+typedef uint32 u32char;
+typedef std::basic_string u32string;
+#endif
+
#ifndef NL_OVERRIDE
#define NL_OVERRIDE override
#endif
diff --git a/nel/include/nel/misc/utf_string_view.h b/nel/include/nel/misc/utf_string_view.h
new file mode 100644
index 000000000..78df8c141
--- /dev/null
+++ b/nel/include/nel/misc/utf_string_view.h
@@ -0,0 +1,95 @@
+// NeL - MMORPG Framework
+// Copyright (C) 2020 Jan BOON (Kaetemi)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+#ifndef NLMISC_UTF_STRING_VIEW_H
+#define NLMISC_UTF_STRING_VIEW_H
+
+#include
+#include
+#include
+#include
+
+namespace NLMISC {
+
+/// String view for UTF-8 and UTF-32 iteration as 32-bit codepoints.
+/// This string view keeps the string as a reference, it does not make a copy.
+/// Only use this for iterating a string's codepoints.
+/// Strings are not necessarily NUL-terminated.
+class CUtfStringView
+{
+public:
+ inline CUtfStringView(const char *utf8Str) : m_Str(utf8Str), m_Size(strlen(utf8Str)), m_Iterator(utf8Iterator) {}
+ inline CUtfStringView(const char *utf8Str, size_t len): m_Str(utf8Str), m_Size(len), m_Iterator(utf8Iterator)
+ {
+ nlassert(len <= strlen(utf8Str));
+ }
+
+ inline CUtfStringView(const std::string &utf8Str) : m_Str(utf8Str.c_str()), m_Size(utf8Str.size()), m_Iterator(utf8Iterator) {}
+ inline CUtfStringView(const ucstring &utf16Str) : m_Str(utf16Str.c_str()), m_Size(utf16Str.size() << 1), m_Iterator(utf16Iterator) {}
+ inline CUtfStringView(const u32string &utf32Str) : m_Str(utf32Str.c_str()), m_Size(utf32Str.size() << 2), m_Iterator(utf32Iterator) {}
+
+ std::string toUtf8(); // Makes a copy
+ u32string toUtf32(); // Makes a copy
+
+ inline bool isUtf8() { return m_Iterator == utf8Iterator; }
+ inline bool isUtf16() { return m_Iterator == utf16Iterator; }
+ inline bool isUtf32() { return m_Iterator == utf32Iterator; }
+
+ struct const_iterator
+ {
+ public:
+ inline void operator++()
+ {
+ m_Char = m_View.m_Iterator(&m_Addr);
+ if ((ptrdiff_t)m_Addr > ((ptrdiff_t)m_View.m_Str + m_View.m_Size))
+ {
+ m_Addr = 0;
+ m_Char = 0;
+ }
+ }
+ inline bool operator!=(const const_iterator &o) const { return m_Addr != o.m_Addr; }
+ inline bool operator==(const const_iterator &o) const { return m_Addr == o.m_Addr; }
+ inline const u32char &operator*() const { return m_Char; }
+ private:
+ friend class CUtfStringView;
+ inline const_iterator(const CUtfStringView &view, const void *addr) : m_View(view), m_Addr(addr), m_Char(addr ? view.m_Iterator(&m_Addr) : 0) { }
+ const CUtfStringView &m_View;
+ const void *m_Addr; // Next address
+ u32char m_Char;
+ };
+
+ typedef const_iterator iterator;
+
+ iterator begin() const { return iterator(*this, m_Str); }
+ inline iterator end() const { return iterator(*this, NULL); }
+
+private:
+ typedef u32char (*TIterator)(const void **addr);
+ static u32char utf8Iterator(const void **addr);
+ static u32char utf16Iterator(const void **addr);
+ static u32char utf32Iterator(const void **addr);
+
+ const void *const m_Str;
+ const size_t m_Size;
+ const TIterator m_Iterator;
+
+}; /* class CUtfStringView */
+
+} /* namespace NLMISC */
+
+#endif /* #ifndef NLMISC_STREAMED_PACKAGE_PROVIDER_H */
+
+/* end of file */
diff --git a/nel/src/misc/utf_string_view.cpp b/nel/src/misc/utf_string_view.cpp
new file mode 100644
index 000000000..57dc5e226
--- /dev/null
+++ b/nel/src/misc/utf_string_view.cpp
@@ -0,0 +1,76 @@
+// NeL - MMORPG Framework
+// Copyright (C) 2020 Jan BOON (Kaetemi)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+#include "stdmisc.h"
+
+// Project includes
+#include
+
+namespace NLMISC
+{
+
+std::string CUtfStringView::toUtf8()
+{
+ if (m_Iterator == utf8Iterator)
+ return std::string((const char *)m_Str, (const char *)((ptrdiff_t)m_Str + m_Size));
+ std::string res;
+ res.reserve((m_Size << 1) + 1);
+ for (iterator it(begin()), end(end()); it != end; ++it)
+ {
+ u32char c = *it;
+ res += (char)c; /* TODO: Encode UTF-8 */
+ }
+}
+
+u32string CUtfStringView::toUtf32()
+{
+ if (m_Iterator == utf32Iterator)
+ return u32string((const u32char *)m_Str, (const u32char *)((ptrdiff_t)m_Str + m_Size));
+ u32string res;
+ res.reserve(m_Size + 1);
+ for (iterator it(begin()), end(end()); it != end; ++it)
+ res += *it;
+}
+
+u32char CUtfStringView::utf8Iterator(const void **addr)
+{
+ /* TODO: Decode UTF-8 */
+ const ucchar **pp = reinterpret_cast(addr);
+ ucchar c = **pp;
+ ++(*pp);
+ return c;
+}
+
+u32char CUtfStringView::utf16Iterator(const void **addr)
+{
+ /* TODO: Decode UTF-16 */
+ const ucchar **pp = reinterpret_cast(addr);
+ ucchar c = **pp;
+ ++(*pp);
+ return c;
+}
+
+u32char CUtfStringView::utf32Iterator(const void **addr)
+{
+ const u32char **pp = reinterpret_cast(addr);
+ u32char c = **pp;
+ ++(*pp);
+ return c;
+}
+
+} /* namespace NLMISC */
+
+/* end of file */
From 81143cdf438cc7e3b8e54e97dafcac03b82a028c Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Wed, 28 Oct 2020 01:03:02 +0800
Subject: [PATCH 044/205] Proper UTF encoding, ryzom/ryzomcore#335
---
nel/include/nel/misc/ucstring.h | 5 +
nel/include/nel/misc/utf_string_view.h | 18 +--
nel/src/misc/ucstring.cpp | 131 +--------------------
nel/src/misc/utf_string_view.cpp | 154 ++++++++++++++++++++++---
4 files changed, 157 insertions(+), 151 deletions(-)
diff --git a/nel/include/nel/misc/ucstring.h b/nel/include/nel/misc/ucstring.h
index 8859a21d9..28c83ce2f 100644
--- a/nel/include/nel/misc/ucstring.h
+++ b/nel/include/nel/misc/ucstring.h
@@ -46,6 +46,11 @@ public:
{
}
+ ucstring(const ucchar *begin, const ucchar *end)
+ : ucstringbase(begin, end)
+ {
+ }
+
ucstring(const std::string &str)
: ucstringbase()
{
diff --git a/nel/include/nel/misc/utf_string_view.h b/nel/include/nel/misc/utf_string_view.h
index 78df8c141..503fc3737 100644
--- a/nel/include/nel/misc/utf_string_view.h
+++ b/nel/include/nel/misc/utf_string_view.h
@@ -19,7 +19,6 @@
#include
#include
-#include
#include
namespace NLMISC {
@@ -27,7 +26,7 @@ namespace NLMISC {
/// String view for UTF-8 and UTF-32 iteration as 32-bit codepoints.
/// This string view keeps the string as a reference, it does not make a copy.
/// Only use this for iterating a string's codepoints.
-/// Strings are not necessarily NUL-terminated.
+/// Strings are not required to be NUL-terminated, but must have at least one character extra.
class CUtfStringView
{
public:
@@ -41,12 +40,13 @@ public:
inline CUtfStringView(const ucstring &utf16Str) : m_Str(utf16Str.c_str()), m_Size(utf16Str.size() << 1), m_Iterator(utf16Iterator) {}
inline CUtfStringView(const u32string &utf32Str) : m_Str(utf32Str.c_str()), m_Size(utf32Str.size() << 2), m_Iterator(utf32Iterator) {}
- std::string toUtf8(); // Makes a copy
- u32string toUtf32(); // Makes a copy
+ std::string toUtf8(bool reEncode = false) const; // Makes a copy
+ ucstring toUtf16(bool reEncode = false) const; // Makes a copy
+ u32string toUtf32() const; // Makes a copy
- inline bool isUtf8() { return m_Iterator == utf8Iterator; }
- inline bool isUtf16() { return m_Iterator == utf16Iterator; }
- inline bool isUtf32() { return m_Iterator == utf32Iterator; }
+ inline bool isUtf8() const { return m_Iterator == utf8Iterator; }
+ inline bool isUtf16() const { return m_Iterator == utf16Iterator; }
+ inline bool isUtf32() const { return m_Iterator == utf32Iterator; }
struct const_iterator
{
@@ -82,8 +82,8 @@ private:
static u32char utf16Iterator(const void **addr);
static u32char utf32Iterator(const void **addr);
- const void *const m_Str;
- const size_t m_Size;
+ const void *const m_Str; // String
+ const size_t m_Size; // Size in bytes
const TIterator m_Iterator;
}; /* class CUtfStringView */
diff --git a/nel/src/misc/ucstring.cpp b/nel/src/misc/ucstring.cpp
index 5fad643ce..79cf78f7e 100644
--- a/nel/src/misc/ucstring.cpp
+++ b/nel/src/misc/ucstring.cpp
@@ -16,6 +16,7 @@
#include "stdmisc.h"
#include "nel/misc/ucstring.h"
+#include "nel/misc/utf_string_view.h"
void ucstring::toString(std::string &str) const
{
@@ -31,138 +32,12 @@ void ucstring::toString(std::string &str) const
std::string ucstring::toUtf8() const
{
-#if defined(NL_OS_WINDOWS)
- // Use OS implementation
- nlctassert(sizeof(wchar_t) == sizeof(ucchar));
- nlctassert(sizeof(wchar_t) == sizeof(uint16));
- return NLMISC::wideToUtf8(static_cast(*this));
-#else
- std::string res;
- ucstring::const_iterator first(begin()), last(end());
- for (; first != last; ++first)
- {
- //ucchar c = *first;
- uint nbLoop = 0;
- if (*first < 0x80)
- res += char(*first);
- else if (*first < 0x800)
- {
- ucchar c = *first;
- c = c >> 6;
- c = c & 0x1F;
- res += char(c) | 0xC0;
- nbLoop = 1;
- }
- else /*if (*first < 0x10000)*/
- {
- ucchar c = *first;
- c = c >> 12;
- c = c & 0x0F;
- res += char(c) | 0xE0;
- nbLoop = 2;
- }
-
- for (uint i = 0; i < nbLoop; ++i)
- {
- ucchar c = *first;
- c = c >> ((nbLoop - i - 1) * 6);
- c = c & 0x3F;
- res += char(c) | 0x80;
- }
- }
- return res;
-#endif
+ return NLMISC::CUtfStringView(*this).toUtf8();
}
void ucstring::fromUtf8(const std::string &stringUtf8)
{
-#if defined(NL_OS_WINDOWS)
- // Use OS implementation
- nlctassert(sizeof(wchar_t) == sizeof(ucchar));
- nlctassert(sizeof(wchar_t) == sizeof(uint16));
- nlctassert(sizeof(std::wstring) == sizeof(ucstring)); // These can be swapped on Windows
- static_cast(*this) = nlmove(NLMISC::utf8ToWide(stringUtf8));
- if (stringUtf8.size() && !size())
- rawCopy(stringUtf8);
-#else
- // clear the string
- erase();
-
- uint8 c;
- ucchar code;
- sint iterations = 0;
-
- std::string::const_iterator first(stringUtf8.begin()), last(stringUtf8.end());
- for (; first != last;)
- {
- c = *first++;
- code = c;
-
- if ((code & 0xFE) == 0xFC)
- {
- code &= 0x01;
- iterations = 5;
- }
- else if ((code & 0xFC) == 0xF8)
- {
- code &= 0x03;
- iterations = 4;
- }
- else if ((code & 0xF8) == 0xF0)
- {
- code &= 0x07;
- iterations = 3;
- }
- else if ((code & 0xF0) == 0xE0)
- {
- code &= 0x0F;
- iterations = 2;
- }
- else if ((code & 0xE0) == 0xC0)
- {
- code &= 0x1F;
- iterations = 1;
- }
- else if ((code & 0x80) == 0x80)
- {
- // If it's not a valid UTF8 string, just copy the line without utf8 conversion
- rawCopy(stringUtf8);
- return;
- }
- else
- {
- push_back(code);
- iterations = 0;
- }
-
- if (iterations)
- {
- for (sint i = 0; i < iterations; i++)
- {
- if (first == last)
- {
- // If it's not a valid UTF8 string, just copy the line without utf8 conversion
- rawCopy(stringUtf8);
- return;
- }
-
- uint8 ch;
- ch = *first++;
-
- if ((ch & 0xC0) != 0x80)
- {
- // If it's not a valid UTF8 string, just copy the line without utf8 conversion
- rawCopy(stringUtf8);
- return;
- }
-
- code <<= 6;
- code |= (ucchar)(ch & 0x3F);
- }
- push_back(code);
- }
- }
-#endif
+ *this = NLMISC::CUtfStringView(stringUtf8).toUtf16();
}
void ucstring::rawCopy(const std::string &str)
diff --git a/nel/src/misc/utf_string_view.cpp b/nel/src/misc/utf_string_view.cpp
index 57dc5e226..ee5fdf089 100644
--- a/nel/src/misc/utf_string_view.cpp
+++ b/nel/src/misc/utf_string_view.cpp
@@ -19,52 +19,178 @@
// Project includes
#include
+// References:
+// - https://twiserandom.com/unicode/unicode-encoding-utf-8-utf-16-utf-32/
+// - https://www.compart.com/en/unicode/U+1F30D
+// - 0xF0 0x9F 0x8C 0x8D
+// - 0xD83C 0xDF0D
+// - 0x0001F30D
+
namespace NLMISC
{
-std::string CUtfStringView::toUtf8()
+std::string CUtfStringView::toUtf8(bool reEncode) const
{
- if (m_Iterator == utf8Iterator)
+ // Decode UTF and encode UTF-8
+ // This implementation makes no attempt at fixing invalid codepoints
+ if (m_Iterator == utf8Iterator && !reEncode)
return std::string((const char *)m_Str, (const char *)((ptrdiff_t)m_Str + m_Size));
std::string res;
- res.reserve((m_Size << 1) + 1);
+ res.reserve(m_Size);
+ for (iterator it(begin()), end(end()); it != end; ++it)
+ {
+ u32char c = *it;
+ if (c < 0x80)
+ {
+ // Encode as 1 byte
+ res += (char)c;
+ }
+ else if (c < 0x0800)
+ {
+ // Encode as 2 bytes
+ res += (char)((c & 0x07C0) >> 6) | 0xC0;
+ res += (char)(c & 0x3F) | 0x80;
+ }
+ else if (c < 0x010000)
+ {
+ // Encode as 3 bytes
+ res += (char)((c & 0xF000) >> 12) | 0xE0;
+ res += (char)((c & 0x0FC0) >> 6) | 0x80;
+ res += (char)(c & 0x3F) | 0x80;
+ }
+ else
+ {
+ // Encode as 4 bytes
+ res += (char)((c & 0x1C0000) >> 18) | 0xF0;
+ res += (char)((c & 0x03F000) >> 12) | 0x80;
+ res += (char)((c & 0x0FC0) >> 6) | 0x80;
+ res += (char)(c & 0x3F) | 0x80;
+ }
+ }
+ return res;
+}
+
+ucstring CUtfStringView::toUtf16(bool reEncode) const
+{
+ if (m_Iterator == utf16Iterator && !reEncode)
+ return ucstring((const ucchar *)m_Str, (const ucchar *)((ptrdiff_t)m_Str + m_Size));
+ ucstring res;
+ res.reserve(m_Size << 1);
for (iterator it(begin()), end(end()); it != end; ++it)
{
u32char c = *it;
- res += (char)c; /* TODO: Encode UTF-8 */
+ if (c < 0x10000)
+ {
+ res += c;
+ }
+ else
+ {
+ c -= 0x10000;
+ res += (c >> 10) | 0xD800;
+ res += (c & 0x3FF) | 0xDC00;
+ }
}
+ return res;
}
-u32string CUtfStringView::toUtf32()
+u32string CUtfStringView::toUtf32() const
{
+ // Decode any UTF
+ // This implementation makes no attempt at fixing bad encoding
if (m_Iterator == utf32Iterator)
return u32string((const u32char *)m_Str, (const u32char *)((ptrdiff_t)m_Str + m_Size));
u32string res;
- res.reserve(m_Size + 1);
+ res.reserve(m_Size << 2);
for (iterator it(begin()), end(end()); it != end; ++it)
res += *it;
+ return res;
}
u32char CUtfStringView::utf8Iterator(const void **addr)
{
- /* TODO: Decode UTF-8 */
- const ucchar **pp = reinterpret_cast(addr);
- ucchar c = **pp;
+ // Decode UTF-8
+ // This implementation makes no attempt at fixing bad encoding, except for bad UTF-16 surrogate pairs
+ const uint8 **pp = reinterpret_cast(addr);
+ u32char c0 = **pp;
++(*pp);
- return c;
+ if ((c0 & 0xC0) == 0xC0)
+ {
+ uint8 cx = **pp;
+ if ((cx & 0xC0) == 0x80)
+ {
+ ++(*pp);
+ c0 &= 0x3F; // Drop first two bits
+ c0 <<= 6;
+ c0 |= (cx & 0x3F); // 12 bits now (6 + 6), 2-byte encoding
+ if (c0 & 0x800)
+ {
+ cx = **pp;
+ if ((cx & 0xC0) == 0x80)
+ {
+ ++(*pp);
+ c0 &= 0x07FF; // Drop first bit
+ c0 <<= 6;
+ c0 |= (cx & 0x3F); // 17 bits now (12 - 1 + 6), 3-byte encoding
+ if (c0 & 0x10000)
+ {
+ cx = **pp;
+ if ((cx & 0xC0) == 0x80)
+ {
+ ++(*pp);
+ c0 &= 0xFFFF; // Drop first bit
+ c0 <<= 6;
+ c0 |= (cx & 0x3F); // 22 bits now (17 - 1 + 6), 3-byte encoding
+ }
+ }
+ else if ((c0 & 0xFC00) == 0xD800) // Higher bits of nutcase UTF-16 encoded as UTF-8
+ {
+ uint8 cy;
+ if ((*pp)[0] == 0xED && ((cx = (*pp)[1]) & 0xF0) == 0xB0 && ((cy = (*pp)[2]) & 0xC0) == 0x80)
+ {
+ // Lower bits of nutcase UTF-16 encoded as UTF-8
+ (*pp) += 3;
+ uint16 c1 = (cx & 0x0F);
+ c1 <<= 6;
+ c1 |= (cy & 0x3F);
+ c0 &= 0x03FF;
+ c0 <<= 10;
+ c0 |= (c1 & 0x03FF);
+ c0 += 0x10000;
+ }
+ }
+ }
+ }
+ }
+ }
+ return c0;
}
u32char CUtfStringView::utf16Iterator(const void **addr)
{
- /* TODO: Decode UTF-16 */
- const ucchar **pp = reinterpret_cast(addr);
- ucchar c = **pp;
+ // Decode UTF-16
+ // This implementation makes no attempt at fixing bad encoding
+ const uint16 **pp = reinterpret_cast(addr);
+ u32char c0 = **pp;
++(*pp);
- return c;
+ if ((c0 & 0xFC00) == 0xD800) // Higher bits
+ {
+ uint16 c1 = **pp;
+ if ((c1 & 0xFC00) == 0xDC00) // Lower bits
+ {
+ ++(*pp);
+ c0 &= 0x03FF;
+ c0 <<= 10;
+ c0 |= (c1 & 0x03FF);
+ c0 += 0x10000;
+ }
+ }
+ return c0;
}
u32char CUtfStringView::utf32Iterator(const void **addr)
{
+ // UTF-32
+ // This implementation makes no attempt at fixing bad encoding
const u32char **pp = reinterpret_cast(addr);
u32char c = **pp;
++(*pp);
From 8fc6ec3b3554e95e509979353a4f28b66a2cd55c Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Wed, 28 Oct 2020 01:03:13 +0800
Subject: [PATCH 045/205] Show box character instead of dot
---
nel/src/3d/font_generator.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/nel/src/3d/font_generator.cpp b/nel/src/3d/font_generator.cpp
index 44d8f5ab0..0bad785a6 100644
--- a/nel/src/3d/font_generator.cpp
+++ b/nel/src/3d/font_generator.cpp
@@ -307,11 +307,13 @@ uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, bool embolden, bool obl
// retrieve glyph index from character code
FT_UInt glyph_index = FT_Get_Char_Index (_Face, c);
+ /*
if (glyph_index == 0)
{
// no glyph available, replace with a dot
glyph_index = FT_Get_Char_Index (_Face, ucchar('.'));
}
+ */
// load glyph image into the slot (erase previous one)
error = FT_Load_Glyph (_Face, glyph_index, FT_LOAD_DEFAULT);
From 25049eaead0d2cf2cb9e0d902923a7195e09663a Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Wed, 28 Oct 2020 01:15:16 +0800
Subject: [PATCH 046/205] Complete some missing implementation for wide strings
---
nel/include/nel/misc/utf_string_view.h | 15 ++++++++++++
nel/src/misc/string_common.cpp | 9 ++++---
nel/src/misc/utf_string_view.cpp | 33 ++++++++++++++++++++++++++
3 files changed, 52 insertions(+), 5 deletions(-)
diff --git a/nel/include/nel/misc/utf_string_view.h b/nel/include/nel/misc/utf_string_view.h
index 503fc3737..e972ca7cf 100644
--- a/nel/include/nel/misc/utf_string_view.h
+++ b/nel/include/nel/misc/utf_string_view.h
@@ -35,6 +35,19 @@ public:
{
nlassert(len <= strlen(utf8Str));
}
+#if defined(NL_OS_WINDOWS)
+ inline CUtfStringView(const wchar_t *utf16Str) : m_Str(utf16Str), m_Size(wcslen(utf16Str)), m_Iterator(utf16Iterator) {}
+ inline CUtfStringView(const wchar_t *utf16Str, size_t len): m_Str(utf16Str), m_Size(len), m_Iterator(utf16Iterator)
+ {
+ nlassert(len <= wcslen(utf16Str));
+ }
+#else
+ inline CUtfStringView(const wchar_t *utf32Str) : m_Str(utf32Str), m_Size(wcslen(utf32Str)), m_Iterator(utf32Iterator) {}
+ inline CUtfStringView(const wchar_t *utf32Str, size_t len): m_Str(utf32Str), m_Size(len), m_Iterator(utf32Iterator)
+ {
+ nlassert(len <= wcslen(utf32Str));
+ }
+#endif
inline CUtfStringView(const std::string &utf8Str) : m_Str(utf8Str.c_str()), m_Size(utf8Str.size()), m_Iterator(utf8Iterator) {}
inline CUtfStringView(const ucstring &utf16Str) : m_Str(utf16Str.c_str()), m_Size(utf16Str.size() << 1), m_Iterator(utf16Iterator) {}
@@ -44,6 +57,8 @@ public:
ucstring toUtf16(bool reEncode = false) const; // Makes a copy
u32string toUtf32() const; // Makes a copy
+ std::wstring toWide() const; // Platform dependent, UTF-16 or UTF-32. Makes a copy.
+
inline bool isUtf8() const { return m_Iterator == utf8Iterator; }
inline bool isUtf16() const { return m_Iterator == utf16Iterator; }
inline bool isUtf32() const { return m_Iterator == utf32Iterator; }
diff --git a/nel/src/misc/string_common.cpp b/nel/src/misc/string_common.cpp
index 93122cc70..f869a5d35 100644
--- a/nel/src/misc/string_common.cpp
+++ b/nel/src/misc/string_common.cpp
@@ -21,6 +21,7 @@
#include "nel/misc/string_common.h"
#include "nel/misc/sstring.h"
+#include "nel/misc/utf_string_view.h"
using namespace std;
@@ -228,8 +229,7 @@ std::string wideToUtf8(const wchar_t *str, size_t len)
#if defined(NL_OS_WINDOWS)
return winWideToCp(str, len, CP_UTF8);
#else
- // TODO: UTF-32 to UTF-8
- nlassert(false);
+ return CUtfStringView(str, len).toUtf8();
#endif
}
@@ -242,10 +242,9 @@ std::string wideToUtf8(const std::wstring &str)
std::wstring utf8ToWide(const char *str, size_t len)
{
#if defined(NL_OS_WINDOWS)
- return winCpToWide(str, len, CP_UTF8);
+ return winCpToWide(str, len, CP_UTF8); // UTF-16
#else
- // TODO: UTF-8 to UTF-32
- nlassert(false);
+ return CUtfStringView(str, len).toWide(); // UTF-32
#endif
}
diff --git a/nel/src/misc/utf_string_view.cpp b/nel/src/misc/utf_string_view.cpp
index ee5fdf089..db2ea7cec 100644
--- a/nel/src/misc/utf_string_view.cpp
+++ b/nel/src/misc/utf_string_view.cpp
@@ -106,6 +106,39 @@ u32string CUtfStringView::toUtf32() const
return res;
}
+std::wstring CUtfStringView::toWide() const
+{
+#ifdef NL_OS_WINDOWS
+ if (m_Iterator == utf16Iterator)
+ return std::wstring((const wchar_t *)m_Str, (const wchar_t *)((ptrdiff_t)m_Str + m_Size));
+ std::wstring res;
+ res.reserve(m_Size << 1);
+ for (iterator it(begin()), end(end()); it != end; ++it)
+ {
+ u32char c = *it;
+ if (c < 0x10000)
+ {
+ res += c;
+ }
+ else
+ {
+ c -= 0x10000;
+ res += (c >> 10) | 0xD800;
+ res += (c & 0x3FF) | 0xDC00;
+ }
+ }
+ return res;
+#else
+ if (m_Iterator == utf32Iterator)
+ return std::wstring((const wchar_t *)m_Str, (const wchar_t *)((ptrdiff_t)m_Str + m_Size));
+ std::wstring res;
+ res.reserve(m_Size << 2);
+ for (iterator it(begin()), end(end()); it != end; ++it)
+ res += *it;
+ return res;
+#endif
+}
+
u32char CUtfStringView::utf8Iterator(const void **addr)
{
// Decode UTF-8
From dca59073aa4121819a080cb5bec367db8c32c7d9 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Wed, 28 Oct 2020 01:15:49 +0800
Subject: [PATCH 047/205] Use platform wide string interface for platform api,
not ucstring
---
nel/src/misc/path.cpp | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/nel/src/misc/path.cpp b/nel/src/misc/path.cpp
index a2f817210..2e3aacae6 100644
--- a/nel/src/misc/path.cpp
+++ b/nel/src/misc/path.cpp
@@ -2790,16 +2790,13 @@ bool CPath::isAbsolutePath(const std::string &path)
bool CFile::setRWAccess(const std::string &filename)
{
#ifdef NL_OS_WINDOWS
- ucstring ucFile;
- ucFile.fromUtf8(filename);
-
- wchar_t *wideFile = (wchar_t*)ucFile.c_str();
+ std::wstring wideFile = NLMISC::utf8ToWide(filename);
// if the file exists and there's no write access
- if (_waccess (wideFile, 00) == 0 && _waccess (wideFile, 06) == -1)
+ if (_waccess (wideFile.c_str(), 00) == 0 && _waccess (wideFile.c_str(), 06) == -1)
{
// try to set the read/write access
- if (_wchmod (wideFile, _S_IREAD | _S_IWRITE) == -1)
+ if (_wchmod (wideFile.c_str(), _S_IREAD | _S_IWRITE) == -1)
{
if (INelContext::getInstance().getAlreadyCreateSharedAmongThreads())
{
@@ -2822,6 +2819,7 @@ bool CFile::setRWAccess(const std::string &filename)
return false;
}
}
+#endif
else
{
if (INelContext::getInstance().getAlreadyCreateSharedAmongThreads())
@@ -2830,7 +2828,6 @@ bool CFile::setRWAccess(const std::string &filename)
}
// return false;
}
-#endif
return true;
}
From 1a045e437e9b1a11f28711e3749696c99f0235e1 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Wed, 28 Oct 2020 02:47:44 +0800
Subject: [PATCH 048/205] Accept any UTF string in NL3D text rendering, support
UTF-32 characters, ryzom/ryzomcore#335
---
nel/include/nel/3d/computed_string.h | 2 +-
nel/include/nel/3d/font_generator.h | 8 ++---
nel/include/nel/3d/font_manager.h | 7 +++--
nel/include/nel/3d/text_context.h | 14 ++++-----
nel/include/nel/3d/text_context_user.h | 8 ++---
nel/include/nel/3d/texture_font.h | 4 +--
nel/include/nel/3d/u_text_context.h | 10 +++---
nel/include/nel/misc/utf_string_view.h | 7 +++++
nel/src/3d/font_generator.cpp | 24 +++++++--------
nel/src/3d/font_manager.cpp | 42 ++++++++------------------
nel/src/3d/text_context.cpp | 8 ++---
nel/src/3d/text_context_user.cpp | 18 +++++------
12 files changed, 72 insertions(+), 80 deletions(-)
diff --git a/nel/include/nel/3d/computed_string.h b/nel/include/nel/3d/computed_string.h
index 3f27a2879..c4404f661 100644
--- a/nel/include/nel/3d/computed_string.h
+++ b/nel/include/nel/3d/computed_string.h
@@ -181,7 +181,7 @@ public:
CVertexBuffer Vertices;
CMaterial *Material;
CRGBA Color;
- ucstring Text;
+ std::string Text;
uint32 CacheVersion;
diff --git a/nel/include/nel/3d/font_generator.h b/nel/include/nel/3d/font_generator.h
index b69249d58..ea737afab 100644
--- a/nel/include/nel/3d/font_generator.h
+++ b/nel/include/nel/3d/font_generator.h
@@ -64,17 +64,17 @@ public:
* \param height height of the generated bitmap, this value is set by this function
* \param pitch pitch of the generated bitmap (+ or - the number of bytes per row), this value is set by this function
*/
- uint8 *getBitmap (ucchar c, uint32 size, bool embolden, bool oblique, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex);
+ uint8 *getBitmap (u32char c, uint32 size, bool embolden, bool oblique, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex);
/** returns the width and height of a character using a specific size and
*
* \warning this function is not very fast (but faster than getBitmap()) because it has to load the char before.
*/
- void getSizes (ucchar c, uint32 size, uint32 &width, uint32 &height);
+ void getSizes (u32char c, uint32 size, uint32 &width, uint32 &height);
- void getKerning (ucchar left, ucchar right, sint32 &kernx);
+ void getKerning (u32char left, u32char right, sint32 &kernx);
- uint32 getCharIndex (ucchar c);
+ uint32 getCharIndex (u32char c);
uint32 getUID() { return _UID; }
diff --git a/nel/include/nel/3d/font_manager.h b/nel/include/nel/3d/font_manager.h
index 663e9d23a..53310e95a 100644
--- a/nel/include/nel/3d/font_manager.h
+++ b/nel/include/nel/3d/font_manager.h
@@ -19,6 +19,7 @@
#include "nel/misc/types_nl.h"
#include "nel/misc/smart_ptr.h"
+#include "nel/misc/utf_string_view.h"
#include "nel/3d/texture.h"
#include "nel/3d/material.h"
#include "nel/3d/texture_font.h"
@@ -111,6 +112,7 @@ public:
* \param output computed string
* \param keep800x600Ratio true if you want that CFontManager look at Driver window size, and resize fontSize so it keeps same size...
*/
+ /*
void computeString (const std::string& s,
CFontGenerator *fontGen,
const NLMISC::CRGBA &color,
@@ -120,11 +122,12 @@ public:
IDriver *driver,
CComputedString& output,
bool keep800x600Ratio= true);
+ */
/**
* Same as computeString but works with a unicode string (ucstring)
*/
- void computeString (const ucstring &s,
+ void computeString (NLMISC::CUtfStringView sv,
CFontGenerator *fontGen,
const NLMISC::CRGBA &color,
uint32 fontSize,
@@ -137,7 +140,7 @@ public:
/**
* Same as computeString but do not make vertex buffers and primitives
*/
- void computeStringInfo (const ucstring &s,
+ void computeStringInfo (NLMISC::CUtfStringView sv,
CFontGenerator *fontGen,
const NLMISC::CRGBA &color,
uint32 fontSize,
diff --git a/nel/include/nel/3d/text_context.h b/nel/include/nel/3d/text_context.h
index 1eb256855..b18747e9a 100644
--- a/nel/include/nel/3d/text_context.h
+++ b/nel/include/nel/3d/text_context.h
@@ -134,7 +134,7 @@ public:
uint32 textPush (const char *format, ...);
/// computes an ucstring and adds the result to the cache (return the index)
- uint32 textPush (const ucstring &str);
+ uint32 textPush (NLMISC::CUtfStringView sv);
/// remove a string from the cache
void erase (uint32 index);
@@ -262,12 +262,12 @@ public:
}
/// Directly print a string
- void printAt (float x, float z, const ucstring &ucstr)
+ void printAt (float x, float z, NLMISC::CUtfStringView sv)
{
nlassert(_FontGen);
// compute the string just one time
- _FontManager->computeString (ucstr, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, _TempString, _Keep800x600Ratio);
+ _FontManager->computeString (sv, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, _TempString, _Keep800x600Ratio);
// draw shaded
if (_Shaded)
@@ -372,14 +372,14 @@ public:
* \param an ucstring
* \param the computed string
*/
- void computeString (const ucstring& s, CComputedString& output)
+ void computeString (NLMISC::CUtfStringView sv, CComputedString& output)
{
- _FontManager->computeString (s, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio);
+ _FontManager->computeString (sv, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio);
}
- void computeStringInfo (const ucstring& s, CComputedString& output)
+ void computeStringInfo (NLMISC::CUtfStringView sv, CComputedString& output)
{
- _FontManager->computeStringInfo (s, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio);
+ _FontManager->computeStringInfo (sv, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio);
}
/// Debug : write to the disk the texture cache
diff --git a/nel/include/nel/3d/text_context_user.h b/nel/include/nel/3d/text_context_user.h
index 2a167b2e9..951f5b154 100644
--- a/nel/include/nel/3d/text_context_user.h
+++ b/nel/include/nel/3d/text_context_user.h
@@ -97,13 +97,13 @@ public:
*/
// @{
uint32 textPush(const char *format, ...) ;
- uint32 textPush(const ucstring &str) ;
+ uint32 textPush(NLMISC::CUtfStringView sv) ;
void setStringColor(uint32 i, CRGBA newCol);
void setStringSelection(uint32 i, uint32 selectStart, uint32 selectSize);
void resetStringSelection(uint32 i);
void erase(uint32 i) ;
virtual CStringInfo getStringInfo (uint32 i);
- virtual CStringInfo getStringInfo (const ucstring &ucstr);
+ virtual CStringInfo getStringInfo (NLMISC::CUtfStringView sv);
void clear() ;
void printAt(float x, float y, uint32 i) ;
@@ -111,10 +111,10 @@ public:
void printClipAtUnProjected(URenderStringBuffer &renderBuffer, class NL3D::CFrustum &frustum, const NLMISC::CMatrix &scaleMatrix, float x, float y, float depth, uint32 i, float xmin, float ymin, float xmax, float ymax);
void printClipAtOld (float x, float y, uint32 i, float xmin, float ymin, float xmax, float ymax);
- void printAt(float x, float y, const ucstring &ucstr) ;
+ void printAt(float x, float y, NLMISC::CUtfStringView sv) ;
void printfAt(float x, float y, const char * format, ...) ;
- void render3D(const CMatrix &mat, const ucstring &ucstr) ;
+ void render3D(const CMatrix &mat, NLMISC::CUtfStringView sv) ;
void render3D(const CMatrix &mat, const char *format, ...) ;
float getLastXBound() const ;
diff --git a/nel/include/nel/3d/texture_font.h b/nel/include/nel/3d/texture_font.h
index 865615b63..5b0796721 100644
--- a/nel/include/nel/3d/texture_font.h
+++ b/nel/include/nel/3d/texture_font.h
@@ -69,7 +69,7 @@ public:
// Holds info for glyphs displayed on screen
struct SLetterInfo
{
- ucchar Char;
+ u32char Char;
sint Size;
bool Embolden;
bool Oblique;
@@ -94,7 +94,7 @@ public:
struct SLetterKey
{
- ucchar Char;
+ u32char Char;
sint Size;
bool Embolden;
bool Oblique;
diff --git a/nel/include/nel/3d/u_text_context.h b/nel/include/nel/3d/u_text_context.h
index cdde02f82..829e80844 100644
--- a/nel/include/nel/3d/u_text_context.h
+++ b/nel/include/nel/3d/u_text_context.h
@@ -24,7 +24,7 @@
#include "nel/misc/rgba.h"
#include "nel/misc/ucstring.h"
#include "nel/misc/matrix.h"
-
+#include "nel/misc/utf_string_view.h"
namespace NL3D {
@@ -248,7 +248,7 @@ public:
* \param an ucstring
* \return the index where computed string has been inserted
*/
- virtual uint32 textPush (const ucstring &str) = 0;
+ virtual uint32 textPush (NLMISC::CUtfStringView sv) = 0;
/**
* set the color of a string.
*/
@@ -274,7 +274,7 @@ public:
* Get a string information from the ucstring
* The returned string info is in pixel size per default.
*/
- virtual CStringInfo getStringInfo (const ucstring &ucstr) = 0;
+ virtual CStringInfo getStringInfo (NLMISC::CUtfStringView sv) = 0;
/**
* empty the map
*/
@@ -299,7 +299,7 @@ public:
/**
* compute and print a ucstring at the location (2D method) x/y E [0,1]
*/
- virtual void printAt (float x, float y, const ucstring &ucstr) = 0;
+ virtual void printAt (float x, float y, NLMISC::CUtfStringView sv) = 0;
/**
* compute and print a string at the location (2D method) x/y E [0,1]
*/
@@ -309,7 +309,7 @@ public:
* compute and render a ucstring at the location (3D method)
* render3D() use UDriver Matrix context for Frustum/ViewMatrix, but use its own modelmatrix (mat).
*/
- virtual void render3D (const NLMISC::CMatrix &mat, const ucstring &ucstr) = 0;
+ virtual void render3D (const NLMISC::CMatrix &mat, NLMISC::CUtfStringView sv) = 0;
/**
* compute and render a string at the location (3D method)
* render3D() use UDriver Matrix context for Frustum/ViewMatrix, but use its own modelmatrix (mat).
diff --git a/nel/include/nel/misc/utf_string_view.h b/nel/include/nel/misc/utf_string_view.h
index e972ca7cf..cc726bb33 100644
--- a/nel/include/nel/misc/utf_string_view.h
+++ b/nel/include/nel/misc/utf_string_view.h
@@ -91,6 +91,13 @@ public:
iterator begin() const { return iterator(*this, m_Str); }
inline iterator end() const { return iterator(*this, NULL); }
+ /// Largest possible number of characters in this string.
+ /// Number of actual characters may be less or equal.
+ inline size_t largestSize() const { return m_Size; }
+
+ inline bool empty() const { return !m_Size; }
+ const void *ptr() const { return m_Str; }
+
private:
typedef u32char (*TIterator)(const void **addr);
static u32char utf8Iterator(const void **addr);
diff --git a/nel/src/3d/font_generator.cpp b/nel/src/3d/font_generator.cpp
index 0bad785a6..86a233f22 100644
--- a/nel/src/3d/font_generator.cpp
+++ b/nel/src/3d/font_generator.cpp
@@ -256,7 +256,7 @@ CFontGenerator::~CFontGenerator ()
}
}
-void CFontGenerator::getSizes (ucchar c, uint32 size, uint32 &width, uint32 &height)
+void CFontGenerator::getSizes (u32char c, uint32 size, uint32 &width, uint32 &height)
{
FT_Error error;
@@ -272,7 +272,7 @@ void CFontGenerator::getSizes (ucchar c, uint32 size, uint32 &width, uint32 &hei
if (glyph_index == 0)
{
// no glyph available, replace with a dot
- glyph_index = FT_Get_Char_Index (_Face, ucchar('.'));
+ glyph_index = FT_Get_Char_Index (_Face, u32char('.'));
}
// load glyph image into the slot (erase previous one)
@@ -294,7 +294,7 @@ void CFontGenerator::getSizes (ucchar c, uint32 size, uint32 &width, uint32 &hei
height = _Face->glyph->metrics.height >> 6;
}
-uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, bool embolden, bool oblique, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex)
+uint8 *CFontGenerator::getBitmap (u32char c, uint32 size, bool embolden, bool oblique, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex)
{
FT_Error error;
@@ -311,7 +311,7 @@ uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, bool embolden, bool obl
if (glyph_index == 0)
{
// no glyph available, replace with a dot
- glyph_index = FT_Get_Char_Index (_Face, ucchar('.'));
+ glyph_index = FT_Get_Char_Index (_Face, u32char('.'));
}
*/
@@ -374,7 +374,7 @@ uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, bool embolden, bool obl
-void CFontGenerator::getKerning (ucchar left, ucchar right, sint32 &kernx)
+void CFontGenerator::getKerning (u32char left, u32char right, sint32 &kernx)
{
if (!FT_HAS_KERNING(_Face))
{
@@ -394,14 +394,14 @@ void CFontGenerator::getKerning (ucchar left, ucchar right, sint32 &kernx)
-uint32 CFontGenerator::getCharIndex (ucchar c)
+uint32 CFontGenerator::getCharIndex (u32char c)
{
uint32 ret = FT_Get_Char_Index(_Face, c);
if (ret == 0)
{
// no glyph available, replace with a dot
- ret = FT_Get_Char_Index (_Face, ucchar('.'));
+ ret = FT_Get_Char_Index (_Face, u32char('.'));
}
return ret;
@@ -475,14 +475,14 @@ CFontGenerator::~CFontGenerator ()
DeleteDC (hdcDib);
}
-void CFontGenerator::getSizes (ucchar c, uint32 size, uint32 &width, uint32 &height)
+void CFontGenerator::getSizes (u32char c, uint32 size, uint32 &width, uint32 &height)
{
}
HFONT hFont = NULL;
uint32 CurrentFontSize = 0;
-uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, bool embolden, bool oblique, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex)
+uint8 *CFontGenerator::getBitmap (u32char c, uint32 size, bool embolden, bool oblique, uint32 &width, uint32 &height, uint32 &pitch, sint32 &left, sint32 &top, sint32 &advx, uint32 &glyphIndex)
{
if (size == 0)
{
@@ -529,7 +529,7 @@ uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, bool embolden, bool obl
SelectObject (hdcDib, hFont);
SelectObject (hdcDib, Dib);
- const ucchar cc = /*(char)*/ c;
+ const u32char cc = /*(char)*/ c;
// prevent outputing white glyph if char is not available in font
DWORD glyphIndex;
@@ -639,13 +639,13 @@ uint8 *CFontGenerator::getBitmap (ucchar c, uint32 size, bool embolden, bool obl
-void CFontGenerator::getKerning (ucchar left, ucchar right, sint32 &kernx)
+void CFontGenerator::getKerning (u32char left, u32char right, sint32 &kernx)
{
}
-uint32 CFontGenerator::getCharIndex (ucchar c)
+uint32 CFontGenerator::getCharIndex (u32char c)
{
return 0;
}
diff --git a/nel/src/3d/font_manager.cpp b/nel/src/3d/font_manager.cpp
index d00ebb8f5..d467c69d1 100644
--- a/nel/src/3d/font_manager.cpp
+++ b/nel/src/3d/font_manager.cpp
@@ -63,27 +63,8 @@ CMaterial* CFontManager::getFontMaterial()
return _MatFont;
}
-
-// ***************************************************************************
-void CFontManager::computeString (const std::string &s,
- CFontGenerator *fontGen,
- const NLMISC::CRGBA &color,
- uint32 fontSize,
- bool embolden,
- bool oblique,
- IDriver *driver,
- CComputedString &output,
- bool keep800x600Ratio)
-{
- // static to avoid reallocation
- static ucstring ucs;
- ucs= s;
- computeString(ucs, fontGen, color, fontSize, embolden, oblique, driver, output, keep800x600Ratio);
-}
-
-
// ***************************************************************************
-void CFontManager::computeString (const ucstring &s,
+void CFontManager::computeString (NLMISC::CUtfStringView sv,
CFontGenerator *fontGen,
const NLMISC::CRGBA &color,
uint32 fontSize,
@@ -109,7 +90,7 @@ void CFontManager::computeString (const ucstring &s,
}
// Setting vertices format
- output.Vertices.setNumVertices (4 * (uint32)s.size());
+ output.Vertices.setNumVertices (4 * (uint32)sv.largestSize());
// 1 character <-> 1 quad
sint32 penx = 0, dx;
@@ -144,7 +125,8 @@ void CFontManager::computeString (const ucstring &s,
output.StringHeight = 0;
// save string info for later rebuild as needed
- output.Text = s;
+ if (sv.ptr() != output.Text.c_str()) // don't resave if rebuilding
+ output.Text = sv.toUtf8();
output.CacheVersion = getCacheVersion();
uint j = 0;
@@ -156,10 +138,11 @@ void CFontManager::computeString (const ucstring &s,
hlfPixScrH = 0.f;
// For all chars
- for (uint i = 0; i < s.size(); i++)
+ //for (uint i = 0; i < s.size(); i++)
+ for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it)
{
// Creating font
- k.Char = s[i];
+ k.Char = *it;
k.FontGenerator = fontGen;
k.Size = fontSize;
k.Embolden = embolden;
@@ -245,7 +228,7 @@ void CFontManager::computeString (const ucstring &s,
// ***************************************************************************
-void CFontManager::computeStringInfo ( const ucstring &s,
+void CFontManager::computeStringInfo ( NLMISC::CUtfStringView sv,
CFontGenerator *fontGen,
const NLMISC::CRGBA &color,
uint32 fontSize,
@@ -258,10 +241,11 @@ void CFontManager::computeStringInfo ( const ucstring &s,
output.Color = color;
// save string info for later rebuild as needed
- output.Text = s;
+ if (sv.ptr() != output.Text.c_str()) // don't resave if rebuilding
+ output.Text = sv.toUtf8();
output.CacheVersion = 0;
- if (s.empty())
+ if (sv.empty())
{
output.StringWidth = 0.f;
output.StringHeight = 0;
@@ -290,10 +274,10 @@ void CFontManager::computeStringInfo ( const ucstring &s,
CTextureFont::SLetterKey k;
CTextureFont::SLetterInfo *pLI;
- for (uint i = 0; i < s.size(); i++)
+ for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it)
{
// Creating font
- k.Char = s[i];
+ k.Char = *it;
k.FontGenerator = fontGen;
k.Size = fontSize;
k.Embolden = embolden;
diff --git a/nel/src/3d/text_context.cpp b/nel/src/3d/text_context.cpp
index 1ccb920e4..ba40904b3 100644
--- a/nel/src/3d/text_context.cpp
+++ b/nel/src/3d/text_context.cpp
@@ -77,13 +77,11 @@ uint32 CTextContext::textPush (const char *format, ...)
char *str;
NLMISC_CONVERT_VARGS (str, format, NLMISC::MaxCStringSize);
- ucstring uc;
- uc.fromUtf8((const char *)str);
- return textPush(uc);
+ return textPush(str);
}
// ------------------------------------------------------------------------------------------------
-uint32 CTextContext::textPush (const ucstring &str)
+uint32 CTextContext::textPush (NLMISC::CUtfStringView sv)
{
nlassert(_FontGen);
@@ -103,7 +101,7 @@ uint32 CTextContext::textPush (const ucstring &str)
nlassert (index < _CacheStrings.size());
CComputedString &strToFill = _CacheStrings[index];
- _FontManager->computeString (str, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, strToFill, _Keep800x600Ratio);
+ _FontManager->computeString (sv, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, strToFill, _Keep800x600Ratio);
// just compute letters, glyphs are rendered on demand before first draw
//_FontManager->computeStringInfo(str, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, strToFill, _Keep800x600Ratio);
diff --git a/nel/src/3d/text_context_user.cpp b/nel/src/3d/text_context_user.cpp
index 0430eae1a..6956c0df5 100644
--- a/nel/src/3d/text_context_user.cpp
+++ b/nel/src/3d/text_context_user.cpp
@@ -231,11 +231,11 @@ uint32 CTextContextUser::textPush(const char *format, ...)
return _TextContext.textPush(ucstring(str)) ;
}
-uint32 CTextContextUser::textPush(const ucstring &str)
+uint32 CTextContextUser::textPush(NLMISC::CUtfStringView sv)
{
H_AUTO2;
- return _TextContext.textPush(str) ;
+ return _TextContext.textPush(sv) ;
}
void CTextContextUser::setStringColor(uint32 i, CRGBA newCol)
{
@@ -279,11 +279,11 @@ UTextContext::CStringInfo CTextContextUser::getStringInfo(uint32 i)
else
return CStringInfo(cstr->StringWidth, cstr->StringHeight, cstr->StringLine);
}
-UTextContext::CStringInfo CTextContextUser::getStringInfo(const ucstring &str)
+UTextContext::CStringInfo CTextContextUser::getStringInfo(NLMISC::CUtfStringView sv)
{
H_AUTO2;
- _TextContext.computeStringInfo(str, _CacheString);
+ _TextContext.computeStringInfo(sv, _CacheString);
return CStringInfo (_CacheString.StringWidth, _CacheString.StringHeight, _CacheString.StringLine);
}
void CTextContextUser::clear()
@@ -319,11 +319,11 @@ void CTextContextUser::printClipAtOld (float x, float y, uint32 i, float xmin, f
printClipAt(rdrBuffer, x, y ,i, xmin, ymin, xmax, ymax);
flushRenderBuffer(&rdrBuffer);
}
-void CTextContextUser::printAt(float x, float y, const ucstring &ucstr)
+void CTextContextUser::printAt(float x, float y, NLMISC::CUtfStringView sv)
{
H_AUTO2;
- _TextContext.printAt(x, y, ucstr);
+ _TextContext.printAt(x, y, sv);
_DriverUser->restoreMatrixContext();
}
void CTextContextUser::printfAt(float x, float y, const char * format, ...)
@@ -337,12 +337,12 @@ void CTextContextUser::printfAt(float x, float y, const char * format, ...)
_DriverUser->restoreMatrixContext();
}
-void CTextContextUser::render3D(const CMatrix &mat, const ucstring &ucstr)
+void CTextContextUser::render3D(const CMatrix &mat, NLMISC::CUtfStringView sv)
{
NL3D_HAUTO_RENDER_3D_TEXTCONTEXT;
CComputedString computedStr;
- _TextContext.computeString(ucstr,computedStr);
+ _TextContext.computeString(sv,computedStr);
computedStr.render3D(*_Driver,mat);
@@ -355,7 +355,7 @@ void CTextContextUser::render3D(const CMatrix &mat, const char *format, ...)
char *str;
NLMISC_CONVERT_VARGS (str, format, NLMISC::MaxCStringSize);
- render3D(mat, ucstring(str));
+ render3D(mat, str);
_DriverUser->restoreMatrixContext();
}
From 932a612f53a1c012379f3dbe3f16a2ffe2300d26 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Wed, 28 Oct 2020 04:32:01 +0800
Subject: [PATCH 049/205] Support UTF-32 in edit box, ryzom/ryzomcore#335
---
nel/include/nel/3d/font_manager.h | 14 +++
nel/include/nel/3d/text_context.h | 5 +
nel/include/nel/3d/text_context_user.h | 1 +
nel/include/nel/3d/u_text_context.h | 5 +
nel/include/nel/gui/group_editbox.h | 22 ++--
nel/include/nel/misc/utf_string_view.h | 35 +++++-
nel/src/3d/font_manager.cpp | 19 ++-
nel/src/3d/text_context_user.cpp | 7 ++
nel/src/gui/group_editbox.cpp | 112 +++++++++++-------
nel/src/gui/group_html.cpp | 3 +-
nel/src/gui/view_text.cpp | 15 ++-
ryzom/client/src/connection.cpp | 8 +-
.../src/interface_v3/action_handler_edit.cpp | 17 +--
.../src/interface_v3/action_handler_item.cpp | 20 ++--
.../src/interface_v3/action_phrase_faber.cpp | 2 +-
.../bot_chat_page_create_guild.cpp | 4 +-
.../src/interface_v3/bot_chat_page_trade.cpp | 14 +--
ryzom/client/src/interface_v3/chat_window.cpp | 8 +-
.../src/interface_v3/dbgroup_build_phrase.cpp | 6 +-
ryzom/client/src/interface_v3/group_map.cpp | 12 +-
.../src/interface_v3/inventory_manager.cpp | 6 +-
.../client/src/interface_v3/macrocmd_key.cpp | 2 +-
.../src/interface_v3/macrocmd_manager.cpp | 2 +-
.../src/interface_v3/people_interraction.cpp | 14 +--
ryzom/client/src/interface_v3/people_list.cpp | 8 +-
ryzom/client/src/login.cpp | 18 +--
ryzom/client/src/r2/editor.cpp | 4 +-
27 files changed, 250 insertions(+), 133 deletions(-)
diff --git a/nel/include/nel/3d/font_manager.h b/nel/include/nel/3d/font_manager.h
index 53310e95a..134df26f9 100644
--- a/nel/include/nel/3d/font_manager.h
+++ b/nel/include/nel/3d/font_manager.h
@@ -137,6 +137,20 @@ public:
CComputedString &output,
bool keep800x600Ratio= true);
+ /**
+ * Same as computeString but do not make vertex buffers and primitives
+ */
+ void computeStringInfo (NLMISC::CUtfStringView sv,
+ size_t len,
+ CFontGenerator *fontGen,
+ const NLMISC::CRGBA &color,
+ uint32 fontSize,
+ bool embolden,
+ bool oblique,
+ IDriver *driver,
+ CComputedString &output,
+ bool keep800x600Ratio= true);
+
/**
* Same as computeString but do not make vertex buffers and primitives
*/
diff --git a/nel/include/nel/3d/text_context.h b/nel/include/nel/3d/text_context.h
index b18747e9a..01a711e7e 100644
--- a/nel/include/nel/3d/text_context.h
+++ b/nel/include/nel/3d/text_context.h
@@ -382,6 +382,11 @@ public:
_FontManager->computeStringInfo (sv, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio);
}
+ void computeStringInfo (NLMISC::CUtfStringView sv, CComputedString& output, size_t len)
+ {
+ _FontManager->computeStringInfo (sv, len, _FontGen, _Color, _FontSize, _Embolden, _Oblique, _Driver, output, _Keep800x600Ratio);
+ }
+
/// Debug : write to the disk the texture cache
void dumpCache (const char *filename)
{
diff --git a/nel/include/nel/3d/text_context_user.h b/nel/include/nel/3d/text_context_user.h
index 951f5b154..039aebcd0 100644
--- a/nel/include/nel/3d/text_context_user.h
+++ b/nel/include/nel/3d/text_context_user.h
@@ -104,6 +104,7 @@ public:
void erase(uint32 i) ;
virtual CStringInfo getStringInfo (uint32 i);
virtual CStringInfo getStringInfo (NLMISC::CUtfStringView sv);
+ virtual CStringInfo getStringInfo (NLMISC::CUtfStringView sv, size_t len);
void clear() ;
void printAt(float x, float y, uint32 i) ;
diff --git a/nel/include/nel/3d/u_text_context.h b/nel/include/nel/3d/u_text_context.h
index 829e80844..9cf710b11 100644
--- a/nel/include/nel/3d/u_text_context.h
+++ b/nel/include/nel/3d/u_text_context.h
@@ -275,6 +275,11 @@ public:
* The returned string info is in pixel size per default.
*/
virtual CStringInfo getStringInfo (NLMISC::CUtfStringView sv) = 0;
+ /**
+ * Get a string information from the ucstring
+ * The returned string info is in pixel size per default.
+ */
+ virtual CStringInfo getStringInfo (NLMISC::CUtfStringView sv, size_t len) = 0;
/**
* empty the map
*/
diff --git a/nel/include/nel/gui/group_editbox.h b/nel/include/nel/gui/group_editbox.h
index dc343410b..62b78584c 100644
--- a/nel/include/nel/gui/group_editbox.h
+++ b/nel/include/nel/gui/group_editbox.h
@@ -63,16 +63,16 @@ namespace NLGUI
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
/// Accessors
- ucstring getInputString() const { return _InputString; }
- const ucstring &getInputStringRef() const { return _InputString; }
+ u32string getInputString() const { return _InputString; }
+ const u32string &getInputStringRef() const { return _InputString; }
const ucstring &getPrompt() const { return _Prompt; }
/** Set the prompt
* NB : line returns are encoded as '\n', not '\r\n'
*/
void setPrompt(const ucstring &s) { _Prompt = s; }
- void setInputString(const ucstring &str);
- void setInputStringRef(const ucstring &str) {_InputString = str; };
+ void setInputString(const u32string &str);
+ void setInputStringRef(const u32string &str) {_InputString = str; };
void setInputStringAsInt(sint32 val);
sint32 getInputStringAsInt() const;
void setInputStringAsInt64(sint64 val);
@@ -81,6 +81,8 @@ namespace NLGUI
float getInputStringAsFloat() const;
void setInputStringAsUtf8(const std::string &str);
std::string getInputStringAsUtf8() const;
+ void setInputStringAsUtf16(const ucstring &str);
+ ucstring getInputStringAsUtf16() const;
void setColor(NLMISC::CRGBA col);
@@ -119,7 +121,7 @@ namespace NLGUI
sint32 getMaxHistoric() const {return _MaxHistoric;}
sint32 getCurrentHistoricIndex () const {return _CurrentHistoricIndex;}
void setCurrentHistoricIndex (sint32 index) {_CurrentHistoricIndex=index;}
- const ucstring &getHistoric(uint32 index) const {return _Historic[index];}
+ const u32string &getHistoric(uint32 index) const {return _Historic[index];}
uint32 getNumHistoric() const {return (uint32)_Historic.size ();}
// Get on change action handler
@@ -188,7 +190,7 @@ namespace NLGUI
REFLECT_LUA_METHOD("setFocusOnText", luaSetFocusOnText);
REFLECT_LUA_METHOD("cancelFocusOnText", luaCancelFocusOnText);
REFLECT_STRING("input_string", getInputStringAsUtf8, setInputStringAsUtf8);
- REFLECT_UCSTRING("uc_input_string", getInputString, setInputString);
+ REFLECT_UCSTRING("uc_input_string", getInputStringAsUtf16, setInputStringAsUtf16);
REFLECT_EXPORT_END
/** Restore the original value of the edit box.
@@ -227,16 +229,16 @@ namespace NLGUI
// Text info
ucstring _Prompt;
- ucstring _InputString;
+ u32string _InputString;
CViewText *_ViewText;
// undo / redo
- ucstring _StartInputString; // value of the input string when focus was acuired first
- ucstring _ModifiedInputString;
+ u32string _StartInputString; // value of the input string when focus was acuired first
+ u32string _ModifiedInputString;
// Historic info
- typedef std::deque THistoric;
+ typedef std::deque THistoric;
THistoric _Historic;
uint32 _MaxHistoric;
sint32 _CurrentHistoricIndex;
diff --git a/nel/include/nel/misc/utf_string_view.h b/nel/include/nel/misc/utf_string_view.h
index cc726bb33..a23c2abca 100644
--- a/nel/include/nel/misc/utf_string_view.h
+++ b/nel/include/nel/misc/utf_string_view.h
@@ -30,6 +30,8 @@ namespace NLMISC {
class CUtfStringView
{
public:
+ inline CUtfStringView() : m_Str(NULL), m_Size(0), m_Iterator(utf32Iterator) {}
+
inline CUtfStringView(const char *utf8Str) : m_Str(utf8Str), m_Size(strlen(utf8Str)), m_Iterator(utf8Iterator) {}
inline CUtfStringView(const char *utf8Str, size_t len): m_Str(utf8Str), m_Size(len), m_Iterator(utf8Iterator)
{
@@ -68,16 +70,31 @@ public:
public:
inline void operator++()
{
- m_Char = m_View.m_Iterator(&m_Addr);
+ m_Char = m_View.m_Iterator(&m_Addr);
if ((ptrdiff_t)m_Addr > ((ptrdiff_t)m_View.m_Str + m_View.m_Size))
{
m_Addr = 0;
m_Char = 0;
}
}
+ inline void operator+=(ptrdiff_t a)
+ {
+ while (m_Addr)
+ {
+ ++(*this);
+ }
+ }
inline bool operator!=(const const_iterator &o) const { return m_Addr != o.m_Addr; }
inline bool operator==(const const_iterator &o) const { return m_Addr == o.m_Addr; }
inline const u32char &operator*() const { return m_Char; }
+ const_iterator() : m_View(*(CUtfStringView *)NULL), m_Addr(NULL), m_Char(0) { }
+
+ const_iterator &operator=(const const_iterator &other)
+ {
+ if(this == &other) return *this;
+ this->~const_iterator();
+ return *new(this) const_iterator(other);
+ }
private:
friend class CUtfStringView;
inline const_iterator(const CUtfStringView &view, const void *addr) : m_View(view), m_Addr(addr), m_Char(addr ? view.m_Iterator(&m_Addr) : 0) { }
@@ -98,12 +115,28 @@ public:
inline bool empty() const { return !m_Size; }
const void *ptr() const { return m_Str; }
+ inline CUtfStringView substr(const iterator &begin, const iterator &end) const
+ {
+ return CUtfStringView(begin.m_Addr, (ptrdiff_t)end.m_Addr - (ptrdiff_t)begin.m_Addr, m_Iterator);
+ }
+
+ inline bool endsWith(char c) { nlassert(c < 0x80); return *((char *)m_Str + m_Size - 1) == c; }
+
+ CUtfStringView &operator=(const CUtfStringView &other)
+ {
+ if(this == &other) return *this;
+ this->~CUtfStringView();
+ return *new(this) CUtfStringView(other);
+ }
+
private:
typedef u32char (*TIterator)(const void **addr);
static u32char utf8Iterator(const void **addr);
static u32char utf16Iterator(const void **addr);
static u32char utf32Iterator(const void **addr);
+ inline CUtfStringView(const void *str, size_t len, TIterator it) : m_Str(str), m_Size(len), m_Iterator(it) { }
+
const void *const m_Str; // String
const size_t m_Size; // Size in bytes
const TIterator m_Iterator;
diff --git a/nel/src/3d/font_manager.cpp b/nel/src/3d/font_manager.cpp
index d467c69d1..70fb59639 100644
--- a/nel/src/3d/font_manager.cpp
+++ b/nel/src/3d/font_manager.cpp
@@ -237,6 +237,22 @@ void CFontManager::computeStringInfo ( NLMISC::CUtfStringView sv,
IDriver *driver,
CComputedString &output,
bool keep800x600Ratio )
+{
+ computeStringInfo(sv, sv.largestSize(), fontGen, color, fontSize, embolden, oblique, driver, output, keep800x600Ratio);
+}
+
+
+// ***************************************************************************
+void CFontManager::computeStringInfo ( NLMISC::CUtfStringView sv,
+ size_t len,
+ CFontGenerator *fontGen,
+ const NLMISC::CRGBA &color,
+ uint32 fontSize,
+ bool embolden,
+ bool oblique,
+ IDriver *driver,
+ CComputedString &output,
+ bool keep800x600Ratio )
{
output.Color = color;
@@ -274,7 +290,8 @@ void CFontManager::computeStringInfo ( NLMISC::CUtfStringView sv,
CTextureFont::SLetterKey k;
CTextureFont::SLetterInfo *pLI;
- for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it)
+ size_t idx = 0;
+ for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end && idx < len; ++it, ++idx)
{
// Creating font
k.Char = *it;
diff --git a/nel/src/3d/text_context_user.cpp b/nel/src/3d/text_context_user.cpp
index 6956c0df5..95d9ebe1c 100644
--- a/nel/src/3d/text_context_user.cpp
+++ b/nel/src/3d/text_context_user.cpp
@@ -286,6 +286,13 @@ UTextContext::CStringInfo CTextContextUser::getStringInfo(NLMISC::CUtfStringVie
_TextContext.computeStringInfo(sv, _CacheString);
return CStringInfo (_CacheString.StringWidth, _CacheString.StringHeight, _CacheString.StringLine);
}
+UTextContext::CStringInfo CTextContextUser::getStringInfo(NLMISC::CUtfStringView sv, size_t len)
+{
+ H_AUTO2;
+
+ _TextContext.computeStringInfo(sv, _CacheString, len);
+ return CStringInfo (_CacheString.StringWidth, _CacheString.StringHeight, _CacheString.StringLine);
+}
void CTextContextUser::clear()
{
H_AUTO2;
diff --git a/nel/src/gui/group_editbox.cpp b/nel/src/gui/group_editbox.cpp
index 2879a62af..b9dc44895 100644
--- a/nel/src/gui/group_editbox.cpp
+++ b/nel/src/gui/group_editbox.cpp
@@ -21,6 +21,7 @@
#include "stdpch.h"
#include "nel/gui/group_editbox.h"
#include "nel/misc/command.h"
+#include "nel/misc/utf_string_view.h"
#include "nel/gui/view_text.h"
#include "nel/misc/xml_auto_ptr.h"
#include "nel/gui/interface_options.h"
@@ -826,11 +827,12 @@ namespace NLGUI
}
// ----------------------------------------------------------------------------
- void CGroupEditBox::writeString(const ucstring &str, bool replace, bool atEnd)
+ void CGroupEditBox::writeString(const ucstring &str16, bool replace, bool atEnd)
{
+ u32string str = CUtfStringView(str16).toUtf32();
sint length = (sint)str.length();
- ucstring toAppend;
+ u32string toAppend;
// filter character depending on the entry type
switch (_EntryType)
{
@@ -963,7 +965,7 @@ namespace NLGUI
{
length = _MaxNumChar - (sint)_InputString.length();
}
- ucstring toAdd = toAppend.substr(0, length);
+ u32string toAdd = toAppend.substr(0, length);
sint32 minPos;
sint32 maxPos;
if (_CurrSelection == this)
@@ -1013,7 +1015,7 @@ namespace NLGUI
_CursorAtPreviousLineEnd = false;
if (_ClearOnEscape)
{
- setInputString(ucstring(""));
+ setInputString(u32string());
triggerOnChangeAH();
}
CWidgetManager::getInstance()->setCaptureKeyboard(NULL);
@@ -1059,8 +1061,9 @@ namespace NLGUI
{
if (isKeyRETURN)
{
- ucstring copyStr= _InputString;
- if ((uint) std::count(copyStr.begin(), copyStr.end(), '\n') >= _MaxNumReturn)
+ //ucstring copyStr= _InputString;
+ //if ((uint) std::count(copyStr.begin(), copyStr.end(), '\n') >= _MaxNumReturn)
+ if ((uint)std::count(_InputString.begin(), _InputString.end(), '\n') >= _MaxNumReturn)
break;
}
@@ -1121,11 +1124,11 @@ namespace NLGUI
if(_EntryType==Integer && (_IntegerMinValue!=INT_MIN || _IntegerMaxValue!=INT_MAX))
{
// estimate new string
- ucstring copyStr= _InputString;
- ucstring::iterator it = copyStr.begin() + _CursorPos;
+ u32string copyStr= _InputString;
+ u32string::iterator it = copyStr.begin() + _CursorPos;
copyStr.insert(it, c);
sint32 value;
- fromString(copyStr.toString(), value);
+ fromString(CUtfStringView(copyStr).toUtf8(), value);
// if out of bounds, abort char
if(value<_IntegerMinValue || value>_IntegerMaxValue)
return;
@@ -1134,12 +1137,12 @@ namespace NLGUI
if(_EntryType==PositiveInteger && (_PositiveIntegerMinValue!=0 || _PositiveIntegerMaxValue!=UINT_MAX))
{
// estimate new string
- ucstring copyStr= _InputString;
- ucstring::iterator it = copyStr.begin() + _CursorPos;
+ u32string copyStr= _InputString;
+ u32string::iterator it = copyStr.begin() + _CursorPos;
copyStr.insert(it, c);
// \todo yoyo: this doesn't really work i think....
uint32 value;
- fromString(copyStr.toString(), value);
+ fromString(CUtfStringView(copyStr).toUtf8(), value);
// if out of bounds, abort char
if(value<_PositiveIntegerMinValue || value>_PositiveIntegerMaxValue)
return;
@@ -1148,7 +1151,7 @@ namespace NLGUI
if ((uint) _InputString.length() < _MaxNumChar)
{
makeTopWindow();
- ucstring::iterator it = _InputString.begin() + _CursorPos;
+ u32string::iterator it = _InputString.begin() + _CursorPos;
_InputString.insert(it, c);
++ _CursorPos;
triggerOnChangeAH();
@@ -1229,11 +1232,11 @@ namespace NLGUI
{
makeTopWindow();
// for french, deutsch and russian, be aware of unicode
- std::string command = _InputString.substr(1).toUtf8();
+ std::string command = CUtfStringView(_InputString.substr(1)).toUtf8();
ICommand::expand(command);
- // then back to ucstring
- _InputString.fromUtf8(command);
- _InputString = '/' + _InputString;
+ // then back to u32string
+ _InputString = CUtfStringView('/' + command).toUtf32();
+ _InputString = _InputString;
_CursorPos = (sint32)_InputString.length();
_CursorAtPreviousLineEnd = false;
triggerOnChangeAH();
@@ -1260,7 +1263,7 @@ namespace NLGUI
// else delete last character
else if(_InputString.size () > 0 && _CursorPos != 0)
{
- ucstring::iterator it = _InputString.begin() + (_CursorPos - 1);
+ u32string::iterator it = _InputString.begin() + (_CursorPos - 1);
_InputString.erase(it);
-- _CursorPos;
_CursorAtPreviousLineEnd = false;
@@ -1439,7 +1442,7 @@ namespace NLGUI
}
else
{
- usTmp = _Prompt + _InputString;
+ usTmp = _Prompt + CUtfStringView(_InputString).toUtf16();
}
_ViewText->setText (usTmp);
}
@@ -1622,7 +1625,7 @@ namespace NLGUI
// ----------------------------------------------------------------------------
- void CGroupEditBox::setInputString(const ucstring &str)
+ void CGroupEditBox::setInputString(const u32string &str)
{
_InputString = str;
if (_CursorPos > (sint32) str.length())
@@ -1641,7 +1644,7 @@ namespace NLGUI
void CGroupEditBox::setDefaultInputString(const ucstring &str)
{
_DefaultInputString= true;
- setInputString(str);
+ setInputString(CUtfStringView(str).toUtf32());
}
@@ -1649,35 +1652,35 @@ namespace NLGUI
sint32 CGroupEditBox::getInputStringAsInt() const
{
sint32 value;
- fromString(_InputString.toString(), value);
+ fromString(getInputStringAsUtf8(), value);
return value;
}
// ***************************************************************************
void CGroupEditBox::setInputStringAsInt(sint32 val)
{
- setInputString(NLMISC::toString(val));
+ setInputStringAsUtf8(NLMISC::toString(val));
}
// ***************************************************************************
sint64 CGroupEditBox::getInputStringAsInt64() const
{
sint64 value;
- fromString(_InputString.toString(), value);
+ fromString(getInputStringAsUtf8(), value);
return value;
}
// ***************************************************************************
void CGroupEditBox::setInputStringAsInt64(sint64 val)
{
- setInputString(NLMISC::toString(val));
+ setInputStringAsUtf8(NLMISC::toString(val));
}
// ***************************************************************************
float CGroupEditBox::getInputStringAsFloat() const
{
float value;
- fromString(_InputString.toString(), value);
+ fromString(getInputStringAsUtf8(), value);
return value;
}
@@ -1685,14 +1688,14 @@ namespace NLGUI
void CGroupEditBox::setInputStringAsFloat(float val)
{
string fmt= "%." + NLMISC::toString(_MaxFloatPrec) + "f";
- setInputString(NLMISC::toString(fmt.c_str(), val));
+ setInputStringAsUtf8(NLMISC::toString(fmt.c_str(), val));
}
// ***************************************************************************
void CGroupEditBox::cutSelection()
{
- sint32 minPos= min(_CursorPos, _SelectCursorPos);
- sint32 maxPos= max(_CursorPos, _SelectCursorPos);
+ ptrdiff_t minPos= min(_CursorPos, _SelectCursorPos);
+ ptrdiff_t maxPos= max(_CursorPos, _SelectCursorPos);
// cut the selection
if(!_InputString.empty())
{
@@ -1706,10 +1709,10 @@ namespace NLGUI
// ***************************************************************************
ucstring CGroupEditBox::getSelection()
{
- sint32 minPos= min(_CursorPos, _SelectCursorPos);
- sint32 maxPos= max(_CursorPos, _SelectCursorPos);
+ ptrdiff_t minPos= min(_CursorPos, _SelectCursorPos);
+ ptrdiff_t maxPos= max(_CursorPos, _SelectCursorPos);
// get the selection
- return _InputString.substr(minPos, maxPos-minPos);
+ return CUtfStringView(_InputString.substr(minPos, maxPos-minPos)).toUtf16();
}
@@ -1738,13 +1741,25 @@ namespace NLGUI
// ***************************************************************************
void CGroupEditBox::setInputStringAsUtf8(const std::string &str)
{
- setInputString(ucstring::makeFromUtf8(str));
+ setInputString(CUtfStringView(str).toUtf32());
}
// ***************************************************************************
std::string CGroupEditBox::getInputStringAsUtf8() const
{
- return _InputString.toUtf8();
+ return CUtfStringView(_InputString).toUtf8();
+ }
+
+ // ***************************************************************************
+ void CGroupEditBox::setInputStringAsUtf16(const ucstring &str)
+ {
+ setInputString(CUtfStringView(str).toUtf32());
+ }
+
+ // ***************************************************************************
+ ucstring CGroupEditBox::getInputStringAsUtf16() const
+ {
+ return CUtfStringView(_InputString).toUtf16();
}
// ***************************************************************************
@@ -1755,7 +1770,7 @@ namespace NLGUI
return;
// set the string and maybe execute
- setInputString((ucchar) '/' + command);
+ setInputString(CUtfStringView((ucchar) '/' + command).toUtf32());
if (execute)
{
// stop selection
@@ -1810,13 +1825,30 @@ namespace NLGUI
// ***************************************************************************
void CGroupEditBox::serialConfig(NLMISC::IStream &f)
{
- f.serialVersion(0);
+ uint version = f.serialVersion(1);
if(_DefaultInputString) // Don't want to save the default input
{
_DefaultInputString= false;
_InputString.clear();
}
- f.serial(_InputString);
+ if (version < 1)
+ {
+ ucstring str;
+ if (!f.isReading())
+ str = CUtfStringView(_InputString).toUtf16();
+ f.serial(str);
+ if (f.isReading())
+ _InputString = CUtfStringView(str).toUtf32();
+ }
+ else
+ {
+ std::string str;
+ if (!f.isReading())
+ str = CUtfStringView(_InputString).toUtf8();
+ f.serial(str);
+ if (f.isReading())
+ _InputString = CUtfStringView(str).toUtf32();
+ }
f.serial(_CursorPos);
f.serial(_PrevNumLine);
if (f.isReading())
@@ -1838,7 +1870,7 @@ namespace NLGUI
void CGroupEditBox::onQuit()
{
// clear the text and restore backup pos before final save
- setInputString(ucstring(""));
+ setInputString(u32string());
_CurrSelection = NULL;
}
@@ -1846,7 +1878,7 @@ namespace NLGUI
void CGroupEditBox::onLoadConfig()
{
// config is not saved when there's an empty string, so restore that default state.
- setInputString(ucstring(""));
+ setInputString(u32string());
_CurrSelection = NULL;
_PrevNumLine = 1;
}
@@ -1861,7 +1893,7 @@ namespace NLGUI
if (_DefaultInputString)
{
_DefaultInputString= false;
- setInputString(ucstring());
+ setInputString(u32string());
}
_CanRedo = false;
_CanUndo = false;
diff --git a/nel/src/gui/group_html.cpp b/nel/src/gui/group_html.cpp
index 0c294c766..7f80405ce 100644
--- a/nel/src/gui/group_html.cpp
+++ b/nel/src/gui/group_html.cpp
@@ -27,6 +27,7 @@
#include "nel/misc/types_nl.h"
#include "nel/misc/rgba.h"
#include "nel/misc/algo.h"
+#include "nel/misc/utf_string_view.h"
#include "nel/gui/libwww.h"
#include "nel/gui/group_html.h"
#include "nel/gui/group_list.h"
@@ -3023,7 +3024,7 @@ namespace NLGUI
CGroupEditBox *eb = dynamic_cast(textArea->getGroup("eb"));
if (eb)
{
- eb->setInputString(decodeHTMLEntities(content));
+ eb->setInputString(CUtfStringView(decodeHTMLEntities(content)).toUtf32());
if (style.hasStyle("background-color"))
{
CViewBitmap *bg = dynamic_cast(eb->getView("bg"));
diff --git a/nel/src/gui/view_text.cpp b/nel/src/gui/view_text.cpp
index 1b7d3f457..7376cd39a 100644
--- a/nel/src/gui/view_text.cpp
+++ b/nel/src/gui/view_text.cpp
@@ -2466,9 +2466,8 @@ namespace NLGUI
if ((uint) (index - charIndex) > currWord.NumSpaces)
{
// get the x position
- ucstring subStr = currWord.Text.substr(0, index - charIndex - currWord.NumSpaces);
// compute the size
- UTextContext::CStringInfo si = TextContext->getStringInfo(subStr);
+ UTextContext::CStringInfo si = TextContext->getStringInfo(currWord.Text, (ptrdiff_t)index - charIndex - currWord.NumSpaces);
fx = px + si.StringWidth + currWord.NumSpaces * currLine.getSpaceWidth();
x = fx / _Scale;
@@ -2496,9 +2495,8 @@ namespace NLGUI
else
{
// get the x position
- ucstring subStr = _Text.substr(0, index);
// compute the size
- UTextContext::CStringInfo si = TextContext->getStringInfo(subStr);
+ UTextContext::CStringInfo si = TextContext->getStringInfo(_Text, index);
y = 0;
x = (sint) ceilf(si.StringWidth / _Scale);
}
@@ -2511,12 +2509,13 @@ namespace NLGUI
float px = 0.f;
UTextContext::CStringInfo si;
- ucstring singleChar(" ");
- uint i;
- for (i = 0; i < textValue.length(); ++i)
+ u32string singleChar(1, ' ');
+ uint i = 0;
+ NLMISC::CUtfStringView sv(textValue);
+ for (NLMISC::CUtfStringView::iterator it(sv.begin()), end(sv.end()); it != end; ++it, ++i)
{
// get character width
- singleChar[0] = textValue[i];
+ singleChar[0] = *it;
si = textContext.getStringInfo(singleChar);
px += si.StringWidth;
// the character is at the i - 1 position
diff --git a/ryzom/client/src/connection.cpp b/ryzom/client/src/connection.cpp
index 38a10d7e4..5aad200ae 100644
--- a/ryzom/client/src/connection.cpp
+++ b/ryzom/client/src/connection.cpp
@@ -1686,7 +1686,7 @@ public:
ucstring sSurName = ucstring("NotSet");
CGroupEditBox *pGEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sEditBoxPath));
if (pGEB != NULL)
- sFirstName = pGEB->getInputString();
+ sFirstName = pGEB->getInputStringAsUtf16();
else
nlwarning ("can't get edit box name : %s",sEditBoxPath.c_str());
@@ -2562,7 +2562,7 @@ static void setTextField(CInterfaceGroup* scenarioWnd, const std::string &uiName
viewText->setText(text);
CGroupEditBox* editBox = dynamic_cast(result);
if(editBox)
- editBox->setInputString(text);
+ editBox->setInputStringAsUtf16(text);
}
}
@@ -2826,7 +2826,7 @@ class CAHScenarioControl : public IActionHandler
{
CGroupEditBox* editBox = dynamic_cast(result);
if(editBox)
- editBox->setInputString(description);
+ editBox->setInputStringAsUtf16(description);
}
}
}
@@ -2977,7 +2977,7 @@ class CAHLoadScenario : public IActionHandler
{
CGroupEditBox* editBox = dynamic_cast(result);
if(editBox)
- description = editBox->getInputString().toString();
+ description = editBox->getInputStringAsUtf8();
}
// races
diff --git a/ryzom/client/src/interface_v3/action_handler_edit.cpp b/ryzom/client/src/interface_v3/action_handler_edit.cpp
index 00a07dd39..81837bf4a 100644
--- a/ryzom/client/src/interface_v3/action_handler_edit.cpp
+++ b/ryzom/client/src/interface_v3/action_handler_edit.cpp
@@ -27,6 +27,7 @@ using namespace NLMISC;
#include "nel/gui/action_handler.h"
#include "nel/gui/group_editbox.h"
+#include "nel/misc/utf_string_view.h"
#include "interface_manager.h"
#include "../client_chat_manager.h"
#include "people_interraction.h"
@@ -56,7 +57,7 @@ extern CClientChatManager ChatMngr;
// ***************************************************************************
// used for character classifiction (when the user press Ctrl-arrow)
-static inline uint getCharacterCategory(ucchar c)
+static inline uint getCharacterCategory(u32char c)
{
if (c == ' ') return 0;
if (c > 127 || isalpha((char) c)) return 1; // alpha & other characters
@@ -69,7 +70,7 @@ static inline uint getCharacterCategory(ucchar c)
/** skip a block of character in a string, (same behaviour than when Ctrl-arrow is pressed)
* It returns the new index
*/
-static uint skipUCCharsRight(uint startPos, const ucstring &str)
+static uint skipUCCharsRight(uint startPos, const u32string &str)
{
uint pos = startPos;
uint endIndex = (uint)str.length();
@@ -86,7 +87,7 @@ static uint skipUCCharsRight(uint startPos, const ucstring &str)
/** skip a block of character in a string, (same behaviour than when Ctrl-arrow is pressed)
* It returns the new index
*/
-static uint skipUCCharsLeft(uint startPos, const ucstring &str)
+static uint skipUCCharsLeft(uint startPos, const u32string &str)
{
uint pos = startPos;
-- pos;
@@ -362,7 +363,7 @@ class CAHEditPreviousLine : public CAHEdit
if (_GroupEdit->getMaxHistoric() && (! _GroupEdit->getViewText()->getMultiLine()))
{
// Get the start of the string.
- ucstring startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos());
+ u32string startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos());
// Search all historic string that match startStr.
for(sint i=_GroupEdit->getCurrentHistoricIndex()+1;i<(sint)_GroupEdit->getNumHistoric();i++)
@@ -434,7 +435,7 @@ class CAHEditNextLine : public CAHEdit
if( (! _GroupEdit->getViewText()->getMultiLine()) && _GroupEdit->getMaxHistoric() && _GroupEdit->getCurrentHistoricIndex()>0)
{
// Get the start of the string.
- ucstring startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos());
+ u32string startStr= _GroupEdit->getInputStringRef().substr(0, _GroupEdit->getCursorPos());
// Search all historic string that match startStr.
for(sint i=_GroupEdit->getCurrentHistoricIndex()-1;i>=0;i--)
@@ -520,8 +521,8 @@ protected:
// else cut forwards
else if(_GroupEdit->getCursorPos() < (sint32) _GroupEdit->getInputStringRef().length())
{
- ucstring inputString = _GroupEdit->getInputStringRef();
- ucstring::iterator it = inputString.begin() + _GroupEdit->getCursorPos();
+ u32string inputString = _GroupEdit->getInputStringRef();
+ u32string::iterator it = inputString.begin() + _GroupEdit->getCursorPos();
inputString.erase(it);
_GroupEdit->setInputStringRef (inputString);
if (!_GroupEdit->getAHOnChange().empty())
@@ -638,7 +639,7 @@ class CAHEditExpandOrCycleTell : public CAHEdit
void actionPart ()
{
// If the line starts with '/tell ', do not try to expand
- static const ucstring TELL_STR("/tell ");
+ static const u32string TELL_STR(CUtfStringView("/tell ").toUtf32());
if (_GroupEdit->getInputString().substr(0, TELL_STR.length()) != TELL_STR)
{
if (_GroupEdit->expand()) return;
diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp
index 3d0981306..998bfcd77 100644
--- a/ryzom/client/src/interface_v3/action_handler_item.cpp
+++ b/ryzom/client/src/interface_v3/action_handler_item.cpp
@@ -129,7 +129,7 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived()
{
if ( pIS->Family == ITEMFAMILY::SCROLL)
{
- editBoxLarge->setInputString(itemInfo.CustomText);
+ editBoxLarge->setInputStringAsUtf16(itemInfo.CustomText);
editLarge->setActive(true);
editBoxLarge->setActive(true);
@@ -147,7 +147,7 @@ void CInterfaceItemEdition::CItemEditionWindow::infoReceived()
strFindReplace(customText, "%mfc", ucstring());
}
- editBoxShort->setInputString(customText);
+ editBoxShort->setInputStringAsUtf16(customText);
editShort->setActive(true);
editBoxShort->setActive(true);
@@ -239,8 +239,8 @@ void CInterfaceItemEdition::CItemEditionWindow::begin()
closeButton->setActive(false);
group->setActive(true);
- editBoxShort->setInputString(ucstring());
- editBoxLarge->setInputString(ucstring());
+ editBoxShort->setInputString(u32string());
+ editBoxLarge->setInputString(u32string());
display->setTextFormatTaged(ucstring());
@@ -250,7 +250,7 @@ void CInterfaceItemEdition::CItemEditionWindow::begin()
// If we already have item info
if ( pIS->Family == ITEMFAMILY::SCROLL)
{
- editBoxLarge->setInputString(itemInfo.CustomText);
+ editBoxLarge->setInputStringAsUtf16(itemInfo.CustomText);
editLarge->setActive(true);
editBoxLarge->setActive(true);
@@ -269,7 +269,7 @@ void CInterfaceItemEdition::CItemEditionWindow::begin()
strFindReplace(customText, "%mfc", ucstring());
}
- editBoxShort->setInputString(customText);
+ editBoxShort->setInputStringAsUtf16(customText);
editShort->setActive(true);
editBoxShort->setActive(true);
@@ -297,8 +297,8 @@ void CInterfaceItemEdition::CItemEditionWindow::begin()
closeButton->setActive(true);
group->setActive(false);
- editBoxShort->setInputString(ucstring());
- editBoxLarge->setInputString(ucstring());
+ editBoxShort->setInputString(u32string());
+ editBoxLarge->setInputString(u32string());
display->setTextFormatTaged(ucstring());
// Finish the display or add the waiter
@@ -406,11 +406,11 @@ void CInterfaceItemEdition::CItemEditionWindow::validate()
if (group && editShort && editBoxShort && editLarge && editBoxLarge && display && editButtons && closeButton && background)
{
bool textValid = editShort->getActive();
- ucstring text = editBoxShort->getInputString();
+ ucstring text = editBoxShort->getInputStringAsUtf16();
if (!textValid)
{
textValid = editLarge->getActive();
- text = editBoxLarge->getInputString();
+ text = editBoxLarge->getInputStringAsUtf16();
}
if (textValid)
diff --git a/ryzom/client/src/interface_v3/action_phrase_faber.cpp b/ryzom/client/src/interface_v3/action_phrase_faber.cpp
index 40efedac0..d039444f9 100644
--- a/ryzom/client/src/interface_v3/action_phrase_faber.cpp
+++ b/ryzom/client/src/interface_v3/action_phrase_faber.cpp
@@ -718,7 +718,7 @@ void CActionPhraseFaber::startMpSelection(uint itemReqLine, uint mpSlot)
if (eb)
{
CWidgetManager::getInstance()->setCaptureKeyboard(eb);
- eb->setInputString(toString(maxQuantity));
+ eb->setInputStringAsUtf8(toString(maxQuantity));
eb->setSelectionAll();
}
}
diff --git a/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp b/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp
index b7ec631b9..105d4a180 100644
--- a/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp
+++ b/ryzom/client/src/interface_v3/bot_chat_page_create_guild.cpp
@@ -70,10 +70,10 @@ class CHandlerGuildCreate : public IActionHandler
CGroupEditBox *pDesc = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(guildDescWin));
- ucstring guildName = pGEB->getInputString();
+ ucstring guildName = pGEB->getInputStringAsUtf16();
ucstring guildDesc;
- if (pDesc != NULL) guildDesc = pDesc->getInputString();
+ if (pDesc != NULL) guildDesc = pDesc->getInputStringAsUtf16();
uint64 icon = CGuildManager::iconMake((uint8)pCS->getGuildBack(), (uint8)pCS->getGuildSymbol(),
pCS->getInvertGuildSymbol(), pCS->getGuildColor1(), pCS->getGuildColor2());
diff --git a/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp b/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp
index 4a59163b3..64f19214f 100644
--- a/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp
+++ b/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp
@@ -333,7 +333,7 @@ uint32 CBotChatPageTrade::getCurrItemQuantity() const
CGroupEditBox *ed = dynamic_cast(ig->getGroup("header_opened:standard_price:quantity:edit:eb"));
if (!ed) return std::numeric_limits::max();
uint32 intQuantity;
- if (fromString(ed->getInputString().toString(), intQuantity))
+ if (fromString(ed->getInputStringAsUtf8(), intQuantity))
{
return intQuantity;
}
@@ -1465,7 +1465,7 @@ void CBotChatPageTrade::setupPriceGroupQuantity(CInterfaceGroup *priceGroup, sin
CGroupEditBox *eb = dynamic_cast(quantityGroup->getGroup("edit:eb"));
if (eb)
{
- eb->setInputString(toString(defaultQuantity));
+ eb->setInputStringAsUtf8(toString(defaultQuantity));
}
}
}
@@ -1569,7 +1569,7 @@ void CBotChatPageTrade::setupResellGroup(bool sellMode, uint defaultQuantity, CI
{
sint32 resaleMargin= NLGUI::CDBManager::getInstance()->getDbProp( "UI:SAVE:TRADE_ITEM:RESALE_MARGIN" )->getValue32();
clamp(resaleMargin, 0, (sint32)MaxResaleMargin);
- eb->setInputString( toString( resaleMargin ) );
+ eb->setInputStringAsUtf8( toString( resaleMargin ) );
eb->setPositiveIntegerMaxValue(MaxResaleMargin);
}
}
@@ -1725,8 +1725,8 @@ void CBotChatPageTrade::startChangeBuyFilterDialog(const std::string &dbext, con
sint rangeMax= 0;
if(dbRangeMin) rangeMin= dbRangeMin->getValue32();
if(dbRangeMax) rangeMax= dbRangeMax->getValue32();
- if(edMin) edMin->setInputString(toString(rangeMin));
- if(edMax) edMax->setInputString(toString(rangeMax));
+ if(edMin) edMin->setInputStringAsUtf8(toString(rangeMin));
+ if(edMax) edMax->setInputStringAsUtf8(toString(rangeMax));
if(edMin) edMin->setPositiveIntegerMaxValue(maxValue);
if(edMax) edMax->setPositiveIntegerMaxValue(maxValue);
@@ -1754,8 +1754,8 @@ void CBotChatPageTrade::resetBuyFilterDialog()
sint rangeMin= 0;
sint rangeMax= _FilterBuyDlgMaxValue;
// write result in EditBox, and in db
- if(edMin) edMin->setInputString(toString(rangeMin));
- if(edMax) edMax->setInputString(toString(rangeMax));
+ if(edMin) edMin->setInputStringAsUtf8(toString(rangeMin));
+ if(edMax) edMax->setInputStringAsUtf8(toString(rangeMax));
if(dbRangeMin) dbRangeMin->setValue32(rangeMin);
if(dbRangeMax) dbRangeMax->setValue32(rangeMax);
diff --git a/ryzom/client/src/interface_v3/chat_window.cpp b/ryzom/client/src/interface_v3/chat_window.cpp
index 1537e7b8b..bfac81212 100644
--- a/ryzom/client/src/interface_v3/chat_window.cpp
+++ b/ryzom/client/src/interface_v3/chat_window.cpp
@@ -363,7 +363,7 @@ void CChatWindow::setCommand(const ucstring &command,bool execute)
void CChatWindow::setEntry(const ucstring &entry)
{
if (!_EB) return;
- _EB->setInputString(entry);
+ _EB->setInputStringAsUtf16(entry);
}
//=================================================================================
@@ -1273,7 +1273,7 @@ public:
{
CGroupEditBox *pEB = dynamic_cast(pCaller);
if (pEB == NULL) return;
- ucstring text = pEB->getInputString();
+ ucstring text = pEB->getInputStringAsUtf16();
// If the line is empty, do nothing
if(text.empty())
return;
@@ -1289,7 +1289,7 @@ public:
// Parse any tokens in the text
if ( ! CInterfaceManager::parseTokens(text))
{
- pEB->setInputString (string(""));
+ pEB->setInputString (u32string());
return;
}
@@ -1329,7 +1329,7 @@ public:
}
}
// Clear input string
- pEB->setInputString (ucstring(""));
+ pEB->setInputString (u32string());
CGroupContainer *gc = static_cast< CGroupContainer* >( pEB->getEnclosingContainer() );
if (gc)
diff --git a/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp b/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp
index 3cd8e759c..8ffa62530 100644
--- a/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp
+++ b/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp
@@ -279,7 +279,7 @@ void CDBGroupBuildPhrase::clearBuildingPhrase()
// Empty the name
if(_UserSentenceName)
{
- _UserSentenceName->setInputString(ucstring());
+ _UserSentenceName->setInputString(u32string());
}
// update Display
@@ -373,7 +373,7 @@ void CDBGroupBuildPhrase::startComposition(const CSPhraseCom &phrase)
// set the editable name.
if(_UserSentenceName)
- _UserSentenceName->setInputString(name);
+ _UserSentenceName->setInputStringAsUtf16(name);
}
@@ -1790,7 +1790,7 @@ void CDBGroupBuildPhrase::buildCurrentPhrase(CSPhraseCom &newPhrase)
// Set the Name
if(_UserSentenceName)
{
- newPhrase.Name= _UserSentenceName->getInputString();
+ newPhrase.Name= _UserSentenceName->getInputStringAsUtf16();
}
}
diff --git a/ryzom/client/src/interface_v3/group_map.cpp b/ryzom/client/src/interface_v3/group_map.cpp
index 17e75486a..b696ae40d 100644
--- a/ryzom/client/src/interface_v3/group_map.cpp
+++ b/ryzom/client/src/interface_v3/group_map.cpp
@@ -141,12 +141,12 @@ static void popupLandMarkNameDialog()
const CUserLandMark userLM = map->getUserLandMark(LastSelectedLandMark);
NLGUI::CDBManager::getInstance()->getDbProp( "UI:TEMP:LANDMARKTYPE" )->setValue8(cb->getTextPos(userLM.Type));
- eb->setInputString(userLM.Title);
+ eb->setInputStringAsUtf16(userLM.Title);
}
else
{
NLGUI::CDBManager::getInstance()->getDbProp( "UI:TEMP:LANDMARKTYPE" )->setValue8(cb->getTextPos(CUserLandMark::Misc));
- eb->setInputString(ucstring());
+ eb->setInputStringAsUtf16(ucstring());
}
CWidgetManager::getInstance()->setCaptureKeyboard(eb);
@@ -3882,7 +3882,7 @@ class CAHLandMarkFilter : public IActionHandler
CGroupEditBox* eb = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(group));
if (!eb) return;
- text = eb->getInputString().toUtf8();
+ text = eb->getInputStringAsUtf8();
}
map->setLandmarkFilter(text);
@@ -3988,7 +3988,7 @@ class CAHValidateUserLandMarkName : public IActionHandler
CGroupMap *map = dynamic_cast(LastSelectedLandMark->getParent());
if (!map) return;
// update existing landmark
- map->updateUserLandMark(LastSelectedLandMark, eb->getInputString(), landMarkType);
+ map->updateUserLandMark(LastSelectedLandMark, eb->getInputStringAsUtf16(), landMarkType);
}
else
{
@@ -3996,11 +3996,11 @@ class CAHValidateUserLandMarkName : public IActionHandler
if (!LastClickedMap) return;
if( UseUserPositionForLandMark )
{
- LastClickedMap->addUserLandMark(LastClickedMap->getPlayerPos(), eb->getInputString(), landMarkType);
+ LastClickedMap->addUserLandMark(LastClickedMap->getPlayerPos(), eb->getInputStringAsUtf16(), landMarkType);
}
else
{
- LastClickedMap->addUserLandMark(LastClickedMap->getRightClickLastPos(), eb->getInputString(), landMarkType);
+ LastClickedMap->addUserLandMark(LastClickedMap->getRightClickLastPos(), eb->getInputStringAsUtf16(), landMarkType);
}
LastClickedMap->invalidateCoords();
}
diff --git a/ryzom/client/src/interface_v3/inventory_manager.cpp b/ryzom/client/src/interface_v3/inventory_manager.cpp
index f84e38234..5324c6e69 100644
--- a/ryzom/client/src/interface_v3/inventory_manager.cpp
+++ b/ryzom/client/src/interface_v3/inventory_manager.cpp
@@ -2755,7 +2755,7 @@ class CHandlerInvSearchButton : public IActionHandler
{
CWidgetManager::getInstance()->setCaptureKeyboard(eb);
eb->setSelectionAll();
- filter = eb->getInputString();
+ filter = eb->getInputStringAsUtf16();
}
CDBGroupListSheetBag *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(btn->getParent()->getId() + ":bag_list"));
@@ -2805,10 +2805,10 @@ class CHandlerInvSetSearch : public IActionHandler
std::string id = pCaller->getParent()->getParent()->getId();
CDBGroupListSheetBag *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(id + ":bag_list"));
- if (pList != NULL) pList->setSearchFilter(eb->getInputString());
+ if (pList != NULL) pList->setSearchFilter(eb->getInputStringAsUtf16());
CDBGroupIconListBag *pIcons = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(id + ":bag_icons"));
- if (pIcons != NULL) pIcons->setSearchFilter(eb->getInputString());
+ if (pIcons != NULL) pIcons->setSearchFilter(eb->getInputStringAsUtf16());
}
};
REGISTER_ACTION_HANDLER( CHandlerInvSetSearch, "inv_set_search" );
diff --git a/ryzom/client/src/interface_v3/macrocmd_key.cpp b/ryzom/client/src/interface_v3/macrocmd_key.cpp
index 7f4c26c08..241862ff1 100644
--- a/ryzom/client/src/interface_v3/macrocmd_key.cpp
+++ b/ryzom/client/src/interface_v3/macrocmd_key.cpp
@@ -1148,7 +1148,7 @@ void CModalContainerEditCmd::onChangeAction()
CGroupEditBox *pEB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( sWin ));
if( pEB )
{
- pEB->setInputString(ucstring(""));
+ pEB->setInputString(u32string());
}
NLGUI::CDBManager::getInstance()->getDbProp( sDB )->setValue32(1);
}
diff --git a/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/ryzom/client/src/interface_v3/macrocmd_manager.cpp
index 6aa831eac..39b2aedde 100644
--- a/ryzom/client/src/interface_v3/macrocmd_manager.cpp
+++ b/ryzom/client/src/interface_v3/macrocmd_manager.cpp
@@ -886,7 +886,7 @@ public:
if (pCS != NULL) pCS->readFromMacro(pMCM->CurrentEditMacro);
// Name
CGroupEditBox *pEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_NEWMACRO_EDIT_NAME));
- if (pEB != NULL) pEB->setInputString(pMCM->CurrentEditMacro.Name);
+ if (pEB != NULL) pEB->setInputStringAsUtf8(pMCM->CurrentEditMacro.Name);
// Commands
CGroupList *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_NEWMACRO_COMMANDS));
if (pList == NULL) return;
diff --git a/ryzom/client/src/interface_v3/people_interraction.cpp b/ryzom/client/src/interface_v3/people_interraction.cpp
index 96f27bb6c..21cfb63cf 100644
--- a/ryzom/client/src/interface_v3/people_interraction.cpp
+++ b/ryzom/client/src/interface_v3/people_interraction.cpp
@@ -2199,7 +2199,7 @@ public:
if (gc)
{
CGroupEditBox *geb = dynamic_cast(gc->getGroup("add_contact_eb:eb"));
- geb->setInputString(ucstring(""));
+ geb->setInputString(u32string());
}
CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, sParams);
}
@@ -2250,18 +2250,18 @@ public:
if (peopleList)
{
// don't add if it is the player name
- if (!ClientCfg.Local && (UserEntity->getEntityName() == geb->getInputString()))
+ if (!ClientCfg.Local && (UserEntity->getEntityName() == geb->getInputStringAsUtf16()))
{
displayVisibleSystemMsg(CI18N::get("uiCantAddYourSelfInContactList"));
}
else
{
- PeopleInterraction.askAddContact(geb->getInputString(), peopleList);
- geb->setInputString(ucstring(""));
+ PeopleInterraction.askAddContact(geb->getInputStringAsUtf16(), peopleList);
+ geb->setInputString(u32string());
}
}
}
- geb->setInputString(ucstring(""));
+ geb->setInputString(u32string());
}
}
}
@@ -2389,7 +2389,7 @@ public:
if (eb)
{
CWidgetManager::getInstance()->setCaptureKeyboard(eb);
- eb->setInputString(ucstring(""));
+ eb->setInputString(u32string());
}
//
if (gc->getActive())
@@ -2416,7 +2416,7 @@ class CHandlerValidatePartyChatName : public IActionHandler
if (!gc) return;
CGroupEditBox *eb = dynamic_cast(gc->getGroup("eb"));
if (!eb) return;
- ucstring title = eb->getInputString();
+ ucstring title = eb->getInputStringAsUtf16();
// TODO GAMEDEV : create (or join ?) a new channel. Each channel (party chat) should have a unique name in the game
// moreover, it should not have the name of another available chat window (for example, it shouldn't be named 'Around Me')
diff --git a/ryzom/client/src/interface_v3/people_list.cpp b/ryzom/client/src/interface_v3/people_list.cpp
index 6be310d94..43ee1543c 100644
--- a/ryzom/client/src/interface_v3/people_list.cpp
+++ b/ryzom/client/src/interface_v3/people_list.cpp
@@ -876,7 +876,7 @@ class CHandlerContactEntry : public IActionHandler
{
CGroupEditBox *pEB = dynamic_cast(pCaller);
if (pEB == NULL) return;
- ucstring text = pEB->getInputString();
+ ucstring text = pEB->getInputStringAsUtf16();
// If the line is empty, do nothing
if(text.empty())
return;
@@ -884,7 +884,7 @@ class CHandlerContactEntry : public IActionHandler
// Parse any tokens in the text
if ( ! CInterfaceManager::parseTokens(text))
{
- pEB->setInputString (string(""));
+ pEB->setInputString (u32string());
return;
}
@@ -895,7 +895,7 @@ class CHandlerContactEntry : public IActionHandler
// TODO : have NLMISC::ICommand accept unicode strings
std::string str = text.toUtf8().substr(1);
NLMISC::ICommand::execute( str, g_log );
- pEB->setInputString (string(""));
+ pEB->setInputString (u32string());
return;
}
// Well, we could have used CChatWindow class to handle this, but CPeopleList was written earlier, so for now
@@ -908,7 +908,7 @@ class CHandlerContactEntry : public IActionHandler
// Simply do a tell on the player
ChatMngr.tell(playerName.toString(), text);
- pEB->setInputString (string(""));
+ pEB->setInputString (u32string());
if (gc)
{
// Restore position of enclosing container if it hasn't been moved/scaled/poped by the user
diff --git a/ryzom/client/src/login.cpp b/ryzom/client/src/login.cpp
index 96922d399..6f3617286 100644
--- a/ryzom/client/src/login.cpp
+++ b/ryzom/client/src/login.cpp
@@ -808,7 +808,7 @@ void initLoginScreen()
CGroupEditBox *pGEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN));
if (pGEB != NULL && (pGEB->getInputString().empty()))
{
- pGEB->setInputString(l);
+ pGEB->setInputStringAsUtf8(l);
}
CAHManager::getInstance()->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_PASSWORD "|select_all=false");
}
@@ -830,8 +830,8 @@ void initAutoLogin()
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CGroupEditBox *pGEBLog = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN));
CGroupEditBox *pGEBPwd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_PASSWORD));
- pGEBLog->setInputString(LoginLogin);
- pGEBPwd->setInputString(LoginPassword);
+ pGEBLog->setInputStringAsUtf8(LoginLogin);
+ pGEBPwd->setInputStringAsUtf8(LoginPassword);
CAHManager::getInstance()->runActionHandler("on_login", NULL, "");
if (ClientCfg.R2Mode)
@@ -1379,8 +1379,8 @@ class CAHOnLogin : public IActionHandler
return;
}
- LoginLogin = pGEBLog->getInputString().toString(); // FIXME: Unicode login
- LoginPassword = pGEBPwd->getInputString().toString();
+ LoginLogin = pGEBLog->getInputStringAsUtf8();
+ LoginPassword = pGEBPwd->getInputStringAsUtf8();
onlogin();
}
@@ -2394,7 +2394,7 @@ bool initCreateAccount()
{
CGroupEditBox * eb = dynamic_cast(createAccountUI->findFromShortId(editBoxes[i] + ":eb"));
if(eb)
- eb->setInputString(ucstring(""));
+ eb->setInputString(u32string());
}
// conditions button
@@ -2581,7 +2581,7 @@ class CAHOnCreateAccountSubmit : public IActionHandler
{
CGroupEditBox * eb = dynamic_cast(createAccountUI->findFromShortId(editBoxes[i] + ":eb"));
if(eb)
- results[i] = eb->getInputString().toUtf8();
+ results[i] = eb->getInputStringAsUtf8();
}
// text
@@ -2735,11 +2735,11 @@ class CAHCreateAccountLogin : public IActionHandler
{
CGroupEditBox * eb = dynamic_cast(createAccountUI->findFromShortId("eb_login:eb"));
if(eb)
- LoginLogin = eb->getInputString().toUtf8();
+ LoginLogin = eb->getInputStringAsUtf8();
eb = dynamic_cast(createAccountUI->findFromShortId("eb_password:eb"));
if(eb)
- LoginPassword = eb->getInputString().toUtf8();
+ LoginPassword = eb->getInputStringAsUtf8();
onlogin(false);
}
diff --git a/ryzom/client/src/r2/editor.cpp b/ryzom/client/src/r2/editor.cpp
index 036e77b21..e9702af28 100644
--- a/ryzom/client/src/r2/editor.cpp
+++ b/ryzom/client/src/r2/editor.cpp
@@ -7484,7 +7484,7 @@ class CAHInviteCharacter : public IActionHandler
CGroupEditBox *geb = dynamic_cast(fatherGC->getGroup("add_contact_eb:eb"));
if (geb && !geb->getInputString().empty())
{
- string charName = geb->getInputString().toString();
+ string charName = geb->getInputStringAsUtf8();
CSessionBrowserImpl & sessionBrowser = CSessionBrowserImpl::getInstance();
sessionBrowser.inviteCharacterByName(sessionBrowser.getCharId(), charName);
@@ -7506,7 +7506,7 @@ class CAHInviteCharacter : public IActionHandler
CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_newcomer");
}
- geb->setInputString(ucstring(""));
+ geb->setInputString(u32string());
}
}
}
From 1d696b8921a0a6f9ba692e61f1cf1a6b2d41e4d7 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Wed, 28 Oct 2020 04:34:18 +0800
Subject: [PATCH 050/205] Revert special handling for wchar
---
nel/include/nel/misc/stream.h | 7 -------
nel/include/nel/misc/types_nl.h | 4 ----
nel/include/nel/misc/ucstring.h | 4 ----
nel/src/misc/system_utils.cpp | 4 ++--
4 files changed, 2 insertions(+), 17 deletions(-)
diff --git a/nel/include/nel/misc/stream.h b/nel/include/nel/misc/stream.h
index 35b6c3f26..89db78a1c 100644
--- a/nel/include/nel/misc/stream.h
+++ b/nel/include/nel/misc/stream.h
@@ -300,13 +300,6 @@ public:
virtual void serial(bool &b) ;
#ifndef NL_OS_CYGWIN
virtual void serial(char &b) ;
-#endif
-#ifdef NL_OS_WINDOWS
- inline void serial(wchar_t &b)
- {
- nlctassert(sizeof(wchar_t) == sizeof(uint16));
- serial(reinterpret_cast(b));
- }
#endif
virtual void serial(std::string &b) ;
virtual void serial(ucstring &b) ;
diff --git a/nel/include/nel/misc/types_nl.h b/nel/include/nel/misc/types_nl.h
index b8fe8270a..bac48c3d6 100644
--- a/nel/include/nel/misc/types_nl.h
+++ b/nel/include/nel/misc/types_nl.h
@@ -546,11 +546,7 @@ template<> struct hash
* \typedef ucchar
* An Unicode character (16 bits)
*/
-#if defined(NL_OS_WINDOWS)
-typedef wchar_t ucchar;
-#else
typedef uint16 ucchar;
-#endif
#ifdef NL_CPP14
typedef char32_t u32char;
diff --git a/nel/include/nel/misc/ucstring.h b/nel/include/nel/misc/ucstring.h
index 28c83ce2f..5b7597f00 100644
--- a/nel/include/nel/misc/ucstring.h
+++ b/nel/include/nel/misc/ucstring.h
@@ -30,11 +30,7 @@
* An unicode string class (16 bits per character).
* Add features to convert and assign \c ucstring to \c string and \c string to \c ucstring.
*/
-#if defined(NL_OS_WINDOWS)
-typedef std::wstring ucstringbase;
-#else
typedef std::basic_string ucstringbase;
-#endif
class ucstring : public ucstringbase
{
diff --git a/nel/src/misc/system_utils.cpp b/nel/src/misc/system_utils.cpp
index 42fe63fca..63eecbf0d 100644
--- a/nel/src/misc/system_utils.cpp
+++ b/nel/src/misc/system_utils.cpp
@@ -168,7 +168,7 @@ bool CSystemUtils::copyTextToClipboard(const ucstring &text)
// allocates a buffer to copy text in global memory
std::string textLocal;
- if (!isUnicode) textLocal = NLMISC::wideToMbcs(text);
+ if (!isUnicode) textLocal = NLMISC::wideToMbcs((const wchar_t *)text.c_str(), text.size());
if (text.size() && !textLocal.size()) textLocal = text.toString();
HGLOBAL mem = GlobalAlloc(GHND | GMEM_DDESHARE, isUnicode ? ((text.size() + 1) * sizeof(wchar_t)) : textLocal.size());
@@ -232,7 +232,7 @@ bool CSystemUtils::pasteTextFromClipboard(ucstring &text)
}
else
{
- static_cast(text) = NLMISC::mbcsToWide((const char *)hLock);
+ reinterpret_cast(text) = NLMISC::mbcsToWide((const char *)hLock);
if (!text.size() && ((const char *)hLock)[0])
text = (const char *)hLock;
}
From 55d83c9486e38d70af0be93600e095bf16197859 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Wed, 28 Oct 2020 05:03:51 +0800
Subject: [PATCH 051/205] Fix comment
---
nel/include/nel/misc/utf_string_view.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/nel/include/nel/misc/utf_string_view.h b/nel/include/nel/misc/utf_string_view.h
index a23c2abca..eac06e0a1 100644
--- a/nel/include/nel/misc/utf_string_view.h
+++ b/nel/include/nel/misc/utf_string_view.h
@@ -26,7 +26,7 @@ namespace NLMISC {
/// String view for UTF-8 and UTF-32 iteration as 32-bit codepoints.
/// This string view keeps the string as a reference, it does not make a copy.
/// Only use this for iterating a string's codepoints.
-/// Strings are not required to be NUL-terminated, but must have at least one character extra.
+/// String must be NUL terminated, but its size may specify a substring.
class CUtfStringView
{
public:
From 993c37f56d579adab13a49bfb4b8828a570245e0 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Wed, 28 Oct 2020 08:24:48 +0800
Subject: [PATCH 052/205] Prefer UTF-8, cleanup, ryzom/ryzomcore#335
---
nel/include/nel/gui/group_editbox.h | 10 ++--
nel/src/gui/CMakeLists.txt | 3 +-
nel/src/gui/group_editbox.cpp | 52 +++++++++----------
nel/src/gui/group_html.cpp | 2 +-
ryzom/client/src/connection.cpp | 2 +-
.../src/interface_v3/action_handler_edit.cpp | 3 +-
.../src/interface_v3/action_handler_item.cpp | 8 +--
.../src/interface_v3/action_phrase_faber.cpp | 2 +-
.../src/interface_v3/bot_chat_page_trade.cpp | 14 ++---
ryzom/client/src/interface_v3/chat_window.cpp | 4 +-
.../src/interface_v3/dbgroup_build_phrase.cpp | 2 +-
ryzom/client/src/interface_v3/group_map.cpp | 2 +-
.../client/src/interface_v3/macrocmd_key.cpp | 6 +--
.../src/interface_v3/macrocmd_manager.cpp | 12 ++---
.../src/interface_v3/people_interraction.cpp | 8 +--
ryzom/client/src/interface_v3/people_list.cpp | 6 +--
ryzom/client/src/login.cpp | 18 +++----
ryzom/client/src/r2/editor.cpp | 4 +-
18 files changed, 77 insertions(+), 81 deletions(-)
diff --git a/nel/include/nel/gui/group_editbox.h b/nel/include/nel/gui/group_editbox.h
index 62b78584c..355c01d3c 100644
--- a/nel/include/nel/gui/group_editbox.h
+++ b/nel/include/nel/gui/group_editbox.h
@@ -63,7 +63,7 @@ namespace NLGUI
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
/// Accessors
- u32string getInputString() const { return _InputString; }
+ std::string getInputString() const;
const u32string &getInputStringRef() const { return _InputString; }
const ucstring &getPrompt() const { return _Prompt; }
@@ -71,7 +71,7 @@ namespace NLGUI
* NB : line returns are encoded as '\n', not '\r\n'
*/
void setPrompt(const ucstring &s) { _Prompt = s; }
- void setInputString(const u32string &str);
+ void setInputString(const std::string &str);
void setInputStringRef(const u32string &str) {_InputString = str; };
void setInputStringAsInt(sint32 val);
sint32 getInputStringAsInt() const;
@@ -79,10 +79,10 @@ namespace NLGUI
sint64 getInputStringAsInt64() const;
void setInputStringAsFloat(float val);
float getInputStringAsFloat() const;
- void setInputStringAsUtf8(const std::string &str);
- std::string getInputStringAsUtf8() const;
void setInputStringAsUtf16(const ucstring &str);
ucstring getInputStringAsUtf16() const;
+ void setInputStringAsUtf32(const u32string &str);
+ u32string getInputStringAsUtf32() const { return _InputString; }
void setColor(NLMISC::CRGBA col);
@@ -189,7 +189,7 @@ namespace NLGUI
REFLECT_LUA_METHOD("setSelectionAll", luaSetSelectionAll);
REFLECT_LUA_METHOD("setFocusOnText", luaSetFocusOnText);
REFLECT_LUA_METHOD("cancelFocusOnText", luaCancelFocusOnText);
- REFLECT_STRING("input_string", getInputStringAsUtf8, setInputStringAsUtf8);
+ REFLECT_STRING("input_string", getInputString, setInputString);
REFLECT_UCSTRING("uc_input_string", getInputStringAsUtf16, setInputStringAsUtf16);
REFLECT_EXPORT_END
diff --git a/nel/src/gui/CMakeLists.txt b/nel/src/gui/CMakeLists.txt
index bb5a0b7f2..4dd53e857 100644
--- a/nel/src/gui/CMakeLists.txt
+++ b/nel/src/gui/CMakeLists.txt
@@ -1,8 +1,7 @@
FILE(GLOB SRC *.cpp *.h)
FILE(GLOB HEADERS ../../include/nel/gui/*.h)
-SOURCE_GROUP("include" FILES ${HEADERS})
-SOURCE_GROUP("src" FILES ${SRC})
+SOURCE_GROUP("" FILES ${HEADERS} ${SRC})
NL_TARGET_LIB(nelgui ${SRC} ${HEADERS})
diff --git a/nel/src/gui/group_editbox.cpp b/nel/src/gui/group_editbox.cpp
index b9dc44895..037ae4656 100644
--- a/nel/src/gui/group_editbox.cpp
+++ b/nel/src/gui/group_editbox.cpp
@@ -1015,7 +1015,7 @@ namespace NLGUI
_CursorAtPreviousLineEnd = false;
if (_ClearOnEscape)
{
- setInputString(u32string());
+ setInputStringAsUtf32(u32string());
triggerOnChangeAH();
}
CWidgetManager::getInstance()->setCaptureKeyboard(NULL);
@@ -1179,7 +1179,7 @@ namespace NLGUI
if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false;
if (!_CanUndo) return false;
_ModifiedInputString = _InputString;
- setInputString(_StartInputString);
+ setInputStringAsUtf32(_StartInputString);
_CanUndo = false;
_CanRedo = true;
setCursorPos((sint32)_InputString.length());
@@ -1192,7 +1192,7 @@ namespace NLGUI
{
if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false;
if (!_CanRedo) return false;
- setInputString(_ModifiedInputString);
+ setInputStringAsUtf32(_ModifiedInputString);
_CanUndo = true;
_CanRedo = false;
setCursorPos((sint32)_InputString.length());
@@ -1303,7 +1303,7 @@ namespace NLGUI
default: break;
}
// update the text
- setInputString(_InputString);
+ setInputStringAsUtf32(_InputString);
// if event of type char or string, consider handle all of them
if( rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keychar || rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keystring )
@@ -1624,8 +1624,13 @@ namespace NLGUI
}
+
// ----------------------------------------------------------------------------
- void CGroupEditBox::setInputString(const u32string &str)
+ void CGroupEditBox::setInputString(const std::string &str)
+ {
+ setInputStringAsUtf32(CUtfStringView(str).toUtf32());
+ }
+ void CGroupEditBox::setInputStringAsUtf32(const u32string &str)
{
_InputString = str;
if (_CursorPos > (sint32) str.length())
@@ -1644,43 +1649,42 @@ namespace NLGUI
void CGroupEditBox::setDefaultInputString(const ucstring &str)
{
_DefaultInputString= true;
- setInputString(CUtfStringView(str).toUtf32());
+ setInputStringAsUtf32(CUtfStringView(str).toUtf32());
}
-
// ***************************************************************************
sint32 CGroupEditBox::getInputStringAsInt() const
{
sint32 value;
- fromString(getInputStringAsUtf8(), value);
+ fromString(getInputString(), value);
return value;
}
// ***************************************************************************
void CGroupEditBox::setInputStringAsInt(sint32 val)
{
- setInputStringAsUtf8(NLMISC::toString(val));
+ setInputString(NLMISC::toString(val));
}
// ***************************************************************************
sint64 CGroupEditBox::getInputStringAsInt64() const
{
sint64 value;
- fromString(getInputStringAsUtf8(), value);
+ fromString(getInputString(), value);
return value;
}
// ***************************************************************************
void CGroupEditBox::setInputStringAsInt64(sint64 val)
{
- setInputStringAsUtf8(NLMISC::toString(val));
+ setInputString(NLMISC::toString(val));
}
// ***************************************************************************
float CGroupEditBox::getInputStringAsFloat() const
{
float value;
- fromString(getInputStringAsUtf8(), value);
+ fromString(getInputString(), value);
return value;
}
@@ -1688,7 +1692,7 @@ namespace NLGUI
void CGroupEditBox::setInputStringAsFloat(float val)
{
string fmt= "%." + NLMISC::toString(_MaxFloatPrec) + "f";
- setInputStringAsUtf8(NLMISC::toString(fmt.c_str(), val));
+ setInputString(NLMISC::toString(fmt.c_str(), val));
}
// ***************************************************************************
@@ -1739,21 +1743,15 @@ namespace NLGUI
}
// ***************************************************************************
- void CGroupEditBox::setInputStringAsUtf8(const std::string &str)
- {
- setInputString(CUtfStringView(str).toUtf32());
- }
-
- // ***************************************************************************
- std::string CGroupEditBox::getInputStringAsUtf8() const
+ std::string CGroupEditBox::getInputString() const
{
- return CUtfStringView(_InputString).toUtf8();
+ return NLMISC::CUtfStringView(_InputString).toUtf8();
}
// ***************************************************************************
void CGroupEditBox::setInputStringAsUtf16(const ucstring &str)
{
- setInputString(CUtfStringView(str).toUtf32());
+ setInputStringAsUtf32(CUtfStringView(str).toUtf32());
}
// ***************************************************************************
@@ -1770,7 +1768,7 @@ namespace NLGUI
return;
// set the string and maybe execute
- setInputString(CUtfStringView((ucchar) '/' + command).toUtf32());
+ setInputStringAsUtf16((ucchar) '/' + command);
if (execute)
{
// stop selection
@@ -1853,7 +1851,7 @@ namespace NLGUI
f.serial(_PrevNumLine);
if (f.isReading())
{
- setInputString(_InputString);
+ setInputStringAsUtf32(_InputString);
}
// serial selection
@@ -1870,7 +1868,7 @@ namespace NLGUI
void CGroupEditBox::onQuit()
{
// clear the text and restore backup pos before final save
- setInputString(u32string());
+ setInputStringAsUtf32(u32string());
_CurrSelection = NULL;
}
@@ -1878,7 +1876,7 @@ namespace NLGUI
void CGroupEditBox::onLoadConfig()
{
// config is not saved when there's an empty string, so restore that default state.
- setInputString(u32string());
+ setInputStringAsUtf32(u32string());
_CurrSelection = NULL;
_PrevNumLine = 1;
}
@@ -1893,7 +1891,7 @@ namespace NLGUI
if (_DefaultInputString)
{
_DefaultInputString= false;
- setInputString(u32string());
+ setInputStringAsUtf32(u32string());
}
_CanRedo = false;
_CanUndo = false;
diff --git a/nel/src/gui/group_html.cpp b/nel/src/gui/group_html.cpp
index 7f80405ce..4fab8c4bb 100644
--- a/nel/src/gui/group_html.cpp
+++ b/nel/src/gui/group_html.cpp
@@ -3024,7 +3024,7 @@ namespace NLGUI
CGroupEditBox *eb = dynamic_cast(textArea->getGroup("eb"));
if (eb)
{
- eb->setInputString(CUtfStringView(decodeHTMLEntities(content)).toUtf32());
+ eb->setInputString(CUtfStringView(decodeHTMLEntities(content)).toUtf8());
if (style.hasStyle("background-color"))
{
CViewBitmap *bg = dynamic_cast(eb->getView("bg"));
diff --git a/ryzom/client/src/connection.cpp b/ryzom/client/src/connection.cpp
index 5aad200ae..00c663e5e 100644
--- a/ryzom/client/src/connection.cpp
+++ b/ryzom/client/src/connection.cpp
@@ -2977,7 +2977,7 @@ class CAHLoadScenario : public IActionHandler
{
CGroupEditBox* editBox = dynamic_cast(result);
if(editBox)
- description = editBox->getInputStringAsUtf8();
+ description = editBox->getInputString();
}
// races
diff --git a/ryzom/client/src/interface_v3/action_handler_edit.cpp b/ryzom/client/src/interface_v3/action_handler_edit.cpp
index 81837bf4a..055a77422 100644
--- a/ryzom/client/src/interface_v3/action_handler_edit.cpp
+++ b/ryzom/client/src/interface_v3/action_handler_edit.cpp
@@ -639,8 +639,7 @@ class CAHEditExpandOrCycleTell : public CAHEdit
void actionPart ()
{
// If the line starts with '/tell ', do not try to expand
- static const u32string TELL_STR(CUtfStringView("/tell ").toUtf32());
- if (_GroupEdit->getInputString().substr(0, TELL_STR.length()) != TELL_STR)
+ if (!NLMISC::startsWith(_GroupEdit->getInputString(), "/tell "))
{
if (_GroupEdit->expand()) return;
}
diff --git a/ryzom/client/src/interface_v3/action_handler_item.cpp b/ryzom/client/src/interface_v3/action_handler_item.cpp
index 998bfcd77..655ea084f 100644
--- a/ryzom/client/src/interface_v3/action_handler_item.cpp
+++ b/ryzom/client/src/interface_v3/action_handler_item.cpp
@@ -239,8 +239,8 @@ void CInterfaceItemEdition::CItemEditionWindow::begin()
closeButton->setActive(false);
group->setActive(true);
- editBoxShort->setInputString(u32string());
- editBoxLarge->setInputString(u32string());
+ editBoxShort->setInputString(std::string());
+ editBoxLarge->setInputString(std::string());
display->setTextFormatTaged(ucstring());
@@ -297,8 +297,8 @@ void CInterfaceItemEdition::CItemEditionWindow::begin()
closeButton->setActive(true);
group->setActive(false);
- editBoxShort->setInputString(u32string());
- editBoxLarge->setInputString(u32string());
+ editBoxShort->setInputString(std::string());
+ editBoxLarge->setInputString(std::string());
display->setTextFormatTaged(ucstring());
// Finish the display or add the waiter
diff --git a/ryzom/client/src/interface_v3/action_phrase_faber.cpp b/ryzom/client/src/interface_v3/action_phrase_faber.cpp
index d039444f9..40efedac0 100644
--- a/ryzom/client/src/interface_v3/action_phrase_faber.cpp
+++ b/ryzom/client/src/interface_v3/action_phrase_faber.cpp
@@ -718,7 +718,7 @@ void CActionPhraseFaber::startMpSelection(uint itemReqLine, uint mpSlot)
if (eb)
{
CWidgetManager::getInstance()->setCaptureKeyboard(eb);
- eb->setInputStringAsUtf8(toString(maxQuantity));
+ eb->setInputString(toString(maxQuantity));
eb->setSelectionAll();
}
}
diff --git a/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp b/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp
index 64f19214f..dc2c88789 100644
--- a/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp
+++ b/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp
@@ -333,7 +333,7 @@ uint32 CBotChatPageTrade::getCurrItemQuantity() const
CGroupEditBox *ed = dynamic_cast(ig->getGroup("header_opened:standard_price:quantity:edit:eb"));
if (!ed) return std::numeric_limits::max();
uint32 intQuantity;
- if (fromString(ed->getInputStringAsUtf8(), intQuantity))
+ if (fromString(ed->getInputString(), intQuantity))
{
return intQuantity;
}
@@ -1465,7 +1465,7 @@ void CBotChatPageTrade::setupPriceGroupQuantity(CInterfaceGroup *priceGroup, sin
CGroupEditBox *eb = dynamic_cast(quantityGroup->getGroup("edit:eb"));
if (eb)
{
- eb->setInputStringAsUtf8(toString(defaultQuantity));
+ eb->setInputString(toString(defaultQuantity));
}
}
}
@@ -1569,7 +1569,7 @@ void CBotChatPageTrade::setupResellGroup(bool sellMode, uint defaultQuantity, CI
{
sint32 resaleMargin= NLGUI::CDBManager::getInstance()->getDbProp( "UI:SAVE:TRADE_ITEM:RESALE_MARGIN" )->getValue32();
clamp(resaleMargin, 0, (sint32)MaxResaleMargin);
- eb->setInputStringAsUtf8( toString( resaleMargin ) );
+ eb->setInputString( toString( resaleMargin ) );
eb->setPositiveIntegerMaxValue(MaxResaleMargin);
}
}
@@ -1725,8 +1725,8 @@ void CBotChatPageTrade::startChangeBuyFilterDialog(const std::string &dbext, con
sint rangeMax= 0;
if(dbRangeMin) rangeMin= dbRangeMin->getValue32();
if(dbRangeMax) rangeMax= dbRangeMax->getValue32();
- if(edMin) edMin->setInputStringAsUtf8(toString(rangeMin));
- if(edMax) edMax->setInputStringAsUtf8(toString(rangeMax));
+ if(edMin) edMin->setInputString(toString(rangeMin));
+ if(edMax) edMax->setInputString(toString(rangeMax));
if(edMin) edMin->setPositiveIntegerMaxValue(maxValue);
if(edMax) edMax->setPositiveIntegerMaxValue(maxValue);
@@ -1754,8 +1754,8 @@ void CBotChatPageTrade::resetBuyFilterDialog()
sint rangeMin= 0;
sint rangeMax= _FilterBuyDlgMaxValue;
// write result in EditBox, and in db
- if(edMin) edMin->setInputStringAsUtf8(toString(rangeMin));
- if(edMax) edMax->setInputStringAsUtf8(toString(rangeMax));
+ if(edMin) edMin->setInputString(toString(rangeMin));
+ if(edMax) edMax->setInputString(toString(rangeMax));
if(dbRangeMin) dbRangeMin->setValue32(rangeMin);
if(dbRangeMax) dbRangeMax->setValue32(rangeMax);
diff --git a/ryzom/client/src/interface_v3/chat_window.cpp b/ryzom/client/src/interface_v3/chat_window.cpp
index bfac81212..ed1a220ca 100644
--- a/ryzom/client/src/interface_v3/chat_window.cpp
+++ b/ryzom/client/src/interface_v3/chat_window.cpp
@@ -1289,7 +1289,7 @@ public:
// Parse any tokens in the text
if ( ! CInterfaceManager::parseTokens(text))
{
- pEB->setInputString (u32string());
+ pEB->setInputString(std::string());
return;
}
@@ -1329,7 +1329,7 @@ public:
}
}
// Clear input string
- pEB->setInputString (u32string());
+ pEB->setInputString (std::string());
CGroupContainer *gc = static_cast< CGroupContainer* >( pEB->getEnclosingContainer() );
if (gc)
diff --git a/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp b/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp
index 8ffa62530..561d48235 100644
--- a/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp
+++ b/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp
@@ -279,7 +279,7 @@ void CDBGroupBuildPhrase::clearBuildingPhrase()
// Empty the name
if(_UserSentenceName)
{
- _UserSentenceName->setInputString(u32string());
+ _UserSentenceName->setInputString(std::string());
}
// update Display
diff --git a/ryzom/client/src/interface_v3/group_map.cpp b/ryzom/client/src/interface_v3/group_map.cpp
index b696ae40d..41b6f021e 100644
--- a/ryzom/client/src/interface_v3/group_map.cpp
+++ b/ryzom/client/src/interface_v3/group_map.cpp
@@ -3882,7 +3882,7 @@ class CAHLandMarkFilter : public IActionHandler
CGroupEditBox* eb = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(group));
if (!eb) return;
- text = eb->getInputStringAsUtf8();
+ text = eb->getInputString();
}
map->setLandmarkFilter(text);
diff --git a/ryzom/client/src/interface_v3/macrocmd_key.cpp b/ryzom/client/src/interface_v3/macrocmd_key.cpp
index 241862ff1..f97e90723 100644
--- a/ryzom/client/src/interface_v3/macrocmd_key.cpp
+++ b/ryzom/client/src/interface_v3/macrocmd_key.cpp
@@ -679,7 +679,7 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std
else sEditBox = WinName+WIN_EDITCMD_COMBO_SECOND_PARAM_EDITBOX;
CGroupEditBox *pEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sEditBox));
// sTmp is utf8
- pEB->setInputStringAsUtf8(sTmp);
+ pEB->setInputString(sTmp);
}
// Setup the param name if any
@@ -863,7 +863,7 @@ void CModalContainerEditCmd::validCurrentCommand()
CGroupEditBox *pEB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( sWin ));
// convert to utf8
if (pEB != NULL)
- CurrentEditCmdLine.ActionName.Argu += pEB->getInputStringAsUtf8();
+ CurrentEditCmdLine.ActionName.Argu += pEB->getInputString();
noParam++;
}
}
@@ -1148,7 +1148,7 @@ void CModalContainerEditCmd::onChangeAction()
CGroupEditBox *pEB= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( sWin ));
if( pEB )
{
- pEB->setInputString(u32string());
+ pEB->setInputString(std::string());
}
NLGUI::CDBManager::getInstance()->getDbProp( sDB )->setValue32(1);
}
diff --git a/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/ryzom/client/src/interface_v3/macrocmd_manager.cpp
index 39b2aedde..bf2197e45 100644
--- a/ryzom/client/src/interface_v3/macrocmd_manager.cpp
+++ b/ryzom/client/src/interface_v3/macrocmd_manager.cpp
@@ -636,7 +636,7 @@ public:
CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(Params));
if (pCS == NULL) return;
- pCS->setMacroText(pEB->getInputStringAsUtf8());
+ pCS->setMacroText(pEB->getInputString());
}
};
REGISTER_ACTION_HANDLER( CHandlerEBUpdateMacroText, "eb_update_macro_text");
@@ -703,10 +703,10 @@ public:
CGroupEditBox *pEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_MACROICONCREATION_EDITTEXT));
if (pEB != NULL)
{
- pEB->setInputStringAsUtf8(pMCM->CurrentEditMacro.DispText);
+ pEB->setInputString(pMCM->CurrentEditMacro.DispText);
CDBCtrlSheet *pCS = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_MACROICONCREATION_ICON));
if (pCS != NULL)
- pCS->setMacroText(pEB->getInputStringAsUtf8());
+ pCS->setMacroText(pEB->getInputString());
}
CAHManager::getInstance()->runActionHandler("set_macro_back", NULL, string("target=")+CTRL_MACROICONCREATION_ICON+"|value="+toString(back));
@@ -862,11 +862,11 @@ public:
if (pEB == NULL) return;
CMacroCmdManager *pMCM = CMacroCmdManager::getInstance();
- pMCM->CurrentEditMacro.Name = pEB->getInputStringAsUtf8();
+ pMCM->CurrentEditMacro.Name = pEB->getInputString();
if ((pMCM->CurrentEditMacro.Name.size() >= 2) &&
(pMCM->CurrentEditMacro.Name[0] == 'u') && (pMCM->CurrentEditMacro.Name[1] == 'i'))
pMCM->CurrentEditMacro.Name[0] = 'U';
- pEB->setInputStringAsUtf8(pMCM->CurrentEditMacro.Name);
+ pEB->setInputString(pMCM->CurrentEditMacro.Name);
}
};
REGISTER_ACTION_HANDLER( CHandlerNewMacroEnterName, "new_macro_enter_name");
@@ -886,7 +886,7 @@ public:
if (pCS != NULL) pCS->readFromMacro(pMCM->CurrentEditMacro);
// Name
CGroupEditBox *pEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_NEWMACRO_EDIT_NAME));
- if (pEB != NULL) pEB->setInputStringAsUtf8(pMCM->CurrentEditMacro.Name);
+ if (pEB != NULL) pEB->setInputString(pMCM->CurrentEditMacro.Name);
// Commands
CGroupList *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_NEWMACRO_COMMANDS));
if (pList == NULL) return;
diff --git a/ryzom/client/src/interface_v3/people_interraction.cpp b/ryzom/client/src/interface_v3/people_interraction.cpp
index 21cfb63cf..7bde7d0fc 100644
--- a/ryzom/client/src/interface_v3/people_interraction.cpp
+++ b/ryzom/client/src/interface_v3/people_interraction.cpp
@@ -2199,7 +2199,7 @@ public:
if (gc)
{
CGroupEditBox *geb = dynamic_cast(gc->getGroup("add_contact_eb:eb"));
- geb->setInputString(u32string());
+ geb->setInputString(std::string());
}
CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, sParams);
}
@@ -2257,11 +2257,11 @@ public:
else
{
PeopleInterraction.askAddContact(geb->getInputStringAsUtf16(), peopleList);
- geb->setInputString(u32string());
+ geb->setInputString(std::string());
}
}
}
- geb->setInputString(u32string());
+ geb->setInputString(std::string());
}
}
}
@@ -2389,7 +2389,7 @@ public:
if (eb)
{
CWidgetManager::getInstance()->setCaptureKeyboard(eb);
- eb->setInputString(u32string());
+ eb->setInputString(std::string());
}
//
if (gc->getActive())
diff --git a/ryzom/client/src/interface_v3/people_list.cpp b/ryzom/client/src/interface_v3/people_list.cpp
index 43ee1543c..1b4c7ea5e 100644
--- a/ryzom/client/src/interface_v3/people_list.cpp
+++ b/ryzom/client/src/interface_v3/people_list.cpp
@@ -884,7 +884,7 @@ class CHandlerContactEntry : public IActionHandler
// Parse any tokens in the text
if ( ! CInterfaceManager::parseTokens(text))
{
- pEB->setInputString (u32string());
+ pEB->setInputString (std::string());
return;
}
@@ -895,7 +895,7 @@ class CHandlerContactEntry : public IActionHandler
// TODO : have NLMISC::ICommand accept unicode strings
std::string str = text.toUtf8().substr(1);
NLMISC::ICommand::execute( str, g_log );
- pEB->setInputString (u32string());
+ pEB->setInputString (std::string());
return;
}
// Well, we could have used CChatWindow class to handle this, but CPeopleList was written earlier, so for now
@@ -908,7 +908,7 @@ class CHandlerContactEntry : public IActionHandler
// Simply do a tell on the player
ChatMngr.tell(playerName.toString(), text);
- pEB->setInputString (u32string());
+ pEB->setInputString (std::string());
if (gc)
{
// Restore position of enclosing container if it hasn't been moved/scaled/poped by the user
diff --git a/ryzom/client/src/login.cpp b/ryzom/client/src/login.cpp
index 6f3617286..b134a5519 100644
--- a/ryzom/client/src/login.cpp
+++ b/ryzom/client/src/login.cpp
@@ -808,7 +808,7 @@ void initLoginScreen()
CGroupEditBox *pGEB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN));
if (pGEB != NULL && (pGEB->getInputString().empty()))
{
- pGEB->setInputStringAsUtf8(l);
+ pGEB->setInputString(l);
}
CAHManager::getInstance()->runActionHandler("set_keyboard_focus", NULL, "target=" CTRL_EDITBOX_PASSWORD "|select_all=false");
}
@@ -830,8 +830,8 @@ void initAutoLogin()
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CGroupEditBox *pGEBLog = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_LOGIN));
CGroupEditBox *pGEBPwd = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CTRL_EDITBOX_PASSWORD));
- pGEBLog->setInputStringAsUtf8(LoginLogin);
- pGEBPwd->setInputStringAsUtf8(LoginPassword);
+ pGEBLog->setInputString(LoginLogin);
+ pGEBPwd->setInputString(LoginPassword);
CAHManager::getInstance()->runActionHandler("on_login", NULL, "");
if (ClientCfg.R2Mode)
@@ -1379,8 +1379,8 @@ class CAHOnLogin : public IActionHandler
return;
}
- LoginLogin = pGEBLog->getInputStringAsUtf8();
- LoginPassword = pGEBPwd->getInputStringAsUtf8();
+ LoginLogin = pGEBLog->getInputString();
+ LoginPassword = pGEBPwd->getInputString();
onlogin();
}
@@ -2394,7 +2394,7 @@ bool initCreateAccount()
{
CGroupEditBox * eb = dynamic_cast(createAccountUI->findFromShortId(editBoxes[i] + ":eb"));
if(eb)
- eb->setInputString(u32string());
+ eb->setInputString(std::string());
}
// conditions button
@@ -2581,7 +2581,7 @@ class CAHOnCreateAccountSubmit : public IActionHandler
{
CGroupEditBox * eb = dynamic_cast(createAccountUI->findFromShortId(editBoxes[i] + ":eb"));
if(eb)
- results[i] = eb->getInputStringAsUtf8();
+ results[i] = eb->getInputString();
}
// text
@@ -2735,11 +2735,11 @@ class CAHCreateAccountLogin : public IActionHandler
{
CGroupEditBox * eb = dynamic_cast(createAccountUI->findFromShortId("eb_login:eb"));
if(eb)
- LoginLogin = eb->getInputStringAsUtf8();
+ LoginLogin = eb->getInputString();
eb = dynamic_cast(createAccountUI->findFromShortId("eb_password:eb"));
if(eb)
- LoginPassword = eb->getInputStringAsUtf8();
+ LoginPassword = eb->getInputString();
onlogin(false);
}
diff --git a/ryzom/client/src/r2/editor.cpp b/ryzom/client/src/r2/editor.cpp
index e9702af28..ee203d312 100644
--- a/ryzom/client/src/r2/editor.cpp
+++ b/ryzom/client/src/r2/editor.cpp
@@ -7484,7 +7484,7 @@ class CAHInviteCharacter : public IActionHandler
CGroupEditBox *geb = dynamic_cast(fatherGC->getGroup("add_contact_eb:eb"));
if (geb && !geb->getInputString().empty())
{
- string charName = geb->getInputStringAsUtf8();
+ string charName = geb->getInputString();
CSessionBrowserImpl & sessionBrowser = CSessionBrowserImpl::getInstance();
sessionBrowser.inviteCharacterByName(sessionBrowser.getCharId(), charName);
@@ -7506,7 +7506,7 @@ class CAHInviteCharacter : public IActionHandler
CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_newcomer");
}
- geb->setInputString(u32string());
+ geb->setInputString(std::string());
}
}
}
From 1ec9f16de45311388ee8eb215f662d49f6513997 Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Wed, 28 Oct 2020 08:26:53 +0800
Subject: [PATCH 053/205] Get rid of useless raw copy in ucstring, default to
UTF-8, ryzom/ryzomcore#335
---
nel/include/nel/misc/ucstring.h | 4 +---
nel/src/misc/ucstring.cpp | 22 +---------------------
2 files changed, 2 insertions(+), 24 deletions(-)
diff --git a/nel/include/nel/misc/ucstring.h b/nel/include/nel/misc/ucstring.h
index 5b7597f00..61f7f416b 100644
--- a/nel/include/nel/misc/ucstring.h
+++ b/nel/include/nel/misc/ucstring.h
@@ -50,7 +50,7 @@ public:
ucstring(const std::string &str)
: ucstringbase()
{
- rawCopy(str);
+ fromUtf8(str);
}
~ucstring() { }
@@ -171,8 +171,6 @@ public:
return ret;
}
-private:
- void rawCopy(const std::string &str);
};
inline ucstring operator+(const ucstringbase &ucstr, ucchar c)
diff --git a/nel/src/misc/ucstring.cpp b/nel/src/misc/ucstring.cpp
index 79cf78f7e..05c0d24ab 100644
--- a/nel/src/misc/ucstring.cpp
+++ b/nel/src/misc/ucstring.cpp
@@ -20,14 +20,7 @@
void ucstring::toString(std::string &str) const
{
- str.resize(size());
- for (uint i = 0; i < str.size(); i++)
- {
- if (operator[](i) > 255)
- str[i] = '?';
- else
- str[i] = (char)operator[](i);
- }
+ str = nlmove(NLMISC::CUtfStringView(*this).toUtf8());
}
std::string ucstring::toUtf8() const
@@ -40,17 +33,4 @@ void ucstring::fromUtf8(const std::string &stringUtf8)
*this = NLMISC::CUtfStringView(stringUtf8).toUtf16();
}
-void ucstring::rawCopy(const std::string &str)
-{
- // We need to convert the char into 8bits unsigned int before promotion to 16 bits
- // otherwise, as char are signed on some compiler (MSCV for ex), the sign bit is extended to 16 bits.
- resize(str.size());
- std::string::const_iterator first(str.begin()), last(str.end());
- iterator dest(begin());
- for (; first != last; ++first, ++dest)
- {
- *dest = uint8(*first);
- }
-}
-
/* end of file */
From 6ff5ddd790c6d339420cae52755fc24303d7fc0b Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Wed, 28 Oct 2020 08:32:17 +0800
Subject: [PATCH 054/205] Explicit function for obtaining 7-bit ascii,
ryzom/ryzomcore#335
---
nel/include/nel/misc/utf_string_view.h | 1 +
nel/src/misc/utf_string_view.cpp | 15 +++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/nel/include/nel/misc/utf_string_view.h b/nel/include/nel/misc/utf_string_view.h
index eac06e0a1..df6bf76c8 100644
--- a/nel/include/nel/misc/utf_string_view.h
+++ b/nel/include/nel/misc/utf_string_view.h
@@ -60,6 +60,7 @@ public:
u32string toUtf32() const; // Makes a copy
std::wstring toWide() const; // Platform dependent, UTF-16 or UTF-32. Makes a copy.
+ std::string toAscii() const; // Returns only values 0-127, 7-bit ASCII. Makes a copy.
inline bool isUtf8() const { return m_Iterator == utf8Iterator; }
inline bool isUtf16() const { return m_Iterator == utf16Iterator; }
diff --git a/nel/src/misc/utf_string_view.cpp b/nel/src/misc/utf_string_view.cpp
index db2ea7cec..3be14f515 100644
--- a/nel/src/misc/utf_string_view.cpp
+++ b/nel/src/misc/utf_string_view.cpp
@@ -106,6 +106,21 @@ u32string CUtfStringView::toUtf32() const
return res;
}
+std::string CUtfStringView::toAscii() const
+{
+ std::string res;
+ res.reserve(m_Size);
+ for (iterator it(begin()), end(end()); it != end; ++it)
+ {
+ u32char c = *it;
+ if (c < 0x80)
+ res += c;
+ else
+ res += '_';
+ }
+ return res;
+}
+
std::wstring CUtfStringView::toWide() const
{
#ifdef NL_OS_WINDOWS
From 698bfff501d481afa26d100db2db0a1ad1c5028c Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Wed, 28 Oct 2020 08:41:39 +0800
Subject: [PATCH 055/205] Prefer UTF-8, cleanup, ryzom/ryzomcore#335
---
nel/include/nel/gui/group_editbox.h | 7 ++---
nel/src/gui/group_editbox.cpp | 26 ++++++++++++++-----
.../src/interface_v3/action_handler_edit.cpp | 26 +++++++++----------
ryzom/client/src/interface_v3/chat_window.cpp | 2 +-
4 files changed, 37 insertions(+), 24 deletions(-)
diff --git a/nel/include/nel/gui/group_editbox.h b/nel/include/nel/gui/group_editbox.h
index 355c01d3c..36b8d63b4 100644
--- a/nel/include/nel/gui/group_editbox.h
+++ b/nel/include/nel/gui/group_editbox.h
@@ -64,13 +64,14 @@ namespace NLGUI
/// Accessors
std::string getInputString() const;
+ std::string getPrompt() const;
const u32string &getInputStringRef() const { return _InputString; }
- const ucstring &getPrompt() const { return _Prompt; }
+ const u32string &getPromptRef() const { return _Prompt; }
/** Set the prompt
* NB : line returns are encoded as '\n', not '\r\n'
*/
- void setPrompt(const ucstring &s) { _Prompt = s; }
+ void setPrompt(const std::string &s);
void setInputString(const std::string &str);
void setInputStringRef(const u32string &str) {_InputString = str; };
void setInputStringAsInt(sint32 val);
@@ -228,7 +229,7 @@ namespace NLGUI
NLMISC::CRGBA _BackSelectColor;
// Text info
- ucstring _Prompt;
+ u32string _Prompt;
u32string _InputString;
CViewText *_ViewText;
diff --git a/nel/src/gui/group_editbox.cpp b/nel/src/gui/group_editbox.cpp
index 037ae4656..1453ba5fe 100644
--- a/nel/src/gui/group_editbox.cpp
+++ b/nel/src/gui/group_editbox.cpp
@@ -96,7 +96,7 @@ namespace NLGUI
_ViewTextDeltaX(0)
{
- _Prompt = ">";
+ _Prompt = u32string(1, '>');
_BackSelectColor= CRGBA::White;
_TextSelectColor= CRGBA::Black;
}
@@ -170,7 +170,7 @@ namespace NLGUI
else
if( name == "prompt" )
{
- return _Prompt.toString();
+ return CUtfStringView(_Prompt).toUtf8();
}
else
if( name == "enter_type" )
@@ -354,7 +354,7 @@ namespace NLGUI
else
if( name == "prompt" )
{
- _Prompt = value;
+ _Prompt = CUtfStringView(value).toUtf32();
return;
}
else
@@ -477,7 +477,7 @@ namespace NLGUI
xmlSetProp( node, BAD_CAST "max_chars_size", BAD_CAST toString( _MaxCharsSize ).c_str() );
xmlSetProp( node, BAD_CAST "enter_loose_focus", BAD_CAST toString( _LooseFocusOnEnter ).c_str() );
xmlSetProp( node, BAD_CAST "enter_recover_focus", BAD_CAST toString( _RecoverFocusOnEnter ).c_str() );
- xmlSetProp( node, BAD_CAST "prompt", BAD_CAST _Prompt.toString().c_str() );
+ xmlSetProp( node, BAD_CAST "prompt", BAD_CAST CUtfStringView(_Prompt).toUtf8().c_str() );
std::string e;
switch( _EntryType )
@@ -606,7 +606,7 @@ namespace NLGUI
if (prop) _ResetFocusOnHide = convertBool(prop);
prop = (char*) xmlGetProp( cur, (xmlChar*)"prompt" );
- if (prop) _Prompt = (const char*)prop;
+ if (prop) _Prompt = CUtfStringView((const char*)prop).toUtf32();
prop = (char*) xmlGetProp( cur, (xmlChar*)"entry_type" );
_EntryType = Text;
@@ -1436,13 +1436,13 @@ namespace NLGUI
ucstring usTmp;
if (_EntryType == Password)
{
- usTmp = _Prompt;
+ usTmp = CUtfStringView(_Prompt).toUtf16();
for (uint32 i = 0; i < _InputString.size(); ++i)
usTmp += "*";
}
else
{
- usTmp = _Prompt + CUtfStringView(_InputString).toUtf16();
+ usTmp = CUtfStringView(_Prompt + _InputString).toUtf16();
}
_ViewText->setText (usTmp);
}
@@ -1624,6 +1624,12 @@ namespace NLGUI
}
+ // ----------------------------------------------------------------------------
+ void CGroupEditBox::setPrompt(const std::string &s)
+ {
+ _Prompt = CUtfStringView(s).toUtf32();
+ }
+
// ----------------------------------------------------------------------------
void CGroupEditBox::setInputString(const std::string &str)
@@ -1742,6 +1748,12 @@ namespace NLGUI
CInterfaceGroup::setActive(active);
}
+ // ***************************************************************************
+ std::string CGroupEditBox::getPrompt() const
+ {
+ return NLMISC::CUtfStringView(_Prompt).toUtf8();
+ }
+
// ***************************************************************************
std::string CGroupEditBox::getInputString() const
{
diff --git a/ryzom/client/src/interface_v3/action_handler_edit.cpp b/ryzom/client/src/interface_v3/action_handler_edit.cpp
index 055a77422..bde8f5389 100644
--- a/ryzom/client/src/interface_v3/action_handler_edit.cpp
+++ b/ryzom/client/src/interface_v3/action_handler_edit.cpp
@@ -288,11 +288,11 @@ class CAHEditGotoLineBegin : public CAHEdit
// go to the start of line
if (_GroupEdit->getViewText())
{
- sint line = _GroupEdit->getViewText()->getLineFromIndex(_GroupEdit->getCursorPos() + (uint)_GroupEdit->getPrompt().length());
+ sint line = _GroupEdit->getViewText()->getLineFromIndex(_GroupEdit->getCursorPos() + (uint)_GroupEdit->getPromptRef().length());
if (line == -1) return;
- sint newPos = std::max(_GroupEdit->getViewText()->getLineStartIndex(line), (sint) _GroupEdit->getPrompt().length());
+ sint newPos = std::max(_GroupEdit->getViewText()->getLineStartIndex(line), (sint) _GroupEdit->getPromptRef().length());
if (newPos == -1) return;
- _GroupEdit->setCursorPos(newPos - (sint32)_GroupEdit->getPrompt().length());
+ _GroupEdit->setCursorPos(newPos - (sint32)_GroupEdit->getPromptRef().length());
_GroupEdit->setCursorAtPreviousLineEnd(false);
}
}
@@ -310,20 +310,20 @@ class CAHEditGotoLineEnd : public CAHEdit
{
if (_GroupEdit->getViewText()->getMultiLine())
{
- sint line = _GroupEdit->getViewText()->getLineFromIndex(_GroupEdit->getCursorPos() + (uint)_GroupEdit->getPrompt().length(), _GroupEdit->isCursorAtPreviousLineEnd());
+ sint line = _GroupEdit->getViewText()->getLineFromIndex(_GroupEdit->getCursorPos() + (uint)_GroupEdit->getPromptRef().length(), _GroupEdit->isCursorAtPreviousLineEnd());
if (line == -1) return;
sint newPos;
bool endOfPreviousLine;
_GroupEdit->getViewText()->getLineEndIndex(line, newPos, endOfPreviousLine);
if (newPos != -1)
{
- _GroupEdit->setCursorPos(newPos - (sint32)_GroupEdit->getPrompt().length());
+ _GroupEdit->setCursorPos(newPos - (sint32)_GroupEdit->getPromptRef().length());
_GroupEdit->setCursorAtPreviousLineEnd(endOfPreviousLine);
}
}
else
{
- _GroupEdit->setCursorPos((sint32)_GroupEdit->getPrompt().length() + (sint32)_GroupEdit->getInputString().length());
+ _GroupEdit->setCursorPos((sint32)_GroupEdit->getPromptRef().length() + (sint32)_GroupEdit->getInputString().length());
}
}
}
@@ -378,7 +378,7 @@ class CAHEditPreviousLine : public CAHEdit
}
else if (_GroupEdit->getViewText()->getMultiLine())
{
- uint cursorPosInText = _GroupEdit->getCursorPos() + (uint)_GroupEdit->getPrompt().length();
+ uint cursorPosInText = _GroupEdit->getCursorPos() + (uint)_GroupEdit->getPromptRef().length();
if (
(_GroupEdit->getCursorPos() == (sint32) _GroupEdit->getInputStringRef().length() && _GroupEdit->getViewText()->getNumLine() == 1) ||
_GroupEdit->getViewText()->getLineFromIndex(cursorPosInText, _GroupEdit->isCursorAtPreviousLineEnd()) == 0
@@ -396,7 +396,7 @@ class CAHEditPreviousLine : public CAHEdit
_GroupEdit->getViewText()->getCharacterIndexFromPosition(cx, cy, newCharIndex, newLineEnd);
if (newLineEnd)
{
- _GroupEdit->setCursorPos(newCharIndex - (sint32)_GroupEdit->getPrompt().length());
+ _GroupEdit->setCursorPos(newCharIndex - (sint32)_GroupEdit->getPromptRef().length());
_GroupEdit->setCursorAtPreviousLineEnd(true);
sint32 newPos = _GroupEdit->getCursorPos();
clamp(newPos, (sint32) 0, (sint32) _GroupEdit->getInputStringRef().size());
@@ -417,7 +417,7 @@ class CAHEditPreviousLine : public CAHEdit
{
_GroupEdit->setCursorPos(newCharIndex + 1);
}
- _GroupEdit->setCursorPos(_GroupEdit->getCursorPos()-(sint32)_GroupEdit->getPrompt().length());
+ _GroupEdit->setCursorPos(_GroupEdit->getCursorPos()-(sint32)_GroupEdit->getPromptRef().length());
sint32 newpos = _GroupEdit->getCursorPos();
clamp(newpos, (sint32) 0, (sint32)_GroupEdit->getInputStringRef().size());
_GroupEdit->setCursorPos(newpos);
@@ -452,7 +452,7 @@ class CAHEditNextLine : public CAHEdit
{
float cx, cy;
float height;
- _GroupEdit->getViewText()->getCharacterPositionFromIndex(_GroupEdit->getCursorPos() + (sint)_GroupEdit->getPrompt().length(), _GroupEdit->isCursorAtPreviousLineEnd(), cx, cy, height);
+ _GroupEdit->getViewText()->getCharacterPositionFromIndex(_GroupEdit->getCursorPos() + (sint)_GroupEdit->getPromptRef().length(), _GroupEdit->isCursorAtPreviousLineEnd(), cx, cy, height);
if (cy != 0)
{
cy -= height;
@@ -461,7 +461,7 @@ class CAHEditNextLine : public CAHEdit
_GroupEdit->getViewText()->getCharacterIndexFromPosition(cx, cy, newCharIndex, newLineEnd);
if (newLineEnd)
{
- _GroupEdit->setCursorPos(newCharIndex - (sint32)_GroupEdit->getPrompt().length());
+ _GroupEdit->setCursorPos(newCharIndex - (sint32)_GroupEdit->getPromptRef().length());
_GroupEdit->setCursorAtPreviousLineEnd(true);
sint32 newPos = _GroupEdit->getCursorPos();
clamp(newPos, (sint32) 0, (sint32) _GroupEdit->getInputStringRef().size());
@@ -480,9 +480,9 @@ class CAHEditNextLine : public CAHEdit
}
else
{
- _GroupEdit->setCursorPos(min(sint32(newCharIndex + 1), sint32(_GroupEdit->getInputStringRef().length() + _GroupEdit->getPrompt().length())));
+ _GroupEdit->setCursorPos(min(sint32(newCharIndex + 1), sint32(_GroupEdit->getInputStringRef().length() + _GroupEdit->getPromptRef().length())));
}
- _GroupEdit->setCursorPos(_GroupEdit->getCursorPos()-(sint32)_GroupEdit->getPrompt().length());
+ _GroupEdit->setCursorPos(_GroupEdit->getCursorPos()-(sint32)_GroupEdit->getPromptRef().length());
sint32 newPos = _GroupEdit->getCursorPos();
clamp(newPos, (sint32) 0, (sint32) _GroupEdit->getInputStringRef().size());
_GroupEdit->setCursorPos(newPos);
diff --git a/ryzom/client/src/interface_v3/chat_window.cpp b/ryzom/client/src/interface_v3/chat_window.cpp
index ed1a220ca..72a877cb7 100644
--- a/ryzom/client/src/interface_v3/chat_window.cpp
+++ b/ryzom/client/src/interface_v3/chat_window.cpp
@@ -262,7 +262,7 @@ void CChatWindow::setPrompt(const ucstring &prompt)
if (!_Chat) return;
CGroupEditBox *eb = dynamic_cast(_Chat->getGroup("eb"));
if (!eb) return;
- eb->setPrompt(prompt);
+ eb->setPrompt(prompt.toUtf8());
}
void CChatWindow::setPromptColor(NLMISC::CRGBA col)
From 9021ce465f09577ea5a4acf3ce0a8254aff159fa Mon Sep 17 00:00:00 2001
From: kaetemi
Date: Wed, 28 Oct 2020 11:24:30 +0800
Subject: [PATCH 056/205] Change CViewText to UTF-8, ryzom/ryzomcore#335
---
nel/include/nel/3d/computed_string.h | 1 +
nel/include/nel/3d/u_text_context.h | 7 +-
nel/include/nel/gui/dbview_quantity.h | 2 +-
nel/include/nel/gui/group_html.h | 2 +-
nel/include/nel/gui/view_text.h | 49 +++++++------
nel/include/nel/misc/utf_string_view.h | 18 ++++-
nel/src/3d/font_manager.cpp | 2 +
nel/src/3d/text_context_user.cpp | 8 +--
nel/src/gui/ctrl_text_button.cpp | 18 ++---
nel/src/gui/dbgroup_combo_box.cpp | 10 +--
nel/src/gui/dbview_number.cpp | 10 +--
nel/src/gui/dbview_quantity.cpp | 8 +--
nel/src/gui/group_container.cpp | 8 +--
nel/src/gui/group_editbox.cpp | 12 ++--
nel/src/gui/group_html.cpp | 12 ++--
nel/src/gui/group_list.cpp | 4 +-
nel/src/gui/group_menu.cpp | 10 +--
nel/src/gui/group_paragraph.cpp | 6 +-
nel/src/gui/group_tree.cpp | 2 +-
nel/src/gui/view_pointer.cpp | 4 +-
nel/src/gui/view_text_formated.cpp | 2 +-
nel/src/gui/view_text_id.cpp | 4 +-
nel/src/gui/view_text_id_formated.cpp | 2 +-
nel/src/gui/widget_manager.cpp | 2 +-
nel/src/misc/diff_tool.cpp | 29 ++++----
nel/src/misc/utf_string_view.cpp | 71 ++++++++++++-------
ryzom/client/src/connection.cpp | 32 ++++-----
ryzom/client/src/entity_cl.cpp | 2 +-
ryzom/client/src/game_context_menu.cpp | 18 ++---
.../src/interface_v3/action_handler_game.cpp | 2 +-
.../src/interface_v3/action_handler_help.cpp | 8 +--
.../src/interface_v3/action_phrase_faber.cpp | 6 +-
.../src/interface_v3/bot_chat_page_trade.cpp | 10 +--
.../src/interface_v3/chat_text_manager.cpp | 8 +--
.../client/src/interface_v3/dbctrl_sheet.cpp | 2 +-
.../src/interface_v3/dbgroup_build_phrase.cpp | 8 +--
.../dbgroup_list_sheet_icon_phrase.cpp | 2 +-
.../interface_v3/dbgroup_list_sheet_text.cpp | 2 +-
.../interface_v3/dbgroup_list_sheet_text.h | 2 +-
...roup_list_sheet_text_brick_composition.cpp | 6 +-
.../dbgroup_list_sheet_text_phrase.cpp | 4 +-
.../dbgroup_list_sheet_text_phrase_id.cpp | 2 +-
.../interface_v3/dbgroup_list_sheet_trade.cpp | 2 +-
.../src/interface_v3/encyclopedia_manager.cpp | 16 ++---
.../src/interface_v3/flying_text_manager.cpp | 2 +-
.../client/src/interface_v3/group_compas.cpp | 2 +-
.../interface_v3/group_in_scene_bubble.cpp | 16 ++---
.../interface_v3/group_in_scene_user_info.cpp | 12 ++--
ryzom/client/src/interface_v3/group_map.cpp | 10 +--
.../src/interface_v3/group_modal_get_key.cpp | 6 +-
.../client/src/interface_v3/group_skills.cpp | 2 +-
.../client/src/interface_v3/guild_manager.cpp | 16 ++---
.../client/src/interface_v3/interface_ddx.cpp | 4 +-
.../src/interface_v3/interface_manager.cpp | 10 +--
.../client/src/interface_v3/lua_ihm_ryzom.cpp | 2 +-
.../client/src/interface_v3/macrocmd_key.cpp | 32 ++++-----
.../src/interface_v3/macrocmd_manager.cpp | 10 +--
.../client/src/interface_v3/music_player.cpp | 4 +-
.../src/interface_v3/people_interraction.cpp | 2 +-
.../src/interface_v3/task_bar_manager.cpp | 4 +-
ryzom/client/src/login.cpp | 18 ++---
ryzom/client/src/net_manager.cpp | 2 +-
ryzom/client/src/player_cl.cpp | 2 +-
ryzom/client/src/r2/editor.cpp | 10 +--
ryzom/client/src/session_browser_impl.cpp | 2 +-
65 files changed, 323 insertions(+), 280 deletions(-)
diff --git a/nel/include/nel/3d/computed_string.h b/nel/include/nel/3d/computed_string.h
index c4404f661..35bfb692c 100644
--- a/nel/include/nel/3d/computed_string.h
+++ b/nel/include/nel/3d/computed_string.h
@@ -182,6 +182,7 @@ public:
CMaterial *Material;
CRGBA Color;
std::string Text;
+ size_t Length;
uint32 CacheVersion;
diff --git a/nel/include/nel/3d/u_text_context.h b/nel/include/nel/3d/u_text_context.h
index 9cf710b11..c5d31b886 100644
--- a/nel/include/nel/3d/u_text_context.h
+++ b/nel/include/nel/3d/u_text_context.h
@@ -104,8 +104,11 @@ public:
*/
float StringLine;
- CStringInfo() {StringWidth= StringHeight= StringLine= 0;}
- CStringInfo(float w, float h, float l) {StringWidth= w; StringHeight= h; StringLine = l;}
+ /// The length in characters
+ size_t StringLength;
+
+ CStringInfo() { StringWidth = StringHeight = StringLine = 0; StringLength = 0; }
+ CStringInfo(float w, float h, float l, size_t len) { StringWidth = w; StringHeight = h; StringLine = l; StringLength = len; }
/**
* Get the string's origin
diff --git a/nel/include/nel/gui/dbview_quantity.h b/nel/include/nel/gui/dbview_quantity.h
index 16a11f5a0..c23b394ab 100644
--- a/nel/include/nel/gui/dbview_quantity.h
+++ b/nel/include/nel/gui/dbview_quantity.h
@@ -57,7 +57,7 @@ namespace NLGUI
CInterfaceProperty _NumberMax;
sint32 _Cache;
sint32 _CacheMax;
- ucstring _EmptyText;
+ std::string _EmptyText;
void buildTextFromCache();
};
diff --git a/nel/include/nel/gui/group_html.h b/nel/include/nel/gui/group_html.h
index 590c43a89..1013a8b10 100644
--- a/nel/include/nel/gui/group_html.h
+++ b/nel/include/nel/gui/group_html.h
@@ -765,7 +765,7 @@ namespace NLGUI
std::string _TextAreaScript;
// Get last char
- ucchar getLastChar() const;
+ u32char getLastChar() const;
// Current link view
class CViewLink *_CurrentViewLink;
diff --git a/nel/include/nel/gui/view_text.h b/nel/include/nel/gui/view_text.h
index 57ab6a096..959c82855 100644
--- a/nel/include/nel/gui/view_text.h
+++ b/nel/include/nel/gui/view_text.h
@@ -84,7 +84,8 @@ namespace NLGUI
/// Set
- void setText (const ucstring &text);
+ void setText(const std::string &text);
+ void setTextAsUtf16 (const ucstring &text);
void setFontName (const std::string &name);
void setFontSize (sint nFontSize, bool coef = true);
void setEmbolden (bool nEmbolden);
@@ -95,7 +96,8 @@ namespace NLGUI
void setShadowColor (const NLMISC::CRGBA &color);
void setShadowOffset (sint x, sint y);
void setLineMaxW (sint nMaxW, bool invalidate=true);
- void setOverflowText(const ucstring &text) { _OverflowText = text; }
+ void setOverflowText(const std::string &text) { _OverflowText = text; }
+ void setOverflowTextAsUtf16(const ucstring &text) { _OverflowText = text.toUtf8(); }
void setMultiLine (bool bMultiLine);
void setMultiLineSpace (sint nMultiLineSpace);
void setMultiLineMaxWOnly (bool state);
@@ -112,8 +114,9 @@ namespace NLGUI
void disableStringSelection();
/// Get
-
- ucstring getText() const { return _Text; }
+ std::string getText() const { return _Text; }
+ ucstring getTextAsUtf16() const;
+ ucstring getHardTextAsUtf16() const;
sint getFontSize() const;
std::string getFontName() const { return _FontName; }
bool getEmbolden() { return _Embolden; }
@@ -124,7 +127,7 @@ namespace NLGUI
NLMISC::CRGBA getShadowColor() { return _ShadowColor; }
void getShadowOffset(sint &x, sint &y) { x = _ShadowX; y = _ShadowY; }
sint getLineMaxW() const { return _LineMaxW; }
- ucstring getOverflowText() const { return _OverflowText; }
+ ucstring getOverflowTextAsUtf16() const { return _OverflowText; }
bool getMultiLine() const { return _MultiLine; }
sint getMultiLineSpace() const { return _MultiLineSpace; }
bool getMultiLineMaxWOnly() const { return _MultiLineMaxWOnly; }
@@ -174,8 +177,9 @@ namespace NLGUI
/// From a line number, get the character at which it ends (not including any '\n' ), or -1 if invalid
void getLineEndIndex(uint line, sint &index, bool &endOfPreviousLine) const;
- std::string getHardText() const { std::string result; _Text.toString (result); return result; }
+ std::string getHardText() const { return _HardText.empty() ? _Text : _HardText; }
void setHardText (const std::string &ht);
+ void setHardTextAsUtf16(const ucstring &ht);
std::string getColorAsString() const;
void setColorAsString(const std::string &ht);
@@ -188,9 +192,11 @@ namespace NLGUI
/** Setup a Text with Format Tags. Text is store without color/format tags, and special array is allocated for Format association
*/
- void setTextFormatTaged(const ucstring &text);
+ void setTextFormatTaged(const std::string &text);
+ void setTextFormatTagedAsUtf16(const ucstring &text);
- void setSingleLineTextFormatTaged(const ucstring &text);
+ void setSingleLineTextFormatTaged(const std::string &text);
+ void setSingleLineTextFormatTagedAsUtf16(const ucstring &text);
// Remove end space
void removeEndSpaces();
@@ -216,10 +222,12 @@ namespace NLGUI
int luaSetLineMaxW(CLuaState &ls);
REFLECT_EXPORT_START(CViewText, CViewBase)
+ REFLECT_STRING("text", getText, setText);
REFLECT_STRING("hardtext", getHardText, setHardText);
- REFLECT_UCSTRING("uc_hardtext", getText, setText);
- REFLECT_UCSTRING("uc_hardtext_format", getText, setTextFormatTaged);
- REFLECT_UCSTRING("uc_hardtext_single_line_format", getText, setSingleLineTextFormatTaged);
+ // REFLECT_UCSTRING("uc_text", getTextAsUtf16, setTextAsUtf16); // Deprecate uc_ functions
+ REFLECT_UCSTRING("uc_hardtext", getHardTextAsUtf16, setHardTextAsUtf16);
+ REFLECT_UCSTRING("uc_hardtext_format", getTextAsUtf16, setTextFormatTagedAsUtf16); // FIXME: Name doesn't make sense
+ REFLECT_UCSTRING("uc_hardtext_single_line_format", getTextAsUtf16, setSingleLineTextFormatTagedAsUtf16); // FIXME: Name doesn't make sense
REFLECT_STRING ("color", getColorAsString, setColorAsString);
REFLECT_RGBA ("color_rgba", getColorRGBA, setColorRGBA);
REFLECT_SINT32 ("alpha", getAlpha, setAlpha);
@@ -228,7 +236,6 @@ namespace NLGUI
REFLECT_LUA_METHOD("setLineMaxW", luaSetLineMaxW);
REFLECT_EXPORT_END
-
virtual void serial(NLMISC::IStream &f);
// Sets the parent element
@@ -236,9 +243,11 @@ namespace NLGUI
void setParentElm( CInterfaceElement *parent ){ _ParentElm = parent; }
protected:
- std::string _HardtextFormat;
/// Text to display.
- ucstring _Text;
+ std::string _HardTextFormat;
+ std::string _HardText;
+ std::string _Text;
+ size_t _TextLength;
/// index of the computed String associated to this text control
uint _Index;
/// info on the computed String associated to this text control
@@ -278,7 +287,7 @@ namespace NLGUI
sint32 _LineMaxW;
/// For single line, true if the text is clamped (ie displayed with "...")
bool _SingleLineTextClamped;
- ucstring _OverflowText;
+ std::string _OverflowText;
/// Multiple lines handling
bool _MultiLine;
@@ -339,7 +348,7 @@ namespace NLGUI
public:
// default ctor
CWord(uint numSpaces = 0) : Index(0), NumSpaces(numSpaces) {}
- ucstring Text;
+ std::string Text;
uint Index; // index of the info for this word
NL3D::UTextContext::CStringInfo Info;
uint NumSpaces; // number of spaces before this word
@@ -347,7 +356,7 @@ namespace NLGUI
CFormatInfo Format;
public:
// build from a string, using the current text context
- void build(const ucstring &text, NL3D::UTextContext &textContext, uint numSpaces= 0);
+ void build(const std::string &text, NL3D::UTextContext &textContext, uint numSpaces= 0);
};
typedef std::vector TWordVect;
@@ -360,7 +369,7 @@ namespace NLGUI
// Clear the line & remove text contexts
void clear(NL3D::UTextContext &textContext);
// Add a new word (and its context) in the line + a number of spaces to append at the end of the line
- void addWord(const ucstring &word, uint numSpaces, const CFormatInfo &wordFormat, float fontWidth, NL3D::UTextContext &textContext);
+ void addWord(const std::string &word, uint numSpaces, const CFormatInfo &wordFormat, float fontWidth, NL3D::UTextContext &textContext);
void addWord(const CWord &word, float fontWidth);
uint getNumWords() const { return (uint)_Words.size(); }
CWord &getWord(uint index) { return _Words[index]; }
@@ -442,7 +451,7 @@ namespace NLGUI
void onInvalidateContent();
// may append a new line, and append a word to the last line (no spaces)
- void flushWordInLine(ucstring &ucCurrentWord, bool &linePushed, const CFormatInfo &wordFormat);
+ void flushWordInLine(std::string &ucCurrentWord, bool &linePushed, const CFormatInfo &wordFormat);
// Clear all the lines and free their datas
void clearLines();
// Update in the case of a multiline text
@@ -456,7 +465,7 @@ namespace NLGUI
void addDontClipWordLine(std::vector &currLine);
// FormatTag build.
- static void buildFormatTagText(const ucstring &text, ucstring &textBuild, std::vector &formatTags, std::vector &tooltips);
+ static void buildFormatTagText(const std::string &text, std::string &textBuild, std::vector &formatTags, std::vector &tooltips);
// FormatTag parsing.
bool isFormatTagChange(uint textIndex, uint ctIndex) const;
void getFormatTagChange(uint textIndex, uint &ctIndex, CFormatInfo &wordFormat) const;
diff --git a/nel/include/nel/misc/utf_string_view.h b/nel/include/nel/misc/utf_string_view.h
index df6bf76c8..61291f421 100644
--- a/nel/include/nel/misc/utf_string_view.h
+++ b/nel/include/nel/misc/utf_string_view.h
@@ -32,6 +32,7 @@ class CUtfStringView
public:
inline CUtfStringView() : m_Str(NULL), m_Size(0), m_Iterator(utf32Iterator) {}
+ inline CUtfStringView(const std::string &utf8Str) : m_Str(utf8Str.c_str()), m_Size(utf8Str.size()), m_Iterator(utf8Iterator) {}
inline CUtfStringView(const char *utf8Str) : m_Str(utf8Str), m_Size(strlen(utf8Str)), m_Iterator(utf8Iterator) {}
inline CUtfStringView(const char *utf8Str, size_t len): m_Str(utf8Str), m_Size(len), m_Iterator(utf8Iterator)
{
@@ -51,8 +52,8 @@ public:
}
#endif
- inline CUtfStringView(const std::string &utf8Str) : m_Str(utf8Str.c_str()), m_Size(utf8Str.size()), m_Iterator(utf8Iterator) {}
inline CUtfStringView(const ucstring &utf16Str) : m_Str(utf16Str.c_str()), m_Size(utf16Str.size() << 1), m_Iterator(utf16Iterator) {}
+ inline CUtfStringView(const ucchar *utf16Str) : m_Str(utf16Str), m_Size(strlen((const char *)utf16Str) & (ptrdiff_t)(-2)), m_Iterator(utf16Iterator) {}
inline CUtfStringView(const u32string &utf32Str) : m_Str(utf32Str.c_str()), m_Size(utf32Str.size() << 2), m_Iterator(utf32Iterator) {}
std::string toUtf8(bool reEncode = false) const; // Makes a copy
@@ -96,9 +97,18 @@ public:
this->~const_iterator();
return *new(this) const_iterator(other);
}
+
+ const void *ptr() const { return m_Addr; }
private:
friend class CUtfStringView;
- inline const_iterator(const CUtfStringView &view, const void *addr) : m_View(view), m_Addr(addr), m_Char(addr ? view.m_Iterator(&m_Addr) : 0) { }
+ inline const_iterator(const CUtfStringView &view, const void *addr) : m_View(view), m_Addr(addr), m_Char(addr ? view.m_Iterator(&m_Addr) : 0)
+ {
+ if ((ptrdiff_t)m_Addr > ((ptrdiff_t)m_View.m_Str + m_View.m_Size))
+ {
+ m_Addr = 0;
+ m_Char = 0;
+ }
+ }
const CUtfStringView &m_View;
const void *m_Addr; // Next address
u32char m_Char;
@@ -116,6 +126,8 @@ public:
inline bool empty() const { return !m_Size; }
const void *ptr() const { return m_Str; }
+ size_t count() const; // Slow count of UTF-32 characters
+
inline CUtfStringView substr(const iterator &begin, const iterator &end) const
{
return CUtfStringView(begin.m_Addr, (ptrdiff_t)end.m_Addr - (ptrdiff_t)begin.m_Addr, m_Iterator);
@@ -130,6 +142,8 @@ public:
return *new(this) CUtfStringView(other);
}
+ static void append(std::string &str, u32char c);
+
private:
typedef u32char (*TIterator)(const void **addr);
static u32char utf8Iterator(const void **addr);
diff --git a/nel/src/3d/font_manager.cpp b/nel/src/3d/font_manager.cpp
index 70fb59639..4a8162f51 100644
--- a/nel/src/3d/font_manager.cpp
+++ b/nel/src/3d/font_manager.cpp
@@ -211,6 +211,7 @@ void CFontManager::computeString (NLMISC::CUtfStringView sv,
}
}
output.Vertices.setNumVertices (j);
+ output.Length = j >> 2;
// compile string info
output.StringWidth = (float)penx;
@@ -314,6 +315,7 @@ void CFontManager::computeStringInfo ( NLMISC::CUtfStringView sv,
penx += pLI->AdvX;
}
}
+ output.Length = idx;
// compile string info
output.StringWidth = (float)penx;
diff --git a/nel/src/3d/text_context_user.cpp b/nel/src/3d/text_context_user.cpp
index 95d9ebe1c..447122293 100644
--- a/nel/src/3d/text_context_user.cpp
+++ b/nel/src/3d/text_context_user.cpp
@@ -275,23 +275,23 @@ UTextContext::CStringInfo CTextContextUser::getStringInfo(uint32 i)
CComputedString *cstr= _TextContext.getComputedString(i);
if(!cstr)
- return CStringInfo(0, 0, 0);
+ return CStringInfo(0, 0, 0, 0);
else
- return CStringInfo(cstr->StringWidth, cstr->StringHeight, cstr->StringLine);
+ return CStringInfo(cstr->StringWidth, cstr->StringHeight, cstr->StringLine, cstr->Length);
}
UTextContext::CStringInfo CTextContextUser::getStringInfo(NLMISC::CUtfStringView sv)
{
H_AUTO2;
_TextContext.computeStringInfo(sv, _CacheString);
- return CStringInfo (_CacheString.StringWidth, _CacheString.StringHeight, _CacheString.StringLine);
+ return CStringInfo (_CacheString.StringWidth, _CacheString.StringHeight, _CacheString.StringLine, _CacheString.Length);
}
UTextContext::CStringInfo CTextContextUser::getStringInfo(NLMISC::CUtfStringView sv, size_t len)
{
H_AUTO2;
_TextContext.computeStringInfo(sv, _CacheString, len);
- return CStringInfo (_CacheString.StringWidth, _CacheString.StringHeight, _CacheString.StringLine);
+ return CStringInfo (_CacheString.StringWidth, _CacheString.StringHeight, _CacheString.StringLine, _CacheString.Length);
}
void CTextContextUser::clear()
{
diff --git a/nel/src/gui/ctrl_text_button.cpp b/nel/src/gui/ctrl_text_button.cpp
index 942dd11f8..1bd32be27 100644
--- a/nel/src/gui/ctrl_text_button.cpp
+++ b/nel/src/gui/ctrl_text_button.cpp
@@ -136,7 +136,7 @@ namespace NLGUI
if( name == "hardtext" )
{
if( _ViewText != NULL )
- return _ViewText->getText().toString();
+ return _ViewText->getText();
else
return std::string( "" );
}
@@ -316,7 +316,7 @@ namespace NLGUI
if( name == "hardtext" )
{
if( _ViewText != NULL )
- _ViewText->setText( value );
+ _ViewText->setHardText( value );
return;
}
else
@@ -487,7 +487,7 @@ namespace NLGUI
xmlNewProp( node, BAD_CAST "wmargin", BAD_CAST toString( _WMargin ).c_str() );
xmlNewProp( node, BAD_CAST "wmin", BAD_CAST toString( _WMin ).c_str() );
xmlNewProp( node, BAD_CAST "hmin", BAD_CAST toString( _HMin ).c_str() );
- xmlNewProp( node, BAD_CAST "hardtext", BAD_CAST _ViewText->getText().toString().c_str() );
+ xmlNewProp( node, BAD_CAST "hardtext", BAD_CAST _ViewText->getText().c_str() );
xmlNewProp( node, BAD_CAST "text_y", BAD_CAST toString( _TextY ).c_str() );
xmlNewProp( node, BAD_CAST "text_x", BAD_CAST toString( _TextX ).c_str() );
xmlNewProp( node, BAD_CAST "text_underlined", BAD_CAST toString( _ViewText->getUnderlined() ).c_str() );
@@ -596,11 +596,11 @@ namespace NLGUI
if (prop)
{
const char *propPtr = prop;
- ucstring text;
+ std::string text;
if (NLMISC::startsWith(propPtr, "ui"))
- text = CI18N::get(propPtr);
+ text = CI18N::get(propPtr).toUtf8();
else
- text.fromUtf8(propPtr);
+ text = propPtr;
_ViewText->setText(text);
}
}
@@ -990,7 +990,7 @@ namespace NLGUI
nlassert( v != NULL );
_ViewText = dynamic_cast< CViewText* >( v );
_ViewText->setId( _Id + "_text" );
- _ViewText->setText( ucstring( "text" ) );
+ _ViewText->setText( "text" );
_ViewText->setSerializable( false );
}
@@ -1044,14 +1044,14 @@ namespace NLGUI
void CCtrlTextButton::setText (const ucstring &text)
{
if (_ViewText && !_IsViewTextId)
- _ViewText->setText(text);
+ _ViewText->setText(text.toUtf8());
}
// ***************************************************************************
ucstring CCtrlTextButton::getText () const
{
if (_ViewText && !_IsViewTextId)
- return _ViewText->getText();
+ return CUtfStringView(_ViewText->getText()).toUtf16();
return ucstring("");
}
diff --git a/nel/src/gui/dbgroup_combo_box.cpp b/nel/src/gui/dbgroup_combo_box.cpp
index 59a8b03c8..f7c49fee8 100644
--- a/nel/src/gui/dbgroup_combo_box.cpp
+++ b/nel/src/gui/dbgroup_combo_box.cpp
@@ -236,15 +236,15 @@ namespace NLGUI
// change selected text
if(_CacheSelection<0 || _CacheSelection>=(sint32)_Texts.size() )
{
- _ViewText->setText(ucstring());
+ _ViewText->setText(std::string());
}
else if(_IsExternViewText)
{
- _ViewText->setText(_ExternViewText);
+ _ViewText->setText(_ExternViewText.toUtf8());
}
else
{
- _ViewText->setText(_Texts[_CacheSelection].second);
+ _ViewText->setText(_Texts[_CacheSelection].second.toUtf8());
}
}
}
@@ -468,13 +468,13 @@ namespace NLGUI
{
_IsExternViewText = true;
_ExternViewText = text;
- _ViewText->setText(_ExternViewText);
+ _ViewText->setText(_ExternViewText.toUtf8());
}
// ***************************************************************************
ucstring CDBGroupComboBox::getViewText() const
{
- return _ViewText->getText();
+ return CUtfStringView(_ViewText->getText()).toUtf16();
}
// ***************************************************************************
diff --git a/nel/src/gui/dbview_number.cpp b/nel/src/gui/dbview_number.cpp
index af768140c..7ba4c17ba 100644
--- a/nel/src/gui/dbview_number.cpp
+++ b/nel/src/gui/dbview_number.cpp
@@ -43,7 +43,7 @@ namespace NLGUI
{
_Positive = false;
_Cache= 0;
- setText(ucstring("0"));
+ setText(std::string("0"));
_Divisor = 1;
_Modulo = 0;
}
@@ -225,7 +225,7 @@ namespace NLGUI
// init cache.
_Cache= 0;
- setText(ucstring("0"));
+ setText(std::string("0"));
return true;
}
@@ -238,9 +238,9 @@ namespace NLGUI
if (_Cache != val)
{
_Cache= val;
- ucstring value = _Format ? NLMISC::formatThousands(toString(val)) : toString(val);
- if (_Positive) setText(val >= 0 ? ( ucstring(_Prefix) + value + ucstring(_Suffix) ) : ucstring("?"));
- else setText( ucstring(_Prefix) + value + ucstring(_Suffix) );
+ std::string value = _Format ? NLMISC::formatThousands(toString(val)) : toString(val);
+ if (_Positive) setText(val >= 0 ? ( _Prefix.toString() + value + _Suffix.toString() ) : "?");
+ else setText( _Prefix.toString() + value + _Suffix.toString() );
}
}
diff --git a/nel/src/gui/dbview_quantity.cpp b/nel/src/gui/dbview_quantity.cpp
index 0b01f14f0..0f90d598e 100644
--- a/nel/src/gui/dbview_quantity.cpp
+++ b/nel/src/gui/dbview_quantity.cpp
@@ -63,7 +63,7 @@ namespace NLGUI
else
if( name == "emptytext" )
{
- return _EmptyText.toString();
+ return _EmptyText;
}
else
return CViewText::getProperty( name );
@@ -112,7 +112,7 @@ namespace NLGUI
else
xmlSetProp( node, BAD_CAST "valuemax", BAD_CAST "" );
- xmlSetProp( node, BAD_CAST "emptytext", BAD_CAST _EmptyText.toString().c_str() );
+ xmlSetProp( node, BAD_CAST "emptytext", BAD_CAST _EmptyText.c_str() );
return node;
}
@@ -148,9 +148,9 @@ namespace NLGUI
{
const char *propPtr = ptr;
if (NLMISC::startsWith(propPtr, "ui"))
- _EmptyText = CI18N::get(propPtr);
+ _EmptyText = CI18N::get(propPtr).toUtf8();
else
- _EmptyText.fromUtf8(propPtr);
+ _EmptyText = propPtr;
}
// init cache.
diff --git a/nel/src/gui/group_container.cpp b/nel/src/gui/group_container.cpp
index 87fb59c38..7bab62820 100644
--- a/nel/src/gui/group_container.cpp
+++ b/nel/src/gui/group_container.cpp
@@ -3744,7 +3744,7 @@ namespace NLGUI
_TitleOpened->setY (pLayer->getValSInt32 ("title_offset_y"));
}
_TitleOpened->setFontSize (pLayer->getValSInt32 ("title_font_size"));
- if (_TitleClass==TitleText) _TitleOpened->setText (_TitleTextOpened);
+ if (_TitleClass==TitleText) _TitleOpened->setText (_TitleTextOpened.toUtf8());
_TitleOpened->setActive (_Opened);
// Title when the container is closed
@@ -3796,7 +3796,7 @@ namespace NLGUI
_TitleClosed->setY (pLayer->getValSInt32 ("title_offset_y"));
}
_TitleClosed->setFontSize (pLayer->getValSInt32 ("title_font_size"));
- if (_TitleClass==TitleText) _TitleClosed->setText (_TitleTextClosed);
+ if (_TitleClass==TitleText) _TitleClosed->setText (_TitleTextClosed.toUtf8());
_TitleClosed->setActive(!_Opened);
@@ -3990,7 +3990,7 @@ namespace NLGUI
{
_TitleTextOpened = title;
if (_TitleOpened != NULL)
- _TitleOpened->setText (title);
+ _TitleOpened->setText (title.toUtf8());
invalidateCoords();
}
@@ -3999,7 +3999,7 @@ namespace NLGUI
{
_TitleTextClosed = title;
if (_TitleClosed != NULL)
- _TitleClosed->setText (_TitleTextClosed);
+ _TitleClosed->setText (_TitleTextClosed.toUtf8());
invalidateCoords();
}
diff --git a/nel/src/gui/group_editbox.cpp b/nel/src/gui/group_editbox.cpp
index 1453ba5fe..768c69066 100644
--- a/nel/src/gui/group_editbox.cpp
+++ b/nel/src/gui/group_editbox.cpp
@@ -96,7 +96,7 @@ namespace NLGUI
_ViewTextDeltaX(0)
{
- _Prompt = u32string(1, '>');
+ _Prompt = u32string(1, (u32char)'>');
_BackSelectColor= CRGBA::White;
_TextSelectColor= CRGBA::Black;
}
@@ -1433,16 +1433,14 @@ namespace NLGUI
{
if (_ViewText)
{
- ucstring usTmp;
+ std::string usTmp;
if (_EntryType == Password)
{
- usTmp = CUtfStringView(_Prompt).toUtf16();
- for (uint32 i = 0; i < _InputString.size(); ++i)
- usTmp += "*";
+ usTmp = CUtfStringView(_Prompt + u32string(_InputString.size(), 0x2022)).toUtf8();
}
else
{
- usTmp = CUtfStringView(_Prompt + _InputString).toUtf16();
+ usTmp = CUtfStringView(_Prompt + _InputString).toUtf8();
}
_ViewText->setText (usTmp);
}
@@ -1585,7 +1583,7 @@ namespace NLGUI
addView( _ViewText );
sint32 w,h;
- w = std::max( sint32( _ViewText->getFontWidth() * _ViewText->getText().size() ), getW() );
+ w = std::max( sint32( _ViewText->getFontWidth() * CUtfStringView(_ViewText->getText()).count() ), getW() );
h = std::max( sint32( _ViewText->getFontHeight() ), getH() );
setH( h );
diff --git a/nel/src/gui/group_html.cpp b/nel/src/gui/group_html.cpp
index 4fab8c4bb..7d9e48baf 100644
--- a/nel/src/gui/group_html.cpp
+++ b/nel/src/gui/group_html.cpp
@@ -2830,7 +2830,7 @@ namespace NLGUI
// Number of child in this paragraph
if (_CurrentViewLink)
{
- bool skipLine = !_CurrentViewLink->getText().empty() && *(_CurrentViewLink->getText().rbegin()) == (ucchar) '\n';
+ bool skipLine = !_CurrentViewLink->getText().empty() && *(_CurrentViewLink->getText().rbegin()) == '\n';
bool sameShadow = style.TextShadow.Enabled && _CurrentViewLink->getShadow();
if (sameShadow && style.TextShadow.Enabled)
{
@@ -2853,7 +2853,7 @@ namespace NLGUI
(style.GlobalColor == _CurrentViewLink->getModulateGlobalColor()))
{
// Concat the text
- _CurrentViewLink->setText(_CurrentViewLink->getText()+tmpStr);
+ _CurrentViewLink->setText(_CurrentViewLink->getText()+tmpStr.toUtf8());
_CurrentViewLink->invalidateContent();
added = true;
}
@@ -2916,7 +2916,7 @@ namespace NLGUI
newLink->setParamsOnLeftClick("name=" + getId() + "|url=" + newLink->Link);
}
}
- newLink->setText(tmpStr);
+ newLink->setText(tmpStr.toUtf8());
newLink->setMultiLineSpace((uint)((float)(style.FontSize)*LineSpaceFontFactor));
newLink->setMultiLine(true);
newLink->setModulateGlobalColor(style.GlobalColor);
@@ -3306,11 +3306,11 @@ namespace NLGUI
// ***************************************************************************
- ucchar CGroupHTML::getLastChar() const
+ u32char CGroupHTML::getLastChar() const
{
if (_CurrentViewLink)
{
- const ucstring &str = _CurrentViewLink->getText();
+ u32string str = CUtfStringView(_CurrentViewLink->getText()).toUtf32(); // FIXME: Optimize reverse UTF iteration
if (!str.empty())
return str[str.length()-1];
}
@@ -3710,7 +3710,7 @@ namespace NLGUI
CGroupEditBox *editBox = dynamic_cast(group);
if (editBox)
{
- entryData = editBox->getViewText()->getText();
+ entryData = CUtfStringView(editBox->getViewText()->getText()).toUtf16();
addEntry = true;
}
}
diff --git a/nel/src/gui/group_list.cpp b/nel/src/gui/group_list.cpp
index d619a8146..4e04501a8 100644
--- a/nel/src/gui/group_list.cpp
+++ b/nel/src/gui/group_list.cpp
@@ -548,7 +548,7 @@ namespace NLGUI
view->setMultiLine (multiLine);
view->setTextMode(_Templ.getTextMode());
if (multiLine) view->setMultiLineSpace (_Space);
- view->setText (line);
+ view->setText (line.toUtf8());
// Herit global-coloring
view->setModulateGlobalColor(getModulateGlobalColor());
addChild(view);
@@ -566,7 +566,7 @@ namespace NLGUI
view->_Parent = this;
view->setMultiLine (multiLine);
if (multiLine) view->setMultiLineSpace (_Space);
- view->setText (line);
+ view->setText (line.toUtf8());
view->setColor (textColor);
// Herit global-coloring
view->setModulateGlobalColor(getModulateGlobalColor());
diff --git a/nel/src/gui/group_menu.cpp b/nel/src/gui/group_menu.cpp
index 830b74fb9..109baf278 100644
--- a/nel/src/gui/group_menu.cpp
+++ b/nel/src/gui/group_menu.cpp
@@ -1231,11 +1231,11 @@ namespace NLGUI
{
pV->setMultiLine (true);
pV->setMultiLineMaxWOnly (true);
- pV->setTextFormatTaged (name);
+ pV->setTextFormatTaged (name.toUtf8());
}
else
{
- pV->setText (name);
+ pV->setText (name.toUtf8());
}
pV->setColor (_GroupMenu->_Color);
pV->setFontSize (_GroupMenu->_FontSize, _GroupMenu->_FontSizeCoef);
@@ -1319,11 +1319,11 @@ namespace NLGUI
{
pV->setMultiLine (true);
pV->setMultiLineMaxWOnly (true);
- pV->setTextFormatTaged (name);
+ pV->setTextFormatTaged (name.toUtf8());
}
else
{
- pV->setText (name);
+ pV->setText (name.toUtf8());
}
pV->setColor (_GroupMenu->_Color);
@@ -1602,7 +1602,7 @@ namespace NLGUI
texture = _Lines[k].ViewText->getCheckBox()->getTexture();
}
CViewTextMenu *pV = NULL;
- pV = copyMenu->addLine (_Lines[k].ViewText->getText(), _Lines[k].AHName, _Lines[k].AHParams, _Lines[k].Id, _Lines[k].Cond,
+ pV = copyMenu->addLine (CUtfStringView(_Lines[k].ViewText->getText()).toUtf16(), _Lines[k].AHName, _Lines[k].AHParams, _Lines[k].Id, _Lines[k].Cond,
texture, _Lines[k].ViewText->getCheckable(), _Lines[k].ViewText->getChecked(), _Lines[k].ViewText->getFormatted ());
copyMenu->_Lines[k].Selectable = _Lines[k].Selectable;
pV->setGrayed(_Lines[k].ViewText->getGrayed());
diff --git a/nel/src/gui/group_paragraph.cpp b/nel/src/gui/group_paragraph.cpp
index f772309a6..f2027a404 100644
--- a/nel/src/gui/group_paragraph.cpp
+++ b/nel/src/gui/group_paragraph.cpp
@@ -503,7 +503,7 @@ namespace NLGUI
view->setMultiLine (multiLine);
view->setTextMode(_Templ.getTextMode());
if (multiLine) view->setMultiLineSpace (_Space);
- view->setText (line);
+ view->setText (line.toUtf8());
// Herit global-coloring
view->setModulateGlobalColor(getModulateGlobalColor());
addChild (view);
@@ -520,7 +520,7 @@ namespace NLGUI
view->_Parent = this;
view->setMultiLine (multiLine);
if (multiLine) view->setMultiLineSpace (_Space);
- view->setText (line);
+ view->setText (line.toUtf8());
view->setColor (textColor);
// Herit global-coloring
view->setModulateGlobalColor(getModulateGlobalColor());
@@ -730,7 +730,7 @@ namespace NLGUI
if (viewText)
{
changeLine = viewText->getNumLine() > 1;
- if (!viewText->getText().empty() && *(viewText->getText().rbegin()) == (ucchar) '\n')
+ if (!viewText->getText().empty() && *(viewText->getText().rbegin()) == '\n')
{
changeLine = true;
}
diff --git a/nel/src/gui/group_tree.cpp b/nel/src/gui/group_tree.cpp
index 9fad363f0..93e9880bb 100644
--- a/nel/src/gui/group_tree.cpp
+++ b/nel/src/gui/group_tree.cpp
@@ -1292,7 +1292,7 @@ namespace NLGUI
CViewText *pVT = new CViewText(TCtorParam());
line.TextOrTemplate = pVT;
pVT->setId("t"+toString(_Lines.size()));
- pVT->setText(pNode->Text);
+ pVT->setText(pNode->Text.toUtf8());
pVT->setColor(pNode->Color);
if(pNode->FontSize==-1)
pVT->setFontSize(_FontSize);
diff --git a/nel/src/gui/view_pointer.cpp b/nel/src/gui/view_pointer.cpp
index 82c0174f5..973708aa6 100644
--- a/nel/src/gui/view_pointer.cpp
+++ b/nel/src/gui/view_pointer.cpp
@@ -458,14 +458,14 @@ namespace NLGUI
{
CViewText *text = dynamic_cast (element);
if (text)
- text->setText(str);
+ text->setText(str.toUtf8());
}
element = target->getView ("real_txt");
if (element)
{
CViewText *text = dynamic_cast (element);
if (text)
- text->setText(str);
+ text->setText(str.toUtf8());
}
target->updateCoords();
target->updateCoords();
diff --git a/nel/src/gui/view_text_formated.cpp b/nel/src/gui/view_text_formated.cpp
index aa948e986..87cfc12bb 100644
--- a/nel/src/gui/view_text_formated.cpp
+++ b/nel/src/gui/view_text_formated.cpp
@@ -87,7 +87,7 @@ namespace NLGUI
formatedResult = formatString(_FormatString, ucstring(""));
//
- setText (formatedResult);
+ setText (formatedResult.toUtf8());
CViewText::checkCoords();
}
diff --git a/nel/src/gui/view_text_id.cpp b/nel/src/gui/view_text_id.cpp
index 562ba881a..065d02e71 100644
--- a/nel/src/gui/view_text_id.cpp
+++ b/nel/src/gui/view_text_id.cpp
@@ -233,9 +233,9 @@ namespace NLGUI
// Set the Text
if(_IsTextFormatTaged)
- setTextFormatTaged(result);
+ setTextFormatTaged(result.toUtf8());
else
- setText (result);
+ setText (result.toUtf8());
}
CViewText::checkCoords();
}
diff --git a/nel/src/gui/view_text_id_formated.cpp b/nel/src/gui/view_text_id_formated.cpp
index 5304e9e5c..5b1dd2a14 100644
--- a/nel/src/gui/view_text_id_formated.cpp
+++ b/nel/src/gui/view_text_id_formated.cpp
@@ -106,7 +106,7 @@ namespace NLGUI
}
formatedResult = CViewTextFormated::formatString(_FormatString, result);
//
- setText (formatedResult);
+ setText (formatedResult.toUtf8());
//
if (bValid)
{
diff --git a/nel/src/gui/widget_manager.cpp b/nel/src/gui/widget_manager.cpp
index 864e4ef5b..2da9f9bdf 100644
--- a/nel/src/gui/widget_manager.cpp
+++ b/nel/src/gui/widget_manager.cpp
@@ -1516,7 +1516,7 @@ namespace NLGUI
CViewText *pTxt = (CViewText*)groupContextHelp->getView("text");
if (pTxt != NULL)
{
- pTxt->setTextFormatTaged(_ContextHelpText);
+ pTxt->setTextFormatTaged(_ContextHelpText.toUtf8());
// update only to get correct W/H
groupContextHelp->updateCoords ();
diff --git a/nel/src/misc/diff_tool.cpp b/nel/src/misc/diff_tool.cpp
index 2b2a490bc..3cbaea5a6 100644
--- a/nel/src/misc/diff_tool.cpp
+++ b/nel/src/misc/diff_tool.cpp
@@ -232,15 +232,15 @@ bool loadStringFile(const std::string filename, vector &stringInfos
ucstring prepareStringFile(const vector &strings, bool removeDiffComments, bool noDiffInfo)
{
- ucstring diff;
+ string diff;
vector::const_iterator first(strings.begin()), last(strings.end());
for (; first != last; ++first)
{
- ucstring str;
+ string str;
const TStringInfo &si = *first;
- string comment = si.Comments.toString();
- vector lines;
+ string comment = si.Comments.toUtf8();
+ vector lines;
explode(comment, string("\n"), lines, true);
uint i;
@@ -274,30 +274,29 @@ ucstring prepareStringFile(const vector &strings, bool removeDiffCo
}
si.Comments = ucstring(comment);
- str = si.Comments;
+ str = comment;
if (!si.Identifier.empty() || !si.Text.empty())
{
// add hash value comment if needed
// if (si.Comments.find(ucstring("// HASH_VALUE ")) == ucstring::npos)
if (!noDiffInfo)
{
- str += ucstring("// HASH_VALUE ") + CI18N::hashToString(si.HashValue)+ nl;
- str += ucstring("// INDEX ") + NLMISC::toString("%u", first-strings.begin())+ nl;
+ str += "// HASH_VALUE " + CI18N::hashToString(si.HashValue) + "\n";
+ str += "// INDEX " + NLMISC::toString("%u", first-strings.begin()) + "\n";
}
str += si.Identifier + '\t';
- ucstring text = CI18N::makeMarkedString('[', ']', si.Text);;
- ucstring text2;
+ string text = CI18N::makeMarkedString('[', ']', si.Text).toUtf8();
+ string text2;
// add new line and tab after each \n tag
- ucstring::size_type pos;
- const ucstring nlTag("\\n");
- while ((pos = text.find(nlTag)) != ucstring::npos)
+ string::size_type pos;
+ while ((pos = text.find("\\n")) != string::npos)
{
- text2 += text.substr(0, pos+2) + nl + "\t";
+ text2 += text.substr(0, pos+2) + "\n\t";
text = text.substr(pos+2);
}
text2 += text;//.substr(0, pos+2);
- str += text2 + nl + nl;
+ str += text2 + "\n\n";
// str += CI18N::makeMarkedString('[', ']', si.Text) + nl + nl;
}
@@ -305,7 +304,7 @@ ucstring prepareStringFile(const vector &strings, bool removeDiffCo
diff += str;
}
- return diff;
+ return ucstring::makeFromUtf8(diff);
}
diff --git a/nel/src/misc/utf_string_view.cpp b/nel/src/misc/utf_string_view.cpp
index 3be14f515..9f4057b66 100644
--- a/nel/src/misc/utf_string_view.cpp
+++ b/nel/src/misc/utf_string_view.cpp
@@ -29,6 +29,41 @@
namespace NLMISC
{
+NL_FORCE_INLINE void appendUtf8(std::string &str, u32char c)
+{
+ if (c < 0x80)
+ {
+ // Encode as 1 byte
+ str += (char)c;
+ }
+ else if (c < 0x0800)
+ {
+ // Encode as 2 bytes
+ str += (char)((c & 0x07C0) >> 6) | 0xC0;
+ str += (char)(c & 0x3F) | 0x80;
+ }
+ else if (c < 0x010000)
+ {
+ // Encode as 3 bytes
+ str += (char)((c & 0xF000) >> 12) | 0xE0;
+ str += (char)((c & 0x0FC0) >> 6) | 0x80;
+ str += (char)(c & 0x3F) | 0x80;
+ }
+ else
+ {
+ // Encode as 4 bytes
+ str += (char)((c & 0x1C0000) >> 18) | 0xF0;
+ str += (char)((c & 0x03F000) >> 12) | 0x80;
+ str += (char)((c & 0x0FC0) >> 6) | 0x80;
+ str += (char)(c & 0x3F) | 0x80;
+ }
+}
+
+void CUtfStringView::append(std::string &str, u32char c)
+{
+ appendUtf8(str, c);
+}
+
std::string CUtfStringView::toUtf8(bool reEncode) const
{
// Decode UTF and encode UTF-8
@@ -39,33 +74,7 @@ std::string CUtfStringView::toUtf8(bool reEncode) const
res.reserve(m_Size);
for (iterator it(begin()), end(end()); it != end; ++it)
{
- u32char c = *it;
- if (c < 0x80)
- {
- // Encode as 1 byte
- res += (char)c;
- }
- else if (c < 0x0800)
- {
- // Encode as 2 bytes
- res += (char)((c & 0x07C0) >> 6) | 0xC0;
- res += (char)(c & 0x3F) | 0x80;
- }
- else if (c < 0x010000)
- {
- // Encode as 3 bytes
- res += (char)((c & 0xF000) >> 12) | 0xE0;
- res += (char)((c & 0x0FC0) >> 6) | 0x80;
- res += (char)(c & 0x3F) | 0x80;
- }
- else
- {
- // Encode as 4 bytes
- res += (char)((c & 0x1C0000) >> 18) | 0xF0;
- res += (char)((c & 0x03F000) >> 12) | 0x80;
- res += (char)((c & 0x0FC0) >> 6) | 0x80;
- res += (char)(c & 0x3F) | 0x80;
- }
+ appendUtf8(res, *it);
}
return res;
}
@@ -154,6 +163,14 @@ std::wstring CUtfStringView::toWide() const
#endif
}
+size_t CUtfStringView::count() const
+{
+ size_t res = 0;
+ for (iterator it(begin()), end(end()); it != end; ++it)
+ ++res;
+ return res;
+}
+
u32char CUtfStringView::utf8Iterator(const void **addr)
{
// Decode UTF-8
diff --git a/ryzom/client/src/connection.cpp b/ryzom/client/src/connection.cpp
index 00c663e5e..36df595bf 100644
--- a/ryzom/client/src/connection.cpp
+++ b/ryzom/client/src/connection.cpp
@@ -1021,7 +1021,7 @@ TInterfaceState globalMenu()
// Display the firewall alert string
CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:outgame:connecting:title"));
if (pVT != NULL)
- pVT->setText(CI18N::get("uiFirewallAlert")+ucstring("..."));
+ pVT->setText(CI18N::get("uiFirewallAlert").toUtf8() + "...");
// The mouse and fullscreen mode should be unlocked for the user to set the firewall permission
nlSleep( 30 ); // 'nice' the client, and prevent to make too many send attempts
@@ -1237,8 +1237,8 @@ TInterfaceState globalMenu()
if (pVT != NULL)
{
pVT->setMultiLine( true );
- pVT->setText(CI18N::get("uiFirewallFail")+ucstring(".\n")+
- CI18N::get("uiFirewallAlert")+ucstring("."));
+ pVT->setText(CI18N::get("uiFirewallFail").toUtf8()+".\n"+
+ CI18N::get("uiFirewallAlert").toUtf8()+".");
}
}
}
@@ -1319,16 +1319,16 @@ public:
if (pVT == NULL) return;
if (rCS.Name.empty())
- pVT->setText(CI18N::get("uiEmptySlot"));
+ pVT->setText(CI18N::get("uiEmptySlot").toUtf8());
else
- pVT->setText(rCS.Name);
+ pVT->setText(rCS.Name.toUtf8());
}
// 5 slots
for (; i < 5; ++i)
{
CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sPath+":text"+NLMISC::toString(i)));
if (pVT == NULL) return;
- pVT->setText(CI18N::get("uiEmptySlot"));
+ pVT->setText(CI18N::get("uiEmptySlot").toUtf8());
}
}
};
@@ -2170,8 +2170,8 @@ public:
CViewText *pVT = dynamic_cast(pNewLine->getView("name"));
if (pVT != NULL)
{
- ucstring ucstr = Mainlands[i].Name + ucstring(" ") + Mainlands[i].Description;
- pVT->setText(ucstr);
+ std::string str = Mainlands[i].Name.toUtf8() + " " + Mainlands[i].Description.toUtf8();
+ pVT->setText(str);
}
// Add to the list
@@ -2311,7 +2311,7 @@ public:
CViewText *pVT = dynamic_cast(pNewLine->getView("name"));
if (pVT != NULL)
{
- pVT->setText(name);
+ pVT->setText(name.toUtf8());
}
CCtrlBase *pBut = pNewLine->getCtrl("but");
@@ -2559,7 +2559,7 @@ static void setTextField(CInterfaceGroup* scenarioWnd, const std::string &uiName
{
CViewText* viewText = dynamic_cast(result);
if(viewText)
- viewText->setText(text);
+ viewText->setText(text.toUtf8());
CGroupEditBox* editBox = dynamic_cast(result);
if(editBox)
editBox->setInputStringAsUtf16(text);
@@ -2682,7 +2682,7 @@ class CAHScenarioControl : public IActionHandler
CViewText* viewText = dynamic_cast(result);
if(viewText)
{
- viewText->setText(R2::getEditor().isInitialized()?CI18N::get("uiR2EDScenarioName"):CI18N::get("uiR2EDScenarioFileName"));
+ viewText->setText(R2::getEditor().isInitialized()?CI18N::get("uiR2EDScenarioName").toUtf8():CI18N::get("uiR2EDScenarioFileName").toUtf8());
}
}
@@ -2712,7 +2712,7 @@ class CAHScenarioControl : public IActionHandler
CViewText* viewText= dynamic_cast(result);
if(viewText)
- viewText->setText(ucstring(""));
+ viewText->setText("");
}
}
setScenarioInformation(scenarioWnd, "");
@@ -2748,7 +2748,7 @@ class CAHScenarioControl : public IActionHandler
CViewText *shardName = dynamic_cast(toggleGr->getView("button_text"));
if (shardName)
{
- shardName->setText(Mainlands[i].Name);
+ shardName->setText(Mainlands[i].Name.toUtf8());
}
}
}
@@ -3250,7 +3250,7 @@ class CAHLoadScenario : public IActionHandler
{
CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text"));
if (pVT != NULL)
- pVT->setText(CI18N::get("uiRingWarningFreeTrial"));
+ pVT->setText(CI18N::get("uiRingWarningFreeTrial").toUtf8());
CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial");
return;
@@ -3331,7 +3331,7 @@ class CAHLoadScenario : public IActionHandler
{
CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text"));
if (pVT != NULL)
- pVT->setText(CI18N::get("uiRingWarningFreeTrial"));
+ pVT->setText(CI18N::get("uiRingWarningFreeTrial").toUtf8());
CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial");
}
@@ -3360,7 +3360,7 @@ class CAHLoadScenario : public IActionHandler
{
CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text"));
if (pVT != NULL)
- pVT->setText(CI18N::get("uiRingWarningInviteFreeTrial"));
+ pVT->setText(CI18N::get("uiRingWarningInviteFreeTrial").toUtf8());
CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial");
}
}
diff --git a/ryzom/client/src/entity_cl.cpp b/ryzom/client/src/entity_cl.cpp
index 10d1573cf..506069426 100644
--- a/ryzom/client/src/entity_cl.cpp
+++ b/ryzom/client/src/entity_cl.cpp
@@ -2353,7 +2353,7 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value)
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:player:header_opened:player_title"));
- if (pVT != NULL) pVT->setText(_Title);
+ if (pVT != NULL) pVT->setText(_Title.toUtf8());
CGroupContainer *pGC = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:player"));
if (pGC != NULL) pGC->setUCTitle(_EntityName);
diff --git a/ryzom/client/src/game_context_menu.cpp b/ryzom/client/src/game_context_menu.cpp
index d4a152392..2b46d33dd 100644
--- a/ryzom/client/src/game_context_menu.cpp
+++ b/ryzom/client/src/game_context_menu.cpp
@@ -718,18 +718,18 @@ void CGameContextMenu::updateContextMenuMissionsOptions( bool forceHide )
{
result = NLMISC::CI18N::get("uiMissionOptionNotReceived");
}
- pVTM->setText(result);
+ pVTM->setText(result.toUtf8());
pVTM->setActive(true);
}
else
{
- pVTM->setText(ucstring(""));
+ pVTM->setText("");
pVTM->setActive(false);
}
}
else
{
- pVTM->setText(ucstring(""));
+ pVTM->setText("");
pVTM->setActive(false);
}
}
@@ -759,16 +759,16 @@ void CGameContextMenu::updateContextMenuWebPage(uint options)
{
result = NLMISC::CI18N::get("uiWebPageNameNotReceived");
}
- pVTM->setText(result);
+ pVTM->setText(result.toUtf8());
}
else
{
- pVTM->setText(ucstring(""));
+ pVTM->setText("");
}
}
else
{
- pVTM->setText(ucstring(""));
+ pVTM->setText("");
}
}
@@ -797,7 +797,7 @@ void CGameContextMenu::updateContextMenuOutpostState(uint options)
{
CViewTextMenu *pVTM = _TextOutpostState;
if (pVTM)
- pVTM->setText(ucstring(STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet)));
+ pVTM->setText(CUtfStringView(STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet)).toUtf8());
}
// apply the active
@@ -839,12 +839,12 @@ void CGameContextMenu::updateContextMenuMissionRing()
{
result = NLMISC::CI18N::get("uiMissionRingNameNotReceived");
}
- pVTM->setText(result);
+ pVTM->setText(result.toUtf8());
pVTM->setActive(true);
}
else
{
- pVTM->setText(ucstring(""));
+ pVTM->setText("");
pVTM->setActive(false);
}
}
diff --git a/ryzom/client/src/interface_v3/action_handler_game.cpp b/ryzom/client/src/interface_v3/action_handler_game.cpp
index bbb392131..19820be99 100644
--- a/ryzom/client/src/interface_v3/action_handler_game.cpp
+++ b/ryzom/client/src/interface_v3/action_handler_game.cpp
@@ -4606,7 +4606,7 @@ public:
CViewText *pVT = dynamic_cast(pIG->getView("t"));
if (!pVT) break;
- names.push_back(toUpper(pVT->getText().toUtf8()));
+ names.push_back(toUpper(pVT->getText()));
}
if (names.size() != nbChilds)
diff --git a/ryzom/client/src/interface_v3/action_handler_help.cpp b/ryzom/client/src/interface_v3/action_handler_help.cpp
index 77f5f5552..030d34bfe 100644
--- a/ryzom/client/src/interface_v3/action_handler_help.cpp
+++ b/ryzom/client/src/interface_v3/action_handler_help.cpp
@@ -1167,7 +1167,7 @@ void setHelpText(CSheetHelpSetup &setup, const ucstring &text)
CViewText *viewText= dynamic_cast(setup.HelpWindow->getView(setup.ViewText));
if(viewText)
{
- viewText->setTextFormatTaged(copyStr);
+ viewText->setTextFormatTaged(copyStr.toUtf8());
}
CInterfaceGroup *viewTextGroup = setup.HelpWindow->getGroup(setup.ScrollTextGroup);
if (viewTextGroup) viewTextGroup->setActive(true);
@@ -3165,7 +3165,7 @@ void setupListBrickHeader(CSheetHelpSetup &setup)
if(view)
{
view->setActive(true);
- view->setTextFormatTaged(CI18N::get("uihelpPhraseHeaderBricks"));
+ view->setTextFormatTaged(CI18N::get("uihelpPhraseHeaderBricks").toUtf8());
}
}
@@ -3806,7 +3806,7 @@ static void onMpChangeItemPart(CInterfaceGroup *wnd, uint32 itemSheetId, const s
string originFilterKey= "iompf" + ITEM_ORIGIN::enumToString((ITEM_ORIGIN::EItemOrigin)itemPart.OriginFilter);
mpCraft+= CI18N::get(originFilterKey);
- viewText->setText(mpCraft);
+ viewText->setText(mpCraft.toUtf8());
}
@@ -3838,7 +3838,7 @@ static void onMpChangeItemPart(CInterfaceGroup *wnd, uint32 itemSheetId, const s
CViewText *statTitle= dynamic_cast(groupStat->getElement(groupStat->getId()+":text" ));
CDBViewBar *statValue= dynamic_cast(groupStat->getElement(groupStat->getId()+":bar" ));
if(statTitle)
- statTitle->setText(RM_FABER_STAT_TYPE::toLocalString(statType));
+ statTitle->setText(RM_FABER_STAT_TYPE::toLocalString(statType).toUtf8());
if(statValue)
statValue->setValue(itemPart.Stats[i]);
}
diff --git a/ryzom/client/src/interface_v3/action_phrase_faber.cpp b/ryzom/client/src/interface_v3/action_phrase_faber.cpp
index 40efedac0..fcef685c5 100644
--- a/ryzom/client/src/interface_v3/action_phrase_faber.cpp
+++ b/ryzom/client/src/interface_v3/action_phrase_faber.cpp
@@ -523,7 +523,7 @@ void CActionPhraseFaber::validateFaberPlanSelection(CSBrickSheet *itemPlanBrick
{
nlstop;
}
- viewText->setText( text );
+ viewText->setText( text.toUtf8() );
}
// Set as Icon the required MP FaberType / or Sheet Texture (directly...)
@@ -1724,7 +1724,7 @@ void CActionPhraseFaber::updateItemResult()
+ "@{FFFF})";
}
strFindReplace(text, "%success", successStr );
- successView->setTextFormatTaged(text);
+ successView->setTextFormatTaged(text.toUtf8());
}
@@ -1790,7 +1790,7 @@ void CActionPhraseFaber::updateItemResult()
uint sv= uint(statArray[i]*100);
if(statTitle)
{
- statTitle->setText(RM_FABER_STAT_TYPE::toLocalString(statType));
+ statTitle->setText(RM_FABER_STAT_TYPE::toLocalString(statType).toUtf8());
statTitle->setColor(usageColor);
}
if(statValueBar)
diff --git a/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp b/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp
index dc2c88789..352ff65f4 100644
--- a/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp
+++ b/ryzom/client/src/interface_v3/bot_chat_page_trade.cpp
@@ -865,7 +865,7 @@ void CBotChatPageTrade::startBuyDialog(CDBCtrlSheet *sheet, CCtrlBase * /* pCall
CViewText *priceLabel = dynamic_cast(ig->getView( "standard_price:total_price_header" ));
if ( _BuyMean == Money && priceLabel )
{
- priceLabel->setText( CI18N::get( "uiPrice" ) );
+ priceLabel->setText( CI18N::get( "uiPrice" ).toUtf8() );
priceLabel->setActive(true);
}
else
@@ -977,7 +977,7 @@ void CBotChatPageTrade::startSellDialog(CDBCtrlSheet *sheet, CCtrlBase * /* pCal
CViewText *priceLabel = dynamic_cast(ig->getView( "standard_price:total_price_header" ));
if ( priceLabel )
{
- priceLabel->setText( CI18N::get( "uiImmediatePrice" ) );
+ priceLabel->setText( CI18N::get( "uiImmediatePrice" ).toUtf8() );
priceLabel->setActive(true);
}
@@ -1012,7 +1012,7 @@ void CBotChatPageTrade::startSellDialog(CDBCtrlSheet *sheet, CCtrlBase * /* pCal
{
ucstring itemName;
itemName = sheet->getItemActualName();
- itemNameView->setText(itemName);
+ itemNameView->setText(itemName.toUtf8());
}
// set help for item
@@ -1679,14 +1679,14 @@ void CBotChatPageTrade::setupFactionPointPrice(bool /* sellMode */, uint default
{
ucstring fmt= CI18N::get("uiUnitFPPrice");
strFindReplace(fmt, "%fac", factionName);
- vt->setText(fmt);
+ vt->setText(fmt.toUtf8());
}
vt= dynamic_cast(fpGroup->getView("total_price_header"));
if(vt)
{
ucstring fmt= CI18N::get("uiTotalFPPrice");
strFindReplace(fmt, "%fac", factionName);
- vt->setText(fmt);
+ vt->setText(fmt.toUtf8());
}
// setup icon according to pvp clan
diff --git a/ryzom/client/src/interface_v3/chat_text_manager.cpp b/ryzom/client/src/interface_v3/chat_text_manager.cpp
index 3b11d17a5..6fae6a29b 100644
--- a/ryzom/client/src/interface_v3/chat_text_manager.cpp
+++ b/ryzom/client/src/interface_v3/chat_text_manager.cpp
@@ -380,12 +380,12 @@ CViewBase *CChatTextManager::createMsgTextSimple(const ucstring &msg, NLMISC::CR
// otherwise, set text normal and apply global color
if (msg.find(ucstring("@{")) != ucstring::npos)
{
- vt->setTextFormatTaged(msg);
+ vt->setTextFormatTaged(msg.toUtf8());
vt->setColor(NLMISC::CRGBA::White);
}
else
{
- vt->setText(msg);
+ vt->setText(msg.toUtf8());
vt->setColor(col);
}
@@ -465,12 +465,12 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C
if (title.size() > 0)
{
vt->LinkTitle = title.toUtf8();
- vt->setText(title);
+ vt->setText(vt->LinkTitle);
}
else
{
vt->LinkTitle = url.toUtf8();
- vt->setText(url);
+ vt->setText(vt->LinkTitle);
}
if (url.find_first_of('\'') != string::npos)
diff --git a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp
index e0e5f2e74..81d34447d 100644
--- a/ryzom/client/src/interface_v3/dbctrl_sheet.cpp
+++ b/ryzom/client/src/interface_v3/dbctrl_sheet.cpp
@@ -2090,7 +2090,7 @@ void CDBCtrlSheet::draw()
_RegenText = new CViewText(CViewBase::TCtorParam());
_RegenText->setId(getId() + ":regen");
_RegenText->setParent(_Parent);
- _RegenText->setOverflowText(ucstring(""));
+ _RegenText->setOverflowText(std::string());
_RegenText->setModulateGlobalColor(false);
_RegenText->setMultiLine(false);
_RegenText->setTextMode(CViewText::ClipWord);
diff --git a/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp b/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp
index 561d48235..c75dc3af3 100644
--- a/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp
+++ b/ryzom/client/src/interface_v3/dbgroup_build_phrase.cpp
@@ -1074,7 +1074,7 @@ void CDBGroupBuildPhrase::updateAllDisplay(const CSPhraseCom &phrase)
float relative_cost;
cost= pBM->getSabrinaCom().getPhraseBrickAndParamCost(phrase.Bricks, i);
relative_cost = pBM->getSabrinaCom().getPhraseBrickAndParamRelativeCost(phrase.Bricks, i);
- ucstring costText;
+ std::string costText;
if( cost == 0 && relative_cost != 0.f )
{
cost = (sint32)(relative_cost * 100.f);
@@ -1119,10 +1119,10 @@ void CDBGroupBuildPhrase::updateAllDisplay(const CSPhraseCom &phrase)
{
word.InfoView->setActive(true);
if(i==0)
- word.InfoView->setText( CI18N::get("uiTextHelpSelectRootBrick") );
+ word.InfoView->setText( CI18N::get("uiTextHelpSelectRootBrick").toUtf8() );
else
// start effect index at 1 (human readable :) )
- word.InfoView->setText( CI18N::get("uiTextHelpSelectEffectBrick") + toString(i) );
+ word.InfoView->setText( CI18N::get("uiTextHelpSelectEffectBrick").toUtf8() + toString(i) );
}
}
@@ -1243,7 +1243,7 @@ void CDBGroupBuildPhrase::updateAllDisplay(const CSPhraseCom &phrase)
{
ucstring text;
pPM->buildPhraseDesc(text, phrase, 0, false, "composition");
- _TextPhraseDesc->setTextFormatTaged(text);
+ _TextPhraseDesc->setTextFormatTaged(text.toUtf8());
}
diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.cpp
index be89ead3d..9a8efa4ae 100644
--- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.cpp
+++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_icon_phrase.cpp
@@ -141,7 +141,7 @@ void CDBGroupListSheetIconPhrase::setSectionGroupId(CInterfaceGroup *pIG, uin
pPM->getPhraseLevelFromSection(sectionId, minLevel, maxLevel);
strFindReplace(sectionText, "%min", toString(minLevel));
strFindReplace(sectionText, "%max", toString(maxLevel));
- name->setText (sectionText);
+ name->setText (sectionText.toUtf8());
}
}
diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp
index f34053396..8483e9925 100644
--- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp
+++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.cpp
@@ -1086,7 +1086,7 @@ void CDBGroupListSheetText::CSheetChild::updateViewTextAsItem()
}
// set text
- Text->setTextFormatTaged(text);
+ Text->setTextFormatTaged(text.toUtf8());
}
}
diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h
index 2486bfc29..d9a495635 100644
--- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h
+++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text.h
@@ -135,7 +135,7 @@ public:
{
ucstring text;
Ctrl->getContextHelp(text);
- Text->setText(text);
+ Text->setText(text.toUtf8());
}
// create a CViewText object that is displayed next to the item. This is the opportunnity to create
diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp
index 490c36b85..8e21b7f26 100644
--- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp
+++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_brick_composition.cpp
@@ -137,11 +137,11 @@ void CDBGroupListSheetTextBrickComposition::CSheetChildBrick::updateViewText(CDB
// Temp if the Desc2 is empty, set Name
ucstring desc2(STRING_MANAGER::CStringManagerClient::getSBrickLocalizedCompositionDescription(brickSheetId));
if( !desc2.empty() && !hasOnlyBlankChars(desc2)) // tolerate Blank error in translation
- Text->setText(desc2);
+ Text->setText(desc2.toUtf8());
else
{
desc2 = STRING_MANAGER::CStringManagerClient::getSBrickLocalizedName(brickSheetId);
- Text->setText(desc2);
+ Text->setText(desc2.toUtf8());
}
@@ -159,7 +159,7 @@ void CDBGroupListSheetTextBrickComposition::CSheetChildBrick::updateViewText(CDB
{
// Special Case for the "Remove Brick" brick. No Cost (not revelant)
if( brick->Id==pBM->getInterfaceRemoveBrick() )
- CostView->setText( ucstring() );
+ CostView->setText( std::string() );
else if( brick->SabrinaCost == 0 && brick->SabrinaRelativeCost != 0.f )
CostView->setText( toString("%+d", (sint32)(brick->SabrinaRelativeCost * 100.f) ) + string("%") );
else
diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.cpp
index ec1bfbaed..3cdf24ca8 100644
--- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.cpp
+++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase.cpp
@@ -94,7 +94,7 @@ void CDBGroupListSheetTextPhrase::CSheetChildPhrase::updateViewText(CDBGroupList
#endif
// set
- Text->setText(text);
+ Text->setText(text.toUtf8());
}
@@ -173,7 +173,7 @@ void CDBGroupListSheetTextPhrase::setSectionGroupId(CInterfaceGroup *pIG, uin
pPM->getPhraseLevelFromSection(sectionId, minLevel, maxLevel);
strFindReplace(sectionText, "%min", toString(minLevel));
strFindReplace(sectionText, "%max", toString(maxLevel));
- name->setText (sectionText);
+ name->setText (sectionText.toUtf8());
}
}
diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase_id.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase_id.cpp
index 45a78980e..6e98afc5c 100644
--- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase_id.cpp
+++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_text_phrase_id.cpp
@@ -48,7 +48,7 @@ void CDBGroupListSheetTextPhraseId::CSheetChildPhrase::updateViewText(CDBGroupLi
// Get the User Name of the phrase
Ctrl->getContextHelp(text);
- Text->setText(text);
+ Text->setText(text.toUtf8());
}
// ***************************************************************************
diff --git a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp
index ce7f2fcf5..b0924f0af 100644
--- a/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp
+++ b/ryzom/client/src/interface_v3/dbgroup_list_sheet_trade.cpp
@@ -457,7 +457,7 @@ void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetT
// setup color and text
text= colorTag + text;
- Text->setTextFormatTaged(text);
+ Text->setTextFormatTaged(text.toUtf8());
}
// ***************************************************************************
diff --git a/ryzom/client/src/interface_v3/encyclopedia_manager.cpp b/ryzom/client/src/interface_v3/encyclopedia_manager.cpp
index ec82b5c8d..6ab68522d 100644
--- a/ryzom/client/src/interface_v3/encyclopedia_manager.cpp
+++ b/ryzom/client/src/interface_v3/encyclopedia_manager.cpp
@@ -303,8 +303,8 @@ void CEncyclopediaManager::rebuildAlbumPage(uint32 albumName)
if (pRBVT != NULL)
{
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
- const ucstring desc(pSMC->getSBrickLocalizedDescription(CSheetId(pAlbum->RewardBrick)));
- pRBVT->setText(desc);
+ CUtfStringView desc(pSMC->getSBrickLocalizedDescription(CSheetId(pAlbum->RewardBrick)));
+ pRBVT->setText(desc.toUtf8());
}
}
@@ -359,18 +359,18 @@ void CEncyclopediaManager::rebuildThemaPage(uint32 themaName)
{
if (pES->type() == CEntitySheet::ITEM)
{
- const ucstring desc(pSMC->getItemLocalizedDescription(CSheetId(pThema->RewardSheet)));
- pRBVT->setText(desc);
+ CUtfStringView desc(pSMC->getItemLocalizedDescription(CSheetId(pThema->RewardSheet)));
+ pRBVT->setText(desc.toUtf8());
}
else if (pES->type() == CEntitySheet::SBRICK)
{
- const ucstring desc(pSMC->getSBrickLocalizedDescription(CSheetId(pThema->RewardSheet)));
- pRBVT->setText(desc);
+ CUtfStringView desc(pSMC->getSBrickLocalizedDescription(CSheetId(pThema->RewardSheet)));
+ pRBVT->setText(desc.toUtf8());
}
else if (pES->type() == CEntitySheet::SPHRASE)
{
- const ucstring desc(pSMC->getSPhraseLocalizedDescription(CSheetId(pThema->RewardSheet)));
- pRBVT->setText(desc);
+ CUtfStringView desc(pSMC->getSPhraseLocalizedDescription(CSheetId(pThema->RewardSheet)));
+ pRBVT->setText(desc.toUtf8());
}
}
diff --git a/ryzom/client/src/interface_v3/flying_text_manager.cpp b/ryzom/client/src/interface_v3/flying_text_manager.cpp
index 23e6e963e..f577d41e2 100644
--- a/ryzom/client/src/interface_v3/flying_text_manager.cpp
+++ b/ryzom/client/src/interface_v3/flying_text_manager.cpp
@@ -143,7 +143,7 @@ void CFlyingTextManager::addFlyingText(void *key, const ucstring &text, const NL
gi.UsedThisFrame= true;
// update infos
- gi.ViewText->setText(text);
+ gi.ViewText->setText(text.toUtf8());
gi.ViewText->setColor(color);
gi.GroupInScene->Position= pos;
gi.GroupInScene->Scale= scale;
diff --git a/ryzom/client/src/interface_v3/group_compas.cpp b/ryzom/client/src/interface_v3/group_compas.cpp
index 87fcec6ce..3c18eb22c 100644
--- a/ryzom/client/src/interface_v3/group_compas.cpp
+++ b/ryzom/client/src/interface_v3/group_compas.cpp
@@ -414,7 +414,7 @@ void CGroupCompas::draw()
}
if (_DistViewText != distText)
{
- _DistView->setText(distText);
+ _DistView->setText(distText.toUtf8());
_DistViewText = distText;
}
}
diff --git a/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp
index 86ccd8e95..f070d3224 100644
--- a/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp
+++ b/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp
@@ -530,10 +530,10 @@ void CGroupInSceneBubbleManager::addSkillPopup (uint skillId, sint delta, uint t
if (group)
{
// Skill name
- const ucstring sSkillName(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)skillId));
+ CUtfStringView sSkillName(STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)skillId));
CViewText *pViewSkillName = dynamic_cast(group->getView("name"));
if (pViewSkillName != NULL)
- pViewSkillName->setText (sSkillName);
+ pViewSkillName->setText (sSkillName.toUtf8());
// Skill value
CCDBNodeLeaf *skillLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:CHARACTER_INFO:SKILLS:"+toString(skillId)+":BaseSKILL", false);
@@ -599,7 +599,7 @@ void CGroupInSceneBubbleManager::addMessagePopup (const ucstring &message, CRGBA
CViewText *pViewName = dynamic_cast(group->getView("name"));
if (pViewName != NULL)
{
- pViewName->setText (message);
+ pViewName->setText (message.toUtf8());
pViewName->setColor (color);
}
@@ -648,7 +648,7 @@ void CGroupInSceneBubbleManager::addMessagePopupCenter (const ucstring &message,
CViewText *pViewName = dynamic_cast(group->getView("name"));
if (pViewName != NULL)
{
- pViewName->setTextFormatTaged(message);
+ pViewName->setTextFormatTaged(message.toUtf8());
pViewName->setColor (color);
}
@@ -787,7 +787,7 @@ void CGroupInSceneBubbleManager::addContextHelp (const ucstring &message, const
}
}
- text->setText(finalMessage);
+ text->setText(finalMessage.toUtf8());
}
}
context->Group->setActive(true);
@@ -1080,7 +1080,7 @@ void CGroupInSceneBubbleManager::webIgChatOpen (uint32 nBotUID, string text, con
if (pVT != NULL)
{
pVT->setActive(false);
- pVT->setText(ucstring(""));
+ pVT->setText(std::string());
}
pCL = dynamic_cast(bubble->getElement(id+"optb"+toString(j)));
if (pCL != NULL) pCL->setActive(false);
@@ -1094,7 +1094,7 @@ void CGroupInSceneBubbleManager::webIgChatOpen (uint32 nBotUID, string text, con
pVT->setActive(true);
ucstring optionText;
optionText.fromUtf8(strs[j]);
- pVT->setText(optionText);
+ pVT->setText(optionText.toUtf8());
pCL = dynamic_cast(bubble->getElement(id+"optb"+toString(j)));
if (pCL != NULL)
{
@@ -1485,7 +1485,7 @@ void CGroupInSceneBubble::setRawText (const ucstring &text)
CInterfaceElement *pVTIE = CWidgetManager::getInstance()->getElementFromId(getId()+":header_opened:window:text");
CViewText *pVT= dynamic_cast(pVTIE);
if (pVT != NULL)
- pVT->setText(text);
+ pVT->setText(text.toUtf8());
}
// ***************************************************************************
diff --git a/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp b/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp
index 8c853b191..fe846038c 100644
--- a/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp
+++ b/ryzom/client/src/interface_v3/group_in_scene_user_info.cpp
@@ -780,19 +780,19 @@ CGroupInSceneUserInfo *CGroupInSceneUserInfo::build (CEntityCL *entity)
// Set player name
if (info->_Name)
{
- info->_Name->setText(entityName);
+ info->_Name->setText(entityName.toUtf8());
info->_Name->setModulateGlobalColor(false);
}
// Set player title
if (info->_Title)
- info->_Title->setText(entityTitle);
+ info->_Title->setText(entityTitle.toUtf8());
// Set tribe name
if (info->_TribeName)
{
nlassert(info->_GuildName == NULL);
- info->_TribeName->setText(theTribeName);
+ info->_TribeName->setText(theTribeName.toUtf8());
}
// Init user leaf nodes
@@ -966,7 +966,7 @@ void CGroupInSceneUserInfo::updateDynamicData ()
if (pPlayer != NULL)
if (pPlayer->isAFK())
entityName += CI18N::get("uiAFK");
- _Name->setText(entityName);
+ _Name->setText(entityName.toUtf8());
// Title color get the PVP color
if (_Title)
@@ -994,7 +994,7 @@ void CGroupInSceneUserInfo::updateDynamicData ()
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
ucstring ucsTmp;
if (pSMC->getString (_Entity->getGuildNameID(), ucsTmp))
- _GuildName->setText(ucsTmp);
+ _GuildName->setText(ucsTmp.toUtf8());
// guildname color is the pvp color
_GuildName->setColor(entityColor);
@@ -1020,7 +1020,7 @@ void CGroupInSceneUserInfo::updateDynamicData ()
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
ucstring ucsTmp;
if (pSMC->getString (_Entity->getEventFactionID(), ucsTmp))
- _EventFaction->setText(ucsTmp);
+ _EventFaction->setText(ucsTmp.toUtf8());
// guildname color depends of PVP faction or not
_EventFaction->setColor(entityColor);
diff --git a/ryzom/client/src/interface_v3/group_map.cpp b/ryzom/client/src/interface_v3/group_map.cpp
index 41b6f021e..4315b1b8b 100644
--- a/ryzom/client/src/interface_v3/group_map.cpp
+++ b/ryzom/client/src/interface_v3/group_map.cpp
@@ -2483,7 +2483,7 @@ void CGroupMap::updateMatchedLandmarks()
CViewText* t = dynamic_cast(g->getView("title"));
if (t)
{
- t->setSingleLineTextFormatTaged(_MatchedLandmarks[k].Title);
+ t->setSingleLineTextFormatTaged(_MatchedLandmarks[k].Title.toUtf8());
}
CViewBitmap* b = dynamic_cast(g->getView("icon"));
@@ -2553,7 +2553,7 @@ void CGroupMap::createLMWidgets(const std::vector &lms)
else // just add a text
{
CLandMarkText *pNewText = new CLandMarkText(CViewBase::TCtorParam());
- pNewText->setText(ucsTmp);
+ pNewText->setText(ucsTmp.toUtf8());
pNewText->Pos = mapPos;
pNewText->setParent(this);
pNewText->setParentPosRef(Hotspot_BL);
@@ -3411,7 +3411,7 @@ CGroupMap::CLandMarkText* CGroupMap::findClosestLandmark(const CVector2f ¢er
for(TLandMarkTextVect::const_iterator it = landmarks.begin(); it != landmarks.end(); ++it)
{
ucstring lc;
- lc = (*it)->getText();
+ lc = CUtfStringView((*it)->getText()).toUtf16();
if(filterLandmark(lc, keywords, startsWith)) {
CVector2f pos;
mapToWorld(pos, (*it)->Pos);
@@ -3466,7 +3466,7 @@ bool CGroupMap::targetLandmarkByName(const ucstring &search, bool startsWith) co
{
ct.setType(CCompassTarget::ContinentLandMark);
mapToWorld(ct.Pos, lmt->Pos);
- ct.Name = lmt->getText();
+ ct.Name = CUtfStringView(lmt->getText()).toUtf16();
closest = dist;
found = true;
}
@@ -3814,7 +3814,7 @@ void CGroupMap::updateClosestLandMarkMenu(const std::string &menu, const NLMISC:
CViewTextMenu* vt = rootMenu->addLine(ucstring(""), "map_landmark_by_index", ahParams, lineId.c_str(), "", "", false, false, false);
if (!vt) break;
- vt->setSingleLineTextFormatTaged(name);
+ vt->setSingleLineTextFormatTaged(name.toUtf8());
// TODO: should calculate from mouse pos and client width
vt->setLineMaxW(800);
diff --git a/ryzom/client/src/interface_v3/group_modal_get_key.cpp b/ryzom/client/src/interface_v3/group_modal_get_key.cpp
index c2d29df78..e3791cf8e 100644
--- a/ryzom/client/src/interface_v3/group_modal_get_key.cpp
+++ b/ryzom/client/src/interface_v3/group_modal_get_key.cpp
@@ -89,7 +89,7 @@ bool CGroupModalGetKey::handleEvent (const NLGUI::CEventDescriptor &event)
// Setup the text !
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CViewText *pVT= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( VIEW_TEXT_KEY ));
- if (pVT != NULL) pVT->setText(Combo.toUCString());
+ if (pVT != NULL) pVT->setText(Combo.toUCString().toUtf8());
// Check if in use
CActionsManager *pCurAM = NULL;
@@ -111,12 +111,12 @@ bool CGroupModalGetKey::handleEvent (const NLGUI::CEventDescriptor &event)
if (baseAction && pCurAM->isActionPresentInContext(it->second))
{
ucstring shortcutName = baseAction->getActionLocalizedText(it->second);
- if (pVT != NULL) pVT->setText(shortcutName);
+ if (pVT != NULL) pVT->setText(shortcutName.toUtf8());
}
}
else
{
- if (pVT != NULL) pVT->setText(string(""));
+ if (pVT != NULL) pVT->setText(string());
}
}
diff --git a/ryzom/client/src/interface_v3/group_skills.cpp b/ryzom/client/src/interface_v3/group_skills.cpp
index f2586401a..053bddf86 100644
--- a/ryzom/client/src/interface_v3/group_skills.cpp
+++ b/ryzom/client/src/interface_v3/group_skills.cpp
@@ -387,7 +387,7 @@ void CGroupSkills::createAllTreeNodes()
// Set Skill Name
CViewText *pViewSkillName = dynamic_cast(pIG->getView("name"));
if (pViewSkillName != NULL)
- pViewSkillName->setText (sSkillName);
+ pViewSkillName->setText (sSkillName.toUtf8());
// Set Skill Max Value
CViewText *pViewSkillMax = dynamic_cast(pIG->getView("max"));
if (pViewSkillMax != NULL)
diff --git a/ryzom/client/src/interface_v3/guild_manager.cpp b/ryzom/client/src/interface_v3/guild_manager.cpp
index d00661357..3a25c0198 100644
--- a/ryzom/client/src/interface_v3/guild_manager.cpp
+++ b/ryzom/client/src/interface_v3/guild_manager.cpp
@@ -470,7 +470,7 @@ void CGuildManager::update()
{
CViewText *pJoinPropPhraseView = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_JOIN_PROPOSAL_PHRASE));
if (pJoinPropPhraseView != NULL)
- pJoinPropPhraseView->setText(_JoinPropPhrase);
+ pJoinPropPhraseView->setText(_JoinPropPhrase.toUtf8());
pJoinProp->setActive(true);
CWidgetManager::getInstance()->setTopWindow(pJoinProp);
@@ -724,7 +724,7 @@ bool CDBGroupListAscensor::CSheetChildAscensor::isInvalidated(CDBGroupListSheetT
ucstring name;
if (nameID && pSMC->getDynString(nameID, name))
{
- Text->setText(name);
+ Text->setText(name.toUtf8());
uint64 icon = NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:" + toString(Index) + ":ICON")->getValue64();
@@ -830,20 +830,20 @@ class CAHGuildSheetOpen : public IActionHandler
// Set name
CViewText *pViewName = dynamic_cast(pLine->getView(TEMPLATE_GUILD_MEMBER_NAME));
if (pViewName != NULL)
- pViewName->setText (rGuildMembers[i].Name);
+ pViewName->setText (rGuildMembers[i].Name.toUtf8());
// Set Grade
CViewText *pViewGrade = dynamic_cast(pLine->getView(TEMPLATE_GUILD_MEMBER_GRADE));
if (pViewGrade != NULL)
{
if (rGuildMembers[i].Grade == EGSPD::CGuildGrade::Leader)
- pViewGrade->setText (CI18N::get("uiGuildLeader"));
+ pViewGrade->setText (CI18N::get("uiGuildLeader").toUtf8());
else if (rGuildMembers[i].Grade == EGSPD::CGuildGrade::HighOfficer)
- pViewGrade->setText (CI18N::get("uiGuildHighOfficer"));
+ pViewGrade->setText (CI18N::get("uiGuildHighOfficer").toUtf8());
else if (rGuildMembers[i].Grade == EGSPD::CGuildGrade::Officer)
- pViewGrade->setText (CI18N::get("uiGuildOfficer"));
+ pViewGrade->setText (CI18N::get("uiGuildOfficer").toUtf8());
else
- pViewGrade->setText (CI18N::get("uiGuildMember"));
+ pViewGrade->setText (CI18N::get("uiGuildMember").toUtf8());
}
// online?
@@ -888,7 +888,7 @@ class CAHGuildSheetOpen : public IActionHandler
str += toString("%01d", rt.getRyzomCycle()+1) +", ";
str += CI18N::get("ui"+MONTH::toString( (MONTH::EMonth)rt.getRyzomMonthInCurrentCycle() )) + ", ";
str += toString("%02d", rt.getRyzomDayOfMonth()+1);
- pViewEnterDate->setText(str);
+ pViewEnterDate->setText(str.toUtf8());
}
// Add to the list
diff --git a/ryzom/client/src/interface_v3/interface_ddx.cpp b/ryzom/client/src/interface_v3/interface_ddx.cpp
index 347a0d94d..caa394723 100644
--- a/ryzom/client/src/interface_v3/interface_ddx.cpp
+++ b/ryzom/client/src/interface_v3/interface_ddx.cpp
@@ -350,7 +350,7 @@ void CInterfaceDDX::CParam::updateScrollView(sint32 nVal)
{
if(ResultView)
{
- ResultView->setText(ucstring(toString(nVal)) + ResultUnit);
+ ResultView->setText(toString(nVal) + ResultUnit.toUtf8());
}
}
@@ -361,7 +361,7 @@ void CInterfaceDDX::CParam::updateScrollView(double nVal)
{
// allow N digits
string fmt= toString("%%.%df", ResultDecimal);
- ResultView->setText(ucstring(toString(fmt.c_str(), nVal)) + ResultUnit);
+ ResultView->setText(toString(fmt.c_str(), nVal) + ResultUnit.toUtf8());
}
}
diff --git a/ryzom/client/src/interface_v3/interface_manager.cpp b/ryzom/client/src/interface_v3/interface_manager.cpp
index 5737e50a0..fdc132030 100644
--- a/ryzom/client/src/interface_v3/interface_manager.cpp
+++ b/ryzom/client/src/interface_v3/interface_manager.cpp
@@ -1530,7 +1530,7 @@ void CInterfaceManager::updateFrameEvents()
CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:weather"));
if (pVT != NULL)
- pVT->setText(str);
+ pVT->setText(str.toUtf8());
CCtrlBase *pTooltip= dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:weather_tt"));
if (pTooltip != NULL)
@@ -1564,7 +1564,7 @@ void CInterfaceManager::updateFrameEvents()
pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:time"));
if (pVT != NULL)
- pVT->setText(str);
+ pVT->setText(str.toUtf8());
str.clear();
// Update the clock in the compass if enabled.
@@ -1577,7 +1577,7 @@ void CInterfaceManager::updateFrameEvents()
str = getTimestampHuman("%I:%M %p");
else
str = getTimestampHuman("%H:%M");
- pVT->setText(str);
+ pVT->setText(str.toUtf8());
}
}
}
@@ -2388,7 +2388,7 @@ void CInterfaceManager::messageBoxInternal(const string &msgBoxGroup, const ucst
if (group && viewText)
{
viewText->setCaseMode(caseMode);
- viewText->setText(text);
+ viewText->setText(text.toUtf8());
CWidgetManager::getInstance()->enableModalWindow(NULL, group);
// don't understand why but need to update coords here
group->updateCoords();
@@ -2441,7 +2441,7 @@ void CInterfaceManager::validMessageBox(TValidMessageIcon icon, const ucstring &
CWidgetManager::getInstance()->setProcedureAction("proc_valid_message_box_cancel", 1, ahOnCancel, paramsOnCancel);
// set text and icon
- viewText->setText(text);
+ viewText->setText(text.toUtf8());
if(viewBitmap)
{
bool active= true;
diff --git a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp
index 119ce44b2..ec754de33 100644
--- a/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp
+++ b/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp
@@ -884,7 +884,7 @@ int CLuaIHMRyzom::setTextFormatTaged(CLuaState &ls)
throw ELuaIHMException("setTextFormatTaged(): '%s' is not a CViewText", pIE->getId().c_str());
// Set the text as format
- vt->setTextFormatTaged(text);
+ vt->setTextFormatTaged(text.toUtf8());
return 0;
}
diff --git a/ryzom/client/src/interface_v3/macrocmd_key.cpp b/ryzom/client/src/interface_v3/macrocmd_key.cpp
index f97e90723..d9dfce119 100644
--- a/ryzom/client/src/interface_v3/macrocmd_key.cpp
+++ b/ryzom/client/src/interface_v3/macrocmd_key.cpp
@@ -103,14 +103,14 @@ void addKeyLine (CGroupList *pParent, const ucstring &keyName, const ucstring &s
CViewText *pViewKeyName = dynamic_cast(pKeysLine->getView(TEMPLATE_KEYS_KEY_NAME));
if (pViewKeyName != NULL)
{
- pViewKeyName->setText (keyName);
+ pViewKeyName->setText (keyName.toUtf8());
pViewKeyName->setColor(grayed?CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlTextGrayColor).getValColor():CRGBA::White);
}
CViewText *pViewShortcutName = dynamic_cast(pKeysLine->getView(TEMPLATE_KEYS_SHORTCUT_NAME));
if (pViewShortcutName != NULL)
{
- pViewShortcutName->setText (shortcutName);
+ pViewShortcutName->setText (shortcutName.toUtf8());
pViewShortcutName->setColor(grayed?CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionCtrlTextGrayColor).getValColor():CRGBA::White);
}
@@ -512,9 +512,9 @@ void CModalContainerEditCmd::activate()
NLGUI::CDBManager::getInstance()->getDbProp( DbComboDisp2P )->setValue32(-1);
// reset name of params
CViewText *pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME));
- if (pViewParamName != NULL) pViewParamName->setText (string(""));
+ if (pViewParamName != NULL) pViewParamName->setText (string());
pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME));
- if (pViewParamName != NULL) pViewParamName->setText (string(""));
+ if (pViewParamName != NULL) pViewParamName->setText (string());
invalidCurrentCommand();
}
@@ -689,7 +689,7 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std
if (noParam == 0) sText = WinName+VIEW_EDITCMD_FIRST_PARAM_NAME;
else sText = WinName+VIEW_EDITCMD_SECOND_PARAM_NAME;
CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sText));
- if (pVT != NULL) pVT->setText(CI18N::get(pBA->Parameters[i].LocalizedName));
+ if (pVT != NULL) pVT->setText(CI18N::get(pBA->Parameters[i].LocalizedName).toUtf8());
noParam++;
}
}
@@ -711,7 +711,7 @@ void CModalContainerEditCmd::activateFrom (const std::string &cmdName, const std
CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_TEXT_KEY));
if (pVT != NULL) pVT->setActive(true);
// setup the text of the key
- pVT->setText(it->second.toUCString());
+ pVT->setText(it->second.toUCString().toUtf8());
// There is already a shortcut so we can display ok button
pBut = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK));
@@ -778,7 +778,7 @@ void CModalContainerEditCmd::invalidCurrentCommand()
{
// Dont display key shortcut if we are in creation mode
pVT= dynamic_cast(CWidgetManager::getInstance()->getElementFromId( WinName+VIEW_EDITCMD_TEXT_KEY ));
- if (pVT != NULL) pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT));
+ if (pVT != NULL) pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT).toUtf8());
// Deactivate the key definer text
pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_TEXT_KEY));
@@ -887,7 +887,7 @@ void CModalContainerEditCmd::validCurrentCommand()
{
CurrentEditCmdLine.Combo = it->second;
// Yes ok let setup the text of the key
- pVT->setText(it->second.toUCString());
+ pVT->setText(it->second.toUCString().toUtf8());
// There is already a shortcut so we can display ok button
CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK));
if (pCB != NULL) pCB->setFrozen (false);
@@ -897,7 +897,7 @@ void CModalContainerEditCmd::validCurrentCommand()
CurrentEditCmdLine.Combo.Key = KeyCount;
CurrentEditCmdLine.Combo.KeyButtons = noKeyButton;
// Display not assigned text
- pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT));
+ pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT).toUtf8());
// Do not display the ok button
CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+CTRL_EDITCMD_BUTTON_OK));
if (pCB != NULL) pCB->setFrozen (true);
@@ -1048,9 +1048,9 @@ void CModalContainerEditCmd::onChangeCategory()
// reset name of params
CViewText *pViewParamName;
pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME));
- if (pViewParamName != NULL) pViewParamName->setText (string(""));
+ if (pViewParamName != NULL) pViewParamName->setText (string());
pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME));
- if (pViewParamName != NULL) pViewParamName->setText (string(""));
+ if (pViewParamName != NULL) pViewParamName->setText (string());
// Reset key
invalidCurrentCommand();
}
@@ -1086,9 +1086,9 @@ void CModalContainerEditCmd::onChangeAction()
// reset name of params
CViewText *pViewParamName;
pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_FIRST_PARAM_NAME));
- if (pViewParamName != NULL) pViewParamName->setText (string(""));
+ if (pViewParamName != NULL) pViewParamName->setText (string());
pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(WinName+VIEW_EDITCMD_SECOND_PARAM_NAME));
- if (pViewParamName != NULL) pViewParamName->setText (string(""));
+ if (pViewParamName != NULL) pViewParamName->setText (string());
uint noParam = 0;
for (uint i = 0; i < rVParams.size(); ++i)
@@ -1111,7 +1111,7 @@ void CModalContainerEditCmd::onChangeAction()
pViewParamName = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(sViewText));
if (pViewParamName != NULL)
- pViewParamName->setText (CI18N::get(rP.LocalizedName));
+ pViewParamName->setText (CI18N::get(rP.LocalizedName).toUtf8());
}
if (rP.Type == CBaseAction::CParameter::Constant)
@@ -1354,7 +1354,7 @@ public:
pMCM->NewKey->CurrentEditCmdLine.Combo = pGetKey->Combo;
CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(pMCM->NewKey->WinName+VIEW_EDITCMD_TEXT_KEY));
- if (pVT != NULL) pVT->setText(pMCM->NewKey->CurrentEditCmdLine.Combo.toUCString());
+ if (pVT != NULL) pVT->setText(pMCM->NewKey->CurrentEditCmdLine.Combo.toUCString().toUtf8());
CCtrlBaseButton *pCB = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(pMCM->NewKey->WinName+CTRL_EDITCMD_BUTTON_OK));
if (pCB != NULL) pCB->setFrozen (false);
@@ -1366,7 +1366,7 @@ public:
pMCM->EditCmd->CurrentEditCmdLine.Combo = pGetKey->Combo;
pMCM->CurrentEditMacro.Combo = pMCM->EditCmd->CurrentEditCmdLine.Combo;
CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_NEWMACRO_KEY));
- if (pVT != NULL) pVT->setText(pMCM->EditCmd->CurrentEditCmdLine.Combo.toUCString());
+ if (pVT != NULL) pVT->setText(pMCM->EditCmd->CurrentEditCmdLine.Combo.toUCString().toUtf8());
}
}
};
diff --git a/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/ryzom/client/src/interface_v3/macrocmd_manager.cpp
index bf2197e45..12b066fff 100644
--- a/ryzom/client/src/interface_v3/macrocmd_manager.cpp
+++ b/ryzom/client/src/interface_v3/macrocmd_manager.cpp
@@ -827,7 +827,7 @@ void addCommandLine (CGroupList *pParent, uint cmdNb, const ucstring &cmdName)
if (pNewCmd == NULL) return;
CViewText *pVT = dynamic_cast(pNewCmd->getView(TEMPLATE_NEWMACRO_COMMAND_TEXT));
- if (pVT != NULL) pVT->setText(cmdName);
+ if (pVT != NULL) pVT->setText(cmdName.toUtf8());
pNewCmd->setParent (pParent);
pParent->addChild (pNewCmd);
@@ -895,9 +895,9 @@ public:
if (pVT != NULL)
{
if (pMCM->CurrentEditMacro.Combo.Key == KeyCount)
- pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT));
+ pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT).toUtf8());
else
- pVT->setText(pMCM->CurrentEditMacro.Combo.toUCString());
+ pVT->setText(pMCM->CurrentEditMacro.Combo.toUCString().toUtf8());
}
pList->clearGroups();
@@ -1003,9 +1003,9 @@ void addMacroLine (CGroupList *pParent, uint macNb, const CMacroCmd ¯o)
if (pVT != NULL)
{
if (macro.Combo.Key != KeyCount)
- pVT->setText(macro.Combo.toUCString());
+ pVT->setText(macro.Combo.toUCString().toUtf8());
else
- pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT));
+ pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT).toUtf8());
}
pNewMacro->setParent (pParent);
diff --git a/ryzom/client/src/interface_v3/music_player.cpp b/ryzom/client/src/interface_v3/music_player.cpp
index 56f97b554..a0a7aed66 100644
--- a/ryzom/client/src/interface_v3/music_player.cpp
+++ b/ryzom/client/src/interface_v3/music_player.cpp
@@ -328,7 +328,7 @@ void CMusicPlayer::rebuildPlaylist()
{
ucstring title;
title.fromUtf8(_Songs[i].Title);
- pVT->setText(title);
+ pVT->setText(title.toUtf8());
}
pVT = dynamic_cast(pNew->getView(TEMPLATE_PLAYLIST_SONG_DURATION));
@@ -483,7 +483,7 @@ void CMusicPlayer::updatePlayingInfo(const std::string info)
CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:mp3_player:screen:text"));
if (pVT)
{
- pVT->setText(ucstring::makeFromUtf8(info));
+ pVT->setText(info);
}
}
diff --git a/ryzom/client/src/interface_v3/people_interraction.cpp b/ryzom/client/src/interface_v3/people_interraction.cpp
index 7bde7d0fc..e285bbaf9 100644
--- a/ryzom/client/src/interface_v3/people_interraction.cpp
+++ b/ryzom/client/src/interface_v3/people_interraction.cpp
@@ -2831,7 +2831,7 @@ class CHandlerSelectChatSource : public IActionHandler
{
ucstring title;
STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title);
- pVTM->setText("["+s+"] " + title);
+ pVTM->setText("["+s+"] " + title.toUtf8());
}
}
}
diff --git a/ryzom/client/src/interface_v3/task_bar_manager.cpp b/ryzom/client/src/interface_v3/task_bar_manager.cpp
index 70d2d9fe7..7c9bb2a45 100644
--- a/ryzom/client/src/interface_v3/task_bar_manager.cpp
+++ b/ryzom/client/src/interface_v3/task_bar_manager.cpp
@@ -180,9 +180,9 @@ public:
if (pVT != NULL)
{
if (it != acmap.end())
- pVT->setText(it->second.toUCString());
+ pVT->setText(it->second.toUCString().toUtf8());
else
- pVT->setText(CI18N::get("uiNotAssigned"));
+ pVT->setText(CI18N::get("uiNotAssigned").toUtf8());
}
}
}
diff --git a/ryzom/client/src/login.cpp b/ryzom/client/src/login.cpp
index b134a5519..9e0fb7f12 100644
--- a/ryzom/client/src/login.cpp
+++ b/ryzom/client/src/login.cpp
@@ -243,7 +243,7 @@ void createOptionalCatUI()
pVT = dynamic_cast(pNewLine->getView("size"));
if (pVT != NULL)
{
- pVT->setText(BGDownloader::getWrittenSize(InfoOnPatch.OptCat[i].Size));
+ pVT->setText(BGDownloader::getWrittenSize(InfoOnPatch.OptCat[i].Size).toUtf8());
}
// Add to the list
@@ -287,7 +287,7 @@ static void setDataScanLog(const ucstring &text)
CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:log_txt:log"));
if (pVT != NULL)
{
- pVT->setText(text);
+ pVT->setText(text.toUtf8());
}
}
@@ -296,10 +296,10 @@ static void setDataScanState(const ucstring &text, ucstring progress= ucstring()
{
CInterfaceManager *pIM= CInterfaceManager::getInstance();
CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:state"));
- if (pVT != NULL) pVT->setText(text);
+ if (pVT != NULL) pVT->setText(text.toUtf8());
pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:login:datascan:content:progress"));
- if (pVT != NULL) pVT->setText(progress);
+ if (pVT != NULL) pVT->setText(progress.toUtf8());
}
void initCatDisplay()
@@ -338,7 +338,7 @@ static void setPatcherStateText(const std::string &baseUIPath, const ucstring &s
CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(baseUIPath + ":content:state"));
if (pVT != NULL)
{
- pVT->setText(str);
+ pVT->setText(str.toUtf8());
}
}
@@ -349,7 +349,7 @@ static void setPatcherProgressText(const std::string &baseUIPath, const ucstring
CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(baseUIPath + ":content:progress"));
if (pVT != NULL)
{
- pVT->setText(str);
+ pVT->setText(str.toUtf8());
}
}
@@ -717,7 +717,7 @@ void loginMainLoop()
ucstring sTmp;
sTmp = BGDownloader::getWrittenSize(currentPatchingSize);
sTmp += " / " + BGDownloader::getWrittenSize(totalPatchSize);
- if (pVT != NULL) pVT->setText(sTmp);
+ if (pVT != NULL) pVT->setText(sTmp.toUtf8());
}
// else if (screen == UI_VARIABLES_SCREEN_CATDISP) // If we are displaying patch info
else if (LoginSM.getCurrentState() == CLoginStateMachine::st_display_cat)
@@ -766,10 +766,10 @@ void loginMainLoop()
// Total size of the patches is optional cats + required cat (f(optCat)) + non opt cat
CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_TOTAL_SIZE));
- if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(TotalPatchSize));
+ if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(TotalPatchSize).toUtf8());
pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(VIEW_NON_OPTIONAL_SIZE));
- if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(nNonOptSize));
+ if (pVT != NULL) pVT->setText(BGDownloader::getWrittenSize(nNonOptSize).toUtf8());
}
}
}
diff --git a/ryzom/client/src/net_manager.cpp b/ryzom/client/src/net_manager.cpp
index 642935869..d1744f3ff 100644
--- a/ryzom/client/src/net_manager.cpp
+++ b/ryzom/client/src/net_manager.cpp
@@ -3374,7 +3374,7 @@ private:
// must set the text by hand
CViewText *vt= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(CWidgetManager::getInstance()->getParser()->getDefine("server_message_box_content_view_text")));
if(vt)
- vt->setTextFormatTaged(contentStr);
+ vt->setTextFormatTaged(contentStr.toUtf8());
// open
CWidgetManager::getInstance()->setTopWindow(pGC);
diff --git a/ryzom/client/src/player_cl.cpp b/ryzom/client/src/player_cl.cpp
index eafdec032..15e8209db 100644
--- a/ryzom/client/src/player_cl.cpp
+++ b/ryzom/client/src/player_cl.cpp
@@ -753,7 +753,7 @@ void CPlayerCL::updateVisualPropertyVpa(const NLMISC::TGameCycle &/* gameCycle *
if (_Slot == 0)
{
CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:player:header_opened:player_title"));
- if (pVT != NULL) pVT->setText(_Title);
+ if (pVT != NULL) pVT->setText(_Title.toUtf8());
}
// rebuild in scene interface
diff --git a/ryzom/client/src/r2/editor.cpp b/ryzom/client/src/r2/editor.cpp
index ee203d312..a708bc2a4 100644
--- a/ryzom/client/src/r2/editor.cpp
+++ b/ryzom/client/src/r2/editor.cpp
@@ -1761,7 +1761,7 @@ void CEditor::waitScenarioScreen()
// Display the firewall alert string
CViewText *pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:r2ed_connecting:title"));
if (pVT != NULL)
- pVT->setText(CI18N::get("uiFirewallAlert")+ucstring("..."));
+ pVT->setText(CI18N::get("uiFirewallAlert").toUtf8()+"...");
// The mouse and fullscreen mode should be unlocked for the user to set the firewall permission
nlSleep( 30 ); // 'nice' the client, and prevent to make too many send attempts
@@ -1853,8 +1853,8 @@ void CEditor::waitScenarioScreen()
if (pVT != NULL)
{
pVT->setMultiLine( true );
- pVT->setText(CI18N::get("uiFirewallFail")+ucstring(".\n")+
- CI18N::get("uiFirewallAlert")+ucstring("."));
+ pVT->setText(CI18N::get("uiFirewallFail").toUtf8()+".\n"+
+ CI18N::get("uiFirewallAlert").toUtf8()+".");
}
}
}
@@ -6468,7 +6468,7 @@ void CEditor::connectionMsg(const std::string &stringId)
CViewText *vt = dynamic_cast(r2ConnectWindow->getView("connexionMsg"));
if (vt)
{
- vt->setText(CI18N::get(stringId));
+ vt->setText(CI18N::get(stringId).toUtf8());
}
}
}
@@ -7497,7 +7497,7 @@ class CAHInviteCharacter : public IActionHandler
{
CViewText* pVT = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:warning_free_trial:text"));
if (pVT != NULL)
- pVT->setText(CI18N::get("uiRingWarningInviteFreeTrial"));
+ pVT->setText(CI18N::get("uiRingWarningInviteFreeTrial").toUtf8());
CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, "group=ui:interface:warning_free_trial");
}
diff --git a/ryzom/client/src/session_browser_impl.cpp b/ryzom/client/src/session_browser_impl.cpp
index 9f3cc77a9..f11c24a54 100644
--- a/ryzom/client/src/session_browser_impl.cpp
+++ b/ryzom/client/src/session_browser_impl.cpp
@@ -230,7 +230,7 @@ int CSessionBrowserImpl::luaJoinRingSession(CLuaState &ls)
{
CViewText* pVT = dynamic_cast