From 556806715e733c199573bcd412f9c6c538425ac1 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 30 Apr 2019 13:16:05 +0800 Subject: [PATCH] Fixing unicode in georges edit dll --- .../georges_dll/georges_implementation.cpp | 6 ++-- .../leveldesign/georges_dll/header_dialog.cpp | 32 +++++++++---------- .../leveldesign/georges_dll/icon_wnd.cpp | 9 +++--- .../leveldesign/georges_dll/imagelist_ex.cpp | 4 +-- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_implementation.cpp b/code/ryzom/tools/leveldesign/georges_dll/georges_implementation.cpp index 2ac3ed596..9e0b30f6e 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_implementation.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_implementation.cpp @@ -579,12 +579,12 @@ void CGeorgesImpl::LoadDocument( const std::string& _sxfullname ) AFX_MANAGE_STATE(AfxGetStaticModuleState()); try { - theApp.OpenDocumentFile(_sxfullname.c_str()); + theApp.OpenDocumentFile(utf8ToTStr(_sxfullname)); } catch (const NLMISC::Exception &e) { std::string tmp = std::string(e.what()) + "(" + _sxfullname + ")"; - theApp.m_pMainWnd->MessageBox(tmp.c_str(), "Georges_Lib", MB_ICONERROR | MB_OK); + theApp.m_pMainWnd->MessageBox(utf8ToTStr(tmp), _T("Georges_Lib"), MB_ICONERROR | MB_OK); } } @@ -666,7 +666,7 @@ IGeorges* IGeorges::getInterface (int version) // Check version number if (version != GEORGES_VERSION) { - MessageBox (NULL, "Bad version of georges.dll.", "Georges", MB_ICONEXCLAMATION|MB_OK); + MessageBox(NULL, _T("Bad version of georges.dll."), _T("Georges"), MB_ICONEXCLAMATION | MB_OK); return NULL; } else diff --git a/code/ryzom/tools/leveldesign/georges_dll/header_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/header_dialog.cpp index 8bdf3e165..ee1385216 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/header_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/header_dialog.cpp @@ -86,20 +86,20 @@ BOOL CHeaderDialog::OnInitDialog() // Create the version setStaticSize (currentPos); - char versionText[512]; - smprintf (versionText, 512, "Version %d.%d", 0, 0); + CString versionText; + versionText.Format(_T("Version %d.%d"), 0, 0); LabelVersion.Create (versionText, WS_VISIBLE, currentPos, this); initWidget (LabelVersion); getNextPosLabel (currentPos); setButtonSize (currentPos, SmallWidget); - IncrementVersion.Create ("Increment Version", WS_VISIBLE|WS_TABSTOP, currentPos, this, BtIncrement); + IncrementVersion.Create (_T("Increment Version"), WS_VISIBLE|WS_TABSTOP, currentPos, this, BtIncrement); initWidget (IncrementVersion); getNextPos (currentPos); // Create the state combo setStaticSize (currentPos); - LabelState.Create ("State:", WS_VISIBLE, currentPos, this); + LabelState.Create (_T("State:"), WS_VISIBLE, currentPos, this); initWidget (LabelState); getNextPosLabel (currentPos); @@ -109,30 +109,30 @@ BOOL CHeaderDialog::OnInitDialog() ComboState.Create (WS_VISIBLE|CBS_DROPDOWNLIST|WS_TABSTOP, pos, this, CbState); uint item; for (item=0; itemmodify (new CActionString (IAction::HeaderVersion, name, *doc, "", "", + doc->modify(new CActionString(IAction::HeaderVersion, tStrToUtf8(name).c_str(), *doc, "", "", doc->getLeftView ()->getCurrentSelectionId (), 0)); } } @@ -299,7 +299,7 @@ void CHeaderDialog::setCommentsToDocument () CGeorgesEditDocSub *current = doc->getSelectedObject (); CString str; Comments.GetWindowText (str); - doc->modify (new CActionString (IAction::HeaderComments, str, *doc, "", "", + doc->modify(new CActionString(IAction::HeaderComments, tStrToUtf8(str).c_str(), *doc, "", "", doc->getLeftView ()->getCurrentSelectionId (), 0)); } } diff --git a/code/ryzom/tools/leveldesign/georges_dll/icon_wnd.cpp b/code/ryzom/tools/leveldesign/georges_dll/icon_wnd.cpp index 5a28d65e6..fd657fcc7 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/icon_wnd.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/icon_wnd.cpp @@ -85,7 +85,7 @@ void CIconWnd::create (DWORD wStyle, RECT &pos, CWnd *parent, uint dialogIndex) LPCTSTR className = AfxRegisterWndClass(CS_OWNDC); // Create this window - CWnd::Create(className, "empty", wStyle, pos, parent, dialogIndex); + CWnd::Create(className, _T("empty"), wStyle, pos, parent, dialogIndex); } bool CIconWnd::updateStr() @@ -283,14 +283,15 @@ void CIconWnd::addIconLayer(NLMISC::CBitmap &dst, const std::string iconStr, con bool CIconWnd::updateWnd(CWnd *pWnd, std::string &str) { - char buffer[512]; + TCHAR buffer[512]; if (pWnd) { pWnd->GetWindowText(buffer, 512); - if (buffer != str) + std::string buf = tStrToUtf8(buffer); + if (buf != str) { - str = buffer; + str = buf; return true; } } diff --git a/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp b/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp index 590e98a25..0de9b99b0 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp @@ -27,7 +27,7 @@ using namespace NLMISC; #pragma warning (disable : 4786) -BOOL CALLBACK EnumResLangProc(HMODULE hModule, LPCSTR lpszType, LPCSTR lpszName, WORD wIDLanguage, +BOOL CALLBACK EnumResLangProc(HMODULE hModule, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIDLanguage, LONG_PTR lParam) { set *iconNames = (set*)lParam; @@ -96,7 +96,7 @@ void CImageListEx::addResourceIcon (const char *filename) int height = imageInfo.rcImage.bottom - imageInfo.rcImage.top; // Load the icon - HICON handle = (HICON) LoadImage (NULL, filename, IMAGE_ICON, width, height, LR_COLOR|LR_LOADFROMFILE); + HICON handle = (HICON) LoadImage (NULL, utf8ToTStr(filename), IMAGE_ICON, width, height, LR_COLOR|LR_LOADFROMFILE); if (handle) { // Copy the icon