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-13 23:43:19 (GMT)
committer echinelli <emilianochinelli@gmail.com>2010-12-13 23:43:19 (GMT)
commit5fe1ae61e848f1f89206729b12092c23d6fe3ada (patch)
tree3c4878cd66cfb598249e6ca057f50f7995db31fb
parentf586dab1fb94b93757545cb77ece16a58b6e7026 (diff)
add:
*help button to menu items *attribute link in actions improvements in Item and actions_creator
-rwxr-xr-xSaludame.activity/actions.py5
-rwxr-xr-xSaludame.activity/actions_creator.py17
-rwxr-xr-xSaludame.activity/menu.py42
-rwxr-xr-xSaludame.activity/menu_creator.py5
4 files changed, 52 insertions, 17 deletions
diff --git a/Saludame.activity/actions.py b/Saludame.activity/actions.py
index 90b5167..9acb008 100755
--- a/Saludame.activity/actions.py
+++ b/Saludame.activity/actions.py
@@ -5,7 +5,7 @@ import events
class Action:
- def __init__(self, id, appereance_probability, time_span, kid_animation_frame_rate, kid_animation_loop_times, kid_animation_path, window_animation_frame_rate, window_animation_loop_times, window_animation_path, sound_loop_times, sound_path, effect, allowed_places, allowed_hours, allowed_events, level=1):
+ def __init__(self, id, appereance_probability, time_span, kid_animation_frame_rate, kid_animation_loop_times, kid_animation_path, window_animation_frame_rate, window_animation_loop_times, window_animation_path, sound_loop_times, sound_path, effect, allowed_places, allowed_hours, allowed_events, level=1, link=None):
self.id = id
self.appereance_probability = appereance_probability
@@ -13,6 +13,8 @@ class Action:
self.time_left = time_span
self.effect = effect
+ self.link = link
+
# conditions
self.allowed_places = allowed_places
self.allowed_hours = allowed_hours
@@ -55,3 +57,4 @@ class Mood:
self.kid_animation_path = kid_animation_path
self.kid_frame_rate = frame_rate
+
diff --git a/Saludame.activity/actions_creator.py b/Saludame.activity/actions_creator.py
index ae28d7b..44ec31b 100755
--- a/Saludame.activity/actions_creator.py
+++ b/Saludame.activity/actions_creator.py
@@ -166,7 +166,7 @@ actions_list = [
),
("brush_teeth", 0.3, 8, 0, 0, None, 3, 1, None, 4, "sound_path",
- effects.Effect(None, [("b_teeth", 0.5)]), None, None, None
+ effects.Effect(None, [("b_teeth", 0.5)]), None, None, None, 1, "un link"
),
("wash_hands", 0.3, 8, 0, 0, None, 3, 1, None, 4, "sound_path",
@@ -174,7 +174,7 @@ actions_list = [
),
("toilet", 0.3, 1.9, 0, 1, "assets/kid/actions/toilet", 3, 1, None, 4, "sound_path",
- effects.Effect(None, [("toilet", 4.0)]), None, None, None, 3
+ effects.Effect(None, [("toilet", 4.0)]), None, None, None, 1, "un link"
),
# Default action - affects the bars continuously
@@ -214,11 +214,11 @@ class ActionsLoader:
return self.actions_list
def __load_actions(self):
- status_actions = [actions.Action(action[0], action[1], action[2], action[3], action[4], action[5], action[6], action[7], action[8], action[9], action[10], self.__set_bar_controller(action[11]), action[12], action[13], action[14], self.get_level(action)) for action in actions_list]
+ status_actions = [actions.Action(action[0], action[1], action[2], action[3], action[4], action[5], action[6], action[7], action[8], action[9], action[10], self.__set_bar_controller(action[11]), action[12], action[13], action[14], self.get_level(action), self.get_link(action)) for action in actions_list]
- location_actions = [actions.Action(action[0], action[1], action[2], action[3], action[4], action[5], action[6], action[7], action[8], action[9], action[10], self.__set_game_manager(action[11]), action[12], action[13], action[14], self.get_level(action)) for action in locations_ac_list]
+ location_actions = [actions.Action(action[0], action[1], action[2], action[3], action[4], action[5], action[6], action[7], action[8], action[9], action[10], self.__set_game_manager(action[11]), action[12], action[13], action[14], self.get_level(action), self.get_link(action)) for action in locations_ac_list]
- clothes_actions = [actions.Action(action[0], action[1], action[2], action[3], action[4], action[5], action[6], action[7], action[8], action[9], action[10], self.__set_game_manager(action[11]), action[12], action[13], action[14], self.get_level(action)) for action in clothes_ac_list]
+ clothes_actions = [actions.Action(action[0], action[1], action[2], action[3], action[4], action[5], action[6], action[7], action[8], action[9], action[10], self.__set_game_manager(action[11]), action[12], action[13], action[14], self.get_level(action), self.get_link(action)) for action in clothes_ac_list]
return status_actions + location_actions + clothes_actions
@@ -238,4 +238,11 @@ class ActionsLoader:
return action[15]
else:
return 1 #action's default level
+
+ def get_link(self, action):
+ if len(action) > 16:
+ return action[16]
+ else:
+ return None
+
diff --git a/Saludame.activity/menu.py b/Saludame.activity/menu.py
index 3587305..0219a19 100755
--- a/Saludame.activity/menu.py
+++ b/Saludame.activity/menu.py
@@ -25,6 +25,7 @@ LARGE_TEXT = 10 #fewer mean small text
SMALL_BUTTON = "assets/menu/A.png"
LARGE_BUTTON = "assets/menu/B.png"
CENTER_BUTTON = "assets/menu/center.png"
+HELP_BUTTON = "assets/menu/menu_help.png"
CLOSE_MENU = "close_menu"
BACK_MENU = "back_menu"
@@ -36,6 +37,7 @@ class Menu(Window):
rect = pygame.Rect((0, 0), SIZE)
rect.center = center
self.windows_controller = windows_controller
+ self.game_manager = game_manager
Window.__init__(self, container, rect, frame_rate, windows_controller, "menu_window")
self.depth = 0 #it means we are in the root of the menu, mayor values means we are not.
@@ -62,8 +64,6 @@ class Menu(Window):
self.on_expansion = False
self.calculate()
- self.game_manager = game_manager
-
def add_item(self, item):
self.item_list.append(item)
@@ -296,20 +296,44 @@ class Item(Widget):
#surface.blit(icon, (0, 0))
#surface.blit(text, (icon.get_size()[0] + 2, 0))
#rect = surface.get_rect()
- self.path = None
+ self.help_image = None
+ self.bg_image = None
if center_item:
- self.image_btn = pygame.image.load(CENTER_BUTTON).convert_alpha()
+ self.bg_image = pygame.image.load(CENTER_BUTTON).convert_alpha()
else:
if len(self.name) > LARGE_TEXT:
- self.image_btn = pygame.image.load(LARGE_BUTTON).convert_alpha()
+ self.bg_image = pygame.image.load(LARGE_BUTTON).convert_alpha()
else:
- self.image_btn = pygame.image.load(SMALL_BUTTON).convert_alpha()
+ self.bg_image = pygame.image.load(SMALL_BUTTON).convert_alpha()
+ self.bg_rect = self.bg_image.get_rect()
- rect = self.image_btn.get_rect()
+ action = self.menu.game_manager.get_action(self.action_id)
+ if action:
+ if action.link: #has to show help button
+ self.help_image = pygame.image.load(HELP_BUTTON).convert_alpha()
+ self.help_rect = self.help_image.get_rect()
+
+ size_and_surface = self.get_surface(20, self.name, self.bg_image, self.help_image)
- self.button = utilities.TextButton2(rect, pygame.Rect((500, 120), (70, 30)), 1, self.name, 20, (255, 255, 255), self.image_btn, None)
+ self.rect = pygame.Rect((0, 0), size_and_surface[0])
- Widget.__init__(self, container, rect, frame_rate, self.button.get_surface())
+ Widget.__init__(self, container, self.rect, frame_rate, size_and_surface[1])
+
+ def get_surface(self, font_size, text, bg_image, help_image):
+ font = utilities.get_font(font_size)
+ render = font.render(text, True, (255, 255, 255))
+
+ if help_image:
+ full_size = self.help_rect.width + self.bg_rect.width - 4, self.help_rect.height
+ surface = pygame.Surface(full_size)
+ surface.fill(bg_image.get_at(bg_image.get_rect().center))
+ surface.blit(bg_image, bg_image.get_rect(left=self.bg_image.get_rect().left))
+ surface.blit(help_image, help_image.get_rect(left=surface.get_rect().left + self.bg_rect.width - 4))
+ else:
+ full_size = bg_image.get_rect().size
+ surface = bg_image.copy()
+ surface.blit(render, render.get_rect(center=self.bg_rect.center))
+ return full_size, surface
def add_subitem(self, item):
"""
diff --git a/Saludame.activity/menu_creator.py b/Saludame.activity/menu_creator.py
index 846701d..c27eeff 100755
--- a/Saludame.activity/menu_creator.py
+++ b/Saludame.activity/menu_creator.py
@@ -99,9 +99,9 @@ example = [
MENU_FRAME_RATE = 1
-def load_menu(character, center, container, windows_controller):
+def load_menu(game_manager, center, container, windows_controller):
font = utilities.get_font(20)
- m = menu.Menu(1, container, windows_controller, [], center, 90, character, font)
+ m = menu.Menu(1, container, windows_controller, [], center, 90, game_manager, font)
for item in example:
an_item = create_item(item, m, container, font)
m.add_item(an_item)
@@ -118,3 +118,4 @@ def create_item(item_tuple, a_menu, container, font):
return menu.Item(container, MENU_FRAME_RATE, item_tuple[0], item_tuple[1], item_tuple[2], subitems, a_menu, font)
+