Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /////////////////////////////////////////////////////////
- /// Pops a Scene off from the stack
- /////////////////////////////////////////////////////////
- void SceneManager::popScene()
- {
- if(scenes.size() > 0)
- {
- Debugger &debugger = Debugger::GetSharedInstance();
- if(currentScene != 0)
- {
- debugger.log("Releasing Scene: " + std::string(typeid(*currentScene).name()));
- currentScene->sceneWillBePoppedOff(); // notify the scene
- currentScene->release(); // release any memory that the scene may contain.
- delete currentScene;
- debugger.log("Popping off Scene: " + std::string(typeid(*currentScene).name()));
- }
- scenes.pop(); // HERE IS EXCEPTION!!
- if(scenes.size() > 0)
- {
- setCurrentScene(scenes.top());
- }
- else
- {
- setCurrentScene(0);
- }
- }
- }
- /////////////////////////////////////////////////////////
- /// Pops of every Scene in the SceneManager.
- /////////////////////////////////////////////////////////
- void SceneManager::popAllScenes()
- {
- while(!scenes.empty())
- {
- popScene();
- }
- }
- /////////////////////////////////////////////////////////
- /// Pushes a Scene off from the Stack.
- /// \param scene A pointer to a Scene, this must be allocated from the heap.
- /////////////////////////////////////////////////////////
- void SceneManager::pushScene(Scene *scene)
- {
- if(scene == 0)
- {
- throw AnaxNullPointerDereferenceException(__FUNCTION__);
- }
- // Since all priorities push on the stack... Won't push in the switch case
- switch(scene->getPriorityLevel())
- {
- /// A <i>Low</i> priority implies that the last Scene will be <i>kept</i> on the Stack
- /// and this Scene will be pushed on.
- case Priority::Low:
- break;
- /// A <i>Medium</i> priority implies that only the last Scene on the stack should be popped off and this
- /// Scene pushed on.
- case Priority::Medium:
- popScene(); // Pop the current scene
- break;
- /// A <i>High</i> priority implies that all the Scene's on the stack should be popped off
- /// and this Scene will be pushed on.
- case Priority::High:
- // Pop of all the scenes
- popAllScenes();
- break;
- }
- // Instead we'll push here
- scenes.push(scene);
- setCurrentScene(scenes.top());
- Debugger::GetSharedInstance().log("Starting up Current Scene: " + std::string(typeid(*currentScene).name()));
- // Setup the Scene
- currentScene->start();
- }
Add Comment
Please, Sign In to add comment