From 943f2d109b631bd3098cf2bc0be947fa89b74499 Mon Sep 17 00:00:00 2001 From: shygoo Date: Fri, 28 Dec 2018 00:32:56 -0600 Subject: [PATCH] Hack to get settings window working in wine --- .../UserInterface/SettingsConfig.cpp | 44 ++++++++++++++++++- .../Project64/UserInterface/SettingsConfig.h | 3 ++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Source/Project64/UserInterface/SettingsConfig.cpp b/Source/Project64/UserInterface/SettingsConfig.cpp index 1b45c2375..598a825a0 100644 --- a/Source/Project64/UserInterface/SettingsConfig.cpp +++ b/Source/Project64/UserInterface/SettingsConfig.cpp @@ -9,7 +9,8 @@ CSettingConfig::CSettingConfig(bool bJustGameSetting /* = false */) : m_GeneralOptionsPage(NULL), m_AdvancedPage(NULL), m_DefaultsPage(NULL), - m_GameConfig(bJustGameSetting) + m_GameConfig(bJustGameSetting), + m_bTVNSelChangedSupported(false) { } @@ -291,6 +292,8 @@ void CSettingConfig::ApplySettings(bool UpdateScreen) LRESULT CSettingConfig::OnPageListItemChanged(NMHDR* /*phdr*/) { + m_bTVNSelChangedSupported = true; + HTREEITEM hItem = m_PagesTreeList.GetSelectedItem(); CSettingsPage * Page = (CSettingsPage *)m_PagesTreeList.GetItemData(hItem); @@ -304,9 +307,48 @@ LRESULT CSettingConfig::OnPageListItemChanged(NMHDR* /*phdr*/) m_CurrentPage->ShowPage(); ::EnableWindow(GetDlgItem(IDC_RESET_PAGE), m_CurrentPage->EnableReset()); } + return 0; // retval ignored } +// fallback to using HitTest if TVN_SELCHANGED isn't working +LRESULT CSettingConfig::OnPageListClicked(NMHDR*) +{ + if (m_bTVNSelChangedSupported) + { + return 0; + } + + DWORD dwClickPos = GetMessagePos(); + CPoint clickPt = CPoint(dwClickPos); + ScreenToClient(&clickPt); + + CRect treeRect; + m_PagesTreeList.GetWindowRect(treeRect); + ScreenToClient(&treeRect); + + clickPt.x -= treeRect.left; + clickPt.y -= treeRect.top; + clickPt.y -= 2; + + UINT uFlags; + HTREEITEM hItem = m_PagesTreeList.HitTest(clickPt, &uFlags); + + CSettingsPage * Page = (CSettingsPage *)m_PagesTreeList.GetItemData(hItem); + + if (Page) + { + if (m_CurrentPage) + { + m_CurrentPage->HidePage(); + } + m_CurrentPage = Page; + m_CurrentPage->ShowPage(); + ::EnableWindow(GetDlgItem(IDC_RESET_PAGE), m_CurrentPage->EnableReset()); + } + return 0; // retval ignored +} + LRESULT CSettingConfig::OnSettingPageChanged(UINT /*uMsg*/, WPARAM /*wPage*/, LPARAM /*lParam*/) { ::EnableWindow(GetDlgItem(IDAPPLY), true); diff --git a/Source/Project64/UserInterface/SettingsConfig.h b/Source/Project64/UserInterface/SettingsConfig.h index 1717c5994..34612b9f9 100644 --- a/Source/Project64/UserInterface/SettingsConfig.h +++ b/Source/Project64/UserInterface/SettingsConfig.h @@ -13,6 +13,7 @@ public: MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked) NOTIFY_HANDLER_EX(IDC_PAGELIST, TVN_SELCHANGED, OnPageListItemChanged) + NOTIFY_HANDLER_EX(IDC_PAGELIST, NM_CLICK, OnPageListClicked) MESSAGE_HANDLER_EX(PSM_CHANGED, OnSettingPageChanged) REFLECT_NOTIFICATIONS() END_MSG_MAP() @@ -22,6 +23,7 @@ public: LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled); LRESULT OnPageListItemChanged(NMHDR* phdr); + LRESULT OnPageListClicked(NMHDR* phdr); LRESULT OnSettingPageChanged(UINT /*uMsg*/, WPARAM wPage, LPARAM /*lParam*/); public: @@ -42,4 +44,5 @@ private: SETTING_SECTIONS m_Sections; CSettingsPage * m_CurrentPage, *m_GeneralOptionsPage, *m_AdvancedPage, *m_DefaultsPage; bool m_GameConfig; + bool m_bTVNSelChangedSupported; };