diff --git a/src/backend/reactions/reaction.cpp b/src/backend/reactions/reaction.cpp index 7d5f894b..fe102dbb 100644 --- a/src/backend/reactions/reaction.cpp +++ b/src/backend/reactions/reaction.cpp @@ -19,13 +19,14 @@ namespace big void reaction::process_common(player_ptr player) { - if (add_to_player_db) + if (add_to_player_db || block_joins) { auto entry = g_player_database_service->get_or_create_player(player); if (block_joins) { entry->block_join = true; + entry->block_join_reason = block_join_reason; g_player_database_service->save(); } } diff --git a/src/backend/reactions/reaction.hpp b/src/backend/reactions/reaction.hpp index 11631129..8e618289 100644 --- a/src/backend/reactions/reaction.hpp +++ b/src/backend/reactions/reaction.hpp @@ -14,6 +14,7 @@ namespace big bool log = true; bool add_to_player_db = false; bool block_joins = false; + int block_join_reason = 1; bool kick = false; bool timeout = false; @@ -21,7 +22,7 @@ namespace big const char* m_notify_message; const char* m_announce_message; - NLOHMANN_DEFINE_TYPE_INTRUSIVE(reaction, announce_in_chat, is_team_only, notify, log, add_to_player_db, block_joins, kick, timeout) + NLOHMANN_DEFINE_TYPE_INTRUSIVE(reaction, announce_in_chat, is_team_only, notify, log, add_to_player_db, block_joins, block_join_reason, kick, timeout) reaction(const char* event_name, const char* notify_message, const char* announce_message); virtual void process(player_ptr player); diff --git a/src/views/settings/view_reaction_settings.cpp b/src/views/settings/view_reaction_settings.cpp index 006af9e4..336916be 100644 --- a/src/views/settings/view_reaction_settings.cpp +++ b/src/views/settings/view_reaction_settings.cpp @@ -1,3 +1,5 @@ +#include "core/data/block_join_reasons.hpp" +#include "backend/reactions/reaction.hpp" #include "views/view.hpp" namespace big @@ -23,8 +25,21 @@ namespace big ImGui::Checkbox("NOTIFY"_T.data(), &reaction.notify); ImGui::Checkbox("LOG"_T.data(), &reaction.log); ImGui::Checkbox("REACTION_ADD_TO_DATABASE"_T.data(), &reaction.add_to_player_db); - if (reaction.add_to_player_db) - ImGui::Checkbox("REACTION_BLOCK_JOINS"_T.data(), &reaction.block_joins); + ImGui::Checkbox("REACTION_BLOCK_JOINS"_T.data(), &reaction.block_joins); + if (reaction.block_joins) + if (ImGui::BeginCombo("BLOCK_JOIN_ALERT"_T.data(), block_join_reasons[reaction.block_join_reason])) + { + for (const auto& [key, value] : block_join_reasons) + { + bool is_selected = (reaction.block_join_reason == key); + + if (ImGui::Selectable(value, is_selected)) + reaction.block_join_reason = key; + if (is_selected) + ImGui::SetItemDefaultFocus(); + } + ImGui::EndCombo(); + } ImGui::Checkbox("REACTION_KICK_PLAYER"_T.data(), &reaction.kick); ImGui::Checkbox("TIMEOUT"_T.data(), &reaction.timeout); ImGui::TreePop(); @@ -44,8 +59,21 @@ namespace big ImGui::Checkbox("NOTIFY"_T.data(), &reaction.notify); ImGui::Checkbox("LOG"_T.data(), &reaction.log); ImGui::Checkbox("REACTION_ADD_TO_DATABASE"_T.data(), &reaction.add_to_player_db); - if (reaction.add_to_player_db) - ImGui::Checkbox("REACTION_BLOCK_JOINS"_T.data(), &reaction.block_joins); + ImGui::Checkbox("REACTION_BLOCK_JOINS"_T.data(), &reaction.block_joins); + if (reaction.block_joins) + if (ImGui::BeginCombo("BLOCK_JOIN_ALERT"_T.data(), block_join_reasons[reaction.block_join_reason])) + { + for (const auto& [key, value] : block_join_reasons) + { + bool is_selected = (reaction.block_join_reason == key); + + if (ImGui::Selectable(value, is_selected)) + reaction.block_join_reason = key; + if (is_selected) + ImGui::SetItemDefaultFocus(); + } + ImGui::EndCombo(); + } ImGui::Checkbox("REACTION_KICK_ATTACKER"_T.data(), &reaction.kick); ImGui::Checkbox("TIMEOUT"_T.data(), &reaction.timeout);