diff options
author | Joshua Minor <j@lux.vu> | 2008-03-11 08:42:59 (GMT) |
---|---|---|
committer | Joshua Minor <j@lux.vu> | 2008-03-11 08:42:59 (GMT) |
commit | aedfe5de7b0b3accd70ed478659cd1dceb125811 (patch) | |
tree | d2a0731df2528a86464c92e0c5720068bb2a17a4 | |
parent | 2a5f179b6f6bb4c7b50566b8abd72e6923e77b63 (diff) |
Added toolbar buttons for easier/harder.
Tidied up the headers of all .py files a bit.
-rwxr-xr-x | Maze.activity/activity.py | 28 | ||||
-rw-r--r-- | Maze.activity/activity/activity.info | 2 | ||||
-rw-r--r-- | Maze.activity/game.py | 12 | ||||
-rw-r--r-- | Maze.activity/icons/activity-easier.svg | 15 | ||||
-rw-r--r-- | Maze.activity/icons/activity-harder.svg | 16 | ||||
-rw-r--r-- | Maze.activity/maze.py | 5 | ||||
-rw-r--r-- | Maze.activity/player.py | 5 | ||||
-rw-r--r-- | docs/NOTES.txt | 5 |
8 files changed, 81 insertions, 7 deletions
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 <http://www.gnu.org/licenses/>. +# along with Maze.activity. If not, see <http://www.gnu.org/licenses/>. 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 @@ +<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
+ <!ENTITY fill_color "#FFFFFF">
+ <!ENTITY stroke_color "#000000">
+]>
+<svg version="1.1" id="Layer_5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="74.5px" height="74px" viewBox="0 0 74.5 74" enable-background="new 0 0 74.5 74" xml:space="preserve">
+<g>
+ <circle cx="37.026" cy="37.18" r="30" fill="&fill_color;"/>
+ <g>
+ <line fill="none" stroke="&stroke_color;" stroke-width="4" x1="55.026" y1="37.18" x2="19.026" y2="37.18"/>
+ </g>
+</g>
+</svg>
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 @@ +<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
+ <!ENTITY fill_color "#FFFFFF">
+ <!ENTITY stroke_color "#000000">
+]>
+<svg version="1.1" id="Layer_5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="74.5px" height="74px" viewBox="0 0 74.5 74" enable-background="new 0 0 74.5 74" xml:space="preserve">
+<g>
+ <circle cx="37.026" cy="37.18" r="30" fill="&fill_color;"/>
+ <g>
+ <line fill="none" stroke="&stroke_color;" stroke-width="4" x1="37.026" y1="19.18" x2="37.026" y2="55.18"/>
+ <line fill="none" stroke="&stroke_color;" stroke-width="4" x1="55.026" y1="37.18" x2="19.026" y2="37.18"/>
+ </g>
+</g>
+</svg>
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 <http://www.gnu.org/licenses/>. +# along with Maze.activity. If not, see <http://www.gnu.org/licenses/>. 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 <http://www.gnu.org/licenses/>. +# along with Maze.activity. If not, see <http://www.gnu.org/licenses/>. 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) + + + + + |