Showing the changes to interface/src/scripting/SelectionScriptingInterface.cpp (1 of 3 files). Show all
Unified · Split
| @@ -78,22 +78,28 @@ bool SelectionScriptingInterface::clearSelectedItemsList(const QString& listName · 77 unmodified lines | ||
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | bool SelectionScriptingInterface::enableListHighlight(const QString& listName, const QVariantMap& highlightStyleValues) { |
| 81 | + bool doSetupHandler = false; | |
| 82 | + | |
| 81 | 83 | auto highlightStyle = _highlightedListMap.find(listName); |
| 82 | 84 | if (highlightStyle == _highlightedListMap.end()) { |
| 83 | 85 | highlightStyle = _highlightedListMap.insert(listName, SelectionHighlightStyle()); |
| 86 | + doSetupHandler = true; | |
| 84 | 87 | } |
| 85 | 88 | |
| 86 | 89 | if (!(*highlightStyle).isBoundToList()) { |
| 87 | 90 | GameplayObjects currentList = _selectedItemsListMap.value(listName); |
| 88 | 91 | if (!currentList.getContainsData()) { |
| 89 | 92 | _selectedItemsListMap.insert(listName, currentList); |
| 90 | − highlightStyleChanged(listName); | |
| 93 | + doSetupHandler = true; | |
| 91 | 94 | } |
| 92 | 95 | (*highlightStyle).setBoundToList(true); |
| 93 | 96 | } |
| 94 | 97 | |
| 95 | 98 | (*highlightStyle).fromVariantMap(highlightStyleValues); |
| 96 | 99 | |
| 100 | + if (doSetupHandler) { | |
| 101 | + setupHandler(listName); | |
| 102 | + } | |
| 97 | 103 | |
| 98 | 104 | emit highlightStyleChanged(listName); |
| 99 | 105 | return true; |
| @@ -190,12 +196,41 @@ bool SelectionScriptingInterface::removeListFromMap(const QString& listName) { · 90 unmodified lines | ||
| 190 | 196 | } |
| 191 | 197 | } |
| 192 | 198 | |
| 199 | +void SelectionScriptingInterface::onSelectedItemsListChanged(const QString& listName) { | |
| 200 | + emit selectedItemsListChanged(listName); | |
| 201 | +} | |
| 202 | + | |
| 203 | +void SelectionScriptingInterface::onHighlightStyleChanged(const QString& listName) { | |
| 204 | + emit onHighlightStyleChanged(listName); | |
| 205 | +} | |
| 206 | + | |
| 207 | +void SelectionScriptingInterface::setupHandler(const QString& selectionName) { | |
| 208 | + auto handler = _handlerMap.find(selectionName); | |
| 209 | + if (handler == _handlerMap.end()) { | |
| 210 | + handler = _handlerMap.insert(selectionName, new SelectionToSceneHandler()); | |
| 211 | + } | |
| 212 | + | |
| 213 | + | |
| 214 | + (*handler)->initialize(selectionName); | |
| 215 | + | |
| 216 | +} | |
| 217 | + | |
| 193 | 218 | |
| 194 | 219 | SelectionToSceneHandler::SelectionToSceneHandler() { |
| 195 | 220 | } |
| 196 | 221 | |
| 197 | 222 | void SelectionToSceneHandler::initialize(const QString& listName) { |
| 198 | 223 | _listName = listName; |
| 224 | + | |
| 225 | + connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::selectedItemsListChanged, this, &SelectionToSceneHandler::selectedItemsListChanged); | |
| 226 | + connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::highlightStyleChanged, this, &SelectionToSceneHandler::highlightStyleChanged); | |
| 227 | + | |
| 228 | + auto mainScene = qApp->getMain3DScene(); | |
| 229 | + if (mainScene) { | |
| 230 | + render::Transaction transaction; | |
| 231 | + transaction.resetSelectionHighlight(listName.toStdString(), DependencyManager::get<SelectionScriptingInterface>()->getHighlightStyle(listName)); | |
| 232 | + mainScene->enqueueTransaction(transaction); | |
| 233 | + } | |
| 199 | 234 | } |
| 200 | 235 | |
| 201 | 236 | void SelectionToSceneHandler::selectedItemsListChanged(const QString& listName) { |
| @@ -251,18 +286,20 @@ void SelectionToSceneHandler::updateSceneFromSelectedList() { · 49 unmodified lines | ||
| 251 | 286 | } |
| 252 | 287 | |
| 253 | 288 | void SelectionToSceneHandler::highlightStyleChanged(const QString& listName) { |
| 254 | − auto mainScene = qApp->getMain3DScene(); | |
| 255 | − if (mainScene) { | |
| 256 | − auto thisStyle = DependencyManager::get<SelectionScriptingInterface>()->getHighlightStyle(listName); | |
| 257 | − render::Transaction transaction; | |
| 258 | − render::ItemIDs finalList; | |
| 289 | + if (listName == _listName) { | |
| 290 | + auto mainScene = qApp->getMain3DScene(); | |
| 291 | + if (mainScene) { | |
| 292 | + auto thisStyle = DependencyManager::get<SelectionScriptingInterface>()->getHighlightStyle(listName); | |
| 293 | + render::Transaction transaction; | |
| 294 | + render::ItemIDs finalList; | |
| 259 | 295 | |
| 260 | − transaction.resetSelectionHighlight(listName.toStdString(), thisStyle); | |
| 296 | + transaction.resetSelectionHighlight(listName.toStdString(), thisStyle); | |
| 261 | 297 | |
| 262 | − mainScene->enqueueTransaction(transaction); | |
| 263 | − } | |
| 264 | − else { | |
| 265 | − qWarning() << "SelectionToSceneHandler::updateRendererSelectedList(), Unexpected null scene, possibly during application shutdown"; | |
| 298 | + mainScene->enqueueTransaction(transaction); | |
| 299 | + } | |
| 300 | + else { | |
| 301 | + qWarning() << "SelectionToSceneHandler::updateRendererSelectedList(), Unexpected null scene, possibly during application shutdown"; | |
| 302 | + } | |
| 266 | 303 | } |
| 267 | 304 | } |
| 268 | 305 | |
| @@ -300,6 +337,7 @@ bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) { · 31 unmodified lines | ||
| 300 | 337 | |
| 301 | 338 | return true; |
| 302 | 339 | } |
| 340 | + | |
| 303 | 341 | QVariantMap SelectionHighlightStyle::toVariantMap() const { |
| 304 | 342 | QVariantMap properties; |
| 305 | 343 | |