Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorechinelli <emilianochinelli@gmail.com>2010-12-16 21:17:13 (GMT)
committer echinelli <emilianochinelli@gmail.com>2010-12-16 21:17:13 (GMT)
commitcde437392cba34e9bc6b353e4174a9a46f932737 (patch)
treea3e15795a379b44f66594e60ef349371017b6f12
parent0b7574e9da0d801bc8b395158710e2b53ee63d0f (diff)
parent20f833fa1da22e087bfd5f066b7c2b9a15eb8b6d (diff)
Merge branch 'master' of git://git.sugarlabs.org/saludame/mainline
Conflicts: Saludame.activity/status_bars_creator.py
-rwxr-xr-xSaludame.activity/challenges.py254
-rw-r--r--Saludame.activity/challenges/ninia_normal.pngbin0 -> 6819 bytes
-rw-r--r--Saludame.activity/challenges/ninio_normal.pngbin0 -> 6286 bytes
-rwxr-xr-xSaludame.activity/challenges_creator.py85
-rwxr-xr-xSaludame.activity/game_manager.py3
-rwxr-xr-xSaludame.activity/main_window.py19
-rwxr-xr-xSaludame.activity/status_bars_creator.py2
-rwxr-xr-xSaludame.activity/utilities.py13
-rwxr-xr-xSaludame.activity/windows_controller.py19
9 files changed, 216 insertions, 179 deletions
diff --git a/Saludame.activity/challenges.py b/Saludame.activity/challenges.py
index 7e8d0c2..e3464e0 100755
--- a/Saludame.activity/challenges.py
+++ b/Saludame.activity/challenges.py
@@ -26,8 +26,8 @@ MOUSE_OVER_COLOR = pygame.Color("green")
class MultipleChoice(Window):
- def __init__(self, container, rect, frame_rate, windows_controller, challenges_creator, bg_color=(0, 0, 0)):
- Window.__init__(self, container, rect, frame_rate, windows_controller, "challenges_window", bg_color)
+ def __init__(self, container, rect, frame_rate, windows_controller, challenges_creator, register_id, bg_color=(0, 0, 0)):
+ Window.__init__(self, container, rect, frame_rate, windows_controller, register_id, bg_color)
###### Sounds ######
self.s_correct = pygame.mixer.Sound(S_CORRECT_PATH)
@@ -38,8 +38,7 @@ class MultipleChoice(Window):
self.choices = []
self.correct = 0
- self.kind = "mc"
- self.n_tf = N_TF
+ self.opportinities = 1
self.challenges_creator = challenges_creator
@@ -49,17 +48,9 @@ class MultipleChoice(Window):
self.win_points = 0
self.lose_points = 0
- # Control de preguntas largas (más de 1 línea)
- # Problema para decidir "donde" cortar la pregunta
- self.question_lines = 1;
-
# Close Button
self.btn_close = TextButton(self.rect, pygame.Rect((910, 0), (30, 30)), 1, "X", 32, (0, 0, 0), self._cb_button_click_close)
- self.buttons += [self.btn_close]
-
- # Answer Button
- #self.btn_view_answer = TextButton(self.rect, pygame.Rect(30, 350, 20, 20), 1, "Me doy por vencido! :(...", TEXT_FONT_SIZE, (255, 20, 20), self._cb_button_click_answer, self._cb_button_over_answer, self._cb_button_out_answer)
- #self.buttons += [self.btn_view_answer]
+ self.buttons += [self.btn_close]
for b in self.buttons:
self.add_child(b)
@@ -70,38 +61,19 @@ class MultipleChoice(Window):
def set_question(self, question):
if (self.question):
self.erase()
- self.question = Text(self.rect, 30, 30, 1, question, TITLE_FONT_SIZE, (0, 0, 0))
-
- """
- Control de preguntas largas. Funciona bien y "relocaliza" las respuestas
- en función de la cantidad de líenas de la pregunta.
- Problema: "corta" la pregunta en un valor hardcodeado el
- cual muchas veces "corta" a una palabra en cualquier lado.
- """
- if (self.question.rect_in_container.width > self.rect.width - 20):
- q1 = Text(self.rect, 30, 30, 1, question[:43], TITLE_FONT_SIZE, (0, 0, 0))
- q2 = Text(self.rect, 30, 65, 1, question[43:], TITLE_FONT_SIZE, (0, 0, 0))
- self.add_child(q1)
- self.add_child(q2)
- self.question_lines = 2
- return
-
- self.question_lines = 1
+
+ self.question = TextBlock(self.rect, 30, 90, 1, question, TITLE_FONT_SIZE, (0, 0, 0), False)
self.add_child(self.question)
def set_correct_answer(self, a):
self.correct = a
def set_answers(self, answers):
- x = 35
- y = 20
- """
- Control de preguntas largas. Funciona bien y "relocaliza" las respuestas
- en función de la cantidad de líenas de la pregunta.
- Problema: "corta" la pregunta en un valor hardcodeado el
- cual muchas veces "corta" a una palabra en cualquier lado.
- """
- y += 40 * self.question_lines
+ x = 30
+ y = self.question.rect_absolute.top
+
+ y += 40 * len(self.question.lines)
+
for ans in answers:
y += 30
b = TextButton(self.rect, pygame.Rect((x, y), (1, 1)), 1, ans, TEXT_FONT_SIZE, ANSWER_COLOR, self._cb_button_click_choice, self._cb_button_over_choice, self._cb_button_out_choice)
@@ -120,43 +92,33 @@ class MultipleChoice(Window):
def set_lose_points(self, points):
self.lose_points = points
-
- def pre_draw(self, screen):
- """
- if FIN_MC:
- self.wait += 1
-
- if self.wait >= 20:
- self.windows_controller.close_active_window()
- """
- if FIN_MC:
- self.windows_controller.close_active_window()
- return []
######## Callbacks buttons ########
def _cb_button_click_choice(self, button):
- global FIN_MC
- if not FIN_MC:
- if(button == self.choices[self.correct]):
- self.s_correct.play()
- self.windows_controller.game_man.add_points(self.win_points)
- if self.kind == "tf":
- if self.n_tf:
- self.n_tf -= 1
- self.challenges_creator.get_challenge("tf")
- else:
- FIN_MC = True # Damos por finalizado el desafío
- self.n_tf = N_TF
- else:
- FIN_MC = True # Damos por finalizado el desafío
- self.windows_controller.show_master_challenge_result_good()
- else:
- self.windows_controller.game_man.add_points(-self.lose_points)
- self.s_incorrect.play()
- if self.kind == "mc":
- FIN_MC = True
- self.windows_controller.show_master_challenge_result_bad()
+ if(button == self.choices[self.correct]):
+ self.s_correct.play()
+ self.windows_controller.game_man.add_points(self.win_points)
+
+ self.windows_controller.close_active_window()
+ self.windows_controller.windows["info_challenge_window"].update_content(u"¡Respuesta correcta!", u"Muy bien, \nganaste %s puntos para tu barra %s" % (self.win_points, self.challenges_creator.game_man.get_lowest_bar().label))
+ self.windows_controller.set_active_window("info_challenge_window")
+ self.opportinities = 1
+ else:
+ self.windows_controller.game_man.add_points(-self.lose_points)
+ self.s_incorrect.play()
+ self.windows_controller.close_active_window()
+
+ if (self.opportinities == 0):
+ self.windows_controller.windows["info_challenge_window"].update_content(u"Perdiste", u"Qué lástima, no era correcta, \nperdiste %s puntos en tu barra de %s. \nLee la biblioteca o pregunta al maestro/a." % (self.lose_points, self.challenges_creator.game_man.get_lowest_bar().label))
+ self.windows_controller.set_active_window("info_challenge_window")
+ self.opportinities = 1
+ else:
+ self.opportinities -= 1
+ self.windows_controller.windows["info_challenge_window"].update_content(u"Respuseta incorrecta", u"La respuesta no esta correcta, intenta otra vez")
+ self.windows_controller.set_active_window("mc_challenge_window")
+ self.windows_controller.set_active_window("info_challenge_window")
+
def _cb_button_over_choice(self, button):
if not FIN_MC:
@@ -167,22 +129,8 @@ class MultipleChoice(Window):
def _cb_button_out_choice(self, button):
if not FIN_MC:
button.switch_color_text(ANSWER_COLOR)
- button.force_update()
-
- def _cb_button_click_answer(self, button):
- global FIN_MC
- FIN_MC = True
- for c in self.choices:
- c.switch_color_text((10, 10, 10))
- (self.choices[self.correct]).switch_color_text((255, 0, 0))
-
- def _cb_button_over_answer(self, button):
- if not FIN_MC:
- self.s_over.play()
-
- def _cb_button_out_answer(self, button):
- pass
-
+ button.force_update()
+
def _cb_button_click_close(self, button):
self.windows_controller.close_active_window()
@@ -200,9 +148,94 @@ class MultipleChoice(Window):
global FIN_MC
FIN_MC = False
-class InfoMasterChallenge(Window):
+class TrueOrFalse(MultipleChoice):
+ def __init__(self, container, rect, frame_rate, windows_controller, challenges_creator, register_id, bg_color=(0, 0, 0)):
+
+ MultipleChoice.__init__(self, container, rect, frame_rate, windows_controller, challenges_creator, register_id, bg_color)
+
+ self.n_tf = N_TF
+ self.question_number = 0
+ self.answers = ["waiting", "waiting", "waiting", "waiting", "waiting"]
+
+ def pre_draw(self, screen):
+ if self.answers[0] == "waiting":
+ q0 = pygame.draw.circle(screen, pygame.Color("grey"), (1020, 550), 10)
+ elif self.answers[0] == "incorrect":
+ q0 = pygame.draw.circle(screen, pygame.Color("red"), (1020, 550), 10)
+ elif self.answers[0] == "correct":
+ q0 = pygame.draw.circle(screen, pygame.Color("green"), (1020, 550), 10)
+
+ if self.answers[1] == "waiting":
+ q1 = pygame.draw.circle(screen, pygame.Color("grey"), (1050, 550), 10)
+ elif self.answers[1] == "incorrect":
+ q1 = pygame.draw.circle(screen, pygame.Color("red"), (1050, 550), 10)
+ elif self.answers[1] == "correct":
+ q1 = pygame.draw.circle(screen, pygame.Color("green"), (1050, 550), 10)
+
+
+ if self.answers[2] == "waiting":
+ q2 = pygame.draw.circle(screen, pygame.Color("grey"), (1080, 550), 10)
+ elif self.answers[2] == "incorrect":
+ q2 = pygame.draw.circle(screen, pygame.Color("red"), (1080, 550), 10)
+ elif self.answers[2] == "correct":
+ q2 = pygame.draw.circle(screen, pygame.Color("green"), (1080, 550), 10)
+
+
+ if self.answers[3] == "waiting":
+ q3 = pygame.draw.circle(screen, pygame.Color("grey"), (1110, 550), 10)
+ elif self.answers[3] == "incorrect":
+ q3 = pygame.draw.circle(screen, pygame.Color("red"), (1110, 550), 10)
+ elif self.answers[3] == "correct":
+ q3 = pygame.draw.circle(screen, pygame.Color("green"), (1110, 550), 10)
+
+
+ if self.answers[4] == "waiting":
+ q4 = pygame.draw.circle(screen, pygame.Color("grey"), (1140, 550), 10)
+ elif self.answers[4] == "incorrect":
+ q4 = pygame.draw.circle(screen, pygame.Color("red"), (1140, 550), 10)
+ elif self.answers[4] == "correct":
+ q4 = pygame.draw.circle(screen, pygame.Color("green"), (1140, 550), 10)
+
+
+ return [q0, q1, q2, q3, q4]
+
+ def _cb_button_click_choice(self, button):
+ if(button == self.choices[self.correct]):
+ self.s_correct.play()
+ self.windows_controller.game_man.add_points(self.win_points)
+ if self.n_tf:
+ # Correct answer
+ self.answers[self.question_number] = "correct"
+ self.n_tf -= 1
+ self.challenges_creator.get_challenge("tf")
+ self.question_number += 1
+ else:
+ self.windows_controller.close_active_window()
+ self.result_and_reset()
+ else:
+ self.windows_controller.game_man.add_points(-self.lose_points)
+ self.s_incorrect.play()
+ if self.n_tf:
+ # Incorrect answer
+ self.answers[self.question_number] = "incorrect"
+ self.n_tf -= 1
+ self.challenges_creator.get_challenge("tf")
+ self.question_number += 1
+ else:
+ self.windows_controller.close_active_window()
+ self.result_and_reset()
+
+ def result_and_reset(self):
+ self.windows_controller.windows["info_challenge_window"].update_content(u"%s Respuestas correctas" % (self.answers.count("correct") + 1), u"Ganaste %s puntos para tu \nbarra %s" % ("[ver puntos]", self.challenges_creator.game_man.get_lowest_bar().label))
+ self.windows_controller.set_active_window("info_challenge_window")
+
+ self.n_tf = N_TF
+ self.question_number = 0
+ self.answers = ["waiting", "waiting", "waiting", "waiting", "waiting"]
+
+class InfoChallenge(Window):
def __init__(self, container, rect, frame_rate, windows_controller, challenges_creator, text_intro, text_result_good, text_result_bad, bg_color=(0, 0, 0)):
- Window.__init__(self, container, rect, frame_rate, windows_controller, "info_master_challenge", bg_color)
+ Window.__init__(self, container, rect, frame_rate, windows_controller, "info_challenge_window", bg_color)
self.set_bg_image("assets/windows/window_2.png")
self.challenges_creator = challenges_creator
@@ -210,33 +243,20 @@ class InfoMasterChallenge(Window):
self.btn_continue = utilities.get_accept_button(self.rect, pygame.Rect((400, 500), (1, 1)), _("Continue"), self._cb_button_click_continue)
self.add_button(self.btn_continue)
- self.text_intro = utilities.TextBlock(rect, 40, 60, 1, text_intro, 35, pygame.Color("blue"))
- self.text_result_good = utilities.TextBlock(rect, 40, 60, 1, text_result_good, 35, pygame.Color("blue"))
- self.text_result_bad = utilities.TextBlock(rect, 40, 60, 1, text_result_bad, 35, pygame.Color("blue"))
-
- self.add_child(self.text_intro)
- self.add_child(self.text_result_good)
- self.add_child(self.text_result_bad)
-
- def show_intro(self):
- self.text_intro.visible = True
- self.text_result_good.visible = False
- self.text_result_bad.visible = False
-
- def show_result_good(self):
- self.text_intro.visible = False
- self.text_result_good.visible = True
- self.text_result_bad.visible = False
+ # Texts
+ self.title = utilities.Text(rect, 40, 40, 1, "Verdadero o Falso", 45, pygame.Color("blue"))
+ self.text = utilities.TextBlock(rect, 40, 120, 1, "Texto de prueba", 35, pygame.Color("black"))
+ self.image = utilities.Image(rect, pygame.Rect(640, 240, 80, 80), 1, "challenges/ninio_normal.png")
+
+ self.add_child(self.title)
+ self.add_child(self.text)
+ self.add_child(self.image)
- def show_result_bad(self):
- self.text_intro.visible = False
- self.text_result_good.visible = False
- self.text_result_bad.visible = True
+ def update_content(self, title="Verdadero o Falso", text="Texto de prueba", image="challenges/ninio_normal.png"):
+ self.title.text = title
+ self.title.refresh()
+ self.text.parse_lines(text)
+ self.image = image
def _cb_button_click_continue(self, button):
- self.windows_controller.close_active_window()
-
- if self.text_intro.visible:
- self.challenges_creator.get_challenge("mc")
- self.windows_controller.set_active_window("challenges_window")
-
+ self.windows_controller.close_active_window()
diff --git a/Saludame.activity/challenges/ninia_normal.png b/Saludame.activity/challenges/ninia_normal.png
new file mode 100644
index 0000000..f68a00c
--- /dev/null
+++ b/Saludame.activity/challenges/ninia_normal.png
Binary files differ
diff --git a/Saludame.activity/challenges/ninio_normal.png b/Saludame.activity/challenges/ninio_normal.png
new file mode 100644
index 0000000..700b109
--- /dev/null
+++ b/Saludame.activity/challenges/ninio_normal.png
Binary files differ
diff --git a/Saludame.activity/challenges_creator.py b/Saludame.activity/challenges_creator.py
index a04a81e..cc26d9d 100755
--- a/Saludame.activity/challenges_creator.py
+++ b/Saludame.activity/challenges_creator.py
@@ -19,8 +19,12 @@ class ChallengesCreator:
self.game_man = game_man
# Multiple Choice window
- self.challenge = challenges.MultipleChoice(self.container, self.rect, self.frame_rate, self.windows_controller, self, self.bg_color)
- self.challenge.set_bg_image("assets/windows/window_1.png")
+ self.mc_challenge = challenges.MultipleChoice(self.container, self.rect, self.frame_rate, self.windows_controller, self, "mc_challenge_window", self.bg_color)
+ self.mc_challenge.set_bg_image("assets/windows/window_1.png")
+
+ # True or False window
+ self.tf_challenge = challenges.TrueOrFalse(self.container, self.rect, self.frame_rate, self.windows_controller, self, "tf_challenge_window", self.bg_color)
+ self.tf_challenge.set_bg_image("assets/windows/window_1.png")
# Tuples of mc_challenges
self.mc_challenges = []
@@ -40,25 +44,30 @@ class ChallengesCreator:
# True or false
# 0 = False | 1 = True
- self.tf_challenges_physica.append(self._create_tf_challenge(_("La alimentación adecuada previene muchas enfermedades importantes"), 1, 10, 10))
- self.tf_challenges_physica.append(self._create_tf_challenge(_("Si no nos vacunamos con las vacunas obligatorias podemos enfermarnos"), 1, 10, 10))
- self.tf_challenges_physica.append(self._create_tf_challenge(_("Cuando estamos ingiriendo alimentos en menor proporción a lo que necesitamos, podemos volvernos más susceptibles a las infecciones "), 1, 10, 10))
- self.tf_challenges_hygiene.append(self._create_tf_challenge(_("Muchos alimentos pueden estar contaminados con agroquímicos, y pesticidas porque son frecuentemente usados"), 1, 10, 10))
+ ## Physica
+ self.tf_challenges_physica.append(self._create_tf_challenge(_("La alimentación adecuada previene muchas enfermedades \nimportantes"), 1, 10, 10))
+ self.tf_challenges_physica.append(self._create_tf_challenge(_("Si no nos vacunamos con las vacunas obligatorias podemos \nenfermarnos"), 1, 10, 10))
+ self.tf_challenges_physica.append(self._create_tf_challenge(_("Cuando estamos ingiriendo alimentos en menor proporción \na lo que necesitamos, podemos volvernos más \nsusceptibles a las infecciones "), 1, 10, 10))
+
+ ## Hygiene
+ self.tf_challenges_hygiene.append(self._create_tf_challenge(_("Muchos alimentos pueden estar contaminados con agroquímicos, \ny pesticidas porque son frecuentemente usados"), 1, 10, 10))
self.tf_challenges_hygiene.append(self._create_tf_challenge(_("Si no voy a comer no necesito lavarme las manos "), 0, 10, 10))
- self.tf_challenges_hygiene.append(self._create_tf_challenge(_("Lo primero que hay que hay que hacer cuando vamos a lavarnos las manos es ponernos jabón"), 0, 10, 10))
+ self.tf_challenges_hygiene.append(self._create_tf_challenge(_("Lo primero que hay que hay que hacer cuando vamos a lavarnos \nlas manos es ponernos jabón"), 0, 10, 10))
- self.tf_challenges_nutrition.append(self._create_tf_challenge(_("Cuando aprendemos hábitos saludables estamos cuidando nuestra salud"), 1, 10, 10))
- self.tf_challenges_nutrition.append(self._create_tf_challenge(_("Tomar mucha agua, hacer ejercicio y comer frutas y verduras ayuda a mover el intestino sin dificultad"), 1, 10, 10))
+ ## Nutrition
+ self.tf_challenges_nutrition.append(self._create_tf_challenge(_("Cuando aprendemos hábitos saludables estamos cuidando nuestra \nsalud"), 1, 10, 10))
+ self.tf_challenges_nutrition.append(self._create_tf_challenge(_("Tomar mucha agua, hacer ejercicio y comer frutas y verduras \nayuda a mover el intestino sin dificultad"), 1, 10, 10))
self.tf_challenges_nutrition.append(self._create_tf_challenge(_("El desayuno no es importante en nuestra alimentación"), 0, 10, 10))
+ ## Spare time
self.tf_challenges_spare_time.append(self._create_tf_challenge(_("La actividad física mejora nuestra imagen"), 1, 10, 10))
- self.tf_challenges_spare_time.append(self._create_tf_challenge(_("La actividad física no nos ayuda prevenir enfermedades como el sobrepeso y la obesidad "), 0, 10, 10))
- self.tf_challenges_spare_time.append(self._create_tf_challenge(_("Ser sedentarios no tiene importancia y no afecta nuestra salud"), 0, 10, 10))
+ self.tf_challenges_spare_time.append(self._create_tf_challenge(_("La actividad física no nos ayuda prevenir enfermedades \ncomo el sobrepeso y la obesidad "), 0, 10, 10))
+ self.tf_challenges_spare_time.append(self._create_tf_challenge(_("Ser sedentarios no tiene importancia y no afecta nuestra \nsalud"), 0, 10, 10))
def _create_mc_challenge(self, question, answers, correct_answer, win_points, lose_points, image=None):
"""
- Create a new challenge (tuple)
+ Create a new mc_challenge (tuple)
"""
challenge = (question, answers, correct_answer, win_points, lose_points, image)
self.mc_challenges.append(challenge)
@@ -72,16 +81,27 @@ class ChallengesCreator:
def get_challenge(self, kind):
"""
- Load and return a random "created" challenge
+ Load and return a random "created" mc_challenge
"""
if kind == "mc":
- self.challenge.kind = "mc"
r = random.randrange(0, len(self.mc_challenges))
c = self.mc_challenges[r]
- elif kind == "tf":
-
- self.challenge.kind = "tf"
+ # Set challenge attributes
+ self.mc_challenge.set_question(c[0])
+ self.mc_challenge.set_answers(c[1])
+ self.mc_challenge.set_correct_answer(c[2])
+ self.mc_challenge.set_win_points(c[3])
+ self.mc_challenge.set_lose_points(c[4])
+
+ # If challenge has an image
+ if c[5]:
+ self.mc_challenge.set_image(c[5])
+
+ return self.mc_challenge
+
+
+ elif kind == "tf":
bar = self.game_man.get_lowest_bar()
if bar.id == "physica":
r = random.randrange(0, len(self.tf_challenges_physica))
@@ -94,17 +114,20 @@ class ChallengesCreator:
c = self.tf_challenges_nutrition[r]
elif bar.id == "spare_time":
r = random.randrange(0, len(self.tf_challenges_spare_time))
- c = self.tf_challenges_spare_time[r]
-
- # Set multiple choice attributes
- self.challenge.set_question(c[0])
- self.challenge.set_answers(c[1])
- self.challenge.set_correct_answer(c[2])
- self.challenge.set_win_points(c[3])
- self.challenge.set_lose_points(c[4])
-
- # If challenge has an image
- if c[5]:
- self.challenge.set_image(c[5])
-
- return self.challenge
+ c = self.tf_challenges_spare_time[r]
+
+ # Set challenge attributes
+ self.tf_challenge.set_question(c[0])
+ self.tf_challenge.set_answers(c[1])
+ self.tf_challenge.set_correct_answer(c[2])
+ self.tf_challenge.set_win_points(c[3])
+ self.tf_challenge.set_lose_points(c[4])
+
+ # If challenge has an image
+ if c[5]:
+ self.tf_challenge.set_image(c[5])
+
+ return self.tf_challenge
+
+ elif kind == "master":
+ pass
diff --git a/Saludame.activity/game_manager.py b/Saludame.activity/game_manager.py
index d456719..87c9a51 100755
--- a/Saludame.activity/game_manager.py
+++ b/Saludame.activity/game_manager.py
@@ -459,7 +459,8 @@ class GameManager:
# Otherwise it loses some points, and continues in the same level, so he has to continue playing to
# reach the master challenge again.
- self.windows_controller.show_master_challenge_intro()
+ #self.windows_controller.show_master_challenge_intro()
+ pass
# Save, load and reset game
diff --git a/Saludame.activity/main_window.py b/Saludame.activity/main_window.py
index 0ac7c80..4ee1472 100755
--- a/Saludame.activity/main_window.py
+++ b/Saludame.activity/main_window.py
@@ -21,10 +21,7 @@ class MainWindow(Window):
self.game_manager = game_man
self.windows = [] # Lista de ventanas que 'componen' la ventana principal
-
- # temporal para probar PanelWindow (se cargará el diccionario en un módulo aparte).
- # self.animations_dic = {'eat_apple': (animation.Apple(pygame.Rect((0, 0), (120, 172)), 10), "Eating an apple!") }
-
+
self.panel_win = PanelWindow(container, pygame.Rect((180, 609), (1015, 200)), 1, windows_controller)
self.windows.append(self.panel_win)
@@ -38,9 +35,9 @@ class MainWindow(Window):
self.add_child(Clock(container, pygame.Rect(0, 528, 1, 1), 1, game_man))
# Challenges
- #challenges_button = ImageButton(self.rect, pygame.Rect((1120, 400), (60, 60)), 1, "challenges/trophy.png", self._cb_button_click_mc_challenges)
- #challenges_button.set_tooltip(_("Multiple choice"))
- #self.add_button(challenges_button)
+ challenges_button = ImageButton(self.rect, pygame.Rect((1120, 400), (60, 60)), 1, "challenges/trophy.png", self._cb_button_click_mc_challenges)
+ challenges_button.set_tooltip(_("Multiple choice"))
+ self.add_button(challenges_button)
challenges_button2 = ImageButton(self.rect, pygame.Rect((1120, 500), (60, 60)), 1, "challenges/trophy.png", self._cb_button_click_tf_challenges)
challenges_button2.set_tooltip(_("True or false"))
@@ -58,11 +55,15 @@ class MainWindow(Window):
#### Callbacks ####
def _cb_button_click_mc_challenges(self, button):
self.cha_loader.get_challenge("mc")
- self.windows_controller.set_active_window("challenges_window")
+ self.windows_controller.set_active_window("mc_challenge_window")
+ self.windows_controller.windows["info_challenge_window"].update_content(u"Múltiple Opción: %s" %(self.cha_loader.game_man.get_lowest_bar().label), u"Tu barra de %s está baja. \nPara ganar puntos tienes que acertar \nla respuesta correcta. \n\n¡Suerte!" %(self.cha_loader.game_man.get_lowest_bar().label))
+ self.windows_controller.set_active_window("info_challenge_window")
def _cb_button_click_tf_challenges(self, button):
self.cha_loader.get_challenge("tf")
- self.windows_controller.set_active_window("challenges_window")
+ self.windows_controller.set_active_window("tf_challenge_window")
+ self.windows_controller.windows["info_challenge_window"].update_content(u"Verdadero o Flaso: %s" %(self.cha_loader.game_man.get_lowest_bar().label), u"Tu barra de %s está baja. \nPara ganar puntos tienes que acertar \nlas preguntas de verdero o falso. \n\n¡Suerte!" %(self.cha_loader.game_man.get_lowest_bar().label))
+ self.windows_controller.set_active_window("info_challenge_window")
def _cb_button_click_stop_animation(self, button):
self.panel_win.stop_animation()
diff --git a/Saludame.activity/status_bars_creator.py b/Saludame.activity/status_bars_creator.py
index 58e3e79..8a96c7e 100755
--- a/Saludame.activity/status_bars_creator.py
+++ b/Saludame.activity/status_bars_creator.py
@@ -27,7 +27,7 @@ class BarsLoader:
### hygiene
hygiene_children_id = [("shower", _("Ducha")), ("w_hands", _("Manos")), ("b_teeth", _("Dientes")), ("toilet", _(u"Baño"))]
- hygiene = status_bars.StatusBar("hygiene", "Hygiene", self.overall_bar, [], hard_level[0], hard_level[1])
+ hygiene = status_bars.StatusBar("hygiene", "Higiene", self.overall_bar, [], hard_level[0], hard_level[1])
hygiene_children_bar = [status_bars.StatusBar(id[0], id[1], hygiene, [], hard_level[0], hard_level[1]) for id in hygiene_children_id]
hygiene.children_list = hygiene_children_bar
diff --git a/Saludame.activity/utilities.py b/Saludame.activity/utilities.py
index d689ae6..1e8b6c2 100755
--- a/Saludame.activity/utilities.py
+++ b/Saludame.activity/utilities.py
@@ -178,7 +178,7 @@ def get_color_tuple(color):
return get_color_tuple(color)
class TextBlock(Widget):
- def __init__(self, container, x, y, frame_rate, text, size, color):
+ def __init__(self, container, x, y, frame_rate, text, size, color, fill=True):
Widget.__init__(self, container, pygame.Rect(x, y, 0, 0), frame_rate)
@@ -188,14 +188,14 @@ class TextBlock(Widget):
self.parse_lines(text)
self.size = size
self.prepare_text_block()
+ self.fill = fill
def parse_lines(self, text):
- #(b, _, a) = text.partition(u"\n") #########WARNING########
- (b, _, a) = text.partition("\n")
+ self.lines = []
+ (b, _, a) = text.partition(u"\n")
self.lines.append(b)
while(a != ''):
- #(b, _, a) = a.partition(u"\n") ########WARNING########
- (b, _, a) = a.partition("\n")
+ (b, _, a) = a.partition(u"\n")
self.lines.append(b)
def prepare_text_block(self):
@@ -216,7 +216,8 @@ class TextBlock(Widget):
def draw(self, screen):
if self.visible:
number_of_lines = 0
- screen.fill((255, 255, 255), (self.rect_absolute))
+ if self.fill:
+ screen.fill((255, 255, 255), (self.rect_absolute))
for l in self.lines:
r = self.font.render(l, False, self.color)
screen.blit(r, (self.rect_absolute.left, self.rect_absolute.top + r.get_rect().height * number_of_lines))
diff --git a/Saludame.activity/windows_controller.py b/Saludame.activity/windows_controller.py
index ecee1fd..4a8896a 100755
--- a/Saludame.activity/windows_controller.py
+++ b/Saludame.activity/windows_controller.py
@@ -45,7 +45,7 @@ class WindowsController:
cha_creator.create_challenges()
self.game_man.challenges_creator = cha_creator
- info_master_challenge = challenges.InfoMasterChallenge(self.screen.get_rect(), pygame.Rect((250, 30), (934, 567)), 1, self, cha_creator, u"¡Felicitaciones! \nHas completado el nivel actual. Para pasar de nivel \ndebes contestar bien la siguiente pregunta. \n\n¡¡Suerte!!", u"Felicitaciones, has pasado de nivel. \nSe han desbloqueado nuevas acciones, \n¿te animás a encontrarlas?", u"Contestaste incorrectamente, \ntendrás que intentar pasar de nivel más adelante")
+ info_master_challenge = challenges.InfoChallenge(self.screen.get_rect(), pygame.Rect((250, 30), (934, 567)), 1, self, cha_creator, u"¡Felicitaciones! \nHas completado el nivel actual. Para pasar de nivel \ndebes contestar bien la siguiente pregunta. \n\n¡¡Suerte!!", u"Felicitaciones, has pasado de nivel. \nSe han desbloqueado nuevas acciones, \n¿te animás a encontrarlas?", u"Contestaste incorrectamente, \ntendrás que intentar pasar de nivel más adelante")
# Customization Window
customization_window = customization.CustomizationWindow(self.screen.get_rect(), pygame.Rect((250, 30), (934, 567)), 1, self, app_loader.get_character())
@@ -75,6 +75,9 @@ class WindowsController:
for win in self.windows_stack[-1].windows:
if isinstance(win, Window):
win.enable_repaint()
+
+ def get_screen(self):
+ return self.screen
def set_active_window(self, window_key):
if window_key <> "main_window":
@@ -84,19 +87,7 @@ class WindowsController:
self.show_window_hierarchy(self.windows_stack[-1])
def register_new_window(self, id, window):
- self.windows[id] = window
-
- def show_master_challenge_intro(self):
- self.set_active_window("info_master_challenge")
- self.windows["info_master_challenge"].show_intro()
-
- def show_master_challenge_result_good(self):
- self.set_active_window("info_master_challenge")
- self.windows["info_master_challenge"].show_result_good()
-
- def show_master_challenge_result_bad(self):
- self.set_active_window("info_master_challenge")
- self.windows["info_master_challenge"].show_result_bad()
+ self.windows[id] = window
def show_window_hierarchy(self, window):
sys.stdout.write(window.get_register_id())