2016-01-27 09:11:59 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
|
|
#include "SettingsPage.h"
|
|
|
|
|
|
|
|
COptionPluginPage::COptionPluginPage(HWND hParent, const RECT & rcDispay)
|
|
|
|
{
|
|
|
|
if (!Create(hParent, rcDispay))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-03-18 02:12:07 +00:00
|
|
|
// Set the text for all GUI items
|
2020-05-12 12:19:05 +00:00
|
|
|
SetDlgItemText(RSP_ABOUT, wGS(PLUG_ABOUT).c_str());
|
|
|
|
SetDlgItemText(GFX_ABOUT, wGS(PLUG_ABOUT).c_str());
|
|
|
|
SetDlgItemText(AUDIO_ABOUT, wGS(PLUG_ABOUT).c_str());
|
|
|
|
SetDlgItemText(CONT_ABOUT, wGS(PLUG_ABOUT).c_str());
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2020-05-12 12:19:05 +00:00
|
|
|
SetDlgItemText(IDC_RSP_NAME, wGS(PLUG_RSP).c_str());
|
|
|
|
SetDlgItemText(IDC_GFX_NAME, wGS(PLUG_GFX).c_str());
|
|
|
|
SetDlgItemText(IDC_AUDIO_NAME, wGS(PLUG_AUDIO).c_str());
|
|
|
|
SetDlgItemText(IDC_CONT_NAME, wGS(PLUG_CTRL).c_str());
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2020-05-12 12:19:05 +00:00
|
|
|
SetDlgItemText(IDC_HLE_GFX, wGS(PLUG_HLE_GFX).c_str());
|
|
|
|
SetDlgItemText(IDC_HLE_AUDIO, wGS(PLUG_HLE_AUDIO).c_str());
|
2016-01-27 09:11:59 +00:00
|
|
|
|
|
|
|
m_GfxGroup.Attach(GetDlgItem(IDC_GFX_NAME));
|
|
|
|
m_AudioGroup.Attach(GetDlgItem(IDC_AUDIO_NAME));
|
|
|
|
m_ControlGroup.Attach(GetDlgItem(IDC_CONT_NAME));
|
|
|
|
m_RspGroup.Attach(GetDlgItem(IDC_RSP_NAME));
|
|
|
|
|
2022-06-27 10:02:38 +00:00
|
|
|
AddPlugins(GFX_LIST, Plugin_GFX_Current, PLUGIN_TYPE_VIDEO);
|
2016-01-27 09:11:59 +00:00
|
|
|
AddPlugins(AUDIO_LIST, Plugin_AUDIO_Current, PLUGIN_TYPE_AUDIO);
|
|
|
|
AddPlugins(CONT_LIST, Plugin_CONT_Current, PLUGIN_TYPE_CONTROLLER);
|
|
|
|
AddPlugins(RSP_LIST, Plugin_RSP_Current, PLUGIN_TYPE_RSP);
|
|
|
|
|
|
|
|
AddModCheckBox(GetDlgItem(IDC_HLE_GFX), Plugin_UseHleGfx);
|
|
|
|
AddModCheckBox(GetDlgItem(IDC_HLE_AUDIO), Plugin_UseHleAudio);
|
|
|
|
|
|
|
|
UpdatePageSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void COptionPluginPage::AddPlugins(int ListId, SettingID Type, PLUGIN_TYPE PluginType)
|
|
|
|
{
|
|
|
|
stdstr Default = g_Settings->LoadStringVal(Type);
|
|
|
|
|
|
|
|
CModifiedComboBox * ComboBox;
|
|
|
|
ComboBox = AddModComboBox(GetDlgItem(ListId), Type);
|
|
|
|
for (int i = 0, n = m_PluginList.GetPluginCount(); i < n; i++)
|
|
|
|
{
|
|
|
|
const CPluginList::PLUGIN * Plugin = m_PluginList.GetPluginInfo(i);
|
2021-04-12 11:35:39 +00:00
|
|
|
if (Plugin == nullptr)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (Plugin->Info.Type != PluginType)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (_stricmp(Default.c_str(), Plugin->FileName.c_str()) == 0)
|
|
|
|
{
|
|
|
|
ComboBox->SetDefault((WPARAM)Plugin);
|
|
|
|
}
|
2020-05-12 12:19:05 +00:00
|
|
|
ComboBox->AddItem(stdstr(Plugin->Info.Name).ToUTF16().c_str(), (WPARAM)Plugin);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void COptionPluginPage::ShowAboutButton(int id)
|
|
|
|
{
|
2021-04-12 11:35:39 +00:00
|
|
|
CModifiedComboBox * ComboBox = nullptr;
|
2016-01-27 09:11:59 +00:00
|
|
|
for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter++)
|
|
|
|
{
|
2023-02-27 23:39:08 +00:00
|
|
|
if ((int)((INT_PTR)cb_iter->second->GetMenu()) != id)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ComboBox = cb_iter->second;
|
|
|
|
break;
|
|
|
|
}
|
2021-04-12 11:35:39 +00:00
|
|
|
if (ComboBox == nullptr)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int index = ComboBox->GetCurSel();
|
|
|
|
if (index == CB_ERR)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const CPluginList::PLUGIN ** PluginPtr = (const CPluginList::PLUGIN **)ComboBox->GetItemDataPtr(index);
|
2021-04-12 11:35:39 +00:00
|
|
|
if (PluginPtr == nullptr)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const CPluginList::PLUGIN * Plugin = *PluginPtr;
|
2021-04-12 11:35:39 +00:00
|
|
|
if (Plugin == nullptr)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-03-18 02:12:07 +00:00
|
|
|
// Load the plugin
|
2016-01-27 09:11:59 +00:00
|
|
|
UINT LastErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
|
2020-05-12 12:19:05 +00:00
|
|
|
HMODULE hLib = LoadLibrary(stdstr((const char *)(Plugin->FullPath)).ToUTF16().c_str());
|
2016-01-27 09:11:59 +00:00
|
|
|
SetErrorMode(LastErrorMode);
|
2021-04-12 11:35:39 +00:00
|
|
|
if (hLib == nullptr)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-03-18 02:12:07 +00:00
|
|
|
// Get DLL about
|
2022-09-21 05:16:07 +00:00
|
|
|
void(CALL * DllAbout)(HWND hWnd);
|
2016-01-27 09:11:59 +00:00
|
|
|
DllAbout = (void(CALL *)(HWND))GetProcAddress(hLib, "DllAbout");
|
|
|
|
|
2021-03-18 02:12:07 +00:00
|
|
|
// Call the function from the DLL
|
2016-01-27 09:11:59 +00:00
|
|
|
DllAbout(m_hWnd);
|
|
|
|
|
|
|
|
FreeLibrary(hLib);
|
|
|
|
}
|
|
|
|
|
|
|
|
void COptionPluginPage::PluginItemChanged(int id, int AboutID, bool bSetChanged)
|
|
|
|
{
|
2021-04-12 11:35:39 +00:00
|
|
|
CModifiedComboBox * ComboBox = nullptr;
|
2016-01-27 09:11:59 +00:00
|
|
|
for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter++)
|
|
|
|
{
|
2023-02-27 23:39:08 +00:00
|
|
|
if ((int)((INT_PTR)cb_iter->second->GetMenu()) != id)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ComboBox = cb_iter->second;
|
|
|
|
break;
|
|
|
|
}
|
2021-04-12 11:35:39 +00:00
|
|
|
if (ComboBox == nullptr)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int index = ComboBox->GetCurSel();
|
|
|
|
if (index == CB_ERR)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const CPluginList::PLUGIN ** PluginPtr = (const CPluginList::PLUGIN **)ComboBox->GetItemDataPtr(index);
|
|
|
|
if (PluginPtr)
|
|
|
|
{
|
|
|
|
const CPluginList::PLUGIN * Plugin = *PluginPtr;
|
|
|
|
if (Plugin)
|
|
|
|
{
|
|
|
|
::EnableWindow(GetDlgItem(AboutID), Plugin->AboutFunction);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bSetChanged)
|
|
|
|
{
|
|
|
|
ComboBox->SetChanged(true);
|
|
|
|
SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void COptionPluginPage::UpdatePageSettings(void)
|
|
|
|
{
|
|
|
|
UpdateCheckBoxes();
|
|
|
|
for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter++)
|
|
|
|
{
|
|
|
|
CModifiedComboBox * ComboBox = cb_iter->second;
|
|
|
|
stdstr SelectedValue;
|
|
|
|
|
|
|
|
ComboBox->SetChanged(g_Settings->LoadStringVal(cb_iter->first, SelectedValue));
|
|
|
|
for (int i = 0, n = ComboBox->GetCount(); i < n; i++)
|
|
|
|
{
|
|
|
|
const CPluginList::PLUGIN ** PluginPtr = (const CPluginList::PLUGIN **)ComboBox->GetItemDataPtr(i);
|
2021-04-12 11:35:39 +00:00
|
|
|
if (PluginPtr == nullptr)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
const CPluginList::PLUGIN * Plugin = *PluginPtr;
|
2021-04-12 11:35:39 +00:00
|
|
|
if (Plugin == nullptr)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (_stricmp(SelectedValue.c_str(), Plugin->FileName.c_str()) != 0)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ComboBox->SetDefault((WPARAM)Plugin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PluginItemChanged(GFX_LIST, GFX_ABOUT, false);
|
|
|
|
PluginItemChanged(AUDIO_LIST, AUDIO_ABOUT, false);
|
|
|
|
PluginItemChanged(CONT_LIST, CONT_ABOUT, false);
|
|
|
|
PluginItemChanged(RSP_LIST, RSP_ABOUT, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void COptionPluginPage::HidePage()
|
|
|
|
{
|
|
|
|
ShowWindow(SW_HIDE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void COptionPluginPage::ShowPage()
|
|
|
|
{
|
|
|
|
ShowWindow(SW_SHOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
void COptionPluginPage::ApplySettings(bool UpdateScreen)
|
|
|
|
{
|
|
|
|
CSettingsPageImpl<COptionPluginPage>::ApplySettings(UpdateScreen);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool COptionPluginPage::EnableReset(void)
|
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
if (CSettingsPageImpl<COptionPluginPage>::EnableReset())
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void COptionPluginPage::ResetPage()
|
|
|
|
{
|
|
|
|
CSettingsPageImpl<COptionPluginPage>::ResetPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
void COptionPluginPage::ApplyComboBoxes(void)
|
|
|
|
{
|
|
|
|
for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter++)
|
|
|
|
{
|
|
|
|
CModifiedComboBox * ComboBox = cb_iter->second;
|
|
|
|
if (ComboBox->IsChanged())
|
|
|
|
{
|
|
|
|
int index = ComboBox->GetCurSel();
|
|
|
|
if (index == CB_ERR)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const CPluginList::PLUGIN ** PluginPtr = (const CPluginList::PLUGIN **)ComboBox->GetItemDataPtr(index);
|
2021-04-12 11:35:39 +00:00
|
|
|
if (PluginPtr == nullptr)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const CPluginList::PLUGIN * Plugin = *PluginPtr;
|
|
|
|
|
|
|
|
g_Settings->SaveString(cb_iter->first, Plugin->FileName.c_str());
|
|
|
|
}
|
|
|
|
if (ComboBox->IsReset())
|
|
|
|
{
|
|
|
|
g_Settings->DeleteSetting(cb_iter->first);
|
|
|
|
ComboBox->SetReset(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool COptionPluginPage::ResetComboBox(CModifiedComboBox & ComboBox, SettingID Type)
|
|
|
|
{
|
|
|
|
if (!ComboBox.IsChanged())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ComboBox.SetReset(true);
|
|
|
|
stdstr Value = g_Settings->LoadDefaultString(Type);
|
|
|
|
for (int i = 0, n = ComboBox.GetCount(); i < n; i++)
|
|
|
|
{
|
|
|
|
const CPluginList::PLUGIN ** PluginPtr = (const CPluginList::PLUGIN **)ComboBox.GetItemDataPtr(i);
|
2021-04-12 11:35:39 +00:00
|
|
|
if (PluginPtr == nullptr)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const CPluginList::PLUGIN * Plugin = *PluginPtr;
|
|
|
|
if (Plugin->FileName != Value)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ComboBox.SetCurSel(i);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void COptionPluginPage::HleGfxChanged(UINT /*Code*/, int id, HWND /*ctl*/)
|
|
|
|
{
|
|
|
|
for (ButtonList::iterator iter = m_ButtonList.begin(); iter != m_ButtonList.end(); iter++)
|
|
|
|
{
|
|
|
|
CModifiedButton * Button = iter->second;
|
2023-02-27 23:39:08 +00:00
|
|
|
if ((int)(INT_PTR)Button->GetMenu() != id)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ((Button->GetCheck() & BST_CHECKED) == 0)
|
|
|
|
{
|
2019-03-18 01:04:05 +00:00
|
|
|
if (!g_Notify->AskYesNoQuestion(g_Lang->GetString(MSG_SET_LLE_GFX_MSG).c_str()))
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
Button->SetCheck(BST_CHECKED);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Button->SetChanged(true);
|
|
|
|
SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void COptionPluginPage::HleAudioChanged(UINT /*Code*/, int id, HWND /*ctl*/)
|
|
|
|
{
|
|
|
|
for (ButtonList::iterator iter = m_ButtonList.begin(); iter != m_ButtonList.end(); iter++)
|
|
|
|
{
|
|
|
|
CModifiedButton * Button = iter->second;
|
2023-02-27 23:39:08 +00:00
|
|
|
if ((int)(INT_PTR)Button->GetMenu() != id)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ((Button->GetCheck() & BST_CHECKED) != 0)
|
|
|
|
{
|
2019-03-18 01:04:05 +00:00
|
|
|
if (!g_Notify->AskYesNoQuestion(g_Lang->GetString(MSG_SET_HLE_AUD_MSG).c_str()))
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
Button->SetCheck(BST_UNCHECKED);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Button->SetChanged(true);
|
|
|
|
SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0);
|
|
|
|
break;
|
|
|
|
}
|
2021-03-18 02:12:07 +00:00
|
|
|
}
|