mirror of
https://github.com/overte-org/overte.git
synced 2025-08-12 12:34:11 +02:00
Merge pull request #10997 from davidkelly/dk/openMarketplace
Open marketplace when we know the marketplaceID of an entity
This commit is contained in:
commit
d9207c7fdf
2 changed files with 28 additions and 1 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue