void nsim(Int_t irun) { gROOT->Reset(); stringstream sfname; sfname << "./data/nnzhsim" << setw(3) << setfill('0') << irun << ".root" << ends; // sfname << "./data/nnzhsim_02_" << setw(3) << setfill('0') << irun << ".root" << ends; TFile file(sfname.str().data(),"RECREATE"); // Output file cerr << "-------------------------------" << endl; cerr << " Opened " << sfname.str().data() << endl; JSFSteer jsf; JSFLCFULL full; NNZHSpring spring("NNZHSpring"); stringstream slname; if (irun == 1) { slname << "./data/nnzhsim.root" << ends; // slname << "./data/nnzhsim100.root" << ends; // slname << "./data/nnzhsim200.root" << ends; } else { slname << "./data/nnzhsim" << setw(3) << setfill('0') << irun-1 << ".root" << ends; // slname << "./data/nnzhsim_02_" << setw(3) << setfill('0') << irun-1 << ".root" << ends; } cerr << " Read " << slname.str().data() << endl; cerr << "-------------------------------" << endl; TFile flast(slname.str().data(),"READ"); // Last run file jsf.GetLastRunInfo(&flast); flast.Close(); JSFHadronizer hdr; // JSFQuickSim sim; stdhep = new JSFWriteStdHep(); spring.ReadBases("bases.root"); Int_t maxevt=10100; // Number of events. // Int_t maxevt=100; // Number of events. jsf.Initialize(); printf(" Roots is %g\n",((NNZHBases*)spring.GetBases())->GetRoots()); jsf.BeginRun(30+irun); // Set run number to 30. Int_t ev = 1; while (1) { printf(" start event %d ",ev); if (jsf.Process(ev)) { printf("Processed event %d ",ev); jsf.FillTree(); jsf.Clear(); printf(" End event %d \n",ev); if (ev >= maxevt) break; ev++; } } jsf.Terminate(); //file.Write(); }
void Suspension::calculateSuspensionForPlayer(Object::Player *player, double forceScale) { double front_sep = GET_SETTING("physics.wheel.frontsep", 0.4); double front_z = GET_SETTING("physics.wheel.frontz", 0.68); double back_sep = GET_SETTING("physics.wheel.backsep", 0.4); double back_z = GET_SETTING("physics.wheel.backz", -0.68); static const Math::Point suspensionPoint[] = { Math::Point(front_sep, -0.2 + 0.05,front_z), Math::Point(-front_sep, -0.2 + 0.05, front_z), Math::Point(-back_sep, -0.2 + 0.05, back_z), Math::Point(back_sep, -0.2 + 0.05, back_z), }; // downward axis of suspension springs Math::Point axis = -player->getPhysicalObject()->getUpDirection(); axis.normalize(); double downFactor = calculateDownFactor(axis); player->getPhysicalObject()->setTraction(std::sqrt(downFactor)); for(int wheel = 0; wheel < 4; wheel ++) { Math::Matrix matrix = player->getTransformation(); // suspension attachment point in world space Math::Point point = matrix * suspensionPoint[wheel]; // rotated but not translated suspension attachment point Math::Point forcePoint = suspensionPoint[wheel]; forcePoint.setW(0.0); forcePoint = matrix * forcePoint; // create a Spring object Spring spring(point, axis); spring.setMinLength( GET_SETTING("physics.driving.minlength", 0.0)); spring.setRestLength( GET_SETTING("physics.driving.restlength", 1.0)); spring.setStretchLength( GET_SETTING("physics.driving.stretchlength", 1.0)); // restore last frame's displacement in the Spring object spring.setLastDisplacement( player->getPhysicalObject()->getSpring(wheel)); // calculate and apply actual force Displacement displacement = spring.doRaycast(); double forceFactor = spring.calculateForceFactor(displacement); player->applyForce(axis * forceFactor * downFactor * forceScale, forcePoint); // record displacement for next time player->getPhysicalObject()->setSpring(wheel, displacement); // find the position of the wheel double down = displacement.getDisplacement(); player->setSuspension(wheel, suspensionPoint[wheel] + Math::Point(0.0, -down - GET_SETTING("physics.wheel.diameter", 0.2), 0.0)); } }
double energy(const Vector &x) const { const int sz = x.get_size(); double out = 0; for (int i=0; i<sz; i++) { out += spring(i)*x[i]*x[i]; } return out; }
Vector grad(const Vector &x) const { const int sz = x.get_size(); Vector out(sz); for (int i=0; i<sz; i++) { out[i] = spring(i)*2*x[i]; } return out; }
void Battle::OnUserBattleStatusUpdated( User &user, UserBattleStatus status ) { if ( IsFounderMe() ) { if ( ( &user != &GetMe() ) && !status.IsBot() && ( m_opts.rankneeded != UserStatus::RANK_1 ) && !status.spectator ) { if ( m_opts.rankneeded > UserStatus::RANK_1 && user.GetStatus().rank < m_opts.rankneeded ) { DoAction( _T("Rank limit autospec: ") + user.GetNick() ); ForceSpectator( user, true ); } else if ( m_opts.rankneeded < UserStatus::RANK_1 && user.GetStatus().rank > ( -m_opts.rankneeded - 1 ) ) { DoAction( _T("Rank limit autospec: ") + user.GetNick() ); ForceSpectator( user, true ); } } UserBattleStatus previousstatus = user.BattleStatus(); if ( m_opts.lockexternalbalancechanges ) { if ( previousstatus.team != status.team ) { ForceTeam( user, previousstatus.team ); status.team = previousstatus.team; } if ( previousstatus.ally != status.ally ) { ForceAlly( user, previousstatus.ally ); status.ally = previousstatus.ally; } } } IBattle::OnUserBattleStatusUpdated( user, status ); if ( status.handicap != 0 ) { UiEvents::GetUiEventSender( UiEvents::OnBattleActionEvent ).SendEvent( UiEvents::OnBattleActionData( wxString(_T(" ")) , ( _T("Warning: user ") + user.GetNick() + _T(" got bonus ") ) << status.handicap ) ); } if ( IsFounderMe() ) { if ( ShouldAutoStart() ) { if ( sett().GetBattleLastAutoStartState() ) { if ( !spring().IsRunning() ) StartHostedBattle(); } } } if ( !GetMe().BattleStatus().spectator ) SetAutoUnspec(false); // we don't need auto unspec anymore ShouldAutoUnspec(); #ifndef SL_QT_MODE ui().OnUserBattleStatus( *this, user ); #endif }
EnergyGradAndPrecond energy_grad_and_precond(const Vector &x) const { EnergyGradAndPrecond egpg; egpg.energy = energy(x); egpg.grad = grad(x); egpg.precond = grad(x); const int sz = x.get_size(); for (int i=0; i<sz; i++) { egpg.precond[i] /= spring(i); } return egpg; }
void Battle::StartSpring() { if ( UserExists( GetMe().GetNick() ) && !GetMe().Status().in_game ) { GetMe().BattleStatus().ready = false; SendMyBattleStatus(); GetMe().Status().in_game = spring().Run( *this ); GetMe().SendMyUserStatus(); } ui().OnBattleStarted( *this ); }
// de-inlined from springsys.h: BOOL SSParticle::AddSpring(SSConstraintPoint *bone, Point3 length, float tension, float dampening) { for (int i=0;i<springs.length();i++) { //if it already exists in the list make it stronger if ( springs[i].GetPointConstraint()->GetIndex() == bone->GetIndex() ) { springs[i].SetTension( springs[i].GetTension()*2 ); return false; } } //if it doesn't exist, add a new one SSSpring spring(bone, length, tension, dampening); springs.append(spring); return true; }
void Battle::StartSpring() { if ( UserExists( GetMe().GetNick() ) && !GetMe().Status().in_game ) { GetMe().BattleStatus().ready = false; SendMyBattleStatus(); // set m_generating_script, this will make the script.txt writer realize we're just clients even if using a relayhost m_generating_script = true; GetMe().Status().in_game = spring().Run( *this ); m_generating_script = false; GetMe().SendMyUserStatus(); } ui().OnBattleStarted( *this ); }
void Battle::StartHostedBattle() { if ( UserExists( GetMe().GetNick() ) ) { if ( IsFounderMe() ) { if ( sett().GetBattleLastAutoControlState() ) { FixTeamIDs( (IBattle::BalanceType)sett().GetFixIDMethod(), sett().GetFixIDClans(), sett().GetFixIDStrongClans(), sett().GetFixIDGrouping() ); Autobalance( (IBattle::BalanceType)sett().GetBalanceMethod(), sett().GetBalanceClans(), sett().GetBalanceStrongClans(), sett().GetBalanceGrouping() ); FixColours(); } if ( IsProxy() ) { if ( UserExists( GetProxy()) && !GetUser(GetProxy()).Status().in_game ) { // DON'T set m_generating_script here, it will trick the script generating code to think we're the host wxString hostscript = spring().WriteScriptTxt( *this ); try { wxString path = TowxString(SlPaths::GetDataDir()) + _T("relayhost_script.txt"); if ( !wxFile::Access( path, wxFile::write ) ) { wxLogError( _T("Access denied to script.txt.") ); } wxFile f( path, wxFile::write ); f.Write( hostscript ); f.Close(); } catch (...) {} m_serv.SendScriptToProxy( hostscript ); } } if( GetAutoLockOnStart() ) { SetIsLocked( true ); SendHostInfo( IBattle::HI_Locked ); } sett().SetLastHostMap(TowxString(GetServer().GetCurrentBattle()->GetHostMapName())); sett().SaveSettings(); if ( !IsProxy() ) GetServer().StartHostedBattle(); else if ( UserExists( GetProxy() ) && GetUser(GetProxy()).Status().in_game ) // relayhost is already ingame, let's try to join it { StartSpring(); } } } }
void NotificationManager::ShowNotification( const UiEvents::NotficationData& data ) { if ( sett().GetUseNotificationPopups() ) { const bool spring_running = spring().IsRunning(); const bool disable_if_ingame = sett().Get<bool>( _T("/GUI/NotificationPopupDisableIngame"), true ); if ( m_notification_wrapper && ! ( disable_if_ingame && spring_running ) ) { //! \todo use image from customizations wxBitmap nmp ( charArr2wxBitmap( springlobby_64_png, sizeof(springlobby_64_png) ) ); m_notification_wrapper->Show( nmp, sett().GetNotificationPopupPosition(), data ); } } #ifndef DISABLE_SOUND if ( sett().GetChatPMSoundNotificationEnabled() ) sound().pm(); #endif }
void IBattle::SetHostMap(const wxString& mapname, const wxString& hash) { if ( mapname != m_host_map.name || hash != m_host_map.hash ) { m_map_loaded = false; m_host_map.name = mapname; m_host_map.hash = hash; if ( !m_host_map.hash.IsEmpty() && m_host_map.hash != '0' ) m_map_exists = usync().MapExists( m_host_map.name, m_host_map.hash ); else m_map_exists = usync().MapExists( m_host_map.name ); #ifndef __WXMSW__ //!TODO why not on win? if ( m_map_exists && !spring().IsRunning() ) usync().PrefetchMap( m_host_map.name ); #endif } }
void MainWindow::OnShowSettingsPP( wxCommandEvent& ) { wxArrayString params; params.push_back(_T("-w")); spring().LaunchEngine(params); /* if ( se_frame && se_frame_active ) { se_frame->updateAllControls(); se_frame->Raise(); return; } se_frame = new settings_frame(this,wxT("SpringSettings")); se_frame_active = true; se_frame->updateAllControls(); se_frame->Show(); */ }
void IBattle::SetLocalMap(const UnitSyncMap& map) { if ( map.name != m_local_map.name || map.hash != m_local_map.hash ) { m_local_map = map; m_map_loaded = true; if ( !m_host_map.hash.IsEmpty() && m_host_map.hash != '0' ) m_map_exists = usync().MapExists( m_host_map.name, m_host_map.hash ); else m_map_exists = usync().MapExists( m_host_map.name ); #ifndef __WXMSW__ if ( m_map_exists && !spring().IsRunning() ) usync().PrefetchMap( m_host_map.name ); #endif if ( IsFounderMe() ) // save all rects infos { } } }
void Balls::event() { beatcounter++; raincounter++; speed = (uint) (((double) speed / 255) * 20); if (speed <= 5) { speed = 5; } //cout << speed <<endl; switch (type) { case 0: rising(); break; case 1: falling(); break; case 2: expandimp(); break; case 3: explodingDimmed(); break; case 4: spring(); break; case 5: raining(); break; case 6: imploding(); break; case 7: sideways(); break; case 8: moon(); break; case 9: mooning(); break; } }
void Battle::StartHostedBattle() { if ( UserExists( GetMe().GetNick() ) ) { if ( IsFounderMe() ) { if ( sett().GetBattleLastAutoControlState() ) { FixTeamIDs( (IBattle::BalanceType)sett().GetFixIDMethod(), sett().GetFixIDClans(), sett().GetFixIDStrongClans(), sett().GetFixIDGrouping() ); Autobalance( (IBattle::BalanceType)sett().GetBalanceMethod(), sett().GetBalanceClans(), sett().GetBalanceStrongClans(), sett().GetBalanceGrouping() ); FixColours(); } if ( IsProxy() ) { wxString hostscript = spring().WriteScriptTxt( *this ); try { wxString path = sett().GetCurrentUsedDataDir() + wxFileName::GetPathSeparator() + _T("relayhost_script.txt"); if ( !wxFile::Access( path, wxFile::write ) ) { wxLogError( _T("Access denied to script.txt.") ); } wxFile f( path, wxFile::write ); f.Write( hostscript ); f.Close(); } catch (...) {} m_serv.SendScriptToProxy( hostscript ); } if( IsFounderMe() && GetAutoLockOnStart() ) { SetIsLocked( true ); SendHostInfo( IBattle::HI_Locked ); } sett().SetLastHostMap( GetServer().GetCurrentBattle()->GetHostMapName() ); sett().SaveSettings(); if ( !IsProxy() ) GetServer().StartHostedBattle(); } } }
void World::generateLevel() { float y = Platform::PLATFORM_HEIGHT / 2; float maxJumpHeight = Bob::BOB_JUMP_VELOCITY * Bob::BOB_JUMP_VELOCITY / (2 * -gravity.y); while(y < WORLD_HEIGHT - WORLD_WIDTH / 2) { int type = MathUtils::randomFloat() > 0.8f ? Platform::PLATFORM_TYPE_MOVING : Platform::PLATFORM_TYPE_STATIC; float x = MathUtils::randomFloat() * (WORLD_WIDTH - Platform::PLATFORM_WIDTH) + Platform::PLATFORM_WIDTH / 2; Platform platform(type, x, y); platforms.push_back(platform); if(MathUtils::randomFloat() > 0.9f && type != Platform::PLATFORM_TYPE_MOVING) { Spring spring(platform.position.x, platform.position.y + Platform::PLATFORM_HEIGHT / 2 + Spring::SPRING_HEIGHT / 2); springs.push_back(spring); } if(y > WORLD_HEIGHT / 3 && MathUtils::randomFloat() > 0.8f) { Squirrel squirrel(platform.position.x + MathUtils::randomFloat(), platform.position.y + Squirrel::SQUIRREL_HEIGHT + MathUtils::randomFloat() * 2); squirrels.push_back(squirrel); } if(MathUtils::randomFloat() > 0.6f) { Coin coin(platform.position.x + MathUtils::randomFloat(), platform.position.y + Coin::COIN_HEIGHT + MathUtils::randomFloat() * 3); coins.push_back(coin); } y += (maxJumpHeight - 0.5f); y -= MathUtils::randomFloat() * (maxJumpHeight / 3); } castle = Castle(WORLD_WIDTH / 2, y); }
/** @brief StartSpring * * @todo: document this function */ void NoGuiSinglePlayerBattle::StartSpring() { spring().Run( *this ); // ui().OnSpringStarting(); //stops torrent system }
void SinglePlayerBattle::StartSpring() { spring().Run( *this ); }
bool CalSaver::saveXmlCoreMesh(const std::string& strFilename, CalCoreMesh *pCoreMesh) { std::stringstream str; vsxTiXmlDocument doc(strFilename); vsxTiXmlElement mesh("MESH"); //mesh.SetAttribute("MAGIC",Cal::MESH_XMLFILE_MAGIC); mesh.SetAttribute("VERSION",Cal::LIBRARY_VERSION); mesh.SetAttribute("NUMSUBMESH",pCoreMesh->getCoreSubmeshCount()); // get the submesh vector std::vector<CalCoreSubmesh *>& vectorCoreSubmesh = pCoreMesh->getVectorCoreSubmesh(); // write all core submeshes int submeshId; for(submeshId = 0; submeshId < (int)vectorCoreSubmesh.size(); ++submeshId) { CalCoreSubmesh *pCoreSubmesh=vectorCoreSubmesh[submeshId]; vsxTiXmlElement submesh("SUBMESH"); submesh.SetAttribute("NUMVERTICES",pCoreSubmesh->getVertexCount()); submesh.SetAttribute("NUMFACES",pCoreSubmesh->getFaceCount()); submesh.SetAttribute("MATERIAL",pCoreSubmesh->getCoreMaterialThreadId()); submesh.SetAttribute("NUMLODSTEPS",pCoreSubmesh->getLodCount()); submesh.SetAttribute("NUMSPRINGS",pCoreSubmesh->getSpringCount()); submesh.SetAttribute("NUMTEXCOORDS",pCoreSubmesh->getVectorVectorTextureCoordinate().size()); // get the vertex, face, physical property and spring vector std::vector<CalCoreSubmesh::Vertex>& vectorVertex = pCoreSubmesh->getVectorVertex(); std::vector<CalCoreSubmesh::Face>& vectorFace = pCoreSubmesh->getVectorFace(); std::vector<CalCoreSubmesh::PhysicalProperty>& vectorPhysicalProperty = pCoreSubmesh->getVectorPhysicalProperty(); std::vector<CalCoreSubmesh::Spring>& vectorSpring = pCoreSubmesh->getVectorSpring(); // get the texture coordinate vector vector std::vector<std::vector<CalCoreSubmesh::TextureCoordinate> >& vectorvectorTextureCoordinate = pCoreSubmesh->getVectorVectorTextureCoordinate(); // write all vertices int vertexId; for(vertexId = 0; vertexId < (int)vectorVertex.size(); ++vertexId) { CalCoreSubmesh::Vertex& Vertex = vectorVertex[vertexId]; vsxTiXmlElement vertex("VERTEX"); vertex.SetAttribute("ID",vertexId); vertex.SetAttribute("NUMINFLUENCES",Vertex.vectorInfluence.size()); // write the vertex data vsxTiXmlElement position("POS"); str.str(""); str << Vertex.position.x << " " << Vertex.position.y << " " << Vertex.position.z; vsxTiXmlText positiondata(str.str()); position.InsertEndChild(positiondata); vertex.InsertEndChild(position); vsxTiXmlElement normal("NORM"); str.str(""); str << Vertex.normal.x << " " << Vertex.normal.y << " " << Vertex.normal.z; vsxTiXmlText normaldata(str.str()); normal.InsertEndChild(normaldata); vertex.InsertEndChild(normal); if(Vertex.collapseId!=-1) { vsxTiXmlElement collapse("COLLAPSEID"); str.str(""); str << Vertex.collapseId; vsxTiXmlText collapseid(str.str()); collapse.InsertEndChild(collapseid); vertex.InsertEndChild(collapse); vsxTiXmlElement collapsecount("COLLAPSECOUNT"); str.str(""); str << Vertex.faceCollapseCount; vsxTiXmlText collapsecountdata(str.str()); collapsecount.InsertEndChild(collapsecountdata); vertex.InsertEndChild(collapsecount); } // write all texture coordinates of this vertex int textureCoordinateId; for(textureCoordinateId = 0; textureCoordinateId < (int)vectorvectorTextureCoordinate.size(); ++textureCoordinateId) { CalCoreSubmesh::TextureCoordinate& textureCoordinate = vectorvectorTextureCoordinate[textureCoordinateId][vertexId]; vsxTiXmlElement tex("TEXCOORD"); str.str(""); str << textureCoordinate.u << " " << textureCoordinate.v; vsxTiXmlText texdata(str.str()); tex.InsertEndChild(texdata); vertex.InsertEndChild(tex); } // write all influences of this vertex int influenceId; for(influenceId = 0; influenceId < (int)Vertex.vectorInfluence.size(); ++influenceId) { CalCoreSubmesh::Influence& Influence = Vertex.vectorInfluence[influenceId]; vsxTiXmlElement influence("INFLUENCE"); influence.SetAttribute("ID",Influence.boneId); str.str(""); str << Influence.weight; vsxTiXmlText influencedata(str.str()); influence.InsertEndChild(influencedata); vertex.InsertEndChild(influence); } // save the physical property of the vertex if there are springs in the core submesh if(pCoreSubmesh->getSpringCount() > 0) { // write the physical property of this vertex if there are springs in the core submesh CalCoreSubmesh::PhysicalProperty& physicalProperty = vectorPhysicalProperty[vertexId]; vsxTiXmlElement physique("PHYSIQUE"); str.str(""); str << physicalProperty.weight; vsxTiXmlText physiquedata(str.str()); physique.InsertEndChild(physiquedata); vertex.InsertEndChild(physique); } submesh.InsertEndChild(vertex); } // write all springs int springId; for(springId = 0; springId < (int)pCoreSubmesh->getSpringCount(); ++springId) { CalCoreSubmesh::Spring& Spring = vectorSpring[springId]; vsxTiXmlElement spring("SPRING"); str.str(""); str << Spring.vertexId[0]<< " " << Spring.vertexId[1]; spring.SetAttribute("VERTEXID",str.str()); str.str(""); str << Spring.springCoefficient; spring.SetAttribute("COEF",str.str()); str.str(""); str << Spring.idleLength; spring.SetAttribute("LENGTH",str.str()); submesh.InsertEndChild(spring); } // write all faces int faceId; for(faceId = 0; faceId < (int)vectorFace.size(); ++faceId) { CalCoreSubmesh::Face& Face = vectorFace[faceId]; vsxTiXmlElement face("FACE"); str.str(""); str << Face.vertexId[0]<< " " << Face.vertexId[1]<< " " << Face.vertexId[2]; face.SetAttribute("VERTEXID",str.str()); submesh.InsertEndChild(face); } mesh.InsertEndChild(submesh); } doc.InsertEndChild(mesh); if(!doc.SaveFile()) { CalError::setLastError(CalError::FILE_WRITING_FAILED, __FILE__, __LINE__, strFilename); return false; } return true; }
void OfflineBattle::StartSpring() { spring().Run(*this); }
void SinglePlayerBattle::StartSpring() { spring().Run( *this ); ui().OnSpringStarting(); }
int SasiApp::exec() { QSplashScreen* splash = 0; QPixmap splash_pixmap; QWidget* show_screen = desktop()->screen( 0 ); if ( splash_pixmap.load( SLcustomizations().GraphicsDir() + "/splash.png" ) ) { splash = new QSplashScreen(show_screen,splash_pixmap); splash->show(); } wxLogChain* logchain = 0; wxLog::SetActiveTarget( new wxLogChain( new wxLogStream( &std::cout ) ) ); //this needs to called _before_ mainwindow instance is created wxInitAllImageHandlers(); wxFileSystem::AddHandler(new wxZipFSHandler); wxSocketBase::Initialize(); usync().FastLoadUnitSyncLibInit( ); QDeclarativeView view(show_screen); QString qmldir; try { qmldir = SLcustomizations().QmlDir(); } catch ( Customizations::DataException& e ) { //for some f****d up reason the strings get internally f****d up w/o the hardcopy QList<QString> copy = e.errors_; QErrorWindow error_win ( copy ); return error_win.exec(); } AudioManager audio_manager (this); audio_manager.start(); view.engine()->addImportPath( qmldir ); #ifdef __WXMSW__ //for webkit declarative plugin view.engine()->addImportPath( QDir( QCoreApplication::applicationDirPath() + "/imports").absolutePath() ); #endif // Visual initialization view.engine()->addImageProvider("minimaps", new MinimapImageProvider); view.engine()->addImageProvider("graphics", new GraphicsProvider); view.engine()->addImageProvider("sides", new SideImageProvider); #if USE_OPENGL QGLFormat format = QGLFormat::defaultFormat(); #ifdef Q_WS_MAC format.setSampleBuffers(true); #else format.setSampleBuffers(false); #endif QGLWidget *glWidget = new QGLWidget(format, &view); view.setViewport(glWidget); view.setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate); #endif view.setAttribute(Qt::WA_OpaquePaintEvent); view.setAttribute(Qt::WA_NoSystemBackground); view.setResizeMode(QDeclarativeView::SizeRootObjectToView); MaplistModel maplist_model( usync().GetMapList() ); SkirmishModel skirmish_model; SideModel side_model( SLcustomizations().GetModname() ); PresetModel preset_model(this); ScreenResolutionModel screenres_model(this); spring().connect( &spring(), SIGNAL(springStarted()), &audio_manager, SLOT(pause())); spring().connect( &spring(), SIGNAL(springStopped()), &audio_manager, SLOT(resume())); QObject::connect((QObject*)view.engine(), SIGNAL(quit()), this, SLOT(quit())); QObject::connect((QObject*)view.engine(), SIGNAL(quit()), &audio_manager, SLOT(doQuit())); QDeclarativeContext* ctxt = view.rootContext(); ctxt->setContextProperty("maplistModel", &maplist_model ); ctxt->setContextProperty("skirmishModel", &skirmish_model ); ctxt->setContextProperty("sideModel", &side_model ); ctxt->setContextProperty("audioManager", &audio_manager ); ctxt->setContextProperty("presetModel", &preset_model ); ctxt->setContextProperty("screenresModel", &screenres_model ); const int sleep_seconds = -1; for ( int i = sleep_seconds; splash && i > 0; i-- ) { splash->showMessage( QString("sleeping for %1 seconds, just to show you this").arg( i ), Qt::AlignHCenter | Qt::AlignBottom ); processEvents(); sleep( 1 ); } // view.showFullScreen(); if ( splash ) splash->finish(&view); view.setSource(QUrl(qmldir + "/main.qml")); QObject::connect(this, SIGNAL(appLoaded()), (QObject*)view.rootObject(), SLOT(onAppLoaded())); QList<QDeclarativeError> errors = view.errors(); if ( errors.size() ) { QErrorWindow error_window ( errors ); return error_window.exec(); } view.show(); view.setFocus(); emit appLoaded(); int ret = QApplication::exec(); audio_manager.wait( 5 /*seconds*/ ); return ret; }