void Clock::start() { m_timer->start(); updateTime(); }
void Gource::logic(float t, float dt) { if(draw_loading) return; if(message_timer>0.0f) message_timer -= dt; if(splash>0.0f) splash -= dt; //init log file if(commitlog == 0) { try { commitlog = determineFormat(logfile); } catch(SeekLogException& exception) { throw SDLAppException("unable to read log file"); } if(commitlog == 0) { //if not in a git dir and no log file, show help if(logfile.size() == 0 || logfile == ".") { SDL_Quit(); throw SDLAppException("", true); } else if(SDLAppDirExists(logfile)) { throw SDLAppException("directory not supported"); } else { throw SDLAppException("unsupported log format (you may need to regenerate your log file)"); } } if(gGourceSettings.start_position>0.0) { seekTo(gGourceSettings.start_position); } } slider.logic(dt); //apply rotation if(rotate_angle != 0.0f) { float s = sinf(rotate_angle); float c = cosf(rotate_angle); root->rotate(s, c); for(std::map<std::string,RUser*>::iterator it = users.begin(); it!=users.end(); it++) { RUser* user = it->second; vec2f userpos = user->getPos(); user->setPos(userpos.rotate(s, c)); } rotate_angle = 0.0f; } //still want to update camera while paused if(paused) { updateBounds(); updateQuadTree(); updateCamera(dt); return; } // get more entries if(commitqueue.size() == 0) { readLog(); } //loop in attempt to find commits if(commitqueue.size()==0 && commitlog->isSeekable() && gGourceSettings.loop) { first_read=true; seekTo(0.0); readLog(); } if(currtime==0 && commitqueue.size()) { currtime = lasttime = commitqueue[0].timestamp; subseconds = 0.0; } //set current time float time_inc = (dt * 86400.0 * gGourceSettings.days_per_second); int seconds = (int) time_inc; subseconds += time_inc - ((float) seconds); if(subseconds >= 1.0) { currtime += (int) subseconds; subseconds -= (int) subseconds; } currtime += seconds; // delete files for(std::vector<RFile*>::iterator it = gGourceRemovedFiles.begin(); it != gGourceRemovedFiles.end(); it++) { deleteFile(*it); } gGourceRemovedFiles.clear(); //add commits up until the current time while(commitqueue.size() > 0) { RCommit commit = commitqueue[0]; if(gGourceSettings.auto_skip_seconds>=0.0 && idle_time >= gGourceSettings.auto_skip_seconds) { currtime = lasttime = commit.timestamp; idle_time = 0.0; } if(commit.timestamp > currtime) break; processCommit(commit, t); currtime = lasttime = commit.timestamp; subseconds = 0.0; commitqueue.pop_front(); } //reset loop counters gGourceUserInnerLoops = 0; gGourceDirNodeInnerLoops = 0; gGourceFileInnerLoops = 0; interactUsers(); updateUsers(t, dt); updateQuadTree(); updateBounds(); updateDirs(dt); updateCamera(dt); updateTime(commitqueue.size() > 0 ? currtime : lasttime); }
void Clock::addIncorrectWord(int score) { if (m_timer->addIncorrectWord(score)) { updateTime(); } }
bool Collectiondb::load ( bool isDump ) { char dname[1024]; // MDW: sprintf ( dname , "%s/collections/" , g_hostdb.m_dir ); sprintf ( dname , "%s" , g_hostdb.m_dir ); Dir d; d.set ( dname ); if ( ! d.open ()) return log("admin: Could not load collection config " "files."); // note it log(LOG_INIT,"admin: Loading collection config files."); // . scan through all subdirs in the collections dir // . they should be like, "coll.main/" and "coll.mycollection/" char *f; while ( ( f = d.getNextFilename ( "*" ) ) ) { // skip if first char not "coll." if ( strncmp ( f , "coll." , 5 ) != 0 ) continue; // must end on a digit (i.e. coll.main.0) if ( ! is_digit (f[gbstrlen(f)-1]) ) continue; // point to collection char *coll = f + 5; // NULL terminate at . char *pp = strchr ( coll , '.' ); if ( ! pp ) continue; *pp = '\0'; // get collnum collnum_t collnum = atol ( pp + 1 ); // add it if ( !addRec ( coll , NULL , 0 , false , collnum , isDump , true ) ) return false; } // note it log(LOG_INIT,"admin: Loaded data for %li collections. Ranging from " "collection #0 to #%li.",m_numRecsUsed,m_numRecs-1); // update the time updateTime(); // don't clean the tree if just dumpin if ( isDump ) return true; // remove any nodes with illegal collnums Rdb *r; //r = g_indexdb.getRdb(); //r->m_tree.cleanTree ((char **)r->m_bases); r = g_posdb.getRdb(); r->m_tree.cleanTree ((char **)r->m_bases); //r = g_datedb.getRdb(); //r->m_tree.cleanTree ((char **)r->m_bases); r = g_titledb.getRdb(); r->m_tree.cleanTree ((char **)r->m_bases); //r = g_revdb.getRdb(); //r->m_tree.cleanTree ((char **)r->m_bases); //r = g_sectiondb.getRdb(); //r->m_tree.cleanTree ((char **)r->m_bases); //r = g_checksumdb.getRdb(); //r->m_tree.cleanTree ((char **)r->m_bases); //r = g_tfndb.getRdb(); //r->m_tree.cleanTree ((char **)r->m_bases); r = g_spiderdb.getRdb(); r->m_tree.cleanTree ((char **)r->m_bases); r = g_doledb.getRdb(); r->m_tree.cleanTree ((char **)r->m_bases); // success return true; }
void JumpingGhostDebugger::update(const sf::Time& frameTime) { updateTime(m_renderTime, frameTime); if (m_renderTime == sf::Time::Zero) { setDisposed(); } }
// . MDW: TODO: bring this back when we have a subdir for each collection // . add a new rec // . returns false and sets g_errno on error // . use a collnum_t of -1 if it is new bool Collectiondb::addRec ( char *coll , char *cpc , long cpclen , bool isNew , collnum_t collnum , bool isDump , bool saveIt ) { // sanity check if ( ( isNew && collnum >= 0) || (!isNew && collnum < 0) ) { log(LOG_LOGIC,"admin: Bad parms passed to addRec."); char *xx = NULL; *xx = 0; } // ensure coll name is legit char *p = coll; for ( ; *p ; p++ ) { if ( is_alnum_a(*p) ) continue; if ( *p == '-' ) continue; break; } if ( *p ) { g_errno = EBADENGINEER; log("admin: \"%s\" is a malformed collection name because it " "contains the '%c' character.",coll,*p); return false; } // . scan for holes // . i is also known as the collection id long i ; if ( collnum >= 0 ) i = (long)collnum; else for ( i = 0 ; i < m_numRecs ; i++ ) if ( ! m_recs[i] ) break; // ceiling? if ( i >= MAX_COLLS ) { g_errno = ENOBUFS; return log("admin: Limit of %li collection reached. " "Collection not created.",(long)MAX_COLLS); } // if empty... bail, no longer accepted, use "main" if ( ! coll || !coll[0] ) { g_errno = EBADENGINEER; return log("admin: Trying to create a new collection " "but no collection name provided. Use the \"c\" " "cgi parameter to specify it."); } // or if too big if ( gbstrlen(coll) > MAX_COLL_LEN ) { g_errno = ENOBUFS; return log("admin: Trying to create a new collection " "whose name \"%s\" of %i chars is longer than the " "max of %li chars.",coll,gbstrlen(coll), (long)MAX_COLL_LEN); } // ensure does not already exist in memory if ( getCollnum ( coll ) >= 0 ) { g_errno = EEXIST; return log("admin: Trying to create collection \"%s\" but " "already exists in memory.",coll); } // MDW: ensure not created on disk since time of last load char dname[512]; sprintf(dname, "%scoll.%s.%li/",g_hostdb.m_dir,coll,i); if ( isNew && opendir ( dname ) ) { g_errno = EEXIST; return log("admin: Trying to create collection %s but " "directory %s already exists on disk.",coll,dname); } //char fname[512]; // ending '/' is ALWAYS included in g_hostdb.m_dir //sprintf ( fname , "%s%li.%s.conf",g_hostdb.m_dir,i,coll); //File f; //f.set ( fname ); //if ( f.doesExist() ) { // g_errno = EEXIST; // return log("admin: Trying to create collection \"%s\" but " // "file %s already exists on disk.",coll,fname); //} // create the record in memory m_recs[i] = new (CollectionRec); if ( ! m_recs[i] ) return log("admin: Failed to allocated %li bytes for new " "collection record for \"%s\".", (long)sizeof(CollectionRec),coll); mnew ( m_recs[i] , sizeof(CollectionRec) , "CollectionRec" ); // get copy collection CollectionRec *cpcrec = NULL; if ( cpc && cpc[0] ) cpcrec = getRec ( cpc , cpclen ); if ( cpc && cpc[0] && ! cpcrec ) log("admin: Collection \"%s\" to copy config from does not " "exist.",cpc); // get the default.conf from working dir if there g_parms.setToDefault( (char *)m_recs[i] ); if ( isNew ) { // the default conf file char tmp1[1024]; sprintf ( tmp1 , "%sdefault.conf" , g_hostdb.m_dir ); // . set our parms from the file. // . accepts OBJ_COLLECTIONREC or OBJ_CONF g_parms.setFromFile ( m_recs[i] , NULL , tmp1 ); } // this will override all if ( cpcrec ) { // copy it, but not the timedb hashtable, etc. long size = (char *)&(cpcrec->m_END_COPY) - (char *)cpcrec; // JAB: bad memcpy - no donut! // this is not how objects are supposed to be copied!!! memcpy ( m_recs[i] , cpcrec , size);//sizeof(CollectionRec) ); // perform the cleanup that a copy constructor might do... //for (int rx = 0; rx < MAX_FILTERS; rx++) // m_recs[i]->m_pRegExParser[rx] = NULL; // don't NUKE the filters! // m_recs[i]->m_numRegExs = 0; // OK - done with cleaning up... // but never copy over the collection hostname, that is // problematic m_recs[i]->m_collectionHostname [0] = '\0'; m_recs[i]->m_collectionHostname1[0] = '\0'; m_recs[i]->m_collectionHostname2[0] = '\0'; } // set coll id and coll name for coll id #i strcpy ( m_recs[i]->m_coll , coll ); m_recs[i]->m_collLen = gbstrlen ( coll ); m_recs[i]->m_collnum = i; // point to this, so Rdb and RdbBase can reference it coll = m_recs[i]->m_coll; // . if has no password or ip add the default password, footbar // . no, just don't have any password, just use the 127.0.0.1 ip // that is the loopback /* if ( m_recs[i]->m_numAdminIps == 0 && m_recs[i]->m_numAdminPwds == 0 ) { m_recs[i]->m_numAdminIps = 1; m_recs[i]->m_adminIps[0] = atoip("0.0.0.0",7); //strcpy ( m_recs[i]->m_adminPwds[0] , "footbar23" ); //m_recs[i]->m_numAdminPwds = 1; //log("admin: Using default password for new collection of " // "'footbar23'."); } */ // collection name HACK for backwards compatibility //if ( strcmp ( coll , "main" ) == 0 ) { // m_recs[i]->m_coll[0] = '\0'; // m_recs[i]->m_collLen = 0; // //coll[0] = '\0'; //} // MDW: create the new directory if ( isNew ) { retry22: if ( ::mkdir ( dname , S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH ) ) { // valgrind? if ( errno == EINTR ) goto retry22; g_errno = errno; mdelete ( m_recs[i] , sizeof(CollectionRec) , "CollectionRec" ); delete ( m_recs[i]); m_recs[i] = NULL; return log("admin: Creating directory %s had error: " "%s.", dname,mstrerror(g_errno)); } // save it into this dir... might fail! if ( ! m_recs[i]->save() ) { mdelete ( m_recs[i] , sizeof(CollectionRec) , "CollectionRec" ); delete ( m_recs[i]); m_recs[i] = NULL; return log("admin: Failed to save file %s: %s", dname,mstrerror(g_errno)); } } // load if not new if ( ! isNew && ! m_recs[i]->load ( coll , i ) ) { mdelete ( m_recs[i], sizeof(CollectionRec), "CollectionRec" ); delete ( m_recs[i]); m_recs[i] = NULL; return log("admin: Failed to load conf for collection " "\"%s\".",coll); } // mark it as needing to be saved instead m_recs[i]->m_needsSave = false; // force this to off for now //m_recs[i]->m_queryExpansion = false; // reserve it if ( i >= m_numRecs ) m_numRecs = i + 1; // count it m_numRecsUsed++; // update the time updateTime(); // if we are doing a dump from the command line, skip this stuff if ( isDump ) return true; bool verify = true; if(isNew) verify = false; // tell rdbs to add one, too //if ( ! g_indexdb.addColl ( coll, verify ) ) goto hadError; if ( ! g_posdb.addColl ( coll, verify ) ) goto hadError; //if ( ! g_datedb.addColl ( coll, verify ) ) goto hadError; if ( ! g_titledb.addColl ( coll, verify ) ) goto hadError; //if ( ! g_revdb.addColl ( coll, verify ) ) goto hadError; //if ( ! g_sectiondb.addColl ( coll, verify ) ) goto hadError; if ( ! g_tagdb.addColl ( coll, verify ) ) goto hadError; //if ( ! g_catdb.addColl ( coll, verify ) ) goto hadError; //if ( ! g_checksumdb.addColl ( coll, verify ) ) goto hadError; if ( ! g_spiderdb.addColl ( coll, verify ) ) goto hadError; if ( ! g_doledb.addColl ( coll, verify ) ) goto hadError; //if ( ! g_tfndb.addColl ( coll, verify ) ) goto hadError; if ( ! g_clusterdb.addColl ( coll, verify ) ) goto hadError; if ( ! g_linkdb.addColl ( coll, verify ) ) goto hadError; // debug message log ( LOG_INFO, "admin: added collection \"%s\" (%li).",coll,(long)i); // tell SpiderCache about this collection, it will create a // SpiderCollection class for it. //g_spiderCache.reset1(); // . make it set is CollectionRec::m_sortByDateTable now // . everyone else uses setTimeOfDayInMilliseconds() in fctypes.cpp // to call this function once their clock is synced with host #0 //if ( g_hostdb.m_initialized && g_hostdb.m_hostId == 0 ) // initSortByDateTable(coll); //else if ( g_hostdb.m_initialized && isClockInSync() ) // initSortByDateTable(coll); // . do it for all regard-less // . once clock is in sync with host #0 we may do it again! //if ( g_hostdb.m_initialized ) // initSortByDateTable(coll); // success return true; hadError: log("admin: Had error adding new collection: %s.",mstrerror(g_errno)); // do not delete it, might have failed to add because not enough // memory to read in the tree *-saved.dat file on disk!! and if // you delete in then core the *-saved.dat file gets overwritten!!! return false; /* g_indexdb.getRdb()->delColl ( coll ); g_datedb.getRdb()->delColl ( coll ); g_timedb.getRdb()->delColl ( coll ); g_titledb.getRdb()->delColl ( coll ); g_revdb.getRdb()->delColl ( coll ); g_sectiondb.getRdb()->delColl ( coll ); g_placedb.getRdb()->delColl ( coll ); g_tagdb.getRdb()->delColl ( coll ); //g_catdb.getRdb()->delColl ( coll ); //g_checksumdb.getRdb()->delColl ( coll ); g_spiderdb.getRdb()->delColl ( coll ); g_doledb.getRdb()->delColl ( coll ); g_tfndb.getRdb()->delColl ( coll ); g_clusterdb.getRdb()->delColl ( coll ); g_linkdb.getRdb()->delColl ( coll ); deleteRec ( coll ); return false; */ }
// . delete a collection // . this uses blocking unlinks, may make non-blocking later bool Collectiondb::deleteRec ( char *coll , bool deleteTurkdb ) { // force on for now deleteTurkdb = true; // no spiders can be out. they may be referencing the CollectionRec // in XmlDoc.cpp... quite likely. if ( g_conf.m_spideringEnabled || g_spiderLoop.m_numSpidersOut > 0 ) { log("admin: Can not delete collection while " "spiders are enabled or active."); return false; } // do not allow this if in repair mode if ( g_repairMode > 0 ) { log("admin: Can not delete collection while in repair mode."); return false; } // ensure it's not NULL if ( ! coll ) { log(LOG_LOGIC,"admin: Collection name to delete is NULL."); return false; } // find the rec for this collection collnum_t collnum = getCollnum ( coll ); // bitch if not found if ( collnum < 0 ) { g_errno = ENOTFOUND; return log(LOG_LOGIC,"admin: Collection \"%s\" not found, " "delete failed.",coll); } CollectionRec *cr = m_recs [ collnum ]; if ( ! cr ) return log("admin: Collection id problem. Delete failed."); // we need a save m_needsSave = true; // nuke it on disk char oldname[1024]; sprintf(oldname, "%scoll.%s.%li/",g_hostdb.m_dir,cr->m_coll, (long)cr->m_collnum); char newname[1024]; sprintf(newname, "%strash/coll.%s.%li.%lli/",g_hostdb.m_dir,cr->m_coll, (long)cr->m_collnum,gettimeofdayInMilliseconds()); //Dir d; d.set ( dname ); // ensure ./trash dir is there char trash[1024]; sprintf(trash, "%strash/",g_hostdb.m_dir); ::mkdir ( trash, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH ) ; // move into that dir ::rename ( oldname , newname ); // debug message logf ( LOG_INFO, "admin: deleted collection \"%s\" (%li).", coll,(long)collnum ); // nuke doleiptable and waintree and waitingtable /* SpiderColl *sc = g_spiderCache.getSpiderColl ( collnum ); sc->m_waitingTree.clear(); sc->m_waitingTable.clear(); sc->m_doleIpTable.clear(); g_spiderLoop.m_lockTable.clear(); g_spiderLoop.m_lockCache.clear(0); sc->m_lastDownloadCache.clear(collnum); */ // remove from spider cache, tell it to sync up with collectiondb //g_spiderCache.reset1(); // . TODO: remove from g_sync // . remove from all rdbs //g_indexdb.getRdb()->delColl ( coll ); g_posdb.getRdb()->delColl ( coll ); //g_datedb.getRdb()->delColl ( coll ); g_titledb.getRdb()->delColl ( coll ); //g_revdb.getRdb()->delColl ( coll ); //g_sectiondb.getRdb()->delColl ( coll ); g_tagdb.getRdb()->delColl ( coll ); // let's preserve the tags... they have all the turk votes in them if ( deleteTurkdb ) { } //g_catdb.getRdb()->delColl ( coll ); //g_checksumdb.getRdb()->delColl ( coll ); g_spiderdb.getRdb()->delColl ( coll ); g_doledb.getRdb()->delColl ( coll ); //g_tfndb.getRdb()->delColl ( coll ); g_clusterdb.getRdb()->delColl ( coll ); g_linkdb.getRdb()->delColl ( coll ); // free it mdelete ( m_recs[(long)collnum], sizeof(CollectionRec), "CollectionRec" ); delete ( m_recs[(long)collnum] ); m_recs[(long)collnum] = NULL; // dec counts m_numRecsUsed--; while ( ! m_recs[m_numRecs-1] ) m_numRecs--; // update the time updateTime(); // done return true; }
void eDVBLocalTimeHandler::updateNonTuned() { updateTime(-1, 0, 0); m_updateNonTunedTimer->start(TIME_UPDATE_INTERVAL, true); }
void CCEngine::updateEngineThread() { // Update our system time updateTime(); time.lifetime += time.real; #if LOG_FPS static uint loggedUpdates = 0; static float loggedDelta = 0.0f; loggedUpdates++; loggedDelta += time.real; if( loggedDelta > 1.0f ) { #if !defined WP8 && !defined WIN8 const float averageFPS = 1.0f / ( loggedDelta / loggedUpdates ); DEBUGLOG( "Average FPS: %f \n", averageFPS ); #endif loggedUpdates = 0; loggedDelta = 0.0f; } #endif if( backButtonActionPending ) { backButtonActionPending = false; handleBackButton(); } // Run callbacks if( engineThreadCallbacks.length > 0 ) { int jobsProcessed = 0; const double startTime = CCEngine::GetSystemTime(); const double finishTime = startTime + 0.002f; // Spend a max of 2ms on this task double currentTime = startTime; while( engineThreadCallbacks.length > 0 ) { CCNativeThreadLock(); CCJobsThreadLock(); CCLambdaCallback *callback = engineThreadCallbacks.pop(); if( callback != NULL ) { callback->safeRun(); } CCNativeThreadUnlock(); CCJobsThreadUnlock(); if( callback != NULL ) { delete callback; } jobsProcessed++; if( textureManager != NULL && textureManager->isReady() ) { currentTime = CCEngine::GetSystemTime(); if( currentTime > finishTime ) { DEBUGLOG( "Max engineThreadCallbacks processed in time %i, %i\n", jobsProcessed, engineThreadCallbacks.length ); break; } } } } finishJobs(); updateLoop(); if( paused == false ) { CCAppManager::UpdateOrientation( time.delta ); } renderLoop(); #if defined DEBUGON && TARGET_IPHONE_SIMULATOR // 66 frames a second in debug //usleep( 15000 ); usleep( 0 ); #endif }
MainWindow::MainWindow() { varinit(); setupUi(this); if (tr("LTR") == "RTL") { qApp->setLayoutDirection(Qt::RightToLeft); } #ifndef Q_WS_WIN testPageSplitter->setPalette(this->palette()); #endif remainingTimeLcdNumber->setVisible(false); remainingTimeProgressBar->setVisible(false); label_minutes->setVisible(false); questionTextSvgSplitter->setCollapsible(0, false); questionTextSvgSplitter->setCollapsible(1, true); tcpSocket = new QTcpSocket(this); progress_dialog = NULL; current_test_use_groups = false; current_connection_local = false; QObject::connect(&timer, SIGNAL(timeout()), this, SLOT(updateTime())); QObject::connect(tbtnQuit, SIGNAL(released()), this, SLOT(close())); QObject::connect(tbtnAbout, SIGNAL(released()), this, SLOT(about())); QObject::connect(tbtnGetReady, SIGNAL(released()), this, SLOT(getReady())); QObject::connect(tbtnStart, SIGNAL(released()), this, SLOT(start())); QObject::connect(tbtnBrowse_DBPath, SIGNAL(released()), this, SLOT(browse_i())); QObject::connect(tbtnBrowse_savePath, SIGNAL(released()), this, SLOT(browse_o())); QObject::connect(tbtnLoad, SIGNAL(released()), this, SLOT(loadFile())); QObject::connect(useDefaultOutputCheckBox, SIGNAL(toggled(bool)), savePathLineEdit, SLOT(setDisabled(bool))); QObject::connect(useDefaultOutputCheckBox, SIGNAL(toggled(bool)), tbtnBrowse_savePath, SLOT(setDisabled(bool))); QObject::connect(serverNameLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(enableConnectButton())); QObject::connect(serverPortLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(enableConnectButton())); QObject::connect(DBPathLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(enableLoadButton())); QObject::connect(tbtnConnect, SIGNAL(released()), this, SLOT(connectSocket())); QObject::connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readIncomingData())); QObject::connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError))); QObject::connect(LQListWidget, SIGNAL(currentTextChanged(QString)), this, SLOT(setCurrentQuestion())); QObject::connect(svgDisplayWidget, SIGNAL(titleClicked(const QString &)), this, SLOT(previewSvg(const QString &))); QObject::connect(btnNext, SIGNAL(released()), this, SLOT(nextQuestion())); QObject::connect(btnLast, SIGNAL(released()), this, SLOT(lastQuestion())); QObject::connect(btnFinish, SIGNAL(released()), this, SLOT(finish())); QObject::connect(btnNewTest, SIGNAL(released()), this, SLOT(newTest())); QObject::connect(btnQuit, SIGNAL(released()), this, SLOT(close())); rbtngrpInputType = new QButtonGroup (this); rbtngrpInputType->addButton(rbtnNetwork); rbtngrpInputType->addButton(rbtnFromFile); QObject::connect(rbtngrpInputType, SIGNAL(buttonReleased(QAbstractButton *)), this, SLOT(toggleInputType(QAbstractButton *))); QObject::connect(answersView, SIGNAL(buttonReleased(Question::Answers)), this, SLOT(setQuestionAnswered(Question::Answers))); for (int i = 0; i < 8; ++i) {infoTableWidget->setItem(i, 0, new QTableWidgetItem);} ITW_test_name = infoTableWidget->item(0, 0); ITW_test_date = infoTableWidget->item(1, 0); ITW_test_timestamp = infoTableWidget->item(2, 0); ITW_test_time = infoTableWidget->item(3, 0); ITW_test_qnum = infoTableWidget->item(4, 0); ITW_test_fnum = infoTableWidget->item(5, 0); ITW_test_flags = infoTableWidget->item(6, 0); ITW_test_passmark = infoTableWidget->item(7, 0); ITW_test_comments = new QTextBrowser (infoTableWidget); infoTableWidget->setCellWidget(8, 0, ITW_test_comments); infoTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch); infoTableWidget->verticalHeader()->setResizeMode(8, QHeaderView::Stretch); resultsTableWidget->setColumnCount(1); resultsTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch); resultsTableWidget->horizontalHeader()->hide(); loadSettings(); // Check app args ---------------------------------------------------------- if (qApp->arguments().count() > 2) { if (qApp->arguments().at(1) == "-port") { serverNameLineEdit->setText("Localhost"); serverPortLineEdit->setText(qApp->arguments().at(2)); connectSocket(); } } else if (qApp->arguments().count() > 1) { openFile(qApp->arguments().at(1)); } }
static void tickHandler(struct tm *tickTime, TimeUnits unitsChanged) { updateTime(tickTime, timeLayer); }
/*********************************************************** synopsis: a big while loop that runs the full length of the game, checks the game events and responds accordingly event action ------------------------------------------------- winGame stop the clock and solve puzzle timeRemaining update the clock tick timeUp stop the clock and solve puzzle solvePuzzle trigger solve puzzle and stop clock updateAnswers trigger update answers startNew trigger start new updateScore trigger update score shuffle trigger shuffle clear trigger clear answer quit end loop poll events check for keyboard/mouse and quit finally, move the sprites -this is always called so the sprites are always considered to be moving no "move sprites" event exists - sprites x&y just needs to be updated and they will always be moved inputs: head - first node in the answers list (in/out) dblHead - first node in the dictionary list screen - the SDL_Surface to display the image letters - first node in the letter sprites (in/out) outputs: n/a ***********************************************************/ static void gameLoop(struct node **head, struct dlb_node *dlbHead, SDL_Surface *screen, struct sprite **letters) { int j,k; int done=0; int numofwords=1; SDL_Event event; time_t timeNow; SDL_TimerID timer; int timer_delay = 20; char buffer[512]; #ifdef demo if (conf.totalgames < 0){ conf.totalgames=8; } conf.totalgames +=1;//demo tags sprintf(buffer,"globaldata/agdemo.cfg"); saveCFG(buffer,&conf); #endif timer = SDL_AddTimer(timer_delay, TimerCallback, NULL); /* main game loop */ while (!done) { if (winGame) { stopTheClock = 1; solvePuzzle = 1; } if ((gameTime < AVAILABLE_TIME) && !stopTheClock) { timeNow = time(0) - gameStart; if (timeNow != gameTime){ gameTime = timeNow; updateTime(screen); } } else { if (!stopTheClock){ stopTheClock = 1; solvePuzzle = 1; } } /* check messages */ if (solvePuzzle) { /* walk the list, setting everything to found */ solveIt(*head); clearWord(letters); strcpy(shuffle, SPACE_FILLED_STRING); strcpy(answer, rootWord); /*displayLetters(screen);*/ displayAnswerBoxes(*head, screen); gamePaused = 1; if (!stopTheClock){ stopTheClock = 1; } solvePuzzle = 0; } if (updateAnswers){ /* move letters back down again */ clearWord(letters); /* displayLetters(screen);*/ displayAnswerBoxes(*head, screen); updateAnswers = 0; } if ((stopTheClock && !gotBigWord && !checkScore)||(startNewGame&&!gotBigWord& !checkScore)){ //Error("inside highscore\n"); for(j=9;j>=0 && hiscore[j].score<totalScore;j--); //Error("score position: %i\n",j); /* the player will be in the hall of fame? */ if(j<9) { for(k=8;k>j;k--) hiscore[k+1]=hiscore[k]; /* put the new score */ hiscore[j+1].score=totalScore; hiscore[j+1].stage=numofwords; //hiscore[j+1].name[0]=0; //if(!getName(hiscore[j+1].name, j+2,i+1)) // break; /* probably a problem if the user closes the window */ /* show the hall of fame */ //hiscores(); /* save hi-scores */ #ifdef demo sprintf(buffer,"/media/internal/appdata/com.cribme.aghddemo/ag-hiscore"); #else sprintf(buffer,"/media/internal/appdata/com.cribme.aghd/ag-hiscore"); #endif //sprintf(buffer,"globaldata/ag-hiscore"); if(!saveScore(buffer,hiscore)) fprintf(stderr,"unable to save hi-scores\ndo you have permissions to write into %s?\n" ,buffer); } checkScore=1; } if (startNewGame) { /* move letters back down again */ if (!gotBigWord){ totalScore = 0; numofwords=0; } newGame(head, dlbHead, screen, letters); #ifdef demo conf.totalgames +=1;//demo tags char buffer[512]; sprintf(buffer,"globaldata/agdemo.cfg"); //Error("Buffer :%s\n",buffer); //Error("TotalGames Written to file :%i\n",conf.totalgames); saveCFG(buffer,&conf); #endif numofwords+=1; checkScore = 0; startNewGame = 0; } if (updateTheScore) { updateScore(screen); updateTheScore = 0; } if (shuffleRemaining) { /* shuffle up the shuffle box */ char shuffler[8]; strcpy(shuffler, shuffle); shuffleAvailableLetters(shuffler, letters); strcpy(shuffle, shuffler); shuffleRemaining = 0; } if (clearGuess) { /* clear the guess; */ if (clearWord(letters) > 0) { Mix_PlayChannel(-1, getSound("clear"),0); } clearGuess = 0; } #ifdef demo //Error("TotalGames:%i\n",conf.totalgames);//conf.totalgames if (conf.totalgames > 8){//conf.totalgames destroyLetters(letters); strcpy(txt, language); ShowBMP(strcat(txt,"images/demo.bmp"),screen, 100,75); done=1; } #endif if (quitGame) { done = 1; } if (inactive){ SDL_WaitEvent(&event); if (event.type == SDL_ACTIVEEVENT && event.active.gain == 1) { inactive = 0; timer = SDL_AddTimer(timer_delay, TimerCallback, NULL); } } else { while (SDL_WaitEvent(&event)) { if (event.type == SDL_ACTIVEEVENT && event.active.gain == 0) { inactive = 1; break; } if (event.type == SDL_USEREVENT) { timer_delay = anySpritesMoving(letters) ? 10 : 100; moveSprites(&screen, letters, letterSpeed); timer = SDL_AddTimer(timer_delay, TimerCallback, NULL); break; } else if (event.type == SDL_MOUSEBUTTONDOWN) { clickDetect(event.button.button, event.button.x, event.button.y, screen, *head, letters); moveSprites(&screen, letters, letterSpeed);//added by me } else if (event.type == SDL_KEYUP) { handleKeyboardEvent(&event, *head, letters); } else if (event.type == SDL_QUIT) { done = 1; break; } } } } #ifdef demo while(conf.totalgames > 8){//conf.totalgames while(SDL_WaitEvent(&event)){ if (event.type == SDL_MOUSEBUTTONDOWN) { PDL_ServiceCall("palm://com.palm.applicationManager/open", "{\"target\":\"http://developer.palm.com/appredirect/?packageid=com.cribme.aghd\"}"); //PDL_LaunchBrowser("http://developer.palm.com/appredirect/?packageid=com.cribme.aghd"); } } } #endif }
void MediaPluginGStreamer010::receiveMessage(const char *message_string) { //std::cerr << "MediaPluginGStreamer010::receiveMessage: received message: \"" << message_string << "\"" << std::endl; LLPluginMessage message_in; if(message_in.parse(message_string) >= 0) { std::string message_class = message_in.getClass(); std::string message_name = message_in.getName(); if(message_class == LLPLUGIN_MESSAGE_CLASS_BASE) { if(message_name == "init") { LLPluginMessage message("base", "init_response"); LLSD versions = LLSD::emptyMap(); versions[LLPLUGIN_MESSAGE_CLASS_BASE] = LLPLUGIN_MESSAGE_CLASS_BASE_VERSION; versions[LLPLUGIN_MESSAGE_CLASS_MEDIA] = LLPLUGIN_MESSAGE_CLASS_MEDIA_VERSION; versions[LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME] = LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME_VERSION; message.setValueLLSD("versions", versions); if ( load() ) { DEBUGMSG("GStreamer010 media instance set up"); } else { WARNMSG("GStreamer010 media instance failed to set up"); } message.setValue("plugin_version", getVersion()); sendMessage(message); } else if(message_name == "idle") { // no response is necessary here. double time = message_in.getValueReal("time"); // Convert time to milliseconds for update() update((int)(time * 1000.0f)); if(GST_STATE(mPlaybin) == GST_STATE_PLAYING) { // update the current playback time if(update_counter == 10) { updateTime(); update_counter = 0; } update_counter++; } } else if(message_name == "cleanup") { unload(); closedown(); } else if(message_name == "shm_added") { SharedSegmentInfo info; info.mAddress = message_in.getValuePointer("address"); info.mSize = (size_t)message_in.getValueS32("size"); std::string name = message_in.getValue("name"); std::ostringstream str; INFOMSG("MediaPluginGStreamer010::receiveMessage: shared memory added, name: %s, size: %d, address: %p", name.c_str(), int(info.mSize), info.mAddress); mSharedSegments.insert(SharedSegmentMap::value_type(name, info)); } else if(message_name == "shm_remove") { std::string name = message_in.getValue("name"); DEBUGMSG("MediaPluginGStreamer010::receiveMessage: shared memory remove, name = %s", name.c_str()); SharedSegmentMap::iterator iter = mSharedSegments.find(name); if(iter != mSharedSegments.end()) { if(mPixels == iter->second.mAddress) { // This is the currently active pixel buffer. Make sure we stop drawing to it. mPixels = NULL; mTextureSegmentName.clear(); // Make sure the movie decoder is no longer pointed at the shared segment. sizeChanged(); } mSharedSegments.erase(iter); } else { WARNMSG("MediaPluginGStreamer010::receiveMessage: unknown shared memory region!"); } // Send the response so it can be cleaned up. LLPluginMessage message("base", "shm_remove_response"); message.setValue("name", name); sendMessage(message); } else { std::ostringstream str; INFOMSG("MediaPluginGStreamer010::receiveMessage: unknown base message: %s", message_name.c_str()); } } else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA) { if(message_name == "init") { // Plugin gets to decide the texture parameters to use. LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "texture_params"); // lame to have to decide this now, it depends on the movie. Oh well. mDepth = 4; mCurrentWidth = 1; mCurrentHeight = 1; mPreviousWidth = 1; mPreviousHeight = 1; mNaturalWidth = 1; mNaturalHeight = 1; mWidth = 1; mHeight = 1; mTextureWidth = 1; mTextureHeight = 1; message.setValueU32("format", GL_RGBA); message.setValueU32("type", GL_UNSIGNED_INT_8_8_8_8_REV); message.setValueS32("depth", mDepth); message.setValueS32("default_width", mWidth); message.setValueS32("default_height", mHeight); message.setValueU32("internalformat", GL_RGBA8); message.setValueBoolean("coords_opengl", true); // true == use OpenGL-style coordinates, false == (0,0) is upper left. message.setValueBoolean("allow_downsample", true); // we respond with grace and performance if asked to downscale sendMessage(message); } else if(message_name == "size_change") { std::string name = message_in.getValue("name"); S32 width = message_in.getValueS32("width"); S32 height = message_in.getValueS32("height"); S32 texture_width = message_in.getValueS32("texture_width"); S32 texture_height = message_in.getValueS32("texture_height"); std::ostringstream str; INFOMSG("---->Got size change instruction from application with shm name: %s - size is %d x %d", name.c_str(), width, height); LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "size_change_response"); message.setValue("name", name); message.setValueS32("width", width); message.setValueS32("height", height); message.setValueS32("texture_width", texture_width); message.setValueS32("texture_height", texture_height); sendMessage(message); if(!name.empty()) { // Find the shared memory region with this name SharedSegmentMap::iterator iter = mSharedSegments.find(name); if(iter != mSharedSegments.end()) { INFOMSG("*** Got size change with matching shm, new size is %d x %d", width, height); INFOMSG("*** Got size change with matching shm, texture size size is %d x %d", texture_width, texture_height); mPixels = (unsigned char*)iter->second.mAddress; mTextureSegmentName = name; mWidth = width; mHeight = height; if (texture_width > 1 || texture_height > 1) // not a dummy size from the app, a real explicit forced size { INFOMSG("**** = REAL RESIZE REQUEST FROM APP"); GST_OBJECT_LOCK(mVideoSink); mVideoSink->resize_forced_always = true; mVideoSink->resize_try_width = texture_width; mVideoSink->resize_try_height = texture_height; GST_OBJECT_UNLOCK(mVideoSink); } mTextureWidth = texture_width; mTextureHeight = texture_height; } } } else if(message_name == "load_uri") { std::string uri = message_in.getValue("uri"); navigateTo( uri ); sendStatus(); } else if(message_name == "mouse_event") { std::string event = message_in.getValue("event"); S32 x = message_in.getValueS32("x"); S32 y = message_in.getValueS32("y"); if(event == "down") { mouseDown(x, y); } else if(event == "up") { mouseUp(x, y); } else if(event == "move") { mouseMove(x, y); }; }; } else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME) { if(message_name == "stop") { stop(); } else if(message_name == "start") { double rate = 0.0; if(message_in.hasValue("rate")) { rate = message_in.getValueReal("rate"); } // NOTE: we don't actually support rate. play(rate); } else if(message_name == "pause") { pause(); } else if(message_name == "seek") { double time = message_in.getValueReal("time"); // defer the actual seek in case we haven't // really truly started yet in which case there // is nothing to seek upon mSeekWanted = true; mSeekDestination = time; } else if(message_name == "set_loop") { bool loop = message_in.getValueBoolean("loop"); mIsLooping = loop; } else if(message_name == "set_volume") { double volume = message_in.getValueReal("volume"); setVolume(volume); } } else { INFOMSG("MediaPluginGStreamer010::receiveMessage: unknown message class: %s", message_class.c_str()); } } }
void CCEngine::updateEngineThread() { // Update our system time if( updateTime() == false ) { #ifdef ANDROID // FIXME: Android needs to always redraw the scene // We currently never return false, so perhaps remove this.. renderer->clear(); renderLoop(); #endif return; } time.lifetime += time.real; #if LOG_FPS static uint loggedUpdates = 0; static float loggedDelta = 0.0f; loggedUpdates++; loggedDelta += time.real; if( loggedDelta > 1.0f ) { const float averageFPS = 1.0f / ( loggedDelta / loggedUpdates ); DEBUGLOG( "Average FPS: %f \n", averageFPS ); loggedUpdates = 0; loggedDelta = 0.0f; } #endif // Run callbacks if( engineThreadCallbacks.length > 0 ) { CCNativeThreadLock(); CCJobsThreadLock(); CCLambdaCallback *callback = engineThreadCallbacks.pop(); CCNativeThreadUnlock(); CCJobsThreadUnlock(); callback->run(); delete callback; // for( int i=0; i<engineThreadCallbacks.length; ++i ) // { // engineThreadCallbacks.list[i]->run(); // delete engineThreadCallbacks.list[i]; // } // engineThreadCallbacks.length = 0; } finishJobs(); updateLoop(); CCViewManager::UpdateOrientation( time.delta ); renderer->clear(); renderLoop(); renderer->resolve(); #if defined DEBUGON && TARGET_IPHONE_SIMULATOR // 66 frames a second in debug //usleep( 15000 ); usleep( 0 ); #endif }