Module: Header

Defined in:
app/components/Header.rb

Overview

Module permettant de

Class Method Summary collapse

Class Method Details

.addSecondObject

Ajoute une seconde au chrono

Returns:

  • true



170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'app/components/Header.rb', line 170

def Header.addSecond()
	if(@pause == false)
		@temps += 1

		@tempsLabel.text = "Temps: " + Header.surDeuxChiffres(@temps / 60) + ":" + Header.surDeuxChiffres(@temps % 60)
		@score = @scoreModel.calcul(@penalite, @temps)
		@scoreLabel.text = "Score: " + @score.to_s
		
		return true
	end

	return false
end

.chronoObject

Crée un chrono dans la header bar

Returns:

  • self



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'app/components/Header.rb', line 147

def Header.chrono()

	Fenetre::enteteFenetre.children.each do |child|
		if(child == @tempsLabel || child == @scoreLabel)
			Fenetre::enteteFenetre.remove(child)
		end
	end

	Fenetre::enteteFenetre.pack_end(@tempsLabel)
	Fenetre::enteteFenetre.pack_end(@scoreLabel)
	
	GLib::Timeout.add_seconds(1){
			Header.addSecond
	}

	return self
end

.pauseObject

Définit un accesseur sur l'état de la pause

Returns:

  • L'état de la pause



85
86
87
# File 'app/components/Header.rb', line 85

def Header.pause() 
	return @pause
end

.pause=(bool) ⇒ Object

Définit l'état de la pause

Parameters:

  • bool

    Booléen de l'état

Returns:

  • L'état de la pause



96
97
98
# File 'app/components/Header.rb', line 96

def Header.pause=(bool) 
	@pause = bool
end

.penaliteObject

Ajoute une pénalité

Returns:

  • self



114
115
116
117
# File 'app/components/Header.rb', line 114

def Header.penalite()
	@penalite += 1
	return self
end

.profil(pseudo) ⇒ Object

Définit le contenu de l'entête de la fenêtre

Returns:

  • Module



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
# File 'app/components/Header.rb', line 49

def Header.profil(pseudo)

	self.reset()

	## Création du bouton de profil
	@boutonProfil = Gtk::Button.new
	image = Gtk::Image.new(:file => Core::ROOTPROJECT + "assets/img/user.png")
	
	box = Gtk::Box.new(:horizontal, 5)

	@boutonProfil.signal_connect_after("clicked")  do
		@pause = true
		Core::changeTo("Reglages", :pseudo => pseudo)
	end

	@boutonProfil.set_name("profil")
	@boutonProfil.add(image)
	box.add(@boutonProfil)

	@pseudo = pseudo

	pseudoProfil = Gtk::Label.new(pseudo.capitalize).set_name("pseudo")
	box.add(pseudoProfil)


	## Ajout au début de l'entête
	Fenetre::enteteFenetre.pack_start(box)

	return self
end

.resetObject

Vide la header bar

Returns:

  • self



32
33
34
35
36
37
38
39
40
41
42
# File 'app/components/Header.rb', line 32

def Header.reset()
	
	@temps = 0
	@score = 0

	Fenetre::enteteFenetre.children.each do |child|
		Fenetre::enteteFenetre.remove(child)
	end

	return self
end

.scoreObject

Définit un accesseur pour le score

Returns:

  • score



131
132
133
# File 'app/components/Header.rb', line 131

def Header.score()
	return @score
end

.score=(score) ⇒ Object

Définit un mutateur pour le score



138
139
140
# File 'app/components/Header.rb', line 138

def Header.score=(score)
	@score = score
end

.surDeuxChiffres(temps) ⇒ Object

Convertit le temps sur deux chiffres

Parameters:

  • temps

    Le temps

Returns:

  • Temps sur deux chiffres



191
192
193
# File 'app/components/Header.rb', line 191

def Header.surDeuxChiffres(temps)
	return temps.to_s.rjust(2, "0")
end

.tempsObject

Définit un accesseur pour le temps

Returns:

  • temps



105
106
107
# File 'app/components/Header.rb', line 105

def Header.temps()
	return @temps
end

.temps=(temps) ⇒ Object

Définit un mutateur pour le temps



122
123
124
# File 'app/components/Header.rb', line 122

def Header.temps=(temps)
	@temps = temps
end