Showing the changes to interface/src/scripting/SelectionScriptingInterface.cpp (1 of 4 files). Show all
Unified · Split
| @@ -83,38 +83,56 @@ bool SelectionScriptingInterface::enableListHighlight(const QString& listName, c · 82 unmodified lines | |||
| 83 | auto highlightStyle = _highlightedListMap.find(listName); | 83 | auto highlightStyle = _highlightedListMap.find(listName); |
| 84 | if (highlightStyle == _highlightedListMap.end()) { | 84 | if (highlightStyle == _highlightedListMap.end()) { |
| 85 | highlightStyle = _highlightedListMap.insert(listName, SelectionHighlightStyle()); | 85 | highlightStyle = _highlightedListMap.insert(listName, SelectionHighlightStyle()); |
| 86 | doSetupHandler = true; | 86 | |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | if (!(*highlightStyle).isBoundToList()) { | 89 | if (!(*highlightStyle).isBoundToList()) { |
| 90 | GameplayObjects currentList = _selectedItemsListMap.value(listName); | 90 | auto currentList = _selectedItemsListMap.find(listName); |
| 91 | if (!currentList.getContainsData()) { | 91 | if (currentList == _selectedItemsListMap.end()) { |
| 92 | _selectedItemsListMap.insert(listName, currentList); | 92 | _selectedItemsListMap.insert(listName, GameplayObjects()); |
| 93 | doSetupHandler = true; | 93 | setupHandler(listName); |
| 94 | // doSetupHandler = true; | ||
| 94 | } | 95 | } |
| 95 | (*highlightStyle).setBoundToList(true); | 96 | (*highlightStyle).setBoundToList(true); |
| 96 | } | 97 | } |
| 97 | 98 | ||
| 98 | (*highlightStyle).fromVariantMap(highlightStyleValues); | 99 | (*highlightStyle).fromVariantMap(highlightStyleValues); |
| 99 | 100 | ||
| 100 | if (doSetupHandler) { | 101 | /* if (doSetupHandler) { |
| 101 | setupHandler(listName); | 102 | setupHandler(listName); |
| 103 | }*/ | ||
| 104 | |||
| 105 | auto mainScene = qApp->getMain3DScene(); | ||
| 106 | if (mainScene) { | ||
| 107 | render::Transaction transaction; | ||
| 108 | transaction.resetSelectionHighlight(listName.toStdString(), (*highlightStyle).getStyle()); | ||
| 109 | mainScene->enqueueTransaction(transaction); | ||
| 110 | } | ||
| 111 | else { | ||
| 112 | qWarning() << "SelectionToSceneHandler::highlightStyleChanged(), Unexpected null scene, possibly during application shutdown"; | ||
| 102 | } | 113 | } |
| 103 | 114 | ||
| 104 | emit highlightStyleChanged(listName); | ||
| 105 | return true; | 115 | return true; |
| 106 | } | 116 | } |
| 107 | 117 | ||
| 108 | bool SelectionScriptingInterface::disableListHighlight(const QString& listName) { | 118 | bool SelectionScriptingInterface::disableListHighlight(const QString& listName) { |
| 109 | auto highlightStyle = _highlightedListMap.find(listName); | 119 | auto highlightStyle = _highlightedListMap.find(listName); |
| 110 | if (highlightStyle != _highlightedListMap.end()) { | 120 | if (highlightStyle != _highlightedListMap.end()) { |
| 111 | if ((*highlightStyle).isBoundToList()) { | 121 | // if ((*highlightStyle).isBoundToList()) { |
| 112 | GameplayObjects currentList = _selectedItemsListMap.value(listName); | ||
| 113 | if (currentList.getContainsData()) { | ||
| 114 | } | ||
| 115 | _highlightedListMap.erase(highlightStyle); | 122 | _highlightedListMap.erase(highlightStyle); |
| 116 | emit selectedItemsListChanged(listName); | 123 | |
| 117 | } | 124 | auto mainScene = qApp->getMain3DScene(); |
| 125 | if (mainScene) { | ||
| 126 | render::Transaction transaction; | ||
| 127 | transaction.removeHighlightFromSelection(listName.toStdString()); | ||
| 128 | mainScene->enqueueTransaction(transaction); | ||
| 129 | } | ||
| 130 | else { | ||
| 131 | qWarning() << "SelectionToSceneHandler::highlightStyleChanged(), Unexpected null scene, possibly during application shutdown"; | ||
| 132 | } | ||
| 133 | // emit highlightStyleRemoved(listName); | ||
| 134 | |||
| 135 | // } | ||
| 118 | } | 136 | } |
| 119 | 137 | ||
| 120 | return true; | 138 | return true; |
| @@ -126,7 +144,7 @@ QVariantMap SelectionScriptingInterface::getListHighlightStyle(const QString& li · 5 unmodified lines | |||
| 126 | 144 | ||
| 127 | render::HighlightStyle SelectionScriptingInterface::getHighlightStyle(const QString& listName) const { | 145 | render::HighlightStyle SelectionScriptingInterface::getHighlightStyle(const QString& listName) const { |
| 128 | auto highlightStyle = _highlightedListMap.find(listName); | 146 | auto highlightStyle = _highlightedListMap.find(listName); |
| 129 | if (highlightStyle != _highlightedListMap.end()) { | 147 | if (highlightStyle == _highlightedListMap.end()) { |
| 130 | return render::HighlightStyle(); | 148 | return render::HighlightStyle(); |
| 131 | } else { | 149 | } else { |
| 132 | return (*highlightStyle).getStyle(); | 150 | return (*highlightStyle).getStyle(); |
| @@ -196,14 +214,6 @@ bool SelectionScriptingInterface::removeListFromMap(const QString& listName) { · 63 unmodified lines | |||
| 196 | } | 214 | } |
| 197 | } | 215 | } |
| 198 | 216 | ||
| 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) { | 217 | void SelectionScriptingInterface::setupHandler(const QString& selectionName) { |
| 208 | auto handler = _handlerMap.find(selectionName); | 218 | auto handler = _handlerMap.find(selectionName); |
| 209 | if (handler == _handlerMap.end()) { | 219 | if (handler == _handlerMap.end()) { |
| @@ -223,14 +233,9 @@ void SelectionToSceneHandler::initialize(const QString& listName) { · 13 unmodified lines | |||
| 223 | _listName = listName; | 233 | _listName = listName; |
| 224 | 234 | ||
| 225 | connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::selectedItemsListChanged, this, &SelectionToSceneHandler::selectedItemsListChanged); | 235 | connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::selectedItemsListChanged, this, &SelectionToSceneHandler::selectedItemsListChanged); |
| 226 | connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::highlightStyleChanged, this, &SelectionToSceneHandler::highlightStyleChanged); | 236 | // connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::highlightStyleChanged, this, &SelectionToSceneHandler::highlightStyleChanged); |
| 237 | // connect(&(*DependencyManager::get<SelectionScriptingInterface>()), &SelectionScriptingInterface::highlightStyleRemoved, this, &SelectionToSceneHandler::highlightStyleRemoved); | ||
| 227 | 238 | ||
| 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 | } | ||
| 234 | } | 239 | } |
| 235 | 240 | ||
| 236 | void SelectionToSceneHandler::selectedItemsListChanged(const QString& listName) { | 241 | void SelectionToSceneHandler::selectedItemsListChanged(const QString& listName) { |
| @@ -284,25 +289,36 @@ void SelectionToSceneHandler::updateSceneFromSelectedList() { · 47 unmodified lines | |||
| 284 | qWarning() << "SelectionToSceneHandler::updateRendererSelectedList(), Unexpected null scene, possibly during application shutdown"; | 289 | qWarning() << "SelectionToSceneHandler::updateRendererSelectedList(), Unexpected null scene, possibly during application shutdown"; |
| 285 | } | 290 | } |
| 286 | } | 291 | } |
| 287 | 292 | /* | |
| 288 | void SelectionToSceneHandler::highlightStyleChanged(const QString& listName) { | 293 | void SelectionToSceneHandler::highlightStyleChanged(const QString& listName) { |
| 289 | if (listName == _listName) { | 294 | if (listName == _listName) { |
| 290 | auto mainScene = qApp->getMain3DScene(); | 295 | auto mainScene = qApp->getMain3DScene(); |
| 291 | if (mainScene) { | 296 | if (mainScene) { |
| 292 | auto thisStyle = DependencyManager::get<SelectionScriptingInterface>()->getHighlightStyle(listName); | 297 | auto thisStyle = DependencyManager::get<SelectionScriptingInterface>()->getHighlightStyle(listName); |
| 293 | render::Transaction transaction; | 298 | render::Transaction transaction; |
| 294 | render::ItemIDs finalList; | ||
| 295 | |||
| 296 | transaction.resetSelectionHighlight(listName.toStdString(), thisStyle); | 299 | transaction.resetSelectionHighlight(listName.toStdString(), thisStyle); |
| 297 | |||
| 298 | mainScene->enqueueTransaction(transaction); | 300 | mainScene->enqueueTransaction(transaction); |
| 299 | } | 301 | } |
| 300 | else { | 302 | else { |
| 301 | qWarning() << "SelectionToSceneHandler::updateRendererSelectedList(), Unexpected null scene, possibly during application shutdown"; | 303 | qWarning() << "SelectionToSceneHandler::highlightStyleChanged(), Unexpected null scene, possibly during application shutdown"; |
| 302 | } | 304 | } |
| 303 | } | 305 | } |
| 304 | } | 306 | } |
| 305 | 307 | ||
| 308 | void SelectionToSceneHandler::highlightStyleRemoved(const QString& listName) { | ||
| 309 | if (listName == _listName) { | ||
| 310 | auto mainScene = qApp->getMain3DScene(); | ||
| 311 | if (mainScene) { | ||
| 312 | render::Transaction transaction; | ||
| 313 | transaction.removeHighlightFromSelection(listName.toStdString()); | ||
| 314 | mainScene->enqueueTransaction(transaction); | ||
| 315 | } | ||
| 316 | else { | ||
| 317 | qWarning() << "SelectionToSceneHandler::highlightStyleRemoved(), Unexpected null scene, possibly during application shutdown"; | ||
| 318 | } | ||
| 319 | } | ||
| 320 | } | ||
| 321 | */ | ||
| 306 | bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) { | 322 | bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) { |
| 307 | auto outlineColor = properties["outlineColor"]; | 323 | auto outlineColor = properties["outlineColor"]; |
| 308 | if (outlineColor.isValid()) { | 324 | if (outlineColor.isValid()) { |