Skip to content

Commit

Permalink
add game version to hud
Browse files Browse the repository at this point in the history
  • Loading branch information
Dregu committed May 28, 2024
1 parent 4aa3387 commit 39e38e5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

MAXWELL is an ingame ImGui overlay for the game ANIMAL WELL, featuring an inventory editor, warping map, cheats etc.

It has last been tested on the 2024-05-27 build on Windows 10, but it might work on other versions too.
It has last been tested on the 2024-05-27 version 1.0.0.15 on Windows 10, but it might work on other versions too.

**Please go away if you haven't finished the game, this will spoil everything for you.**

Expand Down
35 changes: 34 additions & 1 deletion ui.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#define UNICODE

#include <Windows.h>

#include <array>
#include <chrono>
#include <d3d12.h>
Expand All @@ -17,6 +19,8 @@
#include "ui.h"
#include "version.h"

#pragma comment(lib, "version.lib")

// #define STB_IMAGE_IMPLEMENTATION
// #include "stb_image.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
Expand Down Expand Up @@ -105,6 +109,33 @@ void Flags(const std::array<const char *, SIZE> names_array, T *flag_field,
}
}

std::string GetAppVersion() {
DWORD dwHandle;
TCHAR fileName[MAX_PATH];

GetModuleFileName(NULL, fileName, MAX_PATH);
DWORD dwSize = GetFileVersionInfoSize(fileName, &dwHandle);
char *buffer = new char[dwSize];

VS_FIXEDFILEINFO *pvFileInfo = NULL;
UINT fiLen = 0;

if ((dwSize > 0) && GetFileVersionInfo(fileName, dwHandle, dwSize, &buffer)) {
VerQueryValue(&buffer, L"\\", (LPVOID *)&pvFileInfo, &fiLen);
}

if (fiLen > 0) {
char buf[25];
int len =
sprintf(buf, "%hu.%hu.%hu.%hu", HIWORD(pvFileInfo->dwFileVersionMS),
LOWORD(pvFileInfo->dwFileVersionMS),
HIWORD(pvFileInfo->dwFileVersionLS),
LOWORD(pvFileInfo->dwFileVersionLS));
return std::string(buf, len);
}
return "";
}

ImVec2 Normalize(ImVec2 pos) {
ImGuiIO &io = ImGui::GetIO();
ImVec2 res = io.DisplaySize;
Expand Down Expand Up @@ -450,7 +481,9 @@ void UI::Draw() {
ScaleWindow();

ImGuiIO &io = ImGui::GetIO();
std::string version = fmt::format("MAXWELL {}", get_version());
static const std::string gameversion = GetAppVersion();
std::string version = fmt::format("MAXWELL {}", get_version()) +
(gameversion != "" ? " | GAME " + gameversion : "");
ImGui::GetBackgroundDrawList()->AddText(
ImVec2(io.DisplaySize.x / 2.f -
ImGui::CalcTextSize(version.c_str()).x / 2.f,
Expand Down

0 comments on commit 39e38e5

Please sign in to comment.