From d12c1309c4d9b90056fb3da40c4e193b62037eb1 Mon Sep 17 00:00:00 2001 From: Sixhei Tartari <42782503+Democles85@users.noreply.github.com> Date: Sat, 15 Jul 2023 23:19:38 +0200 Subject: [PATCH] feat(Protections): Added buttons for controlling the states of protections (#1717) --- .../settings/view_protection_settings.cpp | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/views/settings/view_protection_settings.cpp b/src/views/settings/view_protection_settings.cpp index 29cd1262..a99942d6 100644 --- a/src/views/settings/view_protection_settings.cpp +++ b/src/views/settings/view_protection_settings.cpp @@ -2,8 +2,16 @@ namespace big { + static inline void set_all_protections(bool state) + { + for (size_t i = (size_t)&g.protections; i <= (size_t) & (g.protections.kick_rejoin); i++) + *(bool*)i = state; + } + void view::protection_settings() { + auto initial_protections = g.protections; + ImGui::BeginGroup(); ImGui::Checkbox("BOUNTY"_T.data(), &g.protections.script_events.bounty); ImGui::Checkbox("CEO_MONEY"_T.data(), &g.protections.script_events.ceo_money); @@ -47,6 +55,17 @@ namespace big ImGui::Checkbox("ADMIN_CHECK"_T.data(), &g.protections.admin_check); ImGui::Checkbox("Kick Rejoin", &g.protections.kick_rejoin); ImGui::EndGroup(); - } + ImGui::SeparatorText("Options"); + ImGui::BeginGroup(); + if (ImGui::Button("Enable All Protections")) + set_all_protections(true); + ImGui::SameLine(); + if (ImGui::Button("Disable All Protections")) + set_all_protections(false); + ImGui::SameLine(); + if (ImGui::Button("Reset Protections")) + g.protections = initial_protections; + ImGui::EndGroup(); + }; }