From 2626226618780c4f4916bf8b3e8b9c214a7bb12c Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Thu, 21 Dec 2023 13:18:23 +0100 Subject: [PATCH] Fix reserved argument path Looks like this gets swallen in godot, so lets just use projectpath Remove duplicate godot export function that now lives in util --- .../public/ScreenPlay/screenplaywallpaper.h | 5 +- .../inc/public/ScreenPlay/screenplaywidget.h | 2 +- ScreenPlay/src/screenplaywallpaper.cpp | 80 +------------------ ScreenPlay/src/screenplaywidget.cpp | 2 +- .../Godot/ScreenPlayGodot/main.gd | 6 +- ScreenPlayWallpaper/main.cpp | 5 +- ScreenPlayWidget/main.cpp | 4 +- 7 files changed, 11 insertions(+), 93 deletions(-) diff --git a/ScreenPlay/inc/public/ScreenPlay/screenplaywallpaper.h b/ScreenPlay/inc/public/ScreenPlay/screenplaywallpaper.h index 37bf7344..e658f987 100644 --- a/ScreenPlay/inc/public/ScreenPlay/screenplaywallpaper.h +++ b/ScreenPlay/inc/public/ScreenPlay/screenplaywallpaper.h @@ -206,9 +206,6 @@ public slots: emit isConnectedChanged(m_isConnected); } -private: - bool exportGodotProject(); - private: const std::shared_ptr m_globalVariables; std::unique_ptr m_connection; @@ -219,7 +216,7 @@ private: QVector m_screenNumber; QProcess m_process; QString m_previewImage; - ContentTypes::InstalledType m_type; + ContentTypes::InstalledType m_type { ContentTypes::InstalledType::Unknown }; Video::FillMode m_fillMode; QString m_appID; QString m_absolutePath; diff --git a/ScreenPlay/inc/public/ScreenPlay/screenplaywidget.h b/ScreenPlay/inc/public/ScreenPlay/screenplaywidget.h index 0d0cdcd0..bc482c82 100644 --- a/ScreenPlay/inc/public/ScreenPlay/screenplaywidget.h +++ b/ScreenPlay/inc/public/ScreenPlay/screenplaywidget.h @@ -123,7 +123,7 @@ private: QString m_previewImage; QString m_appID; QPoint m_position; - ContentTypes::InstalledType m_type; + ContentTypes::InstalledType m_type { ContentTypes::InstalledType::Unknown }; QString m_absolutePath; QTimer m_pingAliveTimer; QStringList m_appArgumentsList; diff --git a/ScreenPlay/src/screenplaywallpaper.cpp b/ScreenPlay/src/screenplaywallpaper.cpp index 14a9212b..c27a14df 100644 --- a/ScreenPlay/src/screenplaywallpaper.cpp +++ b/ScreenPlay/src/screenplaywallpaper.cpp @@ -87,7 +87,7 @@ ScreenPlayWallpaper::ScreenPlayWallpaper( m_appArgumentsList = QStringList { "--screens", screens, - "--path", m_absolutePath, + "--projectpath", m_absolutePath, "--appID", m_appID, "--volume", QString::number(static_cast(volume)), "--fillmode", QVariant::fromValue(fillMode).toString(), @@ -110,10 +110,6 @@ ScreenPlayWallpaper::ScreenPlayWallpaper( bool ScreenPlayWallpaper::start() { - if (m_type == ContentTypes::InstalledType::GodotWallpaper) { - if (!exportGodotProject()) - return false; - } m_process.setArguments(m_appArgumentsList); if (m_type == ContentTypes::InstalledType::GodotWallpaper) { @@ -308,80 +304,6 @@ bool ScreenPlayWallpaper::replace( emit requestSave(); return success; } - -/*! - \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", packageFileName }; - - // Create QProcess instance to run the command - QProcess process; - - // Set the working directory to the given absolute path - 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; - } - - // Capture the standard output and error - QString stdoutString = process.readAllStandardOutput(); - QString stderrString = process.readAllStandardError(); - - // If you want to print the output to the console: - if (!stdoutString.isEmpty()) - qDebug() << "Output:" << stdoutString; - if (!stderrString.isEmpty()) - qDebug() << "Error:" << stderrString; - - // Check for errors - if (process.exitStatus() != QProcess::NormalExit || process.exitCode() != 0) { - qCritical() << "Failed to export Godot project. Error:" << process.errorString(); - return false; - } - - // Check if the project.zip file was created - QString zipPath = QDir(m_absolutePath).filePath(packageFileName); - if (!QFile::exists(zipPath)) { - qCritical() << "Expected export file (" << packageFileName << ") was not created."; - return false; - } - - // Optional: Verify if the .zip file is valid - // (A complete verification would involve extracting the file and checking its contents, - // but for simplicity, we're just checking its size here) - QFileInfo zipInfo(zipPath); - if (zipInfo.size() <= 0) { - qCritical() << "The exported " << packageFileName << " file seems to be invalid."; - return false; - } - - return true; -} } #include "moc_screenplaywallpaper.cpp" diff --git a/ScreenPlay/src/screenplaywidget.cpp b/ScreenPlay/src/screenplaywidget.cpp index 6068ab0a..57878872 100644 --- a/ScreenPlay/src/screenplaywidget.cpp +++ b/ScreenPlay/src/screenplaywidget.cpp @@ -46,7 +46,7 @@ ScreenPlayWidget::ScreenPlayWidget( m_projectSettingsListModel.init(type, projectSettingsListModelProperties); m_appArgumentsList = QStringList { - "--path", + "--projectpath", m_absolutePath, "--appID", m_appID, diff --git a/ScreenPlayWallpaper/Godot/ScreenPlayGodot/main.gd b/ScreenPlayWallpaper/Godot/ScreenPlayGodot/main.gd index a4feba6c..d7a77e8a 100644 --- a/ScreenPlayWallpaper/Godot/ScreenPlayGodot/main.gd +++ b/ScreenPlayWallpaper/Godot/ScreenPlayGodot/main.gd @@ -94,7 +94,7 @@ func parse_args(): # Check if only the default argument is provided if args.size() == 1: - args = ["--path", + args = ["--projectpath", #"C:/Code/cpp/ScreenPlay/ScreenPlay/Content/wallpaper_godot_fjord", "C:/Program Files (x86)/Steam/steamapps/workshop/content/672870/2023_12_08_205323", "--appID", "qmz9lq4wglox5DdYaXumVgRSDeZYAUjC", @@ -124,7 +124,7 @@ func parse_args(): i += 1 # Check for all required arguments - var required_args = ["screens", "path", "appID", "volume", "check", "projectPackageFile"] + var required_args = ["screens", "projectpath", "appID", "volume", "check", "projectPackageFile"] for req_arg in required_args: if not arg_dict.has(req_arg): print("Missing argument:", req_arg) @@ -147,7 +147,7 @@ func parse_args(): return false # Assign the values to the respective properties - screen_play_wallpaper.set_projectPath(arg_dict["path"]) + screen_play_wallpaper.set_projectPath(arg_dict["projectpath"]) screen_play_wallpaper.set_appID(arg_dict["appID"]) screen_play_wallpaper.set_volume(float(arg_dict["volume"])) screen_play_wallpaper.set_projectPackageFile(arg_dict["projectPackageFile"]) diff --git a/ScreenPlayWallpaper/main.cpp b/ScreenPlayWallpaper/main.cpp index 1cf6d142..52a644b4 100644 --- a/ScreenPlayWallpaper/main.cpp +++ b/ScreenPlayWallpaper/main.cpp @@ -43,7 +43,6 @@ int main(int argc, char* argv[]) QCoreApplication::setApplicationVersion("1.0"); std::unique_ptr logging; std::unique_ptr window; - const auto platformName = QGuiApplication::platformName(); #if defined(Q_OS_WIN) window = std::make_unique(); @@ -78,7 +77,7 @@ int main(int argc, char* argv[]) QStringList { // Docs: Don't forget that arguments must start with the name of the executable (ignored, though). QGuiApplication::applicationName(), - "--path", projectPath, + "--projectpath", projectPath, "--appID", "qmz9lq4wglox5DdYaXumVgRSDeZYAUjC", "--screens", "{0}", "--volume", "1", @@ -94,7 +93,7 @@ int main(int argc, char* argv[]) parser.addHelpOption(); // Define the command line options - QCommandLineOption pathOption("path", "Set the project path.", "path"); + QCommandLineOption pathOption("projectpath", "Set the project path.", "projectpath"); QCommandLineOption appIDOption("appID", "Set the application ID.", "appID"); QCommandLineOption screensOption("screens", "Set screens parameter.", "screens"); QCommandLineOption volumeOption("volume", "Set volume level.", "volume"); diff --git a/ScreenPlayWidget/main.cpp b/ScreenPlayWidget/main.cpp index 088842d0..7c92f078 100644 --- a/ScreenPlayWidget/main.cpp +++ b/ScreenPlayWidget/main.cpp @@ -68,7 +68,7 @@ int main(int argc, char* argv[]) QStringList { // Docs: Don't forget that arguments must start with the name of the executable (ignored, though). QGuiApplication::applicationName(), - "--path", projectPath, + "--projectpath", projectPath, "--appID", "qmz9lq4wglox5DdYaXumVgRSDeZYAUjC", "--type", type, "--posX", QString::number(center.x()), @@ -81,7 +81,7 @@ int main(int argc, char* argv[]) QCommandLineParser parser; parser.setApplicationDescription("ScreenPlay Widget"); parser.addHelpOption(); - QCommandLineOption pathOption("path", "Project path", "path"); + QCommandLineOption pathOption("projectpath", "Project path", "projectpath"); QCommandLineOption appIDOption("appID", "Application ID", "appid"); QCommandLineOption typeOption("type", "Content type", "type"); QCommandLineOption posXOption("posX", "X position", "positionX");