# HG changeset patch # User Neil Muller # Date 1282664746 -7200 # Node ID d2f84f22def0e05d1c2bbb85cc087382819305ea # Parent 2f672e98d48854ff858ae7604ccd897748e2d298 Move MessageDialog to widgets diff -r 2f672e98d488 -r d2f84f22def0 gamelib/gamescreen.py --- a/gamelib/gamescreen.py Tue Aug 24 17:33:37 2010 +0200 +++ b/gamelib/gamescreen.py Tue Aug 24 17:45:46 2010 +0200 @@ -2,8 +2,6 @@ # Copyright Boomslang team, 2010 (see COPYING File) # Main menu for the game -import textwrap - from albow.controls import Button, Label, Widget from albow.layout import Row from albow.palette_view import PaletteView @@ -17,7 +15,7 @@ from hand import HandButton from popupmenu import PopupMenu, PopupMenuButton from state import initial_state, Item -from widgets import BoomLabel +from widgets import MessageDialog class InventoryView(PaletteView): @@ -48,23 +46,6 @@ self.state.set_tool(None) -class MessageDialog(BoomLabel, CursorWidget): - - def __init__(self, text, wrap_width, **kwds): - CursorWidget.__init__(self) - paras = text.split("\n\n") - text = "\n".join([textwrap.fill(para, wrap_width) for para in paras]) - Label.__init__(self, text, **kwds) - self.set_margin(5) - self.border_width = 1 - self.border_color = (0, 0, 0) - self.bg_color = (127, 127, 127) - self.fg_color = (0, 0, 0) - - def mouse_down(self, event): - self.dismiss() - - class StateWidget(Widget): def __init__(self, state): diff -r 2f672e98d488 -r d2f84f22def0 gamelib/widgets.py --- a/gamelib/widgets.py Tue Aug 24 17:33:37 2010 +0200 +++ b/gamelib/widgets.py Tue Aug 24 17:45:46 2010 +0200 @@ -3,8 +3,12 @@ """Custom Albow widgets""" +import textwrap + import albow.controls +from cursor import CursorWidget + class BoomLabel(albow.controls.Label): @@ -16,3 +20,18 @@ self.margin = margin self.size = (w + 2 * d, h + 2 * d) +class MessageDialog(BoomLabel, CursorWidget): + + def __init__(self, text, wrap_width, **kwds): + CursorWidget.__init__(self) + paras = text.split("\n\n") + text = "\n".join([textwrap.fill(para, wrap_width) for para in paras]) + albow.controls.Label.__init__(self, text, **kwds) + self.set_margin(5) + self.border_width = 1 + self.border_color = (0, 0, 0) + self.bg_color = (127, 127, 127) + self.fg_color = (0, 0, 0) + + def mouse_down(self, event): + self.dismiss()