From 883ee21a176dd2a186a00077934012490cbfa340 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 30 Apr 2019 13:26:59 +0800 Subject: [PATCH] Fixing unicode in georges edit dll --- .../georges_dll/edit_list_ctrl.cpp | 4 +-- .../leveldesign/georges_dll/form_dialog.cpp | 8 +++--- .../leveldesign/georges_dll/form_dialog.h | 2 +- .../leveldesign/georges_dll/left_view.cpp | 10 +++---- .../leveldesign/georges_dll/main_frm.cpp | 12 ++++----- .../georges_dll/memory_combo_box.cpp | 27 ++++++++++--------- .../georges_dll/memory_combo_box.h | 6 ++--- .../georges_dll/output_console_dlg.cpp | 2 +- .../leveldesign/georges_dll/reg_shell_ext.cpp | 4 +-- 9 files changed, 38 insertions(+), 37 deletions(-) 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 0b16abd4f..bad4b8a1e 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.cpp @@ -69,7 +69,7 @@ bool CEditListCtrl::create (DWORD wStyle, RECT &rect, CWnd *parent, uint dialog_ Edit.SetFont (ListCtrl.GetFont()); Combo.Create (WS_BORDER|CBS_DROPDOWNLIST, rect, &ListCtrl, IdCombo); Combo.SetFont (ListCtrl.GetFont()); - MemCombo.create (WS_CHILD, rect, &ListCtrl, IdMemCombo, "", theApp.RememberListSize); + MemCombo.create (WS_CHILD, rect, &ListCtrl, IdMemCombo, _T(""), theApp.RememberListSize); MemCombo.SetFont (ListCtrl.GetFont()); return true; } @@ -475,7 +475,7 @@ void CEditListCtrl::editItem (uint item, uint subitem) string retString; bool browse; getMemComboBoxProp (Item, SubItem, retString, browse); - MemCombo.setRegisterAdress (retString.c_str ()); + MemCombo.setRegisterAdress (utf8ToTStr(retString)); MemCombo.clearCommand (); if (browse) MemCombo.addCommand (GEORGES_EDIT_BROWSE_LABEL, CmdBrowse); diff --git a/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp index 8cf257035..d86cc21bd 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp @@ -165,7 +165,7 @@ CWnd* CFormDialog::addTypeWidget (const NLGEORGES::CType &type, uint elmIndex, c // Create a reg key string tfn = typeFilename; - string key = GEORGES_EDIT_BASE_REG_KEY"\\"+strlwr (typeFilename)+" MemCombo"; + tstring key = utf8ToTStr(GEORGES_EDIT_BASE_REG_KEY"\\"+strlwr (typeFilename)+" MemCombo"); // Create the widget memCombo->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, title, key.c_str(), type.UIType==CType::EditSpin, type.UIType==CType::FileBrowser, filenameExt); @@ -251,7 +251,7 @@ void CFormDialog::getVirtualDfnFromDocument (const NLGEORGES::CFormDfn *_dfn, co // Create the widget memCombo->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, "Dfn:", - GEORGES_EDIT_BASE_REG_KEY"\\Virtual Dfn MemCombo", false, true, "*.dfn"); + _T(GEORGES_EDIT_BASE_REG_KEY) _T("\\Virtual Dfn MemCombo"), false, true, "*.dfn"); // Get from document memCombo->getFromDocument (*doc->getFormPtr ()); @@ -462,7 +462,7 @@ void CFormDialog::getArrayFromDocument (const char *structName, uint structId, u // Create the widget memCombo->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, "Array size:", - GEORGES_EDIT_BASE_REG_KEY"\\Array Size MemCombo", true, false, NULL); + _T(GEORGES_EDIT_BASE_REG_KEY) _T("\\Array Size MemCombo"), true, false, NULL); // Get from document memCombo->getFromDocument (*doc->getFormPtr ()); @@ -1541,7 +1541,7 @@ CFormMemCombo::~CFormMemCombo () // *************************************************************************** -void CFormMemCombo::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label, const char *reg, bool useSpinner, bool fileBrowser, const char *filenameExt) +void CFormMemCombo::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label, const TCHAR *reg, bool useSpinner, bool fileBrowser, const char *filenameExt) { // Get the doc CGeorgesEditDoc *doc = Dialog->View->GetDocument (); diff --git a/code/ryzom/tools/leveldesign/georges_dll/form_dialog.h b/code/ryzom/tools/leveldesign/georges_dll/form_dialog.h index cb9d29bab..d3afef083 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/form_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_dll/form_dialog.h @@ -207,7 +207,7 @@ public: bool FileBrowser; // Create the widget - void create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label, const char *reg, bool spinner, bool fileBrowser, const char *filenameExt); + void create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label, const TCHAR *reg, bool spinner, bool fileBrowser, const char *filenameExt); // From IFormWidget void onOk (); diff --git a/code/ryzom/tools/leveldesign/georges_dll/left_view.cpp b/code/ryzom/tools/leveldesign/georges_dll/left_view.cpp index 5f699dafe..7101680dd 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/left_view.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/left_view.cpp @@ -109,11 +109,11 @@ void CLeftView::getSubObject (CGeorgesEditDocSub *subObject, HTREEITEM parent, H if (!item) { int itemImage = subObject->getItemImage (GetDocument()); - item = TreeCtrl.InsertItem (subObject->getName ().c_str(), itemImage, itemImage, parent); + item = TreeCtrl.InsertItem (utf8ToTStr(subObject->getName()), itemImage, itemImage, parent); } // Set name - TreeCtrl.SetItemText (item, subObject->getName ().c_str()); + TreeCtrl.SetItemText (item, utf8ToTStr(subObject->getName())); // Set item data TreeCtrl.SetItemData (item, (DWORD)subObject); @@ -351,8 +351,8 @@ BOOL CLeftView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) { // Change the node name TreeCtrl.SetItemText (ptvdi->item.hItem, ptvdi->item.pszText); - doc->modify (new CActionString (IAction::FormArrayRename, ptvdi->item.pszText, *doc, - subObject->getFormName ().c_str (), toString (subObject->getIdInParent ()).c_str(), + doc->modify (new CActionString(IAction::FormArrayRename, tStrToUtf8(ptvdi->item.pszText).c_str(), *doc, + subObject->getFormName().c_str(), toString (subObject->getIdInParent()).c_str(), doc->getLeftView ()->getCurrentSelectionId (), subObject->getSlot ())); return TRUE; } @@ -878,7 +878,7 @@ void CLeftView::OnDelete() CEdit *edit = TreeCtrl.GetEditControl(); if (edit) { - edit->SetWindowText (""); + edit->SetWindowText (_T("")); } else { diff --git a/code/ryzom/tools/leveldesign/georges_dll/main_frm.cpp b/code/ryzom/tools/leveldesign/georges_dll/main_frm.cpp index 02c06fdde..7239d0f69 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/main_frm.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/main_frm.cpp @@ -163,7 +163,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) AssertLog->addDisplayer (&Displayer); // JC: added LoadBarState - LoadBarState("Georges"); + LoadBarState(_T("Georges")); return 0; } @@ -322,7 +322,7 @@ void CMainFrame::OnClose() if (theApp.SaveAllModified()) { // JC: added save bar state - SaveBarState("Georges"); + SaveBarState(_T("Georges")); // Save state theApp.saveState (); @@ -436,7 +436,7 @@ void CMainFrame::OnUpdateModules0(CCmdUI* pCmdUI) pCmdUI->Enable (); string name; theApp.PluginArray[0].PluginInterface->getPluginName (name); - pCmdUI->SetText (name.c_str ()); + pCmdUI->SetText (utf8ToTStr(name)); pCmdUI->SetCheck (theApp.PluginArray[0].Activated); } else @@ -464,7 +464,7 @@ void CMainFrame::OnUpdateModules1(CCmdUI* pCmdUI) pCmdUI->Enable (); string name; theApp.PluginArray[1].PluginInterface->getPluginName (name); - pCmdUI->SetText (name.c_str ()); + pCmdUI->SetText (utf8ToTStr(name)); pCmdUI->SetCheck (theApp.PluginArray[1].Activated); } else @@ -492,7 +492,7 @@ void CMainFrame::OnUpdateModules2(CCmdUI* pCmdUI) pCmdUI->Enable (); string name; theApp.PluginArray[2].PluginInterface->getPluginName (name); - pCmdUI->SetText (name.c_str ()); + pCmdUI->SetText (utf8ToTStr(name)); pCmdUI->SetCheck (theApp.PluginArray[2].Activated); } else @@ -520,7 +520,7 @@ void CMainFrame::OnUpdateModules3(CCmdUI* pCmdUI) pCmdUI->Enable (); string name; theApp.PluginArray[3].PluginInterface->getPluginName (name); - pCmdUI->SetText (name.c_str ()); + pCmdUI->SetText (utf8ToTStr(name)); pCmdUI->SetCheck (theApp.PluginArray[3].Activated); } else diff --git a/code/ryzom/tools/leveldesign/georges_dll/memory_combo_box.cpp b/code/ryzom/tools/leveldesign/georges_dll/memory_combo_box.cpp index baef40640..86204d8f7 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/memory_combo_box.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/memory_combo_box.cpp @@ -43,7 +43,7 @@ CMemoryComboBox::~CMemoryComboBox() // *************************************************************************** -void CMemoryComboBox::create (DWORD style, const RECT &rect, CWnd *parent, UINT nId, const char *registerAdress, int memoryCount) +void CMemoryComboBox::create (DWORD style, const RECT &rect, CWnd *parent, UINT nId, const TCHAR *registerAdress, int memoryCount) { // Register a window Id = nId; @@ -52,7 +52,7 @@ void CMemoryComboBox::create (DWORD style, const RECT &rect, CWnd *parent, UINT LPCTSTR clas = AfxRegisterWndClass (0); if (clas) { - if (Create (clas, "MemoryComboBox", style, rect, parent, nId)) + if (Create (clas, _T("MemoryComboBox"), style, rect, parent, nId)) { // Create the combo box RECT comboRect; @@ -95,16 +95,16 @@ bool CMemoryComboBox::getMemory (int slot, std::string &ret) { // Open the key HKEY hKey; - if (RegOpenKey (HKEY_CURRENT_USER, RegisterAdress.c_str (), &hKey) == ERROR_SUCCESS) + if (RegOpenKey(HKEY_CURRENT_USER, RegisterAdress.c_str (), &hKey) == ERROR_SUCCESS) { // Get the value char strSrc[512]; smprintf (strSrc, 512, "%d", slot); - char str[512]; - long size = 512; - if (RegQueryValue (hKey, strSrc, str, &size) == ERROR_SUCCESS) + TCHAR str[512]; + LONG size = 512 * sizeof(TCHAR); + if (RegQueryValue(hKey, utf8ToTStr(strSrc), str, &size) == ERROR_SUCCESS) { - ret = str; + ret = tStrToUtf8(str); // Close RegCloseKey (hKey); @@ -132,14 +132,14 @@ void CMemoryComboBox::scrollDown (int start, int end) // Get the old value char strSrc[512]; smprintf (strSrc, 512, "%d", i-1); - char str[512]; - long size = 512; - if (RegQueryValue (hKey, strSrc, str, &size) == ERROR_SUCCESS) + TCHAR str[512]; + LONG size = 512 * sizeof(TCHAR); + if (RegQueryValue (hKey, utf8ToTStr(strSrc), str, &size) == ERROR_SUCCESS) { // Set the value char strDst[512]; smprintf (strDst, 512, "%d", i); - RegSetValue (hKey, strDst, REG_SZ, str, size); + RegSetValue (hKey, utf8ToTStr(strSrc), REG_SZ, str, size); } } @@ -157,7 +157,8 @@ void CMemoryComboBox::pushString (const std::string &str) if (RegCreateKey (HKEY_CURRENT_USER, RegisterAdress.c_str (), &hKey) == ERROR_SUCCESS) { // Set the value - RegSetValue (hKey, _T("0"), REG_SZ, str.c_str (), str.size ()); + tstring tstr = utf8ToTStr(str); + RegSetValue (hKey, _T("0"), REG_SZ, tstr.c_str (), tstr.size ()); // Close RegCloseKey (hKey); @@ -460,7 +461,7 @@ void CMemoryComboBox::refreshStrings () // *************************************************************************** -void CMemoryComboBox::setRegisterAdress (const char *registerAdress) +void CMemoryComboBox::setRegisterAdress (const TCHAR *registerAdress) { RegisterAdress = registerAdress; refreshStrings (); diff --git a/code/ryzom/tools/leveldesign/georges_dll/memory_combo_box.h b/code/ryzom/tools/leveldesign/georges_dll/memory_combo_box.h index be999d252..e0fb2d679 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/memory_combo_box.h +++ b/code/ryzom/tools/leveldesign/georges_dll/memory_combo_box.h @@ -46,9 +46,9 @@ public: void onOK (); void onCancel (); - void create (DWORD style, const RECT &rect, CWnd *parent, UINT nId, const char *registerAdress, int memoryCount); + void create (DWORD style, const RECT &rect, CWnd *parent, UINT nId, const TCHAR *registerAdress, int memoryCount); void create (DWORD style, const RECT &rect, CWnd *parent, UINT nId); - void setRegisterAdress (const char *registerAdress); + void setRegisterAdress (const TCHAR *registerAdress); void clearCommand (); void addCommand (const char* commandLabel, uint commandId); void clearStaticStrings (); @@ -59,7 +59,7 @@ public: bool isWnd (const CWnd *wnd) const; void enableAutoCompleteExtension (bool enable, const char * ext); - std::string RegisterAdress; + std::tstring RegisterAdress; int MemoryCount; UINT Id; diff --git a/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.cpp b/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.cpp index abb81b933..4577f6de8 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.cpp @@ -98,7 +98,7 @@ void COutputConsoleDlg::outputString (const char *message) { int index = edit->LineIndex(edit->GetLineCount( )-1) + edit->LineLength(edit->GetLineCount( )-1); edit->SetSel (index, index); - edit->ReplaceSel (message); + edit->ReplaceSel (utf8ToTStr(message)); } } diff --git a/code/ryzom/tools/leveldesign/georges_dll/reg_shell_ext.cpp b/code/ryzom/tools/leveldesign/georges_dll/reg_shell_ext.cpp index c92f2be16..bcb01031f 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/reg_shell_ext.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/reg_shell_ext.cpp @@ -21,12 +21,12 @@ using namespace std; using namespace NLMISC; -void deleteKey (HKEY hKey, const char *name) +void deleteKey (HKEY hKey, const TCHAR *name) { HKEY subKey; if (RegOpenKey (hKey, name, &subKey) == ERROR_SUCCESS) { - char subName[512]; + TCHAR subName[512]; while (RegEnumKey (subKey, 0, subName, 512) == ERROR_SUCCESS) { deleteKey (subKey, subName);