diff --git a/CMake/CMakeVariables.h.in b/CMake/CMakeVariables.h.in index 85654134..930271db 100644 --- a/CMake/CMakeVariables.h.in +++ b/CMake/CMakeVariables.h.in @@ -3,6 +3,8 @@ #define SCREENPLAY_VERSION "@SCREENPLAY_VERSION@" #define SCREENPLAY_SOURCE_DIR "@SCREENPLAY_SOURCE_DIR@" #define SCREENPLAY_GODOT_VERSION "@SCREENPLAY_GODOT_VERSION@" +#define SCREENPLAY_GODOT_VERSION_MAJOR @SCREENPLAY_GODOT_VERSION_MAJOR@ +#define SCREENPLAY_GODOT_VERSION_MINOR @SCREENPLAY_GODOT_VERSION_MINOR@ #define SCREENPLAY_GODOT_RELEASE_TYPE "@SCREENPLAY_GODOT_RELEASE_TYPE@" #define SCREENPLAY_BUILD_TYPE "@SCREENPLAY_BUILD_TYPE@" #define SCREENPLAY_GIT_BRANCH_NAME "@SCREENPLAY_GIT_BRANCH_NAME@" diff --git a/CMake/GenerateCMakeVariableHeader.cmake b/CMake/GenerateCMakeVariableHeader.cmake index 33401597..1329b2c2 100644 --- a/CMake/GenerateCMakeVariableHeader.cmake +++ b/CMake/GenerateCMakeVariableHeader.cmake @@ -6,9 +6,15 @@ # Example generate_cmake_variable_header(${PROJECT_NAME}) # function(generate_cmake_variable_header TARGET) - # NOTE: Also add to CMakeVariables.h.in ! + # ⚠️ Also add to CMakeVariables.h.in ⚠️ + set(SCREENPLAY_SOURCE_DIR ${CMAKE_SOURCE_DIR}) + # Like v4.2-beta3 or v5.0.1-stable set(SCREENPLAY_GODOT_VERSION ${GODOT_VERSION}) + # Only single numbers + set(SCREENPLAY_GODOT_VERSION_MAJOR ${GODOT_VERSION_MAJOR}) + set(SCREENPLAY_GODOT_VERSION_MINOR ${GODOT_VERSION_MINOR}) + # stable, rc1 or beta5 set(SCREENPLAY_GODOT_RELEASE_TYPE ${GODOT_RELEASE_TYPE}) set(SCREENPLAY_BUILD_TYPE "${CMAKE_BUILD_TYPE}") set(SCREENPLAY_BUILD_DATE "${BUILD_DATE}") diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e86ec5c..1a47c10e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,15 +57,26 @@ set(VCPKG_INSTALLED_PATH "${VCPKG_PATH}/installed/${VCPKG_ARCH}") set(VCPKG_BIN_PATH "${VCPKG_INSTALLED_PATH}/bin") # Godot Editor -set(GODOT_VERSION "v4.2") -set(GODOT_RELEASE_TYPE "beta6") +set(GODOT_VERSION_MAJOR "4") +set(GODOT_VERSION_MINOR "2") +set(GODOT_VERSION_PATCH "") + +set(GODOT_RELEASE_TYPE "rc1") +# Use an if statement to check if GODOT_VERSION_PATCH is empty or not +if (GODOT_VERSION_PATCH STREQUAL "") + # If patch version is empty, don't include it and the preceding dot + set(GODOT_VERSION "v${GODOT_VERSION_MAJOR}.${GODOT_VERSION_MINOR}-${GODOT_RELEASE_TYPE}") +else() + # If patch version is not empty, include it and the preceding dot + set(GODOT_VERSION "v${GODOT_VERSION_MAJOR}.${GODOT_VERSION_MINOR}.${GODOT_VERSION_PATCH}-${GODOT_RELEASE_TYPE}") +endif() if(WIN32) - set(GODOT_EDITOR_NAME "Godot_${GODOT_VERSION}-${GODOT_RELEASE_TYPE}_win64.exe") + set(GODOT_EDITOR_NAME "Godot_${GODOT_VERSION}_win64.exe") elseif(APPLE) set(GODOT_EDITOR_NAME "Godot.app") elseif(UNIX) - set(GODOT_EDITOR_NAME "Godot_${GODOT_VERSION}-${GODOT_RELEASE_TYPE}_linux.x86_64") + set(GODOT_EDITOR_NAME "Godot_${GODOT_VERSION}_linux.x86_64") else() message(FATAL_ERROR "Unsupported OS") endif() diff --git a/ScreenPlay/inc/public/ScreenPlay/screenplaywallpaper.h b/ScreenPlay/inc/public/ScreenPlay/screenplaywallpaper.h index 271b128b..33fd323e 100644 --- a/ScreenPlay/inc/public/ScreenPlay/screenplaywallpaper.h +++ b/ScreenPlay/inc/public/ScreenPlay/screenplaywallpaper.h @@ -3,10 +3,13 @@ #pragma once #include +#include +#include #include #include #include - +#include +#include #include #include "ScreenPlay/globalvariables.h" @@ -210,7 +213,7 @@ public slots: } private: - bool exportGodotProject(const QString& absolutePath, int timeoutMilliseconds = 30000); + bool exportGodotProject(); private: const std::shared_ptr m_globalVariables; @@ -218,6 +221,7 @@ private: const std::shared_ptr m_settings; ProjectSettingsListModel m_projectSettingsListModel; + QJsonObject m_projectJson; QVector m_screenNumber; QProcess m_process; QString m_previewImage; diff --git a/ScreenPlay/src/screenplaywallpaper.cpp b/ScreenPlay/src/screenplaywallpaper.cpp index f8c91aa1..2732c3a4 100644 --- a/ScreenPlay/src/screenplaywallpaper.cpp +++ b/ScreenPlay/src/screenplaywallpaper.cpp @@ -16,7 +16,8 @@ namespace ScreenPlay { /*! \brief Constructor for ScreenPlayWallpaper. */ -ScreenPlayWallpaper::ScreenPlayWallpaper(const QVector& screenNumber, +ScreenPlayWallpaper::ScreenPlayWallpaper( + const QVector& screenNumber, const std::shared_ptr& globalVariables, const QString& appID, const QString& absolutePath, @@ -42,7 +43,10 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(const QVector& screenNumber, , m_playbackRate { playbackRate } , m_settings { settings } { - + std::optional projectOpt = ScreenPlayUtil::openJsonFileToObject(absolutePath + "/project.json"); + if (projectOpt.has_value()) { + m_projectJson = projectOpt.value(); + } QJsonObject projectSettingsListModelProperties; if (type == InstalledType::InstalledType::VideoWallpaper) { projectSettingsListModelProperties.insert("volume", m_volume); @@ -66,7 +70,7 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(const QVector& screenNumber, QString tmpScreenNumber; if (m_screenNumber.length() > 1) { - for (const int number : qAsConst(m_screenNumber)) { + for (const int number : std::as_const(m_screenNumber)) { // IMPORTANT: NO TRAILING COMMA! if (number == m_screenNumber.back()) { tmpScreenNumber += QString::number(number); @@ -92,13 +96,22 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(const QVector& screenNumber, if (m_type != InstalledType::InstalledType::GodotWallpaper) { m_appArgumentsList.append(" --disable-features=HardwareMediaKeyHandling"); } + if (m_type == InstalledType::InstalledType::GodotWallpaper) { + if (m_projectJson.contains("version")) { + const quint64 version = m_projectJson.value("version").toInt(); + const QString packageFileName = QString("project-v%1.zip").arg(version); + m_appArgumentsList.append(packageFileName); + } + } } bool ScreenPlayWallpaper::start() { if (m_type == InstalledType::InstalledType::GodotWallpaper) { - exportGodotProject(m_absolutePath); + if (!exportGodotProject()) + return false; } + m_process.setArguments(m_appArgumentsList); if (m_type == InstalledType::InstalledType::GodotWallpaper) { m_process.setProgram(m_globalVariables->godotWallpaperExecutablePath().toString()); @@ -293,22 +306,40 @@ bool ScreenPlayWallpaper::replace( return success; } -bool ScreenPlayWallpaper::exportGodotProject(const QString& absolutePath, int timeoutMilliseconds) +/*! + \brief . +*/ +bool ScreenPlayWallpaper::exportGodotProject() { + if (!m_projectJson.contains("version")) + return false; + + const quint64 version = m_projectJson.value("version").toInt(); + const QString packageFileName = QString("project-v%1.zip").arg(version); + QFileInfo godotPackageFile(m_absolutePath + "/" + packageFileName); + // Skip reexport + if (godotPackageFile.exists()) + return true; + + qInfo() << "No suitable version found for Godot package" << packageFileName << " at" << godotPackageFile.absoluteFilePath() << " exporting a new pck as zip."; + // Prepare the Godot export command - const QList godotCmd = { "--export-pack", "--headless", "Windows Desktop", "project.zip" }; + const QList + godotCmd + = { "--export-pack", "--headless", "Windows Desktop", packageFileName }; // Create QProcess instance to run the command QProcess process; // Set the working directory to the given absolute path - process.setWorkingDirectory(absolutePath); + process.setWorkingDirectory(m_absolutePath); process.setProgram(m_globalVariables->godotEditorExecutablePath().toString()); // Start the Godot export process process.setArguments(godotCmd); process.start(); // Wait for the process to finish or timeout + const int timeoutMilliseconds = 30000; if (!process.waitForFinished(timeoutMilliseconds)) { qCritical() << "Godot export process timed out or failed to start."; return false; @@ -331,9 +362,9 @@ bool ScreenPlayWallpaper::exportGodotProject(const QString& absolutePath, int ti } // Check if the project.zip file was created - QString zipPath = QDir(absolutePath).filePath("project.zip"); + QString zipPath = QDir(m_absolutePath).filePath(packageFileName); if (!QFile::exists(zipPath)) { - qCritical() << "Expected export file (project.zip) was not created."; + qCritical() << "Expected export file (" << packageFileName << ") was not created."; return false; } @@ -342,7 +373,7 @@ bool ScreenPlayWallpaper::exportGodotProject(const QString& absolutePath, int ti // but for simplicity, we're just checking its size here) QFileInfo zipInfo(zipPath); if (zipInfo.size() <= 0) { - qCritical() << "The exported project.zip file seems to be invalid."; + qCritical() << "The exported " << packageFileName << " file seems to be invalid."; return false; } diff --git a/ScreenPlay/src/wizards.cpp b/ScreenPlay/src/wizards.cpp index 3094ceb6..78d4f709 100644 --- a/ScreenPlay/src/wizards.cpp +++ b/ScreenPlay/src/wizards.cpp @@ -1,5 +1,6 @@ // SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only #include "ScreenPlay/wizards.h" +#include "ScreenPlay/CMakeVariables.h" #include "ScreenPlayUtil/util.h" #include #include @@ -322,6 +323,13 @@ void Wizards::createGodotWallpaper( obj.insert("license", licenseName); obj.insert("title", title); obj.insert("createdBy", createdBy); + // Every version change will trigger an reexport + obj.insert("version", 1); + // Something like v4.2-beta3 or v5.0.1-stable + QString godotVersionMajor = QString::number(SCREENPLAY_GODOT_VERSION_MAJOR); + QString godotVersionMinor = QString::number(SCREENPLAY_GODOT_VERSION_MINOR); + obj.insert("godotVersionMajor", godotVersionMajor); + obj.insert("godotVersionMinor", godotVersionMinor); obj.insert("tags", ScreenPlayUtil::fillArray(tags)); obj.insert("type", QVariant::fromValue(InstalledType::InstalledType::GodotWallpaper).toString()); obj.insert("file", "wallpaper.tscn"); diff --git a/ScreenPlayWallpaper/Godot/GDExtention/src/ScreenPlayGodotWallpaper.cpp b/ScreenPlayWallpaper/Godot/GDExtention/src/ScreenPlayGodotWallpaper.cpp index b219fb0f..7476a1d6 100644 --- a/ScreenPlayWallpaper/Godot/GDExtention/src/ScreenPlayGodotWallpaper.cpp +++ b/ScreenPlayWallpaper/Godot/GDExtention/src/ScreenPlayGodotWallpaper.cpp @@ -33,6 +33,9 @@ void ScreenPlayGodotWallpaper::_bind_methods() ClassDB::bind_method(godot::D_METHOD("get_activeScreensList"), &ScreenPlayGodotWallpaper::get_activeScreensList); ClassDB::bind_method(godot::D_METHOD("set_activeScreensList", "screens"), &ScreenPlayGodotWallpaper::set_activeScreensList); + ClassDB::bind_method(godot::D_METHOD("get_projectPackageFile"), &ScreenPlayGodotWallpaper::get_projectPackageFile); + ClassDB::bind_method(godot::D_METHOD("set_projectPackageFile", "projectPackageFile"), &ScreenPlayGodotWallpaper::set_projectPackageFile); + ClassDB::bind_method(godot::D_METHOD("get_projectPath"), &ScreenPlayGodotWallpaper::get_projectPath); ClassDB::bind_method(godot::D_METHOD("set_projectPath", "path"), &ScreenPlayGodotWallpaper::set_projectPath); @@ -54,6 +57,16 @@ void ScreenPlayGodotWallpaper::hideFromTaskbar(HWND hwnd) SetWindowLong(hwnd, GWL_EXSTYLE, lExStyle); } +godot::String ScreenPlayGodotWallpaper::get_projectPackageFile() const +{ + return m_projectPackageFile; +} + +void ScreenPlayGodotWallpaper::set_projectPackageFile(const godot::String& projectPackageFile) +{ + m_projectPackageFile = projectPackageFile; +} + bool ScreenPlayGodotWallpaper::configureWindowGeometry() { if (!m_windowsIntegration.searchWorkerWindowToParentTo()) { diff --git a/ScreenPlayWallpaper/Godot/GDExtention/src/ScreenPlayGodotWallpaper.h b/ScreenPlayWallpaper/Godot/GDExtention/src/ScreenPlayGodotWallpaper.h index ea1d12ff..b8fcb18b 100644 --- a/ScreenPlayWallpaper/Godot/GDExtention/src/ScreenPlayGodotWallpaper.h +++ b/ScreenPlayWallpaper/Godot/GDExtention/src/ScreenPlayGodotWallpaper.h @@ -57,6 +57,9 @@ public: bool send_ping(); bool exit(); + godot::String get_projectPackageFile() const; + void set_projectPackageFile(const godot::String& projectPackageFile); + protected: static void _bind_methods(); @@ -70,6 +73,7 @@ private: godot::String m_appID = ""; godot::String m_projectPath = ""; + godot::String m_projectPackageFile = ""; WindowsIntegration m_windowsIntegration; double m_timesinceLastRead = 0.0; bool m_pipeConnected = false; diff --git a/ScreenPlayWallpaper/Godot/ScreenPlayGodot/main.gd b/ScreenPlayWallpaper/Godot/ScreenPlayGodot/main.gd index dbf71198..71d21a4c 100644 --- a/ScreenPlayWallpaper/Godot/ScreenPlayGodot/main.gd +++ b/ScreenPlayWallpaper/Godot/ScreenPlayGodot/main.gd @@ -44,7 +44,7 @@ func _ready(): get_tree().quit() return #screen_play_wallpaper.set_projectPath("C:\\Code\\cpp\\ScreenPlay\\ScreenPlay\\Content\\wallpaper_godot_fjord") - path = screen_play_wallpaper.get_projectPath() + "/project.zip" + path = screen_play_wallpaper.get_projectPath() + "/" + screen_play_wallpaper.get_projectPackageFile() else: get_tree().quit() return @@ -99,7 +99,7 @@ func parse_args(): if args[0] == "res://main.tscn": offset = 1 - if args.size() < 7: # Adjust this number based on the expected number of arguments + if args.size() < 8: # Adjust this number based on the expected number of arguments print("Not enough arguments provided!") return false @@ -122,6 +122,7 @@ func parse_args(): var type = args[5] # This might need further parsing depending on its expected format screen_play_wallpaper.set_checkWallpaperVisible(args[6 + offset].to_lower() == "true") screen_play_wallpaper.set_activeScreensList(activeScreensList) + screen_play_wallpaper.set_projectPackageFile(args[7 + offset]) # Print or use the parsed values as needed print("Parsing done:", activeScreensList, screen_play_wallpaper.get_projectPath(), screen_play_wallpaper.get_appID(), screen_play_wallpaper.get_volume(), type, screen_play_wallpaper.get_checkWallpaperVisible()) diff --git a/ScreenPlayWallpaper/Godot/ScreenPlayGodot/project.godot b/ScreenPlayWallpaper/Godot/ScreenPlayGodot/project.godot index cb14a4c2..d48bcd61 100644 --- a/ScreenPlayWallpaper/Godot/ScreenPlayGodot/project.godot +++ b/ScreenPlayWallpaper/Godot/ScreenPlayGodot/project.godot @@ -23,14 +23,14 @@ config/icon="res://icon.svg" window/size/viewport_width=1 window/size/viewport_height=1 -window/size/mode=1 -window/size/initial_position_type=0 -window/size/initial_position=Vector2i(9999999, 9999999) +window/size/resizable=false window/size/borderless=true +window/size/transparent=true +window/energy_saving/keep_screen_on=false [editor] -run/main_run_args="\"0\" \"C:/Code/Cpp/ScreenPlay/ScreenPlay/Content/wallpaper_godot_fjord\" \"appID=test\" \"1\" \"Cover\" \"GodotWallpaper\" \"1\"" +run/main_run_args="\"1\" \"C:/Code/Cpp/ScreenPlay/ScreenPlay/Content/wallpaper_godot_fjord\" \"appID=test\" \"1\" \"Cover\" \"GodotWallpaper\" \"1\" \"project-v1.zip\"" [filesystem] diff --git a/Tools/defines.py b/Tools/defines.py index 7e577b74..39466cc2 100644 --- a/Tools/defines.py +++ b/Tools/defines.py @@ -37,7 +37,7 @@ VCPKG_BASE_PACKAGES = [ PYTHON_EXECUTABLE = "python" if sys.platform == "win32" else "python3" FFMPEG_VERSION = "6.0" GODOT_VERSION = "4.2" -GODOT_RELEASE_TYPE = "beta6" +GODOT_RELEASE_TYPE = "rc1" GODOT_DOWNLOAD_SERVER = "https://github.com/godotengine/godot-builds/releases/download" if sys.platform == "win32": SCREENPLAYWALLPAPER_GODOT_EXECUTABLE = "ScreenPlayWallpaperGodot.exe"