How can I output some text if checkbox is checked without having unlimited outputs?
I'm using C++ ImGui for my project.
So when checkbox in ImGui menu is checked, it should output some text in console.
CheckBox:
ImGui::Checkbox("mycheckbox", &bES_active);
This is how I did it:
if(bES_active)
{
std::cout << "Checkbox Clicked!";
}
How can I stop it at first output message?
EDIT: It was in a while
loop, so that's why it gave unlimited outputs.
It doesn't work outside of it, though.
Whole code:
// Main loop
while (!glfwWindowShouldClose(Window)) {
glfwPollEvents();
// Start the Dear ImGui frame
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
if (bESP_active)
{
std::cout << "ESP Activated\n";
}
if (GetAsyncKeyState(VK_INSERT) & 1) {
bMenuVisible = !bMenuVisible;
if (bMenuVisible) {
ShowMenu(Window);
}
else {
HideMenu(Window);
}
}
//-------------
->here is imgui menu drawn...
...
ImGui::Checkbox("ACTIVATE ESP", &bESP_active);
...
//----------------
if (bESP_active) {
do {
LocalPlayer = Mem.readMem<uintptr_t>(Client + dwLocalPlayer);
} while (LocalPlayer == NULL);
int getLocalHealth = Mem.readMem<uintptr_t>(Client + m_iHealth);
ViewMatrix = Mem.readMem<Matrix>(Client + dwViewMatrix);
int LocalTeam = Mem.readMem<int>(LocalPlayer + m_iTeamNum);
for (short int i = 0; i < 64; ++i) {
uintptr_t Entity =
Mem.readMem<uintptr_t>(Client + dwEntityList + i * 0x10);
if (Entity == NULL || Entity == LocalPlayer) continue;
if (Mem.readMem<bool>(Entity + m_bDormant)) continue;
int EntityTeam = Mem.readMem<int>(Entity + m_iTeamNum);
// int Health = Mem.readMem<int>(Entity + m_iHealth);
bool OnSameTeam = EntityTeam == LocalTeam;
// bool OnSameTeam = EntityTeam == Health;
if (OnSameTeam && !bShowTeam) continue; // nor this !2
if (OnSameTeam) // not really used !1
{
Color->R = 0.0f;
Color->B = 1.0f;
}
else
{
Color->R = 1.0f;
Color->B = 0.0f;
}
Vec3 EntityLocation = Mem.readMem<Vec3>(Entity + m_vecOrigin);
Vec2 ScreenCoords;
if (!WorldToScreen(EntityLocation, ScreenCoords, ViewMatrix.VMatrix))
continue;
//(0, -1) Start from the center, and from the button | ScreenCoords
if (bDrawEnemyLines)
{
DrawLine(LineOrigin, ScreenCoords, Color);
}
}
}
glfwSwapBuffers(Window);
// Rendering
ImGui::Render();
int display_w, display_h;
glfwGetFramebufferSize(Window, &display_w, &display_h);
glViewport(0, 0, display_w, display_h);
glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());