Showing the changes to interface/src/scripting/SelectionScriptingInterface.cpp (1 of 4 files). Show all
Unified · Split
| @@ -73,7 +73,7 @@ template <class T> bool SelectionScriptingInterface::addToGameplayObjects(const · 72 unmodified lines | |||
| 73 | currentList.addToGameplayObjects(idToAdd); | 73 | currentList.addToGameplayObjects(idToAdd); |
| 74 | _selectedItemsListMap.insert(listName, currentList); | 74 | _selectedItemsListMap.insert(listName, currentList); |
| 75 | 75 | ||
| 76 | updateRendererSelectedList(listName); | 76 | emit selectedItemsListChanged(listName); |
| 77 | return true; | 77 | return true; |
| 78 | } else { | 78 | } else { |
| 79 | _selectedItemsListMap.insert(listName, GameplayObjects()); | 79 | _selectedItemsListMap.insert(listName, GameplayObjects()); |
| @@ -86,7 +86,7 @@ template <class T> bool SelectionScriptingInterface::removeFromGameplayObjects(c · 6 unmodified lines | |||
| 86 | currentList.removeFromGameplayObjects(idToRemove); | 86 | currentList.removeFromGameplayObjects(idToRemove); |
| 87 | _selectedItemsListMap.insert(listName, currentList); | 87 | _selectedItemsListMap.insert(listName, currentList); |
| 88 | 88 | ||
| 89 | updateRendererSelectedList(listName); | 89 | emit selectedItemsListChanged(listName); |
| 90 | return true; | 90 | return true; |
| 91 | } else { | 91 | } else { |
| 92 | return false; | 92 | return false; |
| @@ -132,7 +132,7 @@ void SelectionScriptingInterface::printList(const QString& listName) { · 39 unmodified lines | |||
| 132 | 132 | ||
| 133 | bool SelectionScriptingInterface::removeListFromMap(const QString& listName) { | 133 | bool SelectionScriptingInterface::removeListFromMap(const QString& listName) { |
| 134 | if (_selectedItemsListMap.remove(listName)) { | 134 | if (_selectedItemsListMap.remove(listName)) { |
| 135 | updateRendererSelectedList(listName); | 135 | //updateRendererSelectedList(listName); |
| 136 | return true; | 136 | return true; |
| 137 | } else { | 137 | } else { |
| 138 | return false; | 138 | return false; |
| @@ -148,9 +148,15 @@ void SelectionToSceneHandler::initialize(render::ScenePointer mainScene, const Q · 9 unmodified lines | |||
| 148 | _listName = listName; | 148 | _listName = listName; |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | void SelectionToSceneHandler::updateRendererSelectedList() { | 151 | void SelectionToSceneHandler::selectedItemsListChanged(const QString& listName) { |
| 152 | if (listName == _listName) { | ||
| 153 | updateSceneFromSelectedList(); | ||
| 154 | } | ||
| 155 | } | ||
| 156 | |||
| 157 | void SelectionToSceneHandler::updateSceneFromSelectedList() { | ||
| 152 | if (_mainScene) { | 158 | if (_mainScene) { |
| 153 | GameplayObjects* thisList = DependencyManager::get<SelectionScriptingInterface>()->getList(_listName); | 159 | GameplayObjects* thisList = &DependencyManager::get<SelectionScriptingInterface>()->getList(_listName); |
| 154 | render::Transaction transaction; | 160 | render::Transaction transaction; |
| 155 | 161 | ||
| 156 | if (thisList != NULL) { | 162 | if (thisList != NULL) { |
| @@ -158,9 +164,8 @@ void SelectionToSceneHandler::updateRendererSelectedList() { · 1 unmodified line | |||
| 158 | render::ItemID currentID; | 164 | render::ItemID currentID; |
| 159 | auto entityTree = qApp->getEntities()->getTree(); | 165 | auto entityTree = qApp->getEntities()->getTree(); |
| 160 | auto& overlays = qApp->getOverlays(); | 166 | auto& overlays = qApp->getOverlays(); |
| 161 | auto currentList = thisList.value(_listName); | ||
| 162 | 167 | ||
| 163 | for (QUuid& currentAvatarID : currentList.getAvatarIDs()) { | 168 | for (QUuid& currentAvatarID : thisList->getAvatarIDs()) { |
| 164 | auto avatar = std::static_pointer_cast<Avatar>(DependencyManager::get<AvatarManager>()->getAvatarBySessionID(currentAvatarID)); | 169 | auto avatar = std::static_pointer_cast<Avatar>(DependencyManager::get<AvatarManager>()->getAvatarBySessionID(currentAvatarID)); |
| 165 | if (avatar) { | 170 | if (avatar) { |
| 166 | currentID = avatar->getRenderItemID(); | 171 | currentID = avatar->getRenderItemID(); |
| @@ -170,7 +175,7 @@ void SelectionToSceneHandler::updateRendererSelectedList() { · 3 unmodified lines | |||
| 170 | } | 175 | } |
| 171 | } | 176 | } |
| 172 | 177 | ||
| 173 | for (EntityItemID& currentEntityID : currentList.getEntityIDs()) { | 178 | for (EntityItemID& currentEntityID : thisList->getEntityIDs()) { |
| 174 | entityTree->withReadLock([&] { | 179 | entityTree->withReadLock([&] { |
| 175 | auto entityItem = entityTree->findEntityByEntityItemID(currentEntityID); | 180 | auto entityItem = entityTree->findEntityByEntityItemID(currentEntityID); |
| 176 | if (entityItem != NULL) { | 181 | if (entityItem != NULL) { |
| @@ -185,7 +190,7 @@ void SelectionToSceneHandler::updateRendererSelectedList() { · 8 unmodified lines | |||
| 185 | }); | 190 | }); |
| 186 | } | 191 | } |
| 187 | 192 | ||
| 188 | for (OverlayID& currentOverlayID : currentList.getOverlayIDs()) { | 193 | for (OverlayID& currentOverlayID : thisList->getOverlayIDs()) { |
| 189 | auto overlay = overlays.getOverlay(currentOverlayID); | 194 | auto overlay = overlays.getOverlay(currentOverlayID); |
| 190 | if (overlay != NULL) { | 195 | if (overlay != NULL) { |
| 191 | currentID = overlay->getRenderItemID(); | 196 | currentID = overlay->getRenderItemID(); |
| @@ -203,6 +208,6 @@ void SelectionToSceneHandler::updateRendererSelectedList() { · 11 unmodified lines | |||
| 203 | qWarning() << "List of GameplayObjects doesn't exist in thisList"; | 208 | qWarning() << "List of GameplayObjects doesn't exist in thisList"; |
| 204 | } | 209 | } |
| 205 | } else { | 210 | } else { |
| 206 | qWarning() << "SelectionScriptingInterface::updateRendererSelectedList(), Unexpected null scene, possibly during application shutdown"; | 211 | qWarning() << "SelectionToSceneHandler::updateRendererSelectedList(), Unexpected null scene, possibly during application shutdown"; |
| 207 | } | 212 | } |
| 208 | } | 213 | } |