Class: JeuUI

Inherits:
Gtk::Box
  • Object
show all
Defined in:
lib/Hashiparmentier/UI/JeuUI.rb

Overview

PAS UTILISE DANS LE VERSION FINALE

Auteur

Brabant Mano

Version

0.1

Date

09/04/2020

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(racine) ⇒ JeuUI

Returns a new instance of JeuUI.



22
23
24
25
26
27
28
# File 'lib/Hashiparmentier/UI/JeuUI.rb', line 22

def initialize(racine)

  super(:vertical , 0)

  @racine = racine

end

Instance Attribute Details

#compteObject (readonly)

Returns the value of attribute compte.



20
21
22
# File 'lib/Hashiparmentier/UI/JeuUI.rb', line 20

def compte
  @compte
end

#racineObject (readonly)

Returns the value of attribute racine.



19
20
21
# File 'lib/Hashiparmentier/UI/JeuUI.rb', line 19

def racine
  @racine
end

Instance Method Details

#chargerGrille(grille, nomCompte) ⇒ Object

Cette méthode permet de charger la grille avec laquelle on va jouer

param
  • grille La grille avec laquelle on va jouer

  • nomCompte Le nom du compte qui joue



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
# File 'lib/Hashiparmentier/UI/JeuUI.rb', line 35

def chargerGrille(grille, nomCompte)

  each_all do |c|
    remove(c)
  end


  @compte = Compte.recuperer(nomCompte)


  @verifGrille = VerifierGrille.creer(grille)
  @donnerTech = DonnerTechnique.creer(grille)
#    @chronoGrille = Chrono.new(@grille)
#    @threadChrono = Thread.new{@chronoGrille.lancerChrono()}

  @grille = GrilleJouableUI.new(grille)

  @undo = Gtk::Button.new(:label => "Undo")
  @undo.signal_connect "clicked" do
    @grille.grille.undo()
  end

  @redo = Gtk::Button.new(:label => "Redo")
  @redo.signal_connect "clicked" do
    @grille.grille.redo()
  end

  @hypotheseCreer = Gtk::Button.new(:label => "Creer hypothèse")
  @hypotheseCreer.signal_connect "clicked" do
    @grille.grille.creerHypothese()
  end

  @hypotheseValider = Gtk::Button.new(:label => "Valider hypothèse")
  @hypotheseValider.signal_connect "clicked" do
    @grille.grille.valideHypothese()
  end


  @hypotheseSupprimer = Gtk::Button.new(:label => "Supprimer hypothèse")
  @hypotheseSupprimer.signal_connect "clicked" do
    @grille.grille.supprimeHypothese(self)
  end

  @sauvegarder = Gtk::Button.new(:label => "Sauvegarder")
  @sauvegarder.signal_connect "clicked" do
    Sauvegarde.recuperer(@compte, @grille.grille).setGrille(@grille.grille).sauvegarder()
  end


  @aideValide = Gtk::Button.new(:label => "Verifier grille")
  @aideValide.signal_connect "clicked" do
    @verifGrille.aider()
  end

  @labelTechnique = Gtk::Label.new()

  @aideTechnique = Gtk::Button.new(:label => "Donner technique")
  @aideTechnique.signal_connect "clicked" do
    @labelTechnique.text = @donnerTech.aider()
  end

  @valider = Gtk::Button.new(:label => "Valider")
  @valider.signal_connect "clicked" do
    finir()
  end

  aides = Gtk::Box.new(:horizontal)
  aides.pack_start(@aideValide, :expand => true, :fill => true)
  aides.pack_start(@aideTechnique, :expand => true, :fill => true)

  labelTechnique = Gtk::Box.new(:vertical)
  labelTechnique.pack_start(@labelTechnique, :expand => true, :fill => true)
  labelTechnique.pack_start(aides, :expand => true, :fill => true)

  undoRedo = Gtk::Box.new(:horizontal)
  undoRedo.pack_start(@undo, :expand => true, :fill => true)
  undoRedo.pack_start(@redo, :expand => true, :fill => true)

  hypotheses = Gtk::Box.new(:vertical)
  hypotheses.pack_start(@hypotheseCreer, :expand => true, :fill => true)
  hypotheses.pack_start(@hypotheseValider, :expand => true, :fill => true)
  hypotheses.pack_start(@hypotheseSupprimer, :expand => true, :fill => true)

  controle = Gtk::Box.new(:vertical)
  controle.pack_start(hypotheses, :expand => true, :fill => true)
  controle.pack_start(undoRedo, :expand => true, :fill => true)
  controle.pack_start(labelTechnique, :expand => true, :fill => true)


  jeu = Gtk::Box.new(:horizontal)
  jeu.pack_start(@grille, :expand => true, :fill => true)
  jeu.pack_start(controle, :expand => true, :fill => true)

  pack_start(jeu, :expand => true, :fill => true)
  pack_start(@valider, :expand => true, :fill => true)

  show_all

end

#finirObject



139
140
141
142
143
144
145
146
147
148
# File 'lib/Hashiparmentier/UI/JeuUI.rb', line 139

def finir()

  if(@grille.grille.fini?())
    #puts "Bravo vous avez gagné !!!"
    @grille.recommencer()
    @grille.sauvegarder(@compte)
    @racine.finirPartie(@grille.grille.tailleX, @grille.grille.difficulte)
  end

end

#grille=(grille) ⇒ Object



135
136
137
# File 'lib/Hashiparmentier/UI/JeuUI.rb', line 135

def grille=(grille)
  @grille.grille=(grille)
end

#sauvegardeGrilleObject



151
152
153
154
155
156
157
158
159
# File 'lib/Hashiparmentier/UI/JeuUI.rb', line 151

def sauvegardeGrille()

  if(!@grille.eql?(nil))

    @grille.sauvegarder(@compte)

  end

end