History

More progress

Zach Fox committed 9 years ago

Commit 52ef0f21 parent 88c24c13 files · +56 −23Browse files

Showing the changes to interface/src/scripting/SelectionScriptingInterface.cpp (1 of 3 files). Show all

Unified · Split

interface/src/scripting/SelectionScriptingInterface.cpp+42−12
@@ -10,6 +10,7 @@ · 9 unmodified lines
10//10//
11 11
12#include "SelectionScriptingInterface.h"12#include "SelectionScriptingInterface.h"
13#include <QDebug>
13#include "Application.h"14#include "Application.h"
14 15
15GameplayObjects::GameplayObjects() {16GameplayObjects::GameplayObjects() {
@@ -49,10 +50,10 @@ SelectionScriptingInterface::SelectionScriptingInterface(AbstractViewStateInterf · 33 unmodified lines
49//50//
50// START HANDLING AVATARS51// START HANDLING AVATARS
51//52//
52bool SelectionScriptingInterface::addToSelectedItemsList(const render::Selection::Name& listName, const QUuid& avatarSessionID) {53bool SelectionScriptingInterface::addToSelectedItemsList(const QString& listName, const QUuid& avatarSessionID) {
53 return addToGameplayObjects(listName, avatarSessionID);54 return addToGameplayObjects(listName, avatarSessionID);
54}55}
55bool SelectionScriptingInterface::removeFromSelectedItemsList(const render::Selection::Name& listName, const QUuid& avatarSessionID) {56bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& listName, const QUuid& avatarSessionID) {
56 return addToGameplayObjects(listName, avatarSessionID);57 return addToGameplayObjects(listName, avatarSessionID);
57}58}
58//59//
@@ -62,10 +63,10 @@ bool SelectionScriptingInterface::removeFromSelectedItemsList(const render::Sele · 3 unmodified lines
62//63//
63// START HANDLING ENTITIES64// START HANDLING ENTITIES
64//65//
65bool SelectionScriptingInterface::addToSelectedItemsList(const render::Selection::Name& listName, const EntityItemID& entityID) {66bool SelectionScriptingInterface::addToSelectedItemsList(const QString& listName, const EntityItemID& entityID) {
66 return addToGameplayObjects(listName, entityID);67 return addToGameplayObjects(listName, entityID);
67}68}
68bool SelectionScriptingInterface::removeFromSelectedItemsList(const render::Selection::Name& listName, const EntityItemID& entityID) {69bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& listName, const EntityItemID& entityID) {
69 return addToGameplayObjects(listName, entityID);70 return addToGameplayObjects(listName, entityID);
70}71}
71//72//
@@ -75,10 +76,10 @@ bool SelectionScriptingInterface::removeFromSelectedItemsList(const render::Sele · 3 unmodified lines
75//76//
76// START HANDLING OVERLAYS77// START HANDLING OVERLAYS
77//78//
78bool SelectionScriptingInterface::addToSelectedItemsList(const render::Selection::Name& listName, const OverlayID& overlayID) {79bool SelectionScriptingInterface::addToSelectedItemsList(const QString& listName, const OverlayID& overlayID) {
79 return addToGameplayObjects(listName, overlayID);80 return addToGameplayObjects(listName, overlayID);
80}81}
81bool SelectionScriptingInterface::removeFromSelectedItemsList(const render::Selection::Name& listName, const OverlayID& overlayID) {82bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& listName, const OverlayID& overlayID) {
82 return addToGameplayObjects(listName, overlayID);83 return addToGameplayObjects(listName, overlayID);
83}84}
84//85//
@@ -88,23 +89,25 @@ bool SelectionScriptingInterface::removeFromSelectedItemsList(const render::Sele · 3 unmodified lines
88//89//
89// START HANDLING GENERIC ITEMS90// START HANDLING GENERIC ITEMS
90//91//
91template <class T> bool SelectionScriptingInterface::addToGameplayObjects(const render::Selection::Name& listName, T idToAdd) {92template <class T> bool SelectionScriptingInterface::addToGameplayObjects(const QString& listName, T idToAdd) {
92 if (_selectedItemsListMap.contains(listName)) {93 if (_selectedItemsListMap.contains(listName)) {
93 auto currentList = _selectedItemsListMap.take(listName);94 auto currentList = _selectedItemsListMap.take(listName);
94 currentList.addToGameplayObjects(idToAdd);95 currentList.addToGameplayObjects(idToAdd);
95 _selectedItemsListMap.insert(listName, currentList);96 _selectedItemsListMap.insert(listName, currentList);
97
96 updateRendererSelectedList(listName);98 updateRendererSelectedList(listName);
97 return true;99 return true;
98 } else {100 } else {
99 _selectedItemsListMap.insert(listName, GameplayObjects());101 _selectedItemsListMap.insert(listName, GameplayObjects());
100 return addToSelectedItemsList(listName, idToAdd);102 return addToGameplayObjects(listName, idToAdd);
101 }103 }
102}104}
103template <class T> bool SelectionScriptingInterface::removeFromGameplayObjects(const render::Selection::Name& listName, T idToRemove) {105template <class T> bool SelectionScriptingInterface::removeFromGameplayObjects(const QString& listName, T idToRemove) {
104 if (_selectedItemsListMap.contains(listName)) {106 if (_selectedItemsListMap.contains(listName)) {
105 auto currentList = _selectedItemsListMap.take(listName);107 auto currentList = _selectedItemsListMap.take(listName);
106 currentList.removeFromGameplayObjects(idToRemove);108 currentList.removeFromGameplayObjects(idToRemove);
107 _selectedItemsListMap.insert(listName, currentList);109 _selectedItemsListMap.insert(listName, currentList);
110
108 updateRendererSelectedList(listName);111 updateRendererSelectedList(listName);
109 return true;112 return true;
110 } else {113 } else {
@@ -115,15 +118,42 @@ template <class T> bool SelectionScriptingInterface::removeFromGameplayObjects(c · 4 unmodified lines
115// END HANDLING GENERIC ITEMS118// END HANDLING GENERIC ITEMS
116//119//
117 120
118bool SelectionScriptingInterface::removeListFromMap(const render::Selection::Name& listName) {121void SelectionScriptingInterface::printList(const QString& listName) {
122 if (_selectedItemsListMap.contains(listName)) {
123 auto currentList = _selectedItemsListMap.value(listName);
124
125 qDebug() << "Avatar IDs:";
126 for (auto i : currentList.getAvatarIDs()) {
127 qDebug() << i << '; ';
128 }
129 qDebug() << "";
130
131 qDebug() << "Entity IDs:";
132 for (auto j : currentList.getEntityIDs()) {
133 qDebug() << j << '; ';
134 }
135 qDebug() << "";
136
137 qDebug() << "Overlay IDs:";
138 for (auto k : currentList.getOverlayIDs()) {
139 qDebug() << k << '; ';
140 }
141 qDebug() << "";
142 } else {
143 qDebug() << "List named" << listName << "doesn't exist.";
144 }
145}
146
147bool SelectionScriptingInterface::removeListFromMap(const QString& listName) {
119 if (_selectedItemsListMap.remove(listName)) {148 if (_selectedItemsListMap.remove(listName)) {
149 updateRendererSelectedList(listName);
120 return true;150 return true;
121 } else {151 } else {
122 return false;152 return false;
123 }153 }
124}154}
125 155
126void SelectionScriptingInterface::updateRendererSelectedList(const render::Selection::Name& listName) {156void SelectionScriptingInterface::updateRendererSelectedList(const QString& listName) {
127 auto scene = _viewState->getMain3DScene();157 auto scene = _viewState->getMain3DScene();
128 if (scene) {158 if (scene) {
129 render::Transaction transaction;159 render::Transaction transaction;
@@ -170,7 +200,7 @@ void SelectionScriptingInterface::updateRendererSelectedList(const render::Selec · 40 unmodified lines
170 }200 }
171 }201 }
172 202
173 render::Selection selection(listName, finalList);203 render::Selection selection(listName.toStdString(), finalList);
174 transaction.resetSelection(selection);204 transaction.resetSelection(selection);
175 205
176 scene->enqueueTransaction(transaction);206 scene->enqueueTransaction(transaction);