mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-02 09:03:37 +00:00
GLideNUI-wtl: Handle changing/adding/removing profile
This commit is contained in:
parent
512544ca67
commit
02fcbf9b88
|
@ -101,6 +101,7 @@
|
|||
<ClCompile Include="..\..\src\GLideNUI-wtl\GLideNUI.cpp" />
|
||||
<ClCompile Include="..\..\src\GLideNUI-wtl\GlSettings.cpp" />
|
||||
<ClCompile Include="..\..\src\GLideNUI-wtl\IniFileClass.cpp" />
|
||||
<ClCompile Include="..\..\src\GLideNUI-wtl\InputDialog.cpp" />
|
||||
<ClCompile Include="..\..\src\GLideNUI-wtl\ScreenShot.cpp" />
|
||||
<ClCompile Include="..\..\src\GLideNUI-wtl\Settings.cpp" />
|
||||
<ClCompile Include="..\..\src\GLideNUI-wtl\util.cpp" />
|
||||
|
@ -126,6 +127,7 @@
|
|||
<ClInclude Include="..\..\src\GLideNUI-wtl\GLideNUI.h" />
|
||||
<ClInclude Include="..\..\src\GLideNUI-wtl\GlSettings.h" />
|
||||
<ClInclude Include="..\..\src\GLideNUI-wtl\IniFileClass.h" />
|
||||
<ClInclude Include="..\..\src\GLideNUI-wtl\InputDialog.h" />
|
||||
<ClInclude Include="..\..\src\GLideNUI-wtl\resource.h" />
|
||||
<ClInclude Include="..\..\src\GLideNUI-wtl\Settings.h" />
|
||||
<ClInclude Include="..\..\src\GLideNUI-wtl\util.h" />
|
||||
|
|
|
@ -87,6 +87,9 @@
|
|||
<ClCompile Include="..\..\src\GLideNUI-wtl\wtl-OsdPreview.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\GLideNUI-wtl\InputDialog.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\GLideNUI-wtl\About.h">
|
||||
|
@ -230,6 +233,9 @@
|
|||
<ClInclude Include="..\..\src\GLideNUI-wtl\WTL\atlwinx.h">
|
||||
<Filter>Header Files\WTL</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\GLideNUI-wtl\InputDialog.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\..\src\GLideNUI-wtl\BottomLeft.ico">
|
||||
|
@ -265,9 +271,6 @@
|
|||
<Image Include="..\..\src\GLideNUI-wtl\Up.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Image>
|
||||
<Image Include="..\..\src\GLideNUI\Icon.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Image>
|
||||
<Image Include="..\..\src\GLideNUI\Info.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Image>
|
||||
|
@ -298,6 +301,12 @@
|
|||
<Image Include="..\..\src\GLideNUI\BottomRight.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Image>
|
||||
<Image Include="..\..\src\GLideNUI-wtl\Icon.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Image>
|
||||
<Image Include="..\..\src\GLideNUI\Icon-Original.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="..\..\src\GLideNUI-wtl\GLideNUI.rc">
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Binary file not shown.
46
src/GLideNUI-wtl/InputDialog.cpp
Normal file
46
src/GLideNUI-wtl/InputDialog.cpp
Normal file
|
@ -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;
|
||||
}
|
34
src/GLideNUI-wtl/InputDialog.h
Normal file
34
src/GLideNUI-wtl/InputDialog.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include "wtl.h"
|
||||
#include "resource.h"
|
||||
|
||||
class CInputDialog :
|
||||
public CDialogImpl<CInputDialog>
|
||||
{
|
||||
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;
|
||||
};
|
|
@ -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);
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user