-
Notifications
You must be signed in to change notification settings - Fork 1
/
options.py
60 lines (53 loc) · 1.46 KB
/
options.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from ConfigParser import SafeConfigParser
NAV_CMDS = ['nav-up', 'nav-down', 'nav-left', 'nav-right', 'nav-confirm', 'nav-back']
ACT_CMDS = ['aX', 'aY', 'A', 'B', 'C', 'D']
DEFAULTS = {
'joy-nav-map': {
('a', 1, -1):0,
('a', 1, 1):1,
('a', 0, -1):2,
('a', 0, 1):3,
('b', 0):4,
('b', 1):5,
},
'key-nav-map': {
'arrow_up':0,
'arrow_down':1,
'arrow_left':2,
'arrow_right':3,
'space':4,
'escape':5,
},
'joy-map': {
('a', 0) : 0,
('a', 1) : 1,
('b', 2) : 2,
('b' ,1) : 3 ,
('b', 3) : 4,
('b', 0) : 5,
},
#~ 'key-nav-map': {
#~ ''
#~ },
'game-opts':{
'controller': 'Keyboard',
}
}
class MoonBunnyOptions(SafeConfigParser):
def __init__(self):
SafeConfigParser.__init__(self)
try:
f = file('options.cfg')
self.read('options.cfg')
except IOError:
for (k, v) in DEFAULTS.items():
self.add_section(k)
for (k2, v2) in v.items():
self.set(k, str(k2), str(v2))
f = file('options.cfg', 'w')
self.write(f)
def save(self):
f = file('options.cfg', 'w')
self.write(f)