From aedfe5de7b0b3accd70ed478659cd1dceb125811 Mon Sep 17 00:00:00 2001 From: Joshua Minor Date: Tue, 11 Mar 2008 08:42:59 +0000 Subject: Added toolbar buttons for easier/harder. Tidied up the headers of all .py files a bit. --- diff --git a/Maze.activity/activity.py b/Maze.activity/activity.py index ceb205c..4b088c9 100755 --- a/Maze.activity/activity.py +++ b/Maze.activity/activity.py @@ -1,6 +1,34 @@ import olpcgames +import pygame +from sugar.graphics.toolbutton import ToolButton +from gettext import gettext as _ class MazeActivity(olpcgames.PyGameActivity): game_name = 'game' game_title = 'Maze' game_size = None # let olpcgames pick a nice size for us + + def build_toolbar( self ): + """Build our Activity toolbar for the Sugar system.""" + toolbar = super( MazeActivity, self ).build_toolbar() + + # Add buttons that will make the maze harder or easier + toolbar.harder = ToolButton('activity-harder') + toolbar.harder.set_tooltip(_('Harder')) + toolbar.harder.connect('clicked', self._harder_cb) + toolbar.insert(toolbar.harder, 2) + toolbar.harder.show() + + toolbar.easier = ToolButton('activity-easier') + toolbar.easier.set_tooltip(_('Easier')) + toolbar.easier.connect('clicked', self._easier_cb) + toolbar.insert(toolbar.easier, 2) + toolbar.easier.show() + + return toolbar + + def _harder_cb(self, button): + pygame.event.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action='harder')) + + def _easier_cb(self, button): + pygame.event.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action='easier')) diff --git a/Maze.activity/activity/activity.info b/Maze.activity/activity/activity.info index 764ba6c..7c4af02 100644 --- a/Maze.activity/activity/activity.info +++ b/Maze.activity/activity/activity.info @@ -3,5 +3,5 @@ name = Maze service_name = vu.lux.olpc.Maze class = activity.MazeActivity icon = activity-maze -activity_version = 5 +activity_version = 6 show_launcher = yes diff --git a/Maze.activity/game.py b/Maze.activity/game.py index ab38a35..2ce497c 100644 --- a/Maze.activity/game.py +++ b/Maze.activity/game.py @@ -1,5 +1,6 @@ # Maze.activity # A simple multi-player maze game for the XO laptop. +# http://wiki.laptop.org/go/Maze # # Special thanks to Brendan Donohoe for the icon. # @@ -11,13 +12,13 @@ # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# Foobar is distributed in the hope that it will be useful, +# Maze.activity is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with Foobar. If not, see . +# along with Maze.activity. If not, see . import sys @@ -225,6 +226,13 @@ class MazeGame: print "Error handling message: %s\n%s" % (event, sys.exc_info()) else: print "Message from unknown buddy?" + elif event.type == pygame.USEREVENT: + if event.action == 'harder': + self.harder() + elif event.action == 'easier': + self.easier() + else: + print "Unknown user event action:", event.action else: print "Unknown event:", event diff --git a/Maze.activity/icons/activity-easier.svg b/Maze.activity/icons/activity-easier.svg new file mode 100644 index 0000000..5b1caef --- /dev/null +++ b/Maze.activity/icons/activity-easier.svg @@ -0,0 +1,15 @@ + + + + +]> + + + + + + + + diff --git a/Maze.activity/icons/activity-harder.svg b/Maze.activity/icons/activity-harder.svg new file mode 100644 index 0000000..e1fc560 --- /dev/null +++ b/Maze.activity/icons/activity-harder.svg @@ -0,0 +1,16 @@ + + + + +]> + + + + + + + + + diff --git a/Maze.activity/maze.py b/Maze.activity/maze.py index adc672f..8fec99c 100644 --- a/Maze.activity/maze.py +++ b/Maze.activity/maze.py @@ -1,5 +1,6 @@ # Maze.activity # A simple multi-player maze game for the XO laptop. +# http://wiki.laptop.org/go/Maze # # Special thanks to Brendan Donohoe for the icon. # @@ -11,13 +12,13 @@ # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# Foobar is distributed in the hope that it will be useful, +# Maze.activity is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with Foobar. If not, see . +# along with Maze.activity. If not, see . import random from pygame import Rect diff --git a/Maze.activity/player.py b/Maze.activity/player.py index 46bf79a..d9421a3 100644 --- a/Maze.activity/player.py +++ b/Maze.activity/player.py @@ -1,5 +1,6 @@ # Maze.activity # A simple multi-player maze game for the XO laptop. +# http://wiki.laptop.org/go/Maze # # Special thanks to Brendan Donohoe for the icon. # @@ -11,13 +12,13 @@ # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# Foobar is distributed in the hope that it will be useful, +# Maze.activity is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with Foobar. If not, see . +# along with Maze.activity. If not, see . from olpcgames.util import get_bundle_path bundlepath = get_bundle_path() diff --git a/docs/NOTES.txt b/docs/NOTES.txt index 610fa3b..d7389bf 100644 --- a/docs/NOTES.txt +++ b/docs/NOTES.txt @@ -93,3 +93,8 @@ def iconFromBuddy(self, buddy): # srf = cairo.ImageSurface(cairo.FORMAT_ARGB32, w, h) # file.render_cairo(cairo.Context(srf)) # return surface.CairoSurface(srf) + + + + + -- cgit v0.9.1