diff --git a/CMakeLists.txt b/CMakeLists.txt index dd8867a7..38bc6dff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,6 @@ if(NOT CMAKE_BUILD_TYPE) endif() project(Alber) -set(PANDA3DS_VERSION "0.8") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) if(APPLE) @@ -44,6 +43,7 @@ option(ENABLE_HTTP_SERVER "Enable HTTP server. Used for Discord bot support" OFF option(ENABLE_DISCORD_RPC "Compile with Discord RPC support (disabled by default)" ON) option(ENABLE_LUAJIT "Enable scripting with the Lua programming language" ON) option(ENABLE_QT_GUI "Enable the Qt GUI. If not selected then the emulator uses a minimal SDL-based UI instead" OFF) +option(ENABLE_GIT_VERSIONING "Enables querying git for the emulator version" ON) option(BUILD_HYDRA_CORE "Build a Hydra core" OFF) option(BUILD_LIBRETRO_CORE "Build a Libretro core" OFF) @@ -61,8 +61,15 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND ENABLE_USER_BUILD) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS-") endif() +# Generate versioning files find_package(Git) -if(GIT_FOUND) +set(PANDA3DS_VERSION "0.8") + +if(NOT EXISTS ${CMAKE_BINARY_DIR}/include/version.hpp.in) + file(WRITE ${CMAKE_BINARY_DIR}/include/version.hpp.in "#define PANDA3DS_VERSION \"\${PANDA3DS_VERSION}\"") +endif() + +if(GIT_FOUND AND ENABLE_GIT_VERSIONING) execute_process( WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0 OUTPUT_VARIABLE PANDA3DS_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE @@ -82,7 +89,7 @@ if(GIT_FOUND) string(REGEX REPLACE "^v" "" PANDA3DS_VERSION "${PANDA3DS_VERSION}") unset(git_version_tag) endif() -configure_file(${PROJECT_SOURCE_DIR}/include/version.hpp.in ${CMAKE_BINARY_DIR}/include/version.hpp) +configure_file(${CMAKE_BINARY_DIR}/include/version.hpp.in ${CMAKE_BINARY_DIR}/include/version.hpp) include_directories(${CMAKE_BINARY_DIR}/include/) add_library(AlberCore STATIC) diff --git a/include/config.hpp b/include/config.hpp index 52be1af7..8833e4b3 100644 --- a/include/config.hpp +++ b/include/config.hpp @@ -40,6 +40,9 @@ struct EmulatorConfig { bool audioEnabled = false; bool vsyncEnabled = true; + bool printAppVersion = true; + bool appVersionOnWindow = false; + bool chargerPlugged = true; // Default to 3% battery to make users suffer int batteryPercentage = 3; diff --git a/include/version.hpp.in b/include/version.hpp.in deleted file mode 100644 index 37359828..00000000 --- a/include/version.hpp.in +++ /dev/null @@ -1 +0,0 @@ -#define PANDA3DS_VERSION "${PANDA3DS_VERSION}" diff --git a/src/config.cpp b/src/config.cpp index dae5a0ab..e1bbf2e4 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -41,6 +41,9 @@ void EmulatorConfig::load() { discordRpcEnabled = toml::find_or(general, "EnableDiscordRPC", false); usePortableBuild = toml::find_or(general, "UsePortableBuild", false); defaultRomPath = toml::find_or(general, "DefaultRomPath", ""); + + printAppVersion = toml::find_or(general, "PrintAppVersion", true); + appVersionOnWindow = toml::find_or(general, "AppVersionOnWindow", false); } } @@ -127,6 +130,8 @@ void EmulatorConfig::save() { data["General"]["EnableDiscordRPC"] = discordRpcEnabled; data["General"]["UsePortableBuild"] = usePortableBuild; data["General"]["DefaultRomPath"] = defaultRomPath.string(); + data["General"]["PrintAppVersion"] = printAppVersion; + data["General"]["AppVersionOnWindow"] = appVersionOnWindow; data["GPU"]["EnableShaderJIT"] = shaderJitEnabled; data["GPU"]["Renderer"] = std::string(Renderer::typeToString(rendererType)); diff --git a/src/panda_qt/main_window.cpp b/src/panda_qt/main_window.cpp index 4b1f399d..45690da7 100644 --- a/src/panda_qt/main_window.cpp +++ b/src/panda_qt/main_window.cpp @@ -14,7 +14,7 @@ #include "services/dsp.hpp" MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent), keyboardMappings(InputMappings::defaultKeyboardMappings()) { - setWindowTitle("Alber - " PANDA3DS_VERSION); + setWindowTitle("Alber"); // Enable drop events for loading ROMs setAcceptDrops(true); resize(800, 240 * 4); @@ -99,6 +99,14 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent) } } + if (emu->getConfig().appVersionOnWindow) { + setWindowTitle("Alber v" PANDA3DS_VERSION); + } + + if (emu->getConfig().printAppVersion) { + printf("Welcome to Panda3DS v%s!\n", PANDA3DS_VERSION); + } + // The emulator graphics context for the thread should be initialized in the emulator thread due to how GL contexts work emuThread = std::thread([this]() { const RendererType rendererType = emu->getConfig().rendererType; diff --git a/src/panda_sdl/frontend_sdl.cpp b/src/panda_sdl/frontend_sdl.cpp index a60bc484..c892c3c5 100644 --- a/src/panda_sdl/frontend_sdl.cpp +++ b/src/panda_sdl/frontend_sdl.cpp @@ -33,7 +33,11 @@ FrontendSDL::FrontendSDL() : keyboardMappings(InputMappings::defaultKeyboardMapp #ifdef PANDA3DS_ENABLE_OPENGL needOpenGL = needOpenGL || (config.rendererType == RendererType::OpenGL); #endif - char* windowTitle = "Alber - " PANDA3DS_VERSION; + + const char* windowTitle = config.appVersionOnWindow ? ("Alber v" PANDA3DS_VERSION) : "Alber"; + if (config.printAppVersion) { + printf("Welcome to Panda3DS v%s!\n", PANDA3DS_VERSION); + } if (needOpenGL) { // Demand 3.3 core for software renderer, or 4.1 core for OpenGL renderer (max available on MacOS)