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