Пример #1
0
    NextLevelDialog(GameControl* game)
        : Dialog("BRAVO!!!",Event::NOP,Event::MENU),
          m_game(game)
    {
        rightControl()->text("<--");
        char buf[32];
        const GameStats& stats = m_game->stats();
        int time = (stats.endTime - stats.startTime)/1000;
        int h = time/60/60;
        int m = time/60 - h*60;
        int s = time - m*60;

        Box *vbox = new VBox();
        vbox->add(new Spacer(),10,1);
        if (h > 0) {
            sprintf(buf,"time: %dh %dm %ds",m,h,s);
        } else if (m > 0) {
            int m = time/60/1000;
            sprintf(buf,"time: %dm %ds",m,s);
        } else {
            sprintf(buf,"time: %ds",s);
        }
        vbox->add(new Label(buf),20,0);
        sprintf(buf,"%d stroke%s",stats.strokeCount,stats.strokeCount==1?"":"s");
        vbox->add(new Label(buf),20,0);
        if (stats.pausedStrokes) {
            sprintf(buf,"     (%d while paused)",stats.pausedStrokes);
            vbox->add(new Label(buf),20,0);
        }
        sprintf(buf,"%d undo%s",stats.undoCount,stats.undoCount==1?"":"s");
        vbox->add(new Label(buf),20,0);
        vbox->add(new Spacer(),10,1);

        Box *hbox2 = new HBox();
        hbox2->add(new Spacer(),20,0);
        hbox2->add(new Button("review",Event(Event::REPLAY,game->m_level)),BUTTON_WIDTH,0);
        hbox2->add(new Spacer(),1,1);
        hbox2->add(new Button("again",Event::RESET),BUTTON_WIDTH,0);
        hbox2->add(new Spacer(),1,1);
        hbox2->add(new Button("next",Event::NEXT),BUTTON_WIDTH,0);
        hbox2->add(new Spacer(),20,0);
        vbox->add(hbox2,BUTTON_HEIGHT,0);

        vbox->add(new Spacer(),10,0);
        content()->add(vbox,0,0);
        m_targetPos = Vec2( 150, 70);
        sizeTo(Vec2(500,240));
    }