mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-24 16:10:14 +00:00
fix: allow closing any bag independently and reset off-screen positions
Remove the forced backpack-open constraint that prevented closing the backpack while other bags were open. Each bag window is now independently closable regardless of which others are open. Add off-screen position reset to individual bag windows (renderBagWindow) so bags saved at positions outside the current resolution snap back to their default stack position.
This commit is contained in:
parent
b10c8b7aea
commit
5e8d4e76c8
1 changed files with 11 additions and 5 deletions
|
|
@ -987,11 +987,7 @@ void InventoryScreen::renderSeparateBags(game::Inventory& inventory, uint64_t mo
|
|||
constexpr int columns = 6;
|
||||
constexpr float baseWindowW = columns * (slotSize + 4.0f) + 30.0f;
|
||||
|
||||
bool anyBagOpen = std::any_of(bagOpen_.begin(), bagOpen_.end(), [](bool b) { return b; });
|
||||
if (anyBagOpen && !backpackOpen_) {
|
||||
// Enforce backpack as the bottom-most stack window when any bag is open.
|
||||
backpackOpen_ = true;
|
||||
}
|
||||
// Each bag window is independently closable — no forced backpack constraint.
|
||||
|
||||
// Anchor stack to the bag bar (bottom-right), opening upward.
|
||||
const float bagBarTop = screenH - (42.0f + 12.0f) - 10.0f;
|
||||
|
|
@ -1076,6 +1072,16 @@ void InventoryScreen::renderBagWindow(const char* title, bool& isOpen,
|
|||
return;
|
||||
}
|
||||
|
||||
// Reset position if the window ended up outside the screen (resolution change)
|
||||
ImVec2 winPos = ImGui::GetWindowPos();
|
||||
ImVec2 winSize = ImGui::GetWindowSize();
|
||||
float scrW = ImGui::GetIO().DisplaySize.x;
|
||||
float scrH = ImGui::GetIO().DisplaySize.y;
|
||||
if (winPos.x > scrW || winPos.y > scrH ||
|
||||
winPos.x + winSize.x < 0 || winPos.y + winSize.y < 0) {
|
||||
ImGui::SetWindowPos(ImVec2(defaultX, defaultY));
|
||||
}
|
||||
|
||||
// Render item slots in 4-column grid
|
||||
for (int i = 0; i < numSlots; i++) {
|
||||
if (i % columns != 0) ImGui::SameLine();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue