Mercurial > boomslang
comparison gamelib/gamescreen.py @ 74:75e1040a1121
Hacky "detail view" widget prototype.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Mon, 23 Aug 2010 21:26:48 +0200 |
parents | 932b0956e77a |
children | 1a5fdc225939 |
comparison
equal
deleted
inserted
replaced
73:932b0956e77a | 74:75e1040a1121 |
---|---|
3 # Main menu for the game | 3 # Main menu for the game |
4 | 4 |
5 from albow.controls import Button, Label, Widget | 5 from albow.controls import Button, Label, Widget |
6 from albow.layout import Column | 6 from albow.layout import Column |
7 from albow.palette_view import PaletteView | 7 from albow.palette_view import PaletteView |
8 from albow.dialogs import Dialog | |
8 from pygame import Rect | 9 from pygame import Rect |
9 from pygame.color import Color | 10 from pygame.color import Color |
10 from pygame.locals import BLEND_ADD | 11 from pygame.locals import BLEND_ADD |
11 | 12 |
12 from constants import BUTTON_SIZE | 13 from constants import BUTTON_SIZE |
73 # queue a redraw | 74 # queue a redraw |
74 self.invalidate() | 75 self.invalidate() |
75 CursorWidget.mouse_move(self, event) | 76 CursorWidget.mouse_move(self, event) |
76 | 77 |
77 | 78 |
79 class DetailWindow(CursorWidget): | |
80 def mouse_down(self, e): | |
81 if e not in self: | |
82 self.dismiss() | |
83 | |
84 def draw(self, surface): | |
85 surface.fill(Color('green')) | |
86 | |
87 | |
78 class GameScreen(CursorSpriteScreen): | 88 class GameScreen(CursorSpriteScreen): |
79 def __init__(self, shell): | 89 def __init__(self, shell): |
80 CursorSpriteScreen.__init__(self, shell) | 90 CursorSpriteScreen.__init__(self, shell) |
81 | 91 |
82 # TODO: Randomly plonk the state here for now | 92 # TODO: Randomly plonk the state here for now |
87 self.popup_menu = PopupMenu(shell) | 97 self.popup_menu = PopupMenu(shell) |
88 self.menubutton = PopupMenuButton('Menu', | 98 self.menubutton = PopupMenuButton('Menu', |
89 action=self.popup_menu.show_menu) | 99 action=self.popup_menu.show_menu) |
90 self.menubutton.bottomleft = self.bottomleft | 100 self.menubutton.bottomleft = self.bottomleft |
91 self.add(self.menubutton) | 101 self.add(self.menubutton) |
102 | |
103 self.detail = DetailWindow() | |
104 self.detail.rect = Rect(0, 0, 200, 200) | |
105 | |
106 self.testbutton = Button('Test', action=self.detail.present) | |
107 self.testbutton.bottomright = self.bottomright | |
108 self.add(self.testbutton) | |
109 | |
92 self.handbutton = HandButton(action=self.hand_pressed) | 110 self.handbutton = HandButton(action=self.hand_pressed) |
93 self.handbutton.bottomleft = self.bottomleft | 111 self.handbutton.bottomleft = self.bottomleft |
94 self.handbutton.get_rect().move_ip(BUTTON_SIZE, 0) | 112 self.handbutton.get_rect().move_ip(BUTTON_SIZE, 0) |
95 self.add(self.handbutton) | 113 self.add(self.handbutton) |
114 | |
96 self.inventory = InventoryView(self.state, self.handbutton) | 115 self.inventory = InventoryView(self.state, self.handbutton) |
97 | |
98 self.inventory.bottomleft = self.bottomleft | 116 self.inventory.bottomleft = self.bottomleft |
99 self.inventory.get_rect().move_ip(2 * BUTTON_SIZE, 0) | 117 self.inventory.get_rect().move_ip(2 * BUTTON_SIZE, 0) |
100 self.add(self.inventory) | 118 self.add(self.inventory) |
101 | 119 |
102 # Test items | 120 # Test items |