2012-12-19 09:30:18 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* *
|
2015-11-10 05:21:49 +00:00
|
|
|
* Project64 - A Nintendo 64 emulator. *
|
2012-12-19 09:30:18 +00:00
|
|
|
* http://www.pj64-emu.com/ *
|
|
|
|
* Copyright (C) 2012 Project64. All rights reserved. *
|
|
|
|
* *
|
|
|
|
* License: *
|
|
|
|
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
2010-06-07 02:23:58 +00:00
|
|
|
#include "stdafx.h"
|
2015-09-07 19:47:44 +00:00
|
|
|
|
2015-12-04 06:49:31 +00:00
|
|
|
#include "SettingsPage.h"
|
|
|
|
#include "SettingsPage-Game-Plugin.h"
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
CGamePluginPage::CGamePluginPage(HWND hParent, const RECT & rcDispay)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2015-11-07 01:11:25 +00:00
|
|
|
if (!Create(hParent, rcDispay))
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-11-07 01:11:25 +00:00
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
//Set the text for all gui Items
|
2015-11-07 01:11:25 +00:00
|
|
|
SetDlgItemTextW(m_hWnd, RSP_ABOUT, GS(PLUG_ABOUT));
|
|
|
|
SetDlgItemTextW(m_hWnd, GFX_ABOUT, GS(PLUG_ABOUT));
|
|
|
|
SetDlgItemTextW(m_hWnd, AUDIO_ABOUT, GS(PLUG_ABOUT));
|
|
|
|
SetDlgItemTextW(m_hWnd, CONT_ABOUT, GS(PLUG_ABOUT));
|
|
|
|
|
|
|
|
SetDlgItemTextW(m_hWnd, IDC_RSP_NAME, GS(PLUG_RSP));
|
|
|
|
SetDlgItemTextW(m_hWnd, IDC_GFX_NAME, GS(PLUG_GFX));
|
|
|
|
SetDlgItemTextW(m_hWnd, IDC_AUDIO_NAME, GS(PLUG_AUDIO));
|
|
|
|
SetDlgItemTextW(m_hWnd, IDC_CONT_NAME, GS(PLUG_CTRL));
|
|
|
|
|
|
|
|
SetDlgItemTextW(m_hWnd, IDC_HLE_GFX, GS(PLUG_HLE_GFX));
|
|
|
|
SetDlgItemTextW(m_hWnd, IDC_HLE_AUDIO, GS(PLUG_HLE_AUDIO));
|
2008-11-14 20:51:06 +00:00
|
|
|
|
2008-12-04 10:41:51 +00:00
|
|
|
m_GfxGroup.Attach(GetDlgItem(IDC_GFX_NAME));
|
2008-11-14 20:51:06 +00:00
|
|
|
m_AudioGroup.Attach(GetDlgItem(IDC_AUDIO_NAME));
|
|
|
|
m_ControlGroup.Attach(GetDlgItem(IDC_CONT_NAME));
|
|
|
|
m_RspGroup.Attach(GetDlgItem(IDC_RSP_NAME));
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
AddPlugins(GFX_LIST, Game_EditPlugin_Gfx, PLUGIN_TYPE_GFX);
|
|
|
|
AddPlugins(AUDIO_LIST, Game_EditPlugin_Audio, PLUGIN_TYPE_AUDIO);
|
|
|
|
AddPlugins(CONT_LIST, Game_EditPlugin_Contr, PLUGIN_TYPE_CONTROLLER);
|
|
|
|
AddPlugins(RSP_LIST, Game_EditPlugin_RSP, PLUGIN_TYPE_RSP);
|
|
|
|
|
|
|
|
AddModCheckBox(GetDlgItem(IDC_HLE_GFX), Game_UseHleGfx);
|
|
|
|
AddModCheckBox(GetDlgItem(IDC_HLE_AUDIO), Game_UseHleAudio);
|
2008-11-14 20:51:06 +00:00
|
|
|
|
|
|
|
UpdatePageSettings();
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
void CGamePluginPage::AddPlugins(int ListId, SettingID Type, PLUGIN_TYPE PluginType)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2008-11-17 10:02:22 +00:00
|
|
|
stdstr Default;
|
2015-11-07 01:11:25 +00:00
|
|
|
bool PluginSelected = g_Settings->LoadStringVal(Type, Default);
|
2008-11-14 20:51:06 +00:00
|
|
|
|
|
|
|
CModifiedComboBox * ComboBox;
|
2015-11-07 01:11:25 +00:00
|
|
|
ComboBox = AddModComboBox(GetDlgItem(ListId), Type);
|
2008-11-17 10:02:22 +00:00
|
|
|
if (!PluginSelected)
|
|
|
|
{
|
|
|
|
ComboBox->SetDefault(NULL);
|
|
|
|
}
|
2015-03-04 09:36:08 +00:00
|
|
|
ComboBox->AddItemW(GS(PLUG_DEFAULT), NULL);
|
2015-11-07 01:11:25 +00:00
|
|
|
|
|
|
|
for (int i = 0, n = m_PluginList.GetPluginCount(); i < n; i++)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
const CPluginList::PLUGIN * Plugin = m_PluginList.GetPluginInfo(i);
|
|
|
|
if (Plugin == NULL)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (Plugin->Info.Type != PluginType)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2015-11-07 01:11:25 +00:00
|
|
|
if (PluginSelected && _stricmp(Default.c_str(), Plugin->FileName.c_str()) == 0)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
ComboBox->SetDefault((WPARAM)Plugin);
|
|
|
|
}
|
|
|
|
ComboBox->AddItem(Plugin->Info.Name, (WPARAM)Plugin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
void CGamePluginPage::ShowAboutButton(int id)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
CModifiedComboBox * ComboBox = NULL;
|
2015-11-07 01:11:25 +00:00
|
|
|
for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter++)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
if ((int)(cb_iter->second->GetMenu()) != id)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ComboBox = cb_iter->second;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ComboBox == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int index = ComboBox->GetCurSel();
|
2015-11-07 01:11:25 +00:00
|
|
|
if (index == CB_ERR)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2015-11-07 01:11:25 +00:00
|
|
|
return;
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
2015-11-07 01:11:25 +00:00
|
|
|
|
2008-12-04 19:15:55 +00:00
|
|
|
const CPluginList::PLUGIN ** PluginPtr = (const CPluginList::PLUGIN **)ComboBox->GetItemDataPtr(index);
|
|
|
|
if (PluginPtr == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const CPluginList::PLUGIN * Plugin = *PluginPtr;
|
2008-11-14 20:51:06 +00:00
|
|
|
if (Plugin == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-11-07 01:11:25 +00:00
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
//Load the plugin
|
2015-11-07 01:11:25 +00:00
|
|
|
UINT LastErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
|
|
|
|
HMODULE hLib = LoadLibrary(Plugin->FullPath);
|
2008-11-14 20:51:06 +00:00
|
|
|
SetErrorMode(LastErrorMode);
|
|
|
|
if (hLib == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-11-07 01:11:25 +00:00
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
//Get DLL about
|
2015-11-07 01:11:25 +00:00
|
|
|
void(__cdecl *DllAbout) (HWND hWnd);
|
|
|
|
DllAbout = (void(__cdecl *)(HWND))GetProcAddress(hLib, "DllAbout");
|
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
//call the function from the dll
|
|
|
|
DllAbout(m_hWnd);
|
|
|
|
|
|
|
|
FreeLibrary(hLib);
|
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
void CGamePluginPage::PluginItemChanged(int id, int AboutID, bool bSetChanged)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
CModifiedComboBox * ComboBox = NULL;
|
2015-11-07 01:11:25 +00:00
|
|
|
for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter++)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
if ((int)(cb_iter->second->GetMenu()) != id)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ComboBox = cb_iter->second;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ComboBox == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int index = ComboBox->GetCurSel();
|
2015-11-07 01:11:25 +00:00
|
|
|
if (index == CB_ERR)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2015-11-07 01:11:25 +00:00
|
|
|
return;
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
2008-12-04 19:15:55 +00:00
|
|
|
const CPluginList::PLUGIN ** PluginPtr = (const CPluginList::PLUGIN **)ComboBox->GetItemDataPtr(index);
|
|
|
|
if (PluginPtr)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2008-12-04 19:15:55 +00:00
|
|
|
const CPluginList::PLUGIN * Plugin = *PluginPtr;
|
|
|
|
if (Plugin)
|
|
|
|
{
|
2015-11-07 01:11:25 +00:00
|
|
|
::EnableWindow(GetDlgItem(AboutID), Plugin->AboutFunction);
|
2008-12-04 19:15:55 +00:00
|
|
|
}
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
2008-12-04 19:15:55 +00:00
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
if (bSetChanged)
|
|
|
|
{
|
|
|
|
ComboBox->SetChanged(true);
|
2015-11-07 01:11:25 +00:00
|
|
|
SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0);
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
void CGamePluginPage::UpdatePageSettings(void)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
UpdateCheckBoxes();
|
2015-11-07 01:11:25 +00:00
|
|
|
for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter++)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
CModifiedComboBox * ComboBox = cb_iter->second;
|
|
|
|
stdstr SelectedValue;
|
2015-11-07 01:11:25 +00:00
|
|
|
|
|
|
|
bool PluginChanged = g_Settings->LoadStringVal(cb_iter->first, SelectedValue);
|
2008-11-17 10:02:22 +00:00
|
|
|
ComboBox->SetChanged(PluginChanged);
|
|
|
|
if (PluginChanged)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2015-11-07 01:11:25 +00:00
|
|
|
for (int i = 0, n = m_PluginList.GetPluginCount(); i < n; i++)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2008-11-17 10:02:22 +00:00
|
|
|
const CPluginList::PLUGIN * Plugin = m_PluginList.GetPluginInfo(i);
|
|
|
|
if (Plugin == NULL)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2015-11-07 01:11:25 +00:00
|
|
|
if (_stricmp(SelectedValue.c_str(), Plugin->FileName.c_str()) != 0)
|
2008-11-17 10:02:22 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ComboBox->SetDefault((WPARAM)Plugin);
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
2015-11-07 01:11:25 +00:00
|
|
|
}
|
|
|
|
else {
|
2008-11-17 10:02:22 +00:00
|
|
|
ComboBox->SetDefault(NULL);
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
}
|
2015-11-07 01:11:25 +00:00
|
|
|
PluginItemChanged(GFX_LIST, GFX_ABOUT, false);
|
|
|
|
PluginItemChanged(AUDIO_LIST, AUDIO_ABOUT, false);
|
|
|
|
PluginItemChanged(CONT_LIST, CONT_ABOUT, false);
|
|
|
|
PluginItemChanged(RSP_LIST, RSP_ABOUT, false);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CGamePluginPage::HidePage()
|
|
|
|
{
|
|
|
|
ShowWindow(SW_HIDE);
|
|
|
|
}
|
2008-11-14 20:51:06 +00:00
|
|
|
|
|
|
|
void CGamePluginPage::ShowPage()
|
|
|
|
{
|
|
|
|
ShowWindow(SW_SHOW);
|
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
void CGamePluginPage::ApplySettings(bool UpdateScreen)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
CSettingsPageImpl<CGamePluginPage>::ApplySettings(UpdateScreen);
|
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
bool CGamePluginPage::EnableReset(void)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
if (CSettingsPageImpl<CGamePluginPage>::EnableReset()) { return true; }
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGamePluginPage::ResetPage()
|
|
|
|
{
|
|
|
|
CSettingsPageImpl<CGamePluginPage>::ResetPage();
|
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
void CGamePluginPage::ApplyComboBoxes(void)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2015-11-07 01:11:25 +00:00
|
|
|
for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter++)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
CModifiedComboBox * ComboBox = cb_iter->second;
|
|
|
|
if (ComboBox->IsChanged())
|
|
|
|
{
|
|
|
|
int index = ComboBox->GetCurSel();
|
2015-11-07 01:11:25 +00:00
|
|
|
if (index == CB_ERR)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2015-11-07 01:11:25 +00:00
|
|
|
return;
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
2008-12-04 19:15:55 +00:00
|
|
|
|
|
|
|
const CPluginList::PLUGIN ** PluginPtr = (const CPluginList::PLUGIN **)ComboBox->GetItemDataPtr(index);
|
|
|
|
if (PluginPtr == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const CPluginList::PLUGIN * Plugin = *PluginPtr;
|
2008-11-14 20:51:06 +00:00
|
|
|
|
2008-11-17 10:02:22 +00:00
|
|
|
if (Plugin)
|
|
|
|
{
|
2015-10-25 10:50:28 +00:00
|
|
|
if (g_Settings->LoadStringVal(cb_iter->first) != Plugin->FileName.c_str())
|
2009-12-28 22:22:50 +00:00
|
|
|
{
|
2015-11-07 01:11:25 +00:00
|
|
|
g_Settings->SaveString(cb_iter->first, Plugin->FileName.c_str());
|
2009-12-28 22:22:50 +00:00
|
|
|
}
|
2015-11-07 01:11:25 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->DeleteSetting(cb_iter->first);
|
2008-11-17 10:02:22 +00:00
|
|
|
}
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
if (ComboBox->IsReset())
|
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->DeleteSetting(cb_iter->first);
|
2008-11-14 20:51:06 +00:00
|
|
|
ComboBox->SetReset(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
bool CGamePluginPage::ResetComboBox(CModifiedComboBox & ComboBox, SettingID /*Type*/)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
if (!ComboBox.IsChanged())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ComboBox.SetReset(true);
|
|
|
|
for (int i = 0, n = ComboBox.GetCount(); i < n; i++)
|
|
|
|
{
|
2008-12-04 19:15:55 +00:00
|
|
|
const CPluginList::PLUGIN ** PluginPtr = (const CPluginList::PLUGIN **)ComboBox.GetItemDataPtr(i);
|
|
|
|
if (PluginPtr == NULL)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (*PluginPtr != NULL)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ComboBox.SetCurSel(i);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
void CGamePluginPage::HleGfxChanged(UINT /*Code*/, int id, HWND /*ctl*/)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2015-11-07 01:11:25 +00:00
|
|
|
for (ButtonList::iterator iter = m_ButtonList.begin(); iter != m_ButtonList.end(); iter++)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
CModifiedButton * Button = iter->second;
|
|
|
|
if ((int)Button->GetMenu() != id)
|
|
|
|
{
|
|
|
|
continue;
|
2015-11-07 01:11:25 +00:00
|
|
|
}
|
2008-11-14 20:51:06 +00:00
|
|
|
if ((Button->GetCheck() & BST_CHECKED) == 0)
|
|
|
|
{
|
2015-11-07 01:11:25 +00:00
|
|
|
int res = MessageBoxW(m_hWnd, GS(MSG_SET_LLE_GFX_MSG), GS(MSG_SET_LLE_GFX_TITLE), MB_YESNO | MB_ICONWARNING);
|
2008-11-14 20:51:06 +00:00
|
|
|
if (res != IDYES)
|
|
|
|
{
|
|
|
|
Button->SetCheck(BST_CHECKED);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Button->SetChanged(true);
|
2015-11-07 01:11:25 +00:00
|
|
|
SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0);
|
2008-11-14 20:51:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-07 01:11:25 +00:00
|
|
|
void CGamePluginPage::HleAudioChanged(UINT /*Code*/, int id, HWND /*ctl*/)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
2015-11-07 01:11:25 +00:00
|
|
|
for (ButtonList::iterator iter = m_ButtonList.begin(); iter != m_ButtonList.end(); iter++)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
CModifiedButton * Button = iter->second;
|
|
|
|
if ((int)Button->GetMenu() != id)
|
|
|
|
{
|
|
|
|
continue;
|
2015-11-07 01:11:25 +00:00
|
|
|
}
|
2008-11-14 20:51:06 +00:00
|
|
|
if ((Button->GetCheck() & BST_CHECKED) != 0)
|
|
|
|
{
|
2015-11-07 01:11:25 +00:00
|
|
|
int res = MessageBoxW(m_hWnd, GS(MSG_SET_HLE_AUD_MSG), GS(MSG_SET_HLE_AUD_TITLE), MB_ICONWARNING | MB_YESNO);
|
2008-11-14 20:51:06 +00:00
|
|
|
if (res != IDYES)
|
|
|
|
{
|
|
|
|
Button->SetCheck(BST_UNCHECKED);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Button->SetChanged(true);
|
2015-11-07 01:11:25 +00:00
|
|
|
SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0);
|
2008-11-14 20:51:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|