mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 11:19:10 +00:00
Convert plLocalizationEditor to use plString.
Required to match previous commits to pfLocalizationMgr and retain functionality.
This commit is contained in:
@ -151,7 +151,7 @@ BOOL CALLBACK plAddElementDlg::IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPAR
|
||||
int index = (int)SendMessage(GetDlgItem(hDlg, IDC_PARENTAGE), CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
|
||||
SendMessage(GetDlgItem(hDlg, IDC_PARENTAGE), CB_GETLBTEXT, (WPARAM)index, (LPARAM)buff);
|
||||
|
||||
pthis->fAgeName = buff;
|
||||
pthis->fAgeName = plString::FromWchar(buff);
|
||||
pthis->fAgeChanged = true;
|
||||
pthis->IUpdateDlg(hDlg);
|
||||
}
|
||||
@ -160,7 +160,7 @@ BOOL CALLBACK plAddElementDlg::IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPAR
|
||||
wchar_t buff[256];
|
||||
GetDlgItemTextW(hDlg, IDC_PARENTAGE, buff, 256);
|
||||
|
||||
pthis->fAgeName = buff;
|
||||
pthis->fAgeName = plString::FromWchar(buff);
|
||||
pthis->fAgeChanged = true;
|
||||
pthis->IUpdateDlg(hDlg, false);
|
||||
}
|
||||
@ -171,7 +171,7 @@ BOOL CALLBACK plAddElementDlg::IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPAR
|
||||
int index = (int)SendMessage(GetDlgItem(hDlg, IDC_PARENTSET), CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
|
||||
SendMessage(GetDlgItem(hDlg, IDC_PARENTSET), CB_GETLBTEXT, (WPARAM)index, (LPARAM)buff);
|
||||
|
||||
pthis->fSetName = buff;
|
||||
pthis->fSetName = plString::FromWchar(buff);
|
||||
pthis->IUpdateDlg(hDlg);
|
||||
}
|
||||
else if (HIWORD(wParam) == CBN_EDITCHANGE && LOWORD(wParam) == IDC_PARENTSET)
|
||||
@ -179,14 +179,14 @@ BOOL CALLBACK plAddElementDlg::IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPAR
|
||||
wchar_t buff[256];
|
||||
GetDlgItemTextW(hDlg, IDC_PARENTSET, buff, 256);
|
||||
|
||||
pthis->fSetName = buff;
|
||||
pthis->fSetName = plString::FromWchar(buff);
|
||||
pthis->IUpdateDlg(hDlg, false);
|
||||
}
|
||||
else if (HIWORD(wParam) == EN_UPDATE && LOWORD(wParam) == IDC_ELEMENTNAME)
|
||||
{
|
||||
wchar_t buff[256];
|
||||
GetDlgItemTextW(hDlg, IDC_ELEMENTNAME, buff, 256);
|
||||
pthis->fElementName = buff;
|
||||
pthis->fElementName = plString::FromWchar(buff);
|
||||
|
||||
pthis->IUpdateDlg(hDlg);
|
||||
}
|
||||
@ -207,7 +207,7 @@ BOOL CALLBACK plAddElementDlg::IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPAR
|
||||
bool plAddElementDlg::IInitDlg(HWND hDlg)
|
||||
{
|
||||
HWND listCtrl = GetDlgItem(hDlg, IDC_PARENTAGE);
|
||||
std::vector<std::wstring> ageNames = pfLocalizationDataMgr::Instance().GetAgeList();
|
||||
std::vector<plString> ageNames = pfLocalizationDataMgr::Instance().GetAgeList();
|
||||
|
||||
// add the age names to the list
|
||||
for (int i = 0; i < ageNames.size(); i++)
|
||||
@ -229,15 +229,15 @@ bool plAddElementDlg::IInitDlg(HWND hDlg)
|
||||
|
||||
void plAddElementDlg::IUpdateDlg(HWND hDlg, bool setFocus)
|
||||
{
|
||||
std::wstring pathStr = L"Path: " + fAgeName + L"." + fSetName + L"." + fElementName;
|
||||
SetDlgItemTextW(hDlg, IDC_PATH, pathStr.c_str());
|
||||
plString pathStr = plString::Format("Path: %s.%s.%s", fAgeName.c_str(), fSetName.c_str(), fElementName.c_str());
|
||||
SetDlgItemTextW(hDlg, IDC_PATH, pathStr.ToWchar());
|
||||
|
||||
if (fAgeChanged) // we only update this if the age changed (saves time and prevents weird bugs, like typing backwards)
|
||||
{
|
||||
// now add the sets
|
||||
HWND listCtrl = GetDlgItem(hDlg, IDC_PARENTSET);
|
||||
SendMessage(listCtrl, CB_RESETCONTENT, (WPARAM)0, (LPARAM)0);
|
||||
std::vector<std::wstring> setNames = pfLocalizationDataMgr::Instance().GetSetList(fAgeName);
|
||||
std::vector<plString> setNames = pfLocalizationDataMgr::Instance().GetSetList(fAgeName);
|
||||
|
||||
// add the set names to the list
|
||||
for (int i = 0; i < setNames.size(); i++)
|
||||
@ -246,24 +246,24 @@ void plAddElementDlg::IUpdateDlg(HWND hDlg, bool setFocus)
|
||||
// select the set we currently have
|
||||
int ret = (int)SendMessage(listCtrl, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)fSetName.c_str());
|
||||
if (ret == CB_ERR) // couldn't find the string, so just set it as the current string in the edit box
|
||||
SetDlgItemTextW(hDlg, IDC_PARENTSET, fSetName.c_str());
|
||||
SetDlgItemTextW(hDlg, IDC_PARENTSET, fSetName.ToWchar());
|
||||
|
||||
fAgeChanged = false;
|
||||
}
|
||||
|
||||
if (fSetName != L"" && setFocus)
|
||||
if (!fSetName.IsEmpty() && setFocus)
|
||||
SetFocus(GetDlgItem(hDlg, IDC_ELEMENTNAME));
|
||||
|
||||
if (fSetName != L"" && fElementName != L"")
|
||||
if (!fSetName.IsEmpty() && fElementName.IsEmpty())
|
||||
EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
|
||||
else
|
||||
EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);
|
||||
}
|
||||
|
||||
plAddElementDlg::plAddElementDlg(std::wstring parentPath)
|
||||
plAddElementDlg::plAddElementDlg(plString parentPath)
|
||||
{
|
||||
// throw away vars
|
||||
std::wstring element, lang;
|
||||
plString element, lang;
|
||||
|
||||
SplitLocalizationPath(parentPath, fAgeName, fSetName, element, lang);
|
||||
}
|
||||
@ -309,7 +309,7 @@ BOOL CALLBACK plAddLocalizationDlg::IDlgProc(HWND hDlg, UINT msg, WPARAM wParam,
|
||||
int index = (int)SendMessage(GetDlgItem(hDlg, IDC_LANGUAGE), CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
|
||||
SendMessage(GetDlgItem(hDlg, IDC_LANGUAGE), CB_GETLBTEXT, (WPARAM)index, (LPARAM)buff);
|
||||
|
||||
pthis->fLanguageName = buff;
|
||||
pthis->fLanguageName = plString::FromWchar(buff);
|
||||
pthis->IUpdateDlg(hDlg);
|
||||
}
|
||||
break;
|
||||
@ -326,16 +326,16 @@ BOOL CALLBACK plAddLocalizationDlg::IDlgProc(HWND hDlg, UINT msg, WPARAM wParam,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
std::vector<std::wstring> IGetAllLanguageNames()
|
||||
std::vector<plString> IGetAllLanguageNames()
|
||||
{
|
||||
int numLocales = plLocalization::GetNumLocales();
|
||||
std::vector<std::wstring> retVal;
|
||||
std::vector<plString> retVal;
|
||||
|
||||
for (int curLocale = 0; curLocale <= numLocales; curLocale++)
|
||||
{
|
||||
const char *name = plLocalization::GetLanguageName((plLocalization::Language)curLocale);
|
||||
wchar_t *wName = hsStringToWString(name);
|
||||
retVal.push_back(wName);
|
||||
retVal.push_back(plString::FromWchar(wName));
|
||||
delete [] wName;
|
||||
}
|
||||
|
||||
@ -344,13 +344,13 @@ std::vector<std::wstring> IGetAllLanguageNames()
|
||||
|
||||
bool plAddLocalizationDlg::IInitDlg(HWND hDlg)
|
||||
{
|
||||
std::wstring pathStr = L"Path: " + fAgeName + L"." + fSetName + L"." + fElementName;
|
||||
SetDlgItemTextW(hDlg, IDC_PATH, pathStr.c_str());
|
||||
plString pathStr = plString::Format("Path: %s.%s.%s", fAgeName.c_str(), fSetName.c_str(), fElementName.c_str());
|
||||
SetDlgItemTextW(hDlg, IDC_PATH, pathStr.ToWchar());
|
||||
|
||||
std::vector<std::wstring> existingLanguages;
|
||||
std::vector<plString> existingLanguages;
|
||||
existingLanguages = pfLocalizationDataMgr::Instance().GetLanguages(fAgeName, fSetName, fElementName);
|
||||
|
||||
std::vector<std::wstring> missingLanguages = IGetAllLanguageNames();
|
||||
std::vector<plString> missingLanguages = IGetAllLanguageNames();
|
||||
for (int i = 0; i < existingLanguages.size(); i++) // remove all languages we already have
|
||||
{
|
||||
for (int j = 0; j < missingLanguages.size(); j++)
|
||||
@ -382,7 +382,7 @@ bool plAddLocalizationDlg::IInitDlg(HWND hDlg)
|
||||
// and put it's value into the internal variable
|
||||
wchar_t buff[256];
|
||||
GetDlgItemText(hDlg, IDC_LANGUAGE, buff, 256);
|
||||
fLanguageName = buff;
|
||||
fLanguageName = plString::FromWchar(buff);
|
||||
|
||||
IUpdateDlg(hDlg);
|
||||
return true;
|
||||
@ -390,16 +390,16 @@ bool plAddLocalizationDlg::IInitDlg(HWND hDlg)
|
||||
|
||||
void plAddLocalizationDlg::IUpdateDlg(HWND hDlg)
|
||||
{
|
||||
if (fLanguageName != L"")
|
||||
if (!fLanguageName.IsEmpty())
|
||||
EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
|
||||
else
|
||||
EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);
|
||||
}
|
||||
|
||||
plAddLocalizationDlg::plAddLocalizationDlg(std::wstring parentPath)
|
||||
plAddLocalizationDlg::plAddLocalizationDlg(plString parentPath)
|
||||
{
|
||||
// throw away vars
|
||||
std::wstring lang;
|
||||
plString lang;
|
||||
|
||||
SplitLocalizationPath(parentPath, fAgeName, fSetName, fElementName, lang);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#include "HeadSpin.h"
|
||||
#include "hsWindows.h"
|
||||
#include <string>
|
||||
#include "plString.h"
|
||||
|
||||
class plAddElementDlg
|
||||
{
|
||||
@ -55,13 +55,13 @@ protected:
|
||||
bool IInitDlg(HWND hDlg);
|
||||
void IUpdateDlg(HWND hDlg, bool setFocus = true);
|
||||
|
||||
std::wstring fAgeName, fSetName, fElementName;
|
||||
plString fAgeName, fSetName, fElementName;
|
||||
bool fAgeChanged;
|
||||
public:
|
||||
plAddElementDlg(std::wstring parentPath);
|
||||
plAddElementDlg(plString parentPath);
|
||||
|
||||
bool DoPick(HWND parent); // returns true if [Ok] clicked, false otherwise.
|
||||
std::wstring GetValue() {return fAgeName + L"." + fSetName + L"." + fElementName;}
|
||||
plString GetValue() {return plString::Format("%s.%s.%s", fAgeName.c_str(), fSetName.c_str(), fElementName.c_str());}
|
||||
};
|
||||
|
||||
class plAddLocalizationDlg
|
||||
@ -72,12 +72,12 @@ protected:
|
||||
bool IInitDlg(HWND hDlg);
|
||||
void IUpdateDlg(HWND hDlg);
|
||||
|
||||
std::wstring fAgeName, fSetName, fElementName, fLanguageName;
|
||||
plString fAgeName, fSetName, fElementName, fLanguageName;
|
||||
public:
|
||||
plAddLocalizationDlg(std::wstring parentPath);
|
||||
plAddLocalizationDlg(plString parentPath);
|
||||
|
||||
bool DoPick(HWND parent); // returns true if [Ok] clicked, false otherwise.
|
||||
std::wstring GetValue() {return fLanguageName;}
|
||||
plString GetValue() {return fLanguageName;}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -45,7 +45,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plLocTreeView.h"
|
||||
#include "plAddDlgs.h"
|
||||
|
||||
|
||||
#include "pfLocalizationMgr/pfLocalizationDataMgr.h"
|
||||
|
||||
#include <map>
|
||||
@ -55,64 +54,40 @@ extern HINSTANCE gInstance;
|
||||
extern HWND gTreeView;
|
||||
|
||||
// global data for this dialog
|
||||
std::wstring gCurrentPath = L"";
|
||||
plString gCurrentPath;
|
||||
|
||||
// split a subtitle path up into its component parts
|
||||
void SplitLocalizationPath(std::wstring path, std::wstring &ageName, std::wstring &setName, std::wstring &locName, std::wstring &locLanguage)
|
||||
void SplitLocalizationPath(plString path, plString &ageName, plString &setName, plString &locName, plString &locLanguage)
|
||||
{
|
||||
ageName = setName = locName = locLanguage = L"";
|
||||
ageName = setName = locName = locLanguage = "";
|
||||
|
||||
std::wstring::size_type lastPos = 0, curPos = 0;
|
||||
// separate the age name out
|
||||
curPos = path.find(L".");
|
||||
if (curPos == std::wstring::npos)
|
||||
{
|
||||
ageName = path;
|
||||
return;
|
||||
}
|
||||
ageName = path.substr(0, curPos);
|
||||
path = path.substr(curPos + 1, path.length());
|
||||
|
||||
// separate the set name out
|
||||
curPos = path.find(L".");
|
||||
if (curPos == std::wstring::npos)
|
||||
{
|
||||
setName = path;
|
||||
return;
|
||||
}
|
||||
setName = path.substr(0, curPos);
|
||||
path = path.substr(curPos + 1, path.length());
|
||||
|
||||
// separate the element out
|
||||
curPos = path.find(L".");
|
||||
if (curPos == std::wstring::npos)
|
||||
{
|
||||
locName = path;
|
||||
return;
|
||||
}
|
||||
locName = path.substr(0, curPos);
|
||||
path = path.substr(curPos + 1, path.length());
|
||||
|
||||
// what's left is the language
|
||||
locLanguage = path;
|
||||
std::vector<plString> tokens = path.Tokenize(".");
|
||||
if (tokens.size() >= 1)
|
||||
ageName = tokens[0];
|
||||
if (tokens.size() >= 2)
|
||||
setName = tokens[1];
|
||||
if (tokens.size() >= 3)
|
||||
locName = tokens[2];
|
||||
if (tokens.size() >= 4)
|
||||
locLanguage = tokens[3];
|
||||
}
|
||||
|
||||
// saves the current localization text to the data manager
|
||||
void SaveLocalizationText()
|
||||
{
|
||||
if (gCurrentPath == L"")
|
||||
if (gCurrentPath.IsEmpty())
|
||||
return; // no path to save
|
||||
|
||||
uint32_t textLen = (uint32_t)SendMessage(GetDlgItem(gEditDlg, IDC_LOCALIZATIONTEXT), WM_GETTEXTLENGTH, (WPARAM)0, (LPARAM)0);
|
||||
wchar_t *buffer = new wchar_t[textLen + 2];
|
||||
GetDlgItemTextW(gEditDlg, IDC_LOCALIZATIONTEXT, buffer, textLen + 1);
|
||||
buffer[textLen + 1] = 0;
|
||||
std::wstring plainTextData = buffer;
|
||||
plString plainTextData = plString::FromWchar(buffer);
|
||||
delete [] buffer;
|
||||
std::wstring ageName, setName, elementName, elementLanguage;
|
||||
plString ageName, setName, elementName, elementLanguage;
|
||||
SplitLocalizationPath(gCurrentPath, ageName, setName, elementName, elementLanguage);
|
||||
|
||||
std::wstring name = ageName + L"." + setName + L"." + elementName;
|
||||
plString name = plString::Format("%s.%s.%s", ageName.c_str(), setName.c_str(), elementName.c_str());
|
||||
pfLocalizationDataMgr::Instance().SetElementPlainTextData(name, elementLanguage, plainTextData);
|
||||
}
|
||||
|
||||
@ -132,38 +107,37 @@ void EnableDlg(BOOL enable)
|
||||
}
|
||||
|
||||
// updates the edit dialog based on the path specified
|
||||
void UpdateEditDlg(std::wstring locPath)
|
||||
void UpdateEditDlg(plString locPath)
|
||||
{
|
||||
if (locPath == gCurrentPath)
|
||||
return;
|
||||
|
||||
gCurrentPath = locPath;
|
||||
|
||||
std::wstring itemText = L"Text (";
|
||||
itemText += locPath + L"):";
|
||||
SetDlgItemTextW(gEditDlg, IDC_LOCPATH, itemText.c_str());
|
||||
plString itemText = plString::Format("Text (%s):", locPath.c_str());
|
||||
SetDlgItemTextW(gEditDlg, IDC_LOCPATH, itemText.ToWchar());
|
||||
|
||||
std::wstring ageName = L"", setName = L"", elementName = L"", elementLanguage = L"";
|
||||
plString ageName, setName, elementName, elementLanguage;
|
||||
SplitLocalizationPath(locPath, ageName, setName, elementName, elementLanguage);
|
||||
|
||||
// now make sure they've drilled down deep enough to enable the dialog
|
||||
if (elementLanguage == L"") // not deep enough
|
||||
if (elementLanguage.IsEmpty()) // not deep enough
|
||||
EnableDlg(FALSE);
|
||||
else
|
||||
{
|
||||
EnableDlg(TRUE);
|
||||
std::wstring key = ageName + L"." + setName + L"." + elementName;
|
||||
std::wstring elementText = pfLocalizationDataMgr::Instance().GetElementPlainTextData(key, elementLanguage);
|
||||
SetDlgItemTextW(gEditDlg, IDC_LOCALIZATIONTEXT, elementText.c_str());
|
||||
plString key = plString::Format("%s.%s.%s", ageName.c_str(), setName.c_str(), elementName.c_str());
|
||||
plString elementText = pfLocalizationDataMgr::Instance().GetElementPlainTextData(key, elementLanguage);
|
||||
SetDlgItemTextW(gEditDlg, IDC_LOCALIZATIONTEXT, elementText.ToWchar());
|
||||
}
|
||||
|
||||
// now to setup the add/delete buttons
|
||||
if (elementLanguage != L"") // they have selected a language
|
||||
if (!elementLanguage.IsEmpty()) // they have selected a language
|
||||
{
|
||||
SetDlgItemText(gEditDlg, IDC_ADD, L"Add Localization");
|
||||
EnableWindow(GetDlgItem(gEditDlg, IDC_ADD), TRUE);
|
||||
SetDlgItemText(gEditDlg, IDC_DELETE, L"Delete Localization");
|
||||
if (elementLanguage != L"English") // don't allow them to delete the default language
|
||||
if (elementLanguage != "English") // don't allow them to delete the default language
|
||||
EnableWindow(GetDlgItem(gEditDlg, IDC_DELETE), TRUE);
|
||||
else
|
||||
EnableWindow(GetDlgItem(gEditDlg, IDC_DELETE), FALSE);
|
||||
@ -173,9 +147,9 @@ void UpdateEditDlg(std::wstring locPath)
|
||||
SetDlgItemText(gEditDlg, IDC_ADD, L"Add Element");
|
||||
EnableWindow(GetDlgItem(gEditDlg, IDC_ADD), TRUE);
|
||||
SetDlgItemText(gEditDlg, IDC_DELETE, L"Delete Element");
|
||||
if (elementName != L"") // the have selected an individual element
|
||||
if (!elementName.IsEmpty()) // they have selected an individual element
|
||||
{
|
||||
std::vector<std::wstring> elementNames = pfLocalizationDataMgr::Instance().GetElementList(ageName, setName);
|
||||
std::vector<plString> elementNames = pfLocalizationDataMgr::Instance().GetElementList(ageName, setName);
|
||||
if (elementNames.size() > 1) // they can't delete the only subtitle in a set
|
||||
EnableWindow(GetDlgItem(gEditDlg, IDC_DELETE), TRUE);
|
||||
else
|
||||
@ -201,43 +175,43 @@ BOOL HandleCommandMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
SaveLocalizationText(); // save any current changes to the database
|
||||
|
||||
std::wstring buttonText;
|
||||
plString buttonText;
|
||||
wchar_t buff[256];
|
||||
GetDlgItemText(gEditDlg, IDC_ADD, buff, 256);
|
||||
buttonText = buff;
|
||||
buttonText = plString::FromWchar(buff);
|
||||
|
||||
if (buttonText == L"Add Element")
|
||||
if (buttonText == "Add Element")
|
||||
{
|
||||
plAddElementDlg dlg(gCurrentPath);
|
||||
if (dlg.DoPick(gEditDlg))
|
||||
{
|
||||
std::wstring path = dlg.GetValue(); // path is age.set.name
|
||||
plString path = dlg.GetValue(); // path is age.set.name
|
||||
if (!pfLocalizationDataMgr::Instance().AddElement(path))
|
||||
MessageBox(gEditDlg, L"Couldn't add new element because one already exists with that name!", L"Error", MB_ICONERROR | MB_OK);
|
||||
else
|
||||
{
|
||||
gCurrentPath = L"";
|
||||
gCurrentPath = "";
|
||||
plLocTreeView::ClearTreeView(gTreeView);
|
||||
plLocTreeView::FillTreeViewFromData(gTreeView, path);
|
||||
UpdateEditDlg(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (buttonText == L"Add Localization")
|
||||
else if (buttonText == "Add Localization")
|
||||
{
|
||||
plAddLocalizationDlg dlg(gCurrentPath);
|
||||
if (dlg.DoPick(gEditDlg))
|
||||
{
|
||||
std::wstring newLanguage = dlg.GetValue();
|
||||
std::wstring ageName, setName, elementName, elementLanguage;
|
||||
plString newLanguage = dlg.GetValue();
|
||||
plString ageName, setName, elementName, elementLanguage;
|
||||
SplitLocalizationPath(gCurrentPath, ageName, setName, elementName, elementLanguage);
|
||||
std::wstring key = ageName + L"." + setName + L"." + elementName;
|
||||
plString key = plString::Format("%s.%s.%s", ageName.c_str(), setName.c_str(), elementName.c_str());
|
||||
if (!pfLocalizationDataMgr::Instance().AddLocalization(key, newLanguage))
|
||||
MessageBox(gEditDlg, L"Couldn't add additional localization!", L"Error", MB_ICONERROR | MB_OK);
|
||||
else
|
||||
{
|
||||
std::wstring path = key + L"." + newLanguage; // select the new language
|
||||
gCurrentPath = L"";
|
||||
plString path = plString::Format("%s.%s", key.c_str(), newLanguage.c_str());
|
||||
gCurrentPath = "";
|
||||
plLocTreeView::ClearTreeView(gTreeView);
|
||||
plLocTreeView::FillTreeViewFromData(gTreeView, path);
|
||||
UpdateEditDlg(path);
|
||||
@ -250,39 +224,39 @@ BOOL HandleCommandMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
SaveLocalizationText(); // save any current changes to the database
|
||||
|
||||
std::wstring messageText = L"Are you sure that you want to delete " + gCurrentPath + L"?";
|
||||
int res = MessageBoxW(gEditDlg, messageText.c_str(), L"Delete", MB_ICONQUESTION | MB_YESNO);
|
||||
plString messageText = plString::Format("Are you sure that you want to delete %s?", gCurrentPath.c_str());
|
||||
int res = MessageBoxW(gEditDlg, messageText.ToWchar(), L"Delete", MB_ICONQUESTION | MB_YESNO);
|
||||
if (res == IDYES)
|
||||
{
|
||||
std::wstring buttonText;
|
||||
plString buttonText;
|
||||
wchar_t buff[256];
|
||||
GetDlgItemText(gEditDlg, IDC_DELETE, buff, 256);
|
||||
buttonText = buff;
|
||||
buttonText = plString::FromWchar(buff);
|
||||
|
||||
if (buttonText == L"Delete Element")
|
||||
if (buttonText == "Delete Element")
|
||||
{
|
||||
if (!pfLocalizationDataMgr::Instance().DeleteElement(gCurrentPath))
|
||||
MessageBox(gEditDlg, L"Couldn't delete element!", L"Error", MB_ICONERROR | MB_OK);
|
||||
else
|
||||
{
|
||||
std::wstring path = gCurrentPath;
|
||||
gCurrentPath = L"";
|
||||
plString path = gCurrentPath;
|
||||
gCurrentPath = "";
|
||||
plLocTreeView::ClearTreeView(gTreeView);
|
||||
plLocTreeView::FillTreeViewFromData(gTreeView, path);
|
||||
UpdateEditDlg(path);
|
||||
}
|
||||
}
|
||||
else if (buttonText == L"Delete Localization")
|
||||
else if (buttonText == "Delete Localization")
|
||||
{
|
||||
std::wstring ageName, setName, elementName, elementLanguage;
|
||||
plString ageName, setName, elementName, elementLanguage;
|
||||
SplitLocalizationPath(gCurrentPath, ageName, setName, elementName, elementLanguage);
|
||||
std::wstring key = ageName + L"." + setName + L"." + elementName;
|
||||
plString key = plString::Format("%s.%s.%s", ageName.c_str(), setName.c_str(), elementName.c_str());
|
||||
if (!pfLocalizationDataMgr::Instance().DeleteLocalization(key, elementLanguage))
|
||||
MessageBox(gEditDlg, L"Couldn't delete localization!", L"Error", MB_ICONERROR | MB_OK);
|
||||
else
|
||||
{
|
||||
std::wstring path = gCurrentPath;
|
||||
gCurrentPath = L"";
|
||||
plString path = gCurrentPath;
|
||||
gCurrentPath = "";
|
||||
plLocTreeView::ClearTreeView(gTreeView);
|
||||
plLocTreeView::FillTreeViewFromData(gTreeView, path);
|
||||
UpdateEditDlg(path);
|
||||
|
@ -45,7 +45,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#include "HeadSpin.h"
|
||||
#include "hsWindows.h"
|
||||
#include <string>
|
||||
|
||||
class plString;
|
||||
|
||||
// Little trick to show a wait cursor while something is working
|
||||
class plWaitCursor
|
||||
@ -63,9 +64,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void SplitLocalizationPath(std::wstring path, std::wstring &ageName, std::wstring &setName, std::wstring &locName, std::wstring &locLanguage);
|
||||
void SplitLocalizationPath(plString path, plString &ageName, plString &setName, plString &locName, plString &locLanguage);
|
||||
void SaveLocalizationText();
|
||||
void UpdateEditDlg(std::wstring subtitlePath);
|
||||
void UpdateEditDlg(plString subtitlePath);
|
||||
BOOL CALLBACK EditDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
#endif
|
||||
|
@ -48,22 +48,26 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "res\resource.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "pfLocalizationMgr/pfLocalizationDataMgr.h"
|
||||
|
||||
extern HINSTANCE gInstance;
|
||||
|
||||
std::wstring plLocTreeView::fPath = L"";
|
||||
plString plLocTreeView::fPath = "";
|
||||
|
||||
HTREEITEM AddLeaf(HWND hTree, HTREEITEM hParent, std::wstring text, bool sort = true)
|
||||
HTREEITEM AddLeaf(HWND hTree, HTREEITEM hParent, plString text, bool sort = true)
|
||||
{
|
||||
// Semi-hack to keep these around as Win32 expects
|
||||
static std::list<plStringBuffer<wchar_t>> bufs;
|
||||
plStringBuffer<wchar_t> buf = text.ToWchar();
|
||||
bufs.push_back(buf);
|
||||
|
||||
TVITEM tvi = {0};
|
||||
tvi.mask = TVIF_TEXT | TVIF_PARAM;
|
||||
tvi.pszText = (wchar_t*)text.c_str();
|
||||
tvi.cchTextMax = (int)text.length();
|
||||
tvi.lParam = NULL;
|
||||
tvi.mask = TVIF_TEXT | TVIF_PARAM;
|
||||
tvi.pszText = const_cast<LPWSTR>(buf.GetData());
|
||||
tvi.cchTextMax = static_cast<int>(text.GetSize());
|
||||
tvi.lParam = NULL;
|
||||
|
||||
TVINSERTSTRUCT tvins = {0};
|
||||
tvins.item = tvi;
|
||||
@ -76,15 +80,15 @@ HTREEITEM AddLeaf(HWND hTree, HTREEITEM hParent, std::wstring text, bool sort =
|
||||
return TreeView_InsertItem(hTree, &tvins);
|
||||
}
|
||||
|
||||
void plLocTreeView::FillTreeViewFromData(HWND treeCtrl, std::wstring selectionPath)
|
||||
void plLocTreeView::FillTreeViewFromData(HWND treeCtrl, plString selectionPath)
|
||||
{
|
||||
std::wstring targetAge, targetSet, targetElement, targetLang;
|
||||
plString targetAge, targetSet, targetElement, targetLang;
|
||||
SplitLocalizationPath(selectionPath, targetAge, targetSet, targetElement, targetLang);
|
||||
bool ageMatched = false;
|
||||
bool setMatched = false;
|
||||
bool elementMatched = false;
|
||||
|
||||
std::vector<std::wstring> ages = pfLocalizationDataMgr::Instance().GetAgeList();
|
||||
std::vector<plString> ages = pfLocalizationDataMgr::Instance().GetAgeList();
|
||||
for (int curAge = 0; curAge < ages.size(); curAge++)
|
||||
{
|
||||
// add the age to the tree
|
||||
@ -99,10 +103,10 @@ void plLocTreeView::FillTreeViewFromData(HWND treeCtrl, std::wstring selectionPa
|
||||
else
|
||||
ageMatched = false;
|
||||
|
||||
std::vector<std::wstring> sets = pfLocalizationDataMgr::Instance().GetSetList(ages[curAge]);
|
||||
std::vector<plString> sets = pfLocalizationDataMgr::Instance().GetSetList(ages[curAge]);
|
||||
for (int curSet = 0; curSet < sets.size(); curSet++)
|
||||
{
|
||||
std::vector<std::wstring> elements = pfLocalizationDataMgr::Instance().GetElementList(ages[curAge], sets[curSet]);
|
||||
std::vector<plString> elements = pfLocalizationDataMgr::Instance().GetElementList(ages[curAge], sets[curSet]);
|
||||
|
||||
HTREEITEM setItem = AddLeaf(treeCtrl, ageItem, sets[curSet]);
|
||||
|
||||
@ -125,13 +129,13 @@ void plLocTreeView::FillTreeViewFromData(HWND treeCtrl, std::wstring selectionPa
|
||||
TreeView_EnsureVisible(treeCtrl, subItem);
|
||||
elementMatched = true;
|
||||
|
||||
if (targetLang.empty())
|
||||
targetLang = L"English";
|
||||
if (targetLang.IsEmpty())
|
||||
targetLang = "English";
|
||||
}
|
||||
else
|
||||
elementMatched = false;
|
||||
|
||||
std::vector<std::wstring> languages = pfLocalizationDataMgr::Instance().GetLanguages(ages[curAge], sets[curSet], elements[curElement]);
|
||||
std::vector<plString> languages = pfLocalizationDataMgr::Instance().GetLanguages(ages[curAge], sets[curSet], elements[curElement]);
|
||||
for (int curLang = 0; curLang < languages.size(); curLang++)
|
||||
{
|
||||
HTREEITEM langItem = AddLeaf(treeCtrl, subItem, languages[curLang]);
|
||||
@ -155,8 +159,8 @@ void plLocTreeView::ClearTreeView(HWND treeCtrl)
|
||||
void plLocTreeView::SelectionChanged(HWND treeCtrl)
|
||||
{
|
||||
HTREEITEM hItem = TreeView_GetSelection(treeCtrl);
|
||||
std::vector<std::wstring> path;
|
||||
fPath = L"";
|
||||
std::vector<plString> path;
|
||||
fPath = "";
|
||||
|
||||
while (hItem)
|
||||
{
|
||||
@ -167,7 +171,7 @@ void plLocTreeView::SelectionChanged(HWND treeCtrl)
|
||||
tvi.pszText = s;
|
||||
tvi.cchTextMax = 200;
|
||||
TreeView_GetItem(treeCtrl, &tvi);
|
||||
path.push_back(tvi.pszText);
|
||||
path.push_back(plString::FromWchar(tvi.pszText));
|
||||
hItem = TreeView_GetParent(treeCtrl, hItem);
|
||||
}
|
||||
|
||||
@ -177,15 +181,15 @@ void plLocTreeView::SelectionChanged(HWND treeCtrl)
|
||||
|
||||
path.pop_back();
|
||||
if (!path.empty())
|
||||
fPath += L".";
|
||||
fPath += ".";
|
||||
}
|
||||
}
|
||||
|
||||
void plLocTreeView::SelectionDblClicked(HWND treeCtrl)
|
||||
{
|
||||
HTREEITEM hItem = TreeView_GetSelection(treeCtrl);
|
||||
std::vector<std::wstring> path;
|
||||
fPath = L"";
|
||||
std::vector<plString> path;
|
||||
fPath = "";
|
||||
|
||||
while (hItem)
|
||||
{
|
||||
@ -196,7 +200,7 @@ void plLocTreeView::SelectionDblClicked(HWND treeCtrl)
|
||||
tvi.pszText = s;
|
||||
tvi.cchTextMax = 200;
|
||||
TreeView_GetItem(treeCtrl, &tvi);
|
||||
path.push_back(tvi.pszText);
|
||||
path.push_back(plString::FromWchar(tvi.pszText));
|
||||
hItem = TreeView_GetParent(treeCtrl, hItem);
|
||||
}
|
||||
|
||||
@ -206,6 +210,6 @@ void plLocTreeView::SelectionDblClicked(HWND treeCtrl)
|
||||
|
||||
path.pop_back();
|
||||
if (!path.empty())
|
||||
fPath += L".";
|
||||
fPath += ".";
|
||||
}
|
||||
}
|
||||
|
@ -43,21 +43,21 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#define _plLocTreeView_h
|
||||
|
||||
#include "HeadSpin.h"
|
||||
#include <string>
|
||||
#include "plString.h"
|
||||
|
||||
class plLocTreeView
|
||||
{
|
||||
protected:
|
||||
static std::wstring fPath;
|
||||
static plString fPath;
|
||||
|
||||
public:
|
||||
static void FillTreeViewFromData(HWND treeCtrl, std::wstring selectionPath);
|
||||
static void FillTreeViewFromData(HWND treeCtrl, plString selectionPath);
|
||||
static void ClearTreeView(HWND treeCtrl);
|
||||
|
||||
static void SelectionChanged(HWND treeCtrl);
|
||||
static void SelectionDblClicked(HWND treeCtrl);
|
||||
|
||||
static std::wstring GetPath() {return fPath;}
|
||||
static plString GetPath() {return fPath;}
|
||||
};
|
||||
|
||||
#endif //_plLocTreeView_h
|
||||
|
@ -223,7 +223,7 @@ LRESULT CALLBACK HandleCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
bInfo.pidlRoot = NULL;
|
||||
bInfo.pszDisplayName = path;
|
||||
bInfo.lpszTitle = L"Select a localization data directory:";
|
||||
bInfo.ulFlags = BIF_EDITBOX;
|
||||
bInfo.ulFlags = BIF_USENEWUI | BIF_VALIDATE | BIF_RETURNONLYFSDIRS | BIF_NONEWFOLDERBUTTON;
|
||||
|
||||
itemList = SHBrowseForFolder(&bInfo);
|
||||
if (itemList != NULL)
|
||||
@ -242,7 +242,7 @@ LRESULT CALLBACK HandleCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
delete [] sPath;
|
||||
|
||||
plLocTreeView::ClearTreeView(gTreeView);
|
||||
plLocTreeView::FillTreeViewFromData(gTreeView, L"");
|
||||
plLocTreeView::FillTreeViewFromData(gTreeView, "");
|
||||
|
||||
gCurPath = path;
|
||||
SetWindowTitle(hWnd, path);
|
||||
|
Reference in New Issue
Block a user