Ejemplo n.º 1
0
/**
 * Initialise le pacman
 * @param c Coordonnée initiale du pacman
 * @return void
 */
void PacmanModel::init(const Coordonnee &c) {
	this->couleur = Couleur(0, 0, 0);
	this->cNormal = this->couleur;
	this->cSpecial = Couleur(1, 0, 0);
	this->coord = c;
	this->coordInitiales = c;
}
Ejemplo n.º 2
0
int main(int argc, char* argv[])
{
    gtk_init(&argc, &argv);

    Souris s;
    int xSouris, ySouris, boutonAppuye; // les infos de la souris

    Fenetre f("Exo2 - Case à cocher (avec constructeurs)", 500, 500);
    s.associerA(f);

    CaseACocher c(f.largeur()/2 - 15, f.hauteur()/2 - 15, 30, Couleur(0, 0, 65535), false);
    c.afficher(f);

    while (!s.testeBoutons(xSouris, ySouris, boutonAppuye)); // attendre le premier clique

    while (boutonAppuye!=3) // clique droit : stop le programme
    {
        if(boutonAppuye==1 && c.cadre().touche(xSouris, ySouris)) // si clique gauche
        {
            c.effacer(f);
            if(c.etat()=='C') 
                c.definirEtat('N'); 
            else
                c.definirEtat('C');
            
            c.afficher(f);
        }

        while (!s.testeBoutons(xSouris, ySouris, boutonAppuye)); // wainting for an other click
    }

    f.disparait();

    return 0;
}
Ejemplo n.º 3
0
void Bouton::dessiner() {
	if(estImage()) {
		Couleur t = Affichage::teinte();
		if(!_actif) {
			Affichage::definirTeinte(Couleur(0, 180));
		}
		else if(_enfonce || (_clic && this->cadreAbsolu().contientPoint(Session::souris()))) { // clic
			Affichage::definirTeinte(Couleur(0, 150));
		}
		else if(_valeur) { // enfoncé
			Affichage::definirTeinte(Couleur(0, 100));
		}
		else { // état normal
			Affichage::definirTeinte(Couleur::blanc);
		}
		
		_image.afficher(glm::vec2(0));
		Affichage::definirTeinte(t);
	}
	else if(estTexte()) {
		Affichage::afficherRectangle(Rectangle(0, 0, Ecran::largeur(), Ecran::hauteur()), Couleur::noir);
		Couleur fond, texte;
		if(!_actif) {
			fond = Couleur::grisClair;
			texte = Couleur::grisFonce;
		}
		else if(_clic && this->cadreAbsolu().contientPoint(Session::souris())) {
			fond = Couleur(50, 255);
			texte = Couleur::noir;
		}
		else if(_valeur) {
			fond = Couleur(90, 255);
			texte = Couleur::noir;
		}
		else {
			fond = Couleur::gris;
			texte = Couleur::noir;
		}
		Affichage::afficherRectangle(Rectangle(glm::vec2(1, 1), this->dimensions() - glm::vec2(2, 2)), fond);
		_texte.definir(texte);
		_texte.afficher(this->dimensions() / 2.0f - _texte.dimensions() / 2.0f);
	}
	
	_enfonce = false;
}
Ejemplo n.º 4
0
int main (int argc, char* argv[])
{
    gtk_init(&argc, &argv);

    Fenetre f;
    Souris s;
    Carre c;
    int x, y, b;

    f.apparait("Exo 3", 400, 400, 0, 0);
    f.choixCouleurTrace(0,0,0);

    c.placer(100,20);
    c.dimensionner(40);
    c.definirCouleur(65535,0,0);


    c.afficher(f);

    s.associerA(f);

    f.choixCouleurTrace(65535, 0, 0);

    while (!s.testeBoutons(x, y, b));

    while (b!=3)
    {
        if(b==1 && c.touche(x, y) && (c.couleur().rouge() == 65535) && (c.couleur().vert()==0) && (c.couleur().bleu() == 0))
        {
            c.definirCouleur(Couleur(0,0, 65535));
            c.afficher(f);
        }
        else if(b==1 && c.touche(x, y) && (c.couleur().rouge() == 0) && (c.couleur().vert()==0) && (c.couleur().bleu() == 65535))
        {
            c.definirCouleur(Couleur(65535,0, 0));
            c.afficher(f);
        }
        while (!s.testeBoutons(x, y, b));
    }

    f.disparait();

    return 0;
}
Ejemplo n.º 5
0
int main (int argc, char **argv)
{
    gtk_init(&argc, &argv);

    FenGrille f;
    Souris s;
    f.apparait("TP7 - exo 2");
    f.choixCouleurTrace(Couleur(0,0,0));
    s.associerA(f);

	CaseACocher cac1(40,40,30,Couleur(65535,0,0), 'h');
	CaseACocher cac2(40,80,30,Couleur(0,50000,0), 'h');

	f.afficherCase(cac1);
	f.afficherCase(cac2);

	int x,y,b;
    while (!s.testeBoutons(x, y, b));

    return 0;
}
Ejemplo n.º 6
0
/**
 * Modifie un filtre existant, version simplifiée de l'autre version
 * @param nom le nom du filtre
 * @param oldNom l'ancien nom du filtre
 * @return vrai si réussite
 */
bool PreferenceCouleur::ModifierFiltre(wxString nom, wxString oldNom)
{
    return ModifierFiltre(nom,
        Couleur(m_sliderFond[ROUGE].GetValue(), m_sliderFond[VERT].GetValue(), m_sliderFond[BLEU].GetValue()),
        Couleur(m_sliderBarre[ROUGE].GetValue(), m_sliderBarre[VERT].GetValue(), m_sliderBarre[BLEU].GetValue()),
        Couleur(m_sliderPolice[ROUGE].GetValue(), m_sliderPolice[VERT].GetValue(), m_sliderPolice[BLEU].GetValue()),
        Couleur(m_checkBoxHaut[ROUGE].GetValue(), m_checkBoxHaut[VERT].GetValue(), m_checkBoxHaut[BLEU].GetValue(), true),
        Couleur(m_checkBoxMiSup[ROUGE].GetValue(), m_checkBoxMiSup[VERT].GetValue(), m_checkBoxMiSup[BLEU].GetValue(), true),
        m_doubleBarre->GetValue(),
        Couleur(m_checkBoxMiInf[ROUGE].GetValue(), m_checkBoxMiInf[VERT].GetValue(), m_checkBoxMiInf[BLEU].GetValue(), true),
        Couleur(m_checkBoxBas[ROUGE].GetValue(), m_checkBoxBas[VERT].GetValue(), m_checkBoxBas[BLEU].GetValue(), true),
        oldNom);
}
Ejemplo n.º 7
0
/**
 * Applique les valeurs du filtre audio sélectionné
 */
void PreferenceCouleur::AppliquerFiltreSelectionne()
{
    /*if (m_textNomSet->IsEmpty())
        return;*/
    Parametre::Get()->setCouleurs(
        Couleur(m_sliderFond[ROUGE].GetValue(), m_sliderFond[VERT].GetValue(), m_sliderFond[BLEU].GetValue()),
        Couleur(m_sliderBarre[ROUGE].GetValue(), m_sliderBarre[VERT].GetValue(), m_sliderBarre[BLEU].GetValue()),
        Couleur(m_sliderPolice[ROUGE].GetValue(), m_sliderPolice[VERT].GetValue(), m_sliderPolice[BLEU].GetValue()),
        Couleur(m_checkBoxHaut[ROUGE].GetValue(), m_checkBoxHaut[VERT].GetValue(), m_checkBoxHaut[BLEU].GetValue(), true),
        Couleur(m_checkBoxMiSup[ROUGE].GetValue(), m_checkBoxMiSup[VERT].GetValue(), m_checkBoxMiSup[BLEU].GetValue(), true),
        Couleur(m_checkBoxMiInf[ROUGE].GetValue(), m_checkBoxMiInf[VERT].GetValue(), m_checkBoxMiInf[BLEU].GetValue(), true),
        Couleur(m_checkBoxBas[ROUGE].GetValue(), m_checkBoxBas[VERT].GetValue(), m_checkBoxBas[BLEU].GetValue(), true),
        m_doubleBarre->GetValue()
        );
}
Ejemplo n.º 8
0
void CaseACocher::dessiner() {
	Rectangle filtre;
	glm::vec2 d(0);
	
	Couleur t = Affichage::teinte();
	Affichage::ajouterOpacite(255);
	if(!_actif) {
		Affichage:: supprimerOpacite();
		Affichage::ajouterOpacite(128);
	}
	else if(_enfonce || (_clic && this->cadreAbsolu().contientPoint(Session::souris()))) { // clic
		Affichage::definirTeinte(Couleur(0, 100));
	}
	
	if(this->valeurIndeterminee()) {
		filtre.gauche = 0;
		filtre.haut = 0;
		filtre.hauteur = 22;
		filtre.largeur = 22;
		d.y = 2;
	}
	else if(_valeur) { // enfoncé
		filtre.gauche = 44;
		filtre.haut = 0;
		filtre.hauteur = 24;
		filtre.largeur = 23;
	}
	else { // état normal
		filtre.gauche = 22;
		filtre.haut = 0;
		filtre.hauteur = 22;
		filtre.largeur = 22;
		d.y = 2;
	}
		
	if(!caseACocher.chargee())
		caseACocher = Image(Session::cheminRessources() + "caseACocher.png");
	
	caseACocher.afficher(d, filtre);
	Affichage::definirTeinte(t);
	Affichage::supprimerOpacite();
	_texte.afficher(glm::vec2(filtre.largeur + 4 + !_valeur, (24 - _texte.dimensions().y) / 2));
}
Ejemplo n.º 9
0
Archivo: tp1.cpp Proyecto: confiture/M2
//////////////////////////////////////////////////////////////////
// ecriture dans un fichier VECT d'une liste de segments
// Entrée : E1,E2 : points extrémité des segments (tableaux de Point3)
//            le segment i est [E1[i],E2[i]]
//          N = nombre de segments
//          nom_fichier = le nom du fichier
//          coul = couleur (par défaut noir = {0,0,0})
// la routine renvoie 0 si le fichier a été créé correctement, 1 sinon
int ecrire_segments_VECT(Point3 E1[], Point3 E2[], int N,
                         const char* nom_fichier, Couleur coul=Couleur(0,0,0))
{
	// ouverture du fichier
	FILE* f=fopen(nom_fichier,"w");
	if (f==(FILE *)NULL)
	{
		fprintf(stderr, "ecrire_segments_VECT : fichier incorrect\n");
		return 1;
	}

	// écriture de l'en-tête
	fprintf(f, "VECT\n%i %i %i\n", N, N*2, N);
	fprintf(f,"\n");

	// nombre de points par segment : 2
	for (int i=0; i<N; i++)
		fprintf(f, " 2");
	fprintf(f, "\n\n");

	// nombre de couleurs par segment : 1
	for (int i=0; i<N; i++)
		fprintf(f, " 1");
	fprintf(f, "\n\n");

	// les différents points des segments
	for (int i=0; i<N; i++)
	{
		fprintf(f, " %15.7e %15.7e %15.7e\n", E1[i].x, E1[i].y, E1[i].z);
		fprintf(f, " %15.7e %15.7e %15.7e\n", E2[i].x, E2[i].y, E2[i].z);
		fprintf(f, "\n");
	}
	fprintf(f, "\n");

	// les couleurs
	for (int i=0; i<N; i++)
		fprintf(f, " %7.3f %7.3f %7.3f %7.3f\n",
		        coul.r, coul.g, coul.b, 1.0);

	// fermeture du fichier
	fclose(f);
	return 0;
}
Ejemplo n.º 10
0
namespace lma
{
  template<class T>
  std::string to_string(const T& o)
  {
    std::stringstream str;
    str << o;
    return str.str();
  }
  
  struct Couleur
  {
    template<class T> std::string operator()(const T& o) const
    { return "\033[" + lma::to_string(o) + "m"; }

    std::string operator()() const { return "\033[0m"; }
    std::string reset() const { return "\033[0m"; }
    std::string red() const { return "\033[31m"; }
    std::string black() const { return "\033[30m"; }
    std::string green() const { return "\033[32m"; }
    std::string white() const { return "\033[37m"; }
    std::string cyan() const { return "\033[36m"; }
    std::string yellow() const{ return "\033[33m"; }
    std::string blue() const{ return "\033[34m"; }
    std::string magenta() const{ return "\033[35m"; }
    std::string bold() const { return this->operator()(1);}
    std::string underline() const { return this->operator()(4);}
    std::string background() const { return this->operator()(7);}
    std::string barre() const { return this->operator()(9);}
    std::string italic() const { return "\033[3m"; }
    std::string yellow(const std::string& str) const { return yellow() + str + reset(); }
    std::string green(const std::string& str) const { return green() + str + reset(); }
    std::string red(const std::string& str) const { return red() + str + reset(); }
  };

  static const Couleur color = Couleur();
  
} 
Ejemplo n.º 11
0
MenuInterface::MenuInterface(VueInterface *parent, std::vector<std::pair<Unichar, index_t>> const &elements, int selection) : VueInterface(Rectangle(), Couleur(220, 240)), _elements(elements.begin(), elements.end()) {
    this->init(parent, selection);
}
Ejemplo n.º 12
0
/**
 * Constructeur vide d'une entité
 */
Entite::Entite() {
	coord = Coordonnee();
	couleur = Couleur();
}
Ejemplo n.º 13
0
void TableauDeBord::dessiner() {
	Affichage::ajouterOpacite(220);
	_fond.afficher(glm::vec2(0, 0));
	Affichage::supprimerOpacite();
	
	size_t lBarre = 200, hBarre = 30;

	glm::vec2 const positionVie(50, 100);

	for(index_t i = 0; i != hBarre; ++i) {
		Affichage::afficherRectangle(Rectangle(positionVie.x * Ecran::echelle().x, (positionVie.y + i) * Ecran::echelle().y, lBarre * Ecran::echelle().x, 1 * Ecran::echelle().y), Couleur(255 - 6 * std::abs(15 - i), 80, 80));
		Affichage::afficherRectangle(Rectangle(positionVie.x * Ecran::echelle().x, (positionVie.y + i) * Ecran::echelle().y, _joueur->vieActuelle() * lBarre / _joueur->vieTotale() * Ecran::echelle().x, 1 * Ecran::echelle().y), Couleur(230 - 8 * std::abs(15 - i), 0, 0));
	}
	 
	Texte chiffres(TRAD("tabBord vie %1/%2", _joueur->vieActuelle(), _joueur->vieTotale()), POLICE_GRANDE, 16 * Ecran::echelleMin(), Couleur::blanc);
	chiffres.afficher(glm::vec2(positionVie.x * Ecran::echelle().x, positionVie.y * Ecran::echelle().y) + (glm::vec2(lBarre * Ecran::echelle().x, hBarre * Ecran::echelle().y) - chiffres.dimensions()) / 2.0f);
	
	glm::vec2 const positionXp(Ecran::largeur() / Ecran::echelle().x - 50 - lBarre , positionVie.y);
	for(index_t i = 0; i != hBarre; ++i) {
		Affichage::afficherRectangle(Rectangle(positionXp.x * Ecran::echelle().x, (positionXp.y + i) * Ecran::echelle().y, lBarre * Ecran::echelle().x, 1 * Ecran::echelle().y), Couleur(12 * std::abs(15 - i), 12 * std::abs(15 - i), 12 * std::abs(15 - i)));
		Affichage::afficherRectangle(Rectangle(positionXp.x * Ecran::echelle().x, (positionXp.y + i) * Ecran::echelle().y, _joueur->xp() * lBarre / _joueur->xpTotale() * Ecran::echelle().x, 1 * Ecran::echelle().y), Couleur(6 * std::abs(15 - i), 6 * std::abs(15 - i), 6 * std::abs(15 - i)));
	}
	
	chiffres.definir(TRAD("tabBord Niveau %1 - %2/%3", _joueur->niveauXp(), _joueur->xp(), _joueur->xpTotale()));
	chiffres.afficher(glm::vec2(positionXp.x * Ecran::echelle().x,  positionXp.y * Ecran::echelle().y) + (glm::vec2(lBarre * Ecran::echelle().x, hBarre * Ecran::echelle().y) - chiffres.dimensions()) / 2.0f);

	Unichar txt;
	switch(_joueur->interaction()) {
		case Joueur::ij_attaquer: {
			Personnage *p = _joueur->attaque();
			txt = TRAD("tabBord Attaquer l'ennemi (%1/%2 vie)", p->vieActuelle(), p->vieTotale());
			break;
		}
		case Joueur::ij_commerce:
			txt = TRAD("tabBord Acheter/vendre des objets");
			break;
		case Joueur::ij_ramasser: {
			std::pair<size_t, size_t> nbObjets = _joueur->nombreObjets();
			if(nbObjets.first == 1 && nbObjets.second == 0)
				txt = TRAD("tabBord Ramasser 1 objet");
			else if(nbObjets.first > 1 && nbObjets.second == 0)
				txt = TRAD("tabBord Ramasser %1 objets", nbObjets.first);
			else if(nbObjets.first == 1 && nbObjets.second == 1)
				txt = TRAD("tabBord Ramasser 1 objet et 1 or");
			else if(nbObjets.first > 1 && nbObjets.second == 1)
				txt = TRAD("tabBord Ramasser %1 objets et 1 or", nbObjets.first);
			else if(nbObjets.first == 0 && nbObjets.second == 1)
				txt = TRAD("tabBord Ramasser 1 or");
			else if(nbObjets.first == 1 && nbObjets.second > 1)
				txt = TRAD("tabBord Ramasser 1 objet et %1 or", nbObjets.second);
			else if(nbObjets.first > 1 && nbObjets.second > 1)
				txt = TRAD("tabBord Ramasser %1 objets et %2 or", nbObjets.first, nbObjets.second);
			else if(nbObjets.first == 0 && nbObjets.second > 1)
				txt = TRAD("tabBord Ramasser %1 or", nbObjets.second);
			break;
		}
		case Joueur::ij_finirNiveau:
			txt = TRAD("Terminer le niveau");
		case Joueur::ij_aucune:
			break;
	}
	
	_interactionJoueur.definir(12 * Ecran::echelleMin());
	_interactionJoueur.definir(txt);
	_interactionJoueur.afficher(glm::vec2((Ecran::largeur() - _interactionJoueur.dimensions().x) / 2, (positionVie.y + hBarre / 2) * Ecran::echelle().y - _interactionJoueur.dimensions().y / 2));
}
Ejemplo n.º 14
0
void Affichage::ajouterSommets(size_t sommets, size_t composantesSommet, coordonnee_t const *pos, coordonnee_t const *couleurs, GLushort const *index) {
    Affichage::changerTexture(Ecran::vide().tex());
    Affichage::verifierDimensions(sommets);
    static glm::vec2 tex[3] = {glm::vec2(0.0, 0.0), glm::vec2(0.0, 1.0), glm::vec2(1.0, 1.0)};
    for(index_t i = 0; i < sommets; ++i) {
        index_t indx = i;
        if(index) {
            indx = index[i];
        }
        Affichage::ajouterSommet(glm::vec2(pos[composantesSommet * indx], pos[composantesSommet * indx + 1]), tex[i % 3], Couleur(couleurs[4 * indx] * 255, couleurs[4 * indx + 1] * 255, couleurs[4 * indx + 2] * 255, couleurs[4 * indx + 3] * 255), false);
    }
}
Ejemplo n.º 15
0
Unichar BoiteDialogue::afficher(Unichar const &texte, Unichar const &description, Unichar const &bouton1, Unichar const &bouton2, Unichar const &bouton3) {
	Unichar retour;

	AfficheurImage fond(Ecran::ecran(), *Ecran::apercu(), Couleur::noir, Couleur(Couleur::noir, 150));
	TexteEtiquette titre(Unichar(), glm::vec2(20, 20), POLICE_NORMALE, 18, Couleur::blanc);
	
	titre.definirDimensions(glm::vec2(Ecran::largeur() * 4 / 5 - 40, 10));
	titre.definirValeurTexte(texte);
	
	TexteEtiquette sousTitre(Unichar(), glm::vec2(20, titre.position().y + titre.dimensions().y + 20), POLICE_NORMALE, 15, Couleur::blanc);
	sousTitre.definirDimensions(glm::vec2(Ecran::largeur() * 4 / 5 - 40, 10));
	sousTitre.definirValeurTexte(description);
	
	
	Bouton b1(glm::vec2(50, 0), bouton1);
	Bouton b2(glm::vec2(50, 0), bouton2);
	Bouton b3(glm::vec2(50, 0), bouton3);

	double largeur = b1.dimensions().x;
	if(!bouton2.empty())
		largeur += 50 + b2.dimensions().x;
	if(!bouton3.empty())
		largeur += 50 + b3.dimensions().x;

	b1.definirPosition(glm::vec2(Ecran::largeur() * 4 / 5 - 20 - b1.dimensions().x, titre.position().y + titre.dimensions().y + 50));
	b1.definirAction(BoiteDialogue::bouton);
	b1.definirParametreAction(&retour);
	b1.definirRaccourci(Session::T_ENTREE);
	
	if(!bouton2.empty()) {
		b2.definirPosition(glm::vec2(b1.position().x - 20 - b2.dimensions().x, titre.position().y + titre.dimensions().y + 50));

		b2.definirAction(BoiteDialogue::bouton);
		b2.definirParametreAction(&retour);
		b2.definirRaccourci(Session::T_ESC);
	}
	if(!bouton3.empty()) {
		if(!bouton2.empty())
			b3.definirPosition(glm::vec2(b2.position().x - 50 - b3.dimensions().x, titre.position().y + titre.dimensions().y + 50));
		else
			b3.definirPosition(glm::vec2(b1.position().x - 50 - b3.dimensions().x, titre.position().y + titre.dimensions().y + 50));

		b3.definirAction(BoiteDialogue::bouton);
		b3.definirParametreAction(&retour);
		b3.definirRaccourci(Session::T_ESPACE);
	}
	
	AfficheurCouleur cadre(Rectangle(0, 0, Ecran::largeur() * 4 / 5, b1.cadre().haut + b1.cadre().hauteur + 20), Couleur(Couleur::noir, 120));
	titre.definirPosition(glm::vec2(20, 20));
	cadre.definirPosition(glm::vec2(std::max<coordonnee_t>(0.0, (Ecran::largeur() - cadre.dimensions().x)/ 2), 3 * Ecran::hauteur() / 7 - cadre.dimensions().y /2));
	
	fond.ajouterEnfant(cadre);
	
	cadre.ajouterEnfant(b1);
	if(!bouton2.empty())
		cadre.ajouterEnfant(b2);
	if(!bouton3.empty())
		cadre.ajouterEnfant(b3);

	cadre.ajouterEnfant(titre);
	cadre.ajouterEnfant(sousTitre);
	
	Ecran::definirPointeurAffiche(true);
	
	Session::ajouterVueFenetre(&fond);
	
	if(Session::evenement(Session::QUITTER))
		Session::reinitialiser(Session::QUITTER);
		
	return retour;
}
Ejemplo n.º 16
0
//          h = facteur d'échelle pour les vecteurs (par défaut 1.0)
// La routine trace les n segments [P[i],P[i]+h*N[i]]
void GEOMVIEW_points_vects(Point *P, Point *N, ULONG n,
  Couleur c, unsigned int e=1, double h=1.0);  
void GEOMVIEW_points_vects(const char *nom_fichier, Point *P, Point *N, ULONG n,
  Couleur c, unsigned int e=1, double h=1.0);  
  
///////////////////////////////////////////////////////////////////
// ecriture dans un fichier ou ajout à un fichier Geomview
// d'une triangulation T de sommets S
// chaque triangle T[j] est un triplet d'entiers {s1,s2,s3}
// indices des 3 sommets 
// Entrée : nom_fichier = le nom du fichier
//          S = tableaux de nS Point (les sommets)
//          nS = nombre de points
//          T = tableaux de nT Triangle (les triangles)
//          nT = nombre de points
//          col_face = couleur des faces (par défaut blanc)
//          col_edge = couleur des aretes (par défaut noir)
//          e = épaisseur des aretes pour la visu (par défaut 1)
// La routine trace les n segments [P[i],P[i]+h*N[i]]
void GEOMVIEW_triangulation(Point *S, ULONG nS, Triangle *T, ULONG nT,
  Couleur col_face=Couleur(1.0,1.0,1.0), Couleur col_edge=Couleur(0.0,0.0,0.0), 
  unsigned int e=1);  
void GEOMVIEW_triangulation(const char *nom_fichier, 
  Point *S, ULONG nS, Triangle *T, ULONG nT,
  Couleur col_face=Couleur(1.0,1.0,1.0), Couleur col_edge=Couleur(0.0,0.0,0.0), 
  unsigned int e=1);  
  
#endif
Ejemplo n.º 17
0
void Affichage::ajouterSommets(size_t sommets, size_t composantesSommet, coordonnee_t const *pos, coordonnee_t const *posTex, coordonnee_t const *couleurs) {
    Affichage::verifierDimensions(sommets);
    for(index_t i = 0; i < sommets; ++i) {
        Affichage::ajouterSommet(glm::vec2(pos[composantesSommet * i], pos[composantesSommet * i + 1]), glm::vec2(posTex[2 * i], posTex[2 * i + 1]), Couleur(couleurs[4 * i] * 255, couleurs[4 * i + 1] * 255, couleurs[4 * i + 2] * 255, couleurs[4 * i + 3] * 255), false);
    }
}
Ejemplo n.º 18
0
VueInterface *vueAvecObjets(std::list<ObjetInterface> const &objets, glm::vec2 const &ecartement) {
	VueInterface *retour = new VueInterface(Rectangle(0, 0, 2 * ecartement.x, 2 * ecartement.y));
	glm::vec2 position(ecartement), pMax;
	coordonnee_t largeur = ecartement.x;
	
	for(std::list<ObjetInterface>::const_iterator i = objets.begin(); i != objets.end(); ++i) {
		VueInterface *o = 0;
		TexteEtiquette *desc = 0;
		glm::vec2 posObj(position);
		if(!i->description.empty()) {
			desc = new TexteEtiquette(i->description, position, POLICE_NORMALE, 14, Couleur(200));
			posObj += glm::vec2(0, 10 + desc->dimensions().y);
		}
		switch(i->type) {
			case ObjetInterface::DESCRIPTION:
				break;
			case ObjetInterface::BOUTON:
				if(i->valeur.size() && i->valeur[0] == '/')
					o = new Bouton(posObj, Image(i->valeur));
				else
					o = new Bouton(posObj, i->valeur);
				static_cast<ControleInterface *>(o)->definirAction(i->action);
				static_cast<ControleInterface *>(o)->definirParametreAction(i->paramAction);
				break;
			case ObjetInterface::CASE_A_COCHER:
				o = new CaseACocher(posObj, i->valeur, false, Couleur(200));
				static_cast<ControleInterface *>(o)->definirAction(i->action);
				static_cast<ControleInterface *>(o)->definirParametreAction(i->paramAction);
				break;
			case ObjetInterface::CHAMP_DE_TEXTE:
				o = new ChampDeTexte(Rectangle(posObj, i->dimensions));
				static_cast<ChampDeTexte *>(o)->definirValeurTexte(i->valeur);
				static_cast<ControleInterface *>(o)->definirAction(i->action);
				static_cast<ControleInterface *>(o)->definirParametreAction(i->paramAction);
				break;
			case ObjetInterface::CHAMP_DE_NOMBRE:
				o = new ChampDeNombre(Rectangle(posObj, i->dimensions));
				static_cast<ChampDeNombre *>(o)->definirValeurTexte(i->valeur);
				static_cast<ControleInterface *>(o)->definirAction(i->action);
				static_cast<ControleInterface *>(o)->definirParametreAction(i->paramAction);
				break;
			case ObjetInterface::MENU_DEROULANT:
				o = new MenuDeroulant(posObj, std::vector<Unichar>(1, TRAD("mdef <menu non initialisé>")));
				static_cast<ControleInterface *>(o)->definirAction(i->action);
				static_cast<ControleInterface *>(o)->definirParametreAction(i->paramAction);
				break;
			case ObjetInterface::AFFICHEUR_IMAGE:
				o = new AfficheurImage(Rectangle(posObj, i->dimensions), Image(i->valeur));
				break;
		}
		
		if(o) {
			o->definirTag(i->tag);
			if(desc)
				retour->ajouterEnfant(*desc);
			retour->ajouterEnfant(*o);
			pMax.x = o->position().x + std::max(desc ? desc->dimensions().x : 0, o->dimensions().x);
			pMax.y = std::max(pMax.y, o->position().y + o->dimensions().y);
			largeur = std::max(largeur, pMax.x);
			
			if(i->saut == ObjetInterface::LIGNE) {
				position.x = ecartement.x;
				position.y = pMax.y + ecartement.y;
			}
			else if(i->saut == ObjetInterface::LIGNE_GROUPEE) {
				position.x = ecartement.x;
				position.y = pMax.y + ecartement.y / 2;
			}
			else if(i->saut == ObjetInterface::COLONNE) {
				position.x = pMax.x + ecartement.x;
			}
		}
		else {
			retour->ajouterEnfant(*desc);
			pMax.x = desc->position().x + desc->dimensions().x;
			pMax.y = desc->position().y + desc->dimensions().y;
			largeur = std::max(largeur, pMax.x);
		
			position.x = ecartement.x;
			position.y = pMax.y + ecartement.y / 2;
		}			
	}
	
	retour->definirDimensions(glm::vec2(largeur, pMax.y) + ecartement);
	
	return retour;
}
Ejemplo n.º 19
0
void MenuInterface::dessiner() {
    Affichage::afficherRectangle(Rectangle(0, 0, Ecran::largeur(), Ecran::hauteur()), _couleurFond);

    Affichage::afficherRectangle(Rectangle(0, 0, this->dimensions().x, 1), Couleur::noir);
    Affichage::afficherRectangle(Rectangle(0, 0, 1, this->dimensions().y), Couleur::noir);
    Affichage::afficherRectangle(Rectangle(0, this->dimensions().y - 1, this->dimensions().x, 1), Couleur::noir);
    Affichage::afficherRectangle(Rectangle(this->dimensions().x - 1, 0, 1, this->dimensions().x), Couleur::noir);

    glm::vec2 pos(20, 5);

    if(_premierAffiche != 0) {
        _fH.afficher(glm::vec2((this->dimensions().x - _fH.dimensions().x) / 2, pos.y + (_hF - _fH.dimensions().y) / 2));
        pos.y += _hF + 5;
    }

    for(index_t i = _premierAffiche; i != _dernierAffiche; ++i) {
        _elements[i]._pos = pos;
        if(i == _sousMenuSurvole) {
            Affichage::afficherRectangle(Rectangle(0, pos.y - 2, this->dimensions().x, _elements[i]._texte.dimensions().y + 4), Couleur(60, 85, 250));
            _elements[i]._texte.definir(Couleur::blanc);
        }
        _elements[i]._texte.afficher(_elements[i]._pos);
        if(i == _sousMenuSurvole)
            _elements[i]._texte.definir(Couleur::noir);

        if(i + this->valeurIndeterminee() == _sousMenuSelectionne) {
            Texte::afficher("x", POLICE_NORMALE, 14, i == _sousMenuSurvole ? Couleur::blanc : Couleur::noir, glm::vec2(5, pos.y));
        }

        pos.y += _elements[i]._texte.dimensions().y + 5;
    }

    if(_dernierAffiche != _elements.size()) {
        _fB.afficher(glm::vec2((this->dimensions().x - _fH.dimensions().x) / 2, pos.y + (_hF - _fB.dimensions().y) / 2));
        pos.y += _hF + 5;
    }
}