void Application::setViewport(std::string const &name) { AScene *ptr; _window->removeAllViewports(); if (_currentScene) { _currentScene->setVisible(false); _currentScene->delViewport(); _currentScene = NULL; } _mouse->setEventCallback(NULL); _keyboard->setEventCallback(NULL); ptr = _sceneMap[name]; ptr->setVisible(true); if (!ptr) throw graphicException("Failed to load " + name + " scene"); ptr->createViewport(); _mouse->setEventCallback(ptr); _keyboard->setEventCallback(ptr); _currentScene = ptr; }
void SceneManager::handleMessage(e_message type, bool activate, std::string const & sceneName) { AScene *tmp; t_iter it; tmp = this->get(sceneName); switch (type) { case MSG_ACTIVE: if (sceneName.empty()) this->setActiveAll(activate); else { if (tmp) tmp->setActive(activate); else std::cout << "existe pas " << sceneName << std::endl; } break; case MSG_VISIBLE: if (sceneName.empty()) this->setVisibleAll(activate); else { if (tmp) tmp->setVisible(activate); } break; default: if (tmp) tmp->receiveMessage(type, activate); else if (sceneName.empty()) { it = this->collection_.begin(); while (it != this->collection_.end()) { (*it)->receiveMessage(type, activate); ++it; } } } }