Changed: Use _T macro, TCHAR, tStrToUtf8/utf8ToTStr, etc... to support UNICODE

--HG--
branch : develop
This commit is contained in:
kervala 2016-12-02 16:24:31 +01:00
parent 894151dba8
commit 7af3a4c68c
12 changed files with 65 additions and 62 deletions

View file

@ -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();

View file

@ -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
{

View file

@ -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)
{

View file

@ -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);

View file

@ -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; i<tileBank.getLandCount(); i++)
{
// Add to the list
list->AddString(tileBank.getLand(i)->getName().c_str());
list->AddString(utf8ToTStr(tileBank.getLand(i)->getName()));
}
for (i=0; i<tileBank.getTileSetCount(); i++)
{
// Add to the list
list2->AddString(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()));
}
}

View file

@ -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; i<ColumnCount; i++)
{
getNewItemText (item, i, text);
ListCtrl.SetItemText (item, i, text.c_str ());
ListCtrl.SetItemText (item, i, utf8ToTStr(text));
}
}
else
{
string text;
getNewItemText (0, 0, text);
ListCtrl.InsertItem (0, text.c_str ());
ListCtrl.InsertItem (0, utf8ToTStr(text));
for (uint i=1; i<ColumnCount; i++)
{
getNewItemText (0, i, text);
ListCtrl.SetItemText (0, i, text.c_str ());
ListCtrl.SetItemText (0, i, utf8ToTStr(text));
}
ListCtrl.SetItemState (0, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
}
@ -311,8 +311,11 @@ LRESULT CMyListCtrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
std::string defDir;
Ctrl->getBrowseInfo (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)
{

View file

@ -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));
}
}
}

View file

@ -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;

View file

@ -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));
}
// ***************************************************************************

View file

@ -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; i<PluginsNames.size (); i++)
{
// Load the dll
HINSTANCE hModule = AfxLoadLibrary (PluginsNames[i].c_str ());
HINSTANCE hModule = AfxLoadLibrary (utf8ToTStr(PluginsNames[i]));
if (hModule)
{
// Get the proc adrdess
@ -971,7 +971,7 @@ void CGeorgesEditApp::OnViewRefresh()
void CGeorgesEditApp::saveWindowState (const CWnd *wnd, const char *name, bool controlBar)
{
HKEY hKey;
nlverify (RegCreateKey (HKEY_CURRENT_USER, GEORGES_EDIT_BASE_REG_KEY"\\Windows states", &hKey) == ERROR_SUCCESS);
nlverify (RegCreateKey (HKEY_CURRENT_USER, _T(GEORGES_EDIT_BASE_REG_KEY "\\Windows states"), &hKey) == ERROR_SUCCESS);
// Get the position
WINDOWPLACEMENT wndpl;
@ -987,7 +987,7 @@ void CGeorgesEditApp::saveWindowState (const CWnd *wnd, const char *name, bool c
void CGeorgesEditApp::loadWindowState (CWnd *wnd, const char *name, bool mdiChildWnd, bool controlBar)
{
HKEY hKey;
if (RegOpenKey (HKEY_CURRENT_USER, GEORGES_EDIT_BASE_REG_KEY"\\Windows states", &hKey) == ERROR_SUCCESS)
if (RegOpenKey (HKEY_CURRENT_USER, _T(GEORGES_EDIT_BASE_REG_KEY "\\Windows states"), &hKey) == ERROR_SUCCESS)
{
// Get the value
WINDOWPLACEMENT wndpl;

View file

@ -38,7 +38,7 @@
// See georges_edit.cpp for the implementation of this class
//
#define GEORGES_EDIT_BASE_REG_KEY _T("Software\\Nevrax\\Georges Edit")
#define GEORGES_EDIT_BASE_REG_KEY "Software\\Nevrax\\Georges Edit"
#define GEORGES_EDIT_BROWSE_LABEL "--- Browse..."
extern const char* TypeFilter;

View file

@ -295,7 +295,7 @@ void CGeorgesEditView::updateTab ()
// Init the tab
CGeorgesEditDocSub *child = parent->getChild (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)