~facundo/enjuewemela/trunk

« back to all changes in this revision

Viewing changes to enjuewemela/games.py

  • Committer: facundo at com
  • Date: 2010-10-21 22:15:01 UTC
  • mfrom: (60.1.7 menus)
  • Revision ID: facundo@taniquetil.com.ar-20101021221501-jq8yjnlbh8p3zymp
Two menus!

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 
11
11
from __future__ import division
12
12
 
 
13
import codecs
 
14
import os
13
15
import random
14
16
import time
15
17
 
 
18
import xdg.BaseDirectory
 
19
 
 
20
from ConfigParser import RawConfigParser
 
21
from config_schema import ConfigSchema
 
22
from configglue.pyschema import SchemaConfigParser
 
23
 
16
24
import cocos
17
25
from cocos.director import director
18
26
from cocos import actions, scene
24
32
import logic_board
25
33
import stats
26
34
import remove_effects
27
 
from gamemenu import MainMenu
 
35
from gamemenu import MainMenu, set_options
28
36
from gems import gems
29
37
from config import (
30
38
    ARISTA, BASE_COLOR, BORDER, PIECE_TRIP_TIME, FALL_TIME,
32
40
from sound import sounds
33
41
 
34
42
 
 
43
 
 
44
 
 
45
class ConfigManager(object):
 
46
    """Keeps the user configuration."""
 
47
 
 
48
    def __init__(self):
 
49
        self.parser = SchemaConfigParser(ConfigSchema())
 
50
        self.fname = os.path.join(xdg.BaseDirectory.xdg_config_home,
 
51
                                  'enjuewemela.conf')
 
52
        self.parser.read(self.fname)
 
53
 
 
54
    def __getitem__(self, key):
 
55
        """Dynamically sets and gets values."""
 
56
        return self.parser.values()['__main__'][key]
 
57
 
 
58
    def __setitem__(self, key, value):
 
59
        """Dynamically sets and gets values."""
 
60
        self.parser.set('__main__', key, value)
 
61
        self.parser.save(self.fname)
 
62
 
 
63
 
35
64
class BackgroundLayer(cocos.layer.Layer):
36
65
    """Background layer for all the game."""
37
66
 
742
771
    def __init__(self):
743
772
        self.playing = None
744
773
        self.timing = None
 
774
        self.config = ConfigManager()
 
775
        set_options(self.config)
745
776
 
746
777
    def _get_custom(self, specification):
747
778
        """Process the specification."""