From f08b86d81472387d6b278e7ae57ca99cc66e94ce Mon Sep 17 00:00:00 2001 From: PabloDinella Date: Thu, 20 Aug 2020 22:19:10 -0300 Subject: [PATCH] add chat warning delay option --- tf2_bot_detector/Config/Settings.cpp | 1 + tf2_bot_detector/Config/Settings.h | 2 ++ tf2_bot_detector/ModeratorLogic.cpp | 2 +- tf2_bot_detector/UI/MainWindow.cpp | 8 ++++++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/tf2_bot_detector/Config/Settings.cpp b/tf2_bot_detector/Config/Settings.cpp index cb2cb748..d2c2b18e 100644 --- a/tf2_bot_detector/Config/Settings.cpp +++ b/tf2_bot_detector/Config/Settings.cpp @@ -220,6 +220,7 @@ void Settings::LoadFile() try_get_to_defaulted(*found, m_AutoChatWarningsConnecting, "auto_chat_warnings_connecting", DEFAULTS.m_AutoChatWarningsConnecting); try_get_to_defaulted(*found, m_AutoVotekick, "auto_votekick", DEFAULTS.m_AutoVotekick); try_get_to_defaulted(*found, m_AutoVotekickDelay, "auto_votekick_delay", DEFAULTS.m_AutoVotekickDelay); + try_get_to_defaulted(*found, m_ChatWarningInterval, "chat_warning_interval", DEFAULTS.m_ChatWarningInterval); try_get_to_defaulted(*found, m_AutoMark, "auto_mark", DEFAULTS.m_AutoMark); try_get_to_defaulted(*found, m_LazyLoadAPIData, "lazy_load_api_data", DEFAULTS.m_LazyLoadAPIData); diff --git a/tf2_bot_detector/Config/Settings.h b/tf2_bot_detector/Config/Settings.h index ccd2f299..06074a52 100644 --- a/tf2_bot_detector/Config/Settings.h +++ b/tf2_bot_detector/Config/Settings.h @@ -56,6 +56,7 @@ namespace tf2_bot_detector bool m_AutoChatWarningsConnecting = false; bool m_AutoVotekick = true; float m_AutoVotekickDelay = 15; + float m_ChatWarningInterval = 20; bool m_AutoMark = true; bool m_SleepWhenUnfocused = true; @@ -67,6 +68,7 @@ namespace tf2_bot_detector ProgramUpdateCheckMode m_ProgramUpdateCheckMode = ProgramUpdateCheckMode::Unknown; constexpr auto GetAutoVotekickDelay() const { return std::chrono::duration(m_AutoVotekickDelay); } + constexpr auto GetChatWarningInterval() const { return std::chrono::milliseconds((int)(m_ChatWarningInterval * 1000)); } const std::string& GetSteamAPIKey() const { return m_SteamAPIKey; } void SetSteamAPIKey(std::string key); diff --git a/tf2_bot_detector/ModeratorLogic.cpp b/tf2_bot_detector/ModeratorLogic.cpp index de9c048f..2cbb2f78 100644 --- a/tf2_bot_detector/ModeratorLogic.cpp +++ b/tf2_bot_detector/ModeratorLogic.cpp @@ -425,7 +425,7 @@ void ModeratorLogic::HandleConnectedEnemyCheaters(const std::vector& en if (m_Settings->m_AutoChatWarnings && m_ActionManager->QueueAction(chatMsg)) { Log({ 1, 0, 0, 1 }, logMsg); - m_NextCheaterWarningTime = now + CHEATER_WARNING_INTERVAL; + m_NextCheaterWarningTime = now + m_Settings->GetChatWarningInterval(); } } else diff --git a/tf2_bot_detector/UI/MainWindow.cpp b/tf2_bot_detector/UI/MainWindow.cpp index facb6fae..b3409a8e 100644 --- a/tf2_bot_detector/UI/MainWindow.cpp +++ b/tf2_bot_detector/UI/MainWindow.cpp @@ -235,6 +235,14 @@ void MainWindow::OnDrawSettingsPopup() "This is needed because players can't vote until they have joined a team and picked a class. If we call a vote before enough people are ready, it might fail."); } + // Chat warning interval + { + if (ImGui::SliderFloat("Chat warning interval", &m_Settings.m_ChatWarningInterval, 20, 60, "%1.1f seconds")) + m_Settings.SaveFile(); + ImGui::SetHoverTooltip("Interval between chat warnings.\n\n" + "Increase it if you feel that you are spamming too much."); + } + // Send warnings for connecting cheaters { if (ImGui::Checkbox("Chat message warnings for connecting cheaters", &m_Settings.m_AutoChatWarningsConnecting))