Traverse the scenegraph to populate the tree model
| 244 | |
| 245 | // Traverse the scenegraph to populate the tree model |
| 246 | void EffectEditor::populateEntityListStore() |
| 247 | { |
| 248 | _entityChoices.Clear(); |
| 249 | |
| 250 | std::string selfEntity = game::current::getValue<std::string>(GKEY_ENTITY_SELF); |
| 251 | |
| 252 | // Append the name to the list store |
| 253 | _entityChoices.Add(selfEntity); |
| 254 | |
| 255 | // Create a scenegraph walker to traverse the graph |
| 256 | class EntityFinder : |
| 257 | public scene::NodeVisitor |
| 258 | { |
| 259 | // List to add names to |
| 260 | wxArrayString& _list; |
| 261 | public: |
| 262 | // Constructor |
| 263 | EntityFinder(wxArrayString& list) : |
| 264 | _list(list) |
| 265 | {} |
| 266 | |
| 267 | // Visit function |
| 268 | bool pre(const scene::INodePtr& node) |
| 269 | { |
| 270 | Entity* entity = Node_getEntity(node); |
| 271 | |
| 272 | if (entity != NULL) |
| 273 | { |
| 274 | // Get the entity name and append it to the list store |
| 275 | _list.Add(entity->getKeyValue("name")); |
| 276 | |
| 277 | return false; // don't traverse children if entity found |
| 278 | } |
| 279 | |
| 280 | return true; // traverse children otherwise |
| 281 | } |
| 282 | } finder(_entityChoices); |
| 283 | |
| 284 | GlobalSceneGraph().root()->traverse(finder); |
| 285 | } |
| 286 | |
| 287 | void EffectEditor::revert() |
| 288 | { |