diff options
author | Mateu Batle <mateu.batle@collabora.co.uk> | 2010-10-27 17:40:28 (GMT) |
---|---|---|
committer | Mateu Batle <mateu.batle@collabora.co.uk> | 2010-10-27 17:40:28 (GMT) |
commit | 0018a9e211ebbe74d371339a70edc0d36c4fc99f (patch) | |
tree | ddfd93d0713c615ed70dbf869747b55b94791af8 /usmpgames/menustate.py |
Initial import of game1 and game2 in math quwy
Diffstat (limited to 'usmpgames/menustate.py')
-rwxr-xr-x | usmpgames/menustate.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/usmpgames/menustate.py b/usmpgames/menustate.py new file mode 100755 index 0000000..325e4a4 --- /dev/null +++ b/usmpgames/menustate.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- + +import pygame, jmenu, sys +from applicationstate import * +from application import * +from infostate import * + +class MenuState(InfoState): + + def __init__(self, background = None): + InfoState.__init__(self, None, background) + self._menu_options = [] + self._menu_states = [] + self.pos = ('center', 'center') + self.font = None + self.light = 10 + self.fontSize = 32 + self.color = (0, 0, 0) + self.justify = True + + def add_menu_option(self, option, state): + self._menu_options.append( option ) + self._menu_states.append( state ) + + def render(self, ms): + InfoState.render(self, ms) + selection = jmenu.run( + self._menu_options, + color = self.color, + size = self.fontSize, + font = self.font, + light = self.light, + justify = self.justify, + pos = self.pos) + try: + index = self._menu_options.index( selection ) + Application.instance().push_state( self._menu_states[index] ) + except: + Application.instance().pop_state() + + def input(self, ms): + pass + + def entering_state(self, fromStack): + ApplicationState.entering_state(self, fromStack) |