Showing the changes to interface/src/scripting/SelectionScriptingInterface.cpp (1 of 3 files). Show all
Unified · Split
| @@ -10,6 +10,7 @@ · 9 unmodified lines | ||
| 10 | 10 | // |
| 11 | 11 | |
| 12 | 12 | #include "SelectionScriptingInterface.h" |
| 13 | +#include <QDebug> | |
| 13 | 14 | #include "Application.h" |
| 14 | 15 | |
| 15 | 16 | GameplayObjects::GameplayObjects() { |
| @@ -49,10 +50,10 @@ SelectionScriptingInterface::SelectionScriptingInterface(AbstractViewStateInterf · 33 unmodified lines | ||
| 49 | 50 | // |
| 50 | 51 | // START HANDLING AVATARS |
| 51 | 52 | // |
| 52 | −bool SelectionScriptingInterface::addToSelectedItemsList(const render::Selection::Name& listName, const QUuid& avatarSessionID) { | |
| 53 | +bool SelectionScriptingInterface::addToSelectedItemsList(const QString& listName, const QUuid& avatarSessionID) { | |
| 53 | 54 | return addToGameplayObjects(listName, avatarSessionID); |
| 54 | 55 | } |
| 55 | −bool SelectionScriptingInterface::removeFromSelectedItemsList(const render::Selection::Name& listName, const QUuid& avatarSessionID) { | |
| 56 | +bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& listName, const QUuid& avatarSessionID) { | |
| 56 | 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 | 64 | // START HANDLING ENTITIES |
| 64 | 65 | // |
| 65 | −bool SelectionScriptingInterface::addToSelectedItemsList(const render::Selection::Name& listName, const EntityItemID& entityID) { | |
| 66 | +bool SelectionScriptingInterface::addToSelectedItemsList(const QString& listName, const EntityItemID& entityID) { | |
| 66 | 67 | return addToGameplayObjects(listName, entityID); |
| 67 | 68 | } |
| 68 | −bool SelectionScriptingInterface::removeFromSelectedItemsList(const render::Selection::Name& listName, const EntityItemID& entityID) { | |
| 69 | +bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& listName, const EntityItemID& entityID) { | |
| 69 | 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 | 77 | // START HANDLING OVERLAYS |
| 77 | 78 | // |
| 78 | −bool SelectionScriptingInterface::addToSelectedItemsList(const render::Selection::Name& listName, const OverlayID& overlayID) { | |
| 79 | +bool SelectionScriptingInterface::addToSelectedItemsList(const QString& listName, const OverlayID& overlayID) { | |
| 79 | 80 | return addToGameplayObjects(listName, overlayID); |
| 80 | 81 | } |
| 81 | −bool SelectionScriptingInterface::removeFromSelectedItemsList(const render::Selection::Name& listName, const OverlayID& overlayID) { | |
| 82 | +bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& listName, const OverlayID& overlayID) { | |
| 82 | 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 | 90 | // START HANDLING GENERIC ITEMS |
| 90 | 91 | // |
| 91 | −template <class T> bool SelectionScriptingInterface::addToGameplayObjects(const render::Selection::Name& listName, T idToAdd) { | |
| 92 | +template <class T> bool SelectionScriptingInterface::addToGameplayObjects(const QString& listName, T idToAdd) { | |
| 92 | 93 | if (_selectedItemsListMap.contains(listName)) { |
| 93 | 94 | auto currentList = _selectedItemsListMap.take(listName); |
| 94 | 95 | currentList.addToGameplayObjects(idToAdd); |
| 95 | 96 | _selectedItemsListMap.insert(listName, currentList); |
| 97 | + | |
| 96 | 98 | updateRendererSelectedList(listName); |
| 97 | 99 | return true; |
| 98 | 100 | } else { |
| 99 | 101 | _selectedItemsListMap.insert(listName, GameplayObjects()); |
| 100 | − return addToSelectedItemsList(listName, idToAdd); | |
| 102 | + return addToGameplayObjects(listName, idToAdd); | |
| 101 | 103 | } |
| 102 | 104 | } |
| 103 | −template <class T> bool SelectionScriptingInterface::removeFromGameplayObjects(const render::Selection::Name& listName, T idToRemove) { | |
| 105 | +template <class T> bool SelectionScriptingInterface::removeFromGameplayObjects(const QString& listName, T idToRemove) { | |
| 104 | 106 | if (_selectedItemsListMap.contains(listName)) { |
| 105 | 107 | auto currentList = _selectedItemsListMap.take(listName); |
| 106 | 108 | currentList.removeFromGameplayObjects(idToRemove); |
| 107 | 109 | _selectedItemsListMap.insert(listName, currentList); |
| 110 | + | |
| 108 | 111 | updateRendererSelectedList(listName); |
| 109 | 112 | return true; |
| 110 | 113 | } else { |
| @@ -115,15 +118,42 @@ template <class T> bool SelectionScriptingInterface::removeFromGameplayObjects(c · 4 unmodified lines | ||
| 115 | 118 | // END HANDLING GENERIC ITEMS |
| 116 | 119 | // |
| 117 | 120 | |
| 118 | −bool SelectionScriptingInterface::removeListFromMap(const render::Selection::Name& listName) { | |
| 121 | +void 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 | + | |
| 147 | +bool SelectionScriptingInterface::removeListFromMap(const QString& listName) { | |
| 119 | 148 | if (_selectedItemsListMap.remove(listName)) { |
| 149 | + updateRendererSelectedList(listName); | |
| 120 | 150 | return true; |
| 121 | 151 | } else { |
| 122 | 152 | return false; |
| 123 | 153 | } |
| 124 | 154 | } |
| 125 | 155 | |
| 126 | −void SelectionScriptingInterface::updateRendererSelectedList(const render::Selection::Name& listName) { | |
| 156 | +void SelectionScriptingInterface::updateRendererSelectedList(const QString& listName) { | |
| 127 | 157 | auto scene = _viewState->getMain3DScene(); |
| 128 | 158 | if (scene) { |
| 129 | 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 | 204 | transaction.resetSelection(selection); |
| 175 | 205 | |
| 176 | 206 | scene->enqueueTransaction(transaction); |