#include "UI/ShortcutDetails.h" #include "UI/SkillDetailClose.h" #include "UI/UIWindow.h" #include "UI/WindowManagerWindows.h" #include namespace { int Add(int left, int right) { return std::bit_cast(static_cast(left) + static_cast(right)); } void ToScreen(const UIWindow& window, int& x, int& y) { x = Add(x, window.geometry.x); y = Add(y, window.geometry.y); for (const WindowAncestry* node = window.parent; node; node = node->parent) { const UIWindow* owner = static_cast(node); x = Add(x, owner->geometry.x); y = Add(y, owner->geometry.y); } } } // OFFSET: 0x009332D0 // FUNCTION: fn_12724 void ShortcutDetails::Open( UIWindow& window, ShortcutGrid& grid, int x, int y, const NormalItemSlot* const* slots, const NormalItemSlot* const* itemSlots ) { const int column = grid.HitTest(x, y, this->itemSlotActive, this->currentRow); if (column == -1) { return; } const int index = 9 * this->currentRow + column; const int limit = std::bit_cast(9u * static_cast(grid.rows)); const NormalItemSlot* slot; if (limit <= index) { if (!this->itemSlotActive) { return; } slot = itemSlots[column]; } else { slot = slots[index]; if (slot->itemId == 0) { return; } } if (limit <= index || slot->unknown_0000 == 0) { ItemInfo item = LookupClientItem(this->inventory, std::bit_cast(slot->itemId), 1); if (item.unknown_0000[1] != 0) { UIWindow* detail = this->windows.EnsureWindow(12); detail->SendMsg(nullptr, 24, reinterpret_cast(&item), 0, 0, 0); } return; } CSkillInfo skill = this->skills.Lookup(slot->itemId); if (!skill.MatchesShortcut(slot)) { return; } UIWindow* detail = this->windows.EnsureWindow(46); if (detail) { if (this->describedSkill == skill.id) { this->skillClose.Close(); } else { detail->SendMsg(nullptr, 61, skill.id, 0, 0, 0); } } int originX = 0; int originY = 0; ToScreen(window, originX, originY); const int targetX = Add(originX, x); unsigned adjustment = 0; if (this->screenWidth - static_cast(targetX) < static_cast(detail->geometry.width)) { adjustment = static_cast(targetX) + detail->geometry.width - this->screenWidth; } const int rowY = std::bit_cast(33u * static_cast(y / 33)); const int targetY = static_cast(originY) <= static_cast(this->screenHeight) * 0.5f ? Add(Add(originY, rowY), 33) : Add(Add(originY, rowY), -detail->geometry.height); detail->Move(std::bit_cast(static_cast(targetX) - adjustment), targetY); }