1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-07-08 05:48:09 +02:00

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
This commit is contained in:
Elias Steurer 2023-12-21 13:18:23 +01:00
parent 70e9b48abf
commit 2626226618
7 changed files with 11 additions and 93 deletions

View File

@ -206,9 +206,6 @@ public slots:
emit isConnectedChanged(m_isConnected);
}
private:
bool exportGodotProject();
private:
const std::shared_ptr<GlobalVariables> m_globalVariables;
std::unique_ptr<SDKConnection> m_connection;
@ -219,7 +216,7 @@ private:
QVector<int> 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;

View File

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

View File

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

View File

@ -46,7 +46,7 @@ ScreenPlayWidget::ScreenPlayWidget(
m_projectSettingsListModel.init(type, projectSettingsListModelProperties);
m_appArgumentsList = QStringList {
"--path",
"--projectpath",
m_absolutePath,
"--appID",
m_appID,

View File

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

View File

@ -43,7 +43,6 @@ int main(int argc, char* argv[])
QCoreApplication::setApplicationVersion("1.0");
std::unique_ptr<const ScreenPlayUtil::LoggingHandler> logging;
std::unique_ptr<BaseWindow> window;
const auto platformName = QGuiApplication::platformName();
#if defined(Q_OS_WIN)
window = std::make_unique<WinWindow>();
@ -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");

View File

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