overte-thingvellir/interface/src/scripting/SelectionScriptingInterface.h
2017-08-23 16:37:13 -07:00

75 lines
2.6 KiB
C++

// SelectionScriptingInterface.h
// interface/src/scripting
//
// Created by Zach Fox on 2017-08-22.
// Copyright 2017 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_SelectionScriptingInterface_h
#define hifi_SelectionScriptingInterface_h
#include <QtCore/QObject>
#include <QtCore/QMap>
#include <DependencyManager.h>
#include <AbstractViewStateInterface.h>
#include "RenderableEntityItem.h"
#include "ui/overlays/Overlay.h"
#include <avatar/AvatarManager.h>
class GameplayObjects {
public:
GameplayObjects();
std::vector<QUuid> getAvatarIDs() { return _avatarIDs; }
bool addToGameplayObjects(const QUuid& avatarID);
bool removeFromGameplayObjects(const QUuid& avatarID);
std::vector<EntityItemID> getEntityIDs() { return _entityIDs; }
bool addToGameplayObjects(const EntityItemID& entityID);
bool removeFromGameplayObjects(const EntityItemID& entityID);
std::vector<OverlayID> getOverlayIDs() { return _overlayIDs; }
bool addToGameplayObjects(const OverlayID& overlayID);
bool removeFromGameplayObjects(const OverlayID& overlayID);
private:
std::vector<QUuid> _avatarIDs;
std::vector<EntityItemID> _entityIDs;
std::vector<OverlayID> _overlayIDs;
};
class SelectionScriptingInterface : public QObject, public Dependency {
Q_OBJECT
public:
SelectionScriptingInterface(AbstractViewStateInterface* viewState);
Q_INVOKABLE void printList(const QString& listName);
Q_INVOKABLE bool removeListFromMap(const QString& listName);
Q_INVOKABLE bool addToSelectedItemsList(const QString& listName, const QUuid& avatarSessionID);
Q_INVOKABLE bool removeFromSelectedItemsList(const QString& listName, const QUuid& avatarSessionID);
Q_INVOKABLE bool addToSelectedItemsList(const QString& listName, const EntityItemID& entityID);
Q_INVOKABLE bool removeFromSelectedItemsList(const QString& listName, const EntityItemID& entityID);
Q_INVOKABLE bool addToSelectedItemsList(const QString& listName, const OverlayID& overlayID);
Q_INVOKABLE bool removeFromSelectedItemsList(const QString& listName, const OverlayID& overlayID);
private:
AbstractViewStateInterface* _viewState;
QMap<QString, GameplayObjects> _selectedItemsListMap;
template <class T> bool addToGameplayObjects(const QString& listName, T idToAdd);
template <class T> bool removeFromGameplayObjects(const QString& listName, T idToRemove);
void updateRendererSelectedList(const QString& listName);
};
#endif // hifi_SelectionScriptingInterface_h