Files
nostalgia/src/olympic/studio/applib/src/popups/about.cpp
T
2025-06-08 21:33:17 -05:00

62 lines
1.3 KiB
C++

/*
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#include <imgui.h>
#include <studio/imguiutil.hpp>
#include "about.hpp"
namespace olympic {
extern ox::String appVersion;
}
namespace studio {
AboutPopup::AboutPopup(turbine::Context &ctx) noexcept:
Popup("About"),
#ifdef DEBUG
m_text{sfmt("{} [DEBUG] - {}", keelCtx(ctx).appName, olympic::appVersion)} {
#else
m_text{sfmt("{} - {}", keelCtx(ctx).appName, olympic::appVersion)} {
#endif
}
void AboutPopup::draw(Context &sctx) noexcept {
if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
close();
return;
}
switch (m_stage) {
case Stage::Closed:
break;
case Stage::Opening:
ImGui::OpenPopup("About");
m_stage = Stage::Open;
[[fallthrough]];
case Stage::Open: {
constexpr auto modalFlags =
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize;
ig::centerNextWindow(sctx.tctx);
auto open = true;
if (ImGui::BeginPopupModal("About", &open, modalFlags)) {
ImGui::Text("%s\n\nBuild date: %s", m_text.c_str(), __DATE__);
ImGui::NewLine();
ImGui::Dummy({148.0f, 0.0f});
ImGui::SameLine();
if (ig::PushButton("Close")) {
ImGui::CloseCurrentPopup();
open = false;
}
ImGui::EndPopup();
}
if (!open) {
m_stage = Stage::Closed;
}
break;
}
}
}
}