diff --git a/interface/src/ui/AvatarCertifyBanner.cpp b/interface/src/ui/AvatarCertifyBanner.cpp new file mode 100644 index 0000000000..6099f40c94 --- /dev/null +++ b/interface/src/ui/AvatarCertifyBanner.cpp @@ -0,0 +1,71 @@ +// +// AvatarCertifyBanner.h +// interface/src/ui +// +// Created by Simon Walton, April 2019 +// Copyright 2019 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 + +#include "OffscreenQmlElement.h" +#include "EntityTreeRenderer.h" +#include "AvatarCertifyBanner.h" + +static const QUrl AVATAR_THEFT_DIALOG = PathUtils::qmlUrl("AvatarTheftSettings.qml"); +static const QUrl AVATAR_THEFT_BANNER_IMAGE = PathUtils::resourcesUrl("images/AvatarTheftBanner.png"); + +AvatarCertifyBanner::AvatarCertifyBanner(QQuickItem* parent) { + +} + +AvatarCertifyBanner::~AvatarCertifyBanner() +{ } + +void AvatarCertifyBanner::show(const QUuid& avatarID, int jointIndex) { + if (!_active) { + auto entityTreeRenderer = DependencyManager::get(); + EntityTreePointer entityTree = entityTreeRenderer->getTree(); + if (!entityTree) { + return; + } + glm::vec3 position { 0.0f, 0.0f, -0.7f }; + EntityItemProperties entityProperties; + entityProperties.setType(EntityTypes::Image); + entityProperties.setImageURL(AVATAR_THEFT_BANNER_IMAGE.toString()); + entityProperties.setName("hifi-avatar-theft-banner"); + entityProperties.setParentID(avatarID); + entityProperties.setParentJointIndex(CAMERA_MATRIX_INDEX); + entityProperties.setLocalPosition(position); + entityProperties.setDimensions({ 1.0f, 1.0f, 0.3f }); + entityProperties.setRenderLayer(RenderLayer::WORLD); + entityProperties.getGrab().setGrabbable(false); + entityProperties.setVisible(true); + + entityTree->withWriteLock([&] { + auto entityTreeItem = entityTree->addEntity(_bannerID, entityProperties); + entityTreeItem->setLocalPosition(position); // ?! + }); + + _active = true; + } +} + +void AvatarCertifyBanner::clear() { + if (_active) { + auto entityTreeRenderer = DependencyManager::get(); + EntityTreePointer entityTree = entityTreeRenderer->getTree(); + if (!entityTree) { + return; + } + + entityTree->withWriteLock([&] { + entityTree->deleteEntity(_bannerID); + }); + + _active = false; + } +} diff --git a/interface/src/ui/AvatarCertifyBanner.h b/interface/src/ui/AvatarCertifyBanner.h new file mode 100644 index 0000000000..4bc4f30653 --- /dev/null +++ b/interface/src/ui/AvatarCertifyBanner.h @@ -0,0 +1,29 @@ +// +// AvatarCertifyBanner.h +// interface/src/ui +// +// Created by Simon Walton, April 2019 +// Copyright 2019 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 +// + +#ifndef hifi_AvatarCertifyBanner_h +#define hifi_AvatarCertifyBanner_h + +class AvatarCertifyBanner : QObject { + Q_OBJECT + HIFI_QML_DECL +public: + AvatarCertifyBanner(QQuickItem* parent = nullptr); + ~AvatarCertifyBanner(); + void show(const QUuid& avatarID, int jointIndex); + void clear(); + +private: + const EntityItemID _bannerID { QUuid::createUuid() }; + bool _active { false }; +}; + +#endif // hifi_AvatarCertifyBanner_h