Add auto loot setting to gameplay settings

Checkbox in Settings > Gameplay > Loot section. When enabled, all items
are automatically sent CMSG_AUTOSTORE_LOOT_ITEM on loot response (same
as right-click looting each item). Gold always auto-loots regardless.
Setting persists in settings.cfg as auto_loot=0/1.
This commit is contained in:
Kelsi 2026-02-17 16:31:00 -08:00
parent a55399fad6
commit 0e18c8871d
4 changed files with 29 additions and 0 deletions

View file

@ -216,6 +216,9 @@ void GameScreen::render(game::GameHandler& gameHandler) {
}
}
// Apply auto-loot setting to GameHandler every frame (cheap bool sync)
gameHandler.setAutoLoot(pendingAutoLoot);
// Sync chat auto-join settings to GameHandler
gameHandler.chatAutoJoin.general = chatAutoJoinGeneral_;
gameHandler.chatAutoJoin.trade = chatAutoJoinTrade_;
@ -5723,6 +5726,15 @@ void GameScreen::renderSettingsWindow() {
}
}
ImGui::Spacing();
ImGui::Text("Loot");
ImGui::Separator();
if (ImGui::Checkbox("Auto Loot", &pendingAutoLoot)) {
saveSettings(); // per-frame sync applies pendingAutoLoot to gameHandler
}
if (ImGui::IsItemHovered())
ImGui::SetTooltip("Automatically pick up all items when looting");
ImGui::Spacing();
ImGui::Text("Bags");
ImGui::Separator();
@ -6304,6 +6316,9 @@ void GameScreen::saveSettings() {
out << "mount_volume=" << pendingMountVolume << "\n";
out << "activity_volume=" << pendingActivityVolume << "\n";
// Gameplay
out << "auto_loot=" << (pendingAutoLoot ? 1 : 0) << "\n";
// Controls
out << "mouse_sensitivity=" << pendingMouseSensitivity << "\n";
out << "invert_mouse=" << (pendingInvertMouse ? 1 : 0) << "\n";
@ -6373,6 +6388,8 @@ void GameScreen::loadSettings() {
else if (key == "npc_voice_volume") pendingNpcVoiceVolume = std::clamp(std::stoi(val), 0, 100);
else if (key == "mount_volume") pendingMountVolume = std::clamp(std::stoi(val), 0, 100);
else if (key == "activity_volume") pendingActivityVolume = std::clamp(std::stoi(val), 0, 100);
// Gameplay
else if (key == "auto_loot") pendingAutoLoot = (std::stoi(val) != 0);
// Controls
else if (key == "mouse_sensitivity") pendingMouseSensitivity = std::clamp(std::stof(val), 0.05f, 1.0f);
else if (key == "invert_mouse") pendingInvertMouse = (std::stoi(val) != 0);