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 | bool SelectionScriptingInterface::enableListHighlight(const QString& listName, const QVariantMap& highlightStyleValues) { | 80 | bool SelectionScriptingInterface::enableListHighlight(const QString& listName, const QVariantMap& highlightStyleValues) { |
| 81 | bool doSetupHandler = false; | ||
| 82 | |||
| 81 | auto highlightStyle = _highlightedListMap.find(listName); | 83 | auto highlightStyle = _highlightedListMap.find(listName); |
| 82 | if (highlightStyle == _highlightedListMap.end()) { | 84 | if (highlightStyle == _highlightedListMap.end()) { |
| 83 | highlightStyle = _highlightedListMap.insert(listName, SelectionHighlightStyle()); | 85 | highlightStyle = _highlightedListMap.insert(listName, SelectionHighlightStyle()); |
| 86 | doSetupHandler = true; | ||
| 84 | } | 87 | } |
| 85 | 88 | ||
| 86 | if (!(*highlightStyle).isBoundToList()) { | 89 | if (!(*highlightStyle).isBoundToList()) { |
| 87 | GameplayObjects currentList = _selectedItemsListMap.value(listName); | 90 | GameplayObjects currentList = _selectedItemsListMap.value(listName); |
| 88 | if (!currentList.getContainsData()) { | 91 | if (!currentList.getContainsData()) { |
| 89 | _selectedItemsListMap.insert(listName, currentList); | 92 | _selectedItemsListMap.insert(listName, currentList); |
| 90 | highlightStyleChanged(listName); | 93 | doSetupHandler = true; |
| 91 | } | 94 | } |
| 92 | (*highlightStyle).setBoundToList(true); | 95 | (*highlightStyle).setBoundToList(true); |
| 93 | } | 96 | } |
| 94 | 97 | ||
| 95 | (*highlightStyle).fromVariantMap(highlightStyleValues); | 98 | (*highlightStyle).fromVariantMap(highlightStyleValues); |
| 96 | 99 | ||
| 100 | if (doSetupHandler) { | ||
| 101 | setupHandler(listName); | ||
| 102 | } | ||
| 97 | 103 | ||
| 98 | emit highlightStyleChanged(listName); | 104 | emit highlightStyleChanged(listName); |
| 99 | return true; | 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 | SelectionToSceneHandler::SelectionToSceneHandler() { | 219 | SelectionToSceneHandler::SelectionToSceneHandler() { |
| 195 | } | 220 | } |
| 196 | 221 | ||
| 197 | void SelectionToSceneHandler::initialize(const QString& listName) { | 222 | void SelectionToSceneHandler::initialize(const QString& listName) { |
| 198 | _listName = listName; | 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 | void SelectionToSceneHandler::selectedItemsListChanged(const QString& listName) { | 236 | void SelectionToSceneHandler::selectedItemsListChanged(const QString& listName) { |
| @@ -251,18 +286,20 @@ void SelectionToSceneHandler::updateSceneFromSelectedList() { · 49 unmodified lines | |||
| 251 | } | 286 | } |
| 252 | 287 | ||
| 253 | void SelectionToSceneHandler::highlightStyleChanged(const QString& listName) { | 288 | void SelectionToSceneHandler::highlightStyleChanged(const QString& listName) { |
| 254 | auto mainScene = qApp->getMain3DScene(); | 289 | if (listName == _listName) { |
| 255 | if (mainScene) { | 290 | auto mainScene = qApp->getMain3DScene(); |
| 256 | auto thisStyle = DependencyManager::get<SelectionScriptingInterface>()->getHighlightStyle(listName); | 291 | if (mainScene) { |
| 257 | render::Transaction transaction; | 292 | auto thisStyle = DependencyManager::get<SelectionScriptingInterface>()->getHighlightStyle(listName); |
| 258 | render::ItemIDs finalList; | 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); | 298 | mainScene->enqueueTransaction(transaction); |
| 263 | } | 299 | } |
| 264 | else { | 300 | else { |
| 265 | qWarning() << "SelectionToSceneHandler::updateRendererSelectedList(), Unexpected null scene, possibly during application shutdown"; | 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 | return true; | 338 | return true; |
| 302 | } | 339 | } |
| 340 | |||
| 303 | QVariantMap SelectionHighlightStyle::toVariantMap() const { | 341 | QVariantMap SelectionHighlightStyle::toVariantMap() const { |
| 304 | QVariantMap properties; | 342 | QVariantMap properties; |
| 305 | 343 | ||