Class: FenetreStatistiques

Inherits:
View
  • Object
show all
Defined in:
app/view/FenetreStatistiques.rb

Overview

classe FenetreStatistiques

Constant Summary

Constants included from Fenetre

Fenetre::COULEUR_BLANC, Fenetre::COULEUR_BLEU, Fenetre::COULEUR_JAUNE, Fenetre::COULEUR_ORANGE, Fenetre::COULEUR_ROUGE, Fenetre::COULEUR_VERT, Fenetre::FONT_MENU, Fenetre::SIZE_AUTRE_JEU, Fenetre::SIZE_CONTENU_REGLE, Fenetre::SIZE_CONTENU_SCORE, Fenetre::SIZE_CONTENU_STAT, Fenetre::SIZE_LABEL_BOUTON, Fenetre::SIZE_PSEUDO, Fenetre::SIZE_TITRE, Fenetre::SIZE_TITRE_JEU, Fenetre::SIZE_TITRE_REGLAGE, Fenetre::SIZE_TITRE_REGLE, Fenetre::SIZE_TITRE_SCORE, Fenetre::SIZE_TITRE_STAT

Instance Attribute Summary

Attributes inherited from View

#content, #controller, #headerBar, #window

Instance Method Summary collapse

Methods inherited from View

inherited, #setInstanceVars

Methods included from Fenetre

appliquerStyle, boutonAnnuler_barre, boutonMenu_barre, boutonPauseChrono_barre, boutonPlayChrono_barre, boutonQuitter_barre, boutonReinit_barre, boutonRetablir_barre, boutonRetour, boutonSauvegarder_barre, box, creerBarreMenu, creerBoxBottom, creerLabelType, creerPopup, css, detruire, enteteFenetre, fenetre, fenetrePrecedente, fenetrePrecedente=, fenetreStyle, viderFenetre

Constructor Details

#initializeFenetreStatistiques

Initialize



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/view/FenetreStatistiques.rb', line 30

def initialize()
		# VI box
		@boxTop = Gtk::Box.new(:vertical,0)
		@boxBottom = Fenetre::creerBoxBottom()
		# VI label
		@titreLabel = Fenetre::creerLabelType("<u>Statistiques</u>",Fenetre::SIZE_TITRE)
	@labelDifficulte = Fenetre::creerLabelType("<u>Difficulté</u>",Fenetre::SIZE_TITRE_STAT)
	@labelRecord = Fenetre::creerLabelType("<u>Record</u>",Fenetre::SIZE_TITRE_STAT)
	@labelMoyenne = Fenetre::creerLabelType("<u>Moyenne</u>",Fenetre::SIZE_TITRE_STAT)
	@labelNbPartie = Fenetre::creerLabelType("<u>Nb Parties</u>",Fenetre::SIZE_TITRE_STAT)
	@labelFacile = Fenetre::creerLabelType("Facile", Fenetre::SIZE_CONTENU_STAT)
	@labelMoyen = Fenetre::creerLabelType("Moyen", Fenetre::SIZE_CONTENU_STAT)
	@labelDifficile = Fenetre::creerLabelType("Difficile", Fenetre::SIZE_CONTENU_STAT)
		# VI stat

		@tabStat = []
  
end

Instance Method Details

#ajoutCssObject

Ajoute les classes css au widget



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'app/view/FenetreStatistiques.rb', line 105

def ajoutCss()
    #css label
    @titreLabel.override_color(:normal, Fenetre::COULEUR_BLANC)
    @titreLabel.set_margin_top(30)
		@labelDifficulte.override_color(:normal, Fenetre::COULEUR_BLANC)
    @labelDifficulte.set_margin(30)		
		@labelRecord.override_color(:normal, Fenetre::COULEUR_BLANC)	
    @labelRecord.set_margin(30)	
		@labelMoyenne.override_color(:normal, Fenetre::COULEUR_BLANC)	
    @labelMoyenne.set_margin(30)	
		@labelNbPartie.override_color(:normal, Fenetre::COULEUR_BLANC)
    @labelNbPartie.set_margin(30)
		@labelFacile.override_color(:normal, Fenetre::COULEUR_VERT)
    @labelFacile.set_margin(15)
		@labelMoyen.override_color(:normal, Fenetre::COULEUR_JAUNE)
    @labelMoyen.set_margin(15)
		@labelDifficile.override_color(:normal, Fenetre::COULEUR_ROUGE)
    @labelDifficile.set_margin(15)
end

#creerBoxTopObject

Créer la box verticale contenant le listing des stats et le titre



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
# File 'app/view/FenetreStatistiques.rb', line 64

def creerBoxTop()
		#Action des boutons
	#tableau statistique
	table=Gtk::Table.new(4,4,false)
	table.attach(@labelDifficulte,0,1,0,1)
	table.attach(@labelRecord,1,2,0,1)
	table.attach(@labelMoyenne,2,3,0,1)
	table.attach(@labelNbPartie,3,4,0,1)
	table.attach(@labelFacile,0,1,1,2)
	table.attach(@labelMoyen,0,1,2,3)
	table.attach(@labelDifficile,0,1,3,4)

    @tabStat = [
        [@meilleursScores[Jeu::FACILE], @moyennes[Jeu::FACILE], @nombreParties[Jeu::FACILE]],
        [@meilleursScores[Jeu::MOYEN], @moyennes[Jeu::MOYEN], @nombreParties[Jeu::MOYEN]],
        [@meilleursScores[Jeu::DIFFICILE], @moyennes[Jeu::DIFFICILE], @nombreParties[Jeu::DIFFICILE]]
    ]

	@tabStat.each_with_index{|tab,index|
		tab.each_with_index{|valeur,id|
			infoStat=Fenetre::creerLabelType("#{valeur}",Fenetre::SIZE_CONTENU_STAT)
			if index==0
				infoStat.override_color(:normal, Fenetre::COULEUR_VERT)
			elsif index==1
				infoStat.override_color(:normal, Fenetre::COULEUR_JAUNE)
			else
				infoStat.override_color(:normal, Fenetre::COULEUR_ROUGE)
			end
            infoStat.set_margin(15)
			table.attach(infoStat,id+1,id+2,index+1,index+2)
		}
	}

    #add des boutons à la box
    @boxTop.add(@titreLabel)
    @boxTop.add(table)
end

#miseEnPlaceObject

Permet de créer et d'ajouter les box au conteneur principal



53
54
55
56
57
58
# File 'app/view/FenetreStatistiques.rb', line 53

def miseEnPlace()
	creerBoxTop()
	ajoutCss()
	Fenetre::box.add(@boxTop)
	Fenetre::box.add(@boxBottom)
end

#runObject

Lance la construction du modèle de la vue. Méthode à définir dans tout les cas ! Autrement pas de rendu de la page.

Returns:

  • self



130
131
132
133
# File 'app/view/FenetreStatistiques.rb', line 130

def run()
	self.miseEnPlace()
	return self
end