I make CEGUI interface use Lua.
and I need Set some chinese string in StaticText.
for Example:
cstrUIHelpWindowHelpText = "大家好"
pWindow = winMgr:getWindow("Root/MainBgImage/TextBgImage/TextWindow")
local myString2,myString = StringToUtf8(cstrUIHelpWindowHelpText,myString1)
pWindow:setText(myString)
StringToUtf8() is a C++ function. and it can work well in C++.
But It's messy code.
How can I use LUA to set chinese string in CEGUI
Moderators: CEGUI MVP, CEGUI Team
-
- Just popping in
- Posts: 10
- Joined: Tue Jul 01, 2008 07:57
- scriptkid
- Home away from home
- Posts: 1178
- Joined: Wed Jan 12, 2005 12:06
- Location: The Hague, The Netherlands
- Contact:
Exactly, it's about the ascii support in lua. What i did for a project was come up with a helper function which i did bind:
which you could call as:
So that you don't have a conversion 'through' the binding. I can confirm that it works for Japanese and Korean at least.
HTH.
Code: Select all
void Gui::setWinTextUTF8(std::string winName, std::string winText)
{
CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton();
if (winMgr.isWindowPresent(winName))
{
CEGUI::Window* win = winMgr.getWindow(winName);
win->setText((CEGUI::utf8*)winText.c_str());
}
}
which you could call as:
Code: Select all
gui_wrapper:setWinTextUTF8("Root/MainBgImage/TextBgImage/TextWindow", "大家好");
So that you don't have a conversion 'through' the binding. I can confirm that it works for Japanese and Korean at least.
HTH.
Check out my released snake game using Cegui!
-
- Just popping in
- Posts: 10
- Joined: Tue Jul 01, 2008 07:57
the function works for Chinese too .
i add a a method setTextA to base class CEGUI::Window, it use a virtual interface to tanslate the code.
but... ... scriptkid
do you forget to use a transform funtion for ascToUTF8 ?
--------------------------------------------------------------------------------
void Gui::setWinTextUTF8(std::string winName, std::string winText)
{
CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton();
if (winMgr.isWindowPresent(winName))
{
CEGUI::Window* win = winMgr.getWindow(winName);
--
CEGUI::String UtfText = (CEGUI::utf8*)ascToUtf8(winText.c_str());
--
win->setText(UtfText );
--
}
}
---------------------------------------------------------------------------------
i add a a method setTextA to base class CEGUI::Window, it use a virtual interface to tanslate the code.
but... ... scriptkid
do you forget to use a transform funtion for ascToUTF8 ?
--------------------------------------------------------------------------------
void Gui::setWinTextUTF8(std::string winName, std::string winText)
{
CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton();
if (winMgr.isWindowPresent(winName))
{
CEGUI::Window* win = winMgr.getWindow(winName);
--
CEGUI::String UtfText = (CEGUI::utf8*)ascToUtf8(winText.c_str());
--
win->setText(UtfText );
--
}
}
---------------------------------------------------------------------------------
Return to “Modifications / Integrations / Customisations”
Who is online
Users browsing this forum: No registered users and 4 guests