Beispiel #1
0
 def __init__(self, SPGoodies):
     """SPGoodies is a class object that SP sets up and will contain references
     to objects, callback methods and observers
     TODO: add more explaination"""
     self.logger = logging.getLogger("childsplay.electro_sp.Activity")
     self.logger.info("Activity started")
     self.SPG = SPGoodies
     self.theme = self.SPG.get_theme()
     self.screen = self.SPG.get_screen()
     self.screenclip = self.SPG.get_screenclip()
     self.blit_pos = self.screenclip.left, self.screenclip.top
     self.orgscreen = pygame.Surface(
         self.screenclip.size)  # we use this to restore the screen
     self.orgscreen.blit(self.screen, (0, 0), self.screenclip)
     self.backgr = self.SPG.get_background()
     # The location of the activities Data dir
     self.my_datadir = os.path.join(self.SPG.get_libdir_path(), 'CPData',
                                    'Electro_spData')
     self.rchash = utils.read_rcfile(
         os.path.join(self.my_datadir, 'electro_sp.rc'))
     self.rchash['theme'] = self.theme
     self.logger.debug("rchash: %s" % self.rchash)
     # Location of the CPData dir which holds some stuff used by multiple activities
     self.CPdatadir = os.path.join(self.SPG.get_libdir_path(), 'CPData')
     # Location of the alphabet sounds dir
     self.absdir = self.SPG.get_absdir_path()  # alphabet sounds dir
     # You MUST call SPInit BEFORE using any of the SpriteUtils stuff
     # it returns a reference to the special CPGroup
     self.actives = SPSpriteUtils.SPInit(self.screen, self.backgr)
     self.scoredisplay = self.SPG.get_scoredisplay()
     files = ('dealcard1.wav', 'good.ogg', 'wrong.ogg', 'button_hover.wav')
     self.Sound = Snd()
     for file in files:
         setattr(self.Sound, file[:-4],
                 utils.load_sound(os.path.join(self.CPdatadir, file)))
Beispiel #2
0
 def __init__(self, SPGoodies):
     """SPGoodies is a class object that SP sets up and will contain references
     to objects, callback methods and observers
     TODO: add more explaination"""
     self.logger = logging.getLogger("childsplay.fallingletters.Activity")
     self.logger.info("Activity started")
     self.SPG = SPGoodies
     self.scoredisplay = self.SPG.get_scoredisplay()
     self.theme = self.SPG.get_theme()
     # alphabetsounds playing
     Misc.language = self.SPG.get_localesetting()[0]
     self.screen = self.SPG.get_screen()
     self.screenclip = self.SPG.get_screenclip()
     self.blit_pos = self.screenclip.left, self.screenclip.top
     self.orgscreen = pygame.Surface(
         self.screenclip.size)  # we use this to restore the screen
     self.orgscreen.blit(self.screen, (0, 0), self.screenclip)
     self.backgr = self.SPG.get_background()
     # The location of the activities Data dir
     self.my_datadir = os.path.join(self.SPG.get_libdir_path(), 'CPData',
                                    'FallinglettersData')
     # Location of the CPData dir which holds some stuff used by multiple activities
     self.CPdatadir = os.path.join(self.SPG.get_libdir_path(), 'CPData')
     # Location of the alphabet sounds dir
     self.absdir = self.SPG.get_absdir_path()  # alphabet sounds dir
     self.rchash = utils.read_rcfile(os.path.join(self.my_datadir, 'c'))
     # You MUST call SPInit BEFORE using any of the SpriteUtils stuff
     # it returns a reference to the special CPGroup
     self.actives = SPSpriteUtils.SPInit(self.screen, self.backgr)
Beispiel #3
0
 def __init__(self,SPGoodies):
     """SPGoodies is a class object that SP sets up and will contain references
     to objects, callback methods and observers
     TODO: add more explaination"""
     self.logger =  logging.getLogger("childsplay.billiard.Activity")
     self.logger.info("Activity started")
     self.SPG = SPGoodies
     self.scoredisplay = self.SPG.get_scoredisplay()
     self.theme = self.SPG.get_theme()
     self.screen = self.SPG.get_screen()
     self.screenclip = self.SPG.get_screenclip()
     self.blit_pos = self.screenclip.left, self.screenclip.top
     self.orgscreen = pygame.Surface(self.screenclip.size) # we use this to restore the screen
     self.orgscreen.blit(self.screen, (0, 0), self.screenclip)
     self.backgr = self.SPG.get_background()
     # The location of the activities Data dir
     self.my_datadir = os.path.join(self.SPG.get_libdir_path(),'CPData','BilliardData')
     # Location of the CPData dir which holds some stuff used by multiple activities
     self.CPdatadir = os.path.join(self.SPG.get_libdir_path(),'CPData')
     # Location of the alphabet sounds dir
     self.absdir = self.SPG.get_absdir_path()# alphabet sounds dir
     self.rchash = utils.read_rcfile(os.path.join(self.my_datadir, 'c'))
     # You MUST call SPInit BEFORE using any of the SpriteUtils stuff
     # it returns a reference to the special CPGroup
     
     Misc.actives = SPSpriteUtils.SPInit(self.screen,self.backgr)
     Misc.movingsign = SPSpriteUtils.SPGroup(self.screen, self.backgr)
     Misc.group = SPSpriteUtils.SPGroup(self.screen, self.backgr)
     # MovingSign controls itself
     MovingSign(_("Billiard Game"), 48, (100,100), (100,400), 1, (8,0,120), self.screen, self.backgr, 1)
Beispiel #4
0
 def setup(self):
     # The location of the activities Data dir
     self.my_datadir = os.path.join(self.SPG.get_libdir_path(), 'CPData',
                                    'SpinbottleData')
     self.rchash = utils.read_rcfile(
         os.path.join(self.my_datadir, 'spinbottle.rc'))
     self.currentletter = None
     self.wordlisthash = {}
     paths = glob.glob(
         os.path.join(self.my_datadir, self.theme,
                      'data_%s' % self.language, '*.txt'))
     self.logger.debug("found: %s " % paths)
     for p in paths:
         f = open(p, 'r')
         lines = f.readlines()
         f.close()
         self.wordlisthash[lines[0][:-1]] = lines[1:]
     self.categories = self.wordlisthash.keys()
     self.logger.debug("Found categories %s" % self.categories)
     random.shuffle(self.categories)
     self.currentcategory = self.categories.pop()
     self.questiontext = _("beginning with the letter: ")
     self.foundtext = _("Already found:")
     self.suggestiontext = _("Suggestions:")
     self.wc = WordCompleter([])
     self.newexercise_counter = 3
Beispiel #5
0
 def __init__(self, SPGoodies):
     """SPGoodies is a class object that SP sets up and will contain references
     to objects, callback methods and observers
     TODO: add more explaination"""
     self.logger = logging.getLogger("childsplay.soundmemory.Activity")
     self.logger.info("Activity started")
     self.SPG = SPGoodies
     self.theme = self.SPG.get_theme()
     self.scoredisplay = self.SPG.get_scoredisplay()
     self.screen = self.SPG.get_screen()
     self.backgr = self.SPG.get_background()
     self.screenclip = self.SPG.get_screenclip()
     self.blit_pos = self.screenclip.left, self.screenclip.top
     self.orgscreen = pygame.Surface(
         self.screenclip.size)  # we use this to restore the screen
     self.orgscreen.blit(self.screen, (0, 0), self.screenclip)
     # store two surfaces for later use
     Img.screen = self.screen
     Img.backgr = self.backgr
     self.screenclip = self.SPG.get_screenclip()
     self.blit_pos = self.screenclip.left, self.screenclip.top
     self.libdir = self.SPG.get_libdir_path()
     self.my_datadir = os.path.join(self.libdir, 'CPData',
                                    'SoundmemoryData')
     self.rchash = utils.read_rcfile(
         os.path.join(self.my_datadir, 'soundmemory.rc'))
     self.rchash['theme'] = self.theme
     self.logger.debug("found rc: %s" % self.rchash)
     # You MUST call SPInit BEFORE using any of the SpriteUtils stuff
     # it returns a reference to the special CPGroup
     self.actives = SPSpriteUtils.SPInit(self.screen, self.backgr)
     self.beamer_set = 'off'
Beispiel #6
0
 def __init__(self,SPGoodies):
     """SPGoodies is a class object that SP sets up and will contain references
     to objects, callback methods and observers
     TODO: add more explaination"""
     self.logger =  logging.getLogger("childsplay.findsound.Activity")
     self.logger.info("Activity started")
     self.SPG = SPGoodies
     self.lang = self.SPG.get_localesetting()[0][:2]
     self.scoredisplay = self.SPG.get_scoredisplay()
     self.theme = self.SPG.get_theme()
     self.screen = self.SPG.get_screen()
     self.screenclip = self.SPG.get_screenclip()
     self.blit_pos = self.screenclip.left, self.screenclip.top
     self.orgscreen = pygame.Surface(self.screenclip.size) # we use this to restore the screen
     self.orgscreen.blit(self.screen, (0, 0), self.screenclip)
     self.backgr = self.SPG.get_background()
     # The location of the activities Data dir
     self.my_datadir = os.path.join(self.SPG.get_libdir_path(),'CPData','FindsoundData')
     # Location of the CPData dir which holds some stuff used by multiple activities
     self.CPdatadir = os.path.join(self.SPG.get_libdir_path(),'CPData')
     # Location of the alphabet sounds dir
     self.absdir = self.SPG.get_absdir_path()# alphabet sounds dir
     self.rchash = utils.read_rcfile(os.path.join(self.my_datadir, 'findsound.rc'))
     self.logger.debug("rchash: " + str(self.rchash))
     # You MUST call SPInit BEFORE using any of the SpriteUtils stuff
     # it returns a reference to the special CPGroup
     self.actives = SPSpriteUtils.SPInit(self.screen,self.backgr)
 def __init__(self,SPGoodies):
     """SPGoodies is a class object that SP sets up and will contain references
     to objects, callback methods and observers
     TODO: add more explaination"""
     self.logger =  logging.getLogger("childsplay.electro_sp.Activity")
     self.logger.info("Activity started")
     self.SPG = SPGoodies
     self.theme = self.SPG.get_theme()
     self.screen = self.SPG.get_screen()
     self.screenclip = self.SPG.get_screenclip()
     self.blit_pos = self.screenclip.left, self.screenclip.top
     self.orgscreen = pygame.Surface(self.screenclip.size) # we use this to restore the screen
     self.orgscreen.blit(self.screen, (0, 0), self.screenclip)
     self.backgr = self.SPG.get_background()
     # The location of the activities Data dir
     self.my_datadir = os.path.join(self.SPG.get_libdir_path(),'CPData','Electro_spData')
     self.rchash = utils.read_rcfile(os.path.join(self.my_datadir, 'electro_sp.rc'))
     self.rchash['theme'] = self.theme
     self.logger.debug("rchash: %s" % self.rchash)
     # Location of the CPData dir which holds some stuff used by multiple activities
     self.CPdatadir = os.path.join(self.SPG.get_libdir_path(),'CPData')
     # Location of the alphabet sounds dir
     self.absdir = self.SPG.get_absdir_path()# alphabet sounds dir
     # You MUST call SPInit BEFORE using any of the SpriteUtils stuff
     # it returns a reference to the special CPGroup
     self.actives = SPSpriteUtils.SPInit(self.screen,self.backgr)
     self.scoredisplay = self.SPG.get_scoredisplay()
     files = ('dealcard1.wav','good.ogg','wrong.ogg','button_hover.wav')
     self.Sound = Snd()
     for file in files:
         setattr(self.Sound, file[:-4], utils.load_sound(os.path.join(self.CPdatadir, file)))
Beispiel #8
0
 def __init__(self, SPGoodies):
     """SPGoodies is a class object that SP sets up and will contain references
     to objects, callback methods and observers
     TODO: add more explaination"""
     self.logger = logging.getLogger("childsplay.wipe.Activity")
     self.logger.info("Activity started")
     self.SPG = SPGoodies
     self.lang = self.SPG.get_localesetting()[0][:2]
     self.scoredisplay = self.SPG.get_scoredisplay()
     self.theme = self.SPG.get_theme()
     self.screen = self.SPG.get_screen()
     self.screenclip = self.SPG.get_screenclip()
     self.blit_pos = self.screenclip.left, self.screenclip.top
     self.orgscreen = pygame.Surface(
         self.screenclip.size)  # we use this to restore the screen
     self.orgscreen.blit(self.screen, (0, 0), self.screenclip)
     self.backgr = self.SPG.get_background()
     # The location of the activities Data dir
     self.my_datadir = os.path.join(self.SPG.get_libdir_path(), 'CPData',
                                    'WipeData')
     # Location of the CPData dir which holds some stuff used by multiple activities
     self.CPdatadir = os.path.join(self.SPG.get_libdir_path(), 'CPData')
     # Location of the alphabet sounds dir
     self.absdir = self.SPG.get_absdir_path()  # alphabet sounds dir
     self.rchash = utils.read_rcfile(
         os.path.join(self.my_datadir, 'wipe.rc'))
     self.logger.debug("rchash: " + str(self.rchash))
     # You MUST call SPInit BEFORE using any of the SpriteUtils stuff
     # it returns a reference to the special CPGroup
     self.actives = SPSpriteUtils.SPInit(self.screen, self.backgr)
     self.newbutton = SPWidgets.ButtonRound(_("New"), (300, 560), fgcol=WHITE, \
                                                  fsize=18, sizename='small')
     self.newbutton.connect_callback(self._cbf_new, MOUSEBUTTONDOWN)
 def __init__(self,SPGoodies):
     """SPGoodies is a class object that SP sets up and will contain references
     to objects, callback methods and observers
     TODO: add more explaination"""
     quiz.Activity.__init__(self, SPGoodies)
     self.logger =  logging.getLogger("childsplay.quiz_royal.Activity")
     self.logger.info("Activity started")
     
     # The location of the activities Data dir (override the super class attributes)
     self.my_datadir = os.path.join(self.SPG.get_libdir_path(),'CPData','Quiz_royalData')
     self.rchash = utils.read_rcfile(os.path.join(self.my_datadir, 'quiz_royal.rc'))
     self.rchash['theme'] = self.theme
     self.rchash['lang'] = self.lang
Beispiel #10
0
 def __init__(self,SPGoodies):
     """SPGoodies is a class object that SP sets up and will contain references
     to objects, callback methods and observers
     TODO: add more explaination"""
     quiz.Activity.__init__(self, SPGoodies)
     self.logger =  logging.getLogger("childsplay.quiz_melody.Activity")
     self.logger.info("Activity started")
     
     # The location of the activities Data dir (override the super class attributes)
     self.my_datadir = os.path.join(self.SPG.get_libdir_path(),'CPData','Quiz_melodyData')
     self.rchash = utils.read_rcfile(os.path.join(self.my_datadir, 'quiz_melody.rc'))
     self.rchash['theme'] = self.theme
     self.rchash['lang'] = self.lang
Beispiel #11
0
    def __init__(self, SPGoodies):
        """SPGoodies is a class object that SP sets up and will contain references
        to objects, callback methods and observers
        TODO: add more explaination"""
        self.logger = logging.getLogger("childsplay.quiz_general.Activity")
        self.logger.info("Activity started")
        self.SPG = SPGoodies
        self.lang = self.SPG.get_localesetting()[0][:2]
        self.screen = self.SPG.get_screen()
        self.screenclip = self.SPG.get_screenclip()
        self.blit_pos = self.screenclip.left, self.screenclip.top
        self.logo_pos = (600, 200 + self.blit_pos[1])
        self.theme = self.SPG.get_theme()
        self.orgscreen = pygame.Surface(
            self.screenclip.size)  # we use this to restore the screen
        self.orgscreen.blit(self.screen, (0, 0), self.screenclip)
        self.backgr = self.SPG.get_background()
        # The location of the activities Data dir
        self.my_datadir = os.path.join(self.SPG.get_libdir_path(), 'CPData',
                                       'Quiz_generalData')
        self.quiz_datadir = os.path.join(self.SPG.get_libdir_path(), 'CPData',
                                         'Quizengine_Data')
        # Location of the CPData dir which holds some stuff used by multiple activities
        self.CPdatadir = os.path.join(self.SPG.get_libdir_path(), 'CPData')
        self.rchash = utils.read_rcfile(
            os.path.join(self.my_datadir, 'quiz_general.rc'))
        self.rchash['theme'] = self.theme
        self.rchash['lang'] = self.lang
        self.logger.debug("found rc: %s" % self.rchash)
        p = os.path.join(self.CPdatadir, 'good_%s.png' % self.lang)
        if not os.path.exists(p):
            p = os.path.join(self.CPdatadir, 'thumbs.png')
        self.ThumbsUp = SPSpriteUtils.MySprite(utils.load_image(p))
        # Location of the CPData dir which holds some stuff used by multiple activities
        self.CPdatadir = os.path.join(self.SPG.get_libdir_path(), 'CPData')
        # Location of the alphabet sounds dir
        self.absdir = self.SPG.get_absdir_path()  # alphabet sounds dir
        # You MUST call SPInit BEFORE using any of the SpriteUtils stuff
        # it returns a reference to the special CPGroup
        self.actives = SPSpriteUtils.SPInit(self.screen, self.backgr)

        self.num_questions = int(self.rchash[self.theme]['questions'])
        self.AreWeDT = False
        self.sessionresults = utils.OrderedDict()
        self.sessionresults_raw = utils.OrderedDict()
        self.old_level = None
        self.sessionid = time.time()
        self.act_score = 0
        self.act_cycles = 1
        self.act_mean = 0
        self.levelup = 0
Beispiel #12
0
 def __init__(self,SPGoodies):
     """SPGoodies is a class object that SP sets up and will contain references
     to objects, callback methods and observers
     TODO: add more explaination"""
     self.logger =  logging.getLogger("childsplay.numbers_sp.Activity")
     self.logger.info("Activity started")
     self.SPG = SPGoodies
     self.lang = self.SPG.get_localesetting()[0][:2]
     self.scoredisplay = self.SPG.get_scoredisplay()
     self.theme = self.SPG.get_theme()
     self.screen = self.SPG.get_screen()
     self.screenclip = self.SPG.get_screenclip()
     self.blit_pos = self.screenclip.left, self.screenclip.top
     self.orgscreen = pygame.Surface(self.screenclip.size) # we use this to restore the screen
     self.orgscreen.blit(self.screen, (0, 0), self.screenclip)
     self.backgr = self.SPG.get_background()
     # The location of the activities Data dir
     self.my_datadir = os.path.join(self.SPG.get_libdir_path(),'CPData','Numbers_spData')
     # Location of the CPData dir which holds some stuff used by multiple activities
     self.CPdatadir = os.path.join(self.SPG.get_libdir_path(),'CPData')
     # Location of the alphabet sounds dir
     self.absdir = self.SPG.get_absdir_path()# alphabet sounds dir
     self.rchash = utils.read_rcfile(os.path.join(self.my_datadir, 'numbers_sp.rc'))
     self.logger.debug("rchash: " + str(self.rchash))
     # You MUST call SPInit BEFORE using any of the SpriteUtils stuff
     # it returns a reference to the special CPGroup
     self.actives = SPSpriteUtils.SPInit(self.screen,self.backgr)
     
     self.GoodSound=utils.load_sound(os.path.join(self.CPdatadir, 'good.ogg'))
     self.WrongSound=utils.load_sound(os.path.join(self.CPdatadir, 'wrong.ogg'))
     self.Done=utils.load_sound(os.path.join(self.CPdatadir, 'wahoo.wav'))
     
     b = os.path.join(self.CPdatadir, '200px_80px_blue.png')
     b_ro = os.path.join(self.CPdatadir, '200px_80px_black.png')
     self.beginbut = SPWidgets.TransImgButton(b, b_ro, \
                                 (300, 510), fsize=24, text= _("Begin"),\
                                 fcol=WHITE)
     self.beginbut.connect_callback(self._cbf_begin, MOUSEBUTTONDOWN)
     self.cheatbut = SPWidgets.TransImgButton(b, b_ro, \
                                 (300, 510), fsize=24, text= _("Cheat"),\
                                 fcol=WHITE)
     self.cheatbut.connect_callback(self._cbf_cheat, MOUSEBUTTONDOWN)
     self.playfield = utils.load_image(os.path.join(self.my_datadir, "playfield.png")).convert()
     self.playfield_position = (40, 120)
     self.list_pos = []
     r = self.playfield.get_rect()
     x, y = self.playfield_position
     for i in range(((r.w - 10) / 70)):
         for j in range(((r.h - 10) / 70)):
             self.list_pos.append(((i * 70) + x + 10, (j* 70) + y + 10))
Beispiel #13
0
    def __init__(self, SPGoodies):
        """SPGoodies is a class object that SP sets up and will contain references
        to objects, callback methods and observers
        TODO: add more explaination"""
        self.logger = logging.getLogger("childsplay.puzzle.Activity")
        self.logger.info("Activity started")
        self.SPG = SPGoodies
        self.lang = self.SPG.get_localesetting()[0][:2]
        self.scoredisplay = self.SPG.get_scoredisplay()
        self.theme = self.SPG.get_theme()
        self.screen = self.SPG.get_screen()
        self.screenclip = self.SPG.get_screenclip()
        self.blit_pos = self.screenclip.left, self.screenclip.top
        self.orgscreen = pygame.Surface(
            self.screenclip.size)  # we use this to restore the screen
        self.orgscreen.blit(self.screen, (0, 0), self.screenclip)
        self.backgr = self.SPG.get_background()
        # The location of the activities Data dir
        self.my_datadir = os.path.join(self.SPG.get_libdir_path(), 'CPData',
                                       'PuzzleData')
        self.rchash = utils.read_rcfile(
            os.path.join(self.my_datadir, 'puzzle.rc'))
        self.rchash['theme'] = self.theme
        # Location of the CPData dir which holds some stuff used by multiple activities
        self.CPdatadir = os.path.join(self.SPG.get_libdir_path(), 'CPData')
        self.DbAssets = os.path.join(self.SPG.get_libdir_path(), 'CPData',
                                     'DbaseAssets')
        # Location of the alphabet sounds dir
        self.absdir = self.SPG.get_absdir_path()  # alphabet sounds dir
        # You MUST call SPInit BEFORE using any of the SpriteUtils stuff
        # it returns a reference to the special CPGroup
        self.actives = SPSpriteUtils.SPInit(self.screen, self.backgr)
        self.actives.set_onematch(True)
        imgdir = os.path.join(self.my_datadir, self.theme)
        if not os.path.exists(imgdir):
            old = imgdir
            imgdir = os.path.join(self.my_datadir, 'childsplay')
            self.logger.debug("not found %s using %s" % (old, imgdir))
        target_path = os.path.join(imgdir, 'target.png')
        self.target_image = utils.load_image(target_path)

        self.gamelevels = [(2, 2, 10), (3, 2, 10), (3, 3, 10), (4, 3, 10),
                           (4, 4, 10)]
        # Images must be 324x324
        # Image Size, by now these values has to be "divisibles" by 2,3,4,5,6
        self.xsize = 324
        self.ysize = 324
 def __init__(self,SPGoodies):
     """SPGoodies is a class object that SP sets up and will contain references
     to objects, callback methods and observers
     TODO: add more explaination"""
     self.logger =  logging.getLogger("childsplay.quiz_general.Activity")
     self.logger.info("Activity started")
     self.SPG = SPGoodies
     self.lang = self.SPG.get_localesetting()[0][:2]
     self.screen = self.SPG.get_screen()
     self.screenclip = self.SPG.get_screenclip()
     self.blit_pos = self.screenclip.left, self.screenclip.top
     self.logo_pos = (600, 200 + self.blit_pos[1])
     self.theme = self.SPG.get_theme()
     self.orgscreen = pygame.Surface(self.screenclip.size) # we use this to restore the screen
     self.orgscreen.blit(self.screen, (0, 0), self.screenclip)
     self.backgr = self.SPG.get_background()
     # The location of the activities Data dir
     self.my_datadir = os.path.join(self.SPG.get_libdir_path(),'CPData','Quiz_generalData')
     self.quiz_datadir = os.path.join(self.SPG.get_libdir_path(),'CPData','Quizengine_Data')
     # Location of the CPData dir which holds some stuff used by multiple activities
     self.CPdatadir = os.path.join(self.SPG.get_libdir_path(),'CPData')
     self.rchash = utils.read_rcfile(os.path.join(self.my_datadir, 'quiz_general.rc'))
     self.rchash['theme'] = self.theme
     self.rchash['lang'] = self.lang
     self.logger.debug("found rc: %s" % self.rchash)
     p = os.path.join(self.CPdatadir,'good_%s.png' % self.lang)
     if not os.path.exists(p):
         p = os.path.join(self.CPdatadir,'thumbs.png')
     self.ThumbsUp = SPSpriteUtils.MySprite(utils.load_image(p))
     # Location of the CPData dir which holds some stuff used by multiple activities
     self.CPdatadir = os.path.join(self.SPG.get_libdir_path(),'CPData')
     # Location of the alphabet sounds dir
     self.absdir = self.SPG.get_absdir_path()# alphabet sounds dir
     # You MUST call SPInit BEFORE using any of the SpriteUtils stuff
     # it returns a reference to the special CPGroup
     self.actives = SPSpriteUtils.SPInit(self.screen,self.backgr)
       
     self.num_questions = int(self.rchash[self.theme]['questions'])
     self.AreWeDT = False
     self.sessionresults = utils.OrderedDict()
     self.sessionresults_raw = utils.OrderedDict()
     self.old_level = None
     self.sessionid = time.time()
     self.act_score = 0
     self.act_cycles = 1
     self.act_mean = 0
     self.levelup = 0
Beispiel #15
0
 def __init__(self,SPGoodies):
     """SPGoodies is a class object that SP sets up and will contain references
     to objects, callback methods and observers
     TODO: add more explaination"""
     self.logger =  logging.getLogger("childsplay.puzzle.Activity")
     self.logger.info("Activity started")
     self.SPG = SPGoodies
     self.lang = self.SPG.get_localesetting()[0][:2]
     self.scoredisplay = self.SPG.get_scoredisplay()
     self.theme = self.SPG.get_theme()
     self.screen = self.SPG.get_screen()
     self.screenclip = self.SPG.get_screenclip()
     self.blit_pos = self.screenclip.left, self.screenclip.top
     self.orgscreen = pygame.Surface(self.screenclip.size) # we use this to restore the screen
     self.orgscreen.blit(self.screen, (0, 0), self.screenclip)
     self.backgr = self.SPG.get_background()
     # The location of the activities Data dir
     self.my_datadir = os.path.join(self.SPG.get_libdir_path(),'CPData','PuzzleData')
     self.rchash = utils.read_rcfile(os.path.join(self.my_datadir, 'puzzle.rc'))
     self.rchash['theme'] = self.theme
     # Location of the CPData dir which holds some stuff used by multiple activities
     self.CPdatadir = os.path.join(self.SPG.get_libdir_path(),'CPData')
     self.DbAssets = os.path.join(self.SPG.get_libdir_path(),'CPData', 'DbaseAssets')
     # Location of the alphabet sounds dir
     self.absdir = self.SPG.get_absdir_path()# alphabet sounds dir
     # You MUST call SPInit BEFORE using any of the SpriteUtils stuff
     # it returns a reference to the special CPGroup
     self.actives = SPSpriteUtils.SPInit(self.screen,self.backgr)
     self.actives.set_onematch(True)
     imgdir = os.path.join(self.my_datadir, self.theme)
     if not os.path.exists(imgdir):
         old = imgdir
         imgdir = os.path.join(self.my_datadir,'childsplay')
         self.logger.debug("not found %s using %s" % (old, imgdir))
     target_path = os.path.join(imgdir,'target.png')
     self.target_image = utils.load_image(target_path)
    
     self.gamelevels = [(2,2,10),
                        (3,2,10),
                        (3,3,10),
                        (4,3,10),
                        (4,4,10)]
     # Images must be 324x324
     # Image Size, by now these values has to be "divisibles" by 2,3,4,5,6
     self.xsize = 324
     self.ysize = 324
Beispiel #16
0
    def __init__(self, SPGoodies):
        """SPGoodies is a class object that SP sets up and will contain references
        to objects, callback methods and observers
        TODO: add more explaination"""
        self.logger = logging.getLogger("childsplay.simon_sp.Activity")
        self.logger.info("Activity started")
        self.SPG = SPGoodies
        self.theme = self.SPG.get_theme()
        self.scoredisplay = self.SPG.get_scoredisplay()
        self.screen = self.SPG.get_screen()
        self.screenclip = self.SPG.get_screenclip()
        self.blit_pos = self.screenclip.left, self.screenclip.top
        self.orgscreen = pygame.Surface(
            self.screenclip.size)  # we use this to restore the screen
        self.orgscreen.blit(self.screen, (0, 0), self.screenclip)
        self.backgr = self.SPG.get_background()
        # The location of the activities Data dir
        self.my_datadir = os.path.join(self.SPG.get_libdir_path(), 'CPData',
                                       'Simon_spData')
        self.rchash = utils.read_rcfile(
            os.path.join(self.my_datadir, 'simon_sp.rc'))
        self.rchash['theme'] = self.theme

        self.logger.debug("found rc: %s" % self.rchash)
        # Location of the CPData dir which holds some stuff used by multiple activities
        self.CPdatadir = os.path.join(self.SPG.get_libdir_path(), 'CPData')
        # Location of the alphabet sounds dir
        self.absdir = self.SPG.get_absdir_path()  # alphabet sounds dir
        # You MUST call SPInit BEFORE using any of the SpriteUtils stuff
        # it returns a reference to the special CPGroup
        self.actives = SPSpriteUtils.SPInit(self.screen, self.backgr)

        ### BT related stuff, was rc file dependant replaced by hardcoded values.
        if self.blit_pos[1] == 0:
            y = 10
        else:
            y = 110
        self.yTop = y  #int(self.config["yMargin"])
        self.xMargin = 0  #int(self.config["xMargin"])
        ##################################
        self.lang = self.SPG.get_localesetting()[0][:2]
        self.sequence = []
        self.all_choices = [1, 2, 3, 4]
Beispiel #17
0
 def setup(self):
     """Override this in your derived class."""
     
     # The location of the activities Data dir
     self.my_datadir = os.path.join(self.SPG.get_libdir_path(),'CPData','SynonymsData')
     # Location of the CPData dir which holds some stuff used by multiple activities
     self.rchash = utils.read_rcfile(os.path.join(self.my_datadir, 'synonyms.rc'))
     
     self.alfabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','r','s','t','u','v','w','z']
     self.sequence = self.alfabet[:]
     random.shuffle(self.sequence)
     self.currentletter = self.sequence.pop()
     
     f = open(os.path.join(self.my_datadir,'dictionary_%s.txt' % self.language), 'r')
     self.wordlist = f.readlines()
     f.close()
     self.wc = WordCompleter(self.wordlist)
     
     self.questiontext = _("Make a word with the letter: ")
     self.foundtext =  _("Already found:")
     self.suggestiontext = _("Suggestions:")
Beispiel #18
0
 def __init__(self,SPGoodies):
     """SPGoodies is a class object that SP sets up and will contain references
     to objects, callback methods and observers
     TODO: add more explaination"""
     self.logger =  logging.getLogger("childsplay.simon_sp.Activity")
     self.logger.info("Activity started")
     self.SPG = SPGoodies
     self.theme = self.SPG.get_theme()
     self.scoredisplay = self.SPG.get_scoredisplay()
     self.screen = self.SPG.get_screen()
     self.screenclip = self.SPG.get_screenclip()
     self.blit_pos = self.screenclip.left, self.screenclip.top
     self.orgscreen = pygame.Surface(self.screenclip.size) # we use this to restore the screen
     self.orgscreen.blit(self.screen, (0, 0), self.screenclip)
     self.backgr = self.SPG.get_background()
     # The location of the activities Data dir
     self.my_datadir = os.path.join(self.SPG.get_libdir_path(),'CPData','Simon_spData')
     self.rchash = utils.read_rcfile(os.path.join(self.my_datadir, 'simon_sp.rc'))
     self.rchash['theme'] = self.theme
     
     self.logger.debug("found rc: %s" % self.rchash)
     # Location of the CPData dir which holds some stuff used by multiple activities
     self.CPdatadir = os.path.join(self.SPG.get_libdir_path(),'CPData')
     # Location of the alphabet sounds dir
     self.absdir = self.SPG.get_absdir_path()# alphabet sounds dir
     # You MUST call SPInit BEFORE using any of the SpriteUtils stuff
     # it returns a reference to the special CPGroup
     self.actives = SPSpriteUtils.SPInit(self.screen,self.backgr)
     
     ### BT related stuff, was rc file dependant replaced by hardcoded values.
     if self.blit_pos[1] == 0:
         y =10
     else:
         y = 110
     self.yTop=y #int(self.config["yMargin"])
     self.xMargin=0  #int(self.config["xMargin"])
     ##################################
     self.lang = self.SPG.get_localesetting()[0][:2]
     self.sequence = []
     self.all_choices=[1,2,3,4]
Beispiel #19
0
 def setup(self):
     # The location of the activities Data dir
     self.my_datadir = os.path.join(self.SPG.get_libdir_path(),'CPData','SpinbottleData')
     self.rchash = utils.read_rcfile(os.path.join(self.my_datadir, 'spinbottle.rc'))
     self.currentletter = None
     self.wordlisthash = {}
     paths = glob.glob(os.path.join(self.my_datadir, self.theme,'data_%s' % self.language, '*.txt'))
     self.logger.debug("found: %s " % paths)
     for p in paths:
         f = open(p, 'r')
         lines = f.readlines()
         f.close()
         self.wordlisthash[lines[0][:-1]] = lines[1:]
     self.categories = self.wordlisthash.keys()
     self.logger.debug("Found categories %s" % self.categories)
     random.shuffle(self.categories)
     self.currentcategory = self.categories.pop()
     self.questiontext = _("beginning with the letter: ")
     self.foundtext =  _("Already found:")
     self.suggestiontext = _("Suggestions:")
     self.wc = WordCompleter([])
     self.newexercise_counter = 3
Beispiel #20
0
 def __init__(self,SPGoodies):
     """SPGoodies is a class object that SP sets up and will contain references
     to objects, callback methods and observers
     TODO: add more explaination"""
     self.logger =  logging.getLogger("childsplay.fishtank.Activity")
     self.logger.info("Activity started")
     self.SPG = SPGoodies
     self.scoredisplay = self.SPG.get_scoredisplay()
     self.theme = self.SPG.get_theme()
     self.screen = self.SPG.get_screen()
     self.screenclip = self.SPG.get_screenclip()
     self.blit_pos = self.screenclip.left, self.screenclip.top
     self.orgscreen = pygame.Surface(self.screenclip.size) # we use this to restore the screen
     self.orgscreen.blit(self.screen, (0, 0), self.screenclip)
     self.backgr = self.SPG.get_background()
     # The location of the activities Data dir
     self.my_datadir = os.path.join(self.SPG.get_libdir_path(),'CPData','FishtankData')
     # Location of the CPData dir which holds some stuff used by multiple activities
     self.CPdatadir = os.path.join(self.SPG.get_libdir_path(),'CPData')
     # Location of the alphabet sounds dir
     self.absdir = self.SPG.get_absdir_path()# alphabet sounds dir
     self.rchash = utils.read_rcfile(os.path.join(self.my_datadir, 'fishtank.rc'))
     self.rchash['theme'] = self.theme
     
     self.sounddir = os.path.join(self.my_datadir,'sounds')
     self.bubimg = utils.load_image(os.path.join(self.my_datadir,'backgrounds',self.theme,'blub0.png'))
     self.bubsnd = utils.load_sound(os.path.join(self.sounddir,'blub0.wav'))
     self.splashsnd = utils.load_sound(os.path.join(self.sounddir,'poolsplash.wav'))
     self.WeAreAquarium = False
     self.aquarium_counter = 0
     
     self.aquarium_music_list = glob.glob(os.path.join(self.sounddir,'*.ogg'))
     # You MUST call SPInit BEFORE using any of the SpriteUtils stuff
     # it returns a reference to the special CPGroup
     self.actives = SPSpriteUtils.SPInit(self.screen,self.backgr)
     self.actives.set_onematch(True)
Beispiel #21
0
    def __init__(self,SPGoodies):
        """SPGoodies is a class object that SP sets up and will contain references
        to objects, callback methods and observers
        TODO: add more explaination"""
        self.logger =  logging.getLogger("childsplay.photoalbum.Activity")
        self.logger.info("Activity started")
        self.SPG = SPGoodies
        self.lang = self.SPG.get_localesetting()[0][:2]
        self.theme = self.SPG.get_theme()
        self.screen = self.SPG.get_screen()
        self.screenclip = self.SPG.get_screenclip()
        self.blit_pos = self.screenclip.left, self.screenclip.top
        self.orgscreen = pygame.Surface(self.screenclip.size) # we use this to restore the screen
        self.orgscreen.blit(self.screen, (0, 0), self.screenclip)
        self.backgr = self.SPG.get_background()
        self.blacksurf = pygame.Surface((800, 600)).convert(8)
        self.blacksurf.fill(BLACK)
        # The location of the activities Data dir
        self.my_datadir = os.path.join(self.SPG.get_libdir_path(),'CPData','PhotoalbumData')
        self.thumbsdir = os.path.join(self.my_datadir, 'thumbs')
        if not os.path.exists(self.thumbsdir):
            os.mkdir(self.thumbsdir)
        self.shelvepath = os.path.join(self.thumbsdir, 'thumbs.db')
        # Location of the CPData dir which holds some stuff used by multiple activities
        self.CPdatadir = os.path.join(self.SPG.get_libdir_path(),'CPData')
        self.importDir = os.path.join(HOMEDIR, 'braintrainer', 'PicImport', self.lang)
        # Location of the alphabet sounds dir
        self.absdir = self.SPG.get_absdir_path()# alphabet sounds dir
        self.rchash = utils.read_rcfile(os.path.join(self.my_datadir, 'photoalbum.rc'))
        self.rchash['theme'] = self.theme
        # You MUST call SPInit BEFORE using any of the SpriteUtils stuff
        # it returns a reference to the special CPGroup
        self.actives = SPSpriteUtils.SPInit(self.screen,self.backgr)
        
        self.timer = None
        self.timerpause = int(self.rchash[self.theme]['pause'])
        # We use old fashion surfs to blit on the screen iso buttons as transbuttons
        # with dynamic background would store a complete background surface each in memory!!
        quit_surf = utils.load_image(os.path.join(self.my_datadir, 'quit.icon.png'))
        quitro_surf = utils.load_image(os.path.join(self.my_datadir, 'quit_ro.icon.png'))
        main_exit_pos = (800 - quit_surf.get_size()[0], 0)
        self.main_exit_but = SPWidgets.TransImgButton(quit_surf, quitro_surf, pos=main_exit_pos)
        self.main_exit_but.connect_callback(self.main_exit_but_cbf, MOUSEBUTTONDOWN)
        self.main_exit_but.set_use_current_background(True)
        #self.main_exit_rect = pygame.Rect(self.main_exit_pos + self.main_exit_surf.get_size())
        
        exit_surf = utils.load_image(os.path.join(self.my_datadir, 'category.icon.png'))
        exitro_surf = utils.load_image(os.path.join(self.my_datadir, 'category_ro.icon.png'))
        exit_pos = (0, 0)
        self.exit_but = SPWidgets.TransImgButton(exit_surf, exitro_surf, pos=exit_pos)
        self.exit_but.connect_callback(self.exit_but_cbf, MOUSEBUTTONDOWN)
        self.exit_but.set_use_current_background(True)
        
        play_surf = utils.load_image(os.path.join(self.my_datadir, 'play.icon.png'))
        playro_surf = utils.load_image(os.path.join(self.my_datadir, 'play_ro.icon.png'))
        
        play_pos = (0, 490 - play_surf.get_size()[1])
        self.play_but = SPWidgets.TransImgButton(play_surf, playro_surf, pos=play_pos)
        self.play_but.connect_callback(self.play_but_cbf, MOUSEBUTTONDOWN)
        #self.play_but.set_use_current_background(True)

        text_surf = utils.load_image(os.path.join(self.my_datadir, 'text.icon.png'))
        textro_surf = utils.load_image(os.path.join(self.my_datadir, 'text_ro.icon.png'))
        text_pos = (800 - text_surf.get_size()[0], 490 - text_surf.get_size()[1])
        self.text_but = SPWidgets.TransImgButton(text_surf, textro_surf, pos=text_pos)
        self.text_but.connect_callback(self.text_but_cbf, MOUSEBUTTONDOWN)
        self.text_but.set_use_current_background(True)

        self.buttons_list = [self.play_but, self.main_exit_but, self.exit_but]
        
        self.text_label = None
        self.text_back = utils.load_image(os.path.join(self.my_datadir, 'text_backgr.png'))
        self.textstring = ''
        
        self.prev_mouse_pos = None
        self.SPG.tellcore_set_dice_minimal_level(6)
        
        self.clear_screen()
Beispiel #22
0
    def __init__(self, SPGoodies):
        """SPGoodies is a class object that SP sets up and will contain references
        to objects, callback methods and observers
        TODO: add more explaination"""
        self.logger = logging.getLogger("childsplay.ichanger.Activity")
        self.logger.info("Activity started")
        self.SPG = SPGoodies
        self.lang = self.SPG.get_localesetting()[0][:2]
        self.scoredisplay = self.SPG.get_scoredisplay()
        self.displayedscore = 0
        self.theme = self.SPG.get_theme()
        self.screen = self.SPG.get_screen()
        self.screenclip = self.SPG.get_screenclip()
        self.blit_pos = self.screenclip.left, self.screenclip.top
        self.orgscreen = pygame.Surface(
            self.screenclip.size)  # we use this to restore the screen
        self.orgscreen.blit(self.screen, (0, 0), self.screenclip)
        self.backgr = self.SPG.get_background()
        # The location of the activities Data dir
        self.my_datadir = os.path.join(self.SPG.get_libdir_path(), 'CPData',
                                       'IchangerData')
        self.rchash = utils.read_rcfile(
            os.path.join(self.my_datadir, 'ichanger.rc'))
        self.rchash['theme'] = self.theme
        self.my_rchash = self.rchash[self.theme]
        self.logger.debug("found rc: %s" % self.rchash)
        # Location of the CPData dir which holds some stuff used by multiple activities
        self.CPdatadir = os.path.join(self.SPG.get_libdir_path(), 'CPData')
        # Location of the alphabet sounds dir
        self.absdir = self.SPG.get_absdir_path()  # alphabet sounds dir
        # You MUST call SPInit BEFORE using any of the SpriteUtils stuff
        # it returns a reference to the special CPGroup
        self.actives = SPSpriteUtils.SPInit(self.screen, self.backgr)

        imgdir = os.path.join(self.my_datadir, 'images', self.theme)
        if not os.path.exists(imgdir):
            imgdir = os.path.join(self.my_datadir, 'images', 'childsplay')

        self.imagepaths_org = [f for f in glob.glob(os.path.join(imgdir, '*'))\
                            if os.path.basename(f) not in ('cardfront.png', 'cardback.png')]
        self.imagepaths = self.imagepaths_org[:]
        random.shuffle(self.imagepaths)
        self.opencard = utils.load_image(os.path.join(imgdir, 'cardfront.png'))
        self.closedcard = utils.load_image(os.path.join(
            imgdir, 'cardback.png'))

        boxsurf = utils.load_image(os.path.join(self.my_datadir, 'box.png'))
        self.pausesnd = utils.load_music(
            os.path.join(self.CPdatadir, 'pause_0_35.ogg'))
        self.good_sound = utils.load_music(
            os.path.join(self.CPdatadir, 'good.ogg'))
        self.wrong_sound = utils.load_music(
            os.path.join(self.CPdatadir, 'wrong.ogg'))
        p = os.path.join(self.CPdatadir, 'good_%s.png' % self.lang)
        if not os.path.exists(p):
            p = os.path.join(self.CPdatadir, 'thumbs.png')
        self.good_image = SPSpriteUtils.MySprite(utils.load_image(p))
        self.good_image.moveto((229, 296))
        # Your top blit position, this depends on the menubar position
        if self.blit_pos[1] == 0:
            y = 10
        else:
            y = 110
        self.cardpositions = [(10, y), (260, y), (10, y + 250), (260, y + 250)]
        #self.start_pos = (600, 380 + y)
        self.but_pos = [(560, 420 + y), (700, 400 + y)]
        boxpos = (510, y)
        self.box = TextBox(boxsurf, boxpos)
Beispiel #23
0
    def __init__(self, SPGoodies):
        """SPGoodies is a class object that SP sets up and will contain references
        to objects, callback methods and observers
        TODO: add more explaination"""
        quiz.Activity.__init__(self, SPGoodies)
        self.logger = logging.getLogger("childsplay.quiz_history.Activity")
        self.logger.info("Activity started")

        # The location of the activities Data dir (override the super class attributes)
        self.my_datadir = os.path.join(self.SPG.get_libdir_path(), 'CPData',
                                       'Quiz_historyData')
        self.background_keyboard = utils.load_image(
            os.path.join(self.my_datadir, 'background_keyboard.png'))
        self.rchash = utils.read_rcfile(
            os.path.join(self.my_datadir, 'quiz_history.rc'))
        self.rchash['theme'] = self.theme
        self.rchash['lang'] = self.lang

        self.screenclip = self.SPG.get_screenclip()
        self.blit_pos = self.screenclip.left, self.screenclip.top
        if self.blit_pos[1] == 0:
            y = 10
        else:
            y = 110
        # setup icons fro prelevel
        pos = [(20, 20+y), (240, 20+y), (460, 20+y), \
               (20, 240+y), (240, 240+y), (460, 240+y)]
        self.prelevel_buttons = []
        img = utils.load_image(os.path.join(self.my_datadir, '30s.png'))
        rop = os.path.join(self.my_datadir, '30s_ro.png')
        if os.path.exists(rop):
            img_ro = utils.load_image(rop)
        else:
            img_ro = None
        but = SPWidgets.TransImgButton(img, img_ro, pos[0], name='30')
        but.connect_callback(self._prelevel_cbf, MOUSEBUTTONUP, 30)
        self.prelevel_buttons.append(but)

        img = utils.load_image(os.path.join(self.my_datadir, '40s.png'))
        rop = os.path.join(self.my_datadir, '40s_ro.png')
        if os.path.exists(rop):
            img_ro = utils.load_image(rop)
        else:
            img_ro = None
        but = SPWidgets.TransImgButton(img, img_ro, pos[1], name='40')
        but.connect_callback(self._prelevel_cbf, MOUSEBUTTONUP, 40)
        self.prelevel_buttons.append(but)

        img = utils.load_image(os.path.join(self.my_datadir, '50s.png'))
        rop = os.path.join(self.my_datadir, '50s_ro.png')
        if os.path.exists(rop):
            img_ro = utils.load_image(rop)
        else:
            img_ro = None
        but = SPWidgets.TransImgButton(img, img_ro, pos[2], name='50')
        but.connect_callback(self._prelevel_cbf, MOUSEBUTTONUP, 50)
        self.prelevel_buttons.append(but)

        img = utils.load_image(os.path.join(self.my_datadir, '60s.png'))
        rop = os.path.join(self.my_datadir, '60s_ro.png')
        if os.path.exists(rop):
            img_ro = utils.load_image(rop)
        else:
            img_ro = None
        but = SPWidgets.TransImgButton(img, img_ro, pos[3], name='60')
        but.connect_callback(self._prelevel_cbf, MOUSEBUTTONUP, 60)
        self.prelevel_buttons.append(but)

        img = utils.load_image(os.path.join(self.my_datadir, '70s.png'))
        rop = os.path.join(self.my_datadir, '70s_ro.png')
        if os.path.exists(rop):
            img_ro = utils.load_image(rop)
        else:
            img_ro = None
        but = SPWidgets.TransImgButton(img, img_ro, pos[4], name='70')
        but.connect_callback(self._prelevel_cbf, MOUSEBUTTONUP, 70)
        self.prelevel_buttons.append(but)

        img = utils.load_image(
            os.path.join(self.my_datadir, self.lang, 'age.png'))
        rop = os.path.join(self.my_datadir, self.lang, 'age_ro.png')
        if os.path.exists(rop):
            img_ro = utils.load_image(rop)
        else:
            img_ro = None
        but = SPWidgets.TransImgButton(img, img_ro, pos[5], name='age')
        but.connect_callback(self._prelevel_cbf, MOUSEBUTTONUP, 'age')
        self.prelevel_buttons.append(but)
 def __init__(self,SPGoodies):
     """SPGoodies is a class object that SP sets up and will contain references
     to objects, callback methods and observers
     TODO: add more explaination"""
     quiz.Activity.__init__(self, SPGoodies)
     self.logger =  logging.getLogger("childsplay.quiz_history.Activity")
     self.logger.info("Activity started")
             
     # The location of the activities Data dir (override the super class attributes)
     self.my_datadir = os.path.join(self.SPG.get_libdir_path(),'CPData','Quiz_historyData')
     self.background_keyboard = utils.load_image(os.path.join(self.my_datadir,'background_keyboard.png'))
     self.rchash = utils.read_rcfile(os.path.join(self.my_datadir, 'quiz_history.rc'))
     self.rchash['theme'] = self.theme
     self.rchash['lang'] = self.lang
     
     self.screenclip = self.SPG.get_screenclip()
     self.blit_pos = self.screenclip.left, self.screenclip.top
     if self.blit_pos[1] == 0:
         y = 10
     else:
         y = 110
     # setup icons fro prelevel
     pos = [(20, 20+y), (240, 20+y), (460, 20+y), \
            (20, 240+y), (240, 240+y), (460, 240+y)]
     self.prelevel_buttons = []
     img = utils.load_image(os.path.join(self.my_datadir, '30s.png'))
     rop =  os.path.join(self.my_datadir, '30s_ro.png')
     if os.path.exists(rop):
         img_ro = utils.load_image(rop)
     else:
         img_ro = None
     but = SPWidgets.TransImgButton(img, img_ro, pos[0], name='30')
     but.connect_callback(self._prelevel_cbf, MOUSEBUTTONUP, 30)
     self.prelevel_buttons.append(but)
     
     img = utils.load_image(os.path.join(self.my_datadir, '40s.png'))
     rop =  os.path.join(self.my_datadir, '40s_ro.png')
     if os.path.exists(rop):
         img_ro = utils.load_image(rop)
     else:
         img_ro = None
     but = SPWidgets.TransImgButton(img, img_ro, pos[1], name='40')
     but.connect_callback(self._prelevel_cbf, MOUSEBUTTONUP, 40)
     self.prelevel_buttons.append(but)
     
     img = utils.load_image(os.path.join(self.my_datadir, '50s.png'))
     rop = os.path.join(self.my_datadir, '50s_ro.png')
     if os.path.exists(rop):
         img_ro = utils.load_image(rop)
     else:
         img_ro = None
     but = SPWidgets.TransImgButton(img, img_ro, pos[2], name='50')
     but.connect_callback(self._prelevel_cbf, MOUSEBUTTONUP, 50)
     self.prelevel_buttons.append(but)
     
     img = utils.load_image(os.path.join(self.my_datadir, '60s.png'))
     rop =  os.path.join(self.my_datadir, '60s_ro.png')
     if os.path.exists(rop):
         img_ro = utils.load_image(rop)
     else:
         img_ro = None
     but = SPWidgets.TransImgButton(img, img_ro, pos[3], name='60')
     but.connect_callback(self._prelevel_cbf, MOUSEBUTTONUP, 60)
     self.prelevel_buttons.append(but)
     
     img = utils.load_image(os.path.join(self.my_datadir, '70s.png'))
     rop = os.path.join(self.my_datadir, '70s_ro.png')
     if os.path.exists(rop):
         img_ro = utils.load_image(rop)
     else:
         img_ro = None
     but = SPWidgets.TransImgButton(img, img_ro, pos[4], name='70')
     but.connect_callback(self._prelevel_cbf, MOUSEBUTTONUP, 70)
     self.prelevel_buttons.append(but)
     
     img = utils.load_image(os.path.join(self.my_datadir, self.lang,'age.png'))
     rop =  os.path.join(self.my_datadir, self.lang, 'age_ro.png')
     if os.path.exists(rop):
         img_ro = utils.load_image(rop)
     else:
         img_ro = None
     but = SPWidgets.TransImgButton(img, img_ro, pos[5], name='age')
     but.connect_callback(self._prelevel_cbf, MOUSEBUTTONUP, 'age')
     self.prelevel_buttons.append(but)
Beispiel #25
0
 def __init__(self,SPGoodies):
     """SPGoodies is a class object that SP sets up and will contain references
     to objects, callback methods and observers
     TODO: add more explaination"""
     self.logger =  logging.getLogger("childsplay.ichanger.Activity")
     self.logger.info("Activity started")
     self.SPG = SPGoodies
     self.lang = self.SPG.get_localesetting()[0][:2]
     self.scoredisplay = self.SPG.get_scoredisplay()
     self.displayedscore = 0
     self.theme = self.SPG.get_theme()
     self.screen = self.SPG.get_screen()
     self.screenclip = self.SPG.get_screenclip()
     self.blit_pos = self.screenclip.left, self.screenclip.top
     self.orgscreen = pygame.Surface(self.screenclip.size) # we use this to restore the screen
     self.orgscreen.blit(self.screen, (0, 0), self.screenclip)
     self.backgr = self.SPG.get_background()
     # The location of the activities Data dir
     self.my_datadir = os.path.join(self.SPG.get_libdir_path(),'CPData','IchangerData')
     self.rchash = utils.read_rcfile(os.path.join(self.my_datadir, 'ichanger.rc'))
     self.rchash['theme'] = self.theme
     self.my_rchash = self.rchash[self.theme]
     self.logger.debug("found rc: %s" % self.rchash)
     # Location of the CPData dir which holds some stuff used by multiple activities
     self.CPdatadir = os.path.join(self.SPG.get_libdir_path(),'CPData')
     # Location of the alphabet sounds dir
     self.absdir = self.SPG.get_absdir_path()# alphabet sounds dir
     # You MUST call SPInit BEFORE using any of the SpriteUtils stuff
     # it returns a reference to the special CPGroup
     self.actives = SPSpriteUtils.SPInit(self.screen,self.backgr)
     
     imgdir = os.path.join(self.my_datadir,'images', self.theme)
     if not os.path.exists(imgdir):
         imgdir = os.path.join(self.my_datadir, 'images','childsplay')
     
     self.imagepaths_org = [f for f in glob.glob(os.path.join(imgdir, '*'))\
                         if os.path.basename(f) not in ('cardfront.png', 'cardback.png')]
     self.imagepaths = self.imagepaths_org[:]
     random.shuffle(self.imagepaths)
     self.opencard = utils.load_image(os.path.join(imgdir,'cardfront.png'))
     self.closedcard = utils.load_image(os.path.join(imgdir,'cardback.png'))
     
     boxsurf = utils.load_image(os.path.join(self.my_datadir,'box.png'))
     self.pausesnd = utils.load_music(os.path.join(self.CPdatadir,'pause_0_35.ogg'))
     self.good_sound=utils.load_music(os.path.join(self.CPdatadir,'good.ogg'))
     self.wrong_sound=utils.load_music(os.path.join(self.CPdatadir,'wrong.ogg'))
     p = os.path.join(self.CPdatadir,'good_%s.png' % self.lang)
     if not os.path.exists(p):
         p = os.path.join(self.CPdatadir,'thumbs.png')
     self.good_image = SPSpriteUtils.MySprite(utils.load_image(p))
     self.good_image.moveto((229,296))
     # Your top blit position, this depends on the menubar position
     if self.blit_pos[1] == 0:
         y = 10
     else:
         y = 110
     self.cardpositions = [(10, y), (260, y), (10, y+250), (260, y+250)]
     #self.start_pos = (600, 380 + y)
     self.but_pos = [(560, 420 + y), (700, 400+y)]
     boxpos = (510, y)
     self.box = TextBox(boxsurf, boxpos)
Beispiel #26
0
    def __init__(self, SPGoodies):
        """SPGoodies is a class object that SP sets up and will contain references
        to objects, callback methods and observers
        TODO: add more explaination"""
        self.logger = logging.getLogger("childsplay.photoalbum.Activity")
        self.logger.info("Activity started")
        self.SPG = SPGoodies
        self.lang = self.SPG.get_localesetting()[0][:2]
        self.theme = self.SPG.get_theme()
        self.screen = self.SPG.get_screen()
        self.screenclip = self.SPG.get_screenclip()
        self.blit_pos = self.screenclip.left, self.screenclip.top
        self.orgscreen = pygame.Surface(
            self.screenclip.size)  # we use this to restore the screen
        self.orgscreen.blit(self.screen, (0, 0), self.screenclip)
        self.backgr = self.SPG.get_background()
        self.blacksurf = pygame.Surface((800, 600)).convert(8)
        self.blacksurf.fill(BLACK)
        # The location of the activities Data dir
        self.my_datadir = os.path.join(self.SPG.get_libdir_path(), 'CPData',
                                       'PhotoalbumData')
        self.thumbsdir = os.path.join(self.my_datadir, 'thumbs')
        if not os.path.exists(self.thumbsdir):
            os.mkdir(self.thumbsdir)
        self.shelvepath = os.path.join(self.thumbsdir, 'thumbs.db')
        # Location of the CPData dir which holds some stuff used by multiple activities
        self.CPdatadir = os.path.join(self.SPG.get_libdir_path(), 'CPData')
        self.importDir = os.path.join(HOMEDIR, 'braintrainer', 'PicImport',
                                      self.lang)
        # Location of the alphabet sounds dir
        self.absdir = self.SPG.get_absdir_path()  # alphabet sounds dir
        self.rchash = utils.read_rcfile(
            os.path.join(self.my_datadir, 'photoalbum.rc'))
        self.rchash['theme'] = self.theme
        # You MUST call SPInit BEFORE using any of the SpriteUtils stuff
        # it returns a reference to the special CPGroup
        self.actives = SPSpriteUtils.SPInit(self.screen, self.backgr)

        self.timer = None
        self.timerpause = int(self.rchash[self.theme]['pause'])
        # We use old fashion surfs to blit on the screen iso buttons as transbuttons
        # with dynamic background would store a complete background surface each in memory!!
        quit_surf = utils.load_image(
            os.path.join(self.my_datadir, 'quit.icon.png'))
        quitro_surf = utils.load_image(
            os.path.join(self.my_datadir, 'quit_ro.icon.png'))
        main_exit_pos = (800 - quit_surf.get_size()[0], 0)
        self.main_exit_but = SPWidgets.TransImgButton(quit_surf,
                                                      quitro_surf,
                                                      pos=main_exit_pos)
        self.main_exit_but.connect_callback(self.main_exit_but_cbf,
                                            MOUSEBUTTONDOWN)
        self.main_exit_but.set_use_current_background(True)
        #self.main_exit_rect = pygame.Rect(self.main_exit_pos + self.main_exit_surf.get_size())

        exit_surf = utils.load_image(
            os.path.join(self.my_datadir, 'category.icon.png'))
        exitro_surf = utils.load_image(
            os.path.join(self.my_datadir, 'category_ro.icon.png'))
        exit_pos = (0, 0)
        self.exit_but = SPWidgets.TransImgButton(exit_surf,
                                                 exitro_surf,
                                                 pos=exit_pos)
        self.exit_but.connect_callback(self.exit_but_cbf, MOUSEBUTTONDOWN)
        self.exit_but.set_use_current_background(True)

        play_surf = utils.load_image(
            os.path.join(self.my_datadir, 'play.icon.png'))
        playro_surf = utils.load_image(
            os.path.join(self.my_datadir, 'play_ro.icon.png'))

        play_pos = (0, 490 - play_surf.get_size()[1])
        self.play_but = SPWidgets.TransImgButton(play_surf,
                                                 playro_surf,
                                                 pos=play_pos)
        self.play_but.connect_callback(self.play_but_cbf, MOUSEBUTTONDOWN)
        #self.play_but.set_use_current_background(True)

        text_surf = utils.load_image(
            os.path.join(self.my_datadir, 'text.icon.png'))
        textro_surf = utils.load_image(
            os.path.join(self.my_datadir, 'text_ro.icon.png'))
        text_pos = (800 - text_surf.get_size()[0],
                    490 - text_surf.get_size()[1])
        self.text_but = SPWidgets.TransImgButton(text_surf,
                                                 textro_surf,
                                                 pos=text_pos)
        self.text_but.connect_callback(self.text_but_cbf, MOUSEBUTTONDOWN)
        self.text_but.set_use_current_background(True)

        self.buttons_list = [self.play_but, self.main_exit_but, self.exit_but]

        self.text_label = None
        self.text_back = utils.load_image(
            os.path.join(self.my_datadir, 'text_backgr.png'))
        self.textstring = ''

        self.prev_mouse_pos = None
        self.SPG.tellcore_set_dice_minimal_level(6)

        self.clear_screen()