feat(Protections): Added buttons for controlling the states of protections (#1717)

This commit is contained in:
Sixhei Tartari 2023-07-15 23:19:38 +02:00 committed by GitHub
parent 4cbea87b16
commit d12c1309c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,8 +2,16 @@
namespace big 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() void view::protection_settings()
{ {
auto initial_protections = g.protections;
ImGui::BeginGroup(); ImGui::BeginGroup();
ImGui::Checkbox("BOUNTY"_T.data(), &g.protections.script_events.bounty); ImGui::Checkbox("BOUNTY"_T.data(), &g.protections.script_events.bounty);
ImGui::Checkbox("CEO_MONEY"_T.data(), &g.protections.script_events.ceo_money); 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("ADMIN_CHECK"_T.data(), &g.protections.admin_check);
ImGui::Checkbox("Kick Rejoin", &g.protections.kick_rejoin); ImGui::Checkbox("Kick Rejoin", &g.protections.kick_rejoin);
ImGui::EndGroup(); 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();
};
} }