void CSettingConfig::BoldChangedPages(HTREEITEM hItem) { if (hItem == m_PagesTreeList.GetRootItem()) { ::EnableWindow(GetDlgItem(IDC_RESET_ALL), false); } bool bEnableResetAll = false; 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); } if (bEnableResetAll) { ::EnableWindow(GetDlgItem(IDC_RESET_ALL), true); } }
CSettingsPage* CSettingsSheet::GetPage(LPCTSTR pszClass) const { for ( int nPage = 0 ; nPage < GetPageCount() ; nPage++ ) { CSettingsPage* pPage = GetPage( nPage ); if ( _tcscmp( CString( pPage->GetRuntimeClass()->m_lpszClassName ), pszClass ) == 0 ) return pPage; } return NULL; }
CSettingsPage* CSettingsSheet::GetPage(CRuntimeClass* pClass) const { for ( int nPage = 0 ; nPage < GetPageCount() ; nPage++ ) { CSettingsPage* pPage = GetPage( nPage ); if ( pPage->IsKindOf( pClass ) ) return pPage; } return NULL; }
void CSettingsSheet::OnCancel() { for ( int nPage = 0 ; nPage < GetPageCount() ; nPage++ ) { CSettingsPage* pPage = GetPage( nPage ); if ( pPage->m_hWnd ) pPage->OnCancel(); } EndDialog( IDCANCEL ); }
void CMediaSettingsPage::OnOK() { UpdateData(); Settings.MediaPlayer.EnablePlay = ( m_bEnablePlay != FALSE ); Settings.MediaPlayer.EnableEnqueue = ( m_bEnableEnqueue != FALSE ); int nSelected = m_wndServices.GetCurSel(); if ( nSelected == nCustomIndex ) nSelected = nSnareazaIndex; Settings.MediaPlayer.ServicePath.clear(); int nCount = m_wndServices.GetCount(); for( int i = 0; i < nCount; ++i ) { CString* psPlayer = (CString*)m_wndServices.GetItemDataPtr( i ); if ( ! psPlayer ) continue; if ( i == nSelected ) *psPlayer += _T("*"); Settings.MediaPlayer.ServicePath.insert( *psPlayer ); } if ( nSelected == nSnareazaIndex ) // Shareaza Media Player is selected Settings.MediaPlayer.ShortPaths = FALSE; CSettingsSheet* pSheet = GetSheet(); for ( INT_PTR nPage = 0 ; nPage < pSheet->GetPageCount() ; nPage++ ) { CSettingsPage* pPage = pSheet->GetPage( nPage ); if ( pPage ) { CString strClass( pPage->GetRuntimeClass()->m_lpszClassName ); if ( strClass == _T("CPluginsSettingsPage") ) { CPluginsSettingsPage* pPluginPage = static_cast< CPluginsSettingsPage* >( pPage ); pPluginPage->UpdateList(); break; } } } Settings.MediaPlayer.FileTypes.clear(); for ( int nItem = 0 ; nItem < m_wndList.GetCount() ; nItem++ ) { CString str; m_wndList.GetLBText( nItem, str ); if ( str.GetLength() ) { Settings.MediaPlayer.FileTypes.insert( str ); } } CSettingsPage::OnOK(); }
BOOL CSettingsSheet::SkinMe(LPCTSTR pszSkin, UINT nIcon, BOOL bLanguage) { EnableBanner( FALSE ); m_szPages.cx = m_szPages.cy = 0; for ( int nPage = 0 ; nPage < GetPageCount() ; nPage++ ) { CSettingsPage* pPage = GetPage( nPage ); CDialogTemplate pTemplate; if ( pPage->GetTemplateName() == NULL ) continue; if ( pTemplate.Load( pPage->GetTemplateName() ) ) { CSize size; pTemplate.GetSizeInPixels( &size ); m_szPages.cx = max( m_szPages.cx, size.cx ); m_szPages.cy = max( m_szPages.cy, size.cy ); } } CRect rcWindow( 0, 0, m_szPages.cx + m_nListWidth + m_nListMargin, m_szPages.cy + + m_nButtonHeight + 8 + 8 + 2 ); CalcWindowRect( &rcWindow ); SetWindowPos( &wndTop, 0, 0, rcWindow.Width(), rcWindow.Height(), SWP_NOMOVE|SWP_NOZORDER ); CRect rcTree( 0, 2, m_nListWidth, 2 + m_szPages.cy ); m_wndTree.MoveWindow( &rcTree ); CRect rcButton( 8, 2 + m_szPages.cy + 8, 8 + m_nButtonWidth, 2 + m_szPages.cy + 8 + m_nButtonHeight ); m_wndOK.MoveWindow( &rcButton ); rcButton.OffsetRect( rcButton.Width() + 8, 0 ); m_wndCancel.MoveWindow( &rcButton ); rcButton.OffsetRect( rcButton.Width() + 8, 0 ); m_wndApply.MoveWindow( &rcButton ); CenterWindow(); SetActivePage( m_pPage ? m_pPage : m_pFirst ); return CSkinDialog::SkinMe( pszSkin, nIcon, bLanguage ); }
void CSettingsSheet::OnApply() { if ( m_pPage && ! m_pPage->OnKillActive() ) return; for ( int nPage = 0 ; nPage < GetPageCount() ; nPage++ ) { CSettingsPage* pPage = GetPage( nPage ); if ( pPage->m_hWnd && ! pPage->OnApply() ) return; } SetModified( FALSE ); }
void CSettingsSheet::OnOK() { if ( m_pPage && ! m_pPage->OnKillActive() ) return; for ( int nPage = 0 ; nPage < GetPageCount() ; nPage++ ) { CSettingsPage* pPage = GetPage( nPage ); if ( pPage->m_hWnd ) pPage->OnOK(); } EndDialog( IDOK ); }
void CSettingsSheet::Layout() { TEXTMETRIC txtMetric; CDC* pDC = GetDC(); pDC->SelectObject( &CoolInterface.m_fntNormal ); pDC->GetTextMetrics( &txtMetric ); ReleaseDC( pDC ); m_nButtonHeight = ( txtMetric.tmHeight + txtMetric.tmExternalLeading ) + 10; m_szPages.cx = m_szPages.cy = 0; for ( int nPage = 0 ; nPage < GetPageCount() ; nPage++ ) { CSettingsPage* pPage = GetPage( nPage ); CDialogTemplate pTemplate; if ( pPage->GetTemplateName() == NULL ) continue; if ( pTemplate.Load( pPage->GetTemplateName() ) ) { CSize size; pTemplate.GetSizeInPixels( &size ); m_szPages.cx = max( m_szPages.cx, size.cx ); m_szPages.cy = max( m_szPages.cy, size.cy ); } } CRect rc( 0, 0, m_szPages.cx, m_szPages.cy ); rc.right += m_nListWidth + m_nListMargin; rc.right += m_nLeftMargin; rc.bottom += m_nTopMargin + m_nButtonHeight + 16; CalcWindowRect( &rc ); SetWindowPos( &wndTop, 0, 0, rc.Width(), rc.Height(), SWP_NOMOVE|SWP_NOZORDER ); rc.SetRect( m_nLeftMargin, m_nTopMargin, 0, 0 ); rc.right = rc.left + m_nListWidth; rc.bottom = rc.top + m_szPages.cy; m_wndTree.MoveWindow( &rc ); rc.SetRect( 8, rc.bottom + 8, 76, m_nButtonHeight ); rc.right += rc.left; rc.bottom += rc.top; m_wndOK.MoveWindow( &rc ); rc.OffsetRect( rc.Width() + 8, 0 ); m_wndCancel.MoveWindow( &rc ); rc.OffsetRect( rc.Width() + 8, 0 ); m_wndApply.MoveWindow( &rc ); }
void CSettingConfig::ApplySettings( bool UpdateScreen ) { stdstr GameIni(g_Settings->LoadString(Game_IniKey)); if (!GameIni.empty()) { stdstr GoodName; if (!g_Settings->LoadString(Game_GoodName,GoodName)) { g_Settings->SaveString(Game_GoodName,GoodName); } } for (SETTING_SECTIONS::const_iterator iter = m_Sections.begin(); iter != m_Sections.end(); iter++) { CConfigSettingSection * Section = *iter; for (size_t i = 0; i < Section->GetPageCount(); i++ ) { CSettingsPage * Page = Section->GetPage(i); Page->ApplySettings(UpdateScreen); } } if (UpdateScreen) { ::EnableWindow(GetDlgItem(IDAPPLY),false); ::EnableWindow(GetDlgItem(IDC_RESET_PAGE), m_CurrentPage->EnableReset()); } if (!g_Settings->LoadString(Game_IniKey).empty()) { stdstr GoodName = g_Settings->LoadString(Rdb_GoodName); if (GoodName.length() > 0) { g_Settings->SaveString(Game_GoodName,GoodName); } } CSettingTypeApplication::Flush(); }
LRESULT CSettingConfig::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& /*bHandled*/) { switch (wID) { case IDAPPLY: ApplySettings(true); break; case IDOK: ApplySettings(false); EndDialog(1); break; case IDCANCEL: EndDialog(0); break; case IDC_RESET_PAGE: 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 (size_t i = 0; i < Section->GetPageCount(); i++) { CSettingsPage * Page = Section->GetPage(i); if (Page->EnableReset()) { Page->ResetPage(); } } } break; } return FALSE; }
LRESULT CSettingConfig::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { stdstr ConfigRomTitle, GameIni(g_Settings->LoadStringVal(Game_IniKey)); if (!GameIni.empty()) { ConfigRomTitle.Format("Config: %s", g_Settings->LoadStringVal(Game_GoodName).c_str()); } RECT rcSettingInfo; ::GetWindowRect(GetDlgItem(IDC_SETTING_INFO), &rcSettingInfo); ::MapWindowPoints(NULL, m_hWnd, (LPPOINT)&rcSettingInfo, 2); CConfigSettingSection * SettingsSection; //Set the text for all gui Items SetDlgItemTextW(m_hWnd, IDC_RESET_PAGE, wGS(BOTTOM_RESET_PAGE).c_str()); SetDlgItemTextW(m_hWnd, IDC_RESET_ALL, wGS(BOTTOM_RESET_ALL).c_str()); SetDlgItemTextW(m_hWnd, IDOK, wGS(CHEAT_OK).c_str()); SetDlgItemTextW(m_hWnd, IDCANCEL, wGS(CHEAT_CANCEL).c_str()); SetDlgItemTextW(m_hWnd, IDAPPLY, wGS(BOTTOM_APPLY).c_str()); if (m_GameConfig) { if (g_Settings->LoadBool(Setting_RdbEditor)) { SetWindowText(stdstr_f("%s ** RDB Edit Mode **", ConfigRomTitle.c_str()).c_str()); } else { SetWindowText(ConfigRomTitle.c_str()); } } else { if (g_Settings->LoadBool(Setting_RdbEditor)) { SetWindowTextW(m_hWnd, stdstr_f("%s ** RDB Edit Mode **", GS(OPTIONS_TITLE)).ToUTF16().c_str()); } else { ::SetWindowTextW(m_hWnd, wGS(OPTIONS_TITLE).c_str()); } if (g_Settings->LoadBool(Setting_PluginPageFirst)) { SettingsSection = new CConfigSettingSection(wGS(TAB_PLUGIN).c_str()); SettingsSection->AddPage(new COptionPluginPage(this->m_hWnd, rcSettingInfo)); m_Sections.push_back(SettingsSection); } m_GeneralOptionsPage = new CGeneralOptionsPage(this, this->m_hWnd, rcSettingInfo); m_AdvancedPage = new CAdvancedOptionsPage(this->m_hWnd, rcSettingInfo); SettingsSection = new CConfigSettingSection(wGS(TAB_OPTIONS).c_str()); SettingsSection->AddPage(m_GeneralOptionsPage); SettingsSection->AddPage(m_AdvancedPage); SettingsSection->AddPage(new COptionsDirectoriesPage(this->m_hWnd, rcSettingInfo)); m_Sections.push_back(SettingsSection); SettingsSection = new CConfigSettingSection(wGS(TAB_ROMSELECTION).c_str()); SettingsSection->AddPage(new COptionsGameBrowserPage(this->m_hWnd, rcSettingInfo)); m_Sections.push_back(SettingsSection); SettingsSection = new CConfigSettingSection(wGS(TAB_SHORTCUTS).c_str()); SettingsSection->AddPage(new COptionsShortCutsPage(this->m_hWnd, rcSettingInfo)); m_Sections.push_back(SettingsSection); if (!g_Settings->LoadBool(Setting_PluginPageFirst)) { SettingsSection = new CConfigSettingSection(wGS(TAB_PLUGIN).c_str()); SettingsSection->AddPage(new COptionPluginPage(this->m_hWnd, rcSettingInfo)); m_Sections.push_back(SettingsSection); } } //Game Settings if (!GameIni.empty()) { CConfigSettingSection * GameSettings = new CConfigSettingSection(ConfigRomTitle.ToUTF16().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 (g_Settings->LoadBool(Setting_RdbEditor)) { GameSettings->AddPage(new CGameStatusPage(this->m_hWnd, rcSettingInfo)); } m_Sections.push_back(GameSettings); } m_PagesTreeList.Attach(GetDlgItem(IDC_PAGELIST)); bool bFirstItem = true; bool HideAdvanced = g_Settings->LoadBool(UserInterface_BasicMode); for (SETTING_SECTIONS::const_iterator iter = m_Sections.begin(); iter != m_Sections.end(); iter++) { CConfigSettingSection * Section = *iter; HTREEITEM hSectionItem = NULL; for (size_t i = 0; i < Section->GetPageCount(); i++) { CSettingsPage * Page = Section->GetPage(i); if (HideAdvanced && Page == m_AdvancedPage) { continue; } if (i == 0) { hSectionItem = m_PagesTreeList.InsertItemW(TVIF_TEXT | TVIF_PARAM, Section->GetPageTitle(), 0, 0, 0, 0, (ULONG)Page, TVI_ROOT, TVI_LAST); continue; } if (hSectionItem == NULL) { continue; } m_PagesTreeList.InsertItemW(TVIF_TEXT | TVIF_PARAM, wGS(Page->PageTitle()).c_str(), 0, 0, 0, 0, (ULONG)Page, hSectionItem, TVI_LAST); } if (bFirstItem && hSectionItem != NULL) { bFirstItem = false; m_PagesTreeList.Expand(hSectionItem); m_PagesTreeList.SelectItem(hSectionItem); } } BoldChangedPages(m_PagesTreeList.GetRootItem()); return TRUE; }