1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
| //#define SUIVI
#include <SFML/Graphics.hpp>
#include <windows.h>
#include <string.h>
#include <cstdlib>
#ifdef SUIVI
#include <iostream>
#endif
#include "MenuColonneCentree.h"
using namespace std;
using namespace sf;
// Implémentation des méthodes de la classe
MenuColonneCentree::MenuColonneCentree(RenderWindow & argWINDOW):
window(argWINDOW) // Liste d'initialisation
{ Font fonte; // Fonte pour le texte des menus
fonte.loadFromFile("Fontes/FonteGVSC.ttf"); // Chargement d'un fichier font
Color couleur; // Couleur pour le texte des menus
couleur.r=255; couleur.g=100; couleur.b=0; couleur.a=255; // Création d'une couleur (rouge-orangé opaque)
width=VideoMode::getDesktopMode().width; // Récupérer résolution horizontale de l'écran
height=VideoMode::getDesktopMode().height; // Récupérer résolution verticale de l'écran
hauteurTextePrincipal=height/13;
hauteurTexteSecondaire=2*height/39;
longueurAnimation=15;
// Présélection par-défaut de l'animation zéro
animation=4;
#ifdef SUIVI
cout << "MenuColonneCentree, MenuColonneCentree OK" << endl;
#endif
}
void MenuColonneCentree::SetContenu(vector<vector<string> > argCONTENU)
{ // Vider les vecteurs
texte.clear();
posX.clear();
posY.clear();
options=(argCONTENU.size());
ligneSelectionnee=0; // Présélection de la première ligne
for (int index(0); index < options; index++)
{ texte[index][0].setString(argCONTENU[index][0]);
texte[index][1].setString(argCONTENU[index][1]);
texte[index][0].setFont(fonte);
texte[index][1].setFont(fonte);
texte[index][0].setColor(couleur);
texte[index][1].setColor(couleur);
texte[index][0].setStyle(0);
texte[index][1].setStyle(0);
posX[index][0]=width/2;
posX[index][1]=2*width/3;
posY[index][0]=(7-options+2*index)*hauteurTextePrincipal;
posY[index][1]=(8-options+2*index)*hauteurTextePrincipal;
}
etatAnimation=false;
etatExistence=true;
#ifdef SUIVI
cout << "MenuColonneCentree, SetContenu OK" << endl;
#endif
}
void MenuColonneCentree::ChoixAnimation(int argNUMERO)
{ animation=argNUMERO;
switch (animation)
{ case 0: etatAnimation=true; break; // Animation standard
case 1: etatAnimation=false; break; // Entrée en glissant pas la droite
case 2: etatAnimation=false; break; // Sortie en glissant pas la gauche
case 3: etatAnimation=false; break; // Sortie en glissant pas la droite
case 4: etatAnimation=true; break; // Animation zéro (ne rien faire)
}
etape=0;
X=0;
for (int index(0); index < options; index++)
{ texte[index][index].setCharacterSize(hauteurTextePrincipal);
texte[index][index].setOrigin(texte[index][index].getGlobalBounds().width/2, hauteurTextePrincipal/2);
texte[index][index+1].setCharacterSize(hauteurTexteSecondaire);
texte[index][index+1].setOrigin(texte[index][index+1].getGlobalBounds().width/2, hauteurTextePrincipal/2);
}
etatAnimation=false;
#ifdef SUIVI
cout << "MenuColonneCentree, ChoixAnimation OK" << endl;
#endif
}
void MenuColonneCentree::MouvementPreselection(int argMOUVEMENT)
{ // argMOUVEMENT : mouvement à effectuer (+ = descendre ; 0 = rester ; - = monter)
ligneSelectionnee+=argMOUVEMENT;
if (ligneSelectionnee > options) {ligneSelectionnee=0;}
else if (ligneSelectionnee < 0) {ligneSelectionnee=options;}
#ifdef SUIVI
cout << "MenuColonneCentree, MouvementPreselection OK" << endl;
#endif
}
void MenuColonneCentree::Animation(int argSTEP)
{ // argSTEP : nombre d'étapes à passer dans l'animation
etape+=argSTEP; // Incrémenter l'index d'animation
switch (animation)
{ case 0: // Animation standard de la ligne sélectionnée
if (etape >= longueurAnimation-1) {etape-=longueurAnimation;} // Ne pas dépasser 14
j=1+DecoupageQuadratiqueMiroir(etape, longueurAnimation); // ERROR: undefined reference to 'DecoupageQuadratiqueMiroir(int, int)'
texte[ligneSelectionnee][0].setCharacterSize(j*hauteurTextePrincipal);
texte[ligneSelectionnee][1].setCharacterSize(j*hauteurTexteSecondaire);
texte[ligneSelectionnee][0].setOrigin(texte[ligneSelectionnee][0].getGlobalBounds().width/2, j*hauteurTextePrincipal/2);
texte[ligneSelectionnee][1].setOrigin(texte[ligneSelectionnee][1].getGlobalBounds().width/2, j*hauteurTexteSecondaire/2);
break;
case 1: // Entrée en glissant par la droite
if (etape >= longueurAnimation-1) // Ne pas dépasser longueurAnimation-1
{ etape=longueurAnimation-1;
etatAnimation=true;
}
X=width*DecoupageQuadratiqueMiroir(etape, longueurAnimation); // ERROR: undefined reference to 'DecoupageQuadratiqueMiroir(int, int)'
break;
case 2: // Sortie en glissant par la gauche
if (etape >= longueurAnimation-1) // Ne pas dépasser longueurAnimation-1
{ etape=longueurAnimation-1;
etatAnimation=true;
etatExistence=false;
}
X=width*DecoupageQuadratiqueMiroir(longueurAnimation-1-etape, longueurAnimation); // ERROR: undefined reference to 'DecoupageQuadratiqueMiroir(int, int)'
break;
case 3: // Sortie en glissant par la droite
if (etape >= longueurAnimation-1) // Ne pas dépasser longueurAnimation-1
{ etape=longueurAnimation-1;
etatAnimation=true;
etatExistence=false;
}
X=-width*DecoupageQuadratiqueMiroir(longueurAnimation-1-etape, longueurAnimation); // ERROR: undefined reference to 'DecoupageQuadratiqueMiroir(int, int)'
break;
case 4: // Animation zéro (ne rien faire)
break;
}
for (int index(0); index == 2*(options+1); index++)
{ texte[index][0].setPosition(posX[index][0]+X, posY[index][0]);
texte[index][1].setPosition(posX[index][1]+X, posY[index][1]);
window.draw(texte[index][0]);
window.draw(texte[index][1]);
}
} |
Partager