2010-06-07 02:23:58 +00:00
|
|
|
#include "stdafx.h"
|
2015-09-07 19:47:44 +00:00
|
|
|
|
|
|
|
#ifdef WINDOWS_UI
|
2015-12-04 06:49:31 +00:00
|
|
|
#include "SettingsConfig.h"
|
|
|
|
#include "Settings/SettingsPage.h"
|
2015-12-06 09:59:58 +00:00
|
|
|
#include <Project64-core/Settings/SettingType/SettingsType-Application.h>
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
CSettingConfig::CSettingConfig(bool bJustGameSetting /* = false */) :
|
2008-11-14 20:51:06 +00:00
|
|
|
m_CurrentPage(NULL),
|
2012-09-27 06:57:51 +00:00
|
|
|
m_GeneralOptionsPage(NULL),
|
|
|
|
m_AdvancedPage(NULL),
|
2008-11-14 20:51:06 +00:00
|
|
|
m_GameConfig(bJustGameSetting)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CSettingConfig::~CSettingConfig ()
|
|
|
|
{
|
|
|
|
for (SETTING_SECTIONS::const_iterator iter = m_Sections.begin(); iter != m_Sections.end(); iter++)
|
|
|
|
{
|
|
|
|
CConfigSettingSection * Section = *iter;
|
|
|
|
delete Section;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSettingConfig::Display(void * ParentWindow)
|
|
|
|
{
|
2015-02-12 10:58:28 +00:00
|
|
|
if (g_BaseSystem)
|
|
|
|
{
|
|
|
|
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_Settings);
|
|
|
|
}
|
|
|
|
|
2015-03-05 11:33:57 +00:00
|
|
|
BOOL result = m_thunk.Init(NULL, NULL);
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
_AtlWinModule.AddCreateWndData(&m_thunk.cd, this);
|
|
|
|
#ifdef _DEBUG
|
|
|
|
m_bModal = true;
|
|
|
|
#endif //_DEBUG
|
|
|
|
::DialogBoxParamW(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCEW(IDD), (HWND)ParentWindow, StartDialogProc, NULL);
|
|
|
|
}
|
|
|
|
|
2015-02-12 10:58:28 +00:00
|
|
|
if (g_BaseSystem)
|
|
|
|
{
|
|
|
|
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_Settings);
|
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2012-09-27 06:57:51 +00:00
|
|
|
void CSettingConfig::UpdateAdvanced ( bool AdvancedMode )
|
|
|
|
{
|
|
|
|
UpdateAdvanced(AdvancedMode,m_PagesTreeList.GetRootItem());
|
|
|
|
BoldChangedPages(m_PagesTreeList.GetRootItem());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CSettingConfig::UpdateAdvanced ( bool AdvancedMode, HTREEITEM hItem )
|
|
|
|
{
|
|
|
|
while (hItem)
|
|
|
|
{
|
|
|
|
CSettingsPage * Page = (CSettingsPage * )m_PagesTreeList.GetItemData(hItem);
|
|
|
|
if (!AdvancedMode && Page == m_AdvancedPage)
|
|
|
|
{
|
|
|
|
m_PagesTreeList.DeleteItem(hItem);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (AdvancedMode && Page == m_GeneralOptionsPage)
|
|
|
|
{
|
2015-03-04 09:36:08 +00:00
|
|
|
m_PagesTreeList.InsertItemW(TVIF_TEXT | TVIF_PARAM,GS(m_AdvancedPage->PageTitle()),0,0,0,0,(ULONG)m_AdvancedPage,hItem,TVI_FIRST);
|
2012-09-27 06:57:51 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (UpdateAdvanced(AdvancedMode,m_PagesTreeList.GetChildItem(hItem)))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
hItem = m_PagesTreeList.GetNextSiblingItem(hItem);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
LRESULT CSettingConfig::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
|
|
|
|
{
|
2015-10-25 10:50:28 +00:00
|
|
|
stdstr ConfigRomTitle, GameIni(g_Settings->LoadStringVal(Game_IniKey));
|
2008-11-14 20:51:06 +00:00
|
|
|
|
|
|
|
if (!GameIni.empty())
|
|
|
|
{
|
2015-10-25 10:50:28 +00:00
|
|
|
ConfigRomTitle.Format("Config: %s",g_Settings->LoadStringVal(Game_GoodName).c_str());
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
RECT rcSettingInfo;
|
|
|
|
::GetWindowRect(GetDlgItem(IDC_SETTING_INFO),&rcSettingInfo);
|
|
|
|
::MapWindowPoints(NULL,m_hWnd,(LPPOINT)&rcSettingInfo,2);
|
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
CConfigSettingSection * SettingsSection;
|
|
|
|
|
2015-03-18 02:09:33 +00:00
|
|
|
//Set the text for all gui Items
|
2015-03-20 19:38:55 +00:00
|
|
|
SetDlgItemTextW(m_hWnd, IDC_RESET_PAGE, GS(BOTTOM_RESET_PAGE));
|
|
|
|
SetDlgItemTextW(m_hWnd, IDC_RESET_ALL, GS(BOTTOM_RESET_ALL));
|
2015-03-18 02:09:33 +00:00
|
|
|
SetDlgItemTextW(m_hWnd, IDOK, GS(CHEAT_OK));
|
|
|
|
SetDlgItemTextW(m_hWnd, IDCANCEL, GS(CHEAT_CANCEL));
|
2015-03-20 19:38:55 +00:00
|
|
|
SetDlgItemTextW(m_hWnd, IDAPPLY, GS(BOTTOM_APPLY));
|
2015-03-18 02:09:33 +00:00
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
if (m_GameConfig)
|
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
if (g_Settings->LoadBool(Setting_RdbEditor))
|
2008-12-04 10:41:51 +00:00
|
|
|
{
|
|
|
|
SetWindowText(stdstr_f("%s ** RDB Edit Mode **",ConfigRomTitle.c_str()).c_str());
|
2015-03-04 09:36:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-12-04 10:41:51 +00:00
|
|
|
SetWindowText(ConfigRomTitle.c_str());
|
|
|
|
}
|
2015-03-04 09:36:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
if (g_Settings->LoadBool(Setting_RdbEditor))
|
2008-12-04 10:41:51 +00:00
|
|
|
{
|
2015-11-26 14:03:46 +00:00
|
|
|
SetWindowText(stdstr_f("%ws ** RDB Edit Mode **",GS(OPTIONS_TITLE)).c_str());
|
2008-12-04 10:41:51 +00:00
|
|
|
} else {
|
2015-03-04 09:36:08 +00:00
|
|
|
::SetWindowTextW(m_hWnd, GS(OPTIONS_TITLE));
|
2008-12-04 10:41:51 +00:00
|
|
|
}
|
2008-11-14 20:51:06 +00:00
|
|
|
|
2012-11-17 01:02:04 +00:00
|
|
|
if (g_Settings->LoadBool(Setting_PluginPageFirst))
|
2008-12-01 18:19:49 +00:00
|
|
|
{
|
|
|
|
SettingsSection = new CConfigSettingSection(GS(TAB_PLUGIN));
|
|
|
|
SettingsSection->AddPage(new COptionPluginPage(this->m_hWnd,rcSettingInfo ));
|
|
|
|
m_Sections.push_back(SettingsSection);
|
|
|
|
}
|
|
|
|
|
2012-10-04 12:01:08 +00:00
|
|
|
m_GeneralOptionsPage = new CGeneralOptionsPage(this,this->m_hWnd,rcSettingInfo );
|
|
|
|
m_AdvancedPage = new CAdvancedOptionsPage(this->m_hWnd,rcSettingInfo );
|
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
SettingsSection = new CConfigSettingSection(GS(TAB_OPTIONS));
|
2012-09-27 06:57:51 +00:00
|
|
|
SettingsSection->AddPage(m_GeneralOptionsPage);
|
|
|
|
SettingsSection->AddPage(m_AdvancedPage);
|
2008-11-14 20:51:06 +00:00
|
|
|
SettingsSection->AddPage(new COptionsDirectoriesPage(this->m_hWnd,rcSettingInfo ));
|
|
|
|
m_Sections.push_back(SettingsSection);
|
|
|
|
|
|
|
|
SettingsSection = new CConfigSettingSection(GS(TAB_ROMSELECTION));
|
|
|
|
SettingsSection->AddPage(new COptionsGameBrowserPage(this->m_hWnd,rcSettingInfo ));
|
|
|
|
m_Sections.push_back(SettingsSection);
|
|
|
|
|
|
|
|
SettingsSection = new CConfigSettingSection(GS(TAB_SHORTCUTS));
|
|
|
|
SettingsSection->AddPage(new COptionsShortCutsPage(this->m_hWnd,rcSettingInfo ));
|
|
|
|
m_Sections.push_back(SettingsSection);
|
|
|
|
|
2012-11-17 01:02:04 +00:00
|
|
|
if (!g_Settings->LoadBool(Setting_PluginPageFirst))
|
2008-12-01 18:19:49 +00:00
|
|
|
{
|
|
|
|
SettingsSection = new CConfigSettingSection(GS(TAB_PLUGIN));
|
|
|
|
SettingsSection->AddPage(new COptionPluginPage(this->m_hWnd,rcSettingInfo ));
|
|
|
|
m_Sections.push_back(SettingsSection);
|
|
|
|
}
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
//Game Settings
|
2008-11-14 20:51:06 +00:00
|
|
|
if (!GameIni.empty())
|
|
|
|
{
|
2015-03-04 09:36:08 +00:00
|
|
|
CConfigSettingSection * GameSettings = new CConfigSettingSection(ConfigRomTitle.ToUTF16().c_str());
|
2008-11-14 20:51:06 +00:00
|
|
|
GameSettings->AddPage(new CGameGeneralPage(this->m_hWnd,rcSettingInfo ));
|
|
|
|
GameSettings->AddPage(new CGameRecompilePage(this->m_hWnd,rcSettingInfo ));
|
|
|
|
GameSettings->AddPage(new CGamePluginPage(this->m_hWnd,rcSettingInfo ));
|
2012-11-17 01:02:04 +00:00
|
|
|
if (g_Settings->LoadBool(Setting_RdbEditor))
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
GameSettings->AddPage(new CGameStatusPage(this->m_hWnd,rcSettingInfo ));
|
|
|
|
}
|
|
|
|
m_Sections.push_back(GameSettings);
|
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
m_PagesTreeList.Attach(GetDlgItem(IDC_PAGELIST));
|
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
bool bFirstItem = true;
|
2012-11-17 01:02:04 +00:00
|
|
|
bool HideAdvanced = g_Settings->LoadBool(UserInterface_BasicMode);
|
2008-09-18 03:15:49 +00:00
|
|
|
for (SETTING_SECTIONS::const_iterator iter = m_Sections.begin(); iter != m_Sections.end(); iter++)
|
|
|
|
{
|
|
|
|
CConfigSettingSection * Section = *iter;
|
|
|
|
|
|
|
|
HTREEITEM hSectionItem = NULL;
|
2012-09-27 06:57:51 +00:00
|
|
|
|
2015-05-24 18:35:47 +00:00
|
|
|
for (size_t i = 0; i < Section->GetPageCount(); i++)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
CSettingsPage * Page = Section->GetPage(i);
|
2012-09-27 06:57:51 +00:00
|
|
|
if (HideAdvanced && Page == m_AdvancedPage)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
if (i == 0)
|
|
|
|
{
|
2015-03-04 09:36:08 +00:00
|
|
|
hSectionItem = m_PagesTreeList.InsertItemW(TVIF_TEXT | TVIF_PARAM,Section->GetPageTitle(),0,0,0,0,(ULONG)Page,TVI_ROOT,TVI_LAST);
|
2008-11-14 20:51:06 +00:00
|
|
|
continue;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
if (hSectionItem == NULL)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2015-03-04 09:36:08 +00:00
|
|
|
m_PagesTreeList.InsertItemW(TVIF_TEXT | TVIF_PARAM,GS(Page->PageTitle()),0,0,0,0,(ULONG)Page,hSectionItem,TVI_LAST);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
2008-11-14 20:51:06 +00:00
|
|
|
if (bFirstItem && hSectionItem != NULL)
|
|
|
|
{
|
|
|
|
bFirstItem = false;
|
|
|
|
m_PagesTreeList.Expand(hSectionItem);
|
|
|
|
m_PagesTreeList.SelectItem(hSectionItem);
|
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
2008-11-14 20:51:06 +00:00
|
|
|
|
|
|
|
BoldChangedPages(m_PagesTreeList.GetRootItem());
|
2008-09-18 03:15:49 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-10-05 09:14:32 +00:00
|
|
|
LRESULT CSettingConfig::OnClicked (WORD /*wNotifyCode*/, WORD wID, HWND , BOOL& /*bHandled*/)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
switch(wID)
|
|
|
|
{
|
2008-11-14 20:51:06 +00:00
|
|
|
case IDAPPLY:
|
|
|
|
ApplySettings(true);
|
|
|
|
break;
|
|
|
|
case IDOK:
|
|
|
|
ApplySettings(false);
|
|
|
|
EndDialog(1);
|
|
|
|
break;
|
2008-09-18 03:15:49 +00:00
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(0);
|
2008-11-14 20:51:06 +00:00
|
|
|
break;
|
2008-12-04 10:41:51 +00:00
|
|
|
case IDC_RESET_PAGE:
|
2008-11-14 20:51:06 +00:00
|
|
|
if (m_CurrentPage)
|
|
|
|
{
|
|
|
|
m_CurrentPage->ResetPage();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IDC_RESET_ALL:
|
|
|
|
for (SETTING_SECTIONS::const_iterator iter = m_Sections.begin(); iter != m_Sections.end(); iter++)
|
|
|
|
{
|
|
|
|
CConfigSettingSection * Section = *iter;
|
|
|
|
|
2015-05-24 18:35:47 +00:00
|
|
|
for (size_t i = 0; i < Section->GetPageCount(); i++ )
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
CSettingsPage * Page = Section->GetPage(i);
|
|
|
|
if (Page->EnableReset())
|
|
|
|
{
|
|
|
|
Page->ResetPage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
void CSettingConfig::ApplySettings( bool UpdateScreen )
|
|
|
|
{
|
2015-10-25 10:50:28 +00:00
|
|
|
stdstr GameIni(g_Settings->LoadStringVal(Game_IniKey));
|
2008-12-04 10:41:51 +00:00
|
|
|
|
|
|
|
if (!GameIni.empty())
|
|
|
|
{
|
|
|
|
stdstr GoodName;
|
2015-10-25 10:50:28 +00:00
|
|
|
if (!g_Settings->LoadStringVal(Game_GoodName,GoodName))
|
2008-12-04 10:41:51 +00:00
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->SaveString(Game_GoodName,GoodName);
|
2008-12-04 10:41:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
for (SETTING_SECTIONS::const_iterator iter = m_Sections.begin(); iter != m_Sections.end(); iter++)
|
|
|
|
{
|
|
|
|
CConfigSettingSection * Section = *iter;
|
|
|
|
|
2015-05-24 18:35:47 +00:00
|
|
|
for (size_t i = 0; i < Section->GetPageCount(); i++ )
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
CSettingsPage * Page = Section->GetPage(i);
|
|
|
|
Page->ApplySettings(UpdateScreen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (UpdateScreen)
|
|
|
|
{
|
|
|
|
::EnableWindow(GetDlgItem(IDAPPLY),false);
|
2008-12-04 10:41:51 +00:00
|
|
|
::EnableWindow(GetDlgItem(IDC_RESET_PAGE), m_CurrentPage->EnableReset());
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
2010-06-29 02:11:22 +00:00
|
|
|
|
2012-11-29 11:24:38 +00:00
|
|
|
|
2015-10-25 10:50:28 +00:00
|
|
|
if (!g_Settings->LoadStringVal(Game_IniKey).empty())
|
2012-11-29 11:24:38 +00:00
|
|
|
{
|
2015-10-25 10:50:28 +00:00
|
|
|
stdstr GoodName = g_Settings->LoadStringVal(Rdb_GoodName);
|
2012-11-29 11:24:38 +00:00
|
|
|
if (GoodName.length() > 0)
|
|
|
|
{
|
|
|
|
g_Settings->SaveString(Game_GoodName,GoodName);
|
|
|
|
}
|
|
|
|
}
|
2010-06-29 02:11:22 +00:00
|
|
|
CSettingTypeApplication::Flush();
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
|
2012-10-05 09:14:32 +00:00
|
|
|
LRESULT CSettingConfig::OnPageListItemChanged(NMHDR* /*phdr*/)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
HTREEITEM hItem = m_PagesTreeList.GetSelectedItem();
|
|
|
|
CSettingsPage * Page = (CSettingsPage * )m_PagesTreeList.GetItemData(hItem);
|
|
|
|
|
|
|
|
if (Page)
|
|
|
|
{
|
|
|
|
if (m_CurrentPage)
|
|
|
|
{
|
|
|
|
m_CurrentPage->HidePage();
|
|
|
|
}
|
|
|
|
m_CurrentPage = Page;
|
2008-11-14 20:51:06 +00:00
|
|
|
m_CurrentPage->ShowPage();
|
2008-12-04 10:41:51 +00:00
|
|
|
::EnableWindow(GetDlgItem(IDC_RESET_PAGE), m_CurrentPage->EnableReset());
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
return 0; // retval ignored
|
|
|
|
}
|
|
|
|
|
2012-10-05 09:14:32 +00:00
|
|
|
LRESULT CSettingConfig::OnSettingPageChanged ( UINT /*uMsg*/, WPARAM /*wPage*/, LPARAM /*lParam*/)
|
2008-11-14 20:51:06 +00:00
|
|
|
{
|
|
|
|
::EnableWindow(GetDlgItem(IDAPPLY),true);
|
2008-12-04 10:41:51 +00:00
|
|
|
::EnableWindow(GetDlgItem(IDC_RESET_PAGE), m_CurrentPage->EnableReset());
|
2008-11-14 20:51:06 +00:00
|
|
|
BoldChangedPages(m_PagesTreeList.GetRootItem());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSettingConfig::BoldChangedPages ( HTREEITEM hItem )
|
|
|
|
{
|
|
|
|
if (hItem == m_PagesTreeList.GetRootItem())
|
|
|
|
{
|
|
|
|
::EnableWindow(GetDlgItem(IDC_RESET_ALL), false);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
2008-11-14 20:51:06 +00:00
|
|
|
bool bEnableResetAll = false;
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
while (hItem)
|
|
|
|
{
|
|
|
|
CSettingsPage * Page = (CSettingsPage * )m_PagesTreeList.GetItemData(hItem);
|
|
|
|
if (Page)
|
|
|
|
{
|
|
|
|
m_PagesTreeList.SetItemState(hItem,Page->EnableReset() ? TVIS_BOLD : 0,TVIS_BOLD);
|
|
|
|
if (Page->EnableReset())
|
|
|
|
{
|
|
|
|
bEnableResetAll = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BoldChangedPages(m_PagesTreeList.GetChildItem(hItem));
|
|
|
|
hItem = m_PagesTreeList.GetNextSiblingItem(hItem);
|
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
if (bEnableResetAll)
|
|
|
|
{
|
|
|
|
::EnableWindow(GetDlgItem(IDC_RESET_ALL), true);
|
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
2015-09-07 19:47:44 +00:00
|
|
|
#endif
|