|
@@ -4,7 +4,6 @@ import configobj
|
4
|
4
|
from configobj import ConfigObj
|
5
|
5
|
|
6
|
6
|
mainDir = GameLogic.expandPath("//")
|
7
|
|
-
|
8
|
7
|
fileName = mainDir + "config.ini"
|
9
|
8
|
|
10
|
9
|
config = ConfigObj(fileName, interpolation=True)
|
|
@@ -25,9 +24,50 @@ def to_dict(section, key):
|
25
|
24
|
except:
|
26
|
25
|
pass
|
27
|
26
|
dict[key] = value
|
|
27
|
+ #print(key, value)
|
|
28
|
+
|
|
29
|
+def readChar():
|
|
30
|
+ mainDir = GameLogic.expandPath("//characters/")
|
|
31
|
+ fileName = mainDir + dict['character'] + ".ini"
|
|
32
|
+ print('loading character settings', fileName)
|
|
33
|
+ char_config = ConfigObj(fileName, interpolation=True)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+ def to_dict2(section, key):
|
|
37
|
+ dict = bge.logic.globalDict
|
|
38
|
+ value = char_config[key]
|
|
39
|
+ if isinstance(value, str):
|
|
40
|
+ if value.isdigit():
|
|
41
|
+ value = int(value)
|
|
42
|
+ else:
|
|
43
|
+ try:
|
|
44
|
+ value = float(value)
|
|
45
|
+ except:
|
|
46
|
+ pass
|
|
47
|
+ dict[key] = value
|
|
48
|
+ print(key, value)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+ char_config.walk(to_dict2, char_config)
|
|
52
|
+
|
|
53
|
+def writeChar():
|
|
54
|
+ dict = bge.logic.globalDict
|
|
55
|
+ mainDir = GameLogic.expandPath("//characters/")
|
|
56
|
+ fileName = mainDir + dict['character'] + ".ini"
|
|
57
|
+ print('writing character settings', fileName)
|
|
58
|
+ char_config = ConfigObj(fileName, interpolation=True)
|
|
59
|
+
|
|
60
|
+ def from_dict2(section, key):
|
|
61
|
+ char_config[key] = dict[key]
|
|
62
|
+
|
|
63
|
+ char_config.walk(from_dict2)
|
|
64
|
+ #char_config[key] = dict[key]
|
|
65
|
+ char_config.write()
|
|
66
|
+
|
28
|
67
|
|
29
|
68
|
def readSettings():
|
30
|
|
- config.walk(to_dict)
|
|
69
|
+ config.walk(to_dict)
|
|
70
|
+ readChar()
|
31
|
71
|
|
32
|
72
|
def from_dict(section, key):
|
33
|
73
|
dict = bge.logic.globalDict
|
|
@@ -35,8 +75,9 @@ def from_dict(section, key):
|
35
|
75
|
|
36
|
76
|
def writeSettings():
|
37
|
77
|
config.walk(from_dict)
|
38
|
|
- config.write()
|
39
|
|
-
|
|
78
|
+ config.write()
|
|
79
|
+ dict = bge.logic.globalDict
|
|
80
|
+
|
40
|
81
|
def setres():
|
41
|
82
|
import GameLogic
|
42
|
83
|
import bge
|