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
|
# File 'lib/Hashiparmentier/UI/FenetreJeuUI.rb', line 28
def initialize(mode, grille ,pseudo,window,window1)
@grille=grille
@mode = mode
@pseudo = pseudo
@scoreCourant = 500 * @grille.tailleX
@compte = Compte.recuperer(@pseudo)
window.destroy()
window1.destroy()
@builderJeu = Gtk::Builder.new
@builderJeu.add_from_file("lib/Hashiparmentier/glade/jeu.glade")
@window = @builderJeu.get_object("windowJeu")
@window.signal_connect('destroy') { |_widget|
@grille.sauvegarder(@compte)
Thread.kill(@threadChrono)
@window.destroy()
Gtk.main_quit }
if (@grille.tailleX == 15)
@window.style_context.add_provider(@@CSS_BG_JEU15, Gtk::StyleProvider::PRIORITY_USER)
else
@window.style_context.add_provider(@@CSS_BG_JEU, Gtk::StyleProvider::PRIORITY_USER)
end
@labelPseudo = @builderJeu.get_object("lbPseudo")
@labelPseudo.set_label("Joueur : "+ @pseudo)
@labelChrono = @builderJeu.get_object("chrono")
@labelScore = @builderJeu.get_object("lbVarScore")
@labelScore.set_label(@grille.score.to_s)
grilleJeux = @builderJeu.get_object("grilleJeux")
grilleJeux.pack_start(@grilleJouable = GrilleJouableUI.new(grille))
@checkpoints = Pile.creer()
@verifGrille = VerifierGrille.creer(@grille)
@donnerTech = DonnerTechnique.creer(@grille)
@clickUndo = @builderJeu.get_object("btnUndo")
@clickUndo.signal_connect('clicked'){@grille.undo()}
@clickRedo = @builderJeu.get_object("btnRedo")
@clickRedo.signal_connect('clicked'){@grille.redo()}
@btnReinit = @builderJeu.get_object("btnReinit")
@btnReinit.signal_connect('clicked'){@grille.recommencer()}
@btnRetour = @builderJeu.get_object("btnRetour")
@btnRetour.signal_connect('clicked'){
@grille.sauvegarder(@compte)
Thread.kill(@threadChrono)
@window.destroy()
Gtk.main_quit
Menu.new()
}
@btnValid1 = @builderJeu.get_object("btnvalid1")
@btnValid1.signal_connect('clicked'){@grille.creerHypothese()}
@btnSuppr1 = @builderJeu.get_object("btnsup1")
@btnSuppr1.signal_connect('clicked'){@grille.supprimeHypothese()}
@btnValCP = @builderJeu.get_object("btnVerifCP")
@btnValCP.signal_connect('clicked'){@grille.valideHypothese()}
@btnSauvegarder = @builderJeu.get_object("btnsave")
@btnSauvegarder.signal_connect('clicked'){@grille.sauvegarder(@compte)}
@labelIndice = @builderJeu.get_object("labelIndice")
@btnDonnerTech = @builderJeu.get_object("btnIndice")
@btnDonnerTech.signal_connect('clicked'){@labelIndice.set_label(@donnerTech.aider())}
@btnVerif = @builderJeu.get_object("btnVerifGrille")
@btnVerif.signal_connect('clicked'){@verifGrille.aider()}
@btnValidGrille = @builderJeu.get_object("btnValidGrille")
@btnValidGrille.signal_connect('clicked'){
@grille.sauvegarder(@compte)
if(@grille.fini?() == true)
Thread.kill(@threadChrono)
fenetre_fin = FenetreFinUI.new(@grille,@compte,@window)
else
@labelIndice.set_label("Vous n'avez pas trouvé la solution ! \n Continuez ...")
end
}
@chronoGrille = Chrono.new(self, @labelChrono)
@threadChrono = Thread.new{@chronoGrille.lancerChrono()}
@btnAide = @builderJeu.get_object("btnAide")
@btnRegles = @builderJeu.get_object("btnRegles")
@btnAstuces = @builderJeu.get_object("btnAstuces")
@grille111 = @builderJeu.get_object("grid1")
@grille111.style_context.add_provider(@@CSS_BOX_STAT, Gtk::StyleProvider::PRIORITY_USER)
@btnAide.style_context.add_provider(@@CSS_BTN_JEU, Gtk::StyleProvider::PRIORITY_USER)
@btnRegles.style_context.add_provider(@@CSS_BTN_JEU, Gtk::StyleProvider::PRIORITY_USER)
@btnAstuces.style_context.add_provider(@@CSS_BTN_JEU, Gtk::StyleProvider::PRIORITY_USER)
@btnValid1.style_context.add_provider(@@CSS_BTN_JEU, Gtk::StyleProvider::PRIORITY_USER)
@btnSuppr1.style_context.add_provider(@@CSS_BTN_JEU, Gtk::StyleProvider::PRIORITY_USER)
@btnValCP.style_context.add_provider(@@CSS_BTN_JEU, Gtk::StyleProvider::PRIORITY_USER)
@btnSauvegarder.style_context.add_provider(@@CSS_BTN_JEU, Gtk::StyleProvider::PRIORITY_USER)
@btnRetour.style_context.add_provider(@@CSS_BTN_JEU, Gtk::StyleProvider::PRIORITY_USER)
@btnDonnerTech.style_context.add_provider(@@CSS_BTN_JEU, Gtk::StyleProvider::PRIORITY_USER)
@clickRedo.style_context.add_provider(@@CSS_BTN_JEU, Gtk::StyleProvider::PRIORITY_USER)
@clickUndo.style_context.add_provider(@@CSS_BTN_JEU, Gtk::StyleProvider::PRIORITY_USER)
@btnReinit.style_context.add_provider(@@CSS_BTN_JEU, Gtk::StyleProvider::PRIORITY_USER)
@btnVerif.style_context.add_provider(@@CSS_BTN_JEU, Gtk::StyleProvider::PRIORITY_USER)
@btnValidGrille.style_context.add_provider(@@CSS_BTN_JEU, Gtk::StyleProvider::PRIORITY_USER)
@btnAide.signal_connect('clicked') { |_widget| AfficherAideJeu() }
@btnRegles.signal_connect('clicked') { |_widget| AfficherRegles() }
@btnAstuces.signal_connect('clicked') { |_widget| AfficherAstuces() }
@boxStat = @builderJeu.get_object("boxStat")
@boxStat.style_context.add_provider(@@CSS_BOX_STAT, Gtk::StyleProvider::PRIORITY_USER)
@window.show_all()
end
|