diff --git a/projects/msvc/GLideNUI-wtl.vcxproj b/projects/msvc/GLideNUI-wtl.vcxproj
index bbab6992..48ce833d 100644
--- a/projects/msvc/GLideNUI-wtl.vcxproj
+++ b/projects/msvc/GLideNUI-wtl.vcxproj
@@ -101,6 +101,7 @@
+
@@ -126,6 +127,7 @@
+
diff --git a/projects/msvc/GLideNUI-wtl.vcxproj.filters b/projects/msvc/GLideNUI-wtl.vcxproj.filters
index 5ebd721c..4c440904 100644
--- a/projects/msvc/GLideNUI-wtl.vcxproj.filters
+++ b/projects/msvc/GLideNUI-wtl.vcxproj.filters
@@ -87,6 +87,9 @@
Source Files
+
+ Source Files
+
@@ -230,6 +233,9 @@
Header Files\WTL
+
+ Header Files
+
@@ -265,9 +271,6 @@
Resource Files
-
- Resource Files
-
Resource Files
@@ -298,6 +301,12 @@
Resource Files
+
+ Resource Files
+
+
+ Resource Files
+
diff --git a/src/GLideNUI-wtl/ConfigDlg.cpp b/src/GLideNUI-wtl/ConfigDlg.cpp
index ab74c364..fb3501b3 100644
--- a/src/GLideNUI-wtl/ConfigDlg.cpp
+++ b/src/GLideNUI-wtl/ConfigDlg.cpp
@@ -10,6 +10,7 @@
#include "config-osd.h"
#include "config-debug.h"
#include "util.h"
+#include "InputDialog.h"
CConfigDlg::CConfigDlg() :
m_blockReInit(false),
@@ -80,14 +81,33 @@ LRESULT CConfigDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lPar
dlgItem.SetWindowText(RomName.c_str());
m_ProfileLeft = Rect.right + 10;
+
+ CButton(GetDlgItem(IDC_GAME_PROFILE)).SetCheck(BST_CHECKED);
+ CButton(GetDlgItem(IDC_USE_PROFILE)).SetCheck(BST_UNCHECKED);
}
else
{
+ CButton(GetDlgItem(IDC_GAME_PROFILE)).SetCheck(BST_UNCHECKED);
+ CButton(GetDlgItem(IDC_USE_PROFILE)).SetCheck(BST_CHECKED);
GetDlgItem(IDC_SETTINGS_PROFILE_STATIC).GetWindowRect(&Rect);
::MapWindowPoints(NULL, m_hWnd, (LPPOINT)&Rect, 2);
m_ProfileLeft = Rect.left;
}
+ ProfileList Profiles = getProfiles(m_strIniPath.c_str());
+ std::string CurrentProfile = getCurrentProfile(m_strIniPath.c_str());
+ CComboBox profilesComboBox(GetDlgItem(IDC_PROFILE));
+ profilesComboBox.ResetContent();
+ for (ProfileList::const_iterator itr = Profiles.begin(); itr != Profiles.end(); itr++)
+ {
+ int Index = profilesComboBox.AddString(ToUTF16(itr->c_str()).c_str());
+ if (CurrentProfile == *itr)
+ {
+ profilesComboBox.SetCurSel(Index);
+ }
+ }
+ profilesComboBox.AddString(L"New...");
+ GetDlgItem(IDC_REMOVE_PROFILE).EnableWindow(profilesComboBox.GetCount() > 2);
Init();
return 0;
}
@@ -159,6 +179,60 @@ void CConfigDlg::OnCustomSettingsToggled(bool checked)
}
}
+LRESULT CConfigDlg::OnProfileChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/)
+{
+ CComboBox profilesComboBox(GetDlgItem(IDC_PROFILE));
+ int nIndex = profilesComboBox.GetCurSel();
+ if (nIndex < 0) { return 0; }
+
+ int nLen = profilesComboBox.GetLBTextLen(nIndex);
+ if (nLen == CB_ERR) { return FALSE; }
+
+ std::wstring Profile;
+ Profile.resize(nLen);
+ profilesComboBox.GetLBText(nIndex, (wchar_t *)Profile.data());
+
+ CButton(GetDlgItem(IDC_USE_PROFILE)).SetCheck(BST_CHECKED);
+ CButton(GetDlgItem(IDC_GAME_PROFILE)).SetCheck(BST_UNCHECKED);
+ if (Profile == L"New...") {
+ bool ok;
+ std::string switchToProfile = getCurrentProfile(m_strIniPath.c_str());
+ std::string newProfile = FromUTF16(CInputDialog::getText(L"New Profile", L"New profile name:", ok).c_str());
+ CComboBox profilesComboBox(GetDlgItem(IDC_PROFILE));
+ if (ok) {
+ ProfileList Profiles = getProfiles(m_strIniPath.c_str());
+ if (strcmp(newProfile.c_str(), "New...") == 0) {
+ MessageBox(L"New settings profiles cannot be called \"New...\".", L"New Profile", MB_OK | MB_ICONWARNING);
+ }
+ else if (newProfile.empty()) {
+ MessageBox(L"Please type a name for your new settings profile.", L"New Profile", MB_OK | MB_ICONWARNING);
+ }
+ else if (Profiles.find(newProfile.c_str()) != Profiles.end()) {
+ MessageBox(L"This settings profile already exists.", L"New Profile", MB_OK | MB_ICONWARNING);
+ } else {
+ profilesComboBox.AddString(ToUTF16(newProfile.c_str()).c_str());
+ addProfile(m_strIniPath.c_str(), newProfile.c_str());
+ GetDlgItem(IDC_REMOVE_PROFILE).EnableWindow(profilesComboBox.GetCount() > 2);
+ switchToProfile = newProfile;
+ }
+ }
+ for (int i = 0, n = profilesComboBox.GetCount(); i < n; ++i) {
+ std::wstring Profile;
+ Profile.resize(profilesComboBox.GetLBTextLen(i) + 1);
+ profilesComboBox.GetLBText(i, (wchar_t *)Profile.data());
+
+ if (strcmp(FromUTF16(Profile.c_str()).c_str(),switchToProfile.c_str()) == 0) {
+ profilesComboBox.SetCurSel(i);
+ break;
+ }
+ }
+ return 0;
+ }
+ changeProfile(m_strIniPath.c_str(), FromUTF16(Profile.c_str()).c_str());
+ Init(true);
+ return 0;
+}
+
void CConfigDlg::SaveSettings()
{
m_Saved = true;
@@ -183,6 +257,66 @@ LRESULT CConfigDlg::OnRestoreDefaults(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /
return 0;
}
+LRESULT CConfigDlg::OnGameProfile(UINT /*Code*/, int /*id*/, HWND /*ctl*/)
+{
+ CButton(GetDlgItem(IDC_USE_PROFILE)).SetCheck(BST_UNCHECKED);
+ Init(true, true);
+ return 0;
+}
+
+LRESULT CConfigDlg::OnUseProfile(UINT /*Code*/, int /*id*/, HWND /*ctl*/)
+{
+ CButton(GetDlgItem(IDC_GAME_PROFILE)).SetCheck(BST_UNCHECKED);
+ Init(true, true);
+ return 0;
+}
+
+LRESULT CConfigDlg::OnRemoveProfile(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+ CComboBox profilesComboBox(GetDlgItem(IDC_PROFILE));
+ if (profilesComboBox.GetCount() <= 2)
+ return 0;
+
+ int nIndex = profilesComboBox.GetCurSel();
+ std::wstring profile;
+ profile.resize(profilesComboBox.GetLBTextLen(nIndex) + 1);
+ profilesComboBox.GetLBText(nIndex, (wchar_t *)profile.data());
+
+ ProfileList Profiles = getProfiles(m_strIniPath.c_str());
+ if (Profiles.find(FromUTF16(profile.c_str()).c_str()) == Profiles.end())
+ return 0;
+
+ std::wstring msg = L"Are you sure you want to remove the settings profile \"";
+ msg += profile.c_str();
+ msg += L"\"?";
+ if (MessageBox(msg.c_str(), L"Remove Profile", MB_YESNO | MB_ICONWARNING) == IDYES) {
+ removeProfile(m_strIniPath.c_str(), FromUTF16(profile.c_str()).c_str());
+ for (int i = 0, n = profilesComboBox.GetCount(); i < n; ++i) {
+ std::wstring ProfileItem;
+ ProfileItem.resize(profilesComboBox.GetLBTextLen(i) + 1);
+ profilesComboBox.GetLBText(i, (wchar_t *)ProfileItem.data());
+
+ if (wcscmp(ProfileItem.c_str(),profile.c_str()) == 0) {
+ profilesComboBox.DeleteString(i);
+ break;
+ }
+ }
+ for (int i = 0, n = profilesComboBox.GetCount(); i < n; ++i) {
+ std::wstring ProfileItem;
+ ProfileItem.resize(profilesComboBox.GetLBTextLen(i) + 1);
+ profilesComboBox.GetLBText(i, (wchar_t *)ProfileItem.data());
+ if (wcscmp(ProfileItem.c_str(),L"New...") != 0) {
+ profilesComboBox.SetCurSel(i);
+ changeProfile(m_strIniPath.c_str(), FromUTF16(ProfileItem.c_str()).c_str());
+ Init(true);
+ break;
+ }
+ }
+ GetDlgItem(IDC_REMOVE_PROFILE).EnableWindow(profilesComboBox.GetCount() > 2);
+ }
+ return 0;
+}
+
LRESULT CConfigDlg::OnSaveClose(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
SaveSettings();
@@ -217,13 +351,12 @@ void CConfigDlg::Init(bool reInit, bool blockCustomSettings)
m_blockReInit = true;
bool CustomSettings = m_EmulationTab != NULL && CButton(m_EmulationTab->GetDlgItem(IDC_CHK_USE_PER_GAME)).GetCheck() == BST_CHECKED;
- /*if (reInit && m_romName != NULL &&
- m_EmulationTab
- ui->customSettingsCheckBox->isChecked() && ui->settingsDestGameRadioButton->isChecked())
+ if (reInit && m_romName != NULL &&
+ CustomSettings && CButton(m_EmulationTab->GetDlgItem(IDC_GAME_PROFILE)).GetCheck() == BST_CHECKED)
{
- loadCustomRomSettings(m_strIniPath, m_romName);
+ loadCustomRomSettings(m_strIniPath.c_str(), m_romName);
}
- else*/ if (reInit)
+ else if (reInit)
{
loadSettings(m_strIniPath.c_str());
}
diff --git a/src/GLideNUI-wtl/ConfigDlg.h b/src/GLideNUI-wtl/ConfigDlg.h
index 6291c557..59e2122f 100644
--- a/src/GLideNUI-wtl/ConfigDlg.h
+++ b/src/GLideNUI-wtl/ConfigDlg.h
@@ -19,6 +19,10 @@ public:
BEGIN_MSG_MAP_EX(CConfigDlg)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
NOTIFY_HANDLER_EX(IDC_TABS, TCN_SELCHANGE, OnTabChange)
+ COMMAND_HANDLER(IDC_PROFILE, CBN_SELCHANGE, OnProfileChanged)
+ COMMAND_HANDLER_EX(IDC_GAME_PROFILE, BN_CLICKED, OnGameProfile)
+ COMMAND_HANDLER_EX(IDC_USE_PROFILE, BN_CLICKED, OnUseProfile)
+ COMMAND_ID_HANDLER(IDC_REMOVE_PROFILE, OnRemoveProfile)
COMMAND_ID_HANDLER(ID_RESTORE_DEFAULTS, OnRestoreDefaults)
COMMAND_ID_HANDLER(ID_SAVECLOSE, OnSaveClose)
COMMAND_ID_HANDLER(ID_SAVE, OnSave)
@@ -32,11 +36,15 @@ public:
protected:
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnRemoveProfile(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnRestoreDefaults(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnSaveClose(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnSave(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnTabChange(NMHDR* pNMHDR);
+ LRESULT OnProfileChanged(WORD wNotifyCode, WORD wID, HWND hwnd, BOOL& bHandled);
+ LRESULT OnGameProfile(UINT /*Code*/, int id, HWND /*ctl*/);
+ LRESULT OnUseProfile(UINT /*Code*/, int id, HWND /*ctl*/);
void Init(bool reInit = false, bool blockCustomSettings = false);
void AddTab(const wchar_t * caption, CConfigTab * tab);
diff --git a/src/GLideNUI-wtl/GLideNUI.rc b/src/GLideNUI-wtl/GLideNUI.rc
index b8f6a29c..55e39e5a 100644
Binary files a/src/GLideNUI-wtl/GLideNUI.rc and b/src/GLideNUI-wtl/GLideNUI.rc differ
diff --git a/src/GLideNUI-wtl/InputDialog.cpp b/src/GLideNUI-wtl/InputDialog.cpp
new file mode 100644
index 00000000..3749ef0a
--- /dev/null
+++ b/src/GLideNUI-wtl/InputDialog.cpp
@@ -0,0 +1,46 @@
+#include "InputDialog.h"
+
+CInputDialog::CInputDialog(wchar_t * DlgTitle, wchar_t * Message, bool & ok) :
+ m_DlgTitle(DlgTitle != NULL ? DlgTitle : L""),
+ m_Message(Message != NULL ? Message : L""),
+ m_ok(ok)
+{
+ m_ok = false;
+}
+
+std::wstring CInputDialog::getText(wchar_t * DlgTitle, wchar_t * Message, bool & ok)
+{
+ CInputDialog Dlg(DlgTitle, Message, ok);
+ Dlg.DoModal();
+ return Dlg.GetInput();
+}
+
+LRESULT CInputDialog::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
+{
+ HICON hIcon = AtlLoadIconImage(IDI_APPICON, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON));
+ SetIcon(hIcon, TRUE);
+ HICON hIconSmall = AtlLoadIconImage(IDI_APPICON, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON));
+ SetIcon(hIconSmall, FALSE);
+
+ SetWindowText(m_DlgTitle.c_str());
+ GetDlgItem(IDC_INFO).SetWindowText(m_Message.c_str());
+ GetDlgItem(IDC_INPUT).SetFocus();
+ return 0;
+}
+
+LRESULT CInputDialog::OnOk(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+ CWindow InputWnd = GetDlgItem(IDC_INPUT);
+ m_Input.resize(InputWnd.GetWindowTextLength() + 1);
+ InputWnd.GetWindowText((wchar_t *)m_Input.data(), m_Input.size());
+
+ m_ok = true;
+ EndDialog(wID);
+ return 0;
+}
+
+LRESULT CInputDialog::OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+{
+ EndDialog(wID);
+ return 0;
+}
diff --git a/src/GLideNUI-wtl/InputDialog.h b/src/GLideNUI-wtl/InputDialog.h
new file mode 100644
index 00000000..8f727faf
--- /dev/null
+++ b/src/GLideNUI-wtl/InputDialog.h
@@ -0,0 +1,34 @@
+#pragma once
+#include
+#include "wtl.h"
+#include "resource.h"
+
+class CInputDialog :
+ public CDialogImpl
+{
+public:
+ static std::wstring getText(wchar_t * DlgTitle, wchar_t * Message, bool & ok);
+
+ CInputDialog(wchar_t * DlgTitle, wchar_t * Message, bool & ok);
+
+ enum { IDD = IDD_INPUT_DIALOG };
+
+ BEGIN_MSG_MAP_EX(CInputDialog)
+ MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
+ COMMAND_ID_HANDLER(IDOK, OnOk)
+ COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
+ END_MSG_MAP()
+
+ const std::wstring & GetInput() const { return m_Input; }
+
+protected:
+ LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
+ LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
+
+private:
+ CInputDialog(void);
+
+ std::wstring m_DlgTitle, m_Message, m_Input;
+ bool & m_ok;
+};
\ No newline at end of file
diff --git a/src/GLideNUI-wtl/config-osd.cpp b/src/GLideNUI-wtl/config-osd.cpp
index 1ee8df8e..cb75bfa6 100644
--- a/src/GLideNUI-wtl/config-osd.cpp
+++ b/src/GLideNUI-wtl/config-osd.cpp
@@ -207,7 +207,7 @@ void COsdTab::LoadSettings(bool /*blockCustomSettings*/)
tv.item.pszText = Item;
tv.item.cchTextMax = sizeof(Item) / sizeof(Item[0]);
tv.item.hItem = m_Fonts.GetChildItem(TVI_ROOT);
- HTREEITEM hParent = TVI_ROOT, hCurrentItem = NULL;
+ HTREEITEM hCurrentItem = NULL;
while (hCurrentItem == NULL && tv.item.hItem)
{
m_Fonts.GetItem(&tv.item);
diff --git a/src/GLideNUI-wtl/resource.h b/src/GLideNUI-wtl/resource.h
index d12151b3..1d0fc2a0 100644
Binary files a/src/GLideNUI-wtl/resource.h and b/src/GLideNUI-wtl/resource.h differ