shuvit 3 years ago
parent
commit
39a2ee3e33
2 changed files with 26 additions and 290 deletions
  1. 14
    278
      Settings.py
  2. 12
    12
      menuV3.py

+ 14
- 278
Settings.py View File

@@ -1,274 +1,42 @@
1
-#from bge import logic
2 1
 import bge
3 2
 import GameLogic
4 3
 import configobj
5 4
 from configobj import ConfigObj
6 5
 
7
-#from os.path import dirname, realpath, join
8
-
9
-#BASE_DIR = os.path.join( os.path.dirname( __file__ ), '..' )
10 6
 mainDir = GameLogic.expandPath("//")
11 7
 
12 8
 fileName = mainDir + "config.ini"
13 9
 
14 10
 config = ConfigObj(fileName, interpolation=True)
15
-#config.filename = filename
16 11
 dict = bge.logic.globalDict
17 12
 
18
-#resx = 1280
19
-#resy = 720
20 13
 print('###############start game##########')
21 14
 dict['music_player'] = 1
15
+
22 16
 def to_dict(section, key):
23 17
     dict = bge.logic.globalDict
24
-    #print(key, config[key])
25
-    str = config[key]
26
-    if str.isdigit():
27
-        dict[key] = int(str)
28
-    else:
29
-        try:
30
-            dict[key] = float(str)
31
-        except:
32
-            dict[key] = str   
33
-
18
+    value = config[key]
19
+    if isinstance(value, str):
20
+        if value.isdigit():
21
+            value = int(value)
22
+        else:
23
+            try:
24
+                value = float(value)
25
+            except:
26
+                pass
27
+    dict[key] = value  
34 28
 
35 29
 def readSettings():
36
-    config.walk(to_dict)    
37
-    
38
-    
39
-    
40
-    
41
-    
42
-#    import GameLogic
43
-#    import bge
44
-#    cont = GameLogic.getCurrentController()
45
-#    own = cont.owner
46
-#    scenes = bge.logic.getSceneList()
47
-#    main_scene = [scene for scene in scenes if scene.name=="main"][0]
48
-#    own = main_scene.objects['Empty']
49
-#    
50
-#    with open(fileName) as reading:
51
-#        #data = [line.split()[0] for line in reading]
52
-#        data = reading.readlines()
53
-#        #print lines[25]
54
-#        #print lines[29]
55
-#        reading.close()
56
-
57
-#    #own["val"] = int(data[1])
58
-#    #own["bright"] = int(data[1])
59
-#    own["playerName"] = data[4]
60
-#    #own["audio"] = int(data[3])
61
-#    own["level"] = data[5]
62
-#    #data6 = data[6]
63
-#    #data6.split(None, 1)[0]
64
-#    #data5 = data5.strip('\n')
65
-#    #print(data6)
66
-#    own["resx"] = int(data[7])
67
-#    own["resy"] = int(data[8])
68
-#    own["framerate"] = int(data[10])
69
-#    own["profile"] = int(data[12])
70
-#    dict = bge.logic.globalDict #Get the global dictionary
71
-#    
72
-#    dict['resx'] = own["resx"]
73
-#    dict['resy'] = own["resy"]   
74
-#    level = data[5]
75
-#    level = level.split(None, 1)[0]
76
-#    level = str(level)
77
-#    own["level"] = level
78
-#    dict["level"] = level
79
-#    print("reading. settings")
80
-#    
81
-#    
82
-#    
83
-#    
84
-#    
85
-#    
86
-#    
87
-#    
88
-#    
89
-#    print("Level: ", level)
90
-#    recorder_on = int(data[14])
91
-#    print("Game play recorder on: ", recorder_on) 
92
-#    #dict = bge.logic.globalDict
93
-#    dict['recorder_on'] = recorder_on
94
-#    own['recorder_on'] = recorder_on
95
-#    dict['recorder_on'] = recorder_on 
96
-#    character = data[1]
97
-#    dict["character"] = str(character.split(None, 1)[0])
98
-#    dict["shirt_color_r"] = float(data[16])
99
-#    dict["shirt_color_g"] = float(data[17])
100
-#    dict["shirt_color_b"] = float(data[18])
101
-#    dict["shoe_color_r"] = float(data[20])
102
-#    dict["shoe_color_g"] = float(data[21])
103
-#    dict["shoe_color_b"] = float(data[22]) 
104
-#    dict["deck_color_r"] = float(data[24])
105
-#    dict["deck_color_g"] = float(data[25])
106
-#    dict["deck_color_b"] = float(data[26]) 
107
-#    dict["shirt_logo"] = int(data[28])  
108
-#    dict["bc"] = int(data[30])
109
-#    dict["BC_BRIGHTNESS"] = float(data[31])
110
-#    dict["BC_CONTRAST"] = float(data[32])  
111
-#    dict['hdr'] = int(data[34])
112
-#    dict['avgL'] = float(data[35])
113
-#    dict['HDRamount'] = float(data[36])
114
-#    dict['ao'] = int(data[38])
115
-#    dict['onlyAO'] = int(data[39])
116
-#    dict['aowidth'] = float(data[40])
117
-#    dict['aoradius'] = float(data[41])
118
-#    dict['dof_on'] = float(data[43])
119
-#    dict['sun_strength'] = float(data[45])
120
-#    dict['sun_rot_x'] = float(data[46])
121
-#    dict['sun_rot_y'] = float(data[47])            
122
-#    dict['shadow_on'] = int(data[48])
123
-#    dict['ambient_strength'] = float(data[49]) 
124
-#    dict['fullscreen_on'] = int(data[51]) 
125
-#    dict['bloom_on'] = int(data[53]) 
126
-#    dict['cam_height'] = float(data[55]) 
127
-#    dict['focal_length'] = int(data[56])        
128
-#    dict['cam_min'] = float(data[57])
129
-#    dict['cam_max'] = float(data[58])
130
-#    dict['music_player'] = int(data[60]) 
131
-#    dict['fxaa'] = int(data[62]) 
132
-#    dict['FXAA_SPAN_MAX'] = float(data[63])   
133
-#    dict['cch_targetHeight'] = float(data[65])         
134
-#    dict["trucks_r"] = float(data[67])
135
-#    dict["trucks_g"] = float(data[68])
136
-#    dict["trucks_b"] = float(data[69])
137
-#    dict["wheel1_r"] = float(data[71])
138
-#    dict["wheel1_g"] = float(data[72])
139
-#    dict["wheel1_b"] = float(data[73])
140
-#    dict["wheel2_r"] = float(data[75])
141
-#    dict["wheel2_g"] = float(data[76])
142
-#    dict["wheel2_b"] = float(data[77])
143
-#    dict["wheel3_r"] = float(data[79])
144
-#    dict["wheel3_g"] = float(data[80])
145
-#    dict["wheel3_b"] = float(data[81])
146
-#    dict["wheel4_r"] = float(data[83])
147
-#    dict["wheel4_g"] = float(data[84])
148
-#    dict["wheel4_b"] = float(data[85])  
149
-#    dict["deck_index"] = int(data[87])                        
150
-#    
151
-    #print('bc = ', dict['bc'])        
152
-    #dict['music_player_on'] = int(data[16])  
30
+    config.walk(to_dict)     
153 31
 
154 32
 def from_dict(section, key):
155
-    
33
+    dict = bge.logic.globalDict
156 34
     config[key] = dict[key]
157 35
 
158 36
 def writeSettings():
159 37
     config.walk(from_dict)  
160 38
     config.write()    
161
-    
162 39
           
163
-        
164
-    
165
-    
166
-#    import GameLogic
167
-#    import bge
168
-#    cont = GameLogic.getCurrentController()
169
-#    own = cont.owner
170
-#    scenes = bge.logic.getSceneList()
171
-#    dict = bge.logic.globalDict
172
-#    main_scene = [scene for scene in scenes if scene.name=="main"][0]
173
-#    own = main_scene.objects['Empty']
174
-#    print("writing called")
175
-#    with open(fileName, 'w') as writing:
176
-#        writing.write(str("//settings.dat")+"\n")
177
-#        writing.write(str(dict["character"])+"\n")
178
-#        writing.write(str(own["bright"])+"\n")
179
-#        writing.write(str("-\n"))
180
-#        writing.write(str("//level (e.g. spine, city, city2)")+"\n")
181
-#        writing.write(str(own["level"])+"\n")
182
-#        writing.write(str("//resolution")+"\n")
183
-#        writing.write(str(dict["resx"])+"\n")
184
-#        writing.write(str(dict["resy"])+"\n")
185
-#        writing.write(str("//show framerate")+"\n")
186
-#        writing.write(str(own["framerate"])+"\n")
187
-#        writing.write(str("//show profile")+"\n")
188
-#        writing.write(str(own["profile"])+"\n")
189
-#        writing.write(str("//Game play recorder off/on (0,1)")+"\n")
190
-#        writing.write(str(own["recorder_on"])+"\n")
191
-#        writing.write(str("//Shirt color [r,g,b]")+"\n")
192
-#        writing.write(str(dict["shirt_color_r"])+"\n") #16
193
-#        writing.write(str(dict["shirt_color_g"])+"\n")
194
-#        writing.write(str(dict["shirt_color_b"])+"\n")    # 
195
-#        writing.write(str("//Shoe color [r,g,b]")+"\n")
196
-#        writing.write(str(dict["shoe_color_r"])+"\n") #16
197
-#        writing.write(str(dict["shoe_color_g"])+"\n")
198
-#        writing.write(str(dict["shoe_color_b"])+"\n")    # 
199
-#        writing.write(str("//Deck color [r,g,b]")+"\n")
200
-#        writing.write(str(dict["deck_color_r"])+"\n") #24
201
-#        writing.write(str(dict["deck_color_g"])+"\n")
202
-#        writing.write(str(dict["deck_color_b"])+"\n")    #                           
203
-#        writing.write(str("//Shirt Logo")+"\n")
204
-#        writing.write(str(dict["shirt_logo"])+"\n") #24
205
-#        writing.write(str("//Brightness/Contrast: On, brightness, contrast")+"\n")
206
-#        writing.write(str(dict["bc"])+"\n")
207
-#        writing.write(str(dict["BC_BRIGHTNESS"])+"\n")
208
-#        writing.write(str(dict["BC_CONTRAST"])+"\n")
209
-#        writing.write(str("//HDR: On, avgL, amount")+"\n")
210
-#        writing.write(str(dict["hdr"])+"\n")
211
-#        writing.write(str(dict["avgL"])+"\n")
212
-#        writing.write(str(dict["HDRamount"])+"\n") 
213
-#        writing.write(str("//AO: On, only, width, radius")+"\n")
214
-#        writing.write(str(dict["ao"])+"\n")
215
-#        writing.write(str(dict["onlyAO"])+"\n")
216
-#        writing.write(str(dict["aowidth"])+"\n")                
217
-#        writing.write(str(dict["aoradius"])+"\n") 
218
-#        writing.write(str("//dof on")+"\n")
219
-#        writing.write(str(dict["dof_on"])+"\n") 
220
-#        writing.write(str("//sun settings: strength, rotx, roty, shadow on, ambient strength")+"\n")
221
-#        writing.write(str(dict["sun_strength"])+"\n")                           
222
-#        writing.write(str(dict["sun_rot_x"])+"\n")                           
223
-#        writing.write(str(dict["sun_rot_y"])+"\n")                           
224
-#        writing.write(str(dict["shadow_on"])+"\n")                                     
225
-#        writing.write(str(dict["ambient_strength"])+"\n") 
226
-#        writing.write(str("//fullscreen on (0,1)")+"\n")
227
-#        writing.write(str(dict["fullscreen_on"])+"\n") 
228
-#        writing.write(str("//bloom on (0,1)")+"\n")
229
-#        writing.write(str(dict["bloom_on"])+"\n")  
230
-#        writing.write(str("//cam")+"\n")
231
-#        writing.write(str(dict["cam_height"])+"\n") 
232
-#        writing.write(str(dict["focal_length"])+"\n") 
233
-#        writing.write(str(dict["cam_min"])+"\n")                 
234
-#        writing.write(str(dict["cam_max"])+"\n") 
235
-#        writing.write(str("//music player on / off")+"\n")
236
-#        writing.write(str(dict["music_player"])+"\n")
237
-#        writing.write(str("//fxaa")+"\n")
238
-#        writing.write(str(dict["fxaa"])+"\n") 
239
-#        writing.write(str(dict["FXAA_SPAN_MAX"])+"\n")    
240
-#        writing.write(str("//camera target height")+"\n")
241
-#        writing.write(str(dict["cch_targetHeight"] )+"\n")   
242
-#        writing.write(str("//trucks color [r,g,b]")+"\n")
243
-#        writing.write(str(dict["trucks_r"])+"\n")
244
-#        writing.write(str(dict["trucks_g"])+"\n")
245
-#        writing.write(str(dict["trucks_b"])+"\n") 
246
-#        writing.write(str("//wheel1 color [r,g,b]")+"\n")
247
-#        writing.write(str(dict["wheel1_r"])+"\n")
248
-#        writing.write(str(dict["wheel1_g"])+"\n")
249
-#        writing.write(str(dict["wheel1_b"])+"\n") 
250
-#        writing.write(str("//wheel2 color [r,g,b]")+"\n")
251
-#        writing.write(str(dict["wheel2_r"])+"\n")
252
-#        writing.write(str(dict["wheel2_g"])+"\n")
253
-#        writing.write(str(dict["wheel2_b"])+"\n") 
254
-#        writing.write(str("//wheel3 color [r,g,b]")+"\n")
255
-#        writing.write(str(dict["wheel3_r"])+"\n")
256
-#        writing.write(str(dict["wheel3_g"])+"\n")
257
-#        writing.write(str(dict["wheel3_b"])+"\n") 
258
-#        writing.write(str("//wheel4 color [r,g,b]")+"\n")
259
-#        writing.write(str(dict["wheel4_r"])+"\n")
260
-#        writing.write(str(dict["wheel4_g"])+"\n")
261
-#        writing.write(str(dict["wheel4_b"])+"\n")                                          
262
-#        writing.write(str("//deck index")+"\n")
263
-#        writing.write(str(dict["deck_index"])+"\n")        
264
-#        
265
-#        #dict['ccH_targetHeight']     
266
-#        
267
-#        #writing.write(str(own["framerate"])+"\n")
268
-#        print("writing settings")
269
-#        writing.close()
270
-       
271
-       
272 40
 def setres():
273 41
     import GameLogic
274 42
     import bge
@@ -300,44 +68,19 @@ def loadlevel():
300 68
     own = main_scene.objects['Empty']
301 69
     cont = GameLogic.getCurrentController()
302 70
     own2 = cont.owner
303
-    #readSettings()
304 71
 
305 72
     dict = bge.logic.globalDict #Get the global dictionary
306 73
     
307
-#    resx = dict["resx"]
308
-#    resy = dict["resy"]
309
-#    #dict['resx'] = resx
310
-#    #dict['resy'] = resy
311
-#    
312
-#    fullscreen = bge.render.getFullScreen()
313
-#    print("fullscreen = ", fullscreen)
314
-#    if fullscreen != True:
315
-#        if dict['fullscreen_on'] == 1:
316
-#            bge.render.setFullScreen(True)
317
-#    if fullscreen == True:
318
-#        if dict['fullscreen_on'] == 0:
319
-#            bge.render.setFullScreen(False) 
320
-#            
321
-#    bge.render.setWindowSize(resx, resy)         
322
-#    print("resolution = ", resx, resy)
323
-    #objList = scene.objects
324 74
     if own["framerate"] == 1:    
325 75
         bge.render.showFramerate(1)
326 76
     if own["profile"] ==1:    
327 77
         bge.render.showProfile(1)   
328
-    #cont = GameLogic.getCurrentController() 
329
-    #own = cont.owner
330
-    #cont = own2.controllers['loadLevel']
331 78
     act = own2.actuators["level"]
332
-    #cont.activate(own.actuators["loading"]) 
333
-    #level = own["level"]
334
-    
335 79
     dict = bge.logic.globalDict
336 80
     level = dict['level']
337
-    #dict['level'] = level
81
+    print('loading level', level)
338 82
     act.scene = level 
339 83
     cont.activate(own2.actuators["level"]) 
340
-    #cont.activate(own2.actuators["stance"])
341 84
     dict['npause'] = False 
342 85
     
343 86
 def timer():
@@ -347,14 +90,7 @@ def timer():
347 90
     dict = bge.logic.globalDict    
348 91
     
349 92
     if dict['reload_timer'] == 1:
350
-        #restart
351
-        # get current scene
352 93
         scene = bge.logic.getCurrentScene()
353
-
354
-        # restart the current scene
355
-        #scene.restart()        
356 94
             
357 95
     if dict['reload_timer'] > 0:
358 96
        dict['reload_timer'] -= 1         
359
-    #print(dict['reload_timer'])
360
-    #own['reload_timer'] = dict['reload_timer']   

+ 12
- 12
menuV3.py View File

@@ -904,7 +904,7 @@ def endpoint(funct, motion, dict, cont):
904 904
         if motion == 'inc':
905 905
             level = "pats"
906 906
             main_empty["level"] = "pats"
907
-            own["level"] = level
907
+            dict['level'] = level
908 908
             Settings.writeSettings()
909 909
             Settings.readSettings()
910 910
             #cont.activate(own.actuators['restart']) 
@@ -917,7 +917,7 @@ def endpoint(funct, motion, dict, cont):
917 917
         if motion == 'inc':
918 918
             level = "j_scene"
919 919
             main_empty["level"] = "j_scene"
920
-            own["level"] = level
920
+            dict['level'] = level
921 921
             Settings.writeSettings()
922 922
             Settings.readSettings()
923 923
             #cont.activate(own.actuators['restart']) 
@@ -930,7 +930,7 @@ def endpoint(funct, motion, dict, cont):
930 930
         if motion == 'inc':
931 931
             level = "lot"
932 932
             main_empty["level"] = "lot"
933
-            own["level"] = level
933
+            dict['level'] = level
934 934
             Settings.writeSettings()
935 935
             Settings.readSettings()
936 936
             #cont.activate(own.actuators['restart']) 
@@ -943,7 +943,7 @@ def endpoint(funct, motion, dict, cont):
943 943
         if motion == 'inc':
944 944
             level = "train"
945 945
             main_empty["level"] = "train"
946
-            own["level"] = level
946
+            dict['level'] = level
947 947
             Settings.writeSettings()
948 948
             Settings.readSettings()
949 949
             #cont.activate(own.actuators['restart']) 
@@ -956,7 +956,7 @@ def endpoint(funct, motion, dict, cont):
956 956
         if motion == 'inc':
957 957
             level = "spine"
958 958
             main_empty["level"] = "spine"
959
-            own["level"] = level
959
+            dict['level'] = level
960 960
             Settings.writeSettings()
961 961
             Settings.readSettings()
962 962
             #cont.activate(own.actuators['restart']) 
@@ -969,7 +969,7 @@ def endpoint(funct, motion, dict, cont):
969 969
         if motion == 'inc':
970 970
             level = "warehouse"
971 971
             main_empty["level"] = "warehouse"
972
-            own["level"] = level
972
+            dict['level'] = level
973 973
             Settings.writeSettings()
974 974
             Settings.readSettings()
975 975
             #cont.activate(own.actuators['restart']) 
@@ -982,7 +982,7 @@ def endpoint(funct, motion, dict, cont):
982 982
         if motion == 'inc':
983 983
             level = "shop"
984 984
             main_empty["level"] = "shop"
985
-            own["level"] = level
985
+            dict['level'] = level
986 986
             Settings.writeSettings()
987 987
             Settings.readSettings()
988 988
             #cont.activate(own.actuators['restart']) 
@@ -993,9 +993,9 @@ def endpoint(funct, motion, dict, cont):
993 993
             
994 994
     if funct == 'SC':
995 995
         if motion == 'inc':
996
-            level = "SC"
997
-            main_empty["level"] = "SC"
998
-            own["level"] = level
996
+            level = "sc"
997
+            main_empty["level"] = "sc"
998
+            dict['level'] = level
999 999
             Settings.writeSettings()
1000 1000
             Settings.readSettings()
1001 1001
             #cont.activate(own.actuators['restart']) 
@@ -1008,7 +1008,7 @@ def endpoint(funct, motion, dict, cont):
1008 1008
         if motion == 'inc':
1009 1009
             level = "user1"
1010 1010
             main_empty["level"] = "user1"
1011
-            own["level"] = level
1011
+            dict['level'] = level
1012 1012
             Settings.writeSettings()
1013 1013
             Settings.readSettings()
1014 1014
             #cont.activate(own.actuators['restart']) 
@@ -1021,7 +1021,7 @@ def endpoint(funct, motion, dict, cont):
1021 1021
         if motion == 'inc':
1022 1022
             level = "user2"
1023 1023
             main_empty["level"] = "user2"
1024
-            own["level"] = level
1024
+            dict['level'] = level
1025 1025
             Settings.writeSettings()
1026 1026
             Settings.readSettings()
1027 1027
             #cont.activate(own.actuators['restart']) 

Loading…
Cancel
Save