From ef30fc7fb88ea03a532a711dd82b49929c9fb0c9 Mon Sep 17 00:00:00 2001 From: CEnnis91 Date: Fri, 23 Jun 2023 14:24:07 -0400 Subject: [PATCH] Project64: Improve flexibility of advanced mode settings toggle --- .../Settings/SettingsPage-AdvancedOptions.h | 4 + .../Settings/SettingsPage-Defaults.h | 4 + .../Settings/SettingsPage-Directories.cpp | 3 +- .../Settings/SettingsPage-Directories.h | 7 +- .../Settings/SettingsPage-DiskDrive.h | 4 + .../Settings/SettingsPage-Game-DiskDrive.h | 4 + .../Settings/SettingsPage-Game-General.h | 4 + .../Settings/SettingsPage-Game-Plugin.h | 4 + .../Settings/SettingsPage-Game-Recompiler.h | 4 + .../Settings/SettingsPage-Game-Status.h | 4 + .../Settings/SettingsPage-GameBrowser.h | 4 + .../Settings/SettingsPage-KeyboardShortcuts.h | 4 + .../Settings/SettingsPage-Options.h | 4 + .../Settings/SettingsPage-Plugin.h | 4 + .../UserInterface/Settings/SettingsPage.h | 9 ++ .../UserInterface/SettingsConfig.cpp | 98 +++++++++---------- .../Project64/UserInterface/SettingsConfig.h | 3 +- 17 files changed, 115 insertions(+), 53 deletions(-) diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-AdvancedOptions.h b/Source/Project64/UserInterface/Settings/SettingsPage-AdvancedOptions.h index cbd618c98..a29a0b5e0 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-AdvancedOptions.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage-AdvancedOptions.h @@ -39,6 +39,10 @@ public: void ApplySettings(bool UpdateScreen); bool EnableReset(void); void ResetPage(void); + bool PageAccessible(bool AdvancedMode) + { + return AdvancedMode; + } private: void UpdatePageSettings(void); diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Defaults.h b/Source/Project64/UserInterface/Settings/SettingsPage-Defaults.h index 0bc10732f..70166c6d3 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Defaults.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Defaults.h @@ -38,6 +38,10 @@ public: void ApplySettings(bool UpdateScreen); bool EnableReset(void); void ResetPage(void); + bool PageAccessible(bool AdvancedMode) + { + return AdvancedMode; + } private: void UpdatePageSettings(void); diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Directories.cpp b/Source/Project64/UserInterface/Settings/SettingsPage-Directories.cpp index 4d73f8c80..e39121a08 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Directories.cpp +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Directories.cpp @@ -5,8 +5,7 @@ COptionsDirectoriesPage::COptionsDirectoriesPage(HWND hParent, const RECT & rcDispay) : m_InUpdateSettings(false) { - Create(hParent); - if (m_hWnd == nullptr) + if (!Create(hParent, rcDispay)) { return; } diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Directories.h b/Source/Project64/UserInterface/Settings/SettingsPage-Directories.h index 1c661caea..acbe28eb3 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Directories.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Directories.h @@ -1,7 +1,7 @@ #pragma once class COptionsDirectoriesPage : - public CDialogImpl, + public CSettingsPageImpl, public CSettingsPage { BEGIN_MSG_MAP_EX(COptionsDirectoriesPage) @@ -48,6 +48,11 @@ public: bool EnableReset(void); void ResetPage(void); + bool PageAccessible(bool AdvancedMode) + { + return CSettingsPageImpl::PageAccessible(AdvancedMode); + } + private: void SelectPluginDir(UINT Code, int id, HWND ctl); void SelectAutoDir(UINT Code, int id, HWND ctl); diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-DiskDrive.h b/Source/Project64/UserInterface/Settings/SettingsPage-DiskDrive.h index 8b0a75293..c3d522dc6 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-DiskDrive.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage-DiskDrive.h @@ -34,6 +34,10 @@ public: void ApplySettings(bool UpdateScreen); bool EnableReset(void); void ResetPage(void); + bool PageAccessible(bool AdvancedMode) + { + return CSettingsPageImpl::PageAccessible(AdvancedMode); + } private: void SelectIplDirJp(UINT Code, int id, HWND ctl); diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Game-DiskDrive.h b/Source/Project64/UserInterface/Settings/SettingsPage-Game-DiskDrive.h index 731d64770..1919b40a8 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Game-DiskDrive.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Game-DiskDrive.h @@ -31,4 +31,8 @@ public: void ApplySettings(bool UpdateScreen); bool EnableReset(void); void ResetPage(void); + bool PageAccessible(bool AdvancedMode) + { + return CSettingsPageImpl::PageAccessible(AdvancedMode); + } }; diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Game-General.h b/Source/Project64/UserInterface/Settings/SettingsPage-Game-General.h index 8a53339aa..d2370ebcc 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Game-General.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Game-General.h @@ -43,4 +43,8 @@ public: void ApplySettings(bool UpdateScreen); bool EnableReset(void); void ResetPage(void); + bool PageAccessible(bool AdvancedMode) + { + return CSettingsPageImpl::PageAccessible(AdvancedMode); + } }; diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.h b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.h index b14077c60..0af8d0aa7 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Plugin.h @@ -40,6 +40,10 @@ public: void ApplySettings(bool UpdateScreen); bool EnableReset(void); void ResetPage(void); + bool PageAccessible(bool AdvancedMode) + { + return CSettingsPageImpl::PageAccessible(AdvancedMode); + } private: void GfxPluginAbout(UINT /*Code*/, int /*id*/, HWND /*ctl*/) diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Recompiler.h b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Recompiler.h index 603f691dd..7cf4bc1e2 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Recompiler.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Recompiler.h @@ -39,6 +39,10 @@ public: void ApplySettings(bool UpdateScreen); bool EnableReset(void); void ResetPage(void); + bool PageAccessible(bool AdvancedMode) + { + return CSettingsPageImpl::PageAccessible(AdvancedMode); + } private: CPartialGroupBox m_SelfModGroup; diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Status.h b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Status.h index f7b05f7f9..3c6e08753 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Game-Status.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Game-Status.h @@ -31,4 +31,8 @@ public: void ApplySettings(bool UpdateScreen); bool EnableReset(void); void ResetPage(void); + bool PageAccessible(bool AdvancedMode) + { + return CSettingsPageImpl::PageAccessible(AdvancedMode); + } }; diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-GameBrowser.h b/Source/Project64/UserInterface/Settings/SettingsPage-GameBrowser.h index abf15d432..dbff205c2 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-GameBrowser.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage-GameBrowser.h @@ -33,6 +33,10 @@ public: void ApplySettings(bool UpdateScreen); bool EnableReset(void); void ResetPage(void); + bool PageAccessible(bool AdvancedMode) + { + return CSettingsPageImpl::PageAccessible(AdvancedMode); + } private: void UpdatePageSettings(void); diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-KeyboardShortcuts.h b/Source/Project64/UserInterface/Settings/SettingsPage-KeyboardShortcuts.h index e5de8016d..7361c92d7 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-KeyboardShortcuts.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage-KeyboardShortcuts.h @@ -38,6 +38,10 @@ public: void ApplySettings(bool UpdateScreen); bool EnableReset(void); void ResetPage(void); + bool PageAccessible(bool AdvancedMode) + { + return CSettingsPageImpl::PageAccessible(AdvancedMode); + } private: void OnCpuStateChanged(UINT Code, int id, HWND ctl); diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Options.h b/Source/Project64/UserInterface/Settings/SettingsPage-Options.h index 9ad66e105..7dae5476b 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Options.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Options.h @@ -35,6 +35,10 @@ public: void ApplySettings(bool UpdateScreen); bool EnableReset(void); void ResetPage(void); + bool PageAccessible(bool AdvancedMode) + { + return CSettingsPageImpl::PageAccessible(AdvancedMode); + } private: void OnBasicMode(UINT Code, int id, HWND ctl); diff --git a/Source/Project64/UserInterface/Settings/SettingsPage-Plugin.h b/Source/Project64/UserInterface/Settings/SettingsPage-Plugin.h index f92e23910..9f78ca9e8 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage-Plugin.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage-Plugin.h @@ -39,6 +39,10 @@ public: void ApplySettings(bool UpdateScreen); bool EnableReset(void); void ResetPage(void); + bool PageAccessible(bool AdvancedMode) + { + return CSettingsPageImpl::PageAccessible(AdvancedMode); + } private: void GfxPluginAbout(UINT /*Code*/, int /*id*/, HWND /*ctl*/) diff --git a/Source/Project64/UserInterface/Settings/SettingsPage.h b/Source/Project64/UserInterface/Settings/SettingsPage.h index dd06b2547..db6e417ac 100644 --- a/Source/Project64/UserInterface/Settings/SettingsPage.h +++ b/Source/Project64/UserInterface/Settings/SettingsPage.h @@ -13,6 +13,7 @@ public: virtual void ApplySettings(bool UpdateScreen) = 0; virtual bool EnableReset(void) = 0; virtual void ResetPage(void) = 0; + virtual bool PageAccessible(bool AdvancedMode) = 0; }; template @@ -533,6 +534,14 @@ public: } } +#pragma warning(push) +#pragma warning(disable : 4100) // warning C4100: 'AdvancedMode': unreferenced formal parameter + bool PageAccessible(bool AdvancedMode) + { + return true; + } +#pragma warning(pop) + protected: TextBoxList m_TxtBoxList; ButtonList m_ButtonList; diff --git a/Source/Project64/UserInterface/SettingsConfig.cpp b/Source/Project64/UserInterface/SettingsConfig.cpp index 61a368e8e..67ae7fff7 100644 --- a/Source/Project64/UserInterface/SettingsConfig.cpp +++ b/Source/Project64/UserInterface/SettingsConfig.cpp @@ -7,8 +7,6 @@ CSettingConfig::CSettingConfig(bool bJustGameSetting /* = false */) : m_CurrentPage(nullptr), m_GeneralOptionsPage(nullptr), - m_AdvancedPage(nullptr), - m_DefaultsPage(nullptr), m_GameConfig(bJustGameSetting), m_bTVNSelChangedSupported(false) { @@ -49,6 +47,7 @@ void CSettingConfig::Display(void * ParentWindow) void CSettingConfig::UpdateAdvanced(bool AdvancedMode) { UpdateAdvanced(AdvancedMode, m_PagesTreeList.GetRootItem()); + DisplayAccessibleSections(AdvancedMode, true); BoldChangedPages(m_PagesTreeList.GetRootItem()); } @@ -57,22 +56,58 @@ void CSettingConfig::UpdateAdvanced(bool AdvancedMode, HTREEITEM hItem) while (hItem) { CSettingsPage * Page = (CSettingsPage *)m_PagesTreeList.GetItemData(hItem); - if (!AdvancedMode && (Page == m_AdvancedPage || Page == m_DefaultsPage)) + if (Page == m_GeneralOptionsPage) + { + UpdateAdvanced(AdvancedMode, m_PagesTreeList.GetChildItem(hItem)); + hItem = m_PagesTreeList.GetNextSiblingItem(hItem); + } + else { HTREEITEM hPage = hItem; hItem = m_PagesTreeList.GetNextSiblingItem(hItem); m_PagesTreeList.DeleteItem(hPage); } - else if (AdvancedMode && Page == m_GeneralOptionsPage) + } +} + +void CSettingConfig::DisplayAccessibleSections(bool AdvancedMode, bool UpdateSections) +{ + bool bFirstItem = true; + + for (SETTING_SECTIONS::const_iterator iter = m_Sections.begin(); iter != m_Sections.end(); iter++) + { + CConfigSettingSection * Section = *iter; + + HTREEITEM hSectionItem = nullptr; + + for (size_t i = 0; i < Section->GetPageCount(); i++) { - m_PagesTreeList.InsertItem(TVIF_TEXT | TVIF_PARAM, wGS(m_AdvancedPage->PageTitle()).c_str(), 0, 0, 0, 0, (LPARAM)m_AdvancedPage, hItem, TVI_FIRST); - m_PagesTreeList.InsertItem(TVIF_TEXT | TVIF_PARAM, wGS(m_DefaultsPage->PageTitle()).c_str(), 0, 0, 0, 0, (LPARAM)m_DefaultsPage, hItem, TVI_FIRST); - break; + CSettingsPage * Page = Section->GetPage((int32_t)((UINT_PTR)i)); + if (UpdateSections && Page == m_GeneralOptionsPage) + { + hSectionItem = m_PagesTreeList.GetRootItem(); + continue; + } + if (!Page->PageAccessible(AdvancedMode)) + { + continue; + } + if (i == 0) + { + hSectionItem = m_PagesTreeList.InsertItem(TVIF_TEXT | TVIF_PARAM, Section->GetPageTitle(), 0, 0, 0, 0, (LPARAM)Page, TVI_ROOT, TVI_LAST); + continue; + } + if (hSectionItem == nullptr) + { + continue; + } + m_PagesTreeList.InsertItem(TVIF_TEXT | TVIF_PARAM, wGS(Page->PageTitle()).c_str(), 0, 0, 0, 0, (LPARAM)Page, hSectionItem, TVI_LAST); } - else + if (bFirstItem && hSectionItem != nullptr) { - UpdateAdvanced(AdvancedMode, m_PagesTreeList.GetChildItem(hItem)); - hItem = m_PagesTreeList.GetNextSiblingItem(hItem); + bFirstItem = false; + m_PagesTreeList.Expand(hSectionItem); + m_PagesTreeList.SelectItem(hSectionItem); } } } @@ -129,16 +164,13 @@ LRESULT CSettingConfig::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /* } m_GeneralOptionsPage = new CGeneralOptionsPage(this, this->m_hWnd, rcSettingInfo); - m_AdvancedPage = new CAdvancedOptionsPage(this->m_hWnd, rcSettingInfo); - m_DefaultsPage = new CDefaultsOptionsPage(this->m_hWnd, rcSettingInfo); - m_DiskDrivePage = new CDiskDrivePage(this->m_hWnd, rcSettingInfo); SettingsSection = new CConfigSettingSection(wGS(TAB_OPTIONS).c_str()); SettingsSection->AddPage(m_GeneralOptionsPage); - SettingsSection->AddPage(m_AdvancedPage); - SettingsSection->AddPage(m_DefaultsPage); + SettingsSection->AddPage(new CAdvancedOptionsPage(this->m_hWnd, rcSettingInfo)); + SettingsSection->AddPage(new CDefaultsOptionsPage(this->m_hWnd, rcSettingInfo)); SettingsSection->AddPage(new COptionsDirectoriesPage(this->m_hWnd, rcSettingInfo)); - SettingsSection->AddPage(m_DiskDrivePage); + SettingsSection->AddPage(new CDiskDrivePage(this->m_hWnd, rcSettingInfo)); m_Sections.push_back(SettingsSection); SettingsSection = new CConfigSettingSection(wGS(TAB_ROMSELECTION).c_str()); @@ -174,40 +206,8 @@ LRESULT CSettingConfig::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /* 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 = nullptr; - - for (size_t i = 0; i < Section->GetPageCount(); i++) - { - CSettingsPage * Page = Section->GetPage((int32_t)((UINT_PTR)i)); - if (HideAdvanced && (Page == m_AdvancedPage || Page == m_DefaultsPage)) - { - continue; - } - if (i == 0) - { - hSectionItem = m_PagesTreeList.InsertItem(TVIF_TEXT | TVIF_PARAM, Section->GetPageTitle(), 0, 0, 0, 0, (LPARAM)Page, TVI_ROOT, TVI_LAST); - continue; - } - if (hSectionItem == nullptr) - { - continue; - } - m_PagesTreeList.InsertItem(TVIF_TEXT | TVIF_PARAM, wGS(Page->PageTitle()).c_str(), 0, 0, 0, 0, (LPARAM)Page, hSectionItem, TVI_LAST); - } - if (bFirstItem && hSectionItem != nullptr) - { - bFirstItem = false; - m_PagesTreeList.Expand(hSectionItem); - m_PagesTreeList.SelectItem(hSectionItem); - } - } - + DisplayAccessibleSections(!HideAdvanced, false); BoldChangedPages(m_PagesTreeList.GetRootItem()); return TRUE; } diff --git a/Source/Project64/UserInterface/SettingsConfig.h b/Source/Project64/UserInterface/SettingsConfig.h index b4fbebcbb..39af880ec 100644 --- a/Source/Project64/UserInterface/SettingsConfig.h +++ b/Source/Project64/UserInterface/SettingsConfig.h @@ -40,6 +40,7 @@ public: private: void UpdateAdvanced(bool AdvancedMode, HTREEITEM hItem); + void DisplayAccessibleSections(bool AdvancedMode, bool UpdateSections); void ApplySettings(bool UpdateScreen); void BoldChangedPages(HTREEITEM hItem); @@ -47,7 +48,7 @@ private: CTreeViewCtrl m_PagesTreeList; SETTING_SECTIONS m_Sections; - CSettingsPage *m_CurrentPage, *m_GeneralOptionsPage, *m_AdvancedPage, *m_DefaultsPage, *m_DiskDrivePage; + CSettingsPage *m_CurrentPage, *m_GeneralOptionsPage; bool m_GameConfig; bool m_bTVNSelChangedSupported; };