History

keep debuging the seelction highlight

samcake committed 8 years ago

Commit e0740b31 parent 76cface5 files · +67 −34Browse files

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

Unified · Split

interface/src/scripting/SelectionScriptingInterface.cpp+44−32
@@ -73,12 +73,11 @@ bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& lis · 72 unmodified lines
73 73
74bool SelectionScriptingInterface::clearSelectedItemsList(const QString& listName) {74bool SelectionScriptingInterface::clearSelectedItemsList(const QString& listName) {
75 _selectedItemsListMap.insert(listName, GameplayObjects());75 _selectedItemsListMap.insert(listName, GameplayObjects());
76 emit selectedItemsListChanged(listName);76 onSelectedItemsListChanged(listName);
77 return true;77 return true;
78}78}
79 79
80bool SelectionScriptingInterface::enableListHighlight(const QString& listName, const QVariantMap& highlightStyleValues) {80bool SelectionScriptingInterface::enableListHighlight(const QString& listName, const QVariantMap& highlightStyleValues) {
81 bool doSetupHandler = false;
82 81
83 auto highlightStyle = _highlightedListMap.find(listName);82 auto highlightStyle = _highlightedListMap.find(listName);
84 if (highlightStyle == _highlightedListMap.end()) {83 if (highlightStyle == _highlightedListMap.end()) {
@@ -90,18 +89,14 @@ bool SelectionScriptingInterface::enableListHighlight(const QString& listName, c · 5 unmodified lines
90 auto currentList = _selectedItemsListMap.find(listName);89 auto currentList = _selectedItemsListMap.find(listName);
91 if (currentList == _selectedItemsListMap.end()) {90 if (currentList == _selectedItemsListMap.end()) {
92 _selectedItemsListMap.insert(listName, GameplayObjects());91 _selectedItemsListMap.insert(listName, GameplayObjects());
93 setupHandler(listName);
94 // doSetupHandler = true;
95 }92 }
93 setupHandler(listName);
94
96 (*highlightStyle).setBoundToList(true);95 (*highlightStyle).setBoundToList(true);
97 }96 }
98 97
99 (*highlightStyle).fromVariantMap(highlightStyleValues);98 (*highlightStyle).fromVariantMap(highlightStyleValues);
100 99
101/* if (doSetupHandler) {
102 setupHandler(listName);
103 }*/
104
105 auto mainScene = qApp->getMain3DScene();100 auto mainScene = qApp->getMain3DScene();
106 if (mainScene) {101 if (mainScene) {
107 render::Transaction transaction;102 render::Transaction transaction;
@@ -139,7 +134,12 @@ bool SelectionScriptingInterface::disableListHighlight(const QString& listName) · 31 unmodified lines
139}134}
140 135
141QVariantMap SelectionScriptingInterface::getListHighlightStyle(const QString& listName) const {136QVariantMap SelectionScriptingInterface::getListHighlightStyle(const QString& listName) const {
142 return QVariantMap();137 auto highlightStyle = _highlightedListMap.find(listName);
138 if (highlightStyle == _highlightedListMap.end()) {
139 return QVariantMap();
140 } else {
141 return (*highlightStyle).toVariantMap();
142 }
143}143}
144 144
145render::HighlightStyle SelectionScriptingInterface::getHighlightStyle(const QString& listName) const {145render::HighlightStyle SelectionScriptingInterface::getHighlightStyle(const QString& listName) const {
@@ -156,7 +156,7 @@ template <class T> bool SelectionScriptingInterface::addToGameplayObjects(const · 10 unmodified lines
156 currentList.addToGameplayObjects(idToAdd);156 currentList.addToGameplayObjects(idToAdd);
157 _selectedItemsListMap.insert(listName, currentList);157 _selectedItemsListMap.insert(listName, currentList);
158 158
159 emit selectedItemsListChanged(listName);159 onSelectedItemsListChanged(listName);
160 return true;160 return true;
161}161}
162template <class T> bool SelectionScriptingInterface::removeFromGameplayObjects(const QString& listName, T idToRemove) {162template <class T> bool SelectionScriptingInterface::removeFromGameplayObjects(const QString& listName, T idToRemove) {
@@ -165,7 +165,7 @@ template <class T> bool SelectionScriptingInterface::removeFromGameplayObjects(c · 2 unmodified lines
165 currentList.removeFromGameplayObjects(idToRemove);165 currentList.removeFromGameplayObjects(idToRemove);
166 _selectedItemsListMap.insert(listName, currentList);166 _selectedItemsListMap.insert(listName, currentList);
167 167
168 emit selectedItemsListChanged(listName);168 onSelectedItemsListChanged(listName);
169 return true;169 return true;
170 } else {170 } else {
171 return false;171 return false;
@@ -180,34 +180,40 @@ GameplayObjects SelectionScriptingInterface::getList(const QString& listName) { · 8 unmodified lines
180}180}
181 181
182void SelectionScriptingInterface::printList(const QString& listName) {182void SelectionScriptingInterface::printList(const QString& listName) {
183 GameplayObjects currentList = _selectedItemsListMap.value(listName);183 auto currentList = _selectedItemsListMap.find(listName);
184 if (currentList.getContainsData()) {184 if (currentList != _selectedItemsListMap.end()) {
185 if ((*currentList).getContainsData()) {
186
187 qDebug() << "List named " << listName << ":";
188 qDebug() << "Avatar IDs:";
189 for (auto i : (*currentList).getAvatarIDs()) {
190 qDebug() << i << ';';
191 }
192 qDebug() << "";
185 193
186 qDebug() << "Avatar IDs:";194 qDebug() << "Entity IDs:";
187 for (auto i : currentList.getAvatarIDs()) {195 for (auto j : (*currentList).getEntityIDs()) {
188 qDebug() << i << ';';196 qDebug() << j << ';';
189 }197 }
190 qDebug() << "";198 qDebug() << "";
191 199
192 qDebug() << "Entity IDs:";200 qDebug() << "Overlay IDs:";
193 for (auto j : currentList.getEntityIDs()) {201 for (auto k : (*currentList).getOverlayIDs()) {
194 qDebug() << j << ';';202 qDebug() << k << ';';
203 }
204 qDebug() << "";
195 }205 }
196 qDebug() << "";206 else {
197 207 qDebug() << "List named " << listName << " empty";
198 qDebug() << "Overlay IDs:";
199 for (auto k : currentList.getOverlayIDs()) {
200 qDebug() << k << ';';
201 }208 }
202 qDebug() << "";
203 } else {209 } else {
204 qDebug() << "List named" << listName << "doesn't exist.";210 qDebug() << "List named " << listName << " doesn't exist.";
205 }211 }
206}212}
207 213
208bool SelectionScriptingInterface::removeListFromMap(const QString& listName) {214bool SelectionScriptingInterface::removeListFromMap(const QString& listName) {
209 if (_selectedItemsListMap.remove(listName)) {215 if (_selectedItemsListMap.remove(listName)) {
210 emit selectedItemsListChanged(listName);216 onSelectedItemsListChanged(listName);
211 return true;217 return true;
212 } else {218 } else {
213 return false;219 return false;
@@ -222,7 +228,15 @@ void SelectionScriptingInterface::setupHandler(const QString& selectionName) { · 8 unmodified lines
222 228
223 229
224 (*handler)->initialize(selectionName);230 (*handler)->initialize(selectionName);
231 // connect(this, &SelectionScriptingInterface::selectedItemsListChanged, handler.value(), &SelectionToSceneHandler::selectedItemsListChanged);
232
233}
225 234
235void SelectionScriptingInterface::onSelectedItemsListChanged(const QString& listName) {
236 auto handler = _handlerMap.find(listName);
237 if (handler != _handlerMap.end()) {
238 (*handler)->updateSceneFromSelectedList();
239 }
226}240}
227 241
228 242
@@ -232,10 +246,8 @@ SelectionToSceneHandler::SelectionToSceneHandler() { · 3 unmodified lines
232void SelectionToSceneHandler::initialize(const QString& listName) {246void SelectionToSceneHandler::initialize(const QString& listName) {
233 _listName = listName;247 _listName = listName;
234 248
235 connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::selectedItemsListChanged, this, &SelectionToSceneHandler::selectedItemsListChanged);
236 // connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::highlightStyleChanged, this, &SelectionToSceneHandler::highlightStyleChanged);
237 // connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::highlightStyleRemoved, this, &SelectionToSceneHandler::highlightStyleRemoved);
238 249
250 updateSceneFromSelectedList();
239}251}
240 252
241void SelectionToSceneHandler::selectedItemsListChanged(const QString& listName) {253void SelectionToSceneHandler::selectedItemsListChanged(const QString& listName) {