2010-06-07 02:23:58 +00:00
|
|
|
#include "stdafx.h"
|
2008-09-18 03:15:49 +00:00
|
|
|
#include "Settings Config.h"
|
|
|
|
#include "Settings/Settings Page.h"
|
2010-06-29 02:11:22 +00:00
|
|
|
#include "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)
|
|
|
|
{
|
|
|
|
DoModal((HWND)ParentWindow);
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
m_PagesTreeList.InsertItem(TVIF_TEXT | TVIF_PARAM,GS(m_AdvancedPage->PageTitle()),0,0,0,0,(ULONG)m_AdvancedPage,hItem,TVI_FIRST);
|
|
|
|
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*/)
|
|
|
|
{
|
2008-11-14 20:51:06 +00:00
|
|
|
stdstr ConfigRomTitle, GameIni(_Settings->LoadString(Game_IniKey));
|
|
|
|
|
|
|
|
if (!GameIni.empty())
|
|
|
|
{
|
|
|
|
ConfigRomTitle.Format("Config: %s",_Settings->LoadString(Game_GoodName).c_str());
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
if (m_GameConfig)
|
|
|
|
{
|
2008-12-04 10:41:51 +00:00
|
|
|
if (_Settings->LoadBool(Setting_RdbEditor))
|
|
|
|
{
|
|
|
|
SetWindowText(stdstr_f("%s ** RDB Edit Mode **",ConfigRomTitle.c_str()).c_str());
|
|
|
|
} else {
|
|
|
|
SetWindowText(ConfigRomTitle.c_str());
|
|
|
|
}
|
2008-11-14 20:51:06 +00:00
|
|
|
} else {
|
2008-12-04 10:41:51 +00:00
|
|
|
if (_Settings->LoadBool(Setting_RdbEditor))
|
|
|
|
{
|
|
|
|
SetWindowText(stdstr_f("%s ** RDB Edit Mode **",GS(OPTIONS_TITLE)).c_str());
|
|
|
|
} else {
|
|
|
|
SetWindowText(GS(OPTIONS_TITLE));
|
|
|
|
}
|
2008-11-14 20:51:06 +00:00
|
|
|
|
2008-12-01 18:19:49 +00:00
|
|
|
if (_Settings->LoadBool(Setting_PluginPageFirst))
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
|
2008-12-01 18:19:49 +00:00
|
|
|
if (!_Settings->LoadBool(Setting_PluginPageFirst))
|
|
|
|
{
|
|
|
|
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())
|
|
|
|
{
|
|
|
|
CConfigSettingSection * GameSettings = new CConfigSettingSection(ConfigRomTitle.c_str());
|
|
|
|
GameSettings->AddPage(new CGameGeneralPage(this->m_hWnd,rcSettingInfo ));
|
|
|
|
GameSettings->AddPage(new CGameRecompilePage(this->m_hWnd,rcSettingInfo ));
|
|
|
|
GameSettings->AddPage(new CGamePluginPage(this->m_hWnd,rcSettingInfo ));
|
|
|
|
if (_Settings->LoadBool(Setting_RdbEditor))
|
|
|
|
{
|
|
|
|
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-09-27 06:57:51 +00:00
|
|
|
bool HideAdvanced = _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
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
for (int i = 0; i < Section->GetPageCount(); i++ )
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2008-11-14 20:51:06 +00:00
|
|
|
hSectionItem = m_PagesTreeList.InsertItem(TVIF_TEXT | TVIF_PARAM,Section->GetPageTitle(),0,0,0,0,(ULONG)Page,TVI_ROOT,TVI_LAST);
|
|
|
|
continue;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
if (hSectionItem == NULL)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
m_PagesTreeList.InsertItem(TVIF_TEXT | TVIF_PARAM,GS(Page->PageTitle()),0,0,0,0,(ULONG)Page,hSectionItem,TVI_LAST);
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CSettingConfig::OnClicked (WORD wNotifyCode, WORD wID, HWND , BOOL& bHandled)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
|
|
|
for (int i = 0; i < Section->GetPageCount(); i++ )
|
|
|
|
{
|
|
|
|
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 )
|
|
|
|
{
|
2008-12-04 10:41:51 +00:00
|
|
|
stdstr GameIni(_Settings->LoadString(Game_IniKey));
|
|
|
|
|
|
|
|
if (!GameIni.empty())
|
|
|
|
{
|
|
|
|
stdstr GoodName;
|
|
|
|
if (!_Settings->LoadString(Game_GoodName,GoodName))
|
|
|
|
{
|
|
|
|
_Settings->SaveString(Game_GoodName,GoodName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
for (int i = 0; i < Section->GetPageCount(); i++ )
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
CSettingTypeApplication::Flush();
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
LRESULT CSettingConfig::OnPageListItemChanged(NMHDR* phdr)
|
|
|
|
{
|
|
|
|
NMLISTVIEW* pnmlv = (NMLISTVIEW*) phdr;
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CSettingConfig::OnSettingPageChanged ( UINT /*uMsg*/, WPARAM wPage, LPARAM /*lParam*/)
|
|
|
|
{
|
|
|
|
::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
|
|
|
}
|
2008-11-14 20:51:06 +00:00
|
|
|
|