From d05d1eef0f8093b2abe3c331027f8f32ee79c087 Mon Sep 17 00:00:00 2001 From: Asaf Paris Mandoki Date: Sun, 12 Jul 2009 08:37:26 +0000 Subject: Added functionality to save/load contraptions to/from the journal (Trac #1034) --- (limited to 'tools.py') diff --git a/tools.py b/tools.py index 1b20da9..2aced3e 100644 --- a/tools.py +++ b/tools.py @@ -4,6 +4,7 @@ # By Alex Levenson #================================================================== import pygame +import olpcgames from pygame.locals import * from helpers import * from inspect import getmro @@ -33,6 +34,13 @@ class Tool(object): elif event.type == USEREVENT: if hasattr(event,"action"): if self.game.toolList.has_key(event.action): self.game.setTool(event.action) + if hasattr(event,"code"): + if event.code == olpcgames.FILE_WRITE_REQUEST: + #saving to journal + self.game.world.pickle_save(event.filename) + if event.code == olpcgames.FILE_READ_REQUEST: + #loading from journal + self.game.world.pickle_load(event.filename) elif event.type == MOUSEBUTTONDOWN and event.button == 1: self.game.canvas.grab_focus() handled = False -- cgit v0.9.1