diff --git a/.gitattributes b/.gitattributes
index d76aec1..70fd382 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -6,3 +6,5 @@ enginecustom/x64/Debug/lua54.dll filter=lfs diff=lfs merge=lfs -text
enginecustom/x64/Release/lua54.dll filter=lfs diff=lfs merge=lfs -text
x64/Debug/lua54.dll filter=lfs diff=lfs merge=lfs -text
x64/Release/lua54.dll filter=lfs diff=lfs merge=lfs -text
+x64/Debug/config.txt filter=lfs diff=lfs merge=lfs -text
+x64/Release/config.txt filter=lfs diff=lfs merge=lfs -text
diff --git a/enginecustom/enginecustom.vcxproj b/enginecustom/enginecustom.vcxproj
index eb89cc7..b6eddea 100644
--- a/enginecustom/enginecustom.vcxproj
+++ b/enginecustom/enginecustom.vcxproj
@@ -156,6 +156,7 @@
+
diff --git a/enginecustom/imgui.ini b/enginecustom/imgui.ini
index dac9d77..2c23bb3 100644
--- a/enginecustom/imgui.ini
+++ b/enginecustom/imgui.ini
@@ -12,7 +12,7 @@ Collapsed=0
Pos=1267,19
Size=317,842
Collapsed=0
-DockId=0x00000005,0
+DockId=0x00000006,0
[Window][render Stats]
Pos=0,630
@@ -48,20 +48,20 @@ DockId=0x0000000B,0
Pos=1267,462
Size=317,166
Collapsed=0
-DockId=0x00000006,0
+DockId=0x00000002,0
[Docking][Data]
-DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=1584,842 Split=Y
- DockNode ID=0x00000003 Parent=0xCCBD8CF7 SizeRef=1584,609 Split=X
- DockNode ID=0x0000000B Parent=0x00000003 SizeRef=234,842 Selected=0x031DC75C
- DockNode ID=0x0000000C Parent=0x00000003 SizeRef=1348,842 Split=X
- DockNode ID=0x00000007 Parent=0x0000000C SizeRef=266,842 Selected=0x393905AB
- DockNode ID=0x00000008 Parent=0x0000000C SizeRef=1316,842 Split=X
- DockNode ID=0x00000001 Parent=0x00000008 SizeRef=1265,842 CentralNode=1
- DockNode ID=0x00000002 Parent=0x00000008 SizeRef=317,842 Split=Y Selected=0x9F035453
- DockNode ID=0x00000005 Parent=0x00000002 SizeRef=317,441 Selected=0x9F035453
- DockNode ID=0x00000006 Parent=0x00000002 SizeRef=317,166 Selected=0x0B098C4B
- DockNode ID=0x00000004 Parent=0xCCBD8CF7 SizeRef=1584,231 Split=X Selected=0xF5D1BB37
- DockNode ID=0x00000009 Parent=0x00000004 SizeRef=792,231 Selected=0xF5D1BB37
- DockNode ID=0x0000000A Parent=0x00000004 SizeRef=790,231 Selected=0xAB74BEE9
+DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=1584,842 Split=X
+ DockNode ID=0x00000005 Parent=0xCCBD8CF7 SizeRef=1265,842 Split=Y
+ DockNode ID=0x00000003 Parent=0x00000005 SizeRef=1584,609 Split=X
+ DockNode ID=0x0000000B Parent=0x00000003 SizeRef=234,842 Selected=0x031DC75C
+ DockNode ID=0x0000000C Parent=0x00000003 SizeRef=1348,842 Split=X
+ DockNode ID=0x00000007 Parent=0x0000000C SizeRef=266,842 Selected=0x393905AB
+ DockNode ID=0x00000008 Parent=0x0000000C SizeRef=1316,842 Split=X
+ DockNode ID=0x00000001 Parent=0x00000008 SizeRef=1265,842 CentralNode=1
+ DockNode ID=0x00000002 Parent=0x00000008 SizeRef=317,842 Selected=0x9F035453
+ DockNode ID=0x00000004 Parent=0x00000005 SizeRef=1584,231 Split=X Selected=0xF5D1BB37
+ DockNode ID=0x00000009 Parent=0x00000004 SizeRef=792,231 Selected=0xF5D1BB37
+ DockNode ID=0x0000000A Parent=0x00000004 SizeRef=790,231 Selected=0xAB74BEE9
+ DockNode ID=0x00000006 Parent=0xCCBD8CF7 SizeRef=317,842 Selected=0x9F035453
diff --git a/enginecustom/src/inc/system/imguiManager.h b/enginecustom/src/inc/system/imguiManager.h
index 1cd6908..2c2224f 100644
--- a/enginecustom/src/inc/system/imguiManager.h
+++ b/enginecustom/src/inc/system/imguiManager.h
@@ -17,6 +17,8 @@
#include "scene_manager.h"
#include "ecs/entity_manager.h"
+#include "version.h"
+
class application_class;
class stats;
@@ -47,6 +49,16 @@ public:
imguiManager();
~imguiManager();
+ /**
+ * Load the build version from a configuration file.
+ * The configuration file should contain a line with the build version in the format "VER=XXX...".
+ * If the line is not found, it will be added with a version of 0.
+ * The build version will be incremented by 1 each time this function is called.
+ * @param filepath The path to the configuration file.
+ * @return True if the build version was loaded successfully, otherwise false.
+ */
+ bool IncrementBuildVersionInConfig(const std::string& filepath);
+
/**
* Initializes the ImGui manager.
* @param hwnd Handle to the window where ImGui will be rendered.
@@ -217,6 +229,8 @@ private:
std::string version_driver_;
ecs::EntityID m_selected_entity_id = 0; // ID of the currently selected entity
+
+ int BUILD_VERSION_VER = -1;
};
#endif
\ No newline at end of file
diff --git a/enginecustom/src/inc/system/version.h b/enginecustom/src/inc/system/version.h
new file mode 100644
index 0000000..9e25a8b
--- /dev/null
+++ b/enginecustom/src/inc/system/version.h
@@ -0,0 +1,24 @@
+#pragma once
+#include "imgui.h"
+#define BUILD_VERSION_MAJOR 14
+#define BUILD_VERSION_MINOR 0
+#define BUILD_VERSION_PATCH 3
+
+// BUILD_VERSION_VER est un int persisté dans un fichier, à charger au lancement et incrémenter à chaque build (voir point 3)
+extern int BUILD_VERSION_VER;
+
+#ifdef _DEBUG
+#define BUILD_VERSION_TYPE "Debug"
+#define BUILD_VERSION_INVERSE "Release"
+// define a color for debug mode (dark yellow)
+#define DEBUG_MODE_COLOR IM_COL32(204, 153, 0, 255)
+#else
+#define BUILD_VERSION_TYPE "Release"
+#define BUILD_VERSION_INVERSE "Debug"
+// define a color for release mode (rouge bordeau)
+#define DEBUG_MODE_COLOR IM_COL32(128, 0, 32, 255)
+#endif
+
+// BUILD_VERSION_STATE est défini manuellement (ex "Dev" ou "Stable")
+#define BUILD_VERSION_STATE "Dev"
+//#define BUILD_VERSION_STATE "Stable"
diff --git a/enginecustom/src/src/system/imguiManager.cpp b/enginecustom/src/src/system/imguiManager.cpp
index 88de361..d6d5765 100644
--- a/enginecustom/src/src/system/imguiManager.cpp
+++ b/enginecustom/src/src/system/imguiManager.cpp
@@ -49,6 +49,50 @@ imguiManager::~imguiManager()
{
}
+bool imguiManager::IncrementBuildVersionInConfig(const std::string& filepath) {
+ std::ifstream file_in(filepath);
+ if (!file_in) return false; // fichier introuvable
+
+ std::vector lines;
+ std::string line;
+
+ // Lire toutes les lignes pour les manipuler
+ while (std::getline(file_in, line)) {
+ if (line.find("VER=") == 0) {
+ // Extraire la version actuelle
+ std::string ver_str = line.substr(4);
+ try {
+ BUILD_VERSION_VER = std::stoi(ver_str);
+ if (BUILD_VERSION_STATE == "Dev")
+ {
+ BUILD_VERSION_VER += 1;
+ line = "VER=" + std::to_string(BUILD_VERSION_VER);
+ }
+ } catch (...) {
+ return false; // erreur conversion
+ }
+ }
+ lines.push_back(line);
+ }
+ file_in.close();
+
+ // Si pas trouvé VER=, on l'ajoute
+ if (BUILD_VERSION_VER == -1) {
+ BUILD_VERSION_VER = 0;
+ lines.push_back("VER=0");
+ }
+
+ // Réécrire tout le fichier
+ std::ofstream file_out(filepath, std::ios::trunc);
+ if (!file_out) return false;
+
+ for (const auto& l : lines) {
+ file_out << l << "\n";
+ }
+ file_out.close();
+ return true;
+}
+
bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceContext* deviceContext)
{
Logger::Get().Log("Initializing imgui", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -186,6 +230,40 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
total_vertex_count_ = stats_->get_vertex_count_ptr();
entity_manager_ = app_->get_entity_manager();
+
+ // Get the exe parent directory to find config.txt ../exefolder
+ char exePath[MAX_PATH];
+ GetModuleFileNameA(NULL, exePath, MAX_PATH);
+ std::string exeDir = std::string(exePath);
+ // Retirer la partie exe filename (tout après le dernier slash)
+ size_t lastSlash = exeDir.find_last_of("\\/");
+ if (lastSlash != std::string::npos) {
+ exeDir = exeDir.substr(0, lastSlash);
+ } else {
+ exeDir = "";
+ }
+
+ // Retirer encore le dernier dossier (rebrousser dans le parent) : aller dans le dossier parent
+ lastSlash = exeDir.find_last_of("\\/");
+ if (lastSlash != std::string::npos) {
+ exeDir = exeDir.substr(0, lastSlash + 1); // garder slash de fin pour concat
+ } else {
+ exeDir = "";
+ }
+
+ std::string configPath = "config.txt"; // ou chemin complet
+ configPath = exeDir + BUILD_VERSION_TYPE + "\\" + configPath;
+ if (!IncrementBuildVersionInConfig(configPath)) {
+ Logger::Get().Log("Failed to increment build version in config.txt", __FILE__, __LINE__, Logger::LogLevel::Warning);
+ }
+
+ // update the build version text in the inverse build type folder
+ configPath = "config.txt";
+ configPath = exeDir + BUILD_VERSION_INVERSE + "\\" + configPath;
+ Logger::Get().Log("Inverse build type config path: " + configPath, __FILE__, __LINE__, Logger::LogLevel::Info);
+ if (!IncrementBuildVersionInConfig(configPath)) {
+ Logger::Get().Log("Failed to increment build version in config.txt of inverse build type", __FILE__, __LINE__, Logger::LogLevel::Warning);
+ }
Logger::Get().Log("imgui initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -276,6 +354,44 @@ void imguiManager::SetupDockspace() {
ImGui::EndMenu();
}
+ const float PAD_X = 14.0f;
+ float menuBarHeight = ImGui::GetFrameHeight();
+
+ std::string versionText = std::string("Build-") + BUILD_VERSION_TYPE + "-" +
+ std::to_string(BUILD_VERSION_MAJOR) + "." +
+ std::to_string(BUILD_VERSION_MINOR) + "." +
+ std::to_string(BUILD_VERSION_PATCH) + "." +
+ std::to_string(BUILD_VERSION_VER) + "-" +
+ BUILD_VERSION_STATE;
+
+ ImVec2 textSize = ImGui::CalcTextSize(versionText.c_str());
+ float windowWidth = ImGui::GetWindowContentRegionMax().x;
+
+ // Rectangle ajusté parfaitement à la hauteur
+ float rectWidth = textSize.x + PAD_X * 2;
+ float rectX = ImGui::GetWindowPos().x + windowWidth - rectWidth - 10.0f; // marge droite
+ float rectY = ImGui::GetWindowPos().y;
+ float offsetX = textSize.x * 0.2f;
+
+ ImVec2 rectMin(rectX - offsetX, rectY);
+ ImVec2 rectMax(rectX + rectWidth - offsetX, rectY + menuBarHeight);
+
+ // Fond arrondi parfaitement aligné avec la barre
+ ImGui::GetForegroundDrawList()->AddRectFilled(
+ rectMin, rectMax, DEBUG_MODE_COLOR, menuBarHeight / 2.0f
+ );
+
+ // Texte centré verticalement dans le rectangle
+ ImVec2 textPos(
+ rectMin.x + PAD_X,
+ rectMin.y + (menuBarHeight - textSize.y) / 2.0f
+ );
+
+ ImGui::GetForegroundDrawList()->AddText(
+ ImGui::GetFont(), ImGui::GetFontSize(),
+ textPos, IM_COL32(255,255,255,255), versionText.c_str()
+ );
+
ImGui::EndMenuBar();
}
diff --git a/x64/Debug/config.txt b/x64/Debug/config.txt
new file mode 100644
index 0000000..6a478b5
--- /dev/null
+++ b/x64/Debug/config.txt
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f10276fc7b03d157f658a34c61a69c39b6849eac0b4c35b5f3c4e063c10c5753
+size 8
diff --git a/x64/Release/config.txt b/x64/Release/config.txt
new file mode 100644
index 0000000..6a478b5
--- /dev/null
+++ b/x64/Release/config.txt
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f10276fc7b03d157f658a34c61a69c39b6849eac0b4c35b5f3c4e063c10c5753
+size 8