make quit button useful
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
namespace ph {
|
namespace ph {
|
||||||
namespace gui {
|
namespace gui {
|
||||||
|
|
||||||
void Render();
|
bool Render();
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
} // namespace gui
|
} // namespace gui
|
||||||
|
|||||||
@@ -107,24 +107,29 @@ static void RenderGameWindow() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static void RenderMainWindow() {
|
static bool RenderMainWindow() {
|
||||||
if (ImGui::Button("Nouvelle Partie")) {
|
if (ImGui::Button("Nouvelle Partie")) {
|
||||||
InGame = true;
|
InGame = true;
|
||||||
Right = true;
|
Right = true;
|
||||||
}
|
}
|
||||||
if (ImGui::Button("Quitter")) {
|
if (ImGui::Button("Quitter")) {
|
||||||
// TODO
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Render() {
|
bool Render() {
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImGui::SetNextWindowPos(ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f), ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
ImGui::SetNextWindowPos(ImVec2(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f), ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
||||||
ImGui::Begin("MainWindow", nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDecoration);
|
ImGui::Begin("MainWindow", nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDecoration);
|
||||||
if (InGame)
|
if (InGame)
|
||||||
RenderGameWindow();
|
RenderGameWindow();
|
||||||
else
|
else {
|
||||||
RenderMainWindow();
|
if (!RenderMainWindow()) {
|
||||||
|
ImGui::End();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Cooldown > 0.0f) {
|
if (Cooldown > 0.0f) {
|
||||||
ImGui::NewLine();
|
ImGui::NewLine();
|
||||||
@@ -139,6 +144,8 @@ void Render() {
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
ImGui::ShowDemoWindow();
|
ImGui::ShowDemoWindow();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init() {}
|
void Init() {}
|
||||||
|
|||||||
@@ -146,7 +146,10 @@ int main(int, char**) {
|
|||||||
ImGui_ImplSDL2_NewFrame();
|
ImGui_ImplSDL2_NewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
ph::gui::Render();
|
if (!done && !ph::gui::Render()) {
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
|
|||||||
Reference in New Issue
Block a user