Skip to content

Commit

Permalink
update tooltip handling for items
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterCouto committed Nov 14, 2021
1 parent 0926f61 commit 7eed05b
Show file tree
Hide file tree
Showing 13 changed files with 309 additions and 117 deletions.
Binary file modified D2Editor.exe
Binary file not shown.
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ Check the following site for updates at https://github.com/WalterCouto/D2CE<br>
* [d2s Binary File Format](d2s_File_Format.md)<br>

### Revision History
**Version 2.05 (Nov 13, 2021)**<br>
**Version 2.05 (Nov 14, 2021)**<br>
- Updated: Updated: Fix up handling of reading files with a corpse<br>
- Updated: Fix up setting/clearing the is potion bit<br>
<br>

- Added: Items Dialog to allow viewing of all items in inventory<br>
Expand Down
1 change: 1 addition & 0 deletions source/D2Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Revision History
================
Version 2.05 (Nov 14, 2021)
- Updated: Fix up handling of reading files with a corpse
- Updated: Fix up setting/clearing the is potion bit
- Added: Items Dialog to allow viewing of all items in inventory
- Added: Added unit tests to cover file with corpse data
Expand Down
29 changes: 6 additions & 23 deletions source/D2ItemToolTipCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ CD2ItemToolTipCtrl::~CD2ItemToolTipCtrl()
//---------------------------------------------------------------------------
BEGIN_MESSAGE_MAP(CD2ItemToolTipCtrl, CMFCToolTipCtrl)
ON_NOTIFY_REFLECT(TTN_SHOW, &CD2ItemToolTipCtrl::OnShow)
//ON_NOTIFY_REFLECT(TTN_POP, &CD2ItemToolTipCtrl::OnPop)
//ON_MESSAGE(TTM_RELAYEVENT, &CD2ItemToolTipCtrl::OnRelayEvent)
ON_MESSAGE(TTM_RELAYEVENT, &CD2ItemToolTipCtrl::OnRelayEvent)
END_MESSAGE_MAP()

// CD2ItemToolTipCtrl message handlers
Expand All @@ -235,16 +234,16 @@ void CD2ItemToolTipCtrl::OnShow(NMHDR* pNMHDR, LRESULT* pResult)
//AfxGetModuleThreadState()->m_nLastHit = static_cast<INT_PTR>(-1);
}

bool bCanDismiss = false;
bool isInvItem = false;
auto currID = (UINT)pNMHDR->idFrom;
switch (currID)
{
case IDC_INV_MERC_HEAD:
case IDC_INV_MERC_HAND_RIGHT:
case IDC_INV_MERC_TORSO:
case IDC_INV_MERC_HAND_LEFT:
bCanDismiss = true;
IsMerc = true;
isInvItem = true;
break;

case IDC_INV_HEAD:
Expand All @@ -268,38 +267,29 @@ void CD2ItemToolTipCtrl::OnShow(NMHDR* pNMHDR, LRESULT* pResult)
case IDC_INV_BOOTS:
case IDC_INV_CORPSE_BOOTS:
case IDC_INV_GOLEM:
bCanDismiss = true;
IsMerc = false;
break;
break;

case IDC_INV_GRID:
case IDC_INV_STASH_GRID:
case IDC_INV_CUBE_GRID:
case IDC_INV_BELT_GRID:
bCanDismiss = true;
IsMerc = false;
isInvItem = true;
break;

default:
bCanDismiss = false;
IsMerc = false;
isInvItem = false;
break;
}

CurrItem = nullptr;
if (bCanDismiss && Callback != nullptr)
if (isInvItem && Callback != nullptr)
{
CPoint point;
::GetCursorPos(&point);
CurrItem = Callback->InvHitTest(currID, point);
}

__super::OnShow(pNMHDR, pResult);
if (bCanDismiss && CurrItem == nullptr)
{
Pop();
}
}
//---------------------------------------------------------------------------
LRESULT CD2ItemToolTipCtrl::OnRelayEvent(WPARAM wParam, LPARAM lParam)
Expand Down Expand Up @@ -331,11 +321,4 @@ LRESULT CD2ItemToolTipCtrl::OnRelayEvent(WPARAM wParam, LPARAM lParam)
}
return DefWindowProc(TTM_RELAYEVENT, wParam, lParam);
}
//---------------------------------------------------------------------------
void CD2ItemToolTipCtrl::OnPop(NMHDR* pNMHDR, LRESULT* pResult)
{
CurrItem = nullptr;
AfxGetModuleThreadState()->m_nLastHit = static_cast<INT_PTR>(-1);
__super::OnPop(pNMHDR, pResult);
}
//---------------------------------------------------------------------------
3 changes: 2 additions & 1 deletion source/D2ItemToolTipCtrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class CD2ItemToolTipCtrlCallback
public:
virtual ~CD2ItemToolTipCtrlCallback() = default;
virtual const d2ce::Item* InvHitTest(UINT id, CPoint point, TOOLINFO* pTI = nullptr) const = 0;
virtual const d2ce::Item* GetInvItem(UINT id, UINT offset) const = 0;

};

//---------------------------------------------------------------------------
Expand All @@ -52,7 +54,6 @@ class CD2ItemToolTipCtrl : public CMFCToolTipCtrl

protected:
afx_msg void OnShow(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnPop(NMHDR* pNMHDR, LRESULT* pResult);
LRESULT OnRelayEvent(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()

Expand Down
Loading

0 comments on commit 7eed05b

Please sign in to comment.