Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

made a few comments in the gui files, some may not be correct I need … #229

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions tf2_bot_detector/UI/ImGui_TF2BotDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ namespace
};
}

void ImGui::TextRightAligned(const std::string_view& text, float offsetX)
void ImGui::TextRightAligned(const std::string_view& text, float offsetX) //This function will right-align certain text by a certain offset.
{
const auto textSize = ImGui::CalcTextSize(text.data(), text.data() + text.size());
//Because everyone has a different size monitor/display,
//this function calcualtes your text size and the column width dynamically based on your detected system
//graphics. Once it has these it uses a 'cursor' to properly place the right aligned text.

float cursorPosX = ImGui::GetCursorPosX();
cursorPosX += ImGui::GetColumnWidth();// ImGui::GetContentRegionAvail().x;
const auto textSize = ImGui::CalcTextSize(text.data(), text.data() + text.size()); //calculates the text size

float cursorPosX = ImGui::GetCursorPosX(); //grabs your cursor position
cursorPosX += ImGui::GetColumnWidth();// ImGui::GetContentRegionAvail().x; //
cursorPosX -= textSize.x;
cursorPosX -= 2 * ImGui::GetStyle().ItemSpacing.x;
cursorPosX -= offsetX;
Expand All @@ -49,7 +53,7 @@ void ImGui::TextRightAligned(const std::string_view& text, float offsetX)
ImGui::TextFmt(text);
}

void ImGui::TextRightAlignedF(const char* fmt, ...)
void ImGui::TextRightAlignedF(const char* fmt, ...) //formats right aligned text with the fmt argument
{
std::va_list ap, ap2;
va_start(ap, fmt);
Expand Down Expand Up @@ -256,7 +260,6 @@ static bool OverrideControl(const std::string_view& overrideLabel, T& overrideVa
retVal = true;
}
}

return retVal;
}

Expand Down
45 changes: 26 additions & 19 deletions tf2_bot_detector/UI/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ using namespace std::chrono_literals;
using namespace std::string_literals;
using namespace std::string_view_literals;


//library used to make GUI (ImGui): https://github.com/ocornut/imgui

MainWindow::MainWindow() :
ImGuiDesktop::Window(800, 600, mh::fmtstr<128>("TF2 Bot Detector v{}", VERSION).c_str()),
m_WorldState(IWorldState::Create(m_Settings)),
Expand Down Expand Up @@ -91,7 +94,7 @@ MainWindow::MainWindow() :
//m_ActionManager.AddPiggybackAction<GenericCommandAction>("net_status");
}

MainWindow::~MainWindow()
MainWindow::~MainWindow() //main window deconstructor
{
}

Expand All @@ -113,11 +116,11 @@ void MainWindow::OnDrawColorPickers(const char* id, const std::initializer_list<
});
}

void MainWindow::OnDrawChat()
void MainWindow::OnDrawChat() //draw the chat box and color code them
{
OnDrawColorPickers("ChatColorPickers",
{
{ "You", m_Settings.m_Theme.m_Colors.m_ChatLogYouFG },
{ "You", m_Settings.m_Theme.m_Colors.m_ChatLogYouFG }, // sets colors to differentiate bettween you and other player types.
{ "Enemies", m_Settings.m_Theme.m_Colors.m_ChatLogEnemyTeamFG },
{ "Friendlies", m_Settings.m_Theme.m_Colors.m_ChatLogFriendlyTeamFG },
});
Expand All @@ -129,7 +132,7 @@ void MainWindow::OnDrawChat()

ImGui::PushTextWrapPos();

const IConsoleLine::PrintArgs args{ m_Settings };
const IConsoleLine::PrintArgs args{ m_Settings }; //print the console lines
for (auto it = m_MainState->m_PrintingLines.rbegin(); it != m_MainState->m_PrintingLines.rend(); ++it)
{
assert(*it);
Expand Down Expand Up @@ -180,7 +183,7 @@ void MainWindow::OnDrawAppLog()
});
}

void MainWindow::OnDrawSettingsPopup()
void MainWindow::OnDrawSettingsPopup() //handles the settings menu popup screen
{
static constexpr char POPUP_NAME[] = "Settings##Popup";

Expand Down Expand Up @@ -209,12 +212,12 @@ void MainWindow::OnDrawSettingsPopup()
if (InputTextSteamIDOverride("My Steam ID", m_Settings.m_LocalSteamIDOverride, true))
m_Settings.SaveFile();

ImGui::TreePop();
ImGui::TreePop(); //this is the expand effect when you click the little down arrows under each of the top level settings
}

if (ImGui::TreeNode("Logging"))
if (ImGui::TreeNode("Logging")) //Logging section
{
#ifdef TF2BD_ENABLE_DISCORD_INTEGRATION
#ifdef TF2BD_ENABLE_DISCORD_INTEGRATION //under the Logging tab, check the Discord Rich Presence and RCON packets tab when discord integration enabled.
if (ImGui::Checkbox("Discord Rich Presence", &m_Settings.m_Logging.m_DiscordRichPresence))
m_Settings.SaveFile();
#endif
Expand All @@ -224,18 +227,18 @@ void MainWindow::OnDrawSettingsPopup()
ImGui::TreePop();
}

if (ImGui::TreeNode("Moderation"))
if (ImGui::TreeNode("Moderation")) //Moderation section
{
// Auto temp mute
{
if (ImGui::Checkbox("Auto temp mute", &m_Settings.m_AutoTempMute))
m_Settings.SaveFile();
ImGui::SetHoverTooltip("Automatically, temporarily mute ingame chat messages if we think someone else in the server is running the tool.");
m_Settings.SaveFile(); //Below is the text that's displayed when you hover your mouse over the sub-setting 'Auto temp mute'
ImGui::SetHoverTooltip("Automatically, temporarily mute ingame chat messages if we think someone else in the server is running the tool.");
}

// Auto votekick delay
{
if (ImGui::SliderFloat("Auto votekick delay", &m_Settings.m_AutoVotekickDelay, 0, 30, "%1.1f seconds"))
if (ImGui::SliderFloat("Auto votekick delay", &m_Settings.m_AutoVotekickDelay, 0, 30, "%1.1f seconds")) //slider bar that lets you change auto votekick wait time
m_Settings.SaveFile();
ImGui::SetHoverTooltip("Delay between a player being registered as fully connected and us expecting them to be ready to vote on an issue.\n\n"
"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.");
Expand All @@ -244,7 +247,7 @@ void MainWindow::OnDrawSettingsPopup()
// Send warnings for connecting cheaters
{
if (ImGui::Checkbox("Chat message warnings for connecting cheaters", &m_Settings.m_AutoChatWarningsConnecting))
m_Settings.SaveFile();
m_Settings.SaveFile();

ImGui::SetHoverTooltip("Automatically sends a chat message if a cheater has joined the lobby,"
" but is not yet in the game. Only has an effect if \"Enable Chat Warnings\""
Expand All @@ -270,7 +273,7 @@ void MainWindow::OnDrawSettingsPopup()

if (ImGui::TreeNode("Service Integrations"))
{
if (ImGui::Checkbox("Discord integrations", &m_Settings.m_Discord.m_EnableRichPresence))
if (ImGui::Checkbox("Discord integrations", &m_Settings.m_Discord.m_EnableRichPresence)) // will enable the discord integration
m_Settings.SaveFile();

#ifdef _DEBUG
Expand All @@ -280,7 +283,7 @@ void MainWindow::OnDrawSettingsPopup()
#endif

if (bool allowInternet = m_Settings.m_AllowInternetUsage.value_or(false);
ImGui::Checkbox("Allow internet connectivity", &allowInternet))
ImGui::Checkbox("Allow internet connectivity", &allowInternet)) //toggle allowing the internet or not and saves it to the settings save file.
{
m_Settings.m_AllowInternetUsage = allowInternet;
m_Settings.SaveFile();
Expand All @@ -290,9 +293,10 @@ void MainWindow::OnDrawSettingsPopup()
{
ImGui::NewLine();
if (std::string key = m_Settings.GetSteamAPIKey();
InputTextSteamAPIKey("Steam API Key", key, true))
InputTextSteamAPIKey("Steam API Key", key, true)) // allows you to enter or get your steam API key. This is necessary to get info
// about players and bots, such as their steam ID. Highly recommend every user have this
{
m_Settings.SetSteamAPIKey(key);
m_Settings.SetSteamAPIKey(key); //save the API key once it's generated and save it in the save file
m_Settings.SaveFile();
}
ImGui::NewLine();
Expand All @@ -310,7 +314,10 @@ void MainWindow::OnDrawSettingsPopup()

ImGui::NewLine();

if (AutoLaunchTF2Checkbox(m_Settings.m_AutoLaunchTF2))
if (AutoLaunchTF2Checkbox(m_Settings.m_AutoLaunchTF2)) //checkbox at the beginning when you launch the gui for the first time that session, asks u if u
//you want TF2 to automatically launch when you start the program. In my opinion,
//there should be a way you can start the program AFTER you start tf2 because I always forget and go to
//my steam library and launch it from there.
m_Settings.SaveFile();

ImGui::EndPopup();
Expand All @@ -335,7 +342,7 @@ void MainWindow::OpenUpdateCheckPopup()
m_UpdateCheckPopupOpen = true;
}

void MainWindow::OnDrawAboutPopup()
void MainWindow::OnDrawAboutPopup() //this is the popout that comes when you click in the main menu under Help-> About Tf2 Bot Detector.
{
static constexpr char POPUP_NAME[] = "About##Popup";

Expand Down