Skip to content

Commit

Permalink
Fixed inventory item rects covering exit button.
Browse files Browse the repository at this point in the history
  • Loading branch information
afritz1 committed Jan 10, 2025
1 parent a31700d commit 4d2cbc8
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions OpenTESArena/src/Interface/CharacterEquipmentPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,26 @@ bool CharacterEquipmentPanel::init()
this->inventoryListBox.setOverrideColor(i, equipColor);
});

this->addButtonProxy(MouseButtonType::Left, this->inventoryListBox.getItemGlobalRect(i),
[this, i]()
ButtonProxy::RectFunction itemRectFunc = [this, i]()
{
const int firstVisibleIndex = this->inventoryListBox.getFirstVisibleItemIndex();
this->inventoryListBox.getCallback(firstVisibleIndex + i)();
});
return this->inventoryListBox.getItemGlobalRect(i);
};

ButtonProxy::Callback itemCallback = this->inventoryListBox.getCallback(i);

ButtonProxy::ActiveFunction itemActiveFunction = [this, &game]()
{
// @todo: I don't like every button proxy having to handle mouse position, fix this design.
// - maybe should give the button proxy a parent rect that all clicks have to be inside, then
// the active func becomes obsolete
const InputManager &inputManager = game.inputManager;
const Int2 mousePosition = inputManager.getMousePosition();
const Int2 mouseClassicPosition = game.renderer.nativeToOriginal(mousePosition);
const Rect inventoryListBoxRect = this->inventoryListBox.getRect();
return inventoryListBoxRect.contains(mouseClassicPosition);
};

this->addButtonProxy(MouseButtonType::Left, itemRectFunc, itemCallback, itemActiveFunction);
}

this->backToStatsButton = Button<Game&>(
Expand Down

0 comments on commit 4d2cbc8

Please sign in to comment.