1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-21 18:22:29 +01:00

Add proper Godot package export caching

We now have  3 versions saved in the godot
project.json.

version: Project version. Every version bump will trigger a
reexport.

We just save the major and minor version for now. Godot
does have pretty good version compability. We will need this information
later when we upgrade to newer Godot versions

godotVersionMajor
godotVersionMinor

Update to latest Godot RC1
This commit is contained in:
Elias Steurer 2023-11-23 11:37:50 +01:00
parent a21829ea05
commit 0185d6d952
11 changed files with 104 additions and 24 deletions

View File

@ -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@"

View File

@ -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}")

View File

@ -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()

View File

@ -3,10 +3,13 @@
#pragma once
#include <QDebug>
#include <QDir>
#include <QFileInfoList>
#include <QJsonObject>
#include <QObject>
#include <QProcess>
#include <QString>
#include <QStringList>
#include <memory>
#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<GlobalVariables> m_globalVariables;
@ -218,6 +221,7 @@ private:
const std::shared_ptr<Settings> m_settings;
ProjectSettingsListModel m_projectSettingsListModel;
QJsonObject m_projectJson;
QVector<int> m_screenNumber;
QProcess m_process;
QString m_previewImage;

View File

@ -16,7 +16,8 @@ namespace ScreenPlay {
/*!
\brief Constructor for ScreenPlayWallpaper.
*/
ScreenPlayWallpaper::ScreenPlayWallpaper(const QVector<int>& screenNumber,
ScreenPlayWallpaper::ScreenPlayWallpaper(
const QVector<int>& screenNumber,
const std::shared_ptr<GlobalVariables>& globalVariables,
const QString& appID,
const QString& absolutePath,
@ -42,7 +43,10 @@ ScreenPlayWallpaper::ScreenPlayWallpaper(const QVector<int>& screenNumber,
, m_playbackRate { playbackRate }
, m_settings { settings }
{
std::optional<QJsonObject> 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<int>& 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<int>& 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<QString> godotCmd = { "--export-pack", "--headless", "Windows Desktop", "project.zip" };
const QList<QString>
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;
}

View File

@ -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 <QFont>
#include <QLinearGradient>
@ -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");

View File

@ -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()) {

View File

@ -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;

View File

@ -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())

View File

@ -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]

View File

@ -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"