enter image description hereI wrote authorization by key in imgui, then I made an injection and a game selection (but it opened in a new window) I would like to make sure that after successful authorization, the old elements are deleted and new ones are drawn without adding a new window
made different windows but the authorization window did not close and it looked ugly
ImGui::SetNextWindowSize(ImVec2(284, 309));
if (ImGui::Begin("sd1", NULL, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings))
{
ImGui::InputText("##keyinput", &inputlicencekey, CHAR_MAX, ImGuiInputTextFlags_Password);
if (ImGui::Button("Login"))
{
if (&inputlicencekey == key)
{
logged = true;
}
}
}ImGui::End();
ImGui::SetNextWindowSize(ImVec2(284, 309));
if (!logged && ImGui::Begin("sd1", NULL, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings))
{
ImGui::Checkbox("Test", &testbool);
if (ImGui::Button("injcet"))
{
testbool = true;
}
ImGui::Text("Int");
ImGui::SliderInt("##dd", &inttest, 0.1f, 15.f);
ImGui::Text("Float");
}ImGui::End();
Change the first line of code to
if (!logged && ImGui::Begin(...))
such that the window only renders if logged
is not set.
Better still, consider adding a state variable:
// at top level
enum class State { START, LOGGED_IN };
State my_state = State::START;
and then your rendering code can inspect my_state
:
switch (my_state) {
case State::START: {
ImGui::Begin(...);
...
my_state = State::LOGGED_IN;
break;
}
case State::LOGGED_IN: {
ImGui::Begin(...)
...
break;
}
}
Here is the exact change you need to make:
if (!logged && ImGui::Begin("sd1", NULL, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings))
{
ImGui::InputText("##keyinput", &inputlicencekey, CHAR_MAX, ImGuiInputTextFlags_Password);
if (ImGui::Button("Login"))
{
if (&inputlicencekey == key)
{
logged = true;
}
}
ImGui::End();
}
ImGui::SetNextWindowSize(ImVec2(284, 309));
if (logged && ImGui::Begin("sd1", NULL, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings))
{
ImGui::Checkbox("Test", &testbool);
if (ImGui::Button("injcet"))
{
testbool = true;
}
ImGui::Text("Int");
ImGui::SliderInt("##dd", &inttest, 0.1f, 15.f);
ImGui::Text("Float");
ImGui::End()
}