From 8eb24e71e3a9290058fd744cb357bd2eb6f826c3 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 2 Dec 2016 16:24:31 +0100 Subject: [PATCH] Changed: Use _T macro, TCHAR, tStrToUtf8/utf8ToTStr, etc... to support UNICODE --- .../tools/3d/object_viewer/multi_tex_dlg.cpp | 18 ++++++------ .../tools/3d/object_viewer/object_viewer.cpp | 4 +-- .../3d/object_viewer/particle_system_edit.cpp | 8 +++--- .../nel_patch_edit/np_epm_subdivide.cpp | 6 ++-- .../3d/tile_edit/SelectionTerritoire.cpp | 12 ++++---- .../georges_dll/edit_list_ctrl.cpp | 15 ++++++---- .../georges_dll/file_browser_dialog.cpp | 12 ++++---- .../georges_dll/file_tree_view.cpp | 6 ++-- .../leveldesign/georges_dll/form_dialog.cpp | 14 +++++----- .../leveldesign/georges_dll/georges_edit.cpp | 28 +++++++++---------- .../leveldesign/georges_dll/georges_edit.h | 2 +- .../georges_dll/georges_edit_view.cpp | 2 +- 12 files changed, 65 insertions(+), 62 deletions(-) diff --git a/code/nel/tools/3d/object_viewer/multi_tex_dlg.cpp b/code/nel/tools/3d/object_viewer/multi_tex_dlg.cpp index 58776b931..58d67bd0b 100644 --- a/code/nel/tools/3d/object_viewer/multi_tex_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/multi_tex_dlg.cpp @@ -214,10 +214,10 @@ void CMultiTexDlg::writeValues(bool alternate) GetDlgItem(IDC_U_SPEED_2)->GetWindowText(u2, 10); GetDlgItem(IDC_V_SPEED_2)->GetWindowText(v2, 10); - if (_tcscanf(u1, "%f", &vs1.x) == 1 && - _tcscanf(v1, "%f", &vs1.y) == 1 && - _tcscanf(u2, "%f", &vs2.x) == 1 && - _tcscanf(v2, "%f", &vs2.y) == 1) + if (_stscanf(u1, _T("%f"), &vs1.x) == 1 && + _stscanf(v1, _T("%f"), &vs1.y) == 1 && + _stscanf(u2, _T("%f"), &vs2.x) == 1 && + _stscanf(v2, _T("%f"), &vs2.y) == 1) { _MTP->setScrollSpeed(0, vs1); _MTP->setScrollSpeed(1, vs2); @@ -236,10 +236,10 @@ void CMultiTexDlg::writeValues(bool alternate) GetDlgItem(IDC_V_SPEED_1_ALTERNATE)->GetWindowText(v1, 10); GetDlgItem(IDC_U_SPEED_2_ALTERNATE)->GetWindowText(u2, 10); GetDlgItem(IDC_V_SPEED_2_ALTERNATE)->GetWindowText(v2, 10); - if (_tcscanf(u1, "%f", &vs1.x) == 1 && - _tcscanf(v1, "%f", &vs1.y) == 1 && - _tcscanf(u2, "%f", &vs2.x) == 1 && - _tcscanf(v2, "%f", &vs2.y) == 1) + if (_stscanf(u1, _T("%f"), &vs1.x) == 1 && + _stscanf(v1, _T("%f"), &vs1.y) == 1 && + _stscanf(u2, _T("%f"), &vs2.x) == 1 && + _stscanf(v2, _T("%f"), &vs2.y) == 1) { _MTP->setAlternateScrollSpeed(0, vs1); _MTP->setAlternateScrollSpeed(1, vs2); @@ -251,7 +251,7 @@ void CMultiTexDlg::writeValues(bool alternate) TCHAR bumpFactorTxt[10]; float bumpFactor; GetDlgItem(IDC_BUMP_FACTOR)->GetWindowText(bumpFactorTxt, 10); - if (_tcscanf(bumpFactorTxt, "%f", &bumpFactor) == 1) + if (_stscanf(bumpFactorTxt, _T("%f"), &bumpFactor) == 1) { _MTP->setBumpFactor(bumpFactor); updateModifiedFlag(); diff --git a/code/nel/tools/3d/object_viewer/object_viewer.cpp b/code/nel/tools/3d/object_viewer/object_viewer.cpp index 923e04a64..f76ecb4e1 100644 --- a/code/nel/tools/3d/object_viewer/object_viewer.cpp +++ b/code/nel/tools/3d/object_viewer/object_viewer.cpp @@ -813,8 +813,8 @@ bool CObjectViewer::initUI (HWND parent) // load the scheme bank if one is present CIFile iF; - ::_makepath (sModulePath, SDrive, SDir, "default", ".scb"); - if (iF.open(sModulePath)) + std::string path = SPath + "default.scb"; + if (iF.open(path)) { try { diff --git a/code/nel/tools/3d/object_viewer/particle_system_edit.cpp b/code/nel/tools/3d/object_viewer/particle_system_edit.cpp index 6d833acdf..7aa989d8b 100644 --- a/code/nel/tools/3d/object_viewer/particle_system_edit.cpp +++ b/code/nel/tools/3d/object_viewer/particle_system_edit.cpp @@ -403,9 +403,9 @@ void CParticleSystemEdit::updateBBoxFromText() m_BBoxYCtrl.GetWindowText(inY, 128); m_BBoxZCtrl.GetWindowText(inZ, 128); - if (_tcscanf(inX, "%f", &h.x) == 1 - && _tcscanf(inY, "%f", &h.y) == 1 - && _tcscanf(inZ, "%f", &h.z) == 1 + if (_stscanf(inX, _T("%f"), &h.x) == 1 + && _stscanf(inY, _T("%f"), &h.y) == 1 + && _stscanf(inZ, _T("%f"), &h.z) == 1 ) { NLMISC::CAABBox b; @@ -466,7 +466,7 @@ void CParticleSystemEdit::OnChangeApplyAfterDelay() GetDlgItem(IDC_APPLY_AFTER_DELAY)->GetWindowText(in, 128); float value; - if (_tcscanf(in, "%f", &value) == 1) + if (_stscanf(in, _T("%f"), &value) == 1) { if (_Node->getPSPointer()->getDelayBeforeDeathConditionTest() != value) { diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_subdivide.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_subdivide.cpp index b67153e07..644b508a8 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_subdivide.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_epm_subdivide.cpp @@ -1237,7 +1237,7 @@ void EditPatchMod::DoEdgeSubdivide() { altered = holdNeeded = 1; if (theHold.Holding()) - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "DoEdgeSubdivide")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("DoEdgeSubdivide"))); // Call the patch add function SubdividePatch(SUBDIV_EDGES, propagate, patch, rpatch); patchData->UpdateChanges(patch, rpatch); @@ -1304,7 +1304,7 @@ void EditPatchMod::DoPatchSubdivide() { altered = holdNeeded = 1; if (theHold.Holding()) - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "DoPatchSubdivide")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("DoPatchSubdivide"))); // Call the patch add function SubdividePatch(SUBDIV_PATCHES, propagate, patch, rpatch); patchData->UpdateChanges(patch, rpatch); @@ -1441,7 +1441,7 @@ void EditPatchMod::DoPatchTurn(bool ccw) { altered = holdNeeded = 1; if (theHold.Holding()) - theHold.Put(new PatchRestore(patchData, this, patch, rpatch, "DoTurnPatch")); + theHold.Put(new PatchRestore(patchData, this, patch, rpatch, _T("DoTurnPatch"))); // Call the patch add function TurnPatch (patch, rpatch, ccw); diff --git a/code/nel/tools/3d/tile_edit/SelectionTerritoire.cpp b/code/nel/tools/3d/tile_edit/SelectionTerritoire.cpp index eb7738411..15b9a5b7d 100644 --- a/code/nel/tools/3d/tile_edit/SelectionTerritoire.cpp +++ b/code/nel/tools/3d/tile_edit/SelectionTerritoire.cpp @@ -361,11 +361,11 @@ void SelectionTerritoire::OnSelect() { POSITION p = sFile.GetStartPosition(); CString str = sFile.GetNextPathName(p); - char *temp = str.GetBuffer(256); - if (temp) + std::string temp = tStrToUtf8(str); + if (!temp.empty()) { CIFile stream; - if (stream.open ((const char*)str)) + if (stream.open (temp)) { list->ResetContent (); list2->ResetContent (); @@ -377,13 +377,13 @@ void SelectionTerritoire::OnSelect() for (i=0; iAddString(tileBank.getLand(i)->getName().c_str()); + list->AddString(utf8ToTStr(tileBank.getLand(i)->getName())); } for (i=0; iAddString(tileBank.getTileSet(i)->getName().c_str()); + list2->AddString(utf8ToTStr(tileBank.getTileSet(i)->getName())); } MainFileName = CString(utf8ToTStr(NLMISC::CFile::getFilename(temp))); @@ -400,7 +400,7 @@ void SelectionTerritoire::OnSelect() button->EnableWindow(true); // Change the bouton text path - GetDlgItem (IDC_PATH)->SetWindowText (tileBank.getAbsPath().c_str()); + GetDlgItem (IDC_PATH)->SetWindowText (utf8ToTStr(tileBank.getAbsPath())); } } diff --git a/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.cpp b/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.cpp index c3a722c6d..4efdf0c16 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.cpp @@ -151,22 +151,22 @@ BOOL CEditListCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) item = ListCtrl.GetNextSelectedItem(pos); string text; getNewItemText (item, 0, text); - ListCtrl.InsertItem (item, text.c_str ()); + ListCtrl.InsertItem (item, utf8ToTStr(text)); for (uint i=1; igetBrowseInfo (Ctrl->Item, Ctrl->SubItem, defExt, defFilename, defDir, filter); - CFileDialog dlgFile (TRUE, defExt.c_str (), defFilename.c_str (), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, filter.c_str (), theApp.m_pMainWnd); - dlgFile.m_ofn.lpstrInitialDir = defDir.c_str (); + TCHAR buffer[MAX_PATH]; + _tcscpy(buffer, utf8ToTStr(defDir)); + + CFileDialog dlgFile (TRUE, utf8ToTStr(defExt), utf8ToTStr(defFilename), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, utf8ToTStr(filter), theApp.m_pMainWnd); + dlgFile.m_ofn.lpstrInitialDir = buffer; Ctrl->OnBrowse = true; if (dlgFile.DoModal () == IDOK) { diff --git a/code/ryzom/tools/leveldesign/georges_dll/file_browser_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/file_browser_dialog.cpp index f63e967ee..98cb78b83 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/file_browser_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/file_browser_dialog.cpp @@ -79,8 +79,8 @@ BOOL CFileBrowserDialog::OnInitDialog() int tabCount = 0; if (theApp.Superuser) { - TabFile->InsertItem (0, "Type"); - TabFile->InsertItem (1, "Dfn"); + TabFile->InsertItem (0, _T("Type")); + TabFile->InsertItem (1, _T("Dfn")); tabCount += 2; TreeCtrlType.create( sz, TabFile, 0); @@ -96,7 +96,7 @@ BOOL CFileBrowserDialog::OnInitDialog() TreeCtrlDfn.setNotifyWindow (m_hWnd, 1); } - TabFile->InsertItem (tabCount, "Form"); + TabFile->InsertItem (tabCount, _T("Form")); TabFile->SetCurSel (tabCount); TreeCtrlForm.create( sz, TabFile, 2); @@ -279,7 +279,7 @@ void CFileBrowserDialog::openDocument () string pathName = CPath::lookup (filename.c_str (), false, false); if (pathName.empty ()) pathName = filename; - theApp.OpenDocumentFile (pathName.c_str()); + theApp.OpenDocumentFile (utf8ToTStr(pathName)); } } else if (IsWindow (TreeCtrlType) && TreeCtrlDfn.IsWindowVisible ()) @@ -289,7 +289,7 @@ void CFileBrowserDialog::openDocument () string pathName = CPath::lookup (filename.c_str (), false, false); if (pathName.empty ()) pathName = filename; - theApp.OpenDocumentFile (pathName.c_str()); + theApp.OpenDocumentFile (utf8ToTStr(pathName)); } } else if (TreeCtrlForm.IsWindowVisible ()) @@ -299,7 +299,7 @@ void CFileBrowserDialog::openDocument () string pathName = CPath::lookup (filename.c_str (), false, false); if (pathName.empty ()) pathName = filename; - theApp.OpenDocumentFile (pathName.c_str()); + theApp.OpenDocumentFile (utf8ToTStr(pathName)); } } } diff --git a/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp b/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp index fac4cb052..3a0616fe1 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp @@ -441,11 +441,11 @@ bool CFileTreeCtrl::enumObjects(HTREEITEM hParentItem,IShellFolder* pParentFolde pParentFolder->GetAttributesOf(1, (LPCITEMIDLIST*)&pidl, &pItemInfo->dwFlags); // Convert display name in file system path - char name[MAX_PATH]; + TCHAR name[MAX_PATH]; nlverify ( SHGetPathFromIDList ( pidl, name ) ); // Save it - pItemInfo->displayName = name; + pItemInfo->displayName = tStrToUtf8(name); // Is a folder ? bool folder = (pItemInfo->dwFlags&SFGAO_FOLDER) !=0; @@ -720,7 +720,7 @@ bool CFileTreeCtrl::getCurrentFilename (std::string &result) if (curSel) { CString str = _TreeCtrl.GetItemText (curSel); - result = str; + result = tStrToUtf8(str); return true; } return false; diff --git a/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp index 76421972b..25d10f9d2 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp @@ -770,7 +770,7 @@ BOOL CFormDialog::OnCommand(WPARAM wParam, LPARAM lParam) colorEdit->Edit.GetWindowText (str); sint r, g, b; - if (sscanf (str, "%d,%d,%d", &r, &g, &b) == 3) + if (_stscanf (str, _T("%d,%d,%d"), &r, &g, &b) == 3) { clamp (r, 0, 255); clamp (g, 0, 255); @@ -1352,18 +1352,18 @@ void IFormWidget::updateLabel () if (node->getForm () == doc->getFormPtr ()) { // The node exist - Label.SetWindowText (SavedLabel.c_str()); + Label.SetWindowText (utf8ToTStr(SavedLabel)); } else { // The node exist in the parent form - Label.SetWindowText ((SavedLabel+" (in parent form)").c_str()); + Label.SetWindowText (utf8ToTStr(SavedLabel + " (in parent form)")); } } else { // The node is empty - Label.SetWindowText ((SavedLabel+" (undefined)").c_str()); + Label.SetWindowText (utf8ToTStr(SavedLabel + " (undefined)")); } } @@ -1509,10 +1509,10 @@ void IFormWidget::onOpenSelected () string str; getValue (str); - std::string str2=CPath::lookup (str.c_str (), false, false); + std::string str2 = CPath::lookup (str, false, false); if (str2.empty()) - str2 = str.c_str (); - theApp.OpenDocumentFile (str2.c_str ()); + str2 = str; + theApp.OpenDocumentFile (utf8ToTStr(str2)); } // *************************************************************************** diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp b/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp index d11e33a5a..1860096aa 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp @@ -74,10 +74,10 @@ CGeorgesEditApp::CGeorgesEditApp() : MemStream (false, false, 1024*1024) ExeStandalone = false; StartExpanded = true; - FormClipBoardFormatStruct = RegisterClipboardFormat ("GeorgesFormStruct"); - FormClipBoardFormatVirtualStruct = RegisterClipboardFormat ("GeorgesFormVirtualStruct"); - FormClipBoardFormatArray = RegisterClipboardFormat ("GeorgesFormArray"); - FormClipBoardFormatType = RegisterClipboardFormat ("GeorgesFormType"); + FormClipBoardFormatStruct = RegisterClipboardFormat (_T("GeorgesFormStruct")); + FormClipBoardFormatVirtualStruct = RegisterClipboardFormat (_T("GeorgesFormVirtualStruct")); + FormClipBoardFormatArray = RegisterClipboardFormat (_T("GeorgesFormArray")); + FormClipBoardFormatType = RegisterClipboardFormat (_T("GeorgesFormType")); nlassert (FormClipBoardFormatStruct); nlassert (FormClipBoardFormatVirtualStruct); nlassert (FormClipBoardFormatArray); @@ -159,7 +159,7 @@ BOOL CGeorgesEditApp::initInstance (int nCmdShow, bool exeStandalone, int x, int if (!isInitialized && exeStandalone) { m_nCmdShow = nCmdShow; - ExePath = GetCommandLine (); + ExePath = tStrToUtf8(GetCommandLine ()); if (ExePath.size()>0) { if (ExePath[0] == '\"') @@ -673,11 +673,11 @@ bool CGeorgesEditApp::getColor (NLMISC::CRGBA &color) // Get custom colors COLORREF arrayColor[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; HKEY hKey; - if (RegOpenKeyEx(HKEY_CURRENT_USER, GEORGES_EDIT_BASE_REG_KEY"\\Custom Colors", 0, KEY_READ, &hKey)==ERROR_SUCCESS) + if (RegOpenKeyEx(HKEY_CURRENT_USER, _T(GEORGES_EDIT_BASE_REG_KEY "\\Custom Colors"), 0, KEY_READ, &hKey)==ERROR_SUCCESS) { DWORD len=sizeof(arrayColor); DWORD type; - RegQueryValueEx (hKey, "", 0, &type, (LPBYTE)(arrayColor), &len); + RegQueryValueEx (hKey, _T(""), 0, &type, (LPBYTE)(arrayColor), &len); RegCloseKey (hKey); } @@ -698,9 +698,9 @@ bool CGeorgesEditApp::getColor (NLMISC::CRGBA &color) // Save the custom colors HKEY hKey; - if (RegCreateKey(HKEY_CURRENT_USER, GEORGES_EDIT_BASE_REG_KEY"\\Custom Colors", &hKey)==ERROR_SUCCESS) + if (RegCreateKey(HKEY_CURRENT_USER, _T(GEORGES_EDIT_BASE_REG_KEY "\\Custom Colors"), &hKey)==ERROR_SUCCESS) { - RegSetValueEx (hKey, "", 0, REG_BINARY, (LPBYTE)(arrayColor), sizeof(arrayColor)); + RegSetValueEx (hKey, _T(""), 0, REG_BINARY, (LPBYTE)(arrayColor), sizeof(arrayColor)); RegCloseKey (hKey); } return true; @@ -711,9 +711,9 @@ bool CGeorgesEditApp::getColor (NLMISC::CRGBA &color) bool CGeorgesEditApp::yesNo (const char* message) { if (m_pMainWnd) - return m_pMainWnd->MessageBox (message, "Georges Edit", MB_YESNO|MB_ICONQUESTION) != IDNO; + return m_pMainWnd->MessageBox (message, _T("Georges Edit"), MB_YESNO|MB_ICONQUESTION) != IDNO; else - return MessageBox (NULL, message, "Georges Edit", MB_YESNO|MB_ICONQUESTION) != IDNO; + return MessageBox (NULL, message, _T("Georges Edit"), MB_YESNO|MB_ICONQUESTION) != IDNO; } void CGeorgesEditApp::loadPlugins () @@ -722,7 +722,7 @@ void CGeorgesEditApp::loadPlugins () for (i=0; igetChild (i); int image = child->getItemImage (doc); - TabCtrl.InsertItem (i, child->getName ().c_str(), image); + TabCtrl.InsertItem (i, utf8ToTStr(child->getName()), image); // This is the selection ? if (subObject == child)