Just gotta test

This commit is contained in:
Zach Fox 2017-08-24 11:07:58 -07:00
parent e834e9d7a7
commit d370eeea2f
2 changed files with 14 additions and 12 deletions

View file

@ -17,6 +17,7 @@ GameplayObjects::GameplayObjects() {
} }
bool GameplayObjects::addToGameplayObjects(const QUuid& avatarID) { bool GameplayObjects::addToGameplayObjects(const QUuid& avatarID) {
containsData = true;
_avatarIDs.push_back(avatarID); _avatarIDs.push_back(avatarID);
return true; return true;
} }
@ -26,6 +27,7 @@ bool GameplayObjects::removeFromGameplayObjects(const QUuid& avatarID) {
} }
bool GameplayObjects::addToGameplayObjects(const EntityItemID& entityID) { bool GameplayObjects::addToGameplayObjects(const EntityItemID& entityID) {
containsData = true;
_entityIDs.push_back(entityID); _entityIDs.push_back(entityID);
return true; return true;
} }
@ -35,6 +37,7 @@ bool GameplayObjects::removeFromGameplayObjects(const EntityItemID& entityID) {
} }
bool GameplayObjects::addToGameplayObjects(const OverlayID& overlayID) { bool GameplayObjects::addToGameplayObjects(const OverlayID& overlayID) {
containsData = true;
_overlayIDs.push_back(overlayID); _overlayIDs.push_back(overlayID);
return true; return true;
} }
@ -96,12 +99,8 @@ template <class T> bool SelectionScriptingInterface::removeFromGameplayObjects(c
// END HANDLING GENERIC ITEMS // END HANDLING GENERIC ITEMS
// //
GameplayObjects* SelectionScriptingInterface::getList(const QString& listName) { GameplayObjects SelectionScriptingInterface::getList(const QString& listName) {
if (_selectedItemsListMap.contains(listName)) { return _selectedItemsListMap.value(listName);
return _selectedItemsListMap.value(listName);
} else {
return NULL;
}
} }
void SelectionScriptingInterface::printList(const QString& listName) { void SelectionScriptingInterface::printList(const QString& listName) {
@ -132,7 +131,7 @@ void SelectionScriptingInterface::printList(const QString& listName) {
bool SelectionScriptingInterface::removeListFromMap(const QString& listName) { bool SelectionScriptingInterface::removeListFromMap(const QString& listName) {
if (_selectedItemsListMap.remove(listName)) { if (_selectedItemsListMap.remove(listName)) {
//updateRendererSelectedList(listName); emit selectedItemsListChanged(listName);
return true; return true;
} else { } else {
return false; return false;
@ -156,16 +155,16 @@ void SelectionToSceneHandler::selectedItemsListChanged(const QString& listName)
void SelectionToSceneHandler::updateSceneFromSelectedList() { void SelectionToSceneHandler::updateSceneFromSelectedList() {
if (_mainScene) { if (_mainScene) {
GameplayObjects* thisList = &DependencyManager::get<SelectionScriptingInterface>()->getList(_listName); GameplayObjects thisList = DependencyManager::get<SelectionScriptingInterface>()->getList(_listName);
render::Transaction transaction; render::Transaction transaction;
if (thisList != NULL) { if (thisList.getContainsData()) {
render::ItemIDs finalList; render::ItemIDs finalList;
render::ItemID currentID; render::ItemID currentID;
auto entityTree = qApp->getEntities()->getTree(); auto entityTree = qApp->getEntities()->getTree();
auto& overlays = qApp->getOverlays(); auto& overlays = qApp->getOverlays();
for (QUuid& currentAvatarID : thisList->getAvatarIDs()) { for (QUuid& currentAvatarID : thisList.getAvatarIDs()) {
auto avatar = std::static_pointer_cast<Avatar>(DependencyManager::get<AvatarManager>()->getAvatarBySessionID(currentAvatarID)); auto avatar = std::static_pointer_cast<Avatar>(DependencyManager::get<AvatarManager>()->getAvatarBySessionID(currentAvatarID));
if (avatar) { if (avatar) {
currentID = avatar->getRenderItemID(); currentID = avatar->getRenderItemID();
@ -175,7 +174,7 @@ void SelectionToSceneHandler::updateSceneFromSelectedList() {
} }
} }
for (EntityItemID& currentEntityID : thisList->getEntityIDs()) { for (EntityItemID& currentEntityID : thisList.getEntityIDs()) {
entityTree->withReadLock([&] { entityTree->withReadLock([&] {
auto entityItem = entityTree->findEntityByEntityItemID(currentEntityID); auto entityItem = entityTree->findEntityByEntityItemID(currentEntityID);
if (entityItem != NULL) { if (entityItem != NULL) {
@ -190,7 +189,7 @@ void SelectionToSceneHandler::updateSceneFromSelectedList() {
}); });
} }
for (OverlayID& currentOverlayID : thisList->getOverlayIDs()) { for (OverlayID& currentOverlayID : thisList.getOverlayIDs()) {
auto overlay = overlays.getOverlay(currentOverlayID); auto overlay = overlays.getOverlay(currentOverlayID);
if (overlay != NULL) { if (overlay != NULL) {
currentID = overlay->getRenderItemID(); currentID = overlay->getRenderItemID();

View file

@ -26,6 +26,8 @@ class GameplayObjects {
public: public:
GameplayObjects(); GameplayObjects();
bool getContainsData() { return containsData; }
std::vector<QUuid> getAvatarIDs() { return _avatarIDs; } std::vector<QUuid> getAvatarIDs() { return _avatarIDs; }
bool addToGameplayObjects(const QUuid& avatarID); bool addToGameplayObjects(const QUuid& avatarID);
bool removeFromGameplayObjects(const QUuid& avatarID); bool removeFromGameplayObjects(const QUuid& avatarID);
@ -39,6 +41,7 @@ public:
bool removeFromGameplayObjects(const OverlayID& overlayID); bool removeFromGameplayObjects(const OverlayID& overlayID);
private: private:
bool containsData { false };
std::vector<QUuid> _avatarIDs; std::vector<QUuid> _avatarIDs;
std::vector<EntityItemID> _entityIDs; std::vector<EntityItemID> _entityIDs;
std::vector<OverlayID> _overlayIDs; std::vector<OverlayID> _overlayIDs;