Exemplo n.º 1
0
int main(){
	// Fps of the game
	const sf::Time ImageParSeconde = (CONTROLE_FLUXVIDEO) ? sf::seconds(1.f / 30.f) : sf::seconds(1.f / 100.f);
	sf::Clock timer;
	sf::Time derniereMaj = sf::Time::Zero;
	Controleur ctrl(CONTROLE_FLUXVIDEO);
	Modele modele(CONTROLE_FLUXVIDEO);
	FenetreVue vue(600, 450, CONTROLE_FLUXVIDEO);
	sf::RenderWindow* window = vue.creerFenetre();

	// Clear screen
	window->clear();
	vue.dessiner();
	// Update the window
	window->display();
	while (window->isOpen())
	{
		// Count the time for each iteration of the loop
		sf::Time tempsPasser = timer.restart();
		derniereMaj += tempsPasser;
		// Regulate number of frame per second
		while (derniereMaj > ImageParSeconde){
			derniereMaj -= ImageParSeconde;
			modele.genererBonus(ImageParSeconde);
			ctrl.ecouterControleutilisateur(window, modele.getH().getRaquetteRef());
			modele.bougerRaquette(ctrl.getSens(), ImageParSeconde.asSeconds());
			modele.bougerIA(ImageParSeconde.asSeconds());
			modele.bougerBalle(ImageParSeconde.asSeconds());
			vue.actualiser(modele.getH(), modele.getIA(), modele.getB(), modele.getBonus(), ctrl.getCurseur());
			if (CONTROLE_FLUXVIDEO){
				// Clear screen
				window->clear();
				vue.dessiner();
				// Update the window
				window->display();
			}
		}
		// Clear screen
		window->clear();
		vue.dessiner();
		// Update the window
		window->display();
	}
	return 0;
}
Exemplo n.º 2
0
void ProduceDoc::organize(){
    QString parametersForTableFormat = m_tableFormatParameters;
    QTextTableFormat tableFormat;
    myFormat(tableFormat,parametersForTableFormat);
    int nombrejoursannee              = m_date.daysInYear();
    QTextCursor   *cursortrie         = new QTextCursor(m_textDocument);

//-----------------------insertion du titre du document-----------------------------------

    QString titreDoc                   = "<font size = 10 color = #3300FF><bold>"+tr("Ledger")+"<bold></font>"
                                         "<br/><br/><br/>";
    //QFont   titreFont                  ("Times", 40, QFont::Bold);
    //QTextCharFormat titreFormat ;
    //titreFormat                       . setFont(titreFont);
    QTextBlockFormat centrer ;
       //centrer                       .setBackground(Qt::yellow) ;
       centrer                        .setForeground(Qt::red) ;
       centrer                        .setAlignment(Qt::AlignCenter) ;
       centrer                        .setLeftMargin(24.0) ;
       centrer                        .setRightMargin(32.0) ;
       centrer                        .setTopMargin(16.0) ;
       centrer                        .setBottomMargin(24.0) ;

    cursortrie                        ->insertBlock(centrer);
    //cursortrie                        ->insertFragment(titredoc);
    cursortrie                        ->insertHtml(titreDoc);
    cursortrie                        ->movePosition(QTextCursor::Down,QTextCursor::MoveAnchor,1);
//janvier
    QString unjanv                    = m_date.toString("yyyy")+"-01-01";
    QString trenteetunjanv            = m_date.toString("yyyy")+"-01-31";
    QString janvier                   = tr("january");
    QString janvList;
    janvList                          = unjanv +","+ trenteetunjanv;


//fevrier------------mois particulier !
    QString unfev                     = m_date.toString("yyyy")+"-02-01";
    QString vingthuitfev              = m_date.toString("yyyy")+"-02-28";
        if(nombrejoursannee == 366){
            vingthuitfev  = m_date.toString("yyyy")+"-02-29";
            }
    QString fevrier                   =  tr("february");
    QString fevList;
    fevList                           = unfev +","+ vingthuitfev;
//mars
        QString unmars                = m_date.toString("yyyy")+"-03-01";
    QString trenteetunmars        = m_date.toString("yyyy")+"-03-31";
    QString mars = tr("march");
    QString marsList;
    marsList                      = unmars +","+ trenteetunmars;
 //avril
        QString unavril               = m_date.toString("yyyy")+"-04-01";
    QString trenteavril           = m_date.toString("yyyy")+"-04-30";
    QString avril                 = tr("april");
    QString avrList;
    avrList                       = unavril +","+ trenteavril;
 //mai
        QString unmai                 = m_date.toString("yyyy")+"-05-01";
    QString trenteetunmai         = m_date.toString("yyyy")+"-05-31";
    QString mai                   = tr("may");
    QString maiList;
    maiList                       = unmai +","+ trenteetunmai;
 //juin
        QString unjuin                = m_date.toString("yyyy")+"-06-01";
    QString trentejuin            = m_date.toString("yyyy")+"-06-30";
    QString juin                  = tr("june");
    QString juinList;
    juinList                     = unjuin +","+ trentejuin;
 //juillet
        QString unjuillet            = m_date.toString("yyyy")+"-07-01";
    QString trenteetunjuillet    = m_date.toString("yyyy")+"-07-31";
    QString juillet              = tr("july");
    QString juillList;
    juillList                    = unjuillet +","+ trenteetunjuillet;
 //aout
        QString unaout               = m_date.toString("yyyy")+"-08-01";
    QString trenteetunaout       = m_date.toString("yyyy")+"-08-31";
    QString aout                 = tr("august");
    QString aouList;
    aouList                      = unaout +","+ trenteetunaout;
 //septembre
        QString unsept               = m_date.toString("yyyy")+"-09-01";
    QString trentesept           = m_date.toString("yyyy")+"-09-30";
    QString sept                 = tr("september");
    QString sepList;
    sepList                      = unsept +","+ trentesept;
 //octobre
        QString unoct                = m_date.toString("yyyy")+"-10-01";
    QString trenteetunoct        = m_date.toString("yyyy")+"-10-31";
    QString oct                  = tr("october");
    QString octList;
    octList                      = unoct +","+ trenteetunoct;
 //novembre
        QString unnov                = m_date.toString("yyyy")+"-11-01";
    QString trentenov            = m_date.toString("yyyy")+"-11-30";
    QString nov                  = tr("november");
    QString novList;
    novList                      = unnov +","+ trentenov;
 //decembre
        QString undec                = m_date.toString("yyyy")+"-12-01";
    QString trenteetundec        = m_date.toString("yyyy")+"-12-31";
    QString dec                  = tr("december");
    //modele(dec, undec , trenteetundec ,tableFormat,cursortrie,m_listforquery);
    //cursortrie->movePosition(QTextCursor::End,QTextCursor::MoveAnchor,1);
    QString decList;
    decList                      = undec +","+ trenteetundec;

//annee
        QString annee                = tr("complete year");
    QString anneeList;
    anneeList                    = unjanv+","+ trenteetundec;
//--------------construction de listes des types----------------------------------------------------------
    if (WarnDebugMessage)
              qDebug() << __FILE__ << QString::number(__LINE__) << " thread 1 "   ;
    LedgerIO lio(0);
    m_typesReceipts = lio.listOfReceiptsTypes();
    m_typesReceipts.removeDuplicates();
    m_typesMovements = lio.listOfMovementsTypes();
    m_typesMovements.removeDuplicates();
    if (WarnDebugMessage)
              qDebug() << __FILE__ << QString::number(__LINE__) << " thread 2 "   ;
//------------boucles mois ---------------------------------------------------------------------
    QStringList listeMois;
        listeMois << janvier << fevrier << mars << avril << mai << juin
                  << juillet << aout << sept << oct << nov << dec << annee ;
    QStringList datesMois;
        datesMois << janvList << fevList << marsList << avrList << maiList << juinList << juillList
                  << aouList << sepList << octList << novList << decList << anneeList;
    for (int i = 0 ; i < listeMois.size() ; i++)
    {
        QString mois      = listeMois[i];
        QString dates     = datesMois[i];
        QStringList list  = dates.split(",");
        QString debutMois = list[0];
        QString finMois   = list[1];

        modele(listeMois[i], debutMois , finMois ,tableFormat,cursortrie);
        cursortrie->movePosition(QTextCursor::End,QTextCursor::MoveAnchor,1);
    }
}//end of organize()