diff --git a/.gitignore b/.gitignore index c54bd13..e9f7710 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ PanoPainter.aps panopainter-log.txt *.pano frames/ +engine/version.gen.h diff --git a/PanoPainter.rc b/PanoPainter.rc index 4c4255c..d1bb1e7 100644 Binary files a/PanoPainter.rc and b/PanoPainter.rc differ diff --git a/data/layout.xml b/data/layout.xml index dae273b..6f244b1 100644 --- a/data/layout.xml +++ b/data/layout.xml @@ -766,7 +766,7 @@ - + diff --git a/engine.vcxproj b/engine.vcxproj index 1e510a9..c63041d 100644 --- a/engine.vcxproj +++ b/engine.vcxproj @@ -119,8 +119,7 @@ true - - + python .\scripts\pre-build.py debug @@ -163,8 +162,7 @@ true - - + python .\scripts\pre-build.py release @@ -230,6 +228,10 @@ + + NotUsing + NotUsing + NotUsing @@ -336,6 +338,8 @@ + + diff --git a/engine.vcxproj.filters b/engine.vcxproj.filters index b681c9b..bb72dac 100644 --- a/engine.vcxproj.filters +++ b/engine.vcxproj.filters @@ -249,6 +249,9 @@ Source Files\ui + + Source Files + @@ -440,6 +443,12 @@ Header Files\ui + + Header Files + + + Header Files + diff --git a/engine/app_layout.cpp b/engine/app_layout.cpp index 8e13fe6..1f9429c 100644 --- a/engine/app_layout.cpp +++ b/engine/app_layout.cpp @@ -632,6 +632,13 @@ void App::initLayout() init_menu_layer(); init_menu_timelapse(); + // set version string + if (auto* version_label = layout[main_id]->find("version")) + { + version_label->set_text(g_version); + } + + if (auto* menu_entry = layout[main_id]->find("menu-about")) { menu_entry->on_click = [=](Node*) { diff --git a/engine/main.cpp b/engine/main.cpp index 624ed79..2301410 100644 --- a/engine/main.cpp +++ b/engine/main.cpp @@ -357,6 +357,9 @@ int main(int argc, char** argv) LOG("GL vendor: %s", glGetString(GL_VENDOR)); LOG("GL renderer: %s", glGetString(GL_RENDERER)); + static wchar_t window_title[512]; + swprintf_s(window_title, L"PanoPainter %s", g_version_number_w); + // If supported create a 3.1 context if (wglewIsSupported("WGL_ARB_create_context")) { @@ -388,7 +391,7 @@ int main(int argc, char** argv) wglDeleteContext(hRC); DestroyWindow(hWnd); - hWnd = CreateWindow(wc.lpszClassName, L"PanoPainter 0.1.2 alpha - OpenGL 3.1", WS_OVERLAPPEDWINDOW, + hWnd = CreateWindow(wc.lpszClassName, window_title, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, clientRect.right - clientRect.left, clientRect.bottom - clientRect.top, 0, 0, hInst, 0); @@ -451,9 +454,9 @@ int main(int argc, char** argv) if (one_sec > 1.f) { - static char title[512]; - sprintf_s(title, "PanoPainter 0.1.2 alpha - OpenGL 3.1 - %d fps", frames); - SetWindowTextA(hWnd, title); + static wchar_t title_fps[512]; + swprintf_s(title_fps, L"%s - %d fps", window_title, frames); + SetWindowText(hWnd, title_fps); one_sec = 0; frames = 0; } diff --git a/engine/pch.h b/engine/pch.h index f9526b7..b21f7de 100644 --- a/engine/pch.h +++ b/engine/pch.h @@ -1,5 +1,7 @@ //#pragma once +#include "version.h" + #define USE_VBO 1 #define USE_SAMPLER 1 diff --git a/engine/version.cpp b/engine/version.cpp new file mode 100644 index 0000000..b49c6da --- /dev/null +++ b/engine/version.cpp @@ -0,0 +1,11 @@ +#include "version.h" +#include "version.gen.h" +#include "windows.h" + +const char* g_version = PP_VERSION_STRING; +const char* g_version_number = PP_VERSION_NUMBER_STRING; +const char* g_window_title = "PanoPainter " PP_VERSION_NUMBER_STRING; + +const wchar_t* g_version_w = TEXT(PP_VERSION_STRING); +const wchar_t* g_version_number_w = TEXT(PP_VERSION_NUMBER_STRING); +const wchar_t* g_window_title_w = L"PanoPainter " TEXT(PP_VERSION_NUMBER_STRING); diff --git a/engine/version.h b/engine/version.h new file mode 100644 index 0000000..6f70250 --- /dev/null +++ b/engine/version.h @@ -0,0 +1,9 @@ +#pragma once + +extern const char* g_version; +extern const char* g_version_number; +extern const char* g_window_title; + +extern const wchar_t* g_version_w; +extern const wchar_t* g_version_number_w; +extern const wchar_t* g_window_title_w; diff --git a/scripts/pre-build.py b/scripts/pre-build.py new file mode 100644 index 0000000..ab5b492 --- /dev/null +++ b/scripts/pre-build.py @@ -0,0 +1,43 @@ +from subprocess import Popen, PIPE, check_output +from tempfile import mkstemp +from shutil import move +from os import remove, close +import re, subprocess, sys + +branch = check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).rstrip().decode("utf-8") +shorthash = check_output(["git", "log", "--pretty=format:%h", "-n 1"]).rstrip().decode("utf-8") +revcount = len(check_output(["git", "log", "--oneline"]).split(b'\n')) - 1 +tag = check_output(["git", "describe", "--tags", "--abbrev=0"]).rstrip().decode("utf-8") +config = sys.argv[1] + +version = "%s.%d (%s-%s-%s)" % (tag, revcount, shorthash, branch, config) +version_number = "%s.%d" % (tag, revcount) + +print("Compiling version: %s" % version) + +version_gen_h = '// AUTO GENERATED FILE - DON\'T MODIFY\n' +version_gen_h += '#define PP_VERSION_NUMBER_STRING "%s"\n' % version_number +version_gen_h += '#define PP_VERSION_STRING "%s"\n' % version +f = open("engine/version.gen.h", "w") +f.write(version_gen_h) + + +""" +file_path = "Setup\\Product.wxs"; +#Create temp file +fh, abs_path = mkstemp() +regex = re.compile(r'Version="\d+\.\d+\.\d+\.\d+"') +with open(abs_path,'w') as new_file: + with open(file_path) as old_file: + for line in old_file: + new_line = regex.sub('Version="%s"' % version, line) + new_file.write(new_line) +close(fh) +#Remove original file +remove(file_path) +#Move new file +move(abs_path, file_path) +""" + + +exit(0)