Skip to content

Commit

Permalink
Add version to About dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
amaiorano committed Dec 23, 2023
1 parent f872ea2 commit 9d165af
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions libs/sdl_engine/src/SDLEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ class SDLEngineImpl {
public:
void RegisterClient(IEngineClient& client) { m_client = &client; }

std::string GetVersionString() const {
if (auto fin = std::ifstream("version.txt"); fin) {
std::string version;
fin >> version;
return version;
}
return "(Dev)";
}

bool Run(int argc, char** argv) {
const auto args = std::vector<std::string_view>(argv + 1, argv + argc);

Expand Down Expand Up @@ -205,13 +214,7 @@ class SDLEngineImpl {
if (m_options.Get<bool>("windowMaximized"))
windowCreateFlags |= SDL_WINDOW_MAXIMIZED;

std::string windowTitle = "Vectrexy";
if (auto fin = std::ifstream("version.txt"); fin) {
std::string version;
fin >> version;
windowTitle += " " + version;
}

std::string windowTitle = std::string{"Vectrexy"} + " (" + GetVersionString() + ")";
m_window = SDL_CreateWindow(windowTitle.c_str(), windowX, windowY, windowWidth,
windowHeight, windowCreateFlags);
if (m_window == nullptr) {
Expand Down Expand Up @@ -586,7 +589,7 @@ class SDLEngineImpl {
ImGui::BeginPopupModal("About Vectrexy", &open, ImGuiWindowFlags_AlwaysAutoResize)) {
m_paused[PauseSource::Menu] = true;

ImGui::Text("Vectrexy");
ImGui::Text("Vectrexy (%s)", GetVersionString().c_str());
ImGui::Text("Programmed by Antonio Maiorano ([email protected])");

ImGui::Text("Available at");
Expand Down

0 comments on commit 9d165af

Please sign in to comment.