avatar packager initial

This commit is contained in:
Thijs Wenker 2018-12-10 21:29:03 +01:00
parent da296cf45e
commit 3943fe2861
8 changed files with 216 additions and 0 deletions

View file

@ -0,0 +1,54 @@
import QtQuick 2.6
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtQml.Models 2.1
import QtGraphicalEffects 1.0
import "../controlsUit" 1.0 as HifiControls
import "../stylesUit" 1.0
import "../windows" as Windows
import "../dialogs"
Windows.ScrollingWindow {
id: root
objectName: "AvatarPackager"
width: 480
height: 706
title: "Avatar Packager"
resizable: true
opacity: parent.opacity
destroyOnHidden: true
implicitWidth: 384; implicitHeight: 640
minSize: Qt.vector2d(200, 300)
Rectangle {
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
RalewaySemiBold {
id: displayNameLabel
size: 24;
anchors.left: parent.left
anchors.top: parent.top
anchors.topMargin: 25
text: 'Avatar Projects'
}
HifiControls.Button {
anchors.left: parent.left
anchors.right: parent.right
anchors.top: displayNameLabel.bottom
text: qsTr("Open Avatar Project")
// color: hifi.buttons.blue
colorScheme: root.colorScheme
height: 30
onClicked: function() {
let avatarProject = AvatarPackagerCore.openAvatarProject();
if (avatarProject) {
console.log("LOAD COMPLETE");
} else {
console.log("LOAD FAILED");
}
}
}
}
}

View file

@ -158,6 +158,7 @@
#include "audio/AudioScope.h"
#include "avatar/AvatarManager.h"
#include "avatar/MyHead.h"
#include "avatar/AvatarPackager.h"
#include "CrashRecoveryHandler.h"
#include "CrashHandler.h"
#include "devices/DdeFaceTracker.h"
@ -912,6 +913,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
DependencyManager::set<ResourceRequestObserver>();
DependencyManager::set<Keyboard>();
DependencyManager::set<KeyboardScriptingInterface>();
DependencyManager::set<AvatarPackager>();
return previousSessionCrashed;
}
@ -2639,6 +2641,7 @@ void Application::cleanupBeforeQuit() {
DependencyManager::destroy<PickManager>();
DependencyManager::destroy<KeyboardScriptingInterface>();
DependencyManager::destroy<Keyboard>();
DependencyManager::destroy<AvatarPackager>();
qCDebug(interfaceapp) << "Application::cleanupBeforeQuit() complete";
}

View file

@ -35,6 +35,7 @@
#include "assets/ATPAssetMigrator.h"
#include "audio/AudioScope.h"
#include "avatar/AvatarManager.h"
#include "avatar/AvatarPackager.h"
#include "AvatarBookmarks.h"
#include "devices/DdeFaceTracker.h"
#include "MainWindow.h"
@ -145,6 +146,12 @@ Menu::Menu() {
addActionToQMenuAndActionHash(editMenu, MenuOption::PackageModel, 0,
qApp, SLOT(packageModel()));
// Edit > Avatar Packager
action = addActionToQMenuAndActionHash(editMenu, MenuOption::AvatarPackager);
connect(action, &QAction::triggered, [] {
DependencyManager::get<AvatarPackager>()->open();
});
// Edit > Reload All Content
addActionToQMenuAndActionHash(editMenu, MenuOption::ReloadContent, 0, qApp, SLOT(reloadResourceCaches()));

View file

@ -46,6 +46,7 @@ namespace MenuOption {
const QString AutoMuteAudio = "Auto Mute Microphone";
const QString AvatarReceiveStats = "Show Receive Stats";
const QString AvatarBookmarks = "Avatar Bookmarks";
const QString AvatarPackager = "Avatar Packager";
const QString Back = "Back";
const QString BinaryEyelidControl = "Binary Eyelid Control";
const QString BookmarkAvatar = "Bookmark Avatar";

View file

@ -0,0 +1,44 @@
//
// AvatarPackager.cpp
//
//
// Created by Thijs Wenker on 12/6/2018
// Copyright 2018 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "AvatarPackager.h"
#include <QQmlContext>
#include <QStandardPaths>
#include <QUrl>
#include <OffscreenUi.h>
#include "ModelSelector.h"
bool AvatarPackager::open() {
static const QUrl url{ "hifi/AvatarPackager.qml" };
const auto packageModelDialogCreated = [=](QQmlContext* context, QObject* newObject) {
context->setContextProperty("AvatarPackagerCore", this);
};
DependencyManager::get<OffscreenUi>()->show(url, "AvatarPackager", packageModelDialogCreated);
return true;
}
QObject* AvatarPackager::openAvatarProject() {
// TODO: use QML file browser here, could handle this on QML side instead
static Setting::Handle<QString> lastModelBrowseLocation("LastModelBrowseLocation",
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;
}

View file

@ -0,0 +1,35 @@
//
// AvatarPackager.h
//
//
// Created by Thijs Wenker on 12/6/2018
// Copyright 2018 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#pragma once
#ifndef hifi_AvatarPackager_h
#define hifi_AvatarPackager_h
#include <QObject>
#include <DependencyManager.h>
#include "avatar/AvatarProject.h"
class AvatarPackager : public QObject, public Dependency {
Q_OBJECT
SINGLETON_DEPENDENCY
public:
bool open();
Q_INVOKABLE void openAvatarProjectWithoutReturnType() {
openAvatarProject();
}
Q_INVOKABLE QObject* openAvatarProject();
};
#endif // hifi_AvatarPackager_h

View file

@ -0,0 +1,27 @@
//
// AvatarProject.h
//
//
// Created by Thijs Wenker on 12/7/2018
// Copyright 2018 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "AvatarProject.h"
AvatarProject* AvatarProject::openAvatarProject(QString path) {
const auto pathToLower = path.toLower();
if (pathToLower.endsWith(".fst")) {
// TODO: do we open FSTs from any path?
return new AvatarProject(path);
}
if (pathToLower.endsWith(".fbx")) {
// TODO: Create FST here:
}
return nullptr;
}

View file

@ -0,0 +1,45 @@
//
// AvatarProject.h
//
//
// Created by Thijs Wenker on 12/7/2018
// Copyright 2018 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#pragma once
#ifndef hifi_AvatarProject_h
#define hifi_AvatarProject_h
#include <QObject>
class AvatarProject : public QObject {
public:
Q_INVOKABLE bool write() {
// Write FST here
return false;
}
Q_INVOKABLE QObject* upload() {
// TODO: create new AvatarProjectUploader here, launch it and return it for status tracking in QML
return nullptr;
}
/**
* returns the AvatarProject or a nullptr on failure.
*/
static AvatarProject* openAvatarProject(QString path);
private:
AvatarProject(QString fstPath) {
}
~AvatarProject() {
// TODO: cleanup FST / AvatarProjectUploader etc.
}
};
#endif // hifi_AvatarProject_h