mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 19:56:44 +02:00
open avatar projects
This commit is contained in:
parent
3943fe2861
commit
c0bd9121fb
6 changed files with 149 additions and 32 deletions
|
@ -7,6 +7,7 @@ import "../controlsUit" 1.0 as HifiControls
|
||||||
import "../stylesUit" 1.0
|
import "../stylesUit" 1.0
|
||||||
import "../windows" as Windows
|
import "../windows" as Windows
|
||||||
import "../dialogs"
|
import "../dialogs"
|
||||||
|
import "avatarPackager"
|
||||||
|
|
||||||
Windows.ScrollingWindow {
|
Windows.ScrollingWindow {
|
||||||
id: root
|
id: root
|
||||||
|
@ -19,35 +20,78 @@ Windows.ScrollingWindow {
|
||||||
destroyOnHidden: true
|
destroyOnHidden: true
|
||||||
implicitWidth: 384; implicitHeight: 640
|
implicitWidth: 384; implicitHeight: 640
|
||||||
minSize: Qt.vector2d(200, 300)
|
minSize: Qt.vector2d(200, 300)
|
||||||
|
|
||||||
|
//HifiConstants { id: hifi }
|
||||||
|
|
||||||
|
AvatarProject {
|
||||||
|
id: avatarProject
|
||||||
|
colorScheme: root.colorScheme
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
id: avatarPackagerMain
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
RalewaySemiBold {
|
RalewaySemiBold {
|
||||||
id: displayNameLabel
|
id: avatarPackagerLabel
|
||||||
size: 24;
|
size: 24;
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.topMargin: 25
|
anchors.topMargin: 25
|
||||||
text: 'Avatar Projects'
|
anchors.bottomMargin: 25
|
||||||
|
text: 'Avatar Packager'
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiControls.Button {
|
HifiControls.Button {
|
||||||
|
id: createProjectButton
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.top: displayNameLabel.bottom
|
anchors.top: avatarPackagerLabel.bottom
|
||||||
text: qsTr("Open Avatar Project")
|
text: qsTr("Create Project")
|
||||||
// color: hifi.buttons.blue
|
|
||||||
colorScheme: root.colorScheme
|
colorScheme: root.colorScheme
|
||||||
height: 30
|
height: 30
|
||||||
onClicked: function() {
|
onClicked: function() {
|
||||||
let avatarProject = AvatarPackagerCore.openAvatarProject();
|
|
||||||
if (avatarProject) {
|
}
|
||||||
console.log("LOAD COMPLETE");
|
}
|
||||||
} else {
|
HifiControls.Button {
|
||||||
console.log("LOAD FAILED");
|
id: openProjectButton
|
||||||
}
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: createProjectButton.bottom
|
||||||
|
text: qsTr("Open Avatar Project")
|
||||||
|
colorScheme: root.colorScheme
|
||||||
|
height: 30
|
||||||
|
onClicked: function() {
|
||||||
|
var avatarProjectsPath = fileDialogHelper.standardPath(/*fileDialogHelper.StandardLocation.DocumentsLocation*/ 1) + "/High Fidelity/Avatar Projects";
|
||||||
|
console.log("path = " + avatarProjectsPath);
|
||||||
|
|
||||||
|
// TODO: make the dialog modal
|
||||||
|
|
||||||
|
var browser = desktop.fileDialog({
|
||||||
|
selectDirectory: false,
|
||||||
|
dir: fileDialogHelper.pathToUrl(avatarProjectsPath),
|
||||||
|
filter: "Avatar Project FST Files (*.fst)",
|
||||||
|
title: "Open Project (.fst)"
|
||||||
|
});
|
||||||
|
|
||||||
|
browser.canceled.connect(function() {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
browser.selectedFile.connect(function(fileUrl) {
|
||||||
|
console.log("FOUND PATH " + fileUrl);
|
||||||
|
let fstFilePath = fileDialogHelper.urlToPath(fileUrl);
|
||||||
|
let avatarProject = AvatarPackagerCore.openAvatarProject(fstFilePath);
|
||||||
|
if (avatarProject) {
|
||||||
|
console.log("LOAD COMPLETE");
|
||||||
|
console.log("file dir = " + AvatarPackagerCore.currentAvatarProject.projectFolderPath);
|
||||||
|
avatarProject.visible = true;
|
||||||
|
avatarPackagerMain.visible = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
import QtQuick 2.6
|
||||||
|
import QtQuick.Controls 2.2
|
||||||
|
import QtQuick.Layouts 1.3
|
||||||
|
import QtGraphicalEffects 1.0
|
||||||
|
|
||||||
|
import "../../controlsUit" 1.0 as HifiControls
|
||||||
|
import "../../stylesUit" 1.0
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: avatarProject
|
||||||
|
|
||||||
|
HifiConstants { id: hifi }
|
||||||
|
|
||||||
|
|
||||||
|
z: 3
|
||||||
|
property int colorScheme;
|
||||||
|
|
||||||
|
visible: false
|
||||||
|
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
|
||||||
|
RalewaySemiBold {
|
||||||
|
id: avatarProjectLabel
|
||||||
|
size: 24;
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.topMargin: 25
|
||||||
|
anchors.bottomMargin: 25
|
||||||
|
text: 'Avatar Project'
|
||||||
|
}
|
||||||
|
HifiControls.Button {
|
||||||
|
id: openFolderButton
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: avatarProjectLabel.bottom
|
||||||
|
text: qsTr("Open Project Folder")
|
||||||
|
colorScheme: avatarProject.colorScheme
|
||||||
|
height: 30
|
||||||
|
onClicked: function() {
|
||||||
|
fileDialogHelper.openDirectory(AvatarPackagerCore.currentAvatarProject.projectFolderPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HifiControls.Button {
|
||||||
|
id: uploadButton
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: openFolderButton.bottom
|
||||||
|
text: qsTr("Upload")
|
||||||
|
color: hifi.buttons.blue
|
||||||
|
colorScheme: avatarProject.colorScheme
|
||||||
|
height: 30
|
||||||
|
onClicked: function() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,11 +12,9 @@
|
||||||
#include "AvatarPackager.h"
|
#include "AvatarPackager.h"
|
||||||
|
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QStandardPaths>
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#include <OffscreenUi.h>
|
#include <OffscreenUi.h>
|
||||||
#include "ModelSelector.h"
|
|
||||||
|
|
||||||
bool AvatarPackager::open() {
|
bool AvatarPackager::open() {
|
||||||
static const QUrl url{ "hifi/AvatarPackager.qml" };
|
static const QUrl url{ "hifi/AvatarPackager.qml" };
|
||||||
|
@ -28,17 +26,10 @@ bool AvatarPackager::open() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject* AvatarPackager::openAvatarProject() {
|
QObject* AvatarPackager::openAvatarProject(QString avatarProjectFSTPath) {
|
||||||
// TODO: use QML file browser here, could handle this on QML side instead
|
if (_currentAvatarProject) {
|
||||||
static Setting::Handle<QString> lastModelBrowseLocation("LastModelBrowseLocation",
|
_currentAvatarProject->deleteLater();
|
||||||
QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
|
|
||||||
const QString filename = QFileDialog::getOpenFileName(nullptr, "Select your model file ...",
|
|
||||||
lastModelBrowseLocation.get(),
|
|
||||||
"Model files (*.fst *.fbx)");
|
|
||||||
QFileInfo fileInfo(filename);
|
|
||||||
|
|
||||||
if (fileInfo.isFile() && fileInfo.completeSuffix().contains(QRegExp("fst|fbx|FST|FBX"))) {
|
|
||||||
return AvatarProject::openAvatarProject(fileInfo.absoluteFilePath());
|
|
||||||
}
|
}
|
||||||
return nullptr;
|
_currentAvatarProject = AvatarProject::openAvatarProject(avatarProjectFSTPath);
|
||||||
|
return _currentAvatarProject;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,15 +21,16 @@
|
||||||
class AvatarPackager : public QObject, public Dependency {
|
class AvatarPackager : public QObject, public Dependency {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
SINGLETON_DEPENDENCY
|
SINGLETON_DEPENDENCY
|
||||||
|
Q_PROPERTY(QObject* currentAvatarProject READ getAvatarProject)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool open();
|
bool open();
|
||||||
|
|
||||||
Q_INVOKABLE void openAvatarProjectWithoutReturnType() {
|
Q_INVOKABLE QObject* openAvatarProject(QString avatarProjectFSTPath);
|
||||||
openAvatarProject();
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_INVOKABLE QObject* openAvatarProject();
|
private:
|
||||||
|
Q_INVOKABLE AvatarProject* getAvatarProject() const { return _currentAvatarProject; };
|
||||||
|
AvatarProject* _currentAvatarProject { nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AvatarPackager_h
|
#endif // hifi_AvatarPackager_h
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// AvatarProject.h
|
// AvatarProject.cpp
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Created by Thijs Wenker on 12/7/2018
|
// Created by Thijs Wenker on 12/7/2018
|
||||||
|
|
|
@ -14,8 +14,15 @@
|
||||||
#define hifi_AvatarProject_h
|
#define hifi_AvatarProject_h
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
class AvatarProject : public QObject {
|
class AvatarProject : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString projectFolderPath READ getProjectPath)
|
||||||
|
Q_PROPERTY(QString projectFSTPath READ getFSTPath)
|
||||||
|
Q_PROPERTY(QString projectFBXPath READ getFBXPath)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Q_INVOKABLE bool write() {
|
Q_INVOKABLE bool write() {
|
||||||
// Write FST here
|
// Write FST here
|
||||||
|
@ -33,13 +40,28 @@ public:
|
||||||
static AvatarProject* openAvatarProject(QString path);
|
static AvatarProject* openAvatarProject(QString path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AvatarProject(QString fstPath) {
|
AvatarProject(QString fstPath) :
|
||||||
|
_fstPath(fstPath) {
|
||||||
|
auto fileInfo = QFileInfo(_fstPath);
|
||||||
|
_projectPath = fileInfo.absoluteDir().absolutePath();
|
||||||
|
|
||||||
|
_fstPath = _projectPath + "TemporaryFBX.fbx";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~AvatarProject() {
|
~AvatarProject() {
|
||||||
// TODO: cleanup FST / AvatarProjectUploader etc.
|
// TODO: cleanup FST / AvatarProjectUploader etc.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_INVOKABLE QString getProjectPath() const { return _projectPath; }
|
||||||
|
Q_INVOKABLE QString getFSTPath() const { return _fstPath; }
|
||||||
|
Q_INVOKABLE QString getFBXPath() const { return _fbxPath; }
|
||||||
|
|
||||||
|
QString _projectPath;
|
||||||
|
QString _fstPath;
|
||||||
|
// TODO: handle this in the FST Class
|
||||||
|
QString _fbxPath;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AvatarProject_h
|
#endif // hifi_AvatarProject_h
|
||||||
|
|
Loading…
Reference in a new issue