diff options
author | echinelli <emilianochinelli@gmail.com> | 2010-12-13 21:43:31 (GMT) |
---|---|---|
committer | echinelli <emilianochinelli@gmail.com> | 2010-12-13 21:43:31 (GMT) |
commit | f586dab1fb94b93757545cb77ece16a58b6e7026 (patch) | |
tree | 3870f18e5e93057a7acfb98767f09f93dcae6319 | |
parent | 3977733ab901a3a3c6a2027490ef6dea0212cb0a (diff) |
menu graphics improvements...
-rwxr-xr-x | Saludame.activity/assets/menu/A.png | bin | 0 -> 965 bytes | |||
-rwxr-xr-x | Saludame.activity/assets/menu/B.png | bin | 0 -> 968 bytes | |||
-rwxr-xr-x | Saludame.activity/assets/menu/center.png | bin | 0 -> 5937 bytes | |||
-rwxr-xr-x | Saludame.activity/assets/menu/menu_help.png | bin | 0 -> 1464 bytes | |||
-rwxr-xr-x | Saludame.activity/menu.py | 44 |
5 files changed, 31 insertions, 13 deletions
diff --git a/Saludame.activity/assets/menu/A.png b/Saludame.activity/assets/menu/A.png Binary files differnew file mode 100755 index 0000000..7e72115 --- /dev/null +++ b/Saludame.activity/assets/menu/A.png diff --git a/Saludame.activity/assets/menu/B.png b/Saludame.activity/assets/menu/B.png Binary files differnew file mode 100755 index 0000000..849fc20 --- /dev/null +++ b/Saludame.activity/assets/menu/B.png diff --git a/Saludame.activity/assets/menu/center.png b/Saludame.activity/assets/menu/center.png Binary files differnew file mode 100755 index 0000000..c236ab3 --- /dev/null +++ b/Saludame.activity/assets/menu/center.png diff --git a/Saludame.activity/assets/menu/menu_help.png b/Saludame.activity/assets/menu/menu_help.png Binary files differnew file mode 100755 index 0000000..7a5e294 --- /dev/null +++ b/Saludame.activity/assets/menu/menu_help.png diff --git a/Saludame.activity/menu.py b/Saludame.activity/menu.py index c1d83ea..3587305 100755 --- a/Saludame.activity/menu.py +++ b/Saludame.activity/menu.py @@ -19,6 +19,13 @@ SIZE = 600, 280 EXP_SPEED = 15 #expansion speed, in pixels per frame MAX_ITEMS = 9 #max items quantity per selection +#fonts +LARGE_TEXT = 10 #fewer mean small text +#buttons +SMALL_BUTTON = "assets/menu/A.png" +LARGE_BUTTON = "assets/menu/B.png" +CENTER_BUTTON = "assets/menu/center.png" + CLOSE_MENU = "close_menu" BACK_MENU = "back_menu" @@ -39,11 +46,11 @@ class Menu(Window): self.item_list = item_list # item's list that going to be displayed, root items self.previous_items = [] - self.exit = Item(container, frame_rate, "salir", "assets/icons/icon_quit.png", CLOSE_MENU, [], self, font) + self.exit = Item(container, frame_rate, "salir", "assets/icons/icon_quit.png", CLOSE_MENU, [], self, font, True) self.exit.rect_in_container.center = center self.exit.set_rect_in_container(self.exit.rect_in_container) - self.back = Item(container, frame_rate, "back", "assets/icons/icon_quit.png", BACK_MENU, [], self, font) + self.back = Item(container, frame_rate, "back", "assets/icons/icon_quit.png", BACK_MENU, [], self, font, True) self.back.rect_in_container.center = center self.back.set_rect_in_container(self.back.rect_in_container) @@ -272,7 +279,7 @@ class Item(Widget): """ Entity that represent an item """ - def __init__(self, container, frame_rate, name, icon_path, action_id, subitems_list, menu, font): + def __init__(self, container, frame_rate, name, icon_path, action_id, subitems_list, menu, font, center_item=False): self.name = name self.subitems_list = subitems_list @@ -280,19 +287,29 @@ class Item(Widget): self.menu = menu # visuals - path = os.path.normpath(icon_path) - icon = pygame.image.load(path).convert_alpha() - text = font.render(self.name, True, (255, 255, 255)) + #path = os.path.normpath(icon_path) + #icon = pygame.image.load(path).convert_alpha() + #text = font.render(self.name, True, (255, 255, 255)) + #x_size = icon.get_size()[0] + text.get_size()[0] + 2 + #y_size = max([icon.get_size()[1], text.get_size()[1]]) + #surface = pygame.Surface((x_size, y_size)) + #surface.blit(icon, (0, 0)) + #surface.blit(text, (icon.get_size()[0] + 2, 0)) + #rect = surface.get_rect() + self.path = None + if center_item: + self.image_btn = pygame.image.load(CENTER_BUTTON).convert_alpha() + else: + if len(self.name) > LARGE_TEXT: + self.image_btn = pygame.image.load(LARGE_BUTTON).convert_alpha() + else: + self.image_btn = pygame.image.load(SMALL_BUTTON).convert_alpha() - x_size = icon.get_size()[0] + text.get_size()[0] + 2 - y_size = max([icon.get_size()[1], text.get_size()[1]]) + rect = self.image_btn.get_rect() - surface = pygame.Surface((x_size, y_size)) - surface.blit(icon, (0, 0)) - surface.blit(text, (icon.get_size()[0] + 2, 0)) - rect = surface.get_rect() + self.button = utilities.TextButton2(rect, pygame.Rect((500, 120), (70, 30)), 1, self.name, 20, (255, 255, 255), self.image_btn, None) - Widget.__init__(self, container, rect, frame_rate, surface) + Widget.__init__(self, container, rect, frame_rate, self.button.get_surface()) def add_subitem(self, item): """ @@ -325,3 +342,4 @@ class Item(Widget): else: self.menu.send_action(CLOSE_MENU) # if the item have not children and have not an action_id, close the menu + |