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
|
{* UltraStar Deluxe - Karaoke Game
*
* UltraStar Deluxe is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*}
unit UScreenScore;
interface
{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}
{$I switches.inc}
uses
UMenu,
SDL,
SysUtils,
UDisplay,
UMusic,
USongs,
UThemes,
gl,
math,
UTexture;
const
ZBars: real = 0.8; // Z value for the bars
ZRatingPic: real = 0.8; // Z value for the rating pictures
EaseOut_MaxSteps: real = 10; // that's the speed of the bars (10 is fast | 100 is slower)
BarRaiseSpeed: cardinal = 14; // Time for raising the bar one step higher (in ms)
type
TScoreBarType = (sbtScore, sbtLine, sbtGolden);
TPlayerScoreScreenTexture = record // holds all colorized textures for up to 6 players
//Bar textures
Score_NoteBarLevel_Dark: TTexture; // Note
Score_NoteBarRound_Dark: TTexture; // that's the round thing on top
Score_NoteBarLevel_Light: TTexture; // LineBonus | Phrasebonus
Score_NoteBarRound_Light: TTexture;
Score_NoteBarLevel_Lightest: TTexture; // GoldenNotes
Score_NoteBarRound_Lightest: TTexture;
end;
TPlayerScoreScreenData = record // holds the positions and other data
Bar_Y: real;
Bar_Actual_Height: real; // this one holds the actual height of the bar, while we animate it
BarScore_ActualHeight: real;
BarLine_ActualHeight: real;
BarGolden_ActualHeight: real;
end;
TPlayerScoreRatingPics = record // a fine array of the rating pictures
RateEaseStep: integer;
RateEaseValue: real;
end;
{ hold maps of players to the different positions }
TPlayerPositionMap = record
Position: byte; // 1..6: Position of Player; 0: no position (e.g. too little screens)
Screen: byte; // 0 - Screen 1; 1 - Screen 2
BothScreens: boolean; // true if player is drawn on both screens
end;
APlayerPositionMap = array of TPlayerPositionMap;
TScreenScore = class(TMenu)
private
{ holds position and screen of players(index)
set by calling MapPlayerstoPosition() }
PlayerPositionMap: APlayerPositionMap;
BarTime: cardinal;
aPlayerScoreScreenTextures: array[1..6] of TPlayerScoreScreenTexture;
aPlayerScoreScreenDatas: array[1..6] of TPlayerScoreScreenData;
aPlayerScoreScreenRatings: array[1..6] of TPlayerScoreRatingPics;
BarScore_EaseOut_Step: real;
BarPhrase_EaseOut_Step: real;
BarGolden_EaseOut_Step: real;
TextArtist: integer;
TextTitle: integer;
TextArtistTitle: integer;
TextName: array[1..6] of integer;
TextScore: array[1..6] of integer;
TextNotes: array[1..6] of integer;
TextNotesScore: array[1..6] of integer;
TextLineBonus: array[1..6] of integer;
TextLineBonusScore: array[1..6] of integer;
TextGoldenNotes: array[1..6] of integer;
TextGoldenNotesScore: array[1..6] of integer;
TextTotal: array[1..6] of integer;
TextTotalScore: array[1..6] of integer;
PlayerStatic: array[1..6] of array of integer;
PlayerTexts: array[1..6] of array of integer;
StaticBoxLightest: array[1..6] of integer;
StaticBoxLight: array[1..6] of integer;
StaticBoxDark: array[1..6] of integer;
StaticBackLevel: array[1..6] of integer;
StaticBackLevelRound: array[1..6] of integer;
StaticLevel: array[1..6] of integer;
StaticLevelRound: array[1..6] of integer;
Animation: real;
TextScore_ActualValue: array[1..6] of integer;
TextPhrase_ActualValue: array[1..6] of integer;
TextGolden_ActualValue: array[1..6] of integer;
procedure MapPlayersToPosition;
procedure FillPlayer(Item, P: integer);
procedure FillPlayerItems(PlayerNumber: integer);
procedure UpdateAnimation;
{****
* helpers for bar easing
*}
procedure EaseBarIn(PlayerNumber: integer; BarType: TScoreBarType);
procedure EaseScoreIn(PlayerNumber: integer; ScoreType: TScoreBarType);
procedure DrawPlayerBars;
procedure DrawBar(BarType: TScoreBarType; PlayerNumber: integer; BarStartPosY: single; NewHeight: real);
{****
* helpers for rating picture
*}
procedure ShowRating(PlayerNumber: integer);
function CalculateBouncing(PlayerNumber: integer): real;
procedure DrawRating(PlayerNumber: integer; Rating: integer);
public
constructor Create; override;
function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override;
function ParseMouse(MouseButton: Integer; BtnDown: Boolean; X, Y: integer): boolean; override;
procedure OnShow; override;
procedure OnShowFinish; override;
function Draw: boolean; override;
end;
implementation
uses
UGraphic,
UScreenSong,
UMenuStatic,
UTime,
UIni,
ULog,
ULanguage,
UNote,
UUnicodeUtils;
function TScreenScore.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean;
begin
Result := true;
if (PressedDown) then
begin
// check normal keys
case UCS4UpperCase(CharCode) of
Ord('Q'):
begin
Result := false;
Exit;
end;
end;
// check special keys
case PressedKey of
SDLK_ESCAPE,
SDLK_BACKSPACE,
SDLK_RETURN:
begin
FadeTo(@ScreenTop5);
Exit;
end;
SDLK_SYSREQ:
begin
Display.SaveScreenShot;
end;
end;
end;
end;
function TScreenScore.ParseMouse(MouseButton: Integer; BtnDown: Boolean; X, Y: integer): boolean;
begin
Result := True;
if (MouseButton = SDL_BUTTON_LEFT) and BtnDown then begin
//left-click anywhere sends return
ParseInput(SDLK_RETURN, 0, true);
end;
end;
constructor TScreenScore.Create;
var
Player: integer;
Counter: integer;
begin
inherited Create;
LoadFromTheme(Theme.Score);
// These two texts arn't used in the deluxe skin
TextArtist := AddText(Theme.Score.TextArtist);
TextTitle := AddText(Theme.Score.TextTitle);
TextArtistTitle := AddText(Theme.Score.TextArtistTitle);
for Player := 1 to 6 do
begin
SetLength(PlayerStatic[Player], Length(Theme.Score.PlayerStatic[Player]));
SetLength(PlayerTexts[Player], Length(Theme.Score.PlayerTexts[Player]));
for Counter := 0 to High(Theme.Score.PlayerStatic[Player]) do
PlayerStatic[Player, Counter] := AddStatic(Theme.Score.PlayerStatic[Player, Counter]);
for Counter := 0 to High(Theme.Score.PlayerTexts[Player]) do
PlayerTexts[Player, Counter] := AddText(Theme.Score.PlayerTexts[Player, Counter]);
TextName[Player] := AddText(Theme.Score.TextName[Player]);
TextScore[Player] := AddText(Theme.Score.TextScore[Player]);
TextNotes[Player] := AddText(Theme.Score.TextNotes[Player]);
TextNotesScore[Player] := AddText(Theme.Score.TextNotesScore[Player]);
TextLineBonus[Player] := AddText(Theme.Score.TextLineBonus[Player]);
TextLineBonusScore[Player] := AddText(Theme.Score.TextLineBonusScore[Player]);
TextGoldenNotes[Player] := AddText(Theme.Score.TextGoldenNotes[Player]);
TextGoldenNotesScore[Player] := AddText(Theme.Score.TextGoldenNotesScore[Player]);
TextTotal[Player] := AddText(Theme.Score.TextTotal[Player]);
TextTotalScore[Player] := AddText(Theme.Score.TextTotalScore[Player]);
StaticBoxLightest[Player] := AddStatic(Theme.Score.StaticBoxLightest[Player]);
StaticBoxLight[Player] := AddStatic(Theme.Score.StaticBoxLight[Player]);
StaticBoxDark[Player] := AddStatic(Theme.Score.StaticBoxDark[Player]);
StaticBackLevel[Player] := AddStatic(Theme.Score.StaticBackLevel[Player]);
StaticBackLevelRound[Player] := AddStatic(Theme.Score.StaticBackLevelRound[Player]);
StaticLevel[Player] := AddStatic(Theme.Score.StaticLevel[Player]);
StaticLevelRound[Player] := AddStatic(Theme.Score.StaticLevelRound[Player]);
//textures
aPlayerScoreScreenTextures[Player].Score_NoteBarLevel_Dark := Tex_Score_NoteBarLevel_Dark[Player];
aPlayerScoreScreenTextures[Player].Score_NoteBarRound_Dark := Tex_Score_NoteBarRound_Dark[Player];
aPlayerScoreScreenTextures[Player].Score_NoteBarLevel_Light := Tex_Score_NoteBarLevel_Light[Player];
aPlayerScoreScreenTextures[Player].Score_NoteBarRound_Light := Tex_Score_NoteBarRound_Light[Player];
aPlayerScoreScreenTextures[Player].Score_NoteBarLevel_Lightest := Tex_Score_NoteBarLevel_Lightest[Player];
aPlayerScoreScreenTextures[Player].Score_NoteBarRound_Lightest := Tex_Score_NoteBarRound_Lightest[Player];
end;
end;
procedure TScreenScore.MapPlayersToPosition;
var
ArrayStartModifier: integer;
PlayersPerScreen: integer;
I: integer;
begin
// all statics / texts are loaded at start - so that we have them all even if we change the amount of players
// To show the corrects statics / text from the them, we simply modify the start of the according arrays
// 1 Player -> Player[0].Score (The score for one player starts at 0)
// -> Statics[1] (The statics for the one player screen start at 1)
// 2 Player -> Player[0..1].Score
// -> Statics[2..3]
// 3 Player -> Player[0..5].Score
// -> Statics[4..6]
case PlayersPlay of
1: ArrayStartModifier := 1;
2, 4: ArrayStartModifier := 2;
3, 6: ArrayStartModifier := 4;
else
ArrayStartModifier := 0; //this should never happen
end;
if (PlayersPlay <= 3) then
PlayersPerScreen := PlayersPlay
else
PlayersPerScreen := PlayersPlay div 2;
SetLength(PlayerPositionMap, PlayersPlay);
// actually map players to positions
for I := 0 to PlayersPlay - 1 do
begin
PlayerPositionMap[I].Screen := (I div PlayersPerScreen) + 1;
if (PlayerPositionMap[I].Screen > Screens) then
PlayerPositionMap[I].Position := 0
else
PlayerPositionMap[I].Position := ArrayStartModifier + (I mod PlayersPerScreen);
PlayerPositionMap[I].BothScreens := (PlayersPlay <= 3) and (Screens > 1);
end;
end;
procedure TScreenScore.UpdateAnimation;
var
CurrentTime: integer;
I: integer;
begin
CurrentTime := SDL_GetTicks();
if (ScreenAct = 1) and ((CurrentTime >= BarTime) and ShowFinish) then
begin
BarTime := CurrentTime + BarRaiseSpeed;
// We actually arise them in the right order, but we have to draw them in reverse order (golden -> phrase -> mainscore)
if (BarScore_EaseOut_Step < EaseOut_MaxSteps * 10) then
BarScore_EaseOut_Step:= BarScore_EaseOut_Step + 1
// PhrasenBonus
else if (BarPhrase_EaseOut_Step < EaseOut_MaxSteps * 10) then
BarPhrase_EaseOut_Step := BarPhrase_EaseOut_Step + 1
// GoldenNotebonus
else if (BarGolden_EaseOut_Step < EaseOut_MaxSteps * 10) then
BarGolden_EaseOut_Step := BarGolden_EaseOut_Step + 1;
end;
end;
procedure TScreenScore.DrawPlayerBars;
var
I: integer;
begin
for I := 0 to PlayersPlay-1 do
begin
if (PlayerPositionMap[I].Position > 0) and ((ScreenAct = PlayerPositionMap[I].Screen) or (PlayerPositionMap[I].BothScreens)) then
begin
if (BarScore_EaseOut_Step >= (EaseOut_MaxSteps * 10)) then
begin
if (BarPhrase_EaseOut_Step >= (EaseOut_MaxSteps * 10)) then
begin
// Draw golden score bar #
EaseBarIn(I + 1, sbtGolden);
EaseScoreIn(I + 1, sbtGolden);
end;
// Draw phrase score bar #
EaseBarIn(I + 1, sbtLine);
EaseScoreIn(I + 1, sbtLine);
end;
// Draw plain score bar #
EaseBarIn(I + 1, sbtScore);
EaseScoreIn(I + 1, sbtScore);
end;
end;
end;
procedure TScreenScore.OnShow;
var
P: integer; // player
I: integer;
V: array[1..6] of boolean; // visibility array
begin
{**
* Turn backgroundmusic on
*}
SoundLib.StartBgMusic;
inherited;
MapPlayersToPosition;
for P := 1 to PlayersPlay do
begin
// data
aPlayerScoreScreenDatas[P].Bar_Y := Theme.Score.StaticBackLevel[PlayerPositionMap[P-1].Position].Y;
// ratings
aPlayerScoreScreenRatings[P].RateEaseStep := 1;
aPlayerScoreScreenRatings[P].RateEaseValue := 20;
// actual values
TextScore_ActualValue[P] := 0;
TextPhrase_ActualValue[P] := 0;
TextGolden_ActualValue[P] := 0;
end;
Text[TextArtist].Text := CurrentSong.Artist;
Text[TextTitle].Text := CurrentSong.Title;
Text[TextArtistTitle].Text := CurrentSong.Artist + ' - ' + CurrentSong.Title;
// set visibility
case PlayersPlay of
1: begin
V[1] := true;
V[2] := false;
V[3] := false;
V[4] := false;
V[5] := false;
V[6] := false;
end;
2, 4: begin
V[1] := false;
V[2] := true;
V[3] := true;
V[4] := false;
V[5] := false;
V[6] := false;
end;
3, 6: begin
V[1] := false;
V[2] := false;
V[3] := false;
V[4] := true;
V[5] := true;
V[6] := true;
end;
end;
for P := 1 to 6 do
begin
Text[TextName[P]].Visible := V[P];
Text[TextScore[P]].Visible := V[P];
// We set alpha to 0 , so we can nicely blend them in when we need them
Text[TextScore[P]].Alpha := 0;
Text[TextNotesScore[P]].Alpha := 0;
Text[TextNotes[P]].Alpha := 0;
Text[TextLineBonus[P]].Alpha := 0;
Text[TextLineBonusScore[P]].Alpha := 0;
Text[TextGoldenNotes[P]].Alpha := 0;
Text[TextGoldenNotesScore[P]].Alpha := 0;
Text[TextTotal[P]].Alpha := 0;
Text[TextTotalScore[P]].Alpha := 0;
Static[StaticBoxLightest[P]].Texture.Alpha := 0;
Static[StaticBoxLight[P]].Texture.Alpha := 0;
Static[StaticBoxDark[P]].Texture.Alpha := 0;
Text[TextNotes[P]].Visible := V[P];
Text[TextNotesScore[P]].Visible := V[P];
Text[TextLineBonus[P]].Visible := V[P];
Text[TextLineBonusScore[P]].Visible := V[P];
Text[TextGoldenNotes[P]].Visible := V[P];
Text[TextGoldenNotesScore[P]].Visible := V[P];
Text[TextTotal[P]].Visible := V[P];
Text[TextTotalScore[P]].Visible := V[P];
for I := 0 to high(PlayerStatic[P]) do
Static[PlayerStatic[P, I]].Visible := V[P];
for I := 0 to high(PlayerTexts[P]) do
Text[PlayerTexts[P, I]].Visible := V[P];
Static[StaticBoxLightest[P]].Visible := V[P];
Static[StaticBoxLight[P]].Visible := V[P];
Static[StaticBoxDark[P]].Visible := V[P];
// we draw that on our own
Static[StaticBackLevel[P]].Visible := false;
Static[StaticBackLevelRound[P]].Visible := false;
Static[StaticLevel[P]].Visible := false;
Static[StaticLevelRound[P]].Visible := false;
end;
BarScore_EaseOut_Step := 1;
BarPhrase_EaseOut_Step := 1;
BarGolden_EaseOut_Step := 1;
end;
procedure TScreenScore.onShowFinish;
var
index: integer;
begin
for index := 1 to (PlayersPlay) do
begin
TextScore_ActualValue[index] := 0;
TextPhrase_ActualValue[index] := 0;
TextGolden_ActualValue[index] := 0;
end;
end;
function TScreenScore.Draw: boolean;
var
CurrentTime: cardinal;
PlayerCounter: integer;
PStart: integer;
PHigh: integer;
begin
{*
player[0].ScoreInt := 7000;
player[0].ScoreLineInt := 2000;
player[0].ScoreGoldenInt := 1000;
player[0].ScoreTotalInt := 10000;
player[1].ScoreInt := 2500;
player[1].ScoreLineInt := 1100;
player[1].ScoreGoldenInt := 900;
player[1].ScoreTotalInt := 4500;
//*}
//Draw the Background
DrawBG;
// Let's start to arise the bars
UpdateAnimation;
// we have to swap the themeobjects values on every draw
// to support dual screen
for PlayerCounter := 1 to PlayersPlay do
begin
FillPlayerItems(PlayerCounter);
end;
if (ShowFinish) then
DrawPlayerBars;
//Draw Theme Objects
DrawFG;
(*
//todo: i need a clever method to draw statics with their z value
for I := 0 to Length(Static) - 1 do
Static[I].Draw;
for I := 0 to Length(Text) - 1 do
Text[I].Draw;
*)
Result := true;
end;
procedure TscreenScore.FillPlayerItems(PlayerNumber: integer);
var
ThemeIndex: integer;
begin
ThemeIndex := PlayerPositionMap[PlayerNumber-1].Position;
if (ThemeIndex > 0) and ((ScreenAct = PlayerPositionMap[PlayerNumber-1].Screen) or (PlayerPositionMap[PlayerNumber-1].BothScreens)) then
begin
// todo: take the name from player[PlayerNumber].Name instead of the ini when this is done (mog)
Text[TextName[ThemeIndex]].Text := Ini.Name[PlayerNumber-1];
// end todo
//golden
Text[TextGoldenNotesScore[ThemeIndex]].Text := IntToStr(TextGolden_ActualValue[PlayerNumber]);
Text[TextGoldenNotesScore[ThemeIndex]].Alpha := (BarGolden_EaseOut_Step / 100);
Static[StaticBoxLightest[ThemeIndex]].Texture.Alpha := (BarGolden_EaseOut_Step / 100);
Text[TextGoldenNotes[ThemeIndex]].Alpha := (BarGolden_EaseOut_Step / 100);
// line bonus
Text[TextLineBonusScore[ThemeIndex]].Text := IntToStr(TextPhrase_ActualValue[PlayerNumber]);
Text[TextLineBonusScore[ThemeIndex]].Alpha := (BarPhrase_EaseOut_Step / 100);
Static[StaticBoxLight[ThemeIndex]].Texture.Alpha := (BarPhrase_EaseOut_Step / 100);
Text[TextLineBonus[ThemeIndex]].Alpha := (BarPhrase_EaseOut_Step / 100);
// plain score
Text[TextNotesScore[ThemeIndex]].Text := IntToStr(TextScore_ActualValue[PlayerNumber]);
Text[TextNotes[ThemeIndex]].Alpha := (BarScore_EaseOut_Step / 100);
Static[StaticBoxDark[ThemeIndex]].Texture.Alpha := (BarScore_EaseOut_Step / 100);
Text[TextNotesScore[ThemeIndex]].Alpha := (BarScore_EaseOut_Step / 100);
// total score
Text[TextTotalScore[ThemeIndex]].Text := IntToStr(TextScore_ActualValue[PlayerNumber] + TextPhrase_ActualValue[PlayerNumber] + TextGolden_ActualValue[PlayerNumber]);
Text[TextTotalScore[ThemeIndex]].Alpha := (BarScore_EaseOut_Step / 100);
Text[TextTotal[ThemeIndex]].Alpha := (BarScore_EaseOut_Step / 100);
if(BarGolden_EaseOut_Step = 100) then
begin
ShowRating(PlayerNumber);
end;
end;
end;
procedure TScreenScore.ShowRating(PlayerNumber: integer);
var
Rating: integer;
ThemeIndex: integer;
begin
ThemeIndex := PlayerPositionMap[PlayerNumber-1].Position;
if (ThemeIndex > 0) and ((ScreenAct = PlayerPositionMap[PlayerNumber-1].Screen) or (PlayerPositionMap[PlayerNumber-1].BothScreens)) then
begin
case (Player[PlayerNumber-1].ScoreTotalInt) of
0..2009:
begin
Text[TextScore[ThemeIndex]].Text := Language.Translate('SING_SCORE_TONE_DEAF');
Rating := 0;
end;
2010..4009:
begin
Text[TextScore[ThemeIndex]].Text := Language.Translate('SING_SCORE_AMATEUR');
Rating := 1;
end;
4010..5009:
begin
Text[TextScore[ThemeIndex]].Text := Language.Translate('SING_SCORE_WANNABE');
Rating := 2;
end;
5010..6009:
begin
Text[TextScore[ThemeIndex]].Text := Language.Translate('SING_SCORE_HOPEFUL');
Rating := 3;
end;
6010..7509:
begin
Text[TextScore[ThemeIndex]].Text := Language.Translate('SING_SCORE_RISING_STAR');
Rating := 4;
end;
7510..8509:
begin
Text[TextScore[ThemeIndex]].Text := Language.Translate('SING_SCORE_LEAD_SINGER');
Rating := 5;
end;
8510..9009:
begin
Text[TextScore[ThemeIndex]].Text := Language.Translate('SING_SCORE_SUPERSTAR');
Rating := 6;
end;
9010..10000:
begin
Text[TextScore[ThemeIndex]].Text := Language.Translate('SING_SCORE_ULTRASTAR');
Rating := 7;
end;
else
Rating := 0; // Cheata :P
end;
//todo: this could break if the width is not given, for instance when there's a skin with no picture for ratings
if ( Theme.Score.StaticRatings[ThemeIndex].W > 0 ) and ( aPlayerScoreScreenRatings[PlayerNumber].RateEaseValue > 0 ) then
begin
Text[TextScore[ThemeIndex]].Alpha := aPlayerScoreScreenRatings[PlayerNumber].RateEaseValue / Theme.Score.StaticRatings[ThemeIndex].W;
end;
// end todo
DrawRating(PlayerNumber, Rating);
end;
end;
procedure TscreenScore.DrawRating(PlayerNumber: integer; Rating: integer);
var
Posx: real;
Posy: real;
Width: real;
ThemeIndex: integer;
begin
ThemeIndex := PlayerPositionMap[PlayerNumber-1].Position;
CalculateBouncing(PlayerNumber);
PosX := Theme.Score.StaticRatings[ThemeIndex].X + (Theme.Score.StaticRatings[ThemeIndex].W * 0.5);
PosY := Theme.Score.StaticRatings[ThemeIndex].Y + (Theme.Score.StaticRatings[ThemeIndex].H * 0.5); ;
Width := aPlayerScoreScreenRatings[PlayerNumber].RateEaseValue/2;
glBindTexture(GL_TEXTURE_2D, Tex_Score_Ratings[Rating].TexNum);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(PosX - Width, PosY - Width);
glTexCoord2f(Tex_Score_Ratings[Rating].TexW, 0); glVertex2f(PosX + Width, PosY - Width);
glTexCoord2f(Tex_Score_Ratings[Rating].TexW, Tex_Score_Ratings[Rating].TexH); glVertex2f(PosX + Width, PosY + Width);
glTexCoord2f(0, Tex_Score_Ratings[Rating].TexH); glVertex2f(PosX - Width, PosY + Width);
glEnd;
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2d);
end;
function TscreenScore.CalculateBouncing(PlayerNumber: integer): real;
var
p, s: real;
RaiseStep, MaxVal: real;
EaseOut_Step: integer;
ThemeIndex: integer;
begin
ThemeIndex := PlayerPositionMap[PlayerNumber-1].Position;
EaseOut_Step := aPlayerScoreScreenRatings[PlayerNumber].RateEaseStep;
MaxVal := Theme.Score.StaticRatings[ThemeIndex].W;
RaiseStep := EaseOut_Step;
if (MaxVal > 0) and (RaiseStep > 0) then
RaiseStep := RaiseStep / MaxVal;
if (RaiseStep = 1) then
begin
Result := MaxVal;
end
else
begin
p := MaxVal * 0.4;
s := p/(2*PI) * arcsin (1);
Result := MaxVal * power(2,-5 * RaiseStep) * sin( (RaiseStep * MaxVal - s) * (2 * PI) / p) + MaxVal;
inc(aPlayerScoreScreenRatings[PlayerNumber].RateEaseStep);
aPlayerScoreScreenRatings[PlayerNumber].RateEaseValue := Result;
end;
end;
procedure TscreenScore.EaseBarIn(PlayerNumber: integer; BarType: TScoreBarType);
const
RaiseSmoothness: integer = 100;
var
MaxHeight: real;
NewHeight: real;
Height2Reach: real;
RaiseStep: real;
BarStartPosY: single;
lTmp: real;
Score: integer;
ThemeIndex: integer;
begin
ThemeIndex := PlayerPositionMap[PlayerNumber-1].Position;
MaxHeight := Theme.Score.StaticBackLevel[ThemeIndex].H;
// let's get the points according to the bar we draw
// score array starts at 0, which means the score for player 1 is in score[0]
// EaseOut_Step is the actual step in the raising process, like the 20iest step of EaseOut_MaxSteps
if (BarType = sbtScore) then
begin
Score := Player[PlayerNumber - 1].ScoreInt;
RaiseStep := BarScore_EaseOut_Step;
BarStartPosY := Theme.Score.StaticBackLevel[ThemeIndex].Y + MaxHeight;
end
else if (BarType = sbtLine) then
begin
Score := Player[PlayerNumber - 1].ScoreLineInt;
RaiseStep := BarPhrase_EaseOut_Step;
BarStartPosY := Theme.Score.StaticBackLevel[ThemeIndex].Y - aPlayerScoreScreenDatas[PlayerNumber].BarScore_ActualHeight + MaxHeight;
end
else if (BarType = sbtGolden) then
begin
Score := Player[PlayerNumber - 1].ScoreGoldenInt;
RaiseStep := BarGolden_EaseOut_Step;
BarStartPosY := Theme.Score.StaticBackLevel[ThemeIndex].Y - aPlayerScoreScreenDatas[PlayerNumber].BarScore_ActualHeight - aPlayerScoreScreenDatas[PlayerNumber].BarLine_ActualHeight + MaxHeight;
end;
// the height dependend of the score
Height2Reach := (Score / MAX_SONG_SCORE) * MaxHeight;
if (aPlayerScoreScreenDatas[PlayerNumber].Bar_Actual_Height < Height2Reach) then
begin
// Check http://proto.layer51.com/d.aspx?f=400 for more info on easing functions
// Calculate the actual step according to the maxsteps
RaiseStep := RaiseStep / EaseOut_MaxSteps;
// quadratic easing out - decelerating to zero velocity
// -end_position * current_time * ( current_time - 2 ) + start_postion
lTmp := (-Height2Reach * RaiseStep * (RaiseStep - 20) + BarStartPosY);
if ( RaiseSmoothness > 0 ) and ( lTmp > 0 ) then
NewHeight := lTmp / RaiseSmoothness;
end
else
NewHeight := Height2Reach;
DrawBar(BarType, PlayerNumber, BarStartPosY, NewHeight);
if (BarType = sbtScore) then
aPlayerScoreScreenDatas[PlayerNumber].BarScore_ActualHeight := NewHeight
else if (BarType = sbtLine) then
aPlayerScoreScreenDatas[PlayerNumber].BarLine_ActualHeight := NewHeight
else if (BarType = sbtGolden) then
aPlayerScoreScreenDatas[PlayerNumber].BarGolden_ActualHeight := NewHeight;
end;
procedure TscreenScore.DrawBar(BarType: TScoreBarType; PlayerNumber: integer; BarStartPosY: single; NewHeight: real);
var
Width: real;
BarStartPosX: real;
ThemeIndex: integer;
begin
ThemeIndex := PlayerPositionMap[PlayerNumber-1].Position;
// this is solely for better readability of the drawing
Width := Theme.Score.StaticBackLevel[ThemeIndex].W;
BarStartPosX := Theme.Score.StaticBackLevel[ThemeIndex].X;
glColor4f(1, 1, 1, 1);
// set the texture for the bar
if (BarType = sbtScore) then
glBindTexture(GL_TEXTURE_2D, aPlayerScoreScreenTextures[PlayerNumber].Score_NoteBarLevel_Dark.TexNum);
if (BarType = sbtLine) then
glBindTexture(GL_TEXTURE_2D, aPlayerScoreScreenTextures[PlayerNumber].Score_NoteBarLevel_Light.TexNum);
if (BarType = sbtGolden) then
glBindTexture(GL_TEXTURE_2D, aPlayerScoreScreenTextures[PlayerNumber].Score_NoteBarLevel_Lightest.TexNum);
//draw it
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex3f(BarStartPosX, BarStartPosY - NewHeight, ZBars);
glTexCoord2f(1, 0); glVertex3f(BarStartPosX + Width, BarStartPosY - NewHeight, ZBars);
glTexCoord2f(1, 1); glVertex3f(BarStartPosX + Width, BarStartPosY, ZBars);
glTexCoord2f(0, 1); glVertex3f(BarStartPosX, BarStartPosY, ZBars);
glEnd;
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2d);
//the round thing on top
if (BarType = sbtScore) then
glBindTexture(GL_TEXTURE_2D, aPlayerScoreScreenTextures[PlayerNumber].Score_NoteBarRound_Dark.TexNum);
if (BarType = sbtLine) then
glBindTexture(GL_TEXTURE_2D, aPlayerScoreScreenTextures[PlayerNumber].Score_NoteBarRound_Light.TexNum);
if (BarType = sbtGolden) then
glBindTexture(GL_TEXTURE_2D, aPlayerScoreScreenTextures[PlayerNumber].Score_NoteBarRound_Lightest.TexNum);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex3f(BarStartPosX, (BarStartPosY - Static[StaticLevelRound[ThemeIndex]].Texture.h) - NewHeight, ZBars);
glTexCoord2f(1, 0); glVertex3f(BarStartPosX + Width, (BarStartPosY - Static[StaticLevelRound[ThemeIndex]].Texture.h) - NewHeight, ZBars);
glTexCoord2f(1, 1); glVertex3f(BarStartPosX + Width, BarStartPosY - NewHeight, ZBars);
glTexCoord2f(0, 1); glVertex3f(BarStartPosX, BarStartPosY - NewHeight, ZBars);
glEnd;
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2d);
end;
procedure TScreenScore.EaseScoreIn(PlayerNumber: integer; ScoreType: TScoreBarType);
const
RaiseSmoothness: integer = 100;
var
RaiseStep: real;
lTmpA: real;
ScoreReached: integer;
EaseOut_Step: real;
ActualScoreValue: integer;
begin
if (ScoreType = sbtScore) then
begin
EaseOut_Step := BarScore_EaseOut_Step;
ActualScoreValue := TextScore_ActualValue[PlayerNumber];
ScoreReached := Player[PlayerNumber-1].ScoreInt;
end;
if (ScoreType = sbtLine) then
begin
EaseOut_Step := BarPhrase_EaseOut_Step;
ActualScoreValue := TextPhrase_ActualValue[PlayerNumber];
ScoreReached := Player[PlayerNumber-1].ScoreLineInt;
end;
if (ScoreType = sbtGolden) then
begin
EaseOut_Step := BarGolden_EaseOut_Step;
ActualScoreValue := TextGolden_ActualValue[PlayerNumber];
ScoreReached := Player[PlayerNumber-1].ScoreGoldenInt;
end;
// EaseOut_Step is the actual step in the raising process, like the 20iest step of EaseOut_MaxSteps
RaiseStep := EaseOut_Step;
if (ActualScoreValue < ScoreReached) then
begin
// Calculate the actual step according to the maxsteps
RaiseStep := RaiseStep / EaseOut_MaxSteps;
// quadratic easing out - decelerating to zero velocity
// -end_position * current_time * ( current_time - 2 ) + start_postion
lTmpA := (-ScoreReached * RaiseStep * (RaiseStep - 20));
if ( lTmpA > 0 ) and
( RaiseSmoothness > 0 ) then
begin
if (ScoreType = sbtScore) then
TextScore_ActualValue[PlayerNumber] := floor( lTmpA / RaiseSmoothness);
if (ScoreType = sbtLine) then
TextPhrase_ActualValue[PlayerNumber] := floor( lTmpA / RaiseSmoothness);
if (ScoreType = sbtGolden) then
TextGolden_ActualValue[PlayerNumber] := floor( lTmpA / RaiseSmoothness);
end;
end
else
begin
if (ScoreType = sbtScore) then
TextScore_ActualValue[PlayerNumber] := ScoreReached;
if (ScoreType = sbtLine) then
TextPhrase_ActualValue[PlayerNumber] := ScoreReached;
if (ScoreType = sbtGolden) then
TextGolden_ActualValue[PlayerNumber] := ScoreReached;
end;
end;
procedure TScreenScore.FillPlayer(Item, P: integer);
var
S: string;
begin
Text[TextName[Item]].Text := Ini.Name[P];
S := IntToStr((Round(Player[P].Score) div 10) * 10);
while (Length(S)<4) do
S := '0' + S;
Text[TextNotesScore[Item]].Text := S;
// while (Length(S)<5) do S := '0' + S;
// Text[TextTotalScore[Item]].Text := S;
//fixed: line bonus and golden notes don't show up,
// another bug: total score was shown without added golden-, linebonus
S := IntToStr(Player[P].ScoreTotalInt);
while (Length(S)<5) do
S := '0' + S;
Text[TextTotalScore[Item]].Text := S;
S := IntToStr(Player[P].ScoreLineInt);
while (Length(S)<4) do
S := '0' + S;
Text[TextLineBonusScore[Item]].Text := S;
S := IntToStr(Player[P].ScoreGoldenInt);
while (Length(S)<4) do
S := '0' + S;
Text[TextGoldenNotesScore[Item]].Text := S;
//end of fix
end;
end.
|