示例#1
0
文件: dmdialog.cpp 项目: SCV/qtwitter
DMDialog::DMDialog( const QString &screenName, QWidget *parent) :
        QDialog(parent),
        progress( new QMovie( ":/icons/progress.gif", "", this ) ),
        screenName( screenName ),
        m_ui(new Ui::DMDialog)
{
    m_ui->setupUi(this);

    m_ui->messageTextEdit->setAllowEnters( true );

    QFont charsLeftFont = m_ui->charsLeftLabel->font();
    charsLeftFont.setPointSize( charsLeftFont.pointSize() - 2 );
    m_ui->charsLeftLabel->setFont( charsLeftFont );
    m_ui->sendingLabel->setFont( charsLeftFont );
    m_ui->progressLabel->resize( m_ui->progressLabel->width(), m_ui->sendingLabel->height() );

    m_ui->charsLeftLabel->setText( tr( "%n characters left", "", charsLeft() ) );
    m_ui->sendingLabel->hide();
    m_ui->progressLabel->hide();
    m_ui->progressLabel->setMovie( progress );

    setWindowTitle( tr( "Direct message %1" ).arg( screenName ) );

    connect( m_ui->messageTextEdit, SIGNAL(textChanged()), this, SLOT(updateCharsLeft()) );
    connect( m_ui->sendButton, SIGNAL(clicked()), this, SLOT(sendDM()) );

    adjustSize();
}
示例#2
0
void Environment::init(){

    std::cout << "Environment Initialisation" << std::endl;

    waitStart = true;
    //Load the level data
    dataLoader.loadLevelData(QString("Data/level")
                             + QString::number(level)
                             + QString(".data"));

    emit sendTotalTime(convertTime(dataLoader.getBestTime()));


    Fly* mouche = new Fly("Fly",7,dataLoader.getInitPos().first,dataLoader.getInitPos().second,15,15,1);

    entityMap.insert(mouche->getID(),mouche);

    flyID = mouche->getID();

    DM.setEM(entityMap);
    emit sendDM(DM);

    emit newLevel(level);

    connect(&timer,SIGNAL(timeout()),this,SLOT(run()));
    timer.start();

}
示例#3
0
void Environment::run(){

    ((Fly*) entityMap.value(flyID))->move();

    bool badAngle = false;

    if(!waitStart){
        int tmpT = chrono.elapsed();

        envTime currentTime = convertTime(tmpT);

        emit sendTime(currentTime);
    }

    if(getFly()->isInSlidingMod()){
        getFly()->Boost(true);
        emit padBlock();
    }

    if(getFly()->get_trigger().intersection(hitBox,sf::Color::Black)){

        isSliding= false;

        if(!getFly()->isInSlidingMod()){
            getFly()->Boost(false);
        }
        if(!badAngle && !isSliding){
            badAngle =  getFly()->slide(hitBox);
            isSliding = true;
        }
        if (badAngle)
            emit sigWall();


    }
    if(((Fly*) entityMap.value(flyID))->get_trigger().intersection(hitBox,sf::Color::Red)){
        // La Mort !
        reloadLevel();
        playerStat.insert("mort",playerStat.value("mort")+1);
        //        bonusPurge();
        //        bonusLoader(level);
    }
    if(((Fly*) entityMap.value(flyID))->get_trigger().intersection(hitBox,sf::Color(0,255,0))){
        if(((Fly*) entityMap.value(flyID))->get_trigger().intersection(hitBox,sf::Color(0,0,255)) && !isArrived){
            emit sigWall();
            getFly()->Boost(false);
        }else{
            isArrived = true;
        }
    }
    if(((Fly*) entityMap.value(flyID))->get_trigger().isInSprite(hitBox,sf::Color(0,0,255)) && !waitStart && isArrived){
        // ligne d'arrivee !

        waitStart = true;
        isArrived = false;

        totalTime = chrono.elapsed();

        if(totalTime < dataLoader.getBestTime()){
            dataLoader.saveHighScore(QString("Data/level")
                                     + QString::number(level)
                                     + QString(".data"),timeToString(convertTime(totalTime)));
            emit sendTotalTime(convertTime(totalTime));
            dataLoader.setBestTime(totalTime);
        }
    }
    if(((Fly*) entityMap.value(flyID))->get_trigger().isInSprite(hitBox,sf::Color::White) && waitStart){
        // départ !
        chrono.start();
        waitStart = false;

    }


    //    bpoint pt;
    //    pt.first = entityMap.value(flyID)->get_x();
    //    pt.second = entityMap.value(flyID)->get_y();

    //    for(int i = 0; i < cacaIdList.size();i++){
    //        if(entityMap.value(cacaIdList[i])->get_trigger().isIN(pt.first,pt.second)){
    //            DM.remove(cacaIdList[i],pt.second);

    //            /*   if(entityMap.value(bonusIdList[i])->get_nom() == "caca")
    //                playerStat.insert("score",playerStat.value("score")+100);
    //            if(entityMap.value(bonusIdList[i])->get_nom() == "cacador")
    //                playerStat.insert("score",playerStat.value("score")+1000);

    //*/
    //            entityMap.remove(cacaIdList[i]);
    //            cacaIdList.remove(i);
    //            cacaIdList.squeeze();

    //        }
    //    }
    //    for(int i = 0; i < cacadorIdList.size();i++){
    //        if(entityMap.value(cacadorIdList[i])->get_trigger().isIN(pt.first,pt.second)){
    //            DM.remove(cacadorIdList[i],pt.second);

    //            /*   if(entityMap.value(bonusIdList[i])->get_nom() == "caca")
    //                playerStat.insert("score",playerStat.value("score")+100);
    //            if(entityMap.value(bonusIdList[i])->get_nom() == "cacador")
    //                playerStat.insert("score",playerStat.value("score")+1000);

    //*/
    //            entityMap.remove(cacadorIdList[i]);
    //            cacadorIdList.remove(i);
    //            cacadorIdList.squeeze();

    //        }
    //    }



    DM.setEM(entityMap);

    emit sendDM(DM);
    emit sendMort(playerStat.value("mort"));
    emit sendScore(playerStat.value("score"));
}