Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/activity.py
blob: 404dd46e819a6c098291f099cef5ee7090542e60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pygtk
pygtk.require('2.0')
import gtk
import hippo
import os
from gettext import gettext as _
import logging

from sugar.activity import activity
from olpcgames import PyGameActivity
from olpcgames import eventwrap
from StoryBuilder import GAME_WIDTH, GAME_HEIGHT

class StoryBuilderActivity(PyGameActivity):
    game_name = 'StoryBuilder:Game'
    game_title = _('Story Builder')
    game_size = (GAME_WIDTH, GAME_HEIGHT)
    pygame_mode = 'SDL'

    def __init__(self, handle):
        """Get into the right directory so we can find the artwork"""
        super(StoryBuilderActivity, self).__init__(handle)
        os.chdir(activity.get_bundle_path())

    def write_file(self, file_path):
        eventwrap.post(eventwrap.SaveEvent(file_path))
        logging.debug('Save sent')
        if eventwrap.wait(types = [eventwrap.Reply]) == None:
            logging.error('Cannot save to journal')

    def read_file(self, file_path):
        eventwrap.post(eventwrap.LoadEvent(file_path))
        logging.debug('Load sent')
        return eventwrap.wait(types = [eventwrap.Reply]) != None