Block join reason to reaction (#3190)

This commit is contained in:
CringeArab 2024-05-30 21:07:39 +03:00 committed by GitHub
parent 0e5c8f7cfb
commit 974e9ad184
3 changed files with 36 additions and 6 deletions

View File

@ -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();
}
}

View File

@ -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);

View File

@ -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);