/*! \qmlmethod Scene* Game::popScene() \brief Suspends and remove the top Scene from the scene stack. Suspends and remove the current Scene from stack. If exitAnimation property the exit will be animated. When there is no scene on stack, it will do nothing. \sa pushScene */ Scene* Game::popScene() { if(m_sceneStack.isEmpty()) return NULL; Scene *topScene = m_sceneStack.pop(); emit stackLevelChanged(); if(topScene){ deactivateScene(topScene); if(!m_sceneStack.isEmpty()){ attachScene(m_sceneStack.top()); } if(!triggerExitAnimation(topScene)){ if(!m_sceneStack.isEmpty()){ activateScene(m_sceneStack.top()); }else{ emit currentSceneChanged(); } topScene->setVisible(false); } } return topScene; }
void Game::activateScene(Scene *scene) { if(!scene){ return; } scene->setRunning(true); scene->setEnabled(true); scene->setFocus(true, Qt::OtherFocusReason); emit currentSceneChanged(); }
void Game::setCurrentScene(Scene *currentScene) { if (m_currentScene != currentScene) { if (m_currentScene) { if (m_viewport) { m_viewport->setVisible(false); m_viewport = 0; } m_currentScene->setRunning(false); m_currentScene->setVisible(false); } m_currentScene = currentScene; if (m_currentScene) { m_currentScene->setGame(this); if ((m_viewport = m_currentScene->viewport())) { m_viewport->setParent(this); m_viewport->setParentItem(this); m_viewport->setScene(m_currentScene); m_viewport->setWidth(width()); m_viewport->setHeight(height()); m_viewport->setContentWidth(m_currentScene->width()); m_viewport->setContentHeight(m_currentScene->height()); m_viewport->updateMaxOffsets(); m_viewport->setVisible(true); m_currentScene->setParentItem(m_viewport); } else { m_currentScene->setParent(this); m_currentScene->setParentItem(this); } m_currentScene->setVisible(true); m_currentScene->setRunning(true); } emit currentSceneChanged(); } }
void Game::handleExitAnimationRunningChanged(bool running) { if(running) return; disconnect(sender(), 0, this, SLOT(handleExitAnimationRunningChanged(bool))); if(m_exitScene){ if(m_exitScene->viewport()){ m_exitScene->viewport()->setVisible(false); } m_exitScene->setVisible(false); } m_exitScene = NULL; if(!m_sceneStack.isEmpty()){ if(!m_sceneStack.top()->running()){ activateScene(m_sceneStack.top()); } }else{ emit currentSceneChanged(); } }
void Scenery3d::loadSceneCompleted() { S3DScene* result = currentLoadFuture.result(); progressBar->setValue(100); StelApp::getInstance().removeProgressBar(progressBar); progressBar=Q_NULLPTR; if(!result) { showMessage(q_("Could not load scene, please check log for error messages!")); return; } else showMessage(q_("Scene successfully loaded.")); //do stuff that requires the main thread const SceneInfo& info = result->getSceneInfo(); //move to the location specified by the scene LandscapeMgr* lmgr = GETSTELMODULE(LandscapeMgr); bool landscapeSetsLocation=lmgr->getFlagLandscapeSetsLocation(); lmgr->setFlagLandscapeSetsLocation(true); lmgr->setCurrentLandscapeName(info.landscapeName, 0.); // took a second, implicitly. // Switched to immediate landscape loading: Else, // Landscape and Navigator at this time have old coordinates! But it should be possible to // delay rot_z computation up to this point and live without an own location section even // with meridian_convergence=from_grid. lmgr->setFlagLandscapeSetsLocation(landscapeSetsLocation); // restore if (info.hasLocation()) { qCDebug(scenery3d) << "Setting location to given coordinates"; StelApp::getInstance().getCore()->moveObserverTo(*info.location, 0., 0.); } else qCDebug(scenery3d) << "No coordinates given in scenery3d.ini"; if (info.hasLookAtFOV()) { qCDebug(scenery3d) << "Setting orientation"; Vec3f lookat=currentLoadScene.lookAt_fov; // This vector is (az_deg, alt_deg, fov_deg) Vec3d v; StelUtils::spheToRect(lookat[0]*M_PI/180.0, lookat[1]*M_PI/180.0, v); mvMgr->setViewDirectionJ2000(StelApp::getInstance().getCore()->altAzToJ2000(v, StelCore::RefractionOff)); mvMgr->zoomTo(lookat[2]); } else qCDebug(scenery3d) << "No orientation given in scenery3d.ini"; //clear loading scene currentLoadScene = SceneInfo(); emit loadingSceneIDChanged(QString()); //switch scenes delete currentScene; currentScene = result; //show the scene setEnableScene(true); emit currentSceneChanged(info); emit currentSceneIDChanged(info.id); }