From 278ff525686374c51d542e608ee612da8cdaec6d Mon Sep 17 00:00:00 2001 From: tobigun Date: Sat, 7 Jun 2008 18:43:58 +0000 Subject: just some cleanup - replaced many German and Polish comments - replaced many cryptic var-names - IlNut replaced with LengthNote - renamed the global var "Filename" to "ConversionFilename" to prevent unintended use of it - more readable code (hopefully), especially NewNote and OnSentenceEnd - added some comments on elementary classes/records and their fields git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1137 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditConvert.pas | 8 +- Game/Code/Screens/UScreenEditHeader.pas | 2 +- Game/Code/Screens/UScreenOpen.pas | 8 +- Game/Code/Screens/UScreenScore.pas | 40 +-- Game/Code/Screens/UScreenSing.pas | 345 +++++++++--------- Game/Code/Screens/UScreenSingModi.pas | 43 ++- Game/Code/Screens/UScreenSong.pas | 593 ++++++++++++++++--------------- Game/Code/Screens/UScreenTop5.pas | 2 +- 8 files changed, 537 insertions(+), 504 deletions(-) (limited to 'Game/Code/Screens') diff --git a/Game/Code/Screens/UScreenEditConvert.pas b/Game/Code/Screens/UScreenEditConvert.pas index 7527dc68..a57e89fb 100644 --- a/Game/Code/Screens/UScreenEditConvert.pas +++ b/Game/Code/Screens/UScreenEditConvert.pas @@ -165,7 +165,7 @@ begin if Interaction = 3 then begin if SelectedNumber > 0 then begin Extract; - SaveSong(Song, Lines, ChangeFileExt(FileName, '.txt'), false); + SaveSong(Song, Lines, ChangeFileExt(ConversionFileName, '.txt'), false); end; end; @@ -396,7 +396,7 @@ begin MidiOut.Open; // MidiOut.SetVolume(100, 100); // temporary} - FileName := GamePath + 'file.mid'; + ConversionFileName := GamePath + 'file.mid'; {$IFDEF UseMIDIPort} MidiFile := TMidiFile.Create(nil); {$ENDIF} @@ -426,9 +426,9 @@ begin MidiOut.Open; - if FileExists(FileName) then + if FileExists(ConversionFileName) then begin - MidiFile.Filename := FileName; + MidiFile.Filename := ConversionFileName; MidiFile.ReadFile; diff --git a/Game/Code/Screens/UScreenEditHeader.pas b/Game/Code/Screens/UScreenEditHeader.pas index 9c6ebc8b..2bba36cd 100644 --- a/Game/Code/Screens/UScreenEditHeader.pas +++ b/Game/Code/Screens/UScreenEditHeader.pas @@ -275,7 +275,7 @@ begin end; // if PlaySentence Text[TextSentence].Text := IntToStr(Czesci[0].Akt + 1) + ' / ' + IntToStr(Czesci[0].Ilosc); - Text[TextNote].Text := IntToStr(AktNuta + 1) + ' / ' + IntToStr(Czesci[0].Czesc[Czesci[0].Akt].IlNut); + Text[TextNote].Text := IntToStr(AktNuta + 1) + ' / ' + IntToStr(Czesci[0].Czesc[Czesci[0].Akt].LengthNote); // Song info Text[TextBPM].Text := FloatToStr(CurrentSong.BPM[0].BPM / 4); diff --git a/Game/Code/Screens/UScreenOpen.pas b/Game/Code/Screens/UScreenOpen.pas index e409812c..7dbe8743 100644 --- a/Game/Code/Screens/UScreenOpen.pas +++ b/Game/Code/Screens/UScreenOpen.pas @@ -61,7 +61,7 @@ begin SDLK_ESCAPE : begin //Empty Filename and go to last Screen - FileName := ''; + ConversionFileName := ''; AudioPlayback.PlaySound(SoundLib.Back); FadeTo(BackScreen); end; @@ -70,14 +70,14 @@ begin begin if (Interaction = 2) then begin //Update Filename and go to last Screen - FileName := Text[TextN].Text; + ConversionFileName := Text[TextN].Text; AudioPlayback.PlaySound(SoundLib.Back); FadeTo(BackScreen); end else if (Interaction = 1) then begin //Empty Filename and go to last Screen - FileName := ''; + ConversionFileName := ''; AudioPlayback.PlaySound(SoundLib.Back); FadeTo(BackScreen); end; @@ -127,7 +127,7 @@ begin // file name AddBox(20, 540, 500, 40); - TextN := AddText(50, 548, 0, 8, 0, 0, 0, FileName); + TextN := AddText(50, 548, 0, 8, 0, 0, 0, ConversionFileName); AddInteraction(iText, TextN); // buttons diff --git a/Game/Code/Screens/UScreenScore.pas b/Game/Code/Screens/UScreenScore.pas index 606d8366..b47c43f1 100644 --- a/Game/Code/Screens/UScreenScore.pas +++ b/Game/Code/Screens/UScreenScore.pas @@ -367,15 +367,15 @@ begin inherited Draw; {* - player[0].ScoreI := 7000; - player[0].ScoreLineI := 2000; - player[0].ScoreGoldenI := 1000; - player[0].ScoreTotalI := 10000; - - player[1].ScoreI := 2500; - player[1].ScoreLineI := 1100; - player[1].ScoreGoldenI := 900; - player[1].ScoreTotalI := 4500; + 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; *} // Let's start to arise the bars CurrentTime := SDL_GetTicks(); @@ -486,7 +486,7 @@ begin ThemeIndex := PlayerNumber + ArrayStartModifier; - case (Player[PlayerNumber-1].ScoreTotalI) of + case (Player[PlayerNumber-1].ScoreTotalInt) of 0..2009: begin Text[TextScore[ThemeIndex]].Text := Language.Translate('SING_SCORE_TONE_DEAF'); @@ -633,25 +633,25 @@ begin // EaseOut_Step is the actual step in the raising process, like the 20iest step of EaseOut_MaxSteps if (BarType = 'Note') then begin - Score := Player[PlayerNumber - 1].ScoreI; + Score := Player[PlayerNumber - 1].ScoreInt; RaiseStep := BarScore_EaseOut_Step; BarStartPosY := Theme.Score.StaticBackLevel[PlayerNumber + ArrayStartModifier].Y + MaxHeight; end; if (BarType = 'Line') then begin - Score := Player[PlayerNumber - 1].ScoreLineI; + Score := Player[PlayerNumber - 1].ScoreLineInt; RaiseStep := BarPhrase_EaseOut_Step; BarStartPosY := Theme.Score.StaticBackLevel[PlayerNumber + ArrayStartModifier].Y - aPlayerScoreScreenDatas[PlayerNumber].BarScore_ActualHeight + MaxHeight; end; if (BarType = 'Golden') then begin - Score := Player[PlayerNumber - 1].ScoreGoldenI; + Score := Player[PlayerNumber - 1].ScoreGoldenInt; RaiseStep := BarGolden_EaseOut_Step; BarStartPosY := Theme.Score.StaticBackLevel[PlayerNumber + ArrayStartModifier].Y - aPlayerScoreScreenDatas[PlayerNumber].BarScore_ActualHeight - aPlayerScoreScreenDatas[PlayerNumber].BarLine_ActualHeight + MaxHeight; end; // the height dependend of the score - Height2Reach := (Score / 10000) * MaxHeight; + Height2Reach := (Score / MAX_SONG_SCORE) * MaxHeight; if (aPlayerScoreScreenDatas[PlayerNumber].Bar_Actual_Height < Height2Reach) then begin @@ -751,19 +751,19 @@ begin begin EaseOut_Step := BarScore_EaseOut_Step; ActualScoreValue := TextScore_ActualValue[PlayerNumber]; - ScoreReached := Player[PlayerNumber-1].ScoreI; + ScoreReached := Player[PlayerNumber-1].ScoreInt; end; if (ScoreType = 'Line') then begin EaseOut_Step := BarPhrase_EaseOut_Step; ActualScoreValue := TextPhrase_ActualValue[PlayerNumber]; - ScoreReached := Player[PlayerNumber-1].ScoreLineI; + ScoreReached := Player[PlayerNumber-1].ScoreLineInt; end; if (ScoreType = 'Golden') then begin EaseOut_Step := BarGolden_EaseOut_Step; ActualScoreValue := TextGolden_ActualValue[PlayerNumber]; - ScoreReached := Player[PlayerNumber-1].ScoreGoldenI; + ScoreReached := Player[PlayerNumber-1].ScoreGoldenInt; end; // EaseOut_Step is the actual step in the raising process, like the 20iest step of EaseOut_MaxSteps @@ -815,17 +815,17 @@ begin //fixed: line bonus and golden notes don't show up, // another bug: total score was shown without added golden-, linebonus - S := IntToStr(Player[P].ScoreTotalI); + S := IntToStr(Player[P].ScoreTotalInt); while (Length(S)<5) do S := '0' + S; Text[TextTotalScore[Item]].Text := S; - S := IntToStr(Player[P].ScoreLineI); + S := IntToStr(Player[P].ScoreLineInt); while (Length(S)<4) do S := '0' + S; Text[TextLineBonusScore[Item]].Text := S; - S := IntToStr(Player[P].ScoreGoldenI); + S := IntToStr(Player[P].ScoreGoldenInt); while (Length(S)<4) do S := '0' + S; Text[TextGoldenNotesScore[Item]].Text := S; diff --git a/Game/Code/Screens/UScreenSing.pas b/Game/Code/Screens/UScreenSing.pas index c97bc691..ad07a081 100644 --- a/Game/Code/Screens/UScreenSing.pas +++ b/Game/Code/Screens/UScreenSing.pas @@ -35,10 +35,9 @@ type public //TextTime: integer; - //TimeBar mod - StaticTimeProgress: integer; - TextTimeText: integer; - //eoa TimeBar mod + // TimeBar fields + StaticTimeProgress: integer; + TextTimeText: integer; StaticP1: integer; TextP1: integer; @@ -90,8 +89,8 @@ type Tex_Background: TTexture; FadeOut: boolean; -// LyricMain: TLyric; -// LyricSub: TLyric; + //LyricMain: TLyric; + //LyricSub: TLyric; Lyrics: TLyricEngine; //Score Manager: @@ -111,8 +110,8 @@ type //procedure UpdateLCD; //TODO: maybe LCD Support as Plugin? procedure Pause; //Pause Mod(Toggles Pause) - procedure onSentenceEnd(S: Cardinal); //OnSentenceEnd for LineBonus + Singbar - procedure onSentenceChange(S: Cardinal); //OnSentenceChange (for Golden Notes) + procedure OnSentenceEnd(SentenceIndex: Cardinal); //OnSentenceEnd for LineBonus + Singbar + procedure OnSentenceChange(SentenceIndex: Cardinal); //OnSentenceChange (for Golden Notes) end; implementation @@ -349,15 +348,17 @@ begin inherited; Log.LogStatus('Begin', 'onShow'); - FadeOut := false; // 0.5.0: early 0.5.0 problems were by this line commented + FadeOut := false; // reset video playback engine, to play Video Clip... fCurrentVideoPlaybackEngine := VideoPlayback; - //SetUp Score Manager - Scores.ClearPlayers; //Clear Old Player Values - Color.R := 0; Color.G := 0; Color.B := 0; //Dummy atm - For P := 0 to PlayersPlay -1 do //Add new Ones + // setup score manager + Scores.ClearPlayers; // clear old player values + Color.R := 0; Color.G := 0; Color.B := 0; // dummy atm + + // add new players + for P := 0 to PlayersPlay-1 do begin Scores.AddPlayer(Tex_ScoreBG[P], Color); end; @@ -368,7 +369,7 @@ begin // prepare players SetLength(Player, PlayersPlay); -// Player[0].ScoreTotalI := 0; + //Player[0].ScoreTotalInt := 0; case PlayersPlay of 1: begin @@ -462,20 +463,20 @@ begin // FIXME: bad style, put the try-except into LoadSong() and not here try - //Check if File is XML - if copy(CurrentSong.FileName,length(CurrentSong.FileName)-3,4) = '.xml' - then success := CurrentSong.LoadXMLSong() - else success := CurrentSong.LoadSong(); + // Check if file is XML + if copy(CurrentSong.FileName,length(CurrentSong.FileName)-3,4) = '.xml' + then success := CurrentSong.LoadXMLSong() + else success := CurrentSong.LoadSong(); except success := false; end; if (not success) then begin - //Error Loading Song -> Go back to Song Screen and Show some Error Message + // error loading song -> go back to song screen and show some error message FadeTo(@ScreenSong); - //Select New Song in Party Mode - if ScreenSong.Mode = smPartyMode then + // select new song in party mode + if ScreenSong.Mode = smPartyMode then ScreenSong.SelectRandomSong(); ScreenPopupError.ShowPopup (Language.Translate('ERROR_CORRUPT_SONG')); // FIXME: do we need this? @@ -485,7 +486,7 @@ begin - // reset video playback engine, to play Video Clip... + // reset video playback engine, to play video clip... Visualization.Init(); @@ -497,12 +498,9 @@ begin fShowVisualization := false; if (CurrentSong.Video <> '') and FileExists(CurrentSong.Path + CurrentSong.Video) then begin - // todo: VideoGap and Start time verwursten - + // TODO: use VideoGap and start time fCurrentVideoPlaybackEngine.Open( CurrentSong.Path + CurrentSong.Video ); - - fCurrentVideoPlaybackEngine.position := CurrentSong.VideoGAP + CurrentSong.Start; - + fCurrentVideoPlaybackEngine.Position := CurrentSong.VideoGAP + CurrentSong.Start; CurrentSong.VideoLoaded := true; end; @@ -657,21 +655,19 @@ begin end; end; // case - // Add Lines to Lyrics - While (not Lyrics.LineinQueue) AND (Lyrics.LineCounter <= High(Lines[0].Line)) do + // Add lines to lyrics + while (not Lyrics.LineinQueue) and (Lyrics.LineCounter <= High(Lines[0].Line)) do Lyrics.AddLine(@Lines[0].Line[Lyrics.LineCounter]); //UpdateLCD; //TODO: maybe LCD Support as Plugin? - //Deactivate Pause + // Deactivate pause Paused := False; - //Kill all Stars not Killed yet - //GoldenStarsTwinkle Mod - GoldenRec.SentenceChange; - //GoldenStarsTwinkle Mod End + // Kill all stars not killed yet (GoldenStarsTwinkle Mod) + GoldenRec.SentenceChange; - {//Set Position of Line Bonus - PhrasenBonus + {//Set Position of Line Bonus - Line Bonus start if (Ini.LineBonus = 1) then //Show Line Bonus at Scores begin Case PlayersPlay of @@ -904,10 +900,10 @@ begin end; end; } - //Set Position of Line Bonus - PhrasenBonus End - //Set Num of Empty Sentences for Phrasen Bonus + // set Position of Line Bonus - Line Bonus end + // set number of empty sentences for Line Bonus NumEmptySentences := 0; - for P := low(Lines[0].Line) to high(Lines[0].Line) do + for P := Low(Lines[0].Line) to High(Lines[0].Line) do if Lines[0].Line[P].TotalNotes = 0 then Inc(NumEmptySentences); Log.LogStatus('End', 'onShow'); @@ -922,24 +918,17 @@ begin try fCurrentVideoPlaybackEngine.GetFrame(LineState.CurrentTime); fCurrentVideoPlaybackEngine.DrawGL(ScreenAct); -// PlaySmpeg; - except - - on E : Exception do - begin - //If an Error occurs Reading Video: prevent Video from being Drawn again and Close Video + except on E : Exception do + begin + //If an error occurs reading video: prevent video from being drawn again and close video CurrentSong.VideoLoaded := False; Log.LogError('Error drawing Video, Video has been disabled for this Song/Session.'); Log.LogError('Error Message : '+ E.message ); Log.LogError(' In : '+ E.ClassName +' (TScreenSing.onShowFinish)' ); Log.LogError('Corrupted File: ' + CurrentSong.Video); - try -// CloseSmpeg; - fCurrentVideoPlaybackEngine.Close; - except - end; - end; + fCurrentVideoPlaybackEngine.Close; + end; end; end; @@ -960,12 +949,12 @@ var S: integer; T: integer; begin - - - - //ScoreBG Mod | den wirren Scheiss hier brauch mer nimmer, wir haben colorized png's - no need for wirrness also - // set player colors - macht nichts weiter als die farben des statics zu wechseln, was zu unschönen effekten bei colorized png führt -{ if PlayersPlay = 4 then begin + // ScoreBG Mod + // TODO: remove this commented out section as we do not need it anymore. + // We use colorized png's now. Set player colors does nothing than changing + // the colors of the statics which will lead to ugly effects on colorized pngs + { + if PlayersPlay = 4 then begin if ScreenAct = 1 then begin LoadColor(Static[StaticP1TwoP].Texture.ColR, Static[StaticP1TwoP].Texture.ColG, Static[StaticP1TwoP].Texture.ColB, 'P1Dark'); @@ -1038,7 +1027,8 @@ begin if ScreenAct = 2 then begin case PlayersPlay of -{ 1: begin + { + 1: begin Text[TextP1].Text := 'P2'; end; 2: begin @@ -1049,8 +1039,8 @@ begin Text[TextP1].Text := 'P4'; Text[TextP2M].Text := 'P5'; Text[TextP3R].Text := 'P6'; - end;} - + end; + } 4: begin Text[TextP1TwoP].Text := 'P3'; Text[TextP2R].Text := 'P4'; @@ -1063,11 +1053,15 @@ begin end; // case end; // if - // stereo -// weird stuff, maybe this is for "dual screen?", but where is player three then? | okay, i commented the stuff out the other day - nothing was missing on screen w/ 6 players - so do we even need this stuff? -// okay this stuff appears again some lines beneath this one, I commented it out for testing what it does - seems like it's doing nothing -// but I might be wrong, so what is this stuff here doing? O.o + //// + // dual screen, part 1 + //////////////////////// + + // Note: ScreenX is the offset of the current screen in dual-screen mode so we + // will move the statics and texts to the correct screen here. + // FIXME: clean up this weird stuff. Commenting this stuff out, nothing + // was missing on screen w/ 6 players - so do we even need this stuff? Static[StaticP1].Texture.X := Static[StaticP1].Texture.X + 10*ScreenX; Text[TextP1].X := Text[TextP1].X + 10*ScreenX; @@ -1082,7 +1076,8 @@ begin {Static[StaticP2RScoreBG].Texture.X := Static[StaticP2RScoreBG].Texture.X + 10*ScreenX; Text[TextP2RScore].X := Text[TextP2RScore].X + 10*ScreenX;} -// end of weird stuff + + // end of weird stuff Static[1].Texture.X := Static[1].Texture.X + 10*ScreenX; @@ -1180,31 +1175,28 @@ begin end; } // draw static menu (BG) - //DrawBG; // there is no menu and the animated background brakes the video playback because the timecode is in a different format - //Draw Background + // Note: there is no menu and the animated background brakes the video playback + //DrawBG; + + // Draw Background SingDrawBackground; + // update and draw movie - - if ShowFinish and - ( CurrentSong.VideoLoaded or fShowVisualization ) then -// if ShowFinish then + if (ShowFinish and + (CurrentSong.VideoLoaded or fShowVisualization)) then begin -// try -// UpdateSmpeg; // this only draws - // todo: find a way to determine, when a new frame is needed - // toto: same for the need to skip frames - + //try + // TODO: find a way to determine, when a new frame is needed + // TODO: same for the need to skip frames if assigned( fCurrentVideoPlaybackEngine ) then begin fCurrentVideoPlaybackEngine.GetFrame(LineState.CurrentTime); fCurrentVideoPlaybackEngine.DrawGL(ScreenAct); end; - -(* + (* except on E : Exception do begin - //If an Error occurs drawing: prevent Video from being Drawn again and Close Video CurrentSong.VideoLoaded := False; log.LogError('Error drawing Video, Video has been disabled for this Song/Session.'); @@ -1212,53 +1204,54 @@ begin Log.LogError(' In : '+ E.ClassName +' (TScreenSing.Draw)' ); Log.LogError('Corrupted File: ' + CurrentSong.Video); - try -// CloseSmpeg; - fCurrentVideoPlaybackEngine.Close; - except - - end; + fCurrentVideoPlaybackEngine.Close; end; end; -*) - + *) end; // draw static menu (FG) DrawFG; // check for music finish -// Log.LogError('Check for music finish: ' + BoolToStr(Music.Finished) + ' ' + FloatToStr(LineState.CurrentTime*1000) + ' ' + IntToStr(CurrentSong.Finish)); - if ShowFinish then begin - if (not AudioPlayback.Finished) and ((CurrentSong.Finish = 0) or (LineState.CurrentTime*1000 <= CurrentSong.Finish)) then begin - //Pause Mod: - if not Paused then Sing(Self); // analyze song - end else begin -// Log.LogError('End'); - if not FadeOut then begin -// Log.LogError('End2'); - Finish; - FadeOut := true; - FadeTo(@ScreenScore); + //Log.LogError('Check for music finish: ' + BoolToStr(Music.Finished) + ' ' + FloatToStr(LineState.CurrentTime*1000) + ' ' + IntToStr(CurrentSong.Finish)); + if ShowFinish then + begin + if (not AudioPlayback.Finished) and + ((CurrentSong.Finish = 0) or (LineState.CurrentTime*1000 <= CurrentSong.Finish)) then + begin + // analyze song if not paused + if (not Paused) then + Sing(Self); + end + else + begin + if (not FadeOut) then + begin + Finish; + FadeOut := true; + FadeTo(@ScreenScore); + end; end; end; - end; - // draw custom items - SingDraw; // always draw + // always draw custom items + SingDraw; -//GoldenNoteStarsTwinkle Mod + //GoldenNoteStarsTwinkle GoldenRec.SpawnRec; -//GoldenNoteStarsTwinkle Mod //Draw Scores Scores.Draw; - // back stereo + //// + // dual screen, part 2 + //////////////////////// + + // Note: ScreenX is the offset of the current screen in dual-screen mode so we + // will move the statics and texts to the correct screen here. + // FIXME: clean up this weird stuff -// weird stuff, maybe this is for "dual screen?", but where is player three then? -// okay this stuff appears again some lines above this one, I commented it out for testing what it does - seems like it's doing nothing -// but I might be wrong, so what is this stuff here doing? O.o Static[StaticP1].Texture.X := Static[StaticP1].Texture.X - 10*ScreenX; Text[TextP1].X := Text[TextP1].X - 10*ScreenX; @@ -1271,22 +1264,23 @@ begin {Static[StaticP2RScoreBG].Texture.X := Static[StaticP2RScoreBG].Texture.X - 10*ScreenX; Text[TextP2RScore].X := Text[TextP2RScore].X - 10*ScreenX;} -//weird end + + //end of weird Static[1].Texture.X := Static[1].Texture.X - 10*ScreenX; for T := 0 to 1 do Text[T].X := Text[T].X - 10*ScreenX; - //Draw Pausepopup - //I use this workaround that the Static is drawen over the Lyrics, Lines, Scores and Effects - //maybe someone could find a better solution + // Draw Pausepopup + // FIXME: this is a workaround that the Static is drawn over the Lyrics, Lines, Scores and Effects + // maybe someone could find a better solution if Paused then - begin - Static[StaticPausePopup].Visible := true; - Static[StaticPausePopup].Draw; - Static[StaticPausePopup].Visible := false; - end; + begin + Static[StaticPausePopup].Visible := true; + Static[StaticPausePopup].Draw; + Static[StaticPausePopup].Visible := false; + end; end; @@ -1295,7 +1289,7 @@ begin AudioInput.CaptureStop; AudioPlayback.Stop; - if Ini.SavePlayback = 1 then begin + if (Ini.SavePlayback = 1) then begin Log.BenchmarkStart(0); Log.LogVoice(0); Log.LogVoice(1); @@ -1306,7 +1300,6 @@ begin if CurrentSong.VideoLoaded then begin -// CloseSmpeg; fCurrentVideoPlaybackEngine.Close; CurrentSong.VideoLoaded := false; // to prevent drawing closed video end; @@ -1333,77 +1326,93 @@ begin end; *) -procedure TScreenSing.onSentenceEnd(S: Cardinal); +procedure TScreenSing.OnSentenceEnd(SentenceIndex: Cardinal); var -I: Integer; -A: Real; -B: integer; //Max Points for Notes + PlayerIndex: Integer; + CurrentPlayer: PPLayer; + CurrentScore: Real; + Line: PLine; + LinePerfection: Real; // perfection of singing performance on the current line + Rating: integer; + LineScore: Real; + LineBonus: Real; + MaxSongScore: integer; // max. points for the song (without line bonus) + MaxLineScore: Real; // max. points for the current line +const + // TODO: move this to a better place + MAX_LINE_RATING = 8; // max. rating for singing performance begin + Line := @Lines[0].Line[SentenceIndex]; - //Check for Empty Sentence - if (Lines[0].Line[S].TotalNotes<=0) then - exit; + // check for empty sentence + if (Line.TotalNotes <= 0) then + Exit; - //Set Max Note Points - if (Ini.LineBonus > 0) then - B := 9000 + // set max song score + if (Ini.LineBonus = 0) then + MaxSongScore := MAX_SONG_SCORE else - B := 10000; + MaxSongScore := MAX_SONG_SCORE - MAX_SONG_LINE_BONUS; - for I := 0 to High(Player) do begin - A := Player[I].Score + Player[I].ScoreGolden - Player[I].ScoreLast + 2; + // Note: ScoreValue is the sum of all note values of the song + MaxLineScore := MaxSongScore * (Line.TotalNotes / Lines[0].ScoreValue); + for PlayerIndex := 0 to High(Player) do + begin + CurrentPlayer := @Player[PlayerIndex]; + CurrentScore := CurrentPlayer.Score + CurrentPlayer.ScoreGolden; - //PhrasenBonus - Line Bonus Mod + // Line Bonus - //Generate Steps 0 to 8 - A := Floor(A / (B * Lines[0].Line[S].TotalNotes / Lines[0].ScoreValue) * 8); + // points for this line + LineScore := CurrentScore - CurrentPlayer.ScoreLast; - If (Ini.LineBonus > 0) then - begin - //PhrasenBonus give Points - Player[I].ScoreLine := Player[I].ScoreLine + (1000 / (Length(Lines[0].Line) - NumEmptySentences) * A / 8); - Player[I].ScoreLineI := Round(Player[I].ScoreLine / 10) * 10; - //Update Total Score - Player[I].ScoreTotalI := Player[I].ScoreI + Player[I].ScoreGoldenI + Player[I].ScoreLineI; - - //Spawn PopUp - If (A >= 8) then - A := 8 - else IF A < 0 then - A := 0; - - Scores.SpawnPopUp(I, Floor(A), Player[I].ScoreTotalI); - end; - //PhrasenBonus - Line Bonus Mod End// } + // determine LinePerfection + // Note: the "+2" extra points are a little bonus so the player does not + // have to be that perfect to reach the bonus steps. + LinePerfection := (LineScore + 2) / MaxLineScore; - //PerfectLineTwinkle Mod (effect) Pt.1 - If (Ini.EffectSing=1) then + // clamp LinePerfection to range [0..1] + if (LinePerfection < 0) then + LinePerfection := 0 + else if (LinePerfection > 1) then + LinePerfection := 1; + + // add line-bonus if enabled + if (Ini.LineBonus > 0) then begin - if A >= 8 then Player[I].LastSentencePerfect := True - else Player[I].LastSentencePerfect := False; + // line-bonus points (same for each line, no matter how long the line is) + LineBonus := MAX_SONG_LINE_BONUS / + (Length(Lines[0].Line) - NumEmptySentences); + // apply line-bonus + CurrentPlayer.ScoreLine := CurrentPlayer.ScoreLine + + LineBonus * LinePerfection; + CurrentPlayer.ScoreLineInt := Round(CurrentPlayer.ScoreLine / 10) * 10; + // update total score + CurrentPlayer.ScoreTotalInt := CurrentPlayer.ScoreInt + + CurrentPlayer.ScoreGoldenInt + + CurrentPlayer.ScoreLineInt; + + // spawn rating pop-up + Rating := Round(LinePerfection * MAX_LINE_RATING); + Scores.SpawnPopUp(PlayerIndex, Rating, CurrentPlayer.ScoreTotalInt); end; - //PerfectLineTwinkle Mod end - //Refresh LastScore - Player[I].ScoreLast := Player[I].Score + Player[I].ScoreGolden; + // PerfectLineTwinkle (effect), Part 1 + If (Ini.EffectSing = 1) then + CurrentPlayer.LastSentencePerfect := (LinePerfection >= 1); + // refresh last score + CurrentPlayer.ScoreLast := CurrentScore; end; - //PerfectLineTwinkle Mod (effect) Pt.2 - if Ini.EffectSing=1 then + // PerfectLineTwinkle (effect), Part 2 + if (Ini.EffectSing = 1) then GoldenRec.SpawnPerfectLineTwinkle; - //PerfectLineTwinkle Mod end - - - // if we are shoing a visualization... change to a new preset after each sentence.. - // Maybe we should make this less often or something... just a - if fShowVisualization then - fCurrentVideoPlaybackEngine.Position := now; // move to a random position end; //Called on Sentence Change S= New Current Sentence -procedure TScreenSing.onSentenceChange(S: Cardinal); +procedure TScreenSing.OnSentenceChange(SentenceIndex: Cardinal); begin //GoldenStarsTwinkle Mod GoldenRec.SentenceChange; diff --git a/Game/Code/Screens/UScreenSingModi.pas b/Game/Code/Screens/UScreenSingModi.pas index 4af999f1..f010ec31 100644 --- a/Game/Code/Screens/UScreenSingModi.pas +++ b/Game/Code/Screens/UScreenSingModi.pas @@ -289,8 +289,8 @@ begin PlayerInfo.Playerinfo[I].Name := PChar(Player[I].Name); if PlayerInfo.Playerinfo[I].Enabled then begin - if (Player[I].ScoreTotalI<=10000) then - PlayerInfo.Playerinfo[I].Score:= Player[I].ScoreTotalI; + if (Player[I].ScoreTotalInt <= MAX_SONG_SCORE) then + PlayerInfo.Playerinfo[I].Score:= Player[I].ScoreTotalInt; PlayerInfo.Playerinfo[I].Bar := Round(Scores.Players[I].RBPos * 100); end; end; @@ -567,7 +567,7 @@ begin if PlayerInfo.Playerinfo[I].Enabled then begin //PlayerInfo.Playerinfo[I].Bar := Player[I].ScorePercent; - PlayerInfo.Playerinfo[I].Score := Player[I].ScoreTotalI; + PlayerInfo.Playerinfo[I].Score := Player[I].ScoreTotalInt; end; end; @@ -586,10 +586,10 @@ begin //Change PlayerInfo/Changeables for I := 0 to PlayerInfo.NumPlayers-1 do begin - if (Player[I].ScoreTotalI <> PlayerInfo.Playerinfo[I].Score) then + if (Player[I].ScoreTotalInt <> PlayerInfo.Playerinfo[I].Score) then begin //Player[I].ScoreTotal := Player[I].ScoreTotal + (PlayerInfo.Playerinfo[I].Score - Player[I].ScoreTotalI); - Player[I].ScoreTotalI := PlayerInfo.Playerinfo[I].Score; + Player[I].ScoreTotalInt := PlayerInfo.Playerinfo[I].Score; end; {if (PlayerInfo.Playerinfo[I].Bar <> Player[I].ScorePercent) then Player[I].ScorePercentTarget := PlayerInfo.Playerinfo[I].Bar; } @@ -656,7 +656,7 @@ begin Result := PChar(Language.Translate(String(Name))); end; } -procedure Print (const Style, Size: Byte; const X, Y: Real; const Text: PChar); stdcall; //Procedure to Print Text +procedure Print(const Style, Size: Byte; const X, Y: Real; const Text: PChar); stdcall; //Procedure to Print Text begin SetFontItalic ((Style and 128) = 128); SetFontStyle(Style and 7); @@ -665,31 +665,36 @@ begin glPrint (PChar(Language.Translate(String(Text)))); end; -function LoadSound (const Name: PChar): Cardinal; stdcall; //Procedure that loads a Custom Sound +function LoadSound(const Name: PChar): Cardinal; stdcall; //Procedure that loads a Custom Sound var - S: TAudioPlaybackStream; - I: Integer; - F: String; + Stream: TAudioPlaybackStream; + i: Integer; + Filename: String; begin //Search for Sound in already loaded Sounds - F := UpperCase(SoundPath + FileName); - For I := 0 to High(CustomSounds) do + Filename := UpperCase(SoundPath + Name); + for i := 0 to High(CustomSounds) do begin - if (UpperCase(CustomSounds[I].Filename) = F) then + if (UpperCase(CustomSounds[i].Filename) = Filename) then begin - Result := I; + Result := i; Exit; end; end; - S := AudioPlayback.OpenSound(SoundPath + String(Name)); - if (S <> nil) then - Result := High(CustomSounds) - else + Stream := AudioPlayback.OpenSound(SoundPath + String(Name)); + if (Stream = nil) then + begin Result := 0; + Exit; + end; + + SetLength(CustomSounds, Length(CustomSounds)+1); + CustomSounds[High(CustomSounds)].Stream := Stream; + Result := High(CustomSounds); end; -procedure PlaySound (const Index: Cardinal); stdcall; //Plays a Custom Sound +procedure PlaySound(const Index: Cardinal); stdcall; //Plays a Custom Sound begin if (Index <= High(CustomSounds)) then AudioPlayback.PlaySound(CustomSounds[Index].Stream); diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 06314bcd..b790bc36 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -83,10 +83,10 @@ type StaticTeam3Joker4: Cardinal; StaticTeam3Joker5: Cardinal; - StaticParty: Array of Cardinal; - TextParty: Array of Cardinal; - StaticNonParty: Array of Cardinal; - TextNonParty: Array of Cardinal; + StaticParty: array of Cardinal; + TextParty: array of Cardinal; + StaticNonParty: array of Cardinal; + TextNonParty: array of Cardinal; constructor Create; override; @@ -131,96 +131,95 @@ type end; implementation -uses UGraphic, - UMain, - UCovers, - math, - gl, - USkins, - UDLLManager, - UParty, - UPlaylist, - UScreenSongMenu; + +uses + UGraphic, + UMain, + UCovers, + math, + gl, + USkins, + UDLLManager, + UParty, + UPlaylist, + UScreenSongMenu; // ***** Public methods ****** // //Show Wrong Song when Tabs on Fix procedure TScreenSong.FixSelected; var I, I2: Integer; +begin + if CatSongs.VisibleSongs > 0 then begin - if CatSongs.VisibleSongs > 0 then + I2:= 0; + for I := low(CatSongs.Song) to High(Catsongs.Song) do begin - I2:= 0; - for I := low(CatSongs.Song) to High(Catsongs.Song) do - begin - if CatSongs.Song[I].Visible then - inc(I2); - - if I = Interaction - 1 then - break; - end; + if CatSongs.Song[I].Visible then + inc(I2); - SongCurrent := I2; - SongTarget := I2; + if I = Interaction - 1 then + break; end; + + SongCurrent := I2; + SongTarget := I2; end; +end; procedure TScreenSong.FixSelected2; var I, I2: Integer; +begin + if CatSongs.VisibleSongs > 0 then begin - if CatSongs.VisibleSongs > 0 then + I2:= 0; + for I := low(CatSongs.Song) to High(Catsongs.Song) do begin - I2:= 0; - for I := low(CatSongs.Song) to High(Catsongs.Song) do - begin - if CatSongs.Song[I].Visible then - inc(I2); + if CatSongs.Song[I].Visible then + inc(I2); - if I = Interaction - 1 then - break; - end; - - SongTarget := I2; + if I = Interaction - 1 then + break; end; - end; -//Show Wrong Song when Tabs on Fix End - procedure TScreenSong.ShowCatTLCustom(Caption: String);// Show Custom Text in Top left - begin - Text[TextCat].Text := Caption; - Text[TextCat].Visible := true; - Static[StaticCat].Visible := False; + SongTarget := I2; end; +end; +//Show Wrong Song when Tabs on Fix End - //Show Cat in Top Left Mod - procedure TScreenSong.ShowCatTL(Cat: Integer); - begin - //Change - Text[TextCat].Text := CatSongs.Song[Cat].Artist; - //showmessage(CatSongs.Song[Cat].Path + CatSongs.Song[Cat].Cover); - //Static[StaticCat].Texture := Texture.GetTexture(Button[Cat].Texture.Name, TEXTURE_TYPE_PLAIN, true); +procedure TScreenSong.ShowCatTLCustom(Caption: String);// Show Custom Text in Top left +begin + Text[TextCat].Text := Caption; + Text[TextCat].Visible := true; + Static[StaticCat].Visible := False; +end; - Static[StaticCat].Texture := Texture.GetTexture(Button[Cat].Texture.Name, TEXTURE_TYPE_PLAIN, true); - //Texture.GetTexture(Button[Cat].Texture.Name, TEXTURE_TYPE_PLAIN, false); - //Button[Cat]. - //Cover +//Show Cat in Top Left Mod +procedure TScreenSong.ShowCatTL(Cat: Integer); +begin + //Change + Text[TextCat].Text := CatSongs.Song[Cat].Artist; + //showmessage(CatSongs.Song[Cat].Path + CatSongs.Song[Cat].Cover); + //Static[StaticCat].Texture := Texture.GetTexture(Button[Cat].Texture.Name, TEXTURE_TYPE_PLAIN, true); + Static[StaticCat].Texture := Texture.GetTexture(Button[Cat].Texture.Name, TEXTURE_TYPE_PLAIN, true); + //Texture.GetTexture(Button[Cat].Texture.Name, TEXTURE_TYPE_PLAIN, false); - //Show - Text[TextCat].Visible := true; - Static[StaticCat].Visible := True; - end; + //Show + Text[TextCat].Visible := true; + Static[StaticCat].Visible := True; +end; - procedure TScreenSong.HideCatTL; - begin - //Hide - //Text[TextCat].Visible := false; - Static[StaticCat].Visible := false; - //New -> Show Text specified in Theme - Text[TextCat].Visible := True; - Text[TextCat].Text := Theme.Song.TextCat.Text; - end; - //Show Cat in Top Left Mod End +procedure TScreenSong.HideCatTL; +begin + //Hide + //Text[TextCat].Visible := false; + Static[StaticCat].Visible := false; + //New -> Show Text specified in Theme + Text[TextCat].Visible := True; + Text[TextCat].Text := Theme.Song.TextCat.Text; +end; +//Show Cat in Top Left Mod End // Method for input parsing. If False is returned, GetNextWindow @@ -229,7 +228,6 @@ function TScreenSong.ParseInput(PressedKey: Cardinal; CharCode: WideChar; Presse var I: integer; I2: integer; -// HS: integer; // Auto Removed, Unused Variable SDL_ModState: Word; Letter: WideChar; begin @@ -247,14 +245,14 @@ begin Exit; end; - If (PressedDown) Then + if (PressedDown) then begin // Key Down SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT); //Jump to Artist/Titel - if ((SDL_ModState and KMOD_LALT <> 0) AND (Mode = smNormal)) then + if ((SDL_ModState and KMOD_LALT <> 0) and (Mode = smNormal)) then begin if (WideCharUpperCase(CharCode)[1] in ([WideChar('A')..WideChar('Z')]) ) then begin @@ -264,10 +262,10 @@ begin //Jump To Titel if (SDL_ModState = (KMOD_LALT or KMOD_LSHIFT)) then begin - For I := 1 to high(CatSongs.Song) do + for I := 1 to high(CatSongs.Song) do begin - if (CatSongs.Song[(I + Interaction) mod I2].Visible) AND - (Length(CatSongs.Song[(I + Interaction) mod I2].Title)>0) AND + if (CatSongs.Song[(I + Interaction) mod I2].Visible) and + (Length(CatSongs.Song[(I + Interaction) mod I2].Title)>0) and (WideStringUpperCase(CatSongs.Song[(I + Interaction) mod I2].Title)[1] = Letter) then begin SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); @@ -283,12 +281,12 @@ begin end; end //Jump to Artist - else if (SDL_ModState = KMOD_LALT) then + else if (SDL_ModState = KMOD_LALT) then begin - For I := 1 to high(CatSongs.Song) do + for I := 1 to high(CatSongs.Song) do begin - if (CatSongs.Song[(I + Interaction) mod I2].Visible) AND - (Length(CatSongs.Song[(I + Interaction) mod I2].Artist)>0) AND + if (CatSongs.Song[(I + Interaction) mod I2].Visible) and + (Length(CatSongs.Song[(I + Interaction) mod I2].Artist)>0) and (WideStringUpperCase(CatSongs.Song[(I + Interaction) mod I2].Artist)[1] = Letter) then begin SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); @@ -319,9 +317,12 @@ begin 'M': //Show SongMenu begin - if (Songs.SongList.Count > 0) then begin - if (Mode = smNormal) then begin - if not CatSongs.Song[Interaction].Main then begin // clicked on Song + if (Songs.SongList.Count > 0) then + begin + if (Mode = smNormal) then + begin + if (not CatSongs.Song[Interaction].Main) then // clicked on Song + begin if CatSongs.CatNumShow = -3 then ScreenSongMenu.MenuShow(SM_Playlist) else @@ -332,14 +333,18 @@ begin ScreenSongMenu.MenuShow(SM_Playlist_Load); end; end //Party Mode -> Show Party Menu - else ScreenSongMenu.MenuShow(SM_Party_Main); + else + begin + ScreenSongMenu.MenuShow(SM_Party_Main); + end; end; Exit; end; 'P': //Show Playlist Menu begin - if (Songs.SongList.Count > 0) AND (Mode = smNormal) then begin + if (Songs.SongList.Count > 0) and (Mode = smNormal) then + begin ScreenSongMenu.MenuShow(SM_Playlist_Load); end; Exit; @@ -347,7 +352,7 @@ begin 'J': //Show Jumpto Menu begin - if (Songs.SongList.Count > 0) AND (Mode = smNormal) then + if (Songs.SongList.Count > 0) and (Mode = smNormal) then begin ScreenSongJumpto.Visible := True; end; @@ -362,67 +367,68 @@ begin 'R': begin - if (Songs.SongList.Count > 0) AND (Mode = smNormal) then begin - - if (SDL_ModState = KMOD_LSHIFT) AND (Ini.Tabs_at_startup = 1) then //Random Category + if (Songs.SongList.Count > 0) and (Mode = smNormal) then + begin + if (SDL_ModState = KMOD_LSHIFT) and (Ini.Tabs_at_startup = 1) then //Random Category begin - I2 := 0; //Count Cats - for I:= low(CatSongs.Song) to high (CatSongs.Song) do - if CatSongs.Song[I].Main then Inc(I2); + I2 := 0; //Count Cats + for I:= low(CatSongs.Song) to high (CatSongs.Song) do + begin + if CatSongs.Song[I].Main then + Inc(I2); + end; - I2 := Random (I2)+1; //Zufall + I2 := Random (I2)+1; //Zufall - //Find Cat: - for I:= low(CatSongs.Song) to high (CatSongs.Song) do - begin - if CatSongs.Song[I].Main then - Dec(I2); - if (I2<=0) then + //Find Cat: + for I:= low(CatSongs.Song) to high (CatSongs.Song) do begin - //Show Cat in Top Left Mod - ShowCatTL (I); + if CatSongs.Song[I].Main then + Dec(I2); + if (I2<=0) then + begin + //Show Cat in Top Left Mod + ShowCatTL (I); - Interaction := I; + Interaction := I; - CatSongs.ShowCategoryList; - CatSongs.ClickCategoryButton(I); - SelectNext; - FixSelected; - break; + CatSongs.ShowCategoryList; + CatSongs.ClickCategoryButton(I); + SelectNext; + FixSelected; + break; end; end; - - end - else if (SDL_ModState = KMOD_LCTRL) AND (Ini.Tabs_at_startup = 1) then //random in All Categorys + else if (SDL_ModState = KMOD_LCTRL) and (Ini.Tabs_at_startup = 1) then //random in All Categorys begin - repeat - I2 := Random(high(CatSongs.Song)+1) - low(CatSongs.Song)+1; - until CatSongs.Song[I2].Main = false; + repeat + I2 := Random(high(CatSongs.Song)+1) - low(CatSongs.Song)+1; + until CatSongs.Song[I2].Main = false; - //Search Cat - for I := I2 downto low(CatSongs.Song) do + //Search Cat + for I := I2 downto low(CatSongs.Song) do begin if CatSongs.Song[I].Main then break; end; - //In I is now the categorie in I2 the song + + //In I is now the categorie in I2 the song - //Choose Cat - CatSongs.ShowCategoryList; + //Choose Cat + CatSongs.ShowCategoryList; - //Show Cat in Top Left Mod + //Show Cat in Top Left Mod ShowCatTL (I); - CatSongs.ClickCategoryButton(I); - SelectNext; - - //Fix: Not Existing Song selected: - //if (I+1=I2) then Inc(I2); + CatSongs.ClickCategoryButton(I); + SelectNext; - //Choose Song - SkipTo(I2-I); + //Fix: Not Existing Song selected: + //if (I+1=I2) then Inc(I2); + //Choose Song + SkipTo(I2-I); end else //Random in one Category begin @@ -443,74 +449,74 @@ begin SDLK_ESCAPE, SDLK_BACKSPACE : begin - if (Mode = smNormal) then - begin - //On Escape goto Cat-List Hack - if (Ini.Tabs_at_startup = 1) AND (CatSongs.CatNumShow <> -1) then - begin - //Find Category - I := Interaction; - while not catsongs.Song[I].Main do + if (Mode = smNormal) then + begin + //On Escape goto Cat-List Hack + if (Ini.Tabs_at_startup = 1) and (CatSongs.CatNumShow <> -1) then begin - Dec (I); - if (I < low(catsongs.Song)) then - break; - end; - if (I<= 1) then - Interaction := high(catsongs.Song) - else - Interaction := I - 1; - - //Stop Music - AudioPlayback.Stop; - - CatSongs.ShowCategoryList; - - //Show Cat in Top Left Mod - HideCatTL; + //Find Category + I := Interaction; + while not catsongs.Song[I].Main do + begin + Dec (I); + if (I < low(catsongs.Song)) then + break; + end; + if (I<= 1) then + Interaction := high(catsongs.Song) + else + Interaction := I - 1; + //Stop Music + AudioPlayback.Stop; - //Show Wrong Song when Tabs on Fix - SelectNext; - FixSelected; - //SelectPrev; - //CatSongs.Song[0].Visible := False; - end - else - begin - //On Escape goto Cat-List Hack End - //Tabs off and in Search or Playlist -> Go back to Song view - if (CatSongs.CatNumShow < -1) then - begin - //Atm: Set Empty Filter - CatSongs.SetFilter('', 0); + CatSongs.ShowCategoryList; //Show Cat in Top Left Mod HideCatTL; - Interaction := 0; + //Show Wrong Song when Tabs on Fix SelectNext; FixSelected; - - ChangeMusic; - end + //SelectPrev; + //CatSongs.Song[0].Visible := False; + end else begin - AudioPlayback.Stop; - AudioPlayback.PlaySound(SoundLib.Back); + //On Escape goto Cat-List Hack End + //Tabs off and in Search or Playlist -> Go back to Song view + if (CatSongs.CatNumShow < -1) then + begin + //Atm: Set Empty Filter + CatSongs.SetFilter('', 0); - FadeTo(@ScreenMain); - end; + //Show Cat in Top Left Mod + HideCatTL; + Interaction := 0; + //Show Wrong Song when Tabs on Fix + SelectNext; + FixSelected; + + ChangeMusic; + end + else + begin + AudioPlayback.Stop; + AudioPlayback.PlaySound(SoundLib.Back); + + FadeTo(@ScreenMain); + end; + + end; + end + //When in party Mode then Ask before Close + else if (Mode = smPartyMode) then + begin + AudioPlayback.PlaySound(SoundLib.Back); + CheckFadeTo(@ScreenMain,'MSG_END_PARTY'); end; - end - //When in party Mode then Ask before Close - else if (Mode = smPartyMode) then - begin - AudioPlayback.PlaySound(SoundLib.Back); - CheckFadeTo(@ScreenMain,'MSG_END_PARTY'); - end; end; SDLK_RETURN: begin @@ -521,7 +527,6 @@ begin {$ENDIF} if CatSongs.Song[Interaction].Main then begin // clicked on Category Button - //Show Cat in Top Left Mod ShowCatTL (Interaction); @@ -531,15 +536,14 @@ begin SongCurrent := SongCurrent - I + I2; SongTarget := SongTarget - I + I2; } - // SetScroll4; - - //Show Wrong Song when Tabs on Fix - SelectNext; - FixSelected; + // SetScroll4; - //Play Music: - ChangeMusic; + //Show Wrong Song when Tabs on Fix + SelectNext; + FixSelected; + //Play Music: + ChangeMusic; end else begin // clicked on song @@ -550,7 +554,7 @@ begin 0: StartSong; 1: SelectPlayers; 2:begin - If (CatSongs.CatNumShow = -3) then + if (CatSongs.CatNumShow = -3) then ScreenSongMenu.MenuShow(SM_Playlist) else ScreenSongMenu.MenuShow(SM_Main); @@ -651,12 +655,12 @@ begin SDLK_RIGHT: begin - if (Songs.SongList.Count > 0) AND (Mode = smNormal) then + if (Songs.SongList.Count > 0) and (Mode = smNormal) then begin AudioPlayback.PlaySound(SoundLib.Change); SelectNext; -// InteractNext; -// SongTarget := Interaction; + //InteractNext; + //SongTarget := Interaction; ChangeMusic; SetScroll4; //UpdateLCD; //TODO: maybe LCD Support as Plugin? @@ -666,7 +670,8 @@ begin SDLK_LEFT: begin - if (Songs.SongList.Count > 0)AND (Mode = smNormal) then begin + if (Songs.SongList.Count > 0)and (Mode = smNormal) then + begin AudioPlayback.PlaySound(SoundLib.Change); SelectPrev; ChangeMusic; @@ -678,7 +683,7 @@ begin SDLK_1: begin //Joker // to-do : Party - {if (Mode = smPartyMode) AND (PartySession.Teams.NumTeams >= 1) AND (PartySession.Teams.Teaminfo[0].Joker > 0) then + {if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= 1) and (PartySession.Teams.Teaminfo[0].Joker > 0) then begin //Use Joker Dec(PartySession.Teams.Teaminfo[0].Joker); @@ -689,7 +694,7 @@ begin SDLK_2: begin //Joker - {if (Mode = smPartyMode) AND (PartySession.Teams.NumTeams >= 2) AND (PartySession.Teams.Teaminfo[1].Joker > 0) then + {if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= 2) and (PartySession.Teams.Teaminfo[1].Joker > 0) then begin //Use Joker Dec(PartySession.Teams.Teaminfo[1].Joker); @@ -700,7 +705,7 @@ begin SDLK_3: begin //Joker - {if (Mode = smPartyMode) AND (PartySession.Teams.NumTeams >= 3) AND (PartySession.Teams.Teaminfo[2].Joker > 0) then + {if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= 3) and (PartySession.Teams.Teaminfo[2].Joker > 0) then begin //Use Joker Dec(PartySession.Teams.Teaminfo[2].Joker); @@ -714,9 +719,7 @@ end; constructor TScreenSong.Create; var -// Pet: integer; - I: integer; -//Label CreateSongButtons; + i: integer; begin inherited Create; @@ -754,23 +757,23 @@ begin //Load Party or NonParty specific Statics and Texts SetLength(StaticParty, Length(Theme.Song.StaticParty)); - for I := 0 to High(Theme.Song.StaticParty) do - StaticParty[I] := AddStatic(Theme.Song.StaticParty[I]); + for i := 0 to High(Theme.Song.StaticParty) do + StaticParty[i] := AddStatic(Theme.Song.StaticParty[i]); SetLength(TextParty, Length(Theme.Song.TextParty)); - for I := 0 to High(Theme.Song.TextParty) do - TextParty[I] := AddText(Theme.Song.TextParty[I]); + for i := 0 to High(Theme.Song.TextParty) do + TextParty[i] := AddText(Theme.Song.TextParty[i]); SetLength(StaticNonParty, Length(Theme.Song.StaticNonParty)); - for I := 0 to High(Theme.Song.StaticNonParty) do - StaticNonParty[I] := AddStatic(Theme.Song.StaticNonParty[I]); + for i := 0 to High(Theme.Song.StaticNonParty) do + StaticNonParty[i] := AddStatic(Theme.Song.StaticNonParty[i]); SetLength(TextNonParty, Length(Theme.Song.TextNonParty)); - for I := 0 to High(Theme.Song.TextNonParty) do - TextNonParty[I] := AddText(Theme.Song.TextNonParty[I]); + for i := 0 to High(Theme.Song.TextNonParty) do + TextNonParty[i] := AddText(Theme.Song.TextNonParty[i]); // Song List -// Songs.LoadSongList; // moved to the UltraStar unit + //Songs.LoadSongList; // moved to the UltraStar unit CatSongs.Refresh; GenerateThumbnails(); @@ -919,10 +922,10 @@ end; procedure TScreenSong.SetScroll1; var B: integer; // button -// BMin: integer; // button min // Auto Removed, Unused Variable -// BMax: integer; // button max // Auto Removed, Unused Variable + //BMin: integer; // button min // Auto Removed, Unused Variable + //BMax: integer; // button max // Auto Removed, Unused Variable Src: integer; -// Dst: integer; + //Dst: integer; Count: integer; // Dst is not used. Count is used. Ready: boolean; @@ -931,8 +934,8 @@ var Typ: integer; // 0 when all songs fits the screen Placed: integer; // number of placed visible buttons begin -// Src := 0; -// Dst := -1; + //Src := 0; + //Dst := -1; Count := 1; Typ := 0; Ready := false; @@ -976,12 +979,14 @@ begin Button[B].Selectable := CatSongs.Song[B].Visible; end; -{ for B := Src to Dst do begin -// Button[B].Visible := true; + { + for B := Src to Dst do begin + //Button[B].Visible := true; Button[B].Visible := CatSongs.Song[B].Visible; Button[B].Selectable := Button[B].Visible; Button[B].Y := 140 + (B-Src) * 60; - end;} + end; + } if Typ = 0 then begin @@ -1055,8 +1060,8 @@ end; procedure TScreenSong.SetScroll2; var B: integer; -// Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu // Auto Removed, Unused Variable -// Wsp2: real; // Auto Removed, Unused Variable + //Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu + //Wsp2: real; begin // liniowe for B := 0 to High(Button) do @@ -1071,19 +1076,21 @@ begin end; // kolowe -{ for B := 0 to High(Button) do begin + { + for B := 0 to High(Button) do begin Wsp := (B - Interaction); // 0 dla srodka, -1 dla lewego, +1 dla prawego itd. Wsp2 := Wsp / Length(Button); Button[B].X := 300 + 10000 * sin(2*pi*Wsp2); -// Button[B].Y := 140 + 50 * ; - end;} + //Button[B].Y := 140 + 50 * ; + end; + } end; procedure TScreenSong.SetScroll3; // with slide var B: integer; -// Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu // Auto Removed, Unused Variable -// Wsp2: real; // Auto Removed, Unused Variable + //Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu + //Wsp2: real; begin SongTarget := Interaction; @@ -1097,21 +1104,25 @@ begin Button[B].Visible := True; end; -{ if Length(Button) >= 3 then begin + { + if Length(Button) >= 3 then begin if Interaction = 0 then Button[High(Button)].X := 300 - 260; if Interaction = High(Button) then Button[0].X := 300 + 260; - end;} + end; + } // kolowe -{ for B := 0 to High(Button) do begin + { + for B := 0 to High(Button) do begin Wsp := (B - Interaction); // 0 dla srodka, -1 dla lewego, +1 dla prawego itd. Wsp2 := Wsp / Length(Button); Button[B].X := 300 + 10000 * sin(2*pi*Wsp2); -// Button[B].Y := 140 + 50 * ; - end;} + //Button[B].Y := 140 + 50 * ; + end; + } end; procedure TScreenSong.SetScroll4; // rotate @@ -1139,7 +1150,7 @@ begin Button[B].W := Theme.Song.Cover.H * Z2; -// Button[B].Y := {50 +} 140 + 50 - 50 * Z2; + //Button[B].Y := {50 +} 140 + 50 - 50 * Z2; Button[B].Y := Theme.Song.Cover.Y + (Theme.Song.Cover.H - Abs(Button[B].H)) * 0.7 ; Button[B].H := Button[B].W; end; @@ -1174,7 +1185,7 @@ begin for B := 0 to High(Button) do begin Button[B].Visible := CatSongs.Song[B].Visible; // nowe if Button[B].Visible then begin // 0.5.0 optimization for 1000 songs - updates only visible songs, hiding in tabs becomes useful for maintaing good speed - if ((ModReal(CatSongs.VisibleIndex(B) - SongCurrent, VS)>-3) AND (ModReal(CatSongs.VisibleIndex(B) - SongCurrent, VS)<3)) then + if ((ModReal(CatSongs.VisibleIndex(B) - SongCurrent, VS)>-3) and (ModReal(CatSongs.VisibleIndex(B) - SongCurrent, VS)<3)) then begin if CatSongs.VisibleIndex(B)> SongCurrent then Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / Z2 @@ -1198,13 +1209,13 @@ begin Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX; Button[B].Z := Z-0.00001; -// Button[B].Y := {50 + 140 + 50 - 50 * Z2; - // Button[B].Y := (Theme.Song.CoverY + 40 + 50 - 50 * Z2); + //Button[B].Y := {50 + 140 + 50 - 50 * Z2; + //Button[B].Y := (Theme.Song.CoverY + 40 + 50 - 50 * Z2); Button[B].Y := (Theme.Song.CoverY + Theme.Song.CoverW - Button[B].W); Button[B].H := Button[B].W; Button[B].Visible := True; end - {else if (((CatSongs.VisibleIndex(B) - SongCurrent)>-3) AND ((CatSongs.VisibleIndex(B) - SongCurrent)<3)) OR ((round (CatSongs.VisibleIndex(B) - SongCurrent) mod VS > -3) AND ((CatSongs.VisibleIndex(B) - SongCurrent)<3)) then + {else if (((CatSongs.VisibleIndex(B) - SongCurrent)>-3) and ((CatSongs.VisibleIndex(B) - SongCurrent)<3)) OR ((round (CatSongs.VisibleIndex(B) - SongCurrent) mod VS > -3) and ((CatSongs.VisibleIndex(B) - SongCurrent)<3)) then begin Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / 12 ;// 0.5.0 (II): takes another 16ms @@ -1240,7 +1251,8 @@ var helper: real; begin VS := CatSongs.VisibleSongs; // cache Visible Songs - {Vars + { + //Vars Theme.Song.CoverW: Radius des Kreises Theme.Song.CoverX: X Pos Linke Kante des gewählten Covers Theme.Song.CoverX: Y Pos Obere Kante des gewählten Covers @@ -1264,11 +1276,11 @@ begin if (Abs(Pos) < 2.5) then {fixed Positions} begin Angle := Pi * (Pos / 5); -// Button[B].Visible := False; + //Button[B].Visible := False; Button[B].H := Abs(Theme.Song.Cover.H * cos(Angle*0.8));//Power(Z2, 3); -// Button[B].Reflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + //Button[B].Reflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; Button[B].Z := 0.95 - Abs(Pos) * 0.01; @@ -1314,7 +1326,7 @@ begin Button[B].Y := Theme.Song.Cover.Y - (Button[B].H - Theme.Song.Cover.H)*0.75; -// Button[B].Reflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + //Button[B].Reflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; Diff := (Button[B].H - Theme.Song.Cover.H)/2; @@ -1324,7 +1336,7 @@ begin end; //Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Button[B].H)/1.5); //Cover at down border of the change field -// Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Button[B].H) * 0.7); + //Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Button[B].H) * 0.7); end; end; @@ -1360,7 +1372,7 @@ begin Button[B].W := Theme.Song.Cover.H * Z2; -// Button[B].Y := {50 +} 140 + 50 - 50 * Z2; + //Button[B].Y := {50 +} 140 + 50 - 50 * Z2; Button[B].X := Theme.Song.Cover.X + (Theme.Song.Cover.H - Abs(Button[B].H)) * 0.7 ; Button[B].H := Button[B].W; end; @@ -1383,7 +1395,7 @@ begin if (Abs(Pos) < 2.5) then {fixed Positions} begin Angle := Pi * (Pos / 5); -// Button[B].Visible := False; + //Button[B].Visible := False; Button[B].H := Abs(Theme.Song.Cover.H * cos(Angle*0.8));//Power(Z2, 3); @@ -1415,7 +1427,7 @@ begin else Pos := (Pos + VS/2)/VS; - Angle := pi * Pos*2; + Angle := Pi * Pos*2; Button[B].Z := (0.4 - Abs(Pos/4)) -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers @@ -1446,16 +1458,16 @@ begin if Ini.Players = 4 then PlayersPlay := 6; //Cat Mod etc - if (Ini.Tabs_at_startup = 1) AND (CatSongs.CatNumShow = -1) then - begin - CatSongs.ShowCategoryList; - FixSelected; - //Show Cat in Top Left Mod - HideCatTL; - end; - + if (Ini.Tabs_at_startup = 1) and (CatSongs.CatNumShow = -1) then + begin + CatSongs.ShowCategoryList; + FixSelected; + //Show Cat in Top Left Mod + HideCatTL; + end; - if Length(CatSongs.Song) > 0 then begin + if Length(CatSongs.Song) > 0 then + begin //Load Music only when Song Preview is activated if ( Ini.PreviewVolume <> 0 ) then begin // to - do : new Song management @@ -1479,7 +1491,6 @@ begin //Party Mode else if (Mode = smPartyMode) then begin - SelectRandomSong; //Show Menu directly in PartyMode //But only if selected in Options @@ -1487,8 +1498,6 @@ begin begin ScreenSongMenu.MenuShow(SM_Party_Main); end; - - end; SetJoker; @@ -1541,18 +1550,22 @@ begin SongCurrent := SongCurrent + dx*dt; -{ if SongCurrent > Catsongs.VisibleSongs then begin + { + if SongCurrent > Catsongs.VisibleSongs then begin SongCurrent := SongCurrent - Catsongs.VisibleSongs; SongTarget := SongTarget - Catsongs.VisibleSongs; - end;} + end; + } + + //Log.BenchmarkStart(5); -// Log.BenchmarkStart(5); SetScroll; -// Log.BenchmarkEnd(5); -// Log.LogBenchmark('SetScroll4', 5); + + //Log.BenchmarkEnd(5); + //Log.LogBenchmark('SetScroll4', 5); //Fading Functions, Only if Covertime is under 5 Seconds - If (CoverTime < 5) then + if (CoverTime < 5) then begin // cover fade if (CoverTime < 1) and (CoverTime + TimeSkip >= 1) then @@ -1623,7 +1636,6 @@ end; procedure TScreenSong.SelectNext; var Skip: integer; -// I: integer; // Auto Removed, Unused Variable VS: Integer; begin VS := CatSongs.VisibleSongs; @@ -1635,7 +1647,8 @@ begin Skip := 1; // this 1 could be changed by CatSongs.FindNextVisible - while (not CatSongs.Song[(Interaction + Skip) mod Length(Interactions)].Visible) do Inc(Skip); + while (not CatSongs.Song[(Interaction + Skip) mod Length(Interactions)].Visible) do + Inc(Skip); SongTarget := SongTarget + 1;//Skip; @@ -1648,14 +1661,14 @@ begin end; end; - // Interaction -> Button, ktorego okladke przeczytamy - // Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, TEXTURE_TYPE_PLAIN, false); // 0.5.0: show uncached texture + + // Interaction -> Button, ktorego okladke przeczytamy + //Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, TEXTURE_TYPE_PLAIN, false); // 0.5.0: show uncached texture end; procedure TScreenSong.SelectPrev; var Skip: integer; -// I: integer; // Auto Removed, Unused Variable VS: Integer; begin VS := CatSongs.VisibleSongs; @@ -1739,15 +1752,14 @@ end; procedure TScreenSong.SkipTo(Target: Cardinal); var -// Skip: integer; // Auto Removed, Unused Variable - I: integer; + i: integer; begin UnLoadDetailedCover; Interaction := High(CatSongs.Song); SongTarget := 0; - for I := 1 to Target+1 do + for i := 1 to Target+1 do SelectNext; FixSelected2; @@ -1762,7 +1774,6 @@ var CurTime: Cardinal; PosX, PosY: Integer; Pos: Real; -// lTmp : double; // Auto Removed, Unused Variable begin // Nothing to do if no music is played or an equalizer bar consists of no block if (AudioPlayback.Finished or (Theme.Song.Equalizer.Length <= 0)) then @@ -1864,11 +1875,11 @@ begin end; end; -Procedure TScreenSong.SelectRandomSong; +procedure TScreenSong.SelectRandomSong; var I, I2: Integer; begin - Case PlaylistMan.Mode of + case PlaylistMan.Mode of smNormal: //All Songs Just Select Random Song begin //When Tabs are activated then use Tab Method @@ -1931,11 +1942,11 @@ end; procedure TScreenSong.SetJoker; begin -// {//If Party Mode + // If Party Mode // to-do : Party if Mode = smPartyMode then //Show Joker that are available begin -(* + (* if (PartySession.Teams.NumTeams >= 1) then begin Static[StaticTeam1Joker1].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 1); @@ -1986,7 +1997,7 @@ begin Static[StaticTeam3Joker4].Visible := False; Static[StaticTeam3Joker5].Visible := False; end; -*) + *) end else begin //Hide all @@ -2018,19 +2029,19 @@ begin //Set Visibility of Party Statics and Text Visible := (Mode = smPartyMode); - For I := 0 to high(StaticParty) do + for I := 0 to high(StaticParty) do Static[StaticParty[I]].Visible := Visible; - For I := 0 to high(TextParty) do + for I := 0 to high(TextParty) do Text[TextParty[I]].Visible := Visible; //Set Visibility of Non Party Statics and Text Visible := not Visible; - For I := 0 to high(StaticNonParty) do + for I := 0 to high(StaticNonParty) do Static[StaticNonParty[I]].Visible := Visible; - For I := 0 to high(TextNonParty) do + for I := 0 to high(TextNonParty) do Text[TextNonParty[I]].Visible := Visible; end; @@ -2062,7 +2073,9 @@ end; procedure TScreenSong.OpenEditor; begin - if (Songs.SongList.Count > 0) and (not CatSongs.Song[Interaction].Main) AND (Mode = smNormal) then + if (Songs.SongList.Count > 0) and + (not CatSongs.Song[Interaction].Main) and + (Mode = smNormal) then begin AudioPlayback.Stop; AudioPlayback.PlaySound(SoundLib.Start); @@ -2074,21 +2087,26 @@ end; //Team No of Team (0-5) procedure TScreenSong.DoJoker (Team: Byte); begin - {if (Mode = smPartyMode) AND (PartySession.Teams.NumTeams >= Team + 1) AND (PartySession.Teams.Teaminfo[Team].Joker > 0) then + { + if (Mode = smPartyMode) and + (PartySession.Teams.NumTeams >= Team + 1) and + (PartySession.Teams.Teaminfo[Team].Joker > 0) then begin //Use Joker Dec(PartySession.Teams.Teaminfo[Team].Joker); SelectRandomSong; SetJoker; - end; } + end; + } end; //Detailed Cover Unloading. Unloads the Detailed, uncached Cover of the cur. Song procedure TScreenSong.UnLoadDetailedCover; begin CoverTime := 0; - - Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, TEXTURE_TYPE_PLAIN, true); // 0.5.0: show cached texture + + // show cached texture + Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, TEXTURE_TYPE_PLAIN, true); Button[Interaction].Texture2.Alpha := 0; if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then @@ -2096,13 +2114,14 @@ begin end; procedure TScreenSong.Refresh; -begin { -CatSongs.Refresh; -CatSongs.ShowCategoryList; -Interaction := 0; -SelectNext; -FixSelected; } - +begin + { + CatSongs.Refresh; + CatSongs.ShowCategoryList; + Interaction := 0; + SelectNext; + FixSelected; + } end; end. diff --git a/Game/Code/Screens/UScreenTop5.pas b/Game/Code/Screens/UScreenTop5.pas index 7ad46d49..18c90f5e 100644 --- a/Game/Code/Screens/UScreenTop5.pas +++ b/Game/Code/Screens/UScreenTop5.pas @@ -103,7 +103,7 @@ begin PMax := Ini.Players; if Ini.Players = 4 then Ini.Players := 5; for I := 0 to PMax do - DataBase.AddScore(CurrentSong, Ini.Difficulty, Ini.Name[I], Round(Player[I].ScoreTotalI)); + DataBase.AddScore(CurrentSong, Ini.Difficulty, Ini.Name[I], Round(Player[I].ScoreTotalInt)); DataBase.WriteScore(CurrentSong); DataBase.ReadScore(CurrentSong); -- cgit v1.2.3