-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDrum.py
2885 lines (2428 loc) · 119 KB
/
Drum.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
from __future__ import division
#####################################################################
# -*- coding: iso-8859-1 -*- #
# #
# Frets on Fire #
# Copyright (C) 2006 Sami Kyostila #
# 2008 Alarian #
# 2008 myfingershurt #
# 2008 Glorandwarf #
# 2008 Capo #
# 2008 Blazingamer #
# 2008 evilynux <evilynux@gmail.com> #
# #
# 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. #
#####################################################################
#altered by myfingershurt to adapt to Alarian mod
from builtins import str
from builtins import chr
from builtins import range
from builtins import object
from past.utils import old_div
import Player
from Song import Note, Tempo
from Mesh import Mesh
from Neck import Neck
import Theme
import random
from copy import deepcopy
from Shader import shaders
from OpenGL.GL import *
import math
#myfingershurt: needed for multi-OS file fetching
import os
import Log
import Song #need the base song defines as well
#Normal guitar key color order: Green, Red, Yellow, Blue, Orange
#Drum fret color order: Red, Yellow, Blue, Green
#actual drum note numbers:
#0 = bass drum (stretched Orange fret), normally Green fret
#1 = drum Red fret, normally Red fret
#2 = drum Yellow fret, normally Yellow fret
#3 = drum Blue fret, normally Blue fret
#4 = drum Green fret, normally Orange fret
#
#So, with regard to note number coloring, swap note.number 0's color wih note.number 4.
#akedrou - 5-drum support is now available.
# to enable it, only here and Player.drums should need changing.
class Drum(object):
def __init__(self, engine, playerObj, editorMode = False, player = 0):
self.engine = engine
self.isDrum = True
self.isBassGuitar = False
self.isVocal = False
#self.starPowerDecreaseDivisor = 200.0*self.engine.audioSpeedFactor
self.starPowerDecreaseDivisor = 200.0/self.engine.audioSpeedFactor
self.drumsHeldDown = [0, 0, 0, 0, 0]
self.lastFretWasBassDrum = False
self.lastFretWasT1 = False #Faaa Drum sound
self.lastFretWasT2 = False
self.lastFretWasT3 = False
self.lastFretWasC = False
self.useMidiSoloMarkers = False
self.canGuitarSolo = False
self.guitarSolo = False
self.sameNoteHopoString = False
self.hopoProblemNoteNum = -1
self.currentGuitarSoloHitNotes = 0
self.matchingNotes = None
self.bigRockEndingMarkerSeen = False
#MFH - I do not understand fully how the handicap scorecard works at the moment, nor do I have the time to figure it out.
#... so for now, I'm just writing some extra code here for the early hitwindow size handicap.
self.earlyHitWindowSizeFactor = 0.5
self.starNotesInView = False
self.openStarNotesInView = False
self.cappedScoreMult = 0
self.isStarPhrase = False
self.finalStarSeen = False
self.freestyleActive = False
# Volshebnyi - BRE scoring variables
self.freestyleEnabled = False
self.freestyleStart = 0
self.freestyleFirstHit = 0
self.freestyleLength = 0
self.freestyleLastHit = 0
self.freestyleBonusFret = -2
self.freestyleLastFretHitTime = list(range(5))
self.freestyleBaseScore = 750
self.freestylePeriod = 1000
self.freestylePercent = 50
self.drumFillsCount = 0
self.drumFillsTotal = 0
self.drumFillsHits = 0
self.drumFillsActive = False
self.drumFillsReady = False
self.freestyleReady = False
self.freestyleOffset = 5
self.freestyleSP = False
self.neckAlpha=[] # necks transparency
self.neckAlpha.append( self.engine.config.get("game", "necks_alpha") ) # all necks
self.neckAlpha.append( self.neckAlpha[0] * self.engine.config.get("game", "neck_alpha") ) # solo neck
self.neckAlpha.append( self.neckAlpha[0] * self.engine.config.get("game", "solo_neck_alpha") ) # solo neck
self.neckAlpha.append( self.neckAlpha[0] * self.engine.config.get("game", "overlay_neck_alpha") ) # overlay neck
self.neckAlpha.append( self.neckAlpha[0] * self.engine.config.get("game", "fail_neck_alpha") ) # fail neck
#self.drumFillOnScreen = False #MFH
self.drumFillEvents = []
self.drumFillWasJustActive = False
#empty variables for class compatibility
self.totalPhrases = 0
self.accThresholdWorstLate = 0
self.accThresholdVeryLate = 0
self.accThresholdLate = 0
self.accThresholdSlightlyLate = 0
self.accThresholdExcellentLate = 0
self.accThresholdPerfect = 0
self.accThresholdExcellentEarly = 0
self.accThresholdSlightlyEarly = 0
self.accThresholdEarly = 0
self.accThresholdVeryEarly = 0
self.tempoBpm = 120 #MFH - default is NEEDED here...
self.beatsPerBoard = 5.0
self.strings = 4
self.fretWeight = [0.0] * self.strings
self.fretActivity = [0.0] * self.strings
self.fretColors = Theme.fretColors
self.spColor = self.fretColors[5]
self.useFretColors = Theme.use_fret_colors
self.openFretActivity = 0.0
self.openFretColor = Theme.openFretColor
self.playedNotes = []
self.missedNotes = []
self.editorMode = editorMode
self.selectedString = 0
self.time = 0.0
self.pickStartPos = 0
self.leftyMode = False
self.drumFlip = False
self.battleSuddenDeath = False
self.battleObjectsEnabled = []
self.battleSDObjectsEnabled = []
if self.engine.config.get("game", "battle_Whammy") == 1:
self.battleObjectsEnabled.append(4)
if self.engine.config.get("game", "battle_Diff_Up") == 1:
self.battleObjectsEnabled.append(2)
if self.engine.config.get("game", "battle_String_Break") == 1:
self.battleObjectsEnabled.append(3)
if self.engine.config.get("game", "battle_Double") == 1:
self.battleObjectsEnabled.append(7)
if self.engine.config.get("game", "battle_Death_Drain") == 1:
self.battleObjectsEnabled.append(1)
if self.engine.config.get("game", "battle_Amp_Overload") == 1:
self.battleObjectsEnabled.append(8)
if self.engine.config.get("game", "battle_Switch_Controls") == 1:
self.battleObjectsEnabled.append(6)
if self.engine.config.get("game", "battle_Steal") == 1:
self.battleObjectsEnabled.append(5)
#if self.engine.config.get("game", "battle_Tune") == 1:
# self.battleObjectsEnabled.append(9)
Log.debug("Battle Objects Enabled: "+str(self.battleObjectsEnabled))
self.battleNextObject = 0
self.battleObjects = [0] * 3
self.battleBeingUsed = [0] * 2
self.battleStatus = [False] * 9
self.battleStartTimes = [0] * 9
self.battleGetTime = 0
self.battleTarget = 0
self.battleLeftyLength = 8000#
self.battleDiffUpLength = 15000
self.battleDiffUpValue = playerObj.getDifficultyInt()
self.battleDoubleLength = 8000
self.battleAmpLength = 8000
self.battleWhammyLimit = 6#
self.battleWhammyNow = 0
self.battleWhammyDown = False
self.battleBreakLimit = 8.0
self.battleBreakNow = 0.0
self.battleBreakString = 0
self.battleObjectGained = 0
self.battleSuddenDeath = False
self.battleDrainStart = 0
self.battleDrainLength = 8000
self.freestyleHitFlameCounts = [0 for n in range(self.strings+1)] #MFH
self.logClassInits = self.engine.config.get("game", "log_class_inits")
if self.logClassInits == 1:
Log.debug("Drum class initialization!")
self.incomingNeckMode = self.engine.config.get("game", "incoming_neck_mode")
self.guitarSoloNeckMode = self.engine.config.get("game", "guitar_solo_neck")
self.bigRockEndings = self.engine.config.get("game", "big_rock_endings")
#self.actualBpm = 0.0
self.currentBpm = 120.0 #MFH - need a default 120BPM to be set in case a custom song has no tempo events.
self.currentPeriod = 60000.0 / self.currentBpm
self.targetBpm = self.currentBpm
self.targetPeriod = 60000.0 / self.targetBpm
self.lastBpmChange = -1.0
self.baseBeat = 0.0
#########For Animations
self.Animspeed = 30#Lower value = Faster animations
#For Animated Starnotes
self.indexCount = 0
#Alarian, For animated hitglow
self.HCount = 0
self.HCount2 = 0
self.Hitanim = True
self.Hitanim2 = True
#myfingershurt: to keep track of pause status here as well
self.paused = False
self.spEnabled = True
self.starPower = 0
self.starPowerGained = False
self.starpowerMode = self.engine.config.get("game", "starpower_mode") #MFH
self.killPoints = False
if self.starpowerMode == 1:
self.starNotesSet = False
else:
self.starNotesSet = True
self.maxStars = []
self.starNotes = []
self.totalNotes = 0
#get difficulty
self.difficulty = playerObj.getDifficultyInt()
self.controlType = playerObj.controlType
self.scoreMultiplier = 1
#myfingershurt:
self.hopoStyle = 0
self.LastStrumWasChord = False
self.spRefillMode = self.engine.config.get("game","sp_notes_while_active")
self.hitglow_color = self.engine.config.get("video", "hitglow_color") #this should be global, not retrieved every fret render.
#myfingershurt: this should be retrieved once at init, not repeatedly in-game whenever tails are rendered.
self.notedisappear = self.engine.config.get("game", "notedisappear")
self.fretsUnderNotes = self.engine.config.get("game", "frets_under_notes")
self.staticStrings = self.engine.config.get("performance", "static_strings")
self.vbpmLogicType = self.engine.config.get("debug", "use_new_vbpm_beta")
self.indexFps = self.engine.config.get("video", "fps")
self.twoChord = 0
self.twoChordApply = False
self.hopoActive = 0
#myfingershurt: need a separate variable to track whether or not hopos are actually active
self.wasLastNoteHopod = False
self.hopoLast = -1
self.hopoColor = (0, .5, .5)
self.player = player
self.scoreMultiplier = 1
self.hit = [False, False, False, False, False]
self.freestyleHit = [False, False, False, False, False]
self.playedSound = [True, True, True, True, True]
#Get theme
themename = self.engine.data.themeLabel
#now theme determination logic is only in data.py:
self.theme = self.engine.data.theme
#check if BRE enabled
if self.bigRockEndings == 2 or (self.theme == 2 and self.bigRockEndings == 1):
self.freestyleEnabled = True
if self.theme < 2: #make board same size as guitar board if GH based theme so it rockmeters dont interfere
self.boardWidth = 3.0
self.boardLength = 9.0
#blazingamer
self.nstype = self.engine.config.get("game", "nstype")
self.twoDnote = Theme.twoDnote
self.twoDkeys = Theme.twoDkeys
self.threeDspin = Theme.threeDspin
self.opencolor = Theme.opencolor
self.noterotate = self.engine.config.get("coffee", "noterotate")
self.rockLevel = 0.0
self.failcount = 0
self.failcount2 = False
self.spcount = 0
self.spcount2 = 0
#akedrou
self.coOpFailed = False
self.coOpRestart = False
self.coOpRescueTime = 0.0
#MFH- fixing neck speed
if self.nstype < 3: #not constant mode:
self.speed = self.engine.config.get("coffee", "neckSpeed")*0.01
else: #constant mode
#self.speed = self.engine.config.get("coffee", "neckSpeed")
self.speed = 410 - self.engine.config.get("coffee", "neckSpeed") #invert this value
self.bigMax = 1
#death_au: fixed neck size
# elif self.twoDnote == False or self.twoDkeys == False:
# self.boardWidth = Theme.neckWidth + 0.6
# self.boardLength = Theme.neckLength
self.boardWidth = Theme.neckWidth
self.boardLength = Theme.neckLength
if self.engine.config.get("game", "large_drum_neck"):
self.boardWidth *= (4.0/3.0)
self.boardLength *= (4.0/3.0)
self.boardScaleX = self.boardWidth/3.0
self.boardScaleY = self.boardLength/9.0
self.fretPress = Theme.fret_press
self.muteSustainReleases = self.engine.config.get("game", "sustain_muting") #MFH
self.hitw = self.engine.config.get("game", "note_hit_window") #this should be global, not retrieved every BPM change.
if self.hitw == 0:
self.hitw = 2.3
elif self.hitw == 1:
self.hitw = 1.9
elif self.hitw == 2:
self.hitw = 1.2
elif self.hitw == 3:
self.hitw = 1.0
elif self.hitw == 4:
self.hitw = 0.70
else:
self.hitw = 1.2
self.keys = []
self.actions = []
self.soloKey = []
self.setBPM(self.currentBpm)
engine.loadImgDrawing(self, "glowDrawing", "glow.png")
#MFH - making hitflames optional
self.hitFlamesPresent = False
try:
engine.loadImgDrawing(self, "hitflames1Drawing", os.path.join("themes",themename,"hitflames1.png"), textureSize = (128, 128))
engine.loadImgDrawing(self, "hitflames2Drawing", os.path.join("themes",themename,"hitflames2.png"), textureSize = (128, 128))
self.hitFlamesPresent = True
except IOError:
self.hitFlamesPresent = False
self.hitflames1Drawing = None
self.hitflames2Drawing = None
try:
engine.loadImgDrawing(self, "hitflamesAnim", os.path.join("themes",themename,"hitflamesanimation.png"), textureSize = (128, 128))
except IOError:
#engine.loadImgDrawing(self, "hitflames1Drawing", os.path.join("themes",themename,"hitflames1.png"), textureSize = (128, 128))
#engine.loadImgDrawing(self, "hitflames2Drawing", os.path.join("themes",themename,"hitflames2.png"), textureSize = (128, 128))
self.Hitanim2 = False
try:
engine.loadImgDrawing(self, "hitglowAnim", os.path.join("themes",themename,"hitglowanimation.png"), textureSize = (128, 128))
except IOError:
try:
engine.loadImgDrawing(self, "hitglowDrawing", os.path.join("themes",themename,"hitglow.png"), textureSize = (128, 128))
engine.loadImgDrawing(self, "hitglow2Drawing", os.path.join("themes",themename,"hitglow2.png"), textureSize = (128, 128))
except IOError:
self.hitglowDrawing = None
self.hitglow2Drawing = None
self.hitFlamesPresent = False #MFH - shut down all flames if these are missing.
self.Hitanim = False
if self.twoDkeys == True: #death_au
#myfingershurt: adding drumfretshacked.png for image-corrected drum fret angles in RB:
try:
engine.loadImgDrawing(self, "fretButtons", os.path.join("themes",themename,"drumfretshacked.png"))
except IOError:
engine.loadImgDrawing(self, "fretButtons", os.path.join("themes",themename,"fretbuttons.png"))
#death_au: adding drumfrets.png (with bass drum frets seperate)
try:
engine.loadImgDrawing(self, "drumFretButtons", os.path.join("themes",themename,"drumfrets.png"))
except IOError:
self.drumFretButtons = None
else: #death_au
defaultKey = False
defaultOpenKey = False
#MFH - can't use IOError for fallback logic for a Mesh() call...
if self.engine.fileExists(os.path.join("themes", themename, "key_drum.dae")):
engine.resource.load(self, "keyMesh", lambda: Mesh(engine.resource.fileName("themes", themename, "key_drum.dae")))
elif self.engine.fileExists(os.path.join("themes", themename, "key.dae")):
engine.resource.load(self, "keyMesh", lambda: Mesh(engine.resource.fileName("themes", themename, "key.dae")))
else:
engine.resource.load(self, "keyMesh", lambda: Mesh(engine.resource.fileName("key.dae")))
defaultKey = True
if self.engine.fileExists(os.path.join("themes", themename, "key_open.dae")):
engine.resource.load(self, "keyMeshOpen", lambda: Mesh(engine.resource.fileName("themes", themename, "key_open.dae")))
else:
engine.resource.load(self, "keyMeshOpen", lambda: Mesh(engine.resource.fileName("key_open.dae")))
defaultOpenKey = True
if defaultKey:
self.keytex = False
self.keytexopen = None
else:
try:
for i in range(5):
engine.loadImgDrawing(self, "keytex"+chr(97+i), os.path.join("themes", themename, "keytex_"+chr(97+i)+".png"))
self.keytex = True
except IOError:
self.keytex = False
if defaultOpenKey:
self.keytexopen = None
else:
try:
engine.loadImgDrawing(self, "keytexopen", os.path.join("themes",themename,"keytex_open.png"))
except IOError:
self.keytexopen = None
#Spinning starnotes or not?
self.starspin = False
if self.twoDnote == True:
try:
engine.loadImgDrawing(self, "noteButtons", os.path.join("themes",themename,"drumnotes.png"))
self.separateDrumNotes = True
except IOError:
engine.loadImgDrawing(self, "noteButtons", os.path.join("themes",themename,"notes.png"))
self.separateDrumNotes = False
else:
defaultNote = False
#MFH - can't use IOError for fallback logic for a Mesh() call...
if self.engine.fileExists(os.path.join("themes", themename, "note_drum.dae")):
engine.resource.load(self, "noteMesh", lambda: Mesh(engine.resource.fileName("themes", themename, "note_drum.dae")))
elif self.engine.fileExists(os.path.join("themes", themename, "note.dae")):
engine.resource.load(self, "noteMesh", lambda: Mesh(engine.resource.fileName("themes", themename, "note.dae")))
else:
engine.resource.load(self, "noteMesh", lambda: Mesh(engine.resource.fileName("note.dae")))
defaultNote = True
if defaultNote:
self.notetex = False
self.starMesh = None
self.startex = False
self.staratex = False
self.spActTex = None
else:
try:
for i in range(5):
engine.loadImgDrawing(self, "notetex"+chr(97+i), os.path.join("themes", themename, "notetex_"+chr(97+i)+".png"))
self.notetex = True
except IOError:
self.notetex = False
if self.engine.fileExists(os.path.join("themes", themename, "star_drum.dae")):
engine.resource.load(self, "starMesh", lambda: Mesh(engine.resource.fileName("themes", themename, "star_drum.dae")))
elif self.engine.fileExists(os.path.join("themes", themename, "star.dae")):
engine.resource.load(self, "starMesh", lambda: Mesh(engine.resource.fileName("themes", themename, "star.dae")))
else:
self.starMesh = None
try:
for i in range(5):
engine.loadImgDrawing(self, "startex"+chr(97+i), os.path.join("themes", themename, "startex_"+chr(97+i)+".png"))
self.startex = True
except IOError:
self.startex = False
try:
for i in range(5):
engine.loadImgDrawing(self, "staratex"+chr(97+i), os.path.join("themes", themename, "staratex_"+chr(97+i)+".png"))
self.staratex = True
except IOError:
self.staratex = False
try:
engine.loadImgDrawing(self, "spActTex", os.path.join("themes",themename,"spacttex.png"))
except IOError:
self.spActTex = None
if self.engine.fileExists(os.path.join("themes", themename, "open.dae")):
engine.resource.load(self, "openMesh", lambda: Mesh(engine.resource.fileName("themes", themename, "open.dae")))
else:
self.openMesh = None
try:
engine.loadImgDrawing(self, "opentexture", os.path.join("themes", themename, "opentex.png"))
self.opentex = True
except IOError:
self.opentex = False
try:
engine.loadImgDrawing(self, "opentexture_star", os.path.join("themes", themename, "opentex_star.png"))
self.opentex_star = True
except IOError:
self.opentex_star = False
try:
engine.loadImgDrawing(self, "opentexture_stara", os.path.join("themes", themename, "opentex_stara.png"))
self.opentex_stara = True
except IOError:
self.opentex_stara = False
try:
engine.loadImgDrawing(self, "freestyle1", os.path.join("themes", themename, "freestyletail1.png"), textureSize = (128, 128))
engine.loadImgDrawing(self, "freestyle2", os.path.join("themes", themename, "freestyletail2.png"), textureSize = (128, 128))
except IOError:
engine.loadImgDrawing(self, "freestyle1", "freestyletail1.png", textureSize = (128, 128))
engine.loadImgDrawing(self, "freestyle2", "freestyletail2.png", textureSize = (128, 128))
if self.theme == 0 or self.theme == 1:
engine.loadImgDrawing(self, "hitlightning", os.path.join("themes",themename,"lightning.png"), textureSize = (128, 128))
#t'aint no tails in drums, yo.
self.simpleTails = True
self.tail1 = None
self.tail2 = None
self.bigTail1 = None
self.bigTail2 = None
self.meshColor = Theme.meshColor
self.hopoColor = Theme.hopoColor
self.spotColor = Theme.spotColor
self.keyColor = Theme.keyColor
self.key2Color = Theme.key2Color
self.tracksColor = Theme.tracksColor
self.barsColor = Theme.barsColor
self.flameColors = Theme.flameColors
self.gh3flameColor = Theme.gh3flameColor
self.flameSizes = Theme.flameSizes
self.glowColor = Theme.glowColor
self.twoChordMax = False
self.disableVBPM = self.engine.config.get("game", "disable_vbpm")
self.disableNoteSFX = self.engine.config.get("video", "disable_notesfx")
self.disableFretSFX = self.engine.config.get("video", "disable_fretsfx")
self.disableFlameSFX = self.engine.config.get("video", "disable_flamesfx")
self.canGuitarSolo = False
self.guitarSolo = False
self.fretboardHop = 0.00 #stump
self.scoreMultiplier = 1
self.coOpFailed = False #akedrou
self.coOpRestart = False #akedrou
self.starPowerActive = False
self.neck = Neck(self.engine, self, playerObj)
def selectPreviousString(self):
self.selectedString = (self.selectedString - 1) % self.strings
def selectString(self, string):
self.selectedString = string % self.strings
def selectNextString(self):
self.selectedString = (self.selectedString + 1) % self.strings
def noteBeingHeld(self):
noteHeld = False
return noteHeld
def isKillswitchPossible(self):
possible = False
return possible
def setBPM(self, bpm):
if bpm > 200:
bpm = 200
#MFH - Filter out unnecessary BPM settings (when currentBPM is already set!)
#if self.actualBpm != bpm:
# self.actualBpm = bpm
self.currentBpm = bpm #update current BPM as well
#MFH - Neck speed determination:
if self.nstype == 0: #BPM mode
self.neckSpeed = old_div((340 - bpm),self.speed)
elif self.nstype == 1: #Difficulty mode
if self.difficulty == 0: #expert
self.neckSpeed = old_div(220,self.speed)
elif self.difficulty == 1:
self.neckSpeed = old_div(250,self.speed)
elif self.difficulty == 2:
self.neckSpeed = old_div(280,self.speed)
else: #easy
self.neckSpeed = old_div(300,self.speed)
elif self.nstype == 2: #BPM & Diff mode
if self.difficulty == 0: #expert
self.neckSpeed = old_div((226-(old_div(bpm,10))),self.speed)
elif self.difficulty == 1:
self.neckSpeed = old_div((256-(old_div(bpm,10))),self.speed)
elif self.difficulty == 2:
self.neckSpeed = old_div((286-(old_div(bpm,10))),self.speed)
else: #easy
self.neckSpeed = old_div((306-(old_div(bpm,10))),self.speed)
else: #Percentage mode - pre-calculated
self.neckSpeed = self.speed
self.earlyMargin = 250 - old_div(bpm,5) - 70*self.hitw
self.lateMargin = 250 - old_div(bpm,5) - 70*self.hitw
#self.earlyMargin = self.lateMargin * self.earlyHitWindowSizeFactor #MFH - scale early hit window here
#self.noteReleaseMargin = 200 - bpm/5 - 70*self.hitw
#if (self.noteReleaseMargin < (200 - bpm/5 - 70*1.2)): #MFH - enforce "tight" hitwindow minimum note release margin
# self.noteReleaseMargin = (200 - bpm/5 - 70*1.2)
if self.muteSustainReleases == 4: #tight
self.noteReleaseMargin = (200 - old_div(bpm,5) - 70*1.2)
elif self.muteSustainReleases == 3: #standard
self.noteReleaseMargin = (200 - old_div(bpm,5) - 70*1.0)
elif self.muteSustainReleases == 2: #wide
self.noteReleaseMargin = (200 - old_div(bpm,5) - 70*0.7)
else: #ultra-wide
self.noteReleaseMargin = (200 - old_div(bpm,5) - 70*0.5)
#MFH - TODO - only calculate the below values if the realtime hit accuracy feedback display is enabled - otherwise this is a waste!
self.accThresholdWorstLate = (0-self.lateMargin)
self.accThresholdVeryLate = (0-(old_div(3*self.lateMargin,4)))
self.accThresholdLate = (0-(old_div(2*self.lateMargin,4)))
self.accThresholdSlightlyLate = (0-(old_div(1*self.lateMargin,4)))
self.accThresholdExcellentLate = -1.0
self.accThresholdPerfect = 1.0
self.accThresholdExcellentEarly = (old_div(1*self.lateMargin,4))
self.accThresholdSlightlyEarly = (old_div(2*self.lateMargin,4))
self.accThresholdEarly = (old_div(3*self.lateMargin,4))
self.accThresholdVeryEarly = (old_div(4*self.lateMargin,4))
def setMultiplier(self, multiplier):
self.scoreMultiplier = multiplier
self.neck.scoreMultiplier = multiplier
#volshebnyi
def renderFreestyleLanes(self, visibility, song, pos, controls):
if not song:
return
if not song.readyToGo:
return
#MFH - check for [section big_rock_ending] to set a flag to determine how to treat the last drum fill marker note:
#for time, event in song.eventTracks[Song.TK_SECTIONS].getEvents(pos - self.lateMargin*2, pos):
# if event.text.find("big rock ending") > 0:
if song.breMarkerTime and pos > song.breMarkerTime:
self.bigRockEndingMarkerSeen = True
#boardWindowMin = pos - self.currentPeriod * 2
boardWindowMax = pos + self.currentPeriod * self.beatsPerBoard
track = song.midiEventTrack[self.player]
#self.currentPeriod = self.neckSpeed
beatsPerUnit = old_div(self.beatsPerBoard, self.boardLength)
if self.freestyleEnabled:
freestyleActive = False
self.drumFillsActive = False
#drumFillOnScreen = False
drumFillEvents = []
#for time, event in track.getEvents(boardWindowMin, boardWindowMax):
for time, event in track.getEvents(pos - self.freestyleOffset, boardWindowMax + self.freestyleOffset):
if isinstance(event, Song.MarkerNote):
if event.number == Song.freestyleMarkingNote and (not event.happened or self.bigRockEndingMarkerSeen): #MFH - don't kill the BRE!
#drumFillOnScreen = True
drumFillEvents.append(event)
length = old_div(old_div((event.length - 50), self.currentPeriod), beatsPerUnit)
w = old_div(self.boardWidth, self.strings)
self.freestyleLength = event.length #volshebnyi
self.freestyleStart = time # volshebnyi
z = old_div((old_div((time - pos), self.currentPeriod)), beatsPerUnit)
z2 = old_div((old_div((time + event.length - pos), self.currentPeriod)), beatsPerUnit)
if z > self.boardLength * .8:
f = old_div((self.boardLength - z), (self.boardLength * .2))
elif z < 0:
f = min(1, max(0, 1 + z2))
else:
f = 1.0
time -= self.freestyleOffset
#volshebnyi - allow tail to move under frets
if time > pos:
self.drumFillsHits = -1
if self.starPower>=50 and not self.starPowerActive:
self.drumFillsReady = True
else:
self.drumFillsReady = False
if self.bigRockEndingMarkerSeen: # and ( (self.drumFillsCount == self.drumFillsTotal and time+event.length>pos) or (time > pos and self.drumFillsCount == self.drumFillsTotal-1) ):
self.freestyleReady = True
self.drumFillsReady = False
else:
self.freestyleReady = False
if time < pos:
if self.bigRockEndingMarkerSeen: # and self.drumFillsCount == self.drumFillsTotal:
freestyleActive = True
else:
#if self.drumFillsCount <= self.drumFillsTotal and self.drumFillsReady:
if self.drumFillsReady:
self.drumFillsActive = True
self.drumFillWasJustActive = True
if self.drumFillsHits<0:
self.drumFillsCount += 1
self.drumFillsHits = 0
if z < -1.5:
length += z +1.5
z = -1.5
#if time+event.length>pos and time+event.length-0.5>pos:
# if controls.getState(self.keys[4]) or controls.getState(self.keys[8]):
# self.starPowerActive = True
#volshebnyi - render 4 freestyle tails
if self.freestyleReady or self.drumFillsReady:
for theFret in range(1,5):
x = (old_div(self.strings, 2) + .5 - theFret) * w
if theFret == 4:
c = self.fretColors[0]
else:
c = self.fretColors[theFret]
color = (.1 + .8 * c[0], .1 + .8 * c[1], .1 + .8 * c[2], 1.0 * visibility * f)
glPushMatrix()
glTranslatef(x, (1.0 - visibility) ** (theFret + 1), z)
freestyleTailMode = 1
self.renderTail(length = length, color = color, fret = theFret, freestyleTail = freestyleTailMode, pos = pos)
glPopMatrix()
if ( self.drumFillsActive and self.drumFillsHits >= 4 and z + length<self.boardLength ):
glPushMatrix()
color = (.1 + .8 * c[0], .1 + .8 * c[1], .1 + .8 * c[2], 1.0 * visibility * f)
glTranslatef(x, 0.0, z + length)
glScalef(1,1.7,1.3)
self.renderNote(length, sustain = False, color = color, flat = False, tailOnly = False, isTappable = False, fret = 4, spNote = False, isOpen = False, spAct = True)
glPopMatrix()
self.freestyleActive = freestyleActive
#self.drumFillOnScreen = drumFillOnScreen
self.drumFillEvents = drumFillEvents
def renderTail(self, length, color, flat = False, fret = 0, freestyleTail = 0, pos = 0):
#volshebnyi - if freestyleTail == 1, render an freestyle tail
# if freestyleTail == 2, render highlighted freestyle tail
beatsPerUnit = old_div(self.beatsPerBoard, self.boardLength)
if flat:
tailscale = (1, .1, 1)
else:
tailscale = None
size = (.08, length + 0.00001)
if size[1] > self.boardLength:
s = self.boardLength
else:
s = (length + 0.00001)
# render an inactive freestyle tail (self.freestyle1 & self.freestyle2)
zsize = .25
size = (.15, s - zsize)
if self.drumFillsActive:
if self.drumFillsHits >= 4:
size = (.30, s - zsize)
if self.drumFillsHits >= 3:
size = (.25, s - zsize)
elif self.drumFillsHits >= 2:
size = (.21, s - zsize)
elif self.drumFillsHits >= 1:
size = (.17, s - zsize)
if self.freestyleActive:
size = (.30, s - zsize)
tex1 = self.freestyle1
tex2 = self.freestyle2
if freestyleTail == 1:
#glColor4f(*color)
c1, c2, c3, c4 = color
tailGlow = 1 - old_div((pos - self.freestyleLastFretHitTime[fret] ), self.freestylePeriod)
if tailGlow < 0:
tailGlow = 0
color = (c1 + c1*2.0*tailGlow, c2 + c2*2.0*tailGlow, c3 + c3*2.0*tailGlow, c4*0.6 + c4*0.4*tailGlow) #MFH - this fades inactive tails' color darker
tailcol = (color)
self.engine.draw3Dtex(tex1, vertex = (-size[0], 0, size[0], size[1]), texcoord = (0.0, 0.0, 1.0, 1.0),
scale = tailscale, color = tailcol)
self.engine.draw3Dtex(tex2, vertex = (-size[0], size[1] - (.05), size[0], size[1] + (zsize)),
scale = tailscale, texcoord = (0.0, 0.05, 1.0, 0.95), color = tailcol)
self.engine.draw3Dtex(tex2, vertex = (-size[0], 0-(zsize), size[0], 0 + (.05)),
scale = tailscale, texcoord = (0.0, 0.95, 1.0, 0.05), color = tailcol)
#myfingershurt:
def renderNote(self, length, sustain, color, flat = False, tailOnly = False, isTappable = False, big = False, fret = 0, spNote = False, isOpen = False, spAct = False):
if flat:
glScalef(1, .1, 1)
beatsPerUnit = old_div(self.beatsPerBoard, self.boardLength)
if tailOnly:
return
#myfingershurt: this should be retrieved once at init, not repeatedly in-game whenever tails are rendered.
if self.twoDnote == True:
if self.notedisappear == True:#Notes keep on going when missed
notecol = (1,1,1,1)#capo
else:
if flat:#Notes disappear when missed
notecol = (.1,.1,.1,1)
else:
notecol = (1,1,1,1)
tailOnly == True
#death_au: Adjusted for different image.
if self.separateDrumNotes:
if isOpen:
size = (self.boardWidth/1.9, (old_div(self.boardWidth,self.strings))/3.0)
texSize = (0,1)
if spNote == True:
texY = (3.0/6.0,4.0/6.0)
elif self.starPowerActive == True: #death_au: drum sp active notes.
texY = (5.0/6.0,1.0)
else:
texY = (1.0/6.0,2.0/6.0)
else:
size = (old_div(old_div(self.boardWidth,self.strings),2), old_div(old_div(self.boardWidth,self.strings),2))
fret -= 1
texSize = (fret/4.0,fret/4.0+0.25)
if spNote == True:
texY = (2.0/6.0,3.0/6.0)
elif self.starPowerActive == True: #death_au: drum sp active notes.
texY = (4.0/6.0,5.0/6.0)
else:
texY = (0.0,1.0/6.0)
else: #automatically generate drum notes from Notes.png
#myfingershurt: swapping notes 0 and 4:
if fret == 0:
#fret = 4 #fret 4 is angled, get fret 2 :)
fret = 2
elif fret == 4:
fret = 0
size = (old_div(old_div(self.boardWidth,self.strings),2), old_div(old_div(self.boardWidth,self.strings),2))
texSize = (fret/5.0,fret/5.0+0.2)
if spNote == True:
if isTappable:
texY = (0.6, 0.8)
else:
texY = (0.4,0.6)
else:
if isTappable:
texY = (0.2,0.4)
else:
texY = (0,0.2)
if self.starPowerActive:
texY = (0.8,1)
if isTappable:
texSize = (0.2,0.4)
else:
texSize = (0,0.2)
elif self.theme == 2:
size = (old_div(old_div(self.boardWidth,self.strings),2), old_div(old_div(self.boardWidth,self.strings),2))
texSize = (fret/5.0,fret/5.0+0.2)
if spNote == True:
if isTappable:
texY = (3*0.166667, 4*0.166667)
else:
texY = (2*0.166667, 3*0.166667)
else:
if isTappable:
texY = (1*0.166667, 2*0.166667)
else:
texY = (0, 1*0.166667)
#rock band fret 0 needs to be reversed just like the fret to match angles better
if fret == 0:
texSize = (fret/5.0+0.2,fret/5.0)
#myfingershurt: adding spNote==False conditional so that star notes can appear in overdrive
if self.starPowerActive and spNote == False:
if isTappable:
texY = (5*0.166667, 1)
else:
texY = (4*0.166667, 5*0.166667)
if isOpen:
size = (self.boardWidth/2.0, (old_div(self.boardWidth,self.strings))/40.0)
self.engine.draw3Dtex(self.noteButtons, vertex = (-size[0],size[1],size[0],-size[1]), texcoord = (texSize[0],texY[0],texSize[1],texY[1]),
scale = (1,1,1), multiples = True, color = color, vertscale = .2)
else:
#mesh = outer ring (black)
#mesh_001 = main note (key color)
#mesh_002 = top (spot or hopo if no mesh_003)
#mesh_003 = hopo bump (hopo color)
if fret == 0:
fret = 4 #fret 4 is angled, get fret 2 :)
#fret = 2 #compensating for this in drum.
elif fret == 4:
fret = 0
if spNote == True and self.starMesh is not None and isOpen == False:
meshObj = self.starMesh
elif isOpen == True and self.openMesh is not None:
meshObj = self.openMesh
else:
meshObj = self.noteMesh
glPushMatrix()
glEnable(GL_DEPTH_TEST)
glDepthMask(1)
glShadeModel(GL_SMOOTH)
if spNote == True and self.threeDspin == True and isOpen == False:
glRotate(90 + old_div(self.time,3), 0, 1, 0)
if isOpen == False and spNote == False and self.noterotate == True:
glRotatef(90, 0, 1, 0)
glRotatef(-90, 1, 0, 0)