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