Merge pull request #10997 from davidkelly/dk/openMarketplace

Open marketplace when we know the marketplaceID of an entity
This commit is contained in:
David Kelly 2017-07-19 15:03:35 -07:00 committed by GitHub
commit d9207c7fdf
2 changed files with 28 additions and 1 deletions

View file

@ -11,6 +11,7 @@
#include "ContextOverlayInterface.h"
#include "Application.h"
#include <EntityTreeRenderer.h>
ContextOverlayInterface::ContextOverlayInterface() {
@ -21,6 +22,9 @@ ContextOverlayInterface::ContextOverlayInterface() {
QLoggingCategory::setFilterRules(QStringLiteral("hifi.context_overlay.debug=false"));
_entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
_hmdScriptingInterface = DependencyManager::get<HMDScriptingInterface>();
_tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
_entityPropertyFlags += PROP_POSITION;
_entityPropertyFlags += PROP_ROTATION;
@ -73,6 +77,24 @@ void ContextOverlayInterface::destroyContextOverlay(const EntityItemID& entityIt
void ContextOverlayInterface::clickContextOverlay(const OverlayID& overlayID, const PointerEvent& event) {
if (overlayID == _contextOverlayID && event.getButton() == PointerEvent::PrimaryButton) {
qCDebug(context_overlay) << "Clicked Context Overlay. Entity ID:" << _currentEntityWithContextOverlay << "Overlay ID:" << overlayID;
openMarketplace();
destroyContextOverlay(_currentEntityWithContextOverlay, PointerEvent());
}
}
static const QString MARKETPLACE_BASE_URL = "http://metaverse.highfidelity.com/marketplace/items/";
void ContextOverlayInterface::openMarketplace() {
// lets open the tablet and go to the current item in
// the marketplace (if the current entity has a
// marketplaceID)
if (!_currentEntityWithContextOverlay.isNull()) {
auto entity = qApp->getEntities()->getTree()->findEntityByID(_currentEntityWithContextOverlay);
if (entity->getMarketplaceID().length() > 0) {
auto tablet = dynamic_cast<TabletProxy*>(_tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
// construct the url to the marketplace item
QString url = MARKETPLACE_BASE_URL + entity->getMarketplaceID();
tablet->gotoWebScreen(url);
_hmdScriptingInterface->openTablet();
}
}
}

View file

@ -18,9 +18,12 @@
#include <DependencyManager.h>
#include <PointerEvent.h>
#include <ui/TabletScriptingInterface.h>
#include "EntityScriptingInterface.h"
#include "ui/overlays/Image3DOverlay.h"
#include "ui/overlays/Overlays.h"
#include "scripting/HMDScriptingInterface.h"
#include "EntityTree.h"
#include "ContextOverlayLogging.h"
@ -34,6 +37,8 @@ class ContextOverlayInterface : public QObject, public Dependency {
Q_PROPERTY(QUuid entityWithContextOverlay READ getCurrentEntityWithContextOverlay WRITE setCurrentEntityWithContextOverlay)
QSharedPointer<EntityScriptingInterface> _entityScriptingInterface;
EntityPropertyFlags _entityPropertyFlags;
QSharedPointer<HMDScriptingInterface> _hmdScriptingInterface;
QSharedPointer<TabletScriptingInterface> _tabletScriptingInterface;
OverlayID _contextOverlayID { UNKNOWN_OVERLAY_ID };
std::shared_ptr<Image3DOverlay> _contextOverlay { nullptr };
public:
@ -51,7 +56,7 @@ public slots:
private:
bool _verboseLogging { true };
QUuid _currentEntityWithContextOverlay{};
void openMarketplace();
};
#endif // hifi_ContextOverlayInterface_h