/
GuitarScene.py
4835 lines (4294 loc) · 261 KB
/
GuitarScene.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#####################################################################
# -*- coding: utf-8 -*- #
# #
# Frets on Fire X (FoFiX) #
# Copyright (C) 2006 Sami Kyöstilä #
# 2008 Alarian #
# 2008 myfingershurt #
# 2008 Capo #
# 2008 Spikehead777 #
# 2008 Glorandwarf #
# 2008 ShiekOdaSandz #
# 2008 QQStarS #
# 2008 .liquid. #
# 2008 Blazingamer #
# 2008 evilynux <evilynux@gmail.com> #
# 2009-2019 FoFiX Team #
# #
# This program is free software; you can redistribute it and/or #
# modify it under the terms of the GNU General Public License #
# as published by the Free Software Foundation; either version 2 #
# of the License, or (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software #
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, #
# MA 02110-1301, USA. #
#####################################################################
from __future__ import with_statement
from math import degrees, atan
import logging
import os
import random
import OpenGL.GL as gl
from fofix.core import Player
from fofix.core import Settings
from fofix.core.Image import drawImage
from fofix.core.Language import _
from fofix.core.Player import STAR, KILL, CANCEL, KEY1A
from fofix.core.Scene import Scene
from fofix.core.Shader import shaders
from fofix.core.constants import *
from fofix.game import Dialogs
from fofix.game import song
from fofix.game.Menu import Menu
from fofix.game.Scorekeeper import ScoreCard
from fofix.game.guitarscene import Stage
from fofix.game.guitarscene.instruments import *
from fofix.game.song import Note, TextEvent, PictureEvent, loadSong, Bars, VocalPhrase
log = logging.getLogger(__name__)
# The plan with this is to move gamemodes to being subclasses of this
class BandPlayBaseScene(Scene):
def __init__(self, engine, libraryName, songName):
superClass = super(BandPlayBaseScene, self)
superClass.__init__(engine)
log.debug("BandPlayBaseScene init...")
self.engine.world.sceneName = "GuitarScene"
self.ready = False
self.countdownSeconds = 3 # don't change this initialization value unless you alter the other related variables to match
self.countdown = 100 # arbitrary value to prevent song from starting right away
self.countdownOK = False
# new loading place for "loading" screen for song preparation:
# new loading phrases
self.sinfo = song.loadSongInfo(self.engine, songName, library=libraryName)
self.phrase = self.sinfo.loadingPhrase
if self.phrase == "":
self.phrase = random.choice(self.engine.theme.loadingPhrase)
self.splash = Dialogs.showSongLoadingSplashScreen(self.engine, songName, libraryName, self.phrase + " \n " + _("Initializing..."))
Dialogs.changeLoadingSplashScreenText(self.engine, self.splash, self.phrase + " \n " + _("Initializing..."))
self.lostFocusPause = self.engine.config.get("game", "lost_focus_pause")
self.instruments = [] # this combines Guitars, Drums, and Vocalists
self.keysList = []
self.soloKeysList = []
self.soloShifts = []
self.playingVocals = False
self.numberOfGuitars = len(self.players)
self.numOfPlayers = len(self.players)
self.numOfSingers = 0
self.firstGuitar = None
self.neckrender = []
self.visibility = 1.0
self.libraryName = libraryName
self.songName = songName
self.done = False
self.pause = False
self.lastMultTime = [None for i in self.players]
self.cheatCodes = [
([102, 97, 115, 116, 102, 111, 114, 119, 97, 114, 100], self.goToResults)
]
self.enteredCode = []
self.song = None
self.lastPickPos = [None for i in self.players]
self.keyBurstTimeout = [None for i in self.players]
self.keyBurstPeriod = 30
self.camera.target = (0.0, 1.0, 8.0)
self.camera.origin = (0.0, 2.0, -3.4)
self.targetX = self.engine.theme.povTarget[0]
self.targetY = self.engine.theme.povTarget[1]
self.targetZ = self.engine.theme.povTarget[2]
self.originX = self.engine.theme.povOrigin[0]
self.originY = self.engine.theme.povOrigin[1]
self.originZ = self.engine.theme.povOrigin[2]
self.customPOV = False
self.ending = False
self.countdownPosX = self.engine.theme.countdownPosX
self.countdownPosY = self.engine.theme.countdownPosY
self.fpsRenderPos = self.engine.theme.fpsRenderPos
self.povTheme = self.engine.theme.povPreset
self.neckintroAnimationType = self.engine.config.get("fretboard", "neck_intro_animation")
self.neckintroThemeType = self.engine.theme.povIntroAnimation
if None not in [self.targetX, self.targetY, self.targetZ, self.originX, self.originY, self.originZ]:
self.customPOV = True
log.debug("All theme POV set. Using custom camera POV.")
# sets the distances the neck has to move in the animation
if self.neckintroAnimationType == 0: # Original
self.boardY = 2
elif self.neckintroAnimationType == 1: # Guitar Hero
self.boardY = 10
elif self.neckintroAnimationType == 2: # Rock Band
self.boardZ = 5
elif self.neckintroAnimationType == 4: # By Theme
if self.neckintroThemeType == "fofix": # Original
self.boardY = 2
elif self.neckintroThemeType == "guitar hero": # Guitar Hero
self.boardY = 10
elif self.neckintroThemeType == "rockband": # Rock Band
self.boardZ = 5
self.counting = self.engine.config.get("video", "counting")
self.phrases = self.engine.config.get("coffee", "game_phrases")
# Song related init
#TODO - single, global BPM here instead of in instrument objects:
#self.tempoBpm = song.DEFAULT_BPM
#self.actualBpm = 0.0
#self.targetPeriod = 60000.0 / self.targetBpm
self.audioDelay = self.engine.config.get("audio", "delay")
self.songTime = -self.audioDelay
self.disableVBPM = self.engine.config.get("game", "disable_vbpm")
self.currentBpm = song.DEFAULT_BPM
self.currentPeriod = 60000.0 / self.currentBpm
self.targetBpm = self.currentBpm
self.lastBpmChange = -1.0
self.baseBeat = 0.0
def loadmages(self, w, h):
# lyric sheet!
if not self.playingVocals:
if self.song.hasMidiLyrics and self.midiLyricsEnabled > 0:
lyricsheet_path = os.path.join("themes", self.themeName, "lyricsheet.png")
lyricsheet2_path = os.path.join("themes", self.themeName, "lyricsheet2.png")
if self.midiLyricMode == 0:
if not self.engine.loadImgDrawing(self, "lyricSheet", lyricsheet_path):
self.lyricSheet = None
else:
if not self.engine.loadImgDrawing(self, "lyricSheet", lyricsheet2_path):
if not self.engine.loadImgDrawing(self, "lyricSheet", lyricsheet_path):
self.lyricSheet = None
else:
self.lyricSheet = None
else:
self.lyricSheet = None
# brescorebackground.png
self.breScoreBackground = None
brescorebackground_path = os.path.join("themes", self.themeName, "brescorebackground.png")
if self.engine.loadImgDrawing(self, "breScoreBackground", brescorebackground_path):
self.breScoreBackgroundWFactor = (w * self.engine.theme.breScoreBackgroundScale) / self.breScoreBackground.width1()
else:
log.debug("BRE score background image loading problem!")
self.breScoreBackground = None
self.breScoreBackgroundWFactor = None
# brescoreframe.png
self.breScoreFrame = None
brescoreframe_path = os.path.join("themes", self.themeName, "brescoreframe.png")
soloframe_path = os.path.join("themes", self.themeName, "soloframe.png")
if self.engine.loadImgDrawing(self, "breScoreFrame", brescoreframe_path):
self.breScoreFrameWFactor = (w * self.engine.theme.breScoreFrameScale) / self.breScoreFrame.width1()
else:
# fallback on using soloframe.png if no brescoreframe.png is found
if self.engine.loadImgDrawing(self, "breScoreFrame", soloframe_path):
self.breScoreFrameWFactor = (w * self.engine.theme.breScoreFrameScale) / self.breScoreFrame.width1()
else:
self.breScoreFrame = None
self.breScoreFrameWFactor = None
if self.soloFrameMode != 0 and self.engine.loadImgDrawing(self, "soloFrame", soloframe_path):
self.soloFrameWFactor = (w * self.engine.theme.soloFrameScale) / self.soloFrame.width1()
else:
self.soloFrame = None
self.soloFrameWFactor = None
self.partImage = True
self.part = [None for i in self.players]
self.partLoad = None
if self.counting or self.coOpType:
for i in range(self.numOfPlayers):
if not self.partImage:
break
if self.instruments[i].isDrum:
drum_path = os.path.join("themes", self.themeName, "drum.png")
if not self.engine.loadImgDrawing(self, "partLoad", drum_path):
if not self.engine.loadImgDrawing(self, "partLoad", os.path.join("drum.png")):
self.counting = False
self.partImage = False
elif self.instruments[i].isBassGuitar:
bass_path = os.path.join("themes", self.themeName, "bass.png")
if not self.engine.loadImgDrawing(self, "partLoad", bass_path):
if not self.engine.loadImgDrawing(self, "partLoad", os.path.join("bass.png")):
self.counting = False
self.partImage = False
elif self.instruments[i].isVocal:
mic_path = os.path.join("themes", self.themeName, "mic.png")
if not self.engine.loadImgDrawing(self, "partLoad", mic_path):
if not self.engine.loadImgDrawing(self, "partLoad", os.path.join("mic.png")):
self.counting = False
self.partImage = False
else:
guitar_path = os.path.join("themes", self.themeName, "guitar.png")
if not self.engine.loadImgDrawing(self, "partLoad", guitar_path):
if not self.engine.loadImgDrawing(self, "partLoad", os.path.join("guitar.png")):
self.counting = False
self.partImage = False
if self.partLoad:
self.part[i] = self.partLoad
self.partLoad = None
# Pause Screen
self.engine.loadImgDrawing(self, "pauseScreen", os.path.join("themes", self.themeName, "pause.png"))
if not self.engine.loadImgDrawing(self, "failScreen", os.path.join("themes", self.themeName, "fail.png")):
self.engine.loadImgDrawing(self, "failScreen", os.path.join("themes", self.themeName, "pause.png"))
# failMessage
self.engine.loadImgDrawing(self, "failMsg", os.path.join("themes", self.themeName, "youfailed.png"))
# youRockMessage
self.engine.loadImgDrawing(self, "rockMsg", os.path.join("themes", self.themeName, "yourock.png"))
def loadSettings(self):
self.stage.updateDelays()
self.activeVolume = self.engine.config.get("audio", "guitarvol")
self.screwUpVolume = self.engine.config.get("audio", "screwupvol")
self.killVolume = self.engine.config.get("audio", "kill_volume")
self.crowdVolume = self.engine.config.get("audio", "crowd_volume")
self.crowdsEnabled = self.engine.config.get("audio", "enable_crowd_tracks")
self.engine.data.crowdVolume = self.crowdVolume
# now update volume of all screwup sounds and other SFX
self.engine.data.SetAllScrewUpSoundFxObjectVolumes(self.screwUpVolume)
# Re-apply Jurgen Settings
self.autoPlay = False
self.jurg = [False for i in self.players]
self.aiSkill = [0 for i in self.players]
for i, player in enumerate(self.players):
jurgen = self.engine.config.get("game", "jurg_p%d" % i)
if jurgen:
self.jurg[i] = True
self.autoPlay = True
self.aiSkill[i] = self.engine.config.get("game", "jurg_skill_p%d" % i)
if player.part.id == song.VOCAL_PART:
self.instruments[i].jurgenEnabled = jurgen
self.instruments[i].jurgenSkill = self.aiSkill[i]
# no Jurgen in Career mode
if self.careerMode:
self.autoPlay = False
self.allTaps = 0
self.autoKickBass = [0 for i in self.players]
self.hopoAfterChord = self.engine.config.get("game", "hopo_after_chord")
self.pov = self.engine.config.get("fretboard", "point_of_view")
# CoffeeMod
self.activeGameControls = self.engine.input.activeGameControls
for i, player in enumerate(self.players):
if player.part.id == song.VOCAL_PART:
continue
self.instruments[i].leftyMode = False
self.instruments[i].twoChordMax = False
self.instruments[i].drumFlip = False
if player.lefty > 0:
self.instruments[i].leftyMode = True
if player.drumflip > 0:
self.instruments[i].drumFlip = True
if player.twoChordMax > 0:
self.instruments[i].twoChordMax = True
self.keysList = []
for i, player in enumerate(self.players):
if self.instruments[i].isDrum:
self.keysList.append(player.drums)
elif self.instruments[i].isVocal:
self.keysList.append([])
continue
else:
self.keysList.append(player.keys)
if not self.instruments[i].twoChordMax:
if self.controls.twoChord[self.activeGameControls[i]] > 0:
self.instruments[i].twoChordMax = True
if self.song and self.song.readyToGo:
self.getHandicap() # to be sure scoring objects are created
# ensure that after a pause or restart, the a/v sync delay is refreshed
self.song.refreshAudioDelay()
# ensuring the miss volume gets refreshed
self.song.refreshVolumes()
self.song.setAllTrackVolumes(1)
if self.crowdsCheering:
self.song.setCrowdVolume(1)
else:
self.song.setCrowdVolume(0.0)
def quit(self):
if self.song:
self.song.stop()
self.resetVariablesToDefaults()
self.done = True
self.engine.view.setViewport(1, 0)
self.engine.view.popLayer(self.menu)
self.engine.view.popLayer(self.failMenu)
self.freeResources()
self.engine.world.finishGame()
def restartSong(self, firstTime=False):
self.resetVariablesToDefaults()
self.engine.data.startSound.play()
self.engine.view.popLayer(self.menu)
if not self.song:
return
# the countdown is now the number of beats to run before the song begins
for instrument in self.instruments:
if instrument.isVocal:
instrument.stopMic()
else:
instrument.endPick(0) # position of the song
self.song.stop()
self.initBeatAndSpClaps()
if self.stage.mode == 3:
self.stage.restartVideo()
def restartAfterFail(self):
self.resetVariablesToDefaults()
self.engine.data.startSound.play()
self.engine.view.popLayer(self.failMenu)
if not self.song:
return
for i, instrument in enumerate(self.instruments):
if instrument.isVocal:
instrument.stopMic()
else:
instrument.endPick(0) # position of the song
self.song.stop()
if self.stage.mode == 3:
self.stage.restartVideo()
def pauseGame(self):
if self.song and self.song.readyToGo:
self.pausePos = self.songTime
self.song.pause()
self.pause = True
for instrument in self.instruments:
instrument.paused = True
if instrument.isVocal:
instrument.stopMic()
else:
instrument.neck.paused = True
def failGame(self):
self.engine.view.pushLayer(self.failMenu)
# don't let the pause menu overlap the fail menu
if self.song and self.song.readyToGo and self.pause:
self.engine.view.popLayer(self.menu)
self.pause = False
for instrument in self.instruments:
instrument.paused = False
if instrument.isVocal:
instrument.stopMic()
else:
instrument.neck.paused = False
self.failEnd = True
def resumeGame(self):
self.loadSettings()
self.setCamera()
if self.resumeCountdownEnabled and not self.failed and not self.countdown:
self.resumeCountdownSeconds = 3
self.resumeCountdown = float(self.resumeCountdownSeconds) * self.songBPS
self.pause = False
else:
if self.song and self.song.readyToGo:
if not self.failed: # don't resume the song if you have already failed
self.song.unpause()
self.pause = False
for instrument in self.instruments:
instrument.paused = False
if instrument.isVocal:
instrument.startMic()
else:
instrument.neck.paused = False
def songLoaded(self, song):
for i, player in enumerate(self.players):
if self.instruments[i].isVocal:
song.difficulty[i] = song.difficulties[song.EXP_DIF] # for track-finding purposes
continue
song.difficulty[i] = player.difficulty
self.song.readyToGo = False
def endSong(self):
self.engine.view.popLayer(self.menu)
validScoreFound = False
for scoreCard in self.scoring: # what if 2p (human) battles 1p (Jurgen / CPU)? He needs a valid score too!
if scoreCard.score > 0:
validScoreFound = True
break
if self.coOpType:
if self.coOpScoreCard.score > 0:
validScoreFound = True
if validScoreFound:
self.goToResults()
else:
self.changeSong()
def changeSong(self):
prevMode = self.engine.world.gameMode
if self.song:
self.song.stop()
self.song = None
self.resetVariablesToDefaults()
self.engine.view.setViewport(1, 0)
self.engine.view.popLayer(self.menu)
self.engine.view.popLayer(self.failMenu)
self.freeResources()
self.engine.world.gameMode = prevMode
self.engine.world.createScene("SongChoosingScene")
def changeAfterFail(self):
if self.song:
self.song.stop()
self.song = None
self.resetVariablesToDefaults()
self.engine.view.setViewport(1, 0)
self.engine.view.popLayer(self.failMenu)
self.freeResources()
self.engine.world.createScene("SongChoosingScene")
def resumeSong(self):
self.engine.view.popLayer(self.menu)
self.resumeGame()
def lostFocus(self): # catch to pause on lostFocus
if self.song and self.song.readyToGo:
if not self.failed and not self.pause and self.lostFocusPause:
self.engine.view.pushLayer(self.menu)
self.pauseGame()
def setCamera(self):
#x=0 middle
#x=1 rotate left
#x=-1 rotate right
#y=3 middle
#y=4 rotate back
#y=2 rotate front
#z=-3
if self.customPOV:
self.camera.target = (self.targetX, self.targetY, self.targetZ)
self.camera.origin = (self.originX, self.originY, self.originZ)
else:
if self.pov == 1: # GH3
self.camera.target = (0.0, 0.6, 4.4)
self.camera.origin = (0.0, 3.5, -3.8)
elif self.pov == 2: # RB
self.camera.target = (0.0, 0.0, 3.7)
self.camera.origin = (0.0, 2.9, -2.9)
elif self.pov == 3: # GH2
self.camera.target = (0.0, 1.6, 2.0)
self.camera.origin = (0.0, 2.6, -3.6)
elif self.pov == 4: # Rock Rev
self.camera.target = (0.0, -6.0, 2.6666666666)
self.camera.origin = (0.0, 6.0, 2.6666666665)
elif self.pov == 5: # Theme
if self.povTheme == "gh2":
self.camera.target = (0.0, 1.6, 2.0)
self.camera.origin = (0.0, 2.6, -3.6)
elif self.povTheme == "gh3":
self.camera.target = (0.0, 0.6, 4.4)
self.camera.origin = (0.0, 3.5, -3.8)
elif self.povTheme == "rb":
self.camera.target = (0.0, 0.0, 3.7)
self.camera.origin = (0.0, 2.9, -2.9)
elif self.povTheme == "fof":
self.camera.target = (0.0, 0.0, 4.0)
self.camera.origin = (0.0, 3.0, -3.0)
else: # FoF
self.camera.target = (0.0, 0.0, 4.0)
self.camera.origin = (0.0, 3.0, -3.0)
# different types of fretbord into animations
if self.neckintroAnimationType == 0: # Original FoFiX rotate down into place
self.camera.origin = (self.camera.origin[0], self.camera.origin[1]*self.boardY, self.camera.origin[2])
elif self.neckintroAnimationType == 1: # Guitar Hero type (from bottom of screen)
self.camera.target = (self.camera.target[0], self.camera.target[1]+self.boardY-1, self.camera.target[2])
self.camera.origin = (self.camera.origin[0], self.camera.origin[1]+self.boardY-1, self.camera.origin[2])
elif self.neckintroAnimationType == 2: # Rock Band type (goes into screen)
self.camera.target = (self.camera.target[0], self.camera.target[1], self.camera.target[2]+self.boardZ-1)
self.camera.origin = (self.camera.origin[0], self.camera.origin[1], self.camera.origin[2]+self.boardZ-1)
elif self.neckintroAnimationType == 3: # Off game starts with the pov as is
self.camera.origin = self.camera.origin
elif self.neckintroAnimationType == 4: # By Theme
if self.neckintroThemeType == "fofix":
self.camera.origin = (self.camera.origin[0], self.camera.origin[1]*self.boardY, self.camera.origin[2])
elif self.neckintroThemeType == "guitar hero":
self.camera.target = (self.camera.target[0], self.camera.target[1]+self.boardY-1, self.camera.target[2])
self.camera.origin = (self.camera.origin[0], self.camera.origin[1]+self.boardY-1, self.camera.origin[2])
elif self.neckintroThemeType == "rockband":
self.camera.target = (self.camera.target[0], self.camera.target[1], self.camera.target[2]+self.boardZ-1)
self.camera.origin = (self.camera.origin[0], self.camera.origin[1], self.camera.origin[2]+self.boardZ-1)
def handleTempo(self, song, pos):
if not song:
return
if self.lastBpmChange > 0 and self.disableVBPM: # only handle tempo once if the VBPM feature is off
return
tempEventHolder = song.tempoEventTrack.getNextTempoChange(pos)
if tempEventHolder:
time, event = tempEventHolder
if ( (time < pos or self.lastBpmChange < 0) or (pos - time < self.currentPeriod or self.lastBpmChange < 0) ) and time > self.lastBpmChange:
self.baseBeat += (time - self.lastBpmChange) / self.currentPeriod
self.targetBpm = event.bpm
song.tempoEventTrack.currentIndex += 1 # manually increase current event
self.lastBpmChange = time
# adjust tempo gradually to meet new target
if self.targetBpm != self.currentBpm:
diff = self.targetBpm - self.currentBpm
tempDiff = round((diff * .03), 4) # better to calculate this once and reuse the variable instead of recalculating every use
if tempDiff != 0:
self.currentBpm = self.currentBpm + tempDiff
else:
self.currentBpm = self.targetBpm
# recalculate all variables dependent on the tempo, apply to instrument objects - only if currentBpm has changed
self.currentPeriod = 60000.0 / self.currentBpm
for instrument in self.instruments:
instrument.setBPM(self.currentBpm)
instrument.lastBpmChange = self.lastBpmChange
instrument.baseBeat = self.baseBeat
def hopFretboard(self, num, height):
""" Hop a fretboard """
if self.instruments[num].fretboardHop < height:
self.instruments[num].fretboardHop = height
def getPlayerNum(self, control):
for i, player in enumerate(self.players):
if control and control in player.keyList:
return i
else:
return -1
def render(self, visibility, topMost):
super(BandPlayBaseScene, self).render(visibility, topMost)
def run(self, ticks):
super(BandPlayBaseScene, self).run(ticks)
class GuitarScene(BandPlayBaseScene):
def __init__(self, engine, libraryName, songName):
superClass = super(GuitarScene, self)
superClass.__init__(engine, libraryName, songName)
self.battle = False
self.coOp = False
self.coOpRB = False
self.coOpType = False
self.practiceMode = False
log.debug("GuitarScene init...")
self.coOpPlayerMeter = 0
# retrieve game parameters
self.gamePlayers = len(self.players)
self.gameMode1p = self.engine.world.gameMode
self.gameMode2p = self.engine.world.multiMode
if self.gameMode1p == 2:
self.careerMode = True
else:
self.careerMode = False
if self.gameMode1p == 1:
self.practiceMode = True
if self.gamePlayers > 1:
# check for battle mode
if self.gameMode2p == 1:
self.battle = True
self.coOp = False
self.coOpRB = False
self.coOpType = False
# Mode 2 was party mode
elif self.gameMode2p == 3:
self.battle = False
self.coOp = True
self.coOpRB = False
self.coOpType = True
elif self.gameMode2p == 4:
self.battle = False
self.coOp = False
self.coOpRB = True
self.coOpType = True
# mode 5 was coop gh
# mode 6 was GH3 battle
self.coOpType = False
else:
self.battle = False
self.coOp = False
self.coOpRB = False
self.coOpType = False
gNum = 0
for j, player in enumerate(self.players):
guitar = True
if player.part.id == song.VOCAL_PART:
inst = Vocalist(self.engine, player, self, player=j)
if self.coOpRB:
inst.coOpRB = True
self.instruments.append(inst)
self.playingVocals = True
self.numOfSingers += 1
self.numberOfGuitars -= 1
guitar = False
elif player.part.id == song.DRUM_PART:
inst = Drum(self.engine, player, self, player=j)
self.instruments.append(inst)
else:
bass = False
if player.part.id == song.BASS_PART:
bass = True
inst = Guitar(self.engine, player, self, player=j, bass=bass)
self.instruments.append(inst)
# both these selections should get guitar solos
if player.part.id == song.LEAD_PART or player.part.id == song.GUITAR_PART:
self.instruments[j].canGuitarSolo = True
if player.practiceMode:
self.practiceMode = True
if guitar:
player.guitarNum = gNum
gNum += 1
if self.firstGuitar is None:
self.firstGuitar = j
self.neckrender.append(self.instruments[j].neck)
if self.instruments[j].isDrum:
self.keysList.append(player.drums)
self.soloKeysList.append(player.drumSolo)
self.soloShifts.append(None)
self.instruments[j].keys = player.drums
self.instruments[j].actions = player.drums
else:
self.keysList.append(player.keys)
self.soloKeysList.append(player.soloKeys)
self.soloShifts.append(player.soloShift)
self.instruments[j].keys = player.keys
self.instruments[j].actions = player.actions
else:
self.neckrender.append(None)
self.keysList.append([])
self.soloKeysList.append([])
self.soloShifts.append([])
log.debug("GuitarScene keysList: %s" % str(self.keysList))
self.aiSkill = [0 for i in self.players]
self.aiHitPercentage = [0 for i in self.players]
self.aiPlayNote = [True for i in self.players]
self.aiUseSP = [0 for i in self.players]
self.battleTarget = [0 for i in self.players]
self.jurgenText = self.engine.theme.jurgTextPos
if float(self.jurgenText[2]) < 0.00035:
self.jurgenText[2] = 0.00035
if float(self.jurgenText[0]) < 0:
self.jurgenText[0] = 0
if float(self.jurgenText[1]) < 0:
self.jurgenText[1] = 0
self.whammySavesSP = self.engine.config.get("game", "whammy_saves_starpower")
self.failingEnabled = self.engine.config.get("coffee", "failingEnabled")
self.timeLeft = None
self.processedFirstNoteYet = False
self.playerAssist = [0 for i in self.players]
for i, player in enumerate(self.players):
if self.instruments[i].isDrum:
if player.autoKick:
self.playerAssist[i] = 3
elif not self.instruments[i].isVocal:
self.playerAssist[i] = player.assistMode
if self.playerAssist[i] == 2 and player.getDifficultyInt() > 1:
self.playerAssist[i] = 0
elif self.playerAssist[i] == 1 and player.getDifficultyInt() > 2:
self.playerAssist[i] = 0
for assistMode in self.playerAssist:
if assistMode > 0:
self.assisting = True
break
else:
self.assisting = False
self.autoPlay = False
self.jurgPlayer = [False for i in self.players]
self.jurg = [False for i in self.players]
self.customBot = [None for i in self.players]
for i in range(self.numOfPlayers):
if self.instruments[i].isVocal:
continue
if self.engine.config.get("game", "jurg_p%d" % i):
self.jurg[i] = True
self.autoPlay = True
self.failed = False
self.finalFailed = False
self.failEnd = False
self.crowdsCheering = False
self.inUnison = [False for i in self.players]
self.haveUnison = [False for i in self.players]
self.firstUnison = False
self.firstUnisonDone = False
self.unisonActive = False
self.unisonNum = 0
self.unisonEarn = [False for i in self.players]
self.starPowersActive = 0
self.playersInGreen = 0
self.crowdFaderVolume = 0.0
self.coOpStarPower = 0
self.coOpStarPowerTimer = 0
self.coOpStarPowerActive = [0 for i in self.players]
self.failTimer = 0
self.rockTimer = 0
self.youRock = False
self.rockCountdown = 100
self.soloReviewDispDelay = 300
self.baseScore = 50
self.baseSustainScore = .1
self.rockFinished = False
self.spTimes = [[] for i in self.players]
self.midiSP = False
self.oBarScale = 0.0 # overdrive bar scale factor
self.firstClap = True
self.multi = [1 for i in self.players]
# Get theme
self.themeName = self.engine.data.themeLabel
self.theme = self.engine.data.theme
if self.engine.theme.hopoIndicatorX is not None:
self.hopoIndicatorX = self.engine.theme.hopoIndicatorX
else:
self.hopoIndicatorX = .950
if self.engine.theme.hopoIndicatorY is not None:
self.hopoIndicatorY = self.engine.theme.hopoIndicatorY
else:
self.hopoIndicatorY = .710
self.hopoIndicatorActiveColor = self.engine.theme.hopoIndicatorActiveColor
self.hopoIndicatorInactiveColor = self.engine.theme.hopoIndicatorInactiveColor
self.rockMax = 30000.0
self.rockMedThreshold = self.rockMax / 3.0
self.rockHiThreshold = self.rockMax / 3.0 * 2
self.rock = [self.rockMax / 2 for i in self.players]
self.arrowRotation = [.5 for i in self.players]
self.starNotesMissed = [False for i in self.players]
self.notesMissed = [False for i in self.players]
self.lessMissed = [False for i in self.players]
self.notesHit = [False for i in self.players]
self.lessHit = False
self.minBase = 400
self.pluBase = 15
self.minGain = 2
self.pluGain = 7
self.battleMax = 300
self.minusRock = [self.minBase for i in self.players]
self.plusRock = [self.pluBase for i in self.players]
self.coOpMulti = 1
self.coOpFailDone = [False for i in self.players]
if self.coOpRB:
self.coOpPlayerMeter = len(self.rock)
self.rock.append(self.rockMax / 2)
self.minusRock.append(0.0)
self.plusRock.append(0.0)
self.timesFailed = [0 for i in self.players]
if self.coOp:
self.coOpPlayerMeter = len(self.rock) - 1 # make sure it's the last one
stage = os.path.join("themes", self.themeName, "stage.ini")
self.stage = Stage.Stage(self, self.engine.resource.fileName(stage))
self.loadSettings()
self.tsBotNames = [_("KiD"), _("Stump"), _("AkedRobot"), _("Q"), _("MFH"), _("Jurgen")]
# pre-translate text strings
self.powerUpName = self.engine.theme.power_up_name
self.tsNoteStreak = _("%d Note Streak")
self.tsPhraseStreak = _("%d Phrase Streak")
self.tsStarPowerReady = _("%s Ready") % self.powerUpName
self.tsCoOpStarPower = _("Activate %s!") % self.powerUpName
self.tsYouFailedBattle = _("You Failed")
self.tsJurgenIsHere = _("%s is here")
self.tsJurgenWasHere = _("%s was here")
self.tsPercentComplete = _("% Complete")
self.tsHopoIndicator = _("HOPO")
self.tsCompleted = _("COMPLETED")
self.tsPercentOn = _(" % ON ")
self.tsBassGroove = _("BASS GROOVE")
self.tsBassGrooveLabel = _("Bass Groove:")
self.tsHandicapLabel = _("Handicap")
self.tsAvgLabel = _("Avg")
self.tsAccVeryLate = _("Very Late")
self.tsAccLate = _("Late")
self.tsAccSlightlyLate = _("Slightly Late")
self.tsAccExcellentLate = _("-Excellent!")
self.tsAccPerfect = _("Perfect!!")
self.tsAccExcellentEarly= _("+Excellent!")
self.tsAccSlightlyEarly = _("Slightly Early")
self.tsAccEarly = _("Early")
self.tsAccVeryEarly = _("Very Early")
self.msLabel = _("ms")
self.tsSolo = _("Solo!")
self.tsPerfectSolo = _("Perfect Solo!")
self.tsAwesomeSolo = _("Awesome Solo!")
self.tsGreatSolo = _("Great Solo!")
self.tsGoodSolo = _("Good Solo!")
self.tsSolidSolo = _("Solid Solo!")
self.tsOkaySolo = _("Okay Solo")
self.tsMessySolo = _("Messy Solo")
self.tsPtsLabel = _("pts")
self.tsGetReady = _("Get Ready to Rock")
self.tsAsMadeFamousBy = _("as made famous by")
self.tsBy = _("by ")
self.tsFrettedBy = _(" fretted by ")
for player in self.players:
player.currentTheme = self.theme
# precalculate full and player viewports
self.engine.view.setViewport(1, 0)
self.wFull, self.hFull = self.engine.view.geometry[2:4]
self.wPlayer = []
self.hPlayer = []
self.hOffset = []
self.hFontOffset = []
# needed for new stage background handling
self.stage.wFull = self.wFull
self.stage.hFull = self.hFull
self.fontScreenBottom = self.engine.data.fontScreenBottom
self.oBarScaleCoef = (0.6 + 0.4 * self.numberOfGuitars) * 1.256 * self.hFull / self.wFull # depends on resolution and number of players
for i, player in enumerate(self.players):
if not self.instruments[i].isVocal:
self.engine.view.setViewportHalf(self.numberOfGuitars, player.guitarNum)
w = self.engine.view.geometryAllHalf[self.numberOfGuitars-1, player.guitarNum, 2]
h = self.engine.view.geometryAllHalf[self.numberOfGuitars-1, player.guitarNum, 3]
else:
w = self.wFull
h = self.hFull
self.wPlayer.append(w)
self.hPlayer.append(h)
self.hOffset.append(h)
self.hFontOffset.append(h)
if not self.instruments[i].isVocal:
self.wPlayer[i] = self.wPlayer[i] * self.numberOfGuitars # set the width
if self.numberOfGuitars > 1:
self.hPlayer[i] = self.hPlayer[i] * self.numberOfGuitars / 1.5 # set the hight
self.hOffset[i] = self.hPlayer[i] * .4 * (self.numberOfGuitars - 1)
else:
self.hPlayer[i] = self.hPlayer[i] * self.numberOfGuitars # set the hight
self.hOffset[i] = 0
self.hFontOffset[i] = -self.hOffset[i] / self.hPlayer[i] * 0.752 # font Height Offset when there are 2 players
self.engine.view.setViewport(1, 0)
self.drumMisses = self.engine.config.get("game", "T_sound") # Faaa Drum sound
# constant definitions, ini value retrievals
self.pitchBendSemitones = -1.0 # perhaps read this from song.ini and fall back on a specific value?
self.lineByLineLyricMaxLineWidth = 0.5
self.lineByLineStartSlopMs = 750
self.digitalKillswitchStarpowerChunkSize = 0.05 * self.engine.audioSpeedFactor
self.digitalKillswitchActiveStarpowerChunkSize = self.digitalKillswitchStarpowerChunkSize / 3.0
# was 0.10, now much closer to actual GH3
self.analogKillswitchStarpowerChunkSize = 0.15 * self.engine.audioSpeedFactor
self.analogKillswitchActiveStarpowerChunkSize = self.analogKillswitchStarpowerChunkSize / 3.0
self.rbOverdriveBarGlowFadeInChunk = .07 # this amount added to visibility every run() cycle when fading in - original .2
self.crowdCheerFadeInChunk = .02 # added to crowdVolume every run() when fading in
self.crowdCheerFadeOutChunk = .03 # subtracted from crowdVolume every run() on fade out.
self.maxDisplayTextScale = 0.0024 # orig 0.0024
self.displayTextScaleStep2 = 0.00008 # orig 0.00008
self.displayTextScaleStep1 = 0.0001 # orig 0.0001
self.textTimeToDisplay = 100
self.songInfoDisplayScale = self.engine.theme.songInfoDisplayScale
self.songInfoDisplayX = self.engine.theme.songInfoDisplayX # This controls the X position of song info display during countdown
self.songInfoDisplayY = self.engine.theme.songInfoDisplayY # This controls the Y position of song info display during countdown
self.lyricMode = self.engine.config.get("game", "lyric_mode")
self.scriptLyricPos = self.engine.config.get("game", "script_lyric_pos")
self.starClaps = self.engine.config.get("game", "star_claps")
self.rb_sp_neck_glow = self.engine.config.get("game", "rb_sp_neck_glow")
self.accuracy = [0 for i in self.players]
self.resumeCountdownEnabled = self.engine.config.get("game", "resume_countdown")
self.resumeCountdown = 0
self.resumeCountdownSeconds = 0
self.pausePos = 0
self.dispAccuracy = [False for i in self.players]
self.showAccuracy = self.engine.config.get("game", "accuracy_mode")
self.hitAccuracyPos = self.engine.config.get("game", "accuracy_pos")
self.showUnusedTextEvents = self.engine.config.get("game", "show_unused_text_events")
self.bassKickSoundEnabled = self.engine.config.get("game", "bass_kick_sound")
self.midiLyricsEnabled = self.engine.config.get("game", "rb_midi_lyrics")
self.midiSectionsEnabled = self.engine.config.get("game", "rb_midi_sections")
if self.numOfPlayers > 1 and self.midiLyricsEnabled == 1:
self.midiLyricsEnabled = 0
if self.numOfPlayers > 1 and self.midiSectionsEnabled == 1:
self.midiSectionsEnabled = 0
self.hopoDebugDisp = self.engine.config.get("game", "hopo_debug_disp")
if self.hopoDebugDisp == 1:
for instrument in self.instruments:
if not instrument.isDrum and not instrument.isVocal:
instrument.debugMode = True
self.numDecimalPlaces = self.engine.config.get("game", "decimal_places")
self.roundDecimalForDisplay = lambda n: ('%%.%df' % self.numDecimalPlaces) % float(n)
self.starScoring = self.engine.config.get("game", "star_scoring")
self.ignoreOpenStrums = self.engine.config.get("game", "ignore_open_strums")
self.muteSustainReleases = self.engine.config.get("game", "sustain_muting")
self.hopoIndicatorEnabled = self.engine.config.get("game", "hopo_indicator")
self.muteLastSecond = self.engine.config.get("audio", "mute_last_second")
self.mutedLastSecondYet = False
self.muteDrumFill = self.engine.config.get("game", "mute_drum_fill")
self.starScoreUpdates = self.engine.config.get("performance", "star_score_updates")
self.currentlyAnimating = True
self.missPausesAnim = self.engine.config.get("game", "miss_pauses_anim")
self.starpowerMode = self.engine.config.get("game", "starpower_mode")
self.useMidiSoloMarkers = False
self.soloFrameMode = self.engine.config.get("game", "solo_frame")
self.whammyEffect = self.engine.config.get("audio", "whammy_effect")
shaders.var["whammy"] = self.whammyEffect
self.bigRockEndings = self.engine.config.get("game", "big_rock_endings")
self.showFreestyleActive = self.engine.config.get("debug", "show_freestyle_active")
self.showBpm = self.engine.config.get("debug", "show_bpm")