Beispiel #1
0
Maybe<Result<T>> Bad_v(Result<T> const& w) {
  switch (w.m_State) {
  case Result<T>::BAD_GOOD_VAL:
    return Just<Result<T>>(Good(w.m_Good_v));
  case Result<T>::BAD_BAD_VAL:
    return Just<Result<T>>(*(w.m_Bad_v));
  default:
    assert(w.m_State == Result<T>::BAD_NO_VAL);
    return Nothing<Result<T>>();
  }
}
Beispiel #2
0
bool
DirectParser::TryRead (int howmany)
{
  DirectMessage msg;
  bool haveOne (true);
  bool atLeastOne (false);
  for (int i=0; i<howmany && haveOne; i++) {
    haveOne = Read (msg);
    atLeastOne |= haveOne;
    if (haveOne) {
      emit Message (msg);
      qDebug () << " Good Direct Read, emit message with " 
                << msg.Op() <<"/" << msg.Subop();
    } else {
      qDebug () << " Bad Direct Read, no emit";
      if (Good () && !Complete()) {
        Reset ();
      }
    }
  }
  return atLeastOne ;
}
Beispiel #3
0
void Scene::setbg_3(){
    QString load;
    if(difficulty==4)
        load=":/pics/pics/bg_oni.png";
    else if(difficulty==3)
        load=":/pics/pics/bg_hard.png";
    else if(difficulty==2)
        load=":/pics/pics/bg_normal.png";
    else
        load=":/pics/pics/bg_easy.png";
    QImage bg;
    bg.load(load);
    bg = bg.scaled(770,400);
    this->setBackgroundBrush(bg);
    text1->setText(title[s]);
    text1->setPos(488,9);
    addItem(text1);
    Map.setSongPlay(title[s]);
    track = new QMediaPlayer(this);
    track->setMedia(QUrl::fromLocalFile(QDir::toNativeSeparators(Map.trackPath)));
    VOL=(Map.map["SONGVOL"]-Map.map["SEVOL"])>0?(Map.map["SONGVOL"]-Map.map["SEVOL"]+50):70;
    track->setVolume(VOL);
    BPM=Map.map["BPM"];
    Map.getMap(title[s],Map.star[difficulty-1]);
    Map.convert(setRandom);
    if(setRandom==true){
        QPixmap ran;
        ran.load(":/pics/pics/optionicon_random.png");
        randomTag = new QGraphicsPixmapItem;
        randomTag->setPos(199,83);
        randomTag->setPixmap(ran);
        addItem(randomTag);
    }
    if(setAuto==true){
        QPixmap au;
        au.load(":/pics/pics/optionicon_auto.png");
        autoTag = new QGraphicsPixmapItem;
        autoTag->setPos(394,72);
        autoTag->setPixmap(au);
        addItem(autoTag);
    }
    if(set30secMode==true){
        QPixmap ctd;
        ctd.load(":/pics/pics/optionicon_demo.png");
        countdownTag = new QGraphicsPixmapItem;
        countdownTag->setPos(294,72);
        countdownTag->setPixmap(ctd);
        addItem(countdownTag);
        countdown = new QTimer(this);
        QObject::connect(countdown , SIGNAL(timeout()) , this , SLOT(secondsLeft()));
    }
    songMap=Map.songMap;
    foreach (QString i, songMap) {
        qDebug()<<i<<endl;
    }

    RD = new QTimer(this);
    LD = new QTimer(this);
    RK = new QTimer(this);
    LK = new QTimer(this);
    rdp = new QGraphicsPixmapItem;ldp = new QGraphicsPixmapItem;
    rkp = new QGraphicsPixmapItem;lkp = new QGraphicsPixmapItem;
    QPixmap res;
    res.load(":/pics/pics/rd.png");
    rdp->setPixmap(res);rdp->setPos(147,123);
    res.load(":/pics/pics/ld.png");
    ldp->setPixmap(res);ldp->setPos(106,123);
    res.load(":/pics/pics/rk.png");
    rkp->setPixmap(res);rkp->setPos(147,124);
    res.load(":/pics/pics/lk.png");
    lkp->setPixmap(res);lkp->setPos(105,124);
    for(int i=0;i<4;i++){
        add[i]=false;
    }
    QObject::connect(this , SIGNAL(PlayRdong()) , this , SLOT(playRdong()));
    QObject::connect(this , SIGNAL(PlayLdong()) , this , SLOT(playLdong()));
    QObject::connect(this , SIGNAL(PlayRka()) , this , SLOT(playRka()));
    QObject::connect(this , SIGNAL(PlayLka()) , this , SLOT(playLka()));
    QObject::connect(RD , SIGNAL(timeout()) , this , SLOT(playRdong()));
    QObject::connect(LD , SIGNAL(timeout()) , this , SLOT(playLdong()));
    QObject::connect(RK , SIGNAL(timeout()) , this , SLOT(playRka()));
    QObject::connect(LK , SIGNAL(timeout()) , this , SLOT(playLka()));    

    AniTimer1 = new QTimer(this);
    QObject::connect(AniTimer1 , SIGNAL(timeout()) , this , SLOT(moveJudgement()));
    QObject::connect(AniTimer1 , SIGNAL(timeout()) , this , SLOT(FlySoul()));
    QObject::connect(AniTimer1 , SIGNAL(timeout()) , this , SLOT(MidSoul()));
    QObject::connect(AniTimer1 , SIGNAL(timeout()) , this , SLOT(WalkSoul()));

    QObject::connect(this , SIGNAL(Great()) , this , SLOT(GenGreat()));
    QObject::connect(this , SIGNAL(Good()) , this , SLOT(GenGood()));
    QObject::connect(this , SIGNAL(Miss()) , this , SLOT(GenMiss()));
    QObject::connect(this , SIGNAL(Combo()) , this , SLOT(ShowCombo()));
    QObject::connect(this , SIGNAL(Score()) , this , SLOT(ShowScore()));
    QObject::connect(this , SIGNAL(Jump()) , this , SLOT(donJump()));
    QObject::connect(this , SIGNAL(SoulF()) , this , SLOT(GenFlySoul()));
    QObject::connect(this , SIGNAL(SoulM()) , this , SLOT(GenMidSoul()));
    QObject::connect(this , SIGNAL(SoulW()) , this , SLOT(GenWalkSoul()));

    ex1.load(":/pics/pics/explosion_s4.png");
    AniTimer2 = new QTimer(this);
    QObject::connect(AniTimer2 , SIGNAL(timeout()) , this , SLOT(RemoveExplode()));
    QObject::connect(this , SIGNAL(Explode()) , this , SLOT(GenExplode()));

    AniTimer3 = new QTimer(this);
    QObject::connect(AniTimer3 , SIGNAL(timeout()) , this , SLOT(Jumper()));
    jumper = new QGraphicsPixmapItem;
    jumper->setPos(0,0);
    addItem(jumper);

    AniTimer4 = new QTimer(this);
    QObject::connect(AniTimer4 , SIGNAL(timeout()) , this , SLOT(Dance()));
    loadDancerPic();
    createDanceItem();

    great=0;good=0;miss=0;
    combo=0;maxcombo=0;soul=0,score=0;
    secLeft=30;jumpPicNum=1;
    msec=60000/BPM/4+2;
    test=60000/BPM/16;
    waitfor=109*test/2+Map.map["OFFSET"]*1000;
    for(int i=0;i<10;i++){
        numberPic[i].load(":/pics/pics/number_"+QString::number(i)+".png");
    }
    for(int i=0;i<10;i++){
        ctdnumberPic[i].load(":/pics/pics/number_"+QString::number(i)+".png");
    }
    for(int i=0;i<10;i++){
        scorenumberPic[i].load(":/pics/pics/scorenumber_"+QString::number(i)+".png");
    }
    for(int i=50;i<1000;i+=100){
        QSound *so;
        QString c;
        c=QString::number(i);
        so = new QSound(":/sound/sound/voice_"+c+"combo.wav");
        comTrack.push_back(so);
        if(i==50)i+=50;
    }
    for(int i=0;i<3;i++){
        jumpPic[i].load(":/pics/pics/playerchar_normal"+QString::number(i+1)+".png");
        jumpPic[i] = jumpPic[i].scaled(jumpPic[i].width()*1.48,jumpPic[i].height()*1.48);
    }
    //Etimer = new QElapsedTimer;
    //Etimer->start();

    timer = new QTimer(this);
    QObject::connect(timer , SIGNAL(timeout()) , this , SLOT(stopWait()));
    timer1 = new QTimer(this);
    timer2 = new QTimer(this);
    timer3 = new QTimer(this);
    cout<<"msec: "<<msec<<endl;
    cout<<"waitfor: "<<waitfor<<endl;
    QObject::connect(timer2 , SIGNAL(timeout()) , this , SLOT(Generate()));
    if(setAuto==false)
        QObject::connect(timer1 , SIGNAL(timeout()) , this , SLOT(Move()));
    else
        QObject::connect(timer1 , SIGNAL(timeout()) , this , SLOT(Auto()));

    QObject::connect(timer3 , SIGNAL(timeout()) , this , SLOT(startWave()));
    if(waitfor<0){
        track->play();
        timer->start(-waitfor);
        waitfor=0;
    }
    else
        timer->start(0);
}
Beispiel #4
0
	void Plugin::Migrate (IPluginsManager *manager)
	{
		QSettings settings
		{
			QCoreApplication::organizationName (),
			QCoreApplication::applicationName () + "_Azoth_LastSeen"
		};

		if (settings.allKeys ().isEmpty ())
			return;

		const auto& reporter = manager->CreateLoadProgressReporter (this);

		qDebug () << Q_FUNC_INFO
				<< "gonna migrate";

		const auto& avail = settings.value ("LastAvailable").value<LastHash_t> ();
		const auto& online = settings.value ("LastOnline").value<LastHash_t> ();
		const auto& status = settings.value ("LastStatusChange").value<LastHash_t> ();
		qDebug () << "done reading";

		QHash<QString, EntryStats> stats;

		{
			const auto& proc = reporter->InitiateProcess (tr ("Uniting keys"), 0, 3);

			for (const auto& pair : Util::Stlize (avail))
				stats [pair.first].Available_ = pair.second;

			++*proc;

			for (const auto& pair : Util::Stlize (online))
				stats [pair.first].Online_ = pair.second;

			++*proc;

			for (const auto& pair : Util::Stlize (status))
				stats [pair.first].StatusChange_ = pair.second;

			++*proc;
		}

		qDebug () << "done uniting";

		{
			auto lock = Storage_->BeginTransaction ();

			const auto& proc = reporter->InitiateProcess (tr ("Writing the database"), 0, stats.size ());
			for (const auto& pair : Util::Stlize (stats))
			{
				Storage_->SetEntryStats (pair.first, pair.second);
				++*proc;
			}

			qDebug () << "done writing";

			lock.Good ();

			qDebug () << "done committing";
		}

		settings.clear ();

		qDebug () << "done clearing";
	}
Beispiel #5
0
void Tokenizer::SkipSpaces()
{
    while (Good() && IsWhitespace(PeekNextChar())) {
        GetNextChar();
    }
}
Beispiel #6
0
void Tokenizer::ReadToken(Token& token)
{
start:

    SkipSpaces();
    token.value_s.clear();

    if (!Good()) {
        token.type = Token::type_eof;
        token.pos_string = "EOF";
        return;
    }

    std::stringstream token_tmp;
    if (!include_stack.empty() && !include_stack.back().name.empty())
        token_tmp << include_stack.back().name << " , ";
    token_tmp << "line " << include_stack.back().line << " , column " << include_stack.back().column;
    token.pos_string = token_tmp.str();

    char c = GetNextChar();
    token.value_s += c;
    // first find what token is it, and handle all except numbers
    switch (c) {
    case '[': {
        token.type = Token::type_section_name;
        token.value_s.clear();
        bool skip_next_eol_char = false;
        while (Good()) {
            c = GetNextChar();
            // std::string has problem with zero characters, replace by space.
            if (c == 0) {
                c = ' ';
            }
            if (c == '\\') {
                if (Good()) {
                    token.value_s += GetNextChar();
                } else {
                    ReportError(token, "Quotes not closed before end of file");
                    return;
                }
            } else if (c == ']') {
                return;
            } else {
                token.value_s += c;
            }
            // handle end of line
            if (skip_next_eol_char) {
                skip_next_eol_char = false;
            } else if (c == 10 || c == 13) {
                //++line;
                //column=1;
                if ((PeekNextChar() == 10 || PeekNextChar() == 13) && (PeekNextChar() != c))
                    skip_next_eol_char = true;
            }
        }
        ReportError(token, "Quotes not closed before end of file");
        return;
    }
    case '{':
        token.type = Token::type_enter_section;
        return;
    case '}':
        token.type = Token::type_leave_section;
        return;
    case ';':
        token.type = Token::type_semicolon;
        return;
    case '=':
        token.type = Token::type_entry_value;
        token.value_s = "";
        while (Good() && PeekNextChar() != ';') {
            unsigned char c_ = GetNextChar();
            token.value_s += c_;
        }
        return;
    case '/': // handle comments
        if (PeekNextChar() == '/') {
            //SkipToEOL();
            if (!include_stack.empty()) {
                std::string tmp;
                std::getline((*include_stack.back().stream), tmp);
                include_stack.back().line += 1;
                include_stack.back().column = 1;
            }

            goto start;
        } else if (PeekNextChar() == '*') { // multi-line comment
            while (Good()) {
                char c1 = GetNextChar();
                if ((c1 == '*') && (PeekNextChar() == '/')) {
                    GetNextChar();
                    break;
                }
            }
            goto start;
        }
    default:
        while (Good() && PeekNextChar() != '=') {
            unsigned char c_ = GetNextChar();
            token.value_s += c_;
        }
        token.type = Token::type_entry_name;
        return;
    }
}