mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-09-18 16:32:33 +02:00
Add basic Godot wizard
This commit is contained in:
parent
c9498b366e
commit
33f744e0f4
@ -73,11 +73,14 @@ set(QML
|
||||
qml/Create/Wizards/ImportWebm/ImportWebmConvert.qml
|
||||
qml/Create/Wizards/ImportWebm/ImportWebmInit.qml
|
||||
qml/Create/Wizards/QMLWallpaper.qml
|
||||
qml/Create/Wizards/GodotWallpaper.qml
|
||||
qml/Create/Wizards/QMLWidget.qml
|
||||
qml/Create/Wizards/WebsiteWallpaper.qml
|
||||
qml/Create/Wizards/WizardPage.qml
|
||||
qml/Create/WizardsFiles/QMLWallpaperMain.qml
|
||||
qml/Create/WizardsFiles/QMLWidgetMain.qml
|
||||
qml/Create/WizardsFiles/Godot_v5/project.godot
|
||||
qml/Create/WizardsFiles/Godot_v5/wallpaper.tscn
|
||||
qml/Installed/Installed.qml
|
||||
qml/Installed/InstalledNavigation.qml
|
||||
qml/Installed/InstalledWelcomeScreen.qml
|
||||
|
@ -82,6 +82,15 @@ public slots:
|
||||
const QString& previewThumbnail,
|
||||
const QVector<QString>& tags);
|
||||
|
||||
|
||||
void createGodotWallpaper(
|
||||
const QString& title,
|
||||
const QString& licenseName,
|
||||
const QString& licenseFile,
|
||||
const QString& createdBy,
|
||||
const QString& previewThumbnail,
|
||||
const QVector<QString>& tags);
|
||||
|
||||
void createGifWallpaper(
|
||||
const QString& title,
|
||||
const QString& licenseName,
|
||||
|
@ -87,6 +87,14 @@ Rectangle {
|
||||
objectName: ""
|
||||
}
|
||||
|
||||
ListElement {
|
||||
headline: qsTr("Godot Wallpaper")
|
||||
source: "qrc:/qml/ScreenPlayApp/qml/Create/Wizards/GodotWallpaper.qml"
|
||||
category: "Code Wallpaper"
|
||||
objectName: ""
|
||||
}
|
||||
|
||||
|
||||
ListElement {
|
||||
headline: qsTr("QML Wallpaper")
|
||||
source: "qrc:/qml/ScreenPlayApp/qml/Create/Wizards/QMLWallpaper.qml"
|
||||
|
101
ScreenPlay/qml/Create/Wizards/GodotWallpaper.qml
Normal file
101
ScreenPlay/qml/Create/Wizards/GodotWallpaper.qml
Normal file
@ -0,0 +1,101 @@
|
||||
import QtQuick
|
||||
import Qt5Compat.GraphicalEffects
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Controls.Material
|
||||
import QtQuick.Layouts
|
||||
import ScreenPlayApp
|
||||
import ScreenPlay
|
||||
import ScreenPlay.Create
|
||||
import ScreenPlayUtil as Util
|
||||
|
||||
WizardPage {
|
||||
id: root
|
||||
|
||||
sourceComponent: ColumnLayout {
|
||||
id: rightWrapper
|
||||
|
||||
function create() {
|
||||
App.wizards.createGodotWallpaper(tfTitle.text, cbLicense.name, cbLicense.licenseFile, tfCreatedBy.text, previewSelector.imageSource, tagSelector.getTags());
|
||||
}
|
||||
|
||||
spacing: 10
|
||||
|
||||
anchors {
|
||||
top: parent.top
|
||||
right: parent.right
|
||||
left: parent.left
|
||||
}
|
||||
|
||||
Util.Headline {
|
||||
text: qsTr("Create a Godot Wallpaper")
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Util.HeadlineSection {
|
||||
text: qsTr("General")
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
spacing: 20
|
||||
|
||||
Util.TextField {
|
||||
id: tfTitle
|
||||
|
||||
Layout.fillWidth: true
|
||||
placeholderText: qsTr("Wallpaper name")
|
||||
required: true
|
||||
onTextChanged: root.ready = text.length >= 1
|
||||
}
|
||||
|
||||
Util.TextField {
|
||||
id: tfCreatedBy
|
||||
|
||||
Layout.fillWidth: true
|
||||
placeholderText: qsTr("Created By")
|
||||
}
|
||||
}
|
||||
|
||||
Util.TextField {
|
||||
id: tfDescription
|
||||
|
||||
Layout.fillWidth: true
|
||||
placeholderText: qsTr("Description")
|
||||
}
|
||||
|
||||
Item {
|
||||
height: 30
|
||||
}
|
||||
|
||||
Util.HeadlineSection {
|
||||
text: qsTr("License & Tags")
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
spacing: 20
|
||||
|
||||
Util.LicenseSelector {
|
||||
id: cbLicense
|
||||
}
|
||||
|
||||
Util.TagSelector {
|
||||
id: tagSelector
|
||||
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
height: 30
|
||||
}
|
||||
|
||||
Util.HeadlineSection {
|
||||
text: qsTr("Preview Image")
|
||||
}
|
||||
|
||||
Util.ImageSelector {
|
||||
id: previewSelector
|
||||
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
}
|
15
ScreenPlay/qml/Create/WizardsFiles/Godot_v5/project.godot
Normal file
15
ScreenPlay/qml/Create/WizardsFiles/Godot_v5/project.godot
Normal file
@ -0,0 +1,15 @@
|
||||
; Engine configuration file.
|
||||
; It's best edited using the editor UI and not directly,
|
||||
; since the parameters that go here are not all obvious.
|
||||
;
|
||||
; Format:
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=5
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Test"
|
||||
run/main_scene="res://wallpaper.tscn"
|
||||
config/features=PackedStringArray("4.2", "Forward Plus")
|
16
ScreenPlay/qml/Create/WizardsFiles/Godot_v5/wallpaper.tscn
Normal file
16
ScreenPlay/qml/Create/WizardsFiles/Godot_v5/wallpaper.tscn
Normal file
@ -0,0 +1,16 @@
|
||||
[gd_scene format=3 uid="uid://d105uliklnkd5"]
|
||||
|
||||
[node name="Node3D" type="Node3D"]
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 5)
|
||||
|
||||
[node name="CSGBox3D" type="CSGBox3D" parent="."]
|
||||
transform = Transform3D(0.707107, -0.5, -0.5, 0, 0.707107, -0.707107, 0.707107, 0.5, 0.5, 0, 0, 0)
|
||||
|
||||
[node name="OmniLight3D" type="OmniLight3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.41283, 1.52646)
|
||||
|
||||
[node name="Label3D" type="Label3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.874896, 0.37249)
|
||||
text = "Godot Wallpaper"
|
@ -289,6 +289,73 @@ void Wizards::createQMLWallpaper(
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\brief .
|
||||
*/
|
||||
void Wizards::createGodotWallpaper(
|
||||
const QString& title,
|
||||
const QString& licenseName,
|
||||
const QString& licenseFile,
|
||||
const QString& createdBy,
|
||||
const QString& previewThumbnail,
|
||||
const QVector<QString>& tags)
|
||||
{
|
||||
if (m_wizardFuture.isRunning()) {
|
||||
qWarning() << "Another wizard is already running! Abort.";
|
||||
return;
|
||||
}
|
||||
|
||||
m_wizardFuture = QtConcurrent::run([=]() {
|
||||
std::optional<QString> folderName = createTemporaryFolder();
|
||||
|
||||
if (!folderName.has_value()) {
|
||||
emit widgetCreationFinished(WizardResult::CreateProjectFolderError);
|
||||
return;
|
||||
}
|
||||
|
||||
const QString workingPath = ScreenPlayUtil::toLocal(m_globalVariables->localStoragePath().toString() + "/" + folderName.value());
|
||||
|
||||
QJsonObject obj;
|
||||
obj.insert("license", licenseName);
|
||||
obj.insert("title", title);
|
||||
obj.insert("createdBy", createdBy);
|
||||
obj.insert("tags", ScreenPlayUtil::fillArray(tags));
|
||||
obj.insert("type", QVariant::fromValue(InstalledType::InstalledType::GodotWallpaper).toString());
|
||||
obj.insert("file", "wallpaper.tscn");
|
||||
|
||||
if (!previewThumbnail.isEmpty()) {
|
||||
if (!Util::copyPreviewThumbnail(obj, previewThumbnail, workingPath)) {
|
||||
emit widgetCreationFinished(WizardResult::CopyPreviewThumbnailError);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Util::writeFileFromQrc(":/qml/ScreenPlayApp/assets/wizards/" + licenseFile, workingPath + "/" + licenseFile)) {
|
||||
qWarning() << "Could not write " << licenseFile;
|
||||
emit widgetCreationFinished(WizardResult::WriteLicenseFileError);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!Util::writeSettings(obj, workingPath + "/project.json")) {
|
||||
emit widgetCreationFinished(WizardResult::WriteProjectFileError);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Util::writeFileFromQrc(":/qml/ScreenPlayApp/qml/Create/WizardsFiles/Godot_v5/project.godot", workingPath + "/project.godot")) {
|
||||
qWarning() << "Could not write main.qml";
|
||||
return;
|
||||
}
|
||||
if (!Util::writeFileFromQrc(":/qml/ScreenPlayApp/qml/Create/WizardsFiles/Godot_v5/wallpaper.tscn", workingPath + "/wallpaper.tscn")) {
|
||||
qWarning() << "Could not write main.qml";
|
||||
return;
|
||||
}
|
||||
|
||||
emit widgetCreationFinished(WizardResult::Ok, workingPath);
|
||||
});
|
||||
}
|
||||
|
||||
void Wizards::createGifWallpaper(
|
||||
const QString& title,
|
||||
const QString& licenseName,
|
||||
|
Loading…
Reference in New Issue
Block a user