Cleaning up unicode conversion

feature/3ds-max-2020
kaetemi 6 years ago
parent 09ea41679f
commit 14304c7f64

@ -79,7 +79,7 @@ BOOL CMissionCompilerFeApp::InitInstance()
#endif #endif
// look at the command line parameters for command line mode // look at the command line parameters for command line mode
string cmdLine = m_lpCmdLine; string cmdLine = NLMISC::tStrToUtf8(m_lpCmdLine);
if (cmdLine.find("-c") != string::npos) if (cmdLine.find("-c") != string::npos)
{ {
NLMISC::createDebug(); NLMISC::createDebug();

@ -184,7 +184,7 @@ BOOL CMissionCompilerFeDlg::OnInitDialog()
if (SearchPaths.size() > 1) if (SearchPaths.size() > 1)
{ {
CWnd* pWnd = GetDlgItem(IDC_PATH_WARNING); CWnd* pWnd = GetDlgItem(IDC_PATH_WARNING);
pWnd->SetWindowText("Warning ! config file contains more than one path ! Only the first is shown ! "); pWnd->SetWindowText(_T("Warning ! config file contains more than one path ! Only the first is shown ! "));
} }
UpdateData(FALSE); UpdateData(FALSE);
@ -196,16 +196,16 @@ BOOL CMissionCompilerFeDlg::OnInitDialog()
// Check if the file "tmptool.txt" exists in system temp directory // Check if the file "tmptool.txt" exists in system temp directory
// It's that way world_editor pass arguments to the program // It's that way world_editor pass arguments to the program
// The file contains a list of primitives to select // The file contains a list of primitives to select
char tmpPath[MAX_PATH]; TCHAR tmpPath[MAX_PATH];
GetEnvironmentVariable("TMP", tmpPath, MAX_PATH); GetEnvironmentVariable(_T ("TMP"), tmpPath, MAX_PATH);
strcat(tmpPath, "\\tmptool.txt"); _tcscat(tmpPath, _T("\\tmptool.txt"));
if (NLMISC::CFile::fileExists(tmpPath)) if (NLMISC::CFile::fileExists(NLMISC::tStrToUtf8(tmpPath)))
{ {
FILE *f = nlfopen(tmpPath, "r"); FILE *f = _tfopen(tmpPath, _T("r"));
if (f == NULL) if (f == NULL)
{ {
nlinfo("Can't open the file for reading !\n%s", tmpPath); nlinfo("Can't open the file for reading !\n%s", nlTStrToUtf8(tmpPath));
return TRUE; return TRUE;
} }
@ -222,7 +222,7 @@ BOOL CMissionCompilerFeDlg::OnInitDialog()
fclose(f); fclose(f);
// delete temp file // delete temp file
NLMISC::CFile::deleteFile(tmpPath); NLMISC::CFile::deleteFile(NLMISC::tStrToUtf8(tmpPath));
// Test to check if the primitive is in src list // Test to check if the primitive is in src list
// If it is, erase it form src and add it to dest // If it is, erase it form src and add it to dest
@ -240,8 +240,8 @@ BOOL CMissionCompilerFeDlg::OnInitDialog()
files[i] = toUpper(CPath::standardizeDosPath(files[i])); files[i] = toUpper(CPath::standardizeDosPath(files[i]));
if (srcPath != files[i]) if (srcPath != files[i])
{ {
::MessageBox(NULL, "Primitive path and working directory are not the same !", ::MessageBox(NULL, _T("Primitive path and working directory are not the same !"),
"Mission compiler", MB_OK|MB_ICONEXCLAMATION); _T("Mission compiler"), MB_OK|MB_ICONEXCLAMATION);
} }
else else
{ {
@ -252,8 +252,8 @@ BOOL CMissionCompilerFeDlg::OnInitDialog()
else else
{ {
char buffer[1024]; char buffer[1024];
sprintf(buffer, "Can't find primitive in the directory !\n%s\n", files[i].c_str(), m_dataDirectory); sprintf(buffer, "Can't find primitive in the directory !\n%s\n", files[i].c_str(), nlTStrToUtf8(m_dataDirectory));
::MessageBox(NULL, buffer, "Mission compiler", MB_OK|MB_ICONEXCLAMATION); ::MessageBox(NULL, nlUtf8ToTStr(buffer), _T("Mission compiler"), MB_OK|MB_ICONEXCLAMATION);
} }
} }
@ -274,7 +274,7 @@ void CMissionCompilerFeDlg::fillSourceList()
addPath.CenterWindow(); addPath.CenterWindow();
addPath.ShowWindow(SW_SHOW); addPath.ShowWindow(SW_SHOW);
string log(addPath.m_addPathLog); string log = tStrToUtf8(addPath.m_addPathLog);
log += "Reading config file\r\n"; log += "Reading config file\r\n";
addPath.m_addPathLog = log.c_str(); addPath.m_addPathLog = log.c_str();
addPath.UpdateData(FALSE); addPath.UpdateData(FALSE);
@ -283,7 +283,7 @@ void CMissionCompilerFeDlg::fillSourceList()
// Fill the src list with available primitives // Fill the src list with available primitives
for (uint i=0; i<SearchPaths.size(); ++i) for (uint i=0; i<SearchPaths.size(); ++i)
{ {
log = addPath.m_addPathLog; log = tStrToUtf8(addPath.m_addPathLog);
log += SearchPaths[i]+"\r\n"; log += SearchPaths[i]+"\r\n";
addPath.m_addPathLog = log.c_str(); addPath.m_addPathLog = log.c_str();
addPath.UpdateData(FALSE); addPath.UpdateData(FALSE);
@ -319,7 +319,7 @@ bool CMissionCompilerFeDlg::readConfigFile()
} }
else else
{ {
AfxMessageBox("Can't find configuration var 'SearchPath', fatal", MB_OK); AfxMessageBox(_T("Can't find configuration var 'SearchPath', fatal"), MB_OK);
PostQuitMessage(-1); PostQuitMessage(-1);
return false; return false;
} }
@ -329,7 +329,7 @@ bool CMissionCompilerFeDlg::readConfigFile()
LigoConfigFile = var->asString(); LigoConfigFile = var->asString();
else else
{ {
AfxMessageBox("Can't find configuration var 'ligo_config', fatal", MB_OK); AfxMessageBox(_T("Can't find configuration var 'ligo_config', fatal"), MB_OK);
PostQuitMessage(-1); PostQuitMessage(-1);
return false; return false;
} }
@ -383,7 +383,7 @@ bool CMissionCompilerFeDlg::readConfigFile()
{ {
CWnd* pWnd = GetDlgItem(IDC_CHECK_SRV1 + i); CWnd* pWnd = GetDlgItem(IDC_CHECK_SRV1 + i);
pWnd->EnableWindow(TRUE); pWnd->EnableWindow(TRUE);
pWnd->SetWindowText(names->asString(i).c_str()); pWnd->SetWindowText(nlUtf8ToTStr(names->asString(i)));
ServerName.push_back(names->asString(i)); ServerName.push_back(names->asString(i));
ServerPathPrim.push_back(pathsPrim->asString(i)); ServerPathPrim.push_back(pathsPrim->asString(i));
@ -412,15 +412,15 @@ void CMissionCompilerFeDlg::updateFileList()
for (uint i=0; first != last; ++first) for (uint i=0; first != last; ++first)
{ {
if (m_filter.GetLength() == 0) if (m_filter.GetLength() == 0)
m_listSrc.InsertString(i++, first->first.c_str()); m_listSrc.InsertString(i++, nlUtf8ToTStr(first->first));
else else
{ {
// check the filter // check the filter
string filter(m_filter.LockBuffer()); string filter = tStrToUtf8(m_filter.LockBuffer());
m_filter.UnlockBuffer(); m_filter.UnlockBuffer();
if (first->first.find(filter) != string::npos) if (first->first.find(filter) != string::npos)
m_listSrc.InsertString(i++, first->first.c_str()); m_listSrc.InsertString(i++, nlUtf8ToTStr(first->first));
} }
} }
} }
@ -429,7 +429,7 @@ void CMissionCompilerFeDlg::updateFileList()
TFileList::iterator first(_DstList.begin()), last(_DstList.end()); TFileList::iterator first(_DstList.begin()), last(_DstList.end());
for (uint i=0; first != last; ++first,++i) for (uint i=0; first != last; ++first,++i)
{ {
m_listDst.InsertString(i, first->first.c_str()); m_listDst.InsertString(i, nlUtf8ToTStr(first->first));
} }
} }
} }
@ -493,7 +493,7 @@ void CMissionCompilerFeDlg::compile(BOOL publish)
dlg.UpdateData(FALSE); dlg.UpdateData(FALSE);
// dlg.m_compileLogCtrl.SetSel(compileLog.size(), compileLog.size(), FALSE); // dlg.m_compileLogCtrl.SetSel(compileLog.size(), compileLog.size(), FALSE);
dlg.RedrawWindow(); dlg.RedrawWindow();
AfxMessageBox(msg.c_str()); AfxMessageBox(nlUtf8ToTStr(msg));
break; break;
} }
} }
@ -569,7 +569,7 @@ void CMissionCompilerFeDlg::OnAdd()
{ {
CString tmp; CString tmp;
m_listSrc.GetText(sel[i], tmp); m_listSrc.GetText(sel[i], tmp);
string file(tmp.LockBuffer()); string file = tStrToUtf8(tmp.LockBuffer());
tmp.UnlockBuffer(); tmp.UnlockBuffer();
_DstList.insert(make_pair(file, _SrcList[file])); _DstList.insert(make_pair(file, _SrcList[file]));
_SrcList.erase(file); _SrcList.erase(file);
@ -585,7 +585,7 @@ void CMissionCompilerFeDlg::OnAddAll()
{ {
CString tmp; CString tmp;
m_listSrc.GetText(0, tmp); m_listSrc.GetText(0, tmp);
string file(tmp.LockBuffer()); string file = tStrToUtf8(tmp.LockBuffer());
tmp.UnlockBuffer(); tmp.UnlockBuffer();
_DstList.insert(make_pair(file, _SrcList[file])); _DstList.insert(make_pair(file, _SrcList[file]));
@ -608,7 +608,7 @@ void CMissionCompilerFeDlg::OnRemove()
{ {
CString tmp; CString tmp;
m_listDst.GetText(sel[i], tmp); m_listDst.GetText(sel[i], tmp);
string file(tmp.LockBuffer()); string file = tStrToUtf8(tmp.LockBuffer());
tmp.UnlockBuffer(); tmp.UnlockBuffer();
_SrcList.insert(make_pair(file, _DstList[file])); _SrcList.insert(make_pair(file, _DstList[file]));
_DstList.erase(file); _DstList.erase(file);
@ -662,7 +662,7 @@ void CMissionCompilerFeDlg::OnSpecialRuncompilertest()
CMissionCompiler mc; CMissionCompiler mc;
if (!mc.compileMissions(primDoc.RootNode, sourceDocName)) if (!mc.compileMissions(primDoc.RootNode, sourceDocName))
{ {
AfxMessageBox("Error while compiling the test primitive, correct error(s) first"); AfxMessageBox(_T("Error while compiling the test primitive, correct error(s) first"));
return; return;
} }
TMissionDataPtr testMission = mc.getMission(0); TMissionDataPtr testMission = mc.getMission(0);
@ -699,7 +699,7 @@ void CMissionCompilerFeDlg::OnSpecialRuncompilertest()
{ {
string msg = "In primitive "; string msg = "In primitive ";
msg += buildPrimPath(e.Primitive) + ": " + e.Why; msg += buildPrimPath(e.Primitive) + ": " + e.Why;
AfxMessageBox(utf8ToTStr(msg)); AfxMessageBox(nlUtf8ToTStr(msg));
} }
} }
@ -991,21 +991,21 @@ void CMissionCompilerFeDlg::OnChangeDir()
// open a dialog to choose a directory // open a dialog to choose a directory
BROWSEINFO bi; BROWSEINFO bi;
char str[MAX_PATH]; TCHAR str[MAX_PATH];
ITEMIDLIST* pidl; LPITEMIDLIST pidl;
char sTemp[1024]; TCHAR sTemp[1024];
// fill the structure with options // fill the structure with options
bi.hwndOwner = this->m_hWnd; bi.hwndOwner = this->m_hWnd;
bi.pidlRoot = NULL; bi.pidlRoot = NULL;
bi.pidlRoot = NULL; bi.pidlRoot = NULL;
bi.pszDisplayName = sTemp; bi.pszDisplayName = sTemp;
bi.lpszTitle = "Choose the data directory"; bi.lpszTitle = _T("Choose the data directory");
bi.ulFlags = 0; bi.ulFlags = 0;
bi.lpfn = dataDirBrowseCallbackProc; bi.lpfn = dataDirBrowseCallbackProc;
char sDir[512]; TCHAR sDir[512];
strcpy(sDir, m_dataDirectory); _tcscpy(sDir, m_dataDirectory);
bi.lParam = (LPARAM)sDir; bi.lParam = (LPARAM)sDir;
bi.iImage = 0; bi.iImage = 0;
pidl = SHBrowseForFolder (&bi); pidl = SHBrowseForFolder (&bi);
@ -1013,7 +1013,7 @@ void CMissionCompilerFeDlg::OnChangeDir()
if (SHGetPathFromIDList(pidl, str)) if (SHGetPathFromIDList(pidl, str))
{ {
m_dataDirectory = str; m_dataDirectory = str;
SearchPaths[0] = str; SearchPaths[0] = tStrToUtf8(str);
fillSourceList(); fillSourceList();
updateFileList(); updateFileList();
UpdateData(FALSE); UpdateData(FALSE);
@ -1023,7 +1023,7 @@ void CMissionCompilerFeDlg::OnChangeDir()
void CMissionCompilerFeDlg::OnChangeDataDir() void CMissionCompilerFeDlg::OnChangeDataDir()
{ {
UpdateData(TRUE); UpdateData(TRUE);
SearchPaths[0] = m_dataDirectory; SearchPaths[0] = tStrToUtf8(m_dataDirectory);
fillSourceList(); fillSourceList();
updateFileList(); updateFileList();
UpdateData(FALSE); UpdateData(FALSE);

Loading…
Cancel
Save