Skip to content

Commit 4d2cbc8

Browse files
committed
Fixed inventory item rects covering exit button.
1 parent a31700d commit 4d2cbc8

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

OpenTESArena/src/Interface/CharacterEquipmentPanel.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,26 @@ bool CharacterEquipmentPanel::init()
7979
this->inventoryListBox.setOverrideColor(i, equipColor);
8080
});
8181

82-
this->addButtonProxy(MouseButtonType::Left, this->inventoryListBox.getItemGlobalRect(i),
83-
[this, i]()
82+
ButtonProxy::RectFunction itemRectFunc = [this, i]()
8483
{
85-
const int firstVisibleIndex = this->inventoryListBox.getFirstVisibleItemIndex();
86-
this->inventoryListBox.getCallback(firstVisibleIndex + i)();
87-
});
84+
return this->inventoryListBox.getItemGlobalRect(i);
85+
};
86+
87+
ButtonProxy::Callback itemCallback = this->inventoryListBox.getCallback(i);
88+
89+
ButtonProxy::ActiveFunction itemActiveFunction = [this, &game]()
90+
{
91+
// @todo: I don't like every button proxy having to handle mouse position, fix this design.
92+
// - maybe should give the button proxy a parent rect that all clicks have to be inside, then
93+
// the active func becomes obsolete
94+
const InputManager &inputManager = game.inputManager;
95+
const Int2 mousePosition = inputManager.getMousePosition();
96+
const Int2 mouseClassicPosition = game.renderer.nativeToOriginal(mousePosition);
97+
const Rect inventoryListBoxRect = this->inventoryListBox.getRect();
98+
return inventoryListBoxRect.contains(mouseClassicPosition);
99+
};
100+
101+
this->addButtonProxy(MouseButtonType::Left, itemRectFunc, itemCallback, itemActiveFunction);
88102
}
89103

90104
this->backToStatsButton = Button<Game&>(

0 commit comments

Comments
 (0)