Showing the changes to interface/src/scripting/SelectionScriptingInterface.cpp (1 of 5 files). Show all
Unified · Split
| @@ -47,48 +47,27 @@ SelectionScriptingInterface::SelectionScriptingInterface(AbstractViewStateInterf · 46 unmodified lines | |||
| 47 | _viewState = viewState; | 47 | _viewState = viewState; |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | // | 50 | bool SelectionScriptingInterface::addToSelectedItemsList(const QString& listName, const QString& itemType, const QUuid& id) { |
| 51 | // START HANDLING AVATARS | 51 | if (itemType == "avatar") { |
| 52 | // | 52 | return addToGameplayObjects(listName, (QUuid)id); |
| 53 | bool SelectionScriptingInterface::addToSelectedItemsList(const QString& listName, const QUuid& avatarSessionID) { | 53 | } else if (itemType == "entity") { |
| 54 | return addToGameplayObjects(listName, avatarSessionID); | 54 | return addToGameplayObjects(listName, (EntityItemID)id); |
| 55 | } | 55 | } else if (itemType == "overlay") { |
| 56 | bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& listName, const QUuid& avatarSessionID) { | 56 | return addToGameplayObjects(listName, (OverlayID)id); |
| 57 | return addToGameplayObjects(listName, avatarSessionID); | 57 | } |
| 58 | } | 58 | return false; |
| 59 | // | 59 | } |
| 60 | // END HANDLING AVATARS | 60 | bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& listName, const QString& itemType, const QUuid& id) { |
| 61 | // | 61 | if (itemType == "avatar") { |
| 62 | 62 | return removeFromGameplayObjects(listName, (QUuid)id); | |
| 63 | // | 63 | } else if (itemType == "entity") { |
| 64 | // START HANDLING ENTITIES | 64 | return removeFromGameplayObjects(listName, (EntityItemID)id); |
| 65 | // | 65 | } else if (itemType == "overlay") { |
| 66 | bool SelectionScriptingInterface::addToSelectedItemsList(const QString& listName, const EntityItemID& entityID) { | 66 | return removeFromGameplayObjects(listName, (OverlayID)id); |
| 67 | return addToGameplayObjects(listName, entityID); | 67 | } |
| 68 | } | 68 | return false; |
| 69 | bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& listName, const EntityItemID& entityID) { | ||
| 70 | return addToGameplayObjects(listName, entityID); | ||
| 71 | } | ||
| 72 | // | ||
| 73 | // END HANDLING ENTITIES | ||
| 74 | // | ||
| 75 | |||
| 76 | // | ||
| 77 | // START HANDLING OVERLAYS | ||
| 78 | // | ||
| 79 | bool SelectionScriptingInterface::addToSelectedItemsList(const QString& listName, const OverlayID& overlayID) { | ||
| 80 | return addToGameplayObjects(listName, overlayID); | ||
| 81 | } | ||
| 82 | bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& listName, const OverlayID& overlayID) { | ||
| 83 | return addToGameplayObjects(listName, overlayID); | ||
| 84 | } | 69 | } |
| 85 | // | ||
| 86 | // END HANDLING OVERLAYS | ||
| 87 | // | ||
| 88 | 70 | ||
| 89 | // | ||
| 90 | // START HANDLING GENERIC ITEMS | ||
| 91 | // | ||
| 92 | template <class T> bool SelectionScriptingInterface::addToGameplayObjects(const QString& listName, T idToAdd) { | 71 | template <class T> bool SelectionScriptingInterface::addToGameplayObjects(const QString& listName, T idToAdd) { |
| 93 | if (_selectedItemsListMap.contains(listName)) { | 72 | if (_selectedItemsListMap.contains(listName)) { |
| 94 | auto currentList = _selectedItemsListMap.take(listName); | 73 | auto currentList = _selectedItemsListMap.take(listName); |
| @@ -153,17 +132,25 @@ bool SelectionScriptingInterface::removeListFromMap(const QString& listName) { · 58 unmodified lines | |||
| 153 | } | 132 | } |
| 154 | } | 133 | } |
| 155 | 134 | ||
| 156 | void SelectionScriptingInterface::updateRendererSelectedList(const QString& listName) { | 135 | |
| 157 | auto scene = _viewState->getMain3DScene(); | 136 | SelectionToSceneHandler::SelectionToSceneHandler() { |
| 158 | if (scene) { | 137 | } |
| 138 | |||
| 139 | void SelectionToSceneHandler::initialize(render::ScenePointer mainScene, const QString& listName) { | ||
| 140 | _mainScene = mainScene; | ||
| 141 | _listName = listName; | ||
| 142 | } | ||
| 143 | |||
| 144 | void SelectionToSceneHandler::updateRendererSelectedList() { | ||
| 145 | if (_mainScene) { | ||
| 159 | render::Transaction transaction; | 146 | render::Transaction transaction; |
| 160 | 147 | ||
| 161 | if (_selectedItemsListMap.contains(listName)) { | 148 | if (_selectedItemsListMap.contains(_listName)) { |
| 162 | render::ItemIDs finalList; | 149 | render::ItemIDs finalList; |
| 163 | render::ItemID currentID; | 150 | render::ItemID currentID; |
| 164 | auto entityTree = qApp->getEntities()->getTree(); | 151 | auto entityTree = qApp->getEntities()->getTree(); |
| 165 | auto& overlays = qApp->getOverlays(); | 152 | auto& overlays = qApp->getOverlays(); |
| 166 | auto currentList = _selectedItemsListMap.value(listName); | 153 | auto currentList = _selectedItemsListMap.value(_listName); |
| 167 | 154 | ||
| 168 | for (QUuid& currentAvatarID : currentList.getAvatarIDs()) { | 155 | for (QUuid& currentAvatarID : currentList.getAvatarIDs()) { |
| 169 | auto avatar = std::static_pointer_cast<Avatar>(DependencyManager::get<AvatarManager>()->getAvatarBySessionID(currentAvatarID)); | 156 | auto avatar = std::static_pointer_cast<Avatar>(DependencyManager::get<AvatarManager>()->getAvatarBySessionID(currentAvatarID)); |
| @@ -200,10 +187,10 @@ void SelectionScriptingInterface::updateRendererSelectedList(const QString& list · 30 unmodified lines | |||
| 200 | } | 187 | } |
| 201 | } | 188 | } |
| 202 | 189 | ||
| 203 | render::Selection selection(listName.toStdString(), finalList); | 190 | render::Selection selection(_listName.toStdString(), finalList); |
| 204 | transaction.resetSelection(selection); | 191 | transaction.resetSelection(selection); |
| 205 | 192 | ||
| 206 | scene->enqueueTransaction(transaction); | 193 | _mainScene->enqueueTransaction(transaction); |
| 207 | } else { | 194 | } else { |
| 208 | qWarning() << "List of GameplayObjects doesn't exist in _selectedItemsListMap"; | 195 | qWarning() << "List of GameplayObjects doesn't exist in _selectedItemsListMap"; |
| 209 | } | 196 | } |