示例#1
0
void Service::onRunning()
{
	if (_tickTime <= 0)
	{
		return;
	}

	_running = true;
	boost::posix_time::ptime tickStart, tickEnd;
	boost::posix_time::millisec_posix_time_system_config::time_duration_type time_elapse;

	while (1)
	{
		tickStart = boost::posix_time::microsec_clock::universal_time();
		processAllMessage();
		
		if (!_running)
		{
			break;
		}

		onTick();
		tickEnd = boost::posix_time::microsec_clock::universal_time();

		time_elapse = tickEnd - tickStart;
		_tickCostTime = time_elapse.total_milliseconds();
		
		//MH_TRACE2(getName()+"ticktime", _tickCostTime);
		if (_tickCostTime < _tickTime)
		{
			boost::this_thread::sleep(boost::posix_time::millisec(_tickTime - _tickCostTime));
		}
	}
}
示例#2
0
void LampGameObject::doTick()
{

	//Do culling in tick? 
	//Yes please, less culling calls

	//Update our transform

	//Get parent transform matrix
	mat4* ptrParentMatrix = NULL;
	if (m_pParent != NULL)
	{
		ptrParentMatrix = m_transform.getGlobalPtr();
	}
	m_transform.calculateGlobal(ptrParentMatrix);

	//Call our on tick function
	onTick();

	//Tell all our components that this game object is being ticked
	for (unsigned int i = 0; i < m_vComponents.size(); i++)
	{
		m_vComponents[i]->onTick();
	}

	//Give the message to all our children
	for (unsigned int i = 0; i < m_vChildren.size(); i++)
	{
		m_vChildren[i]->doTick();
	}

}
示例#3
0
	void TransferApi::on(UploadManagerListener::Tick, const UploadList& aUploads) noexcept {
		for (const auto& ul : aUploads) {
			if (ul->getPos() == 0) continue;

			onTick(ul, false);
		}
	}
示例#4
0
Animation::Animation(Board* parentBoard):
    mParentBoard(parentBoard)
{
    mTimer = new QTimer(this);
    connect(mTimer, SIGNAL(timeout()), this, SLOT(onTick()));

    mTickDelay = XML::instance().readValue(XML_ITEMS_FILENAME, QList<QString>() << XML_NODE_ANIMATION << XML_NODE_TIMER).toInt();
}
/*!
    Constructs new timer with the given \a parent.
*/
HsClockWidgetTimer::HsClockWidgetTimer(QObject *parent)
  : QObject(parent),
    mTimer(0)
{
    mTimer = new QTimer(this);
    mTimer->setInterval(1000);    
    connect(mTimer, SIGNAL(timeout()), SLOT(onTick()));
}
示例#6
0
文件: button.cpp 项目: gilligan/bsnes
void Button::create(Window &parent, unsigned x, unsigned y, unsigned width, unsigned height, const char *text) {
  button->setParent(parent.window->container);
  button->setGeometry(x, y, width, height);
  button->setText(text);
  if(parent.window->defaultFont) button->setFont(*parent.window->defaultFont);
  button->show();
  button->connect(button, SIGNAL(released()), SLOT(onTick()));
}
示例#7
0
 void Level::tick(float dt_s)
 {
     onTick(dt_s);
     tickingActors_.update(dt_s);
     tickingComponents_.update(dt_s);
     physicsWorld_->stepSimulation(dt_s);
     audioWorld_->simulate();
 }
EditButton::EditButton(QWidget *parent)
	: QPushButton(parent)
	, m_Selected(false)
	, m_T(PI_PLUS_PI_2)
	, m_Alpha(0)
{
	m_Timer = new QTimer(this);
	connect(m_Timer, SIGNAL(timeout()), this, SLOT(onTick()));
}
void
PlaybackControlsWidget::onTrackStarted( const Track& track, const Track& oldTrack )
{
    ui->progressBar->setTrack( track );

    if ( m_movie )
        m_movie->stop();

    if ( !track.isNull() )
    {
        disconnect( &RadioService::instance(), SIGNAL(tick(qint64)), this, SLOT(onTick(qint64)));
        disconnect( &ScrobbleService::instance(), SIGNAL(frameChanged(int)), ui->progressBar, SLOT(onFrameChanged(int)) );

        // you can love tag and share all tracks
        aApp->loveAction()->setEnabled( true );
        aApp->tagAction()->setEnabled( true );
        aApp->shareAction()->setEnabled( true );

        // play is always enabled as you should always
        // be able to start the radio
        aApp->playAction()->setEnabled( true );

        aApp->playAction()->setChecked( track.source() == Track::LastFmRadio );

        // can only ban and skip radio tracks
        aApp->banAction()->setEnabled( track.source() == Track::LastFmRadio );
        aApp->skipAction()->setEnabled( track.source() == Track::LastFmRadio );

        aApp->loveAction()->setChecked( track.isLoved() );

        ui->controls->setVisible( track.source() == Track::LastFmRadio );

        setScrobbleTrack( track.source() != Track::LastFmRadio  );

        if( track.source() == Track::LastFmRadio )
        {
            // A radio track!
            connect( track.signalProxy(), SIGNAL(loveToggled(bool)), ui->love, SLOT(setChecked(bool)));

            ui->status->setText( tr("Listening to...") );
            ui->device->setText( RadioService::instance().station().title() );

            connect( &RadioService::instance(), SIGNAL(tick(qint64)), SLOT(onTick(qint64)) );
        }
示例#10
0
void Animation::startBlinking(Cell* srcCell, Cell* dstCell)
{
    mTimer->start(mTickDelay);

    mSrcCell = srcCell;
    mDstCell = dstCell;

    mDstNativePiece = mDstCell->getPiece();

    onTick();
}
示例#11
0
/**
  * \brief Set the media file
  * @param filePath as the media file path
  */
void UBMediaWidget::setFile(const QString &filePath)
{
    Q_ASSERT("" != filePath);
    mFilePath = filePath;
    mpMediaObject = new Phonon::MediaObject(this);
    mpMediaObject->setTickInterval(TICK_INTERVAL);
    connect(mpMediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(onStateChanged(Phonon::State,Phonon::State)));
    connect(mpMediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(onTotalTimeChanged(qint64)));
    connect(mpMediaObject, SIGNAL(tick(qint64)), this, SLOT(onTick(qint64)));
    mpMediaObject->setCurrentSource(Phonon::MediaSource(filePath));
    createMediaPlayer();
}
示例#12
0
void BaseApplicationService::tick(uint64_t new_timestamp) {
    active_.Send([=] {
        if (! (new_timestamp >= current_timestamp_)) {
            assert(!"New timestamp given is older than the currently stored timestamp!");
            return;
        }

        current_timestamp_.exchange(new_timestamp);

        onTick();
    } );
}
示例#13
0
文件: main.cpp 项目: onlyuser/Sandbox
void onDisplay()
{
    vt::Scene *scene = vt::Scene::instance();

    onTick();
    glClearColor(0, 0, 0, 1);
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    scene->render();
    if(debug_vert_normals) {
        scene->render_vert_normals();
    }
    glutSwapBuffers();
}
示例#14
0
WdgtBenchmark::WdgtBenchmark(QWidget *parent)
    : QWidget(parent)
{
	ui.setupUi(this);
	next_line_ = 0;
	connect(&timer_, SIGNAL(timeout()), this, SLOT(onTick()));
	timer_.setInterval(10);
	timer_.start();

	header_ = addLine(true);
	header_.l_name->setText("Name");
	header_.l_mean->setText("Mean [ms]");
	header_.l_last->setText("Last [ms]");
}
示例#15
0
void NauTimer::update(){
    if(bRunning){
        curTime = ofGetElapsedTimef();
        
        if(curTime>=endTime){
            curRound++;
            endTime = endTime + tick;
            onTick();
        }
        
        if(curRound>=rounds){
            stop();
        }
    }
}
示例#16
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    m_settings("Coffey", "PresentRadio")
{
    ui->setupUi(this);

    connect(&m_radio, SIGNAL(tick(qint64)), SLOT(onTick(qint64)));
    connect(&m_radio, SIGNAL(trackSpooled(lastfm::Track)), SLOT(onTrackSpooled(lastfm::Track)));

    connect(ui->playStop, SIGNAL(clicked(bool)), SLOT(onPlayStopClicked(bool)));
    connect(ui->skip, SIGNAL(clicked()), SLOT(onSkipClicked()));
    //connect(ui->login, SIGNAL(clicked()), SLOT(onLoginClicked()));

    m_deviceModel = new BluetoothDeviceModel(this);
    ui->listView->setModel(m_deviceModel);

    connect(m_deviceModel, SIGNAL(found(int)), ui->btProgress, SLOT(setValue(int)));
    connect(m_deviceModel, SIGNAL(maximum(int)), ui->btProgress, SLOT(setMaximum(int)));

    m_cocoaInitializer = new CocoaInitializer();
    m_deviceInquiry = new BluetoothDeviceInquiry(m_deviceModel);
    m_deviceInquiry->start();
    ui->btProgress->setValue(0);

    connect(m_deviceModel, SIGNAL(devicesFound()), SLOT(onDevicesFound()));

    lastfm::ws::ApiKey = "52e420f41b41b041830694ecc3b383b6";
    lastfm::ws::SharedSecret = "11970cc8f4b06b833e9f74d1ebeb5553";

    if (m_settings.contains("session_key"))
    {
        lastfm::ws::SessionKey = m_settings.value("session_key", "NULL").toString();
        lastfm::ws::Username = m_settings.value("username", "NULL").toString();

        ui->playStop->setEnabled(true);

        m_scrobSocket = new ScrobSocket("tst", this);
        connect(&m_radio, SIGNAL(trackSpooled(lastfm::Track)), m_scrobSocket, SLOT(start(lastfm::Track)));
        connect(&m_radio, SIGNAL(stopped()), m_scrobSocket, SLOT(stop()));
    }
    else
    {
        m_login = new Login(this);
        connect(m_login, SIGNAL(finished(int)), SLOT(onLoginFinished(int)));
        m_login->show();
    }
}
示例#17
0
void PlayerController::setCurrentSong_helper(int idx)
{
    m_currentSong = idx;
    if (m_view) {
        if (idx < 0) {
            m_view->setTitle("");
            m_view->setArtist("");
            m_view->setCurrentIndex(-1);
        } else {
            m_view->setTitle(m_model->titleAt(m_currentSong));
            m_view->setArtist(m_model->artistAt(m_currentSong));
            m_view->setCurrentIndex(m_currentSong);
        }
        onTick(0);
    }
}
示例#18
0
void PlayerController::createPlayer()
{
    m_mediaObject = new Phonon::MediaObject(this);
    m_audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
    m_audioPath = Phonon::createPath(m_mediaObject, m_audioOutput);

    m_mediaObject->setTickInterval(1000);

    connect(m_mediaObject, SIGNAL(aboutToFinish()),
            SLOT(onAboutToFinish()));
    connect(m_mediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)),
            SLOT(onStateChanged(Phonon::State)));
    connect(m_mediaObject, SIGNAL(tick(qint64)),
            SLOT(onTick(qint64)));
    connect(m_mediaObject, SIGNAL(totalTimeChanged(qint64)),
            SLOT(onTotalTimeChanged(qint64)));
}
示例#19
0
    void Engine::run() {
        if (screen == NULL) return;
        
        running = true;

        SDL_Event event;
        Point a;
        surface_vector dupa;
        surface_vector::iterator it;
        int previous = SDL_GetTicks();
        int time;

        // Pętla główna
        while (running) {
            while (SDL_PollEvent (&event)) {
                switch (event.type) {
                case SDL_QUIT:
                    running = false;
                    break;
                case SDL_MOUSEBUTTONUP:
                    a.x = event.button.x;
                    a.y = event.button.y;

                    dupa = screen->objectsAtPoint (a);
                    for (it=dupa.begin(); it < dupa.end(); it++) {
                        //(*it)->fireEvent("click");
                        (*it)->onClick();
                    }
                    break;
                }
            }
            
            // żeby ruch był
            time = SDL_GetTicks();
            onTick(time - previous);
            
            // rysowanie
            screen->render();
            
            previous = time;
        }
        
        running = false;
    }
示例#20
0
bool RfService::tick()
{
    unsigned int t = RfClock();

    if (!mIsInitialized)
    {
        if (!onInitialize())
        {
            return false;
        }

        mIsInitialized = true;
    }

    bool ret = onTick(RfClock() - mInitTime);

    mTickTime = RfClock() - t;

    return ret;
}
示例#21
0
void PlayerController::initializeView()
{
    if (!m_view)
        return;

    // Initialize data from model
    if (m_songsAvailable) {
        m_view->setTitle(m_model->titleAt(m_currentSong));
        m_view->setArtist(m_model->artistAt(m_currentSong));
    } else {
        m_view->setTitle("");
        m_view->setArtist("");
    }

    // Initialize data from controller
    onTotalTimeChanged(m_mediaObject->totalTime());
    onTick(m_mediaObject->currentTime());
    onStateChanged(m_mediaObject->state());
    m_view->setVolume((m_audioOutput->volumeDecibel() + 35) / 35);
    m_view->setMuted(m_audioOutput->isMuted());
    m_view->setShuffle(m_shuffle);
    m_view->setRepeat(m_repeat);
    m_view->setPlaylistModel(m_playlistModel);
}
示例#22
0
文件: main.c 项目: havardh/TDT4258
int main ( void ) {

	printf("Game!\n");

	// Init devices
	ButtonInit();
	LedInit();

	Screen screen = ScreenNew(320, 240);
	Canvas canvas = CanvasNew( &screen );

	// Init game
	Controller ctrl = ControllerNew( &canvas );
	onGameInit( &ctrl );

	// Main loop
	static tick_delay = 0;
	while(ctrl.running) {

		if ( tick_delay++ == 20000 ) {
			tick_delay = 0;
			onTick( &ctrl );
		}

		ButtonPoll();

	}

	onGameExit( &ctrl );

	ButtonDestroy();
	LedDestroy();
	ScreenDestroy( &screen );

	return 0;
}
示例#23
0
void pItem::constructor() {
  qtAction = new QAction(0);
  connect(qtAction, SIGNAL(triggered()), SLOT(onTick()));
}
示例#24
0
void PlayerController::stop()
{
    m_mediaObject->stop();
    onTick(0);
}
示例#25
0
void Timer::tick()
{
  assert_ui_thread();

  onTick();
}
示例#26
0
void Timer::tick()
{
  onTick();
}
示例#27
0
void Tween::tick(double t) {
  onTick(t);
}
示例#28
0
	void TransferApi::on(DownloadManagerListener::Tick, const DownloadList& aDownloads) noexcept {
		for (const auto& dl : aDownloads) {
			onTick(dl, true);
		}
	}
void OpenGLWindow::renderNow()
{
    if (!isExposed())
        return;

    // initialize opengl context

    bool needsInitialize = false;

    if (!m_context) {
        m_context = new QOpenGLContext(this);
        m_context->setFormat(requestedFormat());

        if (m_context->create()) {
            m_gl = m_context->versionFunctions<GLFunctions>();
            if (!m_gl) {
                qCritical("Critical: Unable to initialize OpenGL 4.1 Functions");
                exit(EXIT_FAILURE);
            }

#ifdef DEBUG_OPENGL
            m_logger = new QOpenGLDebugLogger(this);
#endif
            needsInitialize = true;

            m_tickTimer.start();
            m_fpsTimer.start();
        } else {
            qWarning("Warning: Unable to create OpenGL context");
            return;
        }
    }

    m_context->makeCurrent(this);

    if (needsInitialize) {
        m_gl->initializeOpenGLFunctions();
        g_glFunctions = m_gl;
#ifdef DEBUG_OPENGL
        if (m_context->hasExtension(QByteArrayLiteral("GL_KHR_debug"))) {
            m_logger->initialize();
            connect(m_logger,
                    &QOpenGLDebugLogger::messageLogged,
                    this,
                    &OpenGLWindow::handleLogMessage,
                    Qt::DirectConnection);
            m_logger->enableMessages();
            m_logger->startLogging(QOpenGLDebugLogger::SynchronousLogging);
            const QList<QOpenGLDebugMessage> &preInitErrors = m_logger->loggedMessages();
            if (preInitErrors.size()) {
                qWarning() << "Warning: Pre-Initialization OpenGL Errors (Qt's fault)";
                qWarning() << "--[" << preInitErrors << "]--";
            }
        } else {
            qWarning("OpenGL KHR Debugging not available.");
        }
#endif
        initialize();
    }

    // check initialize qpainter context

    if (!m_device) {
        m_device = new QOpenGLPaintDevice;
        m_device->setSize(size());

        m_painter = new QPainter(m_device);
        m_painter->setRenderHint(QPainter::Antialiasing);
        m_painter->setRenderHint(QPainter::TextAntialiasing);
    }

    if (!m_painter->isActive()) {
        m_painter->begin(m_device);
    }

    // render

    float seconds = m_tickTimer.restart() * 0.001f;
    if (seconds > 1.0f) seconds = 1.0f;

    onTick(seconds);
    render();

    m_context->swapBuffers(this);

    if (m_animating)
        renderLater();
}