Browse Source

adding things

shuvit 6 years ago
parent
commit
0939a7dcc4
3 changed files with 872 additions and 0 deletions
  1. 659
    0
      menuV3.py
  2. 168
    0
      music_player.py
  3. 45
    0
      pause_menu2.py

+ 659
- 0
menuV3.py View File

@@ -0,0 +1,659 @@
1
+import bge
2
+keyboard = bge.logic.keyboard
3
+JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
4
+
5
+
6
+#exit functions
7
+#=======
8
+def endpoint(funct, motion, dict, cont):
9
+    print('endpoint', funct,motion)
10
+    scene = bge.logic.getCurrentScene()
11
+    shirt = scene.objects["Char4:Zshirtt1"]  
12
+    shoeR = scene.objects['Char4:Shoes02.R']
13
+    shoeL = scene.objects['Char4:Shoes02.L']
14
+    deck = scene.objects["deck"]
15
+    throw_deck = scene.objectsInactive["throw_deck"] 
16
+    cam = scene.objects['Camera.003']       
17
+    c_move = .025 #color move amount  
18
+    if funct == 'exit':
19
+        print("exit function", motion)
20
+        bge.logic.endGame()
21
+    if funct == 'restart':
22
+        print("restart function", motion)  
23
+        bge.logic.restartGame()      
24
+    if funct == 'shirt color r':
25
+        s_color = shirt.color
26
+        s_color_r = s_color[0]
27
+        if motion == 'inc':
28
+            if s_color_r < 1:
29
+                s_color_r += c_move
30
+                s_color_r = round(s_color_r, 2)
31
+            else:
32
+                s_color_r = 1 
33
+        if motion == 'dec':
34
+            if s_color_r > c_move:
35
+                s_color_r -= c_move
36
+                s_color_r = round(s_color_r, 2)
37
+            else:
38
+                s_color_r = 0                          
39
+        new_col = [s_color_r, s_color[1], s_color[2], s_color[3]]
40
+        shirt.color = new_col
41
+        dict['shirt_color_r'] = new_col[0]          
42
+        
43
+    if funct == 'shirt color g':
44
+        s_color = shirt.color
45
+        s_color_g = s_color[1]
46
+        if motion == 'inc':
47
+            if s_color_g < 1:
48
+                s_color_g += c_move
49
+                s_color_g = round(s_color_g, 2)
50
+            else:
51
+                s_color_rg = 1 
52
+        if motion == 'dec':
53
+            if s_color_g > c_move:
54
+                s_color_g -= c_move
55
+                s_color_g = round(s_color_g, 2)
56
+            else:
57
+                s_color_g = 0          
58
+        new_col = [s_color[0], s_color_g, s_color[2], s_color[3]]
59
+        shirt.color = new_col   
60
+        dict['shirt_color_g'] = new_col[1]         
61
+    if funct == 'shirt color b':
62
+        s_color = shirt.color
63
+        s_color_b = s_color[2]
64
+        if motion == 'inc':
65
+            if s_color_b < 1:
66
+                s_color_b += c_move
67
+                s_color_b = round(s_color_b, 2)
68
+            else:
69
+                s_color_b = 1
70
+        if motion == 'dec':
71
+            if s_color_b > c_move:
72
+                s_color_b -= c_move
73
+                s_color_b = round(s_color_b, 2)
74
+            else:
75
+                s_color_b = 0          
76
+        new_col = [s_color[0], s_color[1], s_color_b, s_color[3]]
77
+        shirt.color = new_col   
78
+        print(new_col)          
79
+        dict['shirt_color_b'] = new_col[2]
80
+        
81
+        
82
+        
83
+        
84
+    if funct == 'shoe color r':
85
+        s_color = shoeL.color
86
+        s_color_r = s_color[0]
87
+        if motion == 'inc':
88
+            if s_color_r < 1:
89
+                s_color_r += c_move
90
+                s_color_r = round(s_color_r, 2)
91
+            else:
92
+                s_color_r = 1 
93
+        if motion == 'dec':
94
+            if s_color_r > c_move:
95
+                s_color_r -= c_move
96
+                s_color_r = round(s_color_r, 2)
97
+            else:
98
+                s_color_r = 0                          
99
+        new_col = [s_color_r, s_color[1], s_color[2], s_color[3]]
100
+        shoeL.color = new_col
101
+        shoeR.color = new_col
102
+        dict['shoe_color_r'] = new_col[0]          
103
+        
104
+    if funct == 'shoe color g':
105
+        s_color = shoeL.color
106
+        s_color_g = s_color[1]
107
+        if motion == 'inc':
108
+            if s_color_g < 1:
109
+                s_color_g += c_move
110
+                s_color_g = round(s_color_g, 2)
111
+            else:
112
+                s_color_rg = 1 
113
+        if motion == 'dec':
114
+            if s_color_g > c_move:
115
+                s_color_g -= c_move
116
+                s_color_g = round(s_color_g, 2)
117
+            else:
118
+                s_color_g = 0          
119
+        new_col = [s_color[0], s_color_g, s_color[2], s_color[3]]
120
+        shoeL.color = new_col   
121
+        shoeR.color = new_col
122
+        dict['shoe_color_g'] = new_col[1]         
123
+    if funct == 'shoe color b':
124
+        s_color = shoeL.color
125
+        s_color_b = s_color[2]
126
+        if motion == 'inc':
127
+            if s_color_b < 1:
128
+                s_color_b += c_move
129
+                s_color_b = round(s_color_b, 2)
130
+            else:
131
+                s_color_b = 1
132
+        if motion == 'dec':
133
+            if s_color_b > c_move:
134
+                s_color_b -= c_move
135
+                s_color_b = round(s_color_b, 2)
136
+            else:
137
+                s_color_b = 0          
138
+        new_col = [s_color[0], s_color[1], s_color_b, s_color[3]]
139
+        shoeL.color = new_col   
140
+        shoeR.color = new_col
141
+        print(new_col)          
142
+        dict['shoe_color_b'] = new_col[2]     
143
+        
144
+        
145
+    if funct == 'deck color r':
146
+        s_color = deck.color
147
+        s_color_r = s_color[0]
148
+        if motion == 'inc':
149
+            if s_color_r < 1:
150
+                s_color_r += c_move
151
+                s_color_r = round(s_color_r, 2)
152
+            else:
153
+                s_color_r = 1 
154
+        if motion == 'dec':
155
+            if s_color_r > c_move:
156
+                s_color_r -= c_move
157
+                s_color_r = round(s_color_r, 2)
158
+            else:
159
+                s_color_r = 0                          
160
+        new_col = [s_color_r, s_color[1], s_color[2], s_color[3]]
161
+        deck.color = new_col
162
+        throw_deck.color = new_col
163
+        dict['deck_color_r'] = new_col[0]          
164
+        
165
+    if funct == 'deck color g':
166
+        s_color = deck.color
167
+        s_color_g = s_color[1]
168
+        if motion == 'inc':
169
+            if s_color_g < 1:
170
+                s_color_g += c_move
171
+                s_color_g = round(s_color_g, 2)
172
+            else:
173
+                s_color_rg = 1 
174
+        if motion == 'dec':
175
+            if s_color_g > c_move:
176
+                s_color_g -= c_move
177
+                s_color_g = round(s_color_g, 2)
178
+            else:
179
+                s_color_g = 0          
180
+        new_col = [s_color[0], s_color_g, s_color[2], s_color[3]]
181
+        deck.color = new_col   
182
+        throw_deck.color = new_col
183
+        dict['deck_color_g'] = new_col[1]         
184
+    if funct == 'deck color b':
185
+        s_color = deck.color
186
+        s_color_b = s_color[2]
187
+        if motion == 'inc':
188
+            if s_color_b < 1:
189
+                s_color_b += c_move
190
+                s_color_b = round(s_color_b, 2)
191
+            else:
192
+                s_color_b = 1
193
+        if motion == 'dec':
194
+            if s_color_b > c_move:
195
+                s_color_b -= c_move
196
+                s_color_b = round(s_color_b, 2)
197
+            else:
198
+                s_color_b = 0          
199
+        new_col = [s_color[0], s_color[1], s_color_b, s_color[3]]
200
+        deck.color = new_col   
201
+        throw_deck.color = new_col
202
+        print(new_col)          
203
+        dict['deck_color_b'] = new_col[2]  
204
+        
205
+    if funct == 'shirt logo':
206
+        logo = dict['shirt_logo']               
207
+        logo1 = shirt.meshes[0].materials[0].textures[6]
208
+        logo2 = shirt.meshes[0].materials[0].textures[7]
209
+        logo3 = shirt.meshes[0].materials[0].textures[5]        
210
+        if motion == 'inc':
211
+            if logo == 0:
212
+                logo = 1
213
+            elif logo == 1:
214
+                logo = 2   
215
+            elif logo == 2:
216
+                logo = 3
217
+            elif logo == 3:
218
+                logo = 0                                
219
+        if motion == 'dec':
220
+            if logo == 0:
221
+                logo = 3
222
+            elif logo == 1:
223
+                logo = 0   
224
+            elif logo == 2:
225
+                logo = 1 
226
+            elif logo == 3:
227
+                logo = 2                                               
228
+        if logo == 1:
229
+            logo1.diffuseIntensity = 1
230
+            logo2.diffuseIntensity = 0
231
+            logo1.diffuseFactor = 1
232
+            logo2.diffuseFactor = 0
233
+            logo3.diffuseIntensity = 0
234
+            logo3.diffuseFactor = 0
235
+        if logo == 2:
236
+            logo1.diffuseIntensity = 0
237
+            logo1.diffuseFactor = 0
238
+            logo2.diffuseIntensity = 1 
239
+            logo2.diffuseFactor = 1  
240
+            logo3.diffuseIntensity = 0
241
+            logo3.diffuseFactor = 0            
242
+        if logo == 3:
243
+            logo1.diffuseIntensity = 0
244
+            logo1.diffuseFactor = 0
245
+            logo2.diffuseIntensity = 0 
246
+            logo2.diffuseFactor = 0  
247
+            logo3.diffuseIntensity = 1
248
+            logo3.diffuseFactor = 1                                 
249
+        if logo == 0:
250
+            logo1.diffuseIntensity = 0
251
+            logo2.diffuseIntensity = 0            
252
+            logo1.diffuseFactor = 0
253
+            logo2.diffuseFactor = 0
254
+            logo3.diffuseIntensity = 0
255
+            logo3.diffuseFactor = 0            
256
+        dict['shirt_logo']  = logo
257
+        
258
+    if funct == 'brightness / contrast on':
259
+        if motion == 'inc':
260
+            cont.activate(cam.actuators["bc"])
261
+            cam['bc'] = 1
262
+            dict['bc'] = 1
263
+        else:
264
+            cont.activate(cam.actuators["bc_off"])            
265
+            cam['bc'] = 0
266
+            dict['bc'] = 0
267
+    if funct == 'brightness value':
268
+        b = cam['BC_BRIGHTNESS']
269
+        if motion == 'inc':
270
+            b += .05
271
+        else:
272
+            b -= .05    
273
+        cam['BC_BRIGHTNESS'] = round(b,2)        
274
+        dict['BC_BRIGHTNESS'] = round(b,2)        
275
+
276
+    if funct == 'contrast value':
277
+        b = cam['BC_CONTRAST']
278
+        if motion == 'inc':
279
+            b += .05
280
+        else:
281
+            b -= .05    
282
+        cam['BC_CONTRAST'] = round(b,2)        
283
+        dict['BC_CONTRAST'] = round(b,2)    
284
+        
285
+    if funct == 'hdr on':
286
+        if motion == 'inc':
287
+            cont.activate(cam.actuators["hdr"])
288
+            cam['hdr'] = 1
289
+            dict['hdr'] = 1
290
+        else:
291
+            cont.activate(cam.actuators["hdr_off"])            
292
+            cam['hdr'] = 0
293
+            dict['hdr'] = 0
294
+    if funct == 'avgL':
295
+        b = cam['avgL']
296
+        if motion == 'inc':
297
+            b += .05
298
+        else:
299
+            b -= .05    
300
+        cam['avgL'] = round(b,2)        
301
+        dict['avgL'] = round(b,2)        
302
+
303
+    if funct == 'hdr strength':
304
+        b = cam['HDRamount']
305
+        if motion == 'inc':
306
+            b += .05
307
+        else:
308
+            b -= .05    
309
+        cam['HDRamount'] = round(b,2)        
310
+        dict['HDRamount'] = round(b,2)              
311
+
312
+    if funct == 'ao on':
313
+        if motion == 'inc':
314
+            cont.activate(cam.actuators["ao"])
315
+            cam['ao'] = 1
316
+            dict['ao'] = 1
317
+        else:
318
+            cont.activate(cam.actuators["ao_off"])            
319
+            cam['ao'] = 0
320
+            dict['ao'] = 0
321
+    if funct == 'ao width':
322
+        b = cam['aowidth']
323
+        if motion == 'inc':
324
+            b += 1
325
+        else:
326
+            b -= 1    
327
+        cam['aowidth'] = round(b,2)        
328
+        dict['aowidth'] = round(b,2)        
329
+
330
+    if funct == 'ao radius':
331
+        b = cam['aoradius']
332
+        if motion == 'inc':
333
+            b += 1
334
+        else:
335
+            b -= 1    
336
+        cam['aoradius'] = round(b,2)        
337
+        dict['aoradius'] = round(b,2)  
338
+    if funct == 'ao only':
339
+        b = cam['onlyAO']
340
+        if motion == 'inc':
341
+            b = 1
342
+        else:
343
+            b = 0    
344
+        cam['onlyAO'] = b        
345
+        dict['onlyAO'] = b  
346
+        
347
+        
348
+    if funct == 'dof on':
349
+        if motion == 'inc':
350
+            cont.activate(cam.actuators["DOF"])
351
+            cam['dof_on'] = 1
352
+            dict['dof_on'] = 1
353
+        else:
354
+            cont.activate(cam.actuators["DOF_off"])            
355
+            cam['dof_on'] = 0
356
+            dict['dof_on'] = 0      
357
+            
358
+        
359
+    if funct == 'sun strength':
360
+        b = cam['sun_strength']
361
+        if motion == 'inc':
362
+            b += .05
363
+        else:
364
+            b -= .05    
365
+        cam['sun_strength'] = round(b,2)        
366
+        dict['sun_strength'] = round(b,2)                                       
367
+        if 'sun33' in scene.objects:
368
+            sun = scene.objects['sun33']
369
+            sun.energy = b
370
+    if funct == 'ambient strength':
371
+        b = cam['ambient_strength']
372
+        if motion == 'inc':
373
+            b += .05
374
+        else:
375
+            b -= .05    
376
+        cam['ambient_strength'] = round(b,2)        
377
+        dict['ambient_strength'] = round(b,2)                                       
378
+        if 'sun33' in scene.objects:
379
+            scene.world.envLightEnergy = b            
380
+    if funct == 'sun rot x':
381
+        #b = cam['sun_rot_x']
382
+        b=0
383
+        if motion == 'inc':
384
+            b += .05
385
+        else:
386
+            b -= .05        
387
+        if 'camposEmpty' in scene.objects:
388
+            
389
+            em = scene.objects['camposEmpty']
390
+            
391
+            rot = [ b, 0.0, 0]
392
+            em.applyRotation(rot,True)
393
+        cam['sun_rot_x'] = round(b,2)
394
+        dict['sun_rot_x'] = round(b,2)
395
+    if funct == 'sun rot y':
396
+        #b = cam['sun_rot_y']
397
+        b=0
398
+        if motion == 'inc':
399
+            b += .05
400
+        else:
401
+            b -= .05         
402
+        if 'camposEmpty' in scene.objects:
403
+            
404
+            em = scene.objects['camposEmpty']
405
+            
406
+            rot = [ 0, b, 0]
407
+            em.applyRotation(rot,True)
408
+        cam['sun_rot_y'] = round(b,2)
409
+        dict['sun_rot_y'] = round(b,2)        
410
+
411
+#=======
412
+#end exit functions
413
+
414
+def get_c_list(dict):
415
+    #main menu
416
+    if dict['mlevel'] == 0:
417
+        dict['current_list'] = ['exit', 'settings', 'level', 'replay', 'restart']
418
+        
419
+    #opt = dict['current_list'][dict['current_index']]
420
+    
421
+    if dict['mlevel'] == 1:
422
+        if dict['lv0_opt'] == 'settings':
423
+        #if opt == 'settings':
424
+            dict['current_list'] = ['graphics', 'player', 'level', 'camera', 'physics']
425
+        if dict['lv0_opt'] == 'replay':
426
+            dict['current_list'] = ['enter replay', 'recorder on', 'record length']  
427
+    if dict['mlevel'] == 2:
428
+        if dict['lv1_opt'] == 'graphics':
429
+        #if opt == 'settings':
430
+            dict['current_list'] = ['brightness / contrast', 'ao', 'hdr', 'dof']
431
+    if dict['mlevel'] == 2:
432
+        if dict['lv1_opt'] == 'player':
433
+        #if opt == 'settings':
434
+            dict['current_list'] = ['shirt color r', 'shirt color g', 'shirt color b', 'shoe color r', 'shoe color g', 'shoe color b','deck color r', 'deck color g', 'deck color b', 'shirt logo']            
435
+
436
+    if dict['mlevel'] == 2:
437
+        if dict['lv1_opt'] == 'level':
438
+        #if opt == 'settings':
439
+            dict['current_list'] = ['sun strength', 'ambient strength', 'sun rot x', 'sun rot y', 'shadow on']
440
+
441
+    if dict['mlevel'] == 3:
442
+        if dict['lv2_opt'] == 'ao':
443
+            dict['current_list'] = ['ao on', 'ao radius', 'ao width', 'ao only'] 
444
+        if dict['lv2_opt'] == 'brightness / contrast':
445
+            dict['current_list'] = ['brightness / contrast on', 'brightness value', 'contrast value'] 
446
+            
447
+        if dict['lv2_opt'] == 'hdr':
448
+            dict['current_list'] = ['hdr on', 'avgL', 'hdr strength']
449
+        if dict['lv2_opt'] == 'dof':
450
+            dict['current_list'] = ['dof on']    
451
+
452
+def get_inputs(dict, cont):
453
+    #opt = dict['current_list'][dict['current_index']]
454
+    #b
455
+    if keyboard.events[bge.events.LEFTARROWKEY] == JUST_ACTIVATED or (dict['bBut'] == False and dict['last_bBut'] == True):
456
+        if dict['current_index'] not in dict['menu_end_points']:
457
+            #print('lkey')
458
+            if dict['mlevel'] == 2:
459
+                dict['mlevel'] = 1
460
+                dict['current_index'] = dict['lv1_index']
461
+            elif dict['mlevel'] == 1:
462
+                dict['mlevel'] = 0
463
+                dict['current_index'] = dict['lv0_index'] 
464
+            elif dict['mlevel'] == 3:
465
+                dict['mlevel'] = 2
466
+                dict['current_index'] = dict['lv2_index']
467
+        else:
468
+            pass
469
+#            funct = dict['current_index']
470
+#            motion = 'dec'
471
+#            endpoint(funct, motion, dict)                               
472
+        #a
473
+    if (keyboard.events[bge.events.RIGHTARROWKEY] == JUST_ACTIVATED) or (dict['aBut'] == False and dict['last_aBut'] == True):
474
+        if dict['current_opt'] not in dict['menu_end_points']:
475
+            if dict['mlevel'] == 0: 
476
+                dict['lv0_opt'] = dict['current_list'][dict['current_index']]
477
+                dict['lv0_index'] = dict['current_index']
478
+                dict['mlevel'] = 1
479
+                dict['lv1_index'] = 0   
480
+                dict['current_index'] = 0 
481
+            elif dict['mlevel'] == 1: 
482
+                dict['lv1_opt'] = dict['current_list'][dict['current_index']]
483
+                dict['lv1_index'] = dict['current_index']
484
+                dict['mlevel'] = 2
485
+                dict['lv2_index'] = 0   
486
+                dict['current_index'] = 0 
487
+            elif dict['mlevel'] == 2: 
488
+                dict['lv2_opt'] = dict['current_list'][dict['current_index']]
489
+                dict['lv2_index'] = dict['current_index']
490
+                dict['mlevel'] = 3
491
+                dict['lv3_index'] = 0   
492
+                dict['current_index'] = 0  
493
+            elif dict['mlevel'] == 3: 
494
+                dict['lv3_opt'] = dict['current_list'][dict['current_index']]
495
+                dict['lv3_index'] = dict['current_index']
496
+                #dict['mlevel'] = 3
497
+                #dict['lv3_index'] = 0   
498
+                dict['current_index'] = 0                                      
499
+        else:
500
+            pass
501
+            funct = dict['current_opt']
502
+            motion = 'inc'
503
+            endpoint(funct, motion, dict, cont)                          
504
+    #down     
505
+    if keyboard.events[bge.events.DOWNARROWKEY] == JUST_ACTIVATED or (dict['ddPad'] == False and dict['last_ddPad'] == True):
506
+        if dict['current_index'] < (len(dict['current_list']) - 1):
507
+            dict['current_index'] += 1  
508
+            if dict['mlevel'] == 0:
509
+                dict['lv0_index'] = dict['current_index']
510
+            if dict['mlevel'] == 1:
511
+                dict['lv1_index'] = dict['current_index']                
512
+            if dict['mlevel'] == 2:
513
+                dict['lv2_index'] = dict['current_index']  
514
+            if dict['mlevel'] == 3:
515
+                dict['lv3_index'] = dict['current_index']                                                
516
+    #up    
517
+    if keyboard.events[bge.events.UPARROWKEY] == JUST_ACTIVATED or (dict['udPad'] == False and dict['last_udPad'] == True):
518
+        if dict['current_index'] > 0:
519
+            dict['current_index'] -= 1  
520
+            if dict['mlevel'] == 0:
521
+                dict['lv0_index'] = dict['current_index']
522
+            if dict['mlevel'] == 1:
523
+                dict['lv1_index'] = dict['current_index']                
524
+            if dict['mlevel'] == 2:
525
+                dict['lv2_index'] = dict['current_index'] 
526
+            if dict['mlevel'] == 3:
527
+                dict['lv3_index'] = dict['current_index']        
528
+                
529
+    #left
530
+    if dict['ldPad'] == False and dict['last_ldPad'] == True:
531
+        if dict['current_opt'] in dict['menu_end_points']:
532
+            funct = dict['current_opt']
533
+            motion = 'dec'
534
+            endpoint(funct, motion, dict, cont)         
535
+    
536
+    #right
537
+    if dict['rdPad'] == False and dict['last_rdPad'] == True:
538
+        if dict['current_opt'] in dict['menu_end_points']:
539
+            funct = dict['current_opt']
540
+            motion = 'inc'
541
+            endpoint(funct, motion, dict, cont)              
542
+                                       
543
+
544
+def init(own, dict):
545
+    print('initing')
546
+    own['inited'] = True
547
+    dict['lv0_opt'] = 0
548
+    dict['lv0_index'] = 0
549
+    dict['lv1_opt'] = 0
550
+    dict['lv1_index'] = 0 
551
+    dict['lv2_opt'] = 0
552
+    dict['lv2_index'] = 0
553
+    dict['lv3_opt'] = 0
554
+    dict['lv3_index'] = 0        
555
+    dict['current_list'] = ['']
556
+    dict['current_index'] = 0
557
+    dict['mlevel'] = 0
558
+    dict['current_opt'] = ''
559
+    dict['pause_menu_text'] = ''
560
+    dict['menu_end_points'] = ['exit', 'restart', 'shirt color r', 'shirt color g', 'shirt color b', 'shoe color r', 'shoe color g', 'shoe color b','deck color r', 'deck color g', 'deck color b', 'shirt logo', 'brightness / contrast on', 'brightness value', 'contrast value', 'hdr on', 'avgL', 'hdr strength', 'ao on', 'ao radius', 'ao width', 'ao only', 'dof on', 'sun strength', 'sun rot x', 'sun rot y', 'shadow on', 'ambient strength']
561
+    
562
+def output(dict):
563
+    try:
564
+        opt = dict['current_list'][dict['current_index']]
565
+    except:
566
+        print('broken!!', dict['current_list'], dict['current_index'])    
567
+    dict['current_opt'] = opt
568
+    #print(dict['lv1_index'], 'level: ', dict['mlevel'], dict['lv0_opt'], dict['current_index'], dict['current_list'], dict['current_opt'])    
569
+    outp = 'menu > '
570
+    if dict['mlevel'] == 0:
571
+        outp = outp + dict['current_opt']
572
+    if dict['mlevel'] == 1:
573
+        outp = outp + dict['lv0_opt'] +' > ' + dict['current_opt'] 
574
+    if dict['mlevel'] == 2:
575
+        outp = outp + dict['lv0_opt'] +' > ' + dict['lv1_opt'] + ' > ' + dict['current_opt']  
576
+    if dict['mlevel'] == 3:
577
+        outp = outp + dict['lv0_opt'] +' > ' + dict['lv1_opt'] + ' > '  + dict['lv2_opt'] + ' > ' + dict['current_opt']                       
578
+    
579
+    #print(outp) 
580
+    #print(dict['current_opt'])
581
+    if dict['current_opt'] in dict['menu_end_points']:
582
+        #print('adding end point value')
583
+        if dict['current_opt'] == 'shirt color r':
584
+            outp = outp + ': ' + str(dict['shirt_color_r'])
585
+            print(outp + ': ' + str(dict['shirt_color_r']))
586
+        if dict['current_opt'] == 'shirt color g':
587
+            outp = outp + ': ' + str(dict['shirt_color_g'])
588
+        if dict['current_opt'] == 'shirt color b':
589
+            outp = outp + ': ' + str(dict['shirt_color_b']) 
590
+            
591
+        if dict['current_opt'] == 'shoe color r':
592
+            outp = outp + ': ' + str(dict['shoe_color_r'])
593
+            print(outp + ': ' + str(dict['shoe_color_r']))
594
+        if dict['current_opt'] == 'shoe color g':
595
+            outp = outp + ': ' + str(dict['shoe_color_g'])
596
+        if dict['current_opt'] == 'shoe color b':
597
+            outp = outp + ': ' + str(dict['shoe_color_b'])      
598
+        if dict['current_opt'] == 'deck color r':
599
+            outp = outp + ': ' + str(dict['deck_color_r'])
600
+            print(outp + ': ' + str(dict['deck_color_r']))
601
+        if dict['current_opt'] == 'deck color g':
602
+            outp = outp + ': ' + str(dict['deck_color_g'])
603
+        if dict['current_opt'] == 'deck color b':
604
+            outp = outp + ': ' + str(dict['deck_color_b'])  
605
+        if dict['current_opt'] == 'shirt logo':
606
+            outp = outp + ': ' + str(dict['shirt_logo'])                                                         
607
+        if dict['current_opt'] ==  'brightness / contrast on':
608
+            outp = outp + ': ' + str(dict['bc'])             
609
+            
610
+        if dict['current_opt'] ==  'brightness value':
611
+            outp = outp + ': ' + str(dict['BC_BRIGHTNESS']) 
612
+        if dict['current_opt'] ==  'contrast value':
613
+            outp = outp + ': ' + str(dict['BC_CONTRAST'])   
614
+            
615
+        if dict['current_opt'] ==  'hdr on':
616
+            outp = outp + ': ' + str(dict['hdr'])             
617
+        if dict['current_opt'] ==  'avgL':
618
+            outp = outp + ': ' + str(dict['avgL']) 
619
+        if dict['current_opt'] ==  'hdr strength':
620
+            outp = outp + ': ' + str(dict['HDRamount'])  
621
+            
622
+        if dict['current_opt'] ==  'ao on':
623
+            outp = outp + ': ' + str(dict['ao'])             
624
+        if dict['current_opt'] ==  'ao width':
625
+            outp = outp + ': ' + str(dict['aowidth']) 
626
+            
627
+            
628
+        if dict['current_opt'] ==  'ao radius':
629
+            outp = outp + ': ' + str(dict['aoradius'])
630
+            
631
+            
632
+        if dict['current_opt'] ==  'ao only':
633
+            outp = outp + ': ' + str(dict['onlyAO'])   
634
+            
635
+            
636
+        if dict['current_opt'] ==  'dof on':
637
+            outp = outp + ': ' + str(dict['dof_on'])  
638
+        if dict['current_opt'] ==  'sun strength':
639
+            outp = outp + ': ' + str(dict['sun_strength'])                                   
640
+        if dict['current_opt'] ==  'sun rot x':
641
+            outp = outp + ': ' + str(dict['sun_rot_x'])                                      
642
+        if dict['current_opt'] ==  'sun rot y':
643
+            outp = outp + ': ' + str(dict['sun_rot_y'])                
644
+        if dict['current_opt'] ==  'shadow on':
645
+            outp = outp + ': ' + str(dict['shadow_on'])  
646
+        if dict['current_opt'] ==  'ambient strength':
647
+            outp = outp + ': ' + str(dict['ambient_strength'])                          
648
+            
649
+    dict['pause_menu_text'] = outp
650
+def main(cont):
651
+    
652
+    own = cont.owner
653
+    dict = bge.logic.globalDict
654
+    if 'inited' not in own:
655
+        init(own, dict)
656
+    get_c_list(dict) 
657
+    get_inputs(dict, cont) 
658
+    get_c_list(dict)
659
+    output(dict)  

+ 168
- 0
music_player.py View File

@@ -0,0 +1,168 @@
1
+#shuvit.org
2
+#mp3 player
3
+
4
+import bge
5
+import os
6
+import aud
7
+import random
8
+from tinytag import TinyTag
9
+
10
+directory = bge.logic.expandPath('//Music')
11
+file_list = os.listdir(directory) 
12
+selected = random.choice(file_list)
13
+full_path = os.path.join(directory, selected)
14
+
15
+dict = bge.logic.globalDict
16
+dict['mu_current_song'] = ''
17
+dict['mu_stopped'] = 0
18
+dict['mu_playlist'] = ''
19
+dict['mu_lib'] = ''
20
+dict['change_track'] = 0
21
+dict['mu_track_time'] = 0
22
+#dict['mu_last_track'] = ''
23
+#dict['mu_artist'] = ''
24
+#dict['mu_title'] = ''
25
+
26
+keyboard = bge.logic.keyboard
27
+JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
28
+
29
+def stop_music(sound):
30
+
31
+    print("Stop music")    
32
+    sound.pauseSound()
33
+    dict['mu_stopped'] = 1
34
+    
35
+def play_music():
36
+
37
+    print("Play music") 
38
+    full_path = os.path.join(directory, dict['mu_current_song'])
39
+    sound = bge.logic.getCurrentController().actuators['music_player']
40
+    sound.sound = aud.Factory(full_path)
41
+    sound.stopSound()
42
+    sound.startSound()
43
+    dict['mu_stopped'] = 0
44
+    dict['change_track'] = 0
45
+    dict['mu_track_time'] = 0   
46
+
47
+    try:
48
+        tag = TinyTag.get(full_path)
49
+        print('Playing: ', 'Artist: %s' % tag.artist, 'Track: %s' % tag.title)
50
+        dict['mu_artist'] = tag.artist
51
+        dict['mu_title'] = tag.title
52
+        info = ('Music > ', 'Artist: %s' % tag.artist, 'Track: %s' % tag.title)
53
+        print(info)
54
+        dict['music_info'] = info
55
+    except:
56
+        print("Track has no tag.") 
57
+    print(dict['mu_title'], 'mu_title')
58
+def next_track():
59
+
60
+    print("next track")
61
+    dict = bge.logic.globalDict
62
+    plist = dict['mu_playlist']
63
+    cur_song = dict['mu_current_song']
64
+    pl_length = len(dict['mu_playlist'])    
65
+
66
+    if pl_length > 1:
67
+        try:
68
+            plist.remove(cur_song)
69
+        except:
70
+            pass    
71
+
72
+    if pl_length == 1:    
73
+        print('rebuilding playlist')
74
+        file_list = os.listdir(directory) 
75
+        plist = file_list
76
+
77
+    selected = random.choice(plist)
78
+    dict['mu_last_track'] = dict['mu_current_song']
79
+    dict['mu_current_song'] = selected
80
+    dict['mu_playlist'] = plist
81
+    dict['change_track'] = 0
82
+    dict['mu_track_time'] = 0
83
+    play_music()
84
+    
85
+    
86
+
87
+    #dict['music_info'] = info    
88
+
89
+def previous_track():
90
+
91
+    print("previous track") 
92
+    dict['mu_current_song'] = dict['mu_last_track']
93
+    play_music()
94
+
95
+def initer(cont):
96
+    #cont = bge.logic.getCurrentController()
97
+    own = cont.owner
98
+    if 'mp_inited' not in own:
99
+        own['mp_inited'] = True
100
+        print('Initializing music player')
101
+        dict = bge.logic.globalDict
102
+        file_list = os.listdir(directory) 
103
+        dict['mu_lib'] = file_list
104
+        dict['mu_playlist'] = file_list
105
+        dict['change_track'] = 0
106
+        selected = random.choice(file_list)
107
+        dict['mu_current_song'] = selected
108
+        print('Current Track: ', dict['mu_current_song'])
109
+        full_path = os.path.join(directory, selected)
110
+
111
+        try:
112
+            tag = TinyTag.get(full_path)
113
+            print('Artist: %s' % tag.artist, 'Track: %s' % tag.title)
114
+            dict['mu_artist'] = tag.artist
115
+            dict['mu_title'] = tag.title            
116
+        except:
117
+            print("Track has no tag.")     
118
+
119
+def check_status():
120
+
121
+    sound = bge.logic.getCurrentController().actuators['music_player']
122
+    cur_song = dict['mu_current_song']
123
+    full_path = os.path.join(directory, dict['mu_current_song'])
124
+    sound = bge.logic.getCurrentController().actuators['music_player']
125
+    sound.sound = aud.Factory(full_path)  
126
+
127
+    if sound.time < dict['mu_track_time'] and dict['mu_stopped'] == 0 and dict['change_track'] == 0:
128
+        print('song over, getting new one')
129
+        dict['change_track'] = 1
130
+        dict['mu_track_time'] = 0
131
+    else:
132
+        dict['change_track'] = 0
133
+    dict['mu_track_time'] = sound.time    
134
+
135
+def main(cont):
136
+
137
+    dict = bge.logic.globalDict        
138
+    cur_song = dict['mu_current_song']    
139
+    full_path = os.path.join(directory, dict['mu_current_song'])
140
+    sound = bge.logic.getCurrentController().actuators['music_player']
141
+    sound.sound = aud.Factory(full_path)
142
+    sound.mode = 1
143
+    initer(cont)
144
+    if dict['mu_stopped'] == 0:        
145
+        sound.startSound()
146
+    if dict['change_track'] == 1:
147
+        dict['change_track'] = 0
148
+        next_track() 
149
+
150
+    plist = dict['mu_playlist']  
151
+    pl_length = len(dict['mu_playlist'])    
152
+    if pl_length == 0:
153
+        dict['mu_playlist'] = dict['mu_lib']  
154
+        
155
+    #allow controlls while paused or in replay    
156
+    if dict['npause']  == True or dict['playback'] == True:
157
+        if dict['yBut'] == False and dict['last_yBut'] == True:
158
+            if dict['mu_stopped'] == 1:
159
+                play_music()    
160
+            else:
161
+                stop_music(sound)  
162
+        if dict['lBump'] == False and dict['last_lBump'] == True:
163
+            previous_track()
164
+        if dict['rBump'] == False and dict['last_rBump'] == True:
165
+            next_track()                
166
+            
167
+   
168
+#main()        

+ 45
- 0
pause_menu2.py View File

@@ -0,0 +1,45 @@
1
+import bge
2
+
3
+
4
+def check_idle():
5
+    dict = bge.logic.globalDict
6
+    dict['menu_idle_timer'] +=1
7
+    idle = 0
8
+    if dict['aBut'] or dict['bBut'] or dict['xBut'] or dict['yBut'] or dict['ddPad'] or dict['udPad'] or dict['ldPad'] or dict['rdPad'] or (dict['lUD'] > .02 or dict['lUD'] < -.02) or (dict['lLR'] > .02 or dict['lLR'] < -.02) or (dict['rUD'] > .02 or dict['rUD'] < -.02) or (dict['rLR'] > .02 or dict['rLR'] < -.02):
9
+        dict['menu_idle_timer'] = 0
10
+    #print('idtime', dict['menu_idle_timer']) 
11
+    if dict['menu_idle_timer'] > 500:
12
+        idle =1
13
+    return idle                        
14
+
15
+def update_text(cont):
16
+    own = cont.owner
17
+    scene = bge.logic.getCurrentScene()
18
+    dict = bge.logic.globalDict
19
+    if dict['pause_menu_text'] == '':
20
+        scene.objects['menu_text'].text = 'menu > fuck' 
21
+    else:
22
+        if 'menu_text' in scene.objects: 
23
+            scene.objects['menu_text'].text = dict['pause_menu_text']   
24
+        if 'menu_text.001' in scene.objects: 
25
+            scene.objects['menu_text.001'].text = dict['pause_menu_text']               
26
+
27
+#    scene = bge.logic.getCurrentScene()
28
+    for object in scene.objects:
29
+        if isinstance(object, bge.types.KX_FontObject):
30
+            object.resolution = 16     
31
+                    
32
+    info = ('Music > ' + dict['mu_artist'] + ' - ' + dict['mu_title'])
33
+    #print(info)
34
+    try:
35
+        scene.objects['music_info_txt'].text = info                       
36
+    except:
37
+        pass    
38
+                    
39
+                    
40
+def main(cont):
41
+    update_text(cont)  
42
+    check_idle()      
43
+
44
+#active selection list        
45
+#selected_item_index

Loading…
Cancel
Save