mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-03 08:03:50 +00:00
Send CMSG_LOOT_MONEY for online gold looting and replace action bar right-click removal with drag-to-ground
This commit is contained in:
parent
c3b0769982
commit
4c530e9cee
5 changed files with 67 additions and 12 deletions
|
|
@ -1137,6 +1137,12 @@ public:
|
||||||
static network::Packet build(uint8_t srcBag, uint8_t srcSlot);
|
static network::Packet build(uint8_t srcBag, uint8_t srcSlot);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** CMSG_LOOT_MONEY packet builder (empty body) */
|
||||||
|
class LootMoneyPacket {
|
||||||
|
public:
|
||||||
|
static network::Packet build();
|
||||||
|
};
|
||||||
|
|
||||||
/** CMSG_LOOT_RELEASE packet builder */
|
/** CMSG_LOOT_RELEASE packet builder */
|
||||||
class LootReleasePacket {
|
class LootReleasePacket {
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,10 @@ private:
|
||||||
std::unordered_map<uint32_t, uint32_t> spellIconIds_;
|
std::unordered_map<uint32_t, uint32_t> spellIconIds_;
|
||||||
bool spellIconDbLoaded_ = false;
|
bool spellIconDbLoaded_ = false;
|
||||||
GLuint getSpellIcon(uint32_t spellId, pipeline::AssetManager* am);
|
GLuint getSpellIcon(uint32_t spellId, pipeline::AssetManager* am);
|
||||||
|
|
||||||
|
// Action bar drag state (-1 = not dragging)
|
||||||
|
int actionBarDragSlot_ = -1;
|
||||||
|
GLuint actionBarDragIcon_ = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ui
|
} // namespace ui
|
||||||
|
|
|
||||||
|
|
@ -4164,13 +4164,13 @@ void GameHandler::handleLootResponse(network::Packet& packet) {
|
||||||
if (currentLoot.gold > 0) {
|
if (currentLoot.gold > 0) {
|
||||||
if (singlePlayerMode_) {
|
if (singlePlayerMode_) {
|
||||||
addMoneyCopper(currentLoot.gold);
|
addMoneyCopper(currentLoot.gold);
|
||||||
|
currentLoot.gold = 0;
|
||||||
|
} else if (state == WorldState::IN_WORLD && socket) {
|
||||||
|
// Auto-loot gold by sending CMSG_LOOT_MONEY (server handles the rest)
|
||||||
|
auto pkt = LootMoneyPacket::build();
|
||||||
|
socket->send(pkt);
|
||||||
|
currentLoot.gold = 0;
|
||||||
}
|
}
|
||||||
std::string msg = "You loot ";
|
|
||||||
msg += std::to_string(currentLoot.getGold()) + "g ";
|
|
||||||
msg += std::to_string(currentLoot.getSilver()) + "s ";
|
|
||||||
msg += std::to_string(currentLoot.getCopper()) + "c.";
|
|
||||||
addSystemChatMessage(msg);
|
|
||||||
currentLoot.gold = 0; // Clear gold from loot window after collecting
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1928,6 +1928,11 @@ network::Packet AutoEquipItemPacket::build(uint8_t srcBag, uint8_t srcSlot) {
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
network::Packet LootMoneyPacket::build() {
|
||||||
|
network::Packet packet(static_cast<uint16_t>(Opcode::CMSG_LOOT_MONEY));
|
||||||
|
return packet;
|
||||||
|
}
|
||||||
|
|
||||||
network::Packet LootReleasePacket::build(uint64_t lootGuid) {
|
network::Packet LootReleasePacket::build(uint64_t lootGuid) {
|
||||||
network::Packet packet(static_cast<uint16_t>(Opcode::CMSG_LOOT_RELEASE));
|
network::Packet packet(static_cast<uint16_t>(Opcode::CMSG_LOOT_RELEASE));
|
||||||
packet.writeUInt64(lootGuid);
|
packet.writeUInt64(lootGuid);
|
||||||
|
|
|
||||||
|
|
@ -1505,6 +1505,22 @@ void GameScreen::renderActionBar(game::GameHandler& gameHandler) {
|
||||||
const auto& held = inventoryScreen.getHeldItem();
|
const auto& held = inventoryScreen.getHeldItem();
|
||||||
gameHandler.setActionBarSlot(i, game::ActionBarSlot::ITEM, held.itemId);
|
gameHandler.setActionBarSlot(i, game::ActionBarSlot::ITEM, held.itemId);
|
||||||
inventoryScreen.returnHeldItem(gameHandler.getInventory());
|
inventoryScreen.returnHeldItem(gameHandler.getInventory());
|
||||||
|
} else if (clicked && actionBarDragSlot_ >= 0) {
|
||||||
|
// Dropping a dragged action bar slot onto another slot - swap or place
|
||||||
|
if (i != actionBarDragSlot_) {
|
||||||
|
// Swap the two slots
|
||||||
|
const auto& dragSrc = bar[actionBarDragSlot_];
|
||||||
|
auto srcType = dragSrc.type;
|
||||||
|
auto srcId = dragSrc.id;
|
||||||
|
gameHandler.setActionBarSlot(actionBarDragSlot_, slot.type, slot.id);
|
||||||
|
gameHandler.setActionBarSlot(i, srcType, srcId);
|
||||||
|
}
|
||||||
|
actionBarDragSlot_ = -1;
|
||||||
|
actionBarDragIcon_ = 0;
|
||||||
|
} else if (clicked && !slot.isEmpty()) {
|
||||||
|
// Pick up this action bar slot for dragging
|
||||||
|
actionBarDragSlot_ = i;
|
||||||
|
actionBarDragIcon_ = iconTex;
|
||||||
} else if (clicked) {
|
} else if (clicked) {
|
||||||
if (slot.type == game::ActionBarSlot::SPELL && slot.isReady()) {
|
if (slot.type == game::ActionBarSlot::SPELL && slot.isReady()) {
|
||||||
uint64_t target = gameHandler.hasTarget() ? gameHandler.getTargetGuid() : 0;
|
uint64_t target = gameHandler.hasTarget() ? gameHandler.getTargetGuid() : 0;
|
||||||
|
|
@ -1514,11 +1530,6 @@ void GameScreen::renderActionBar(game::GameHandler& gameHandler) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Right-click to clear slot
|
|
||||||
if (ImGui::IsItemClicked(ImGuiMouseButton_Right) && !slot.isEmpty()) {
|
|
||||||
gameHandler.setActionBarSlot(i, game::ActionBarSlot::EMPTY, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tooltip
|
// Tooltip
|
||||||
if (ImGui::IsItemHovered() && slot.type == game::ActionBarSlot::SPELL && slot.id != 0) {
|
if (ImGui::IsItemHovered() && slot.type == game::ActionBarSlot::SPELL && slot.id != 0) {
|
||||||
std::string fullName = getSpellName(slot.id);
|
std::string fullName = getSpellName(slot.id);
|
||||||
|
|
@ -1533,7 +1544,6 @@ void GameScreen::renderActionBar(game::GameHandler& gameHandler) {
|
||||||
} else {
|
} else {
|
||||||
ImGui::Text("Item #%u", slot.id);
|
ImGui::Text("Item #%u", slot.id);
|
||||||
}
|
}
|
||||||
ImGui::TextDisabled("(Right-click to remove)");
|
|
||||||
ImGui::EndTooltip();
|
ImGui::EndTooltip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1567,6 +1577,36 @@ void GameScreen::renderActionBar(game::GameHandler& gameHandler) {
|
||||||
|
|
||||||
ImGui::PopStyleColor();
|
ImGui::PopStyleColor();
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
|
|
||||||
|
// Handle action bar drag: render icon at cursor and detect drop outside
|
||||||
|
if (actionBarDragSlot_ >= 0) {
|
||||||
|
ImVec2 mousePos = ImGui::GetMousePos();
|
||||||
|
|
||||||
|
// Draw dragged icon at cursor
|
||||||
|
if (actionBarDragIcon_) {
|
||||||
|
ImGui::GetForegroundDrawList()->AddImage(
|
||||||
|
(ImTextureID)(uintptr_t)actionBarDragIcon_,
|
||||||
|
ImVec2(mousePos.x - 20, mousePos.y - 20),
|
||||||
|
ImVec2(mousePos.x + 20, mousePos.y + 20));
|
||||||
|
} else {
|
||||||
|
ImGui::GetForegroundDrawList()->AddRectFilled(
|
||||||
|
ImVec2(mousePos.x - 20, mousePos.y - 20),
|
||||||
|
ImVec2(mousePos.x + 20, mousePos.y + 20),
|
||||||
|
IM_COL32(80, 80, 120, 180));
|
||||||
|
}
|
||||||
|
|
||||||
|
// On mouse release, check if outside the action bar area
|
||||||
|
if (ImGui::IsMouseReleased(ImGuiMouseButton_Left)) {
|
||||||
|
bool insideBar = (mousePos.x >= barX && mousePos.x <= barX + barW &&
|
||||||
|
mousePos.y >= barY && mousePos.y <= barY + barH);
|
||||||
|
if (!insideBar) {
|
||||||
|
// Dropped outside - clear the slot
|
||||||
|
gameHandler.setActionBarSlot(actionBarDragSlot_, game::ActionBarSlot::EMPTY, 0);
|
||||||
|
}
|
||||||
|
actionBarDragSlot_ = -1;
|
||||||
|
actionBarDragIcon_ = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================
|
// ============================================================
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue