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 | 47 | _viewState = viewState; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | −// | |
| 51 | −// START HANDLING AVATARS | |
| 52 | −// | |
| 53 | −bool SelectionScriptingInterface::addToSelectedItemsList(const QString& listName, const QUuid& avatarSessionID) { | |
| 54 | − return addToGameplayObjects(listName, avatarSessionID); | |
| 55 | −} | |
| 56 | −bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& listName, const QUuid& avatarSessionID) { | |
| 57 | − return addToGameplayObjects(listName, avatarSessionID); | |
| 58 | −} | |
| 59 | −// | |
| 60 | −// END HANDLING AVATARS | |
| 61 | −// | |
| 62 | − | |
| 63 | −// | |
| 64 | −// START HANDLING ENTITIES | |
| 65 | −// | |
| 66 | −bool SelectionScriptingInterface::addToSelectedItemsList(const QString& listName, const EntityItemID& entityID) { | |
| 67 | − return addToGameplayObjects(listName, entityID); | |
| 68 | −} | |
| 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); | |
| 50 | +bool SelectionScriptingInterface::addToSelectedItemsList(const QString& listName, const QString& itemType, const QUuid& id) { | |
| 51 | + if (itemType == "avatar") { | |
| 52 | + return addToGameplayObjects(listName, (QUuid)id); | |
| 53 | + } else if (itemType == "entity") { | |
| 54 | + return addToGameplayObjects(listName, (EntityItemID)id); | |
| 55 | + } else if (itemType == "overlay") { | |
| 56 | + return addToGameplayObjects(listName, (OverlayID)id); | |
| 57 | + } | |
| 58 | + return false; | |
| 59 | +} | |
| 60 | +bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& listName, const QString& itemType, const QUuid& id) { | |
| 61 | + if (itemType == "avatar") { | |
| 62 | + return removeFromGameplayObjects(listName, (QUuid)id); | |
| 63 | + } else if (itemType == "entity") { | |
| 64 | + return removeFromGameplayObjects(listName, (EntityItemID)id); | |
| 65 | + } else if (itemType == "overlay") { | |
| 66 | + return removeFromGameplayObjects(listName, (OverlayID)id); | |
| 67 | + } | |
| 68 | + return false; | |
| 84 | 69 | } |
| 85 | −// | |
| 86 | −// END HANDLING OVERLAYS | |
| 87 | −// | |
| 88 | 70 | |
| 89 | −// | |
| 90 | −// START HANDLING GENERIC ITEMS | |
| 91 | −// | |
| 92 | 71 | template <class T> bool SelectionScriptingInterface::addToGameplayObjects(const QString& listName, T idToAdd) { |
| 93 | 72 | if (_selectedItemsListMap.contains(listName)) { |
| 94 | 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) { | |
| 157 | − auto scene = _viewState->getMain3DScene(); | |
| 158 | − if (scene) { | |
| 135 | + | |
| 136 | +SelectionToSceneHandler::SelectionToSceneHandler() { | |
| 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 | 146 | render::Transaction transaction; |
| 160 | 147 | |
| 161 | − if (_selectedItemsListMap.contains(listName)) { | |
| 148 | + if (_selectedItemsListMap.contains(_listName)) { | |
| 162 | 149 | render::ItemIDs finalList; |
| 163 | 150 | render::ItemID currentID; |
| 164 | 151 | auto entityTree = qApp->getEntities()->getTree(); |
| 165 | 152 | auto& overlays = qApp->getOverlays(); |
| 166 | − auto currentList = _selectedItemsListMap.value(listName); | |
| 153 | + auto currentList = _selectedItemsListMap.value(_listName); | |
| 167 | 154 | |
| 168 | 155 | for (QUuid& currentAvatarID : currentList.getAvatarIDs()) { |
| 169 | 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 | 191 | transaction.resetSelection(selection); |
| 205 | 192 | |
| 206 | − scene->enqueueTransaction(transaction); | |
| 193 | + _mainScene->enqueueTransaction(transaction); | |
| 207 | 194 | } else { |
| 208 | 195 | qWarning() << "List of GameplayObjects doesn't exist in _selectedItemsListMap"; |
| 209 | 196 | } |