Project64: Fix deleting an enhancement

This commit is contained in:
zilmar 2022-01-27 14:02:32 +10:30
parent b26de13d64
commit 05bf0f9fb4
2 changed files with 29 additions and 0 deletions

View File

@ -247,6 +247,33 @@ LRESULT CEnhancementUI::OnEnhancementListClicked(NMHDR* lpnmh)
return 0;
}
LRESULT CEnhancementUI::OnPopupDelete(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
int Response = MessageBox(wGS(MSG_DEL_SURE).c_str(), wGS(MSG_DEL_TITLE).c_str(), MB_YESNO | MB_ICONQUESTION);
if (Response != IDYES)
{
return 0;
}
TVITEM item = { 0 };
item.hItem = m_hSelectedItem;
item.mask = TVIF_PARAM;
m_TreeList.GetItem(&item);
ChangeChildrenStatus(TVI_ROOT, false);
for (CEnhancementList::iterator itr = m_Enhancements.begin(); itr != m_Enhancements.end(); itr++)
{
if (item.lParam != (LPARAM)&itr->second)
{
continue;
}
m_Enhancements.erase(itr);
g_Enhancements->UpdateEnhancements(m_Enhancements);
break;
}
RefreshList();
}
LRESULT CEnhancementUI::OnEnhancementListRClicked(NMHDR* pNMHDR)
{
TVHITTESTINFO ht = { 0 };

View File

@ -21,6 +21,7 @@ public:
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
COMMAND_ID_HANDLER(ID_POPUP_EDIT, OnEditEnhancement)
COMMAND_ID_HANDLER(ID_POPUP_ADDENHANCEMENT, OnAddEnhancement)
COMMAND_ID_HANDLER(ID_POPUP_DELETE, OnPopupDelete)
NOTIFY_HANDLER_EX(IDC_ENHANCEMENTLIST, NM_CLICK, OnEnhancementListClicked)
NOTIFY_HANDLER_EX(IDC_ENHANCEMENTLIST, NM_RCLICK, OnEnhancementListRClicked)
NOTIFY_HANDLER_EX(IDC_ENHANCEMENTLIST, NM_DBLCLK, OnEnhancementListDClicked)
@ -44,6 +45,7 @@ private:
LRESULT OnEditEnhancement(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnAddEnhancement(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled );
LRESULT OnCloseCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL & bHandled);
LRESULT OnPopupDelete(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnEnhancementListClicked(NMHDR * lpnmh);
LRESULT OnEnhancementListRClicked(NMHDR * lpnmh);
LRESULT OnEnhancementListDClicked(NMHDR * lpnmh);