From 6db1465f89985e8675db3fdac1aa7d662dda3722 Mon Sep 17 00:00:00 2001 From: s_alexander Date: Sat, 19 Apr 2008 15:23:35 +0000 Subject: tried to make songloading working with the old loader and keep all changes that were made since starting to work on a new one *hope that worked* you may delete your existing cover.cache (the cover cache is still NOT working) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1024 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 196 +++++++++++++++++++------------------- 1 file changed, 98 insertions(+), 98 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 27c137f7..609d46b1 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -144,7 +144,7 @@ uses UGraphic, procedure TScreenSong.FixSelected; var I, I2: Integer; begin - {if CatSongs.VisibleSongs > 0 then + if CatSongs.VisibleSongs > 0 then begin I2:= 0; for I := low(CatSongs.Song) to High(Catsongs.Song) do @@ -158,13 +158,13 @@ var I, I2: Integer; SongCurrent := I2; SongTarget := I2; - end; } + end; end; procedure TScreenSong.FixSelected2; var I, I2: Integer; - begin // to - do : new Song management - { if CatSongs.VisibleSongs > 0 then + begin + if CatSongs.VisibleSongs > 0 then begin I2:= 0; for I := low(CatSongs.Song) to High(Catsongs.Song) do @@ -177,7 +177,7 @@ var I, I2: Integer; end; SongTarget := I2; - end;} + end; end; //Show Wrong Song when Tabs on Fix End @@ -262,7 +262,7 @@ begin begin For I := 1 to high(CatSongs.Song) do begin - {if (CatSongs.Song[(I + Interaction) mod I2].Visible) AND + if (CatSongs.Song[(I + Interaction) mod I2].Visible) AND (Length(CatSongs.Song[(I + Interaction) mod I2].Title)>0) AND (WideUpperCase(CatSongs.Song[(I + Interaction) mod I2].Title)[1] = Letter) then begin @@ -275,15 +275,15 @@ begin //UpdateLCD; //TODO: maybe LCD Support as Plugin? //Break and Exit Exit; - end; } + end; end; end //Jump to Artist else if (SDL_ModState = KMOD_LALT) then begin For I := 1 to high(CatSongs.Song) do - begin // to - do : new Song management - {if (CatSongs.Song[(I + Interaction) mod I2].Visible) AND + begin + if (CatSongs.Song[(I + Interaction) mod I2].Visible) AND (Length(CatSongs.Song[(I + Interaction) mod I2].Artist)>0) AND (WideUpperCase(CatSongs.Song[(I + Interaction) mod I2].Artist)[1] = Letter) then begin @@ -297,7 +297,7 @@ begin //Break and Exit Exit; - end; } + end; end; end; end; @@ -316,8 +316,8 @@ begin 'M': //Show SongMenu begin if (Songs.SongList.Count > 0) then begin - if (Mode = smNormal) then begin // to - do : new Song management - {if not CatSongs.Song[Interaction].Main then begin // clicked on Song + if (Mode = smNormal) then begin + if not CatSongs.Song[Interaction].Main then begin // clicked on Song if CatSongs.CatNumShow = -3 then ScreenSongMenu.MenuShow(SM_Playlist) else @@ -326,7 +326,7 @@ begin else begin ScreenSongMenu.MenuShow(SM_Playlist_Load); - end;} + end; end //Party Mode -> Show Party Menu else ScreenSongMenu.MenuShow(SM_Party_Main); end; @@ -362,16 +362,16 @@ begin if (SDL_ModState = KMOD_LSHIFT) AND (Ini.Tabs_at_startup = 1) then //Random Category begin - I2 := 0; //Count Cats // to - do : new Song management - {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 + if CatSongs.Song[I].Main then Inc(I2); I2 := Random (I2)+1; //Zufall //Find Cat: for I:= low(CatSongs.Song) to high (CatSongs.Song) do begin - {if CatSongs.Song[I].Main then + if CatSongs.Song[I].Main then Dec(I2); if (I2<=0) then begin @@ -385,23 +385,23 @@ begin SelectNext; FixSelected; break; - end; } - end; // to - do : new Song management + end; + end; end else if (SDL_ModState = KMOD_LCTRL) AND (Ini.Tabs_at_startup = 1) then //random in All Categorys begin - {repeat + repeat I2 := Random(high(CatSongs.Song)+1) - low(CatSongs.Song)+1; - until CatSongs.Song[I2].Main = false; } + until CatSongs.Song[I2].Main = false; //Search Cat - {for I := I2 downto low(CatSongs.Song) do + for I := I2 downto low(CatSongs.Song) do begin if CatSongs.Song[I].Main then break; - end; } + end; //In I is now the categorie in I2 the song //Choose Cat @@ -446,12 +446,12 @@ begin begin //Find Category I := Interaction; - {while not catsongs.Song[I].Main do + while not catsongs.Song[I].Main do begin Dec (I); if (I < low(catsongs.Song)) then break; - end; } + end; if (I<= 1) then Interaction := high(catsongs.Song) else @@ -514,8 +514,8 @@ begin begin {$IFDEF UseSerialPort} // PortWriteB($378, 0); - {$ENDIF} // to - do : new Song management - {if CatSongs.Song[Interaction].Main then + {$ENDIF} + if CatSongs.Song[Interaction].Main then begin // clicked on Category Button //Show Cat in Top Left Mod @@ -530,7 +530,7 @@ begin // SetScroll4; //Show Wrong Song when Tabs on Fix -{ SelectNext; + SelectNext; FixSelected; //Play Music: @@ -560,7 +560,7 @@ begin else ScreenSong.StartSong; end; - end; } + end; end; end; @@ -577,12 +577,12 @@ begin I := Interaction; if I <= 0 then I := 1; - {while not catsongs.Song[I].Main do + while not catsongs.Song[I].Main do begin Inc (I); if (I > high(catsongs.Song)) then I := low(catsongs.Song); - end; } + end; Interaction := I; @@ -618,14 +618,14 @@ begin I2 := 0; if I <= 0 then I := 1; - {while not catsongs.Song[I].Main or (I2 = 0) do + while not catsongs.Song[I].Main or (I2 = 0) do begin if catsongs.Song[I].Main then Inc(I2); Dec (I); if (I < low(catsongs.Song)) then I := high(catsongs.Song); - end; } + end; Interaction := I; @@ -790,7 +790,7 @@ var Pet: integer; Label CreateSongButtons; begin - {if (length(CatSongs.Song) > 0) then + if (length(CatSongs.Song) > 0) then begin //Set Length of Button Array one Time Instead of one time for every Song SetButtonLength(Length(CatSongs.Song)); @@ -803,30 +803,30 @@ begin // new Texture.Limit := 512;// 256 0.4.2 value, 512 in 0.5.0 - if not FileExists({CatSongs.Song[Pet].Path + }{CatSongs.Song[Pet].Cover) then + if not FileExists(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover) then CatSongs.Song[Pet].Cover := ''; // 0.5.0: if cover not found then show 'no cover' - // to - do : new Song management + if CatSongs.Song[Pet].Cover = '' then AddButton(300 + Pet*250, 140, 200, 200, Skin.GetTextureFileName('SongCover'), TEXTURE_TYPE_PLAIN, Theme.Song.Cover.Reflections) else begin // cache texture if there is a need to this - if not Covers.CoverExists({CatSongs.Song[Pet].Path + }{CatSongs.Song[Pet].Cover) then + if not Covers.CoverExists(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover) then begin Texture.CreateCacheMipmap := true; - Texture.GetTexture({CatSongs.Song[Pet].Path + }{CatSongs.Song[Pet].Cover, TEXTURE_TYPE_PLAIN, true); // preloads textures and creates cache mipmap + Texture.GetTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, TEXTURE_TYPE_PLAIN, true); // preloads textures and creates cache mipmap Texture.CreateCacheMipmap := false; // puts this texture to the cache file - Covers.AddCover({CatSongs.Song[Pet].Path + }{CatSongs.Song[Pet].Cover); + Covers.AddCover(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover); // unload full size texture - Texture.UnloadTexture({CatSongs.Song[Pet].Path + }{CatSongs.Song[Pet].Cover, TEXTURE_TYPE_PLAIN, false); + Texture.UnloadTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, TEXTURE_TYPE_PLAIN, false); // we should also add mipmap texture by calling createtexture and use mipmap cache as data source end; // and now load it from cache file (small place for the optimization by eliminating reading it from file, but not here) - AddButton(300 + Pet*250, 140, 200, 200,{ CatSongs.Song[Pet].Path + }{CatSongs.Song[Pet].Cover, TEXTURE_TYPE_PLAIN, Theme.Song.Cover.Reflections); + AddButton(300 + Pet*250, 140, 200, 200, CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, TEXTURE_TYPE_PLAIN, Theme.Song.Cover.Reflections); end; Texture.Limit := 1024*1024; I := -1; @@ -848,7 +848,7 @@ begin try AddButton(300 + Pet*250, 140, 200, 200, '', TEXTURE_TYPE_PLAIN, Theme.Song.Cover.Reflections); except - ShowMessage('"No Cover" image is damaged. Ultrastar will exit now.'); + ShowMessage('"No Cover" image is damaged. Ultrastar will exit now.'); Halt; end; I := Pet + 1; @@ -858,7 +858,7 @@ begin if (I <> -1) then GoTo CreateSongButtons; - end; } + end; end; procedure TScreenSong.SetScroll; @@ -886,7 +886,7 @@ begin //Set Texts: Text[TextArtist].Text := CatSongs.Song[Interaction].Artist; Text[TextTitle].Text := CatSongs.Song[Interaction].Title; - {if (Ini.Tabs_at_startup = 1) And (CatSongs.CatNumShow = -1) then + if (Ini.Tabs_at_startup = 1) And (CatSongs.CatNumShow = -1) then begin Text[TextNumber].Text := IntToStr(CatSongs.Song[Interaction].OrderNum) + '/' + IntToStr(CatSongs.CatCount); Text[TextTitle].Text := '(' + IntToStr(CatSongs.Song[Interaction].CatNumber) + ' ' + Language.Translate('SING_SONGS_IN_CAT') + ')'; @@ -898,15 +898,15 @@ begin else if (Ini.Tabs_at_startup = 1) then Text[TextNumber].Text := IntToStr(CatSongs.Song[Interaction].CatNumber) + '/' + IntToStr(CatSongs.Song[Interaction - CatSongs.Song[Interaction].CatNumber].CatNumber) else - Text[TextNumber].Text := IntToStr(Interaction+1) + '/' + IntToStr(Length(CatSongs.Song));} + Text[TextNumber].Text := IntToStr(Interaction+1) + '/' + IntToStr(Length(CatSongs.Song)); end else begin Text[TextNumber].Text := '0/0'; Text[TextArtist].Text := ''; Text[TextTitle].Text := ''; - {for B := 0 to High(Button) do - Button[B].Visible := False; } + for B := 0 to High(Button) do + Button[B].Visible := False; end; end; @@ -934,12 +934,12 @@ begin Placed := 0; VisCount := 0; - {for B := 0 to High(Button) do - if CatSongs.Song[B].Visible then Inc(VisCount);} + for B := 0 to High(Button) do + if CatSongs.Song[B].Visible then Inc(VisCount); VisInt := 0; - {for B := 0 to Interaction-1 do - if CatSongs.Song[B].Visible then Inc(VisInt); } + for B := 0 to Interaction-1 do + if CatSongs.Song[B].Visible then Inc(VisInt); if VisCount <= 6 then begin @@ -964,11 +964,11 @@ begin end; - // to - do : new Song management + // hide all buttons for B := 0 to High(Button) do begin Button[B].Visible := false; - //Button[B].Selectable := CatSongs.Song[B].Visible; + Button[B].Selectable := CatSongs.Song[B].Visible; end; { for B := Src to Dst do begin @@ -979,7 +979,7 @@ begin end;} - {if Typ = 0 then begin + if Typ = 0 then begin for B := 0 to High(Button) do begin if CatSongs.Song[B].Visible then begin Button[B].Visible := true; @@ -987,9 +987,9 @@ begin Inc(Placed); end; end; - end; } + end; - {if Typ = 1 then begin + if Typ = 1 then begin B := 0; while (Count > 0) do begin if CatSongs.Song[B].Visible then begin @@ -1000,9 +1000,9 @@ begin end; Inc(B); end; - end; } + end; - {if Typ = 2 then begin + if Typ = 2 then begin B := High(Button); while (Count > 0) do begin if CatSongs.Song[B].Visible then begin @@ -1044,7 +1044,7 @@ begin end; if Length(Button) > 0 then - Static[1].Texture.Y := Button[Interaction].Y - 5; // selection texture } + Static[1].Texture.Y := Button[Interaction].Y - 5; // selection texture end; procedure TScreenSong.SetScroll2; @@ -1053,7 +1053,7 @@ var // Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu // Auto Removed, Unused Variable // Wsp2: real; // Auto Removed, Unused Variable begin - {// liniowe + // liniowe for B := 0 to High(Button) do Button[B].X := 300 + (B - Interaction) * 260; @@ -1080,7 +1080,7 @@ var // Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu // Auto Removed, Unused Variable // Wsp2: real; // Auto Removed, Unused Variable begin - {SongTarget := Interaction; + SongTarget := Interaction; // liniowe for B := 0 to High(Button) do @@ -1116,7 +1116,7 @@ var Z, Z2: real; VS: integer; begin - {VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important + VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important // kolowe for B := 0 to High(Button) do begin @@ -1124,7 +1124,7 @@ begin 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 Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / VS {CatSongs.VisibleSongs};// 0.5.0 (II): takes another 16ms -{ + Z := (1 + cos(Wsp)) / 2; Z2 := (1 + 2*Z) / 3; @@ -1134,11 +1134,11 @@ begin Button[B].W := Theme.Song.Cover.H * 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].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; - end;} + end; end; (* @@ -1234,7 +1234,7 @@ var X: Real; helper: real; begin - {VS := CatSongs.VisibleSongs; // cache Visible Songs + VS := CatSongs.VisibleSongs; // cache Visible Songs {Vars Theme.Song.CoverW: Radius des Kreises Theme.Song.CoverX: X Pos Linke Kante des gewählten Covers @@ -1242,7 +1242,7 @@ begin Theme.Song.CoverH: Höhe der Cover (CatSongs.VisibleIndex(B) - SongCurrent)/VS = Distance to middle Cover in % - }{ + } //Change Pos of all Buttons for B := low(Button) to high(Button) do @@ -1256,7 +1256,7 @@ begin else if (Pos > VS/2) then Pos := Pos - VS; - if (Abs(Pos) < 2.5) then {fixed Positions} { + if (Abs(Pos) < 2.5) then {fixed Positions} begin Angle := Pi * (Pos / 5); // Button[B].Visible := False; @@ -1281,7 +1281,7 @@ begin end else - begin {Behind the Front Covers} { + begin {Behind the Front Covers} // limit-bg-covers hack if (abs(abs(Pos)-VS/2)>10) then Button[B].Visible:=False; @@ -1322,7 +1322,7 @@ begin // Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Button[B].H) * 0.7); end; - end; } + end; end; procedure TScreenSong.SetScroll6; // rotate (slotmachine style) @@ -1336,7 +1336,7 @@ var Wsp: real; Z, Z2: real; begin - {VS := CatSongs.VisibleSongs; // cache Visible Songs + VS := CatSongs.VisibleSongs; // cache Visible Songs if VS <=5 then begin // kolowe for B := 0 to High(Button) do @@ -1345,7 +1345,7 @@ begin 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 Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / VS {CatSongs.VisibleSongs};// 0.5.0 (II): takes another 16ms - { + Z := (1 + cos(Wsp)) / 2; Z2 := (1 + 2*Z) / 3; @@ -1355,9 +1355,9 @@ 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; { + Button[B].H := Button[B].W; end; end; end @@ -1375,7 +1375,7 @@ begin else if (Pos > VS/2) then Pos := Pos - VS; - if (Abs(Pos) < 2.5) then {fixed Positions} { + if (Abs(Pos) < 2.5) then {fixed Positions} begin Angle := Pi * (Pos / 5); // Button[B].Visible := False; @@ -1398,7 +1398,7 @@ begin Button[B].Y := Theme.Song.Cover.Y + Theme.Song.Cover.W * X - Diff; end else - begin {Behind the Front Covers} { + begin {Behind the Front Covers} // limit-bg-covers hack if (abs(VS/2-abs(Pos))>10) then Button[B].Visible:=False; @@ -1427,7 +1427,7 @@ begin end; end; end; - end; } + end; end; @@ -1453,8 +1453,8 @@ 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 - if(AudioPlayback.Open({CatSongs.Song[Interaction].Path + }CatSongs.Song[Interaction].Mp3)) then + begin + if(AudioPlayback.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3)) then begin AudioPlayback.SetLoop(false); AudioPlayback.Position := AudioPlayback.Length / 4; @@ -1508,8 +1508,8 @@ begin AudioPlayback.SetMusicVolume(100); //If Preview is deactivated: Load MUsicfile now - If (Ini.PreviewVolume = 0) then // to - do : new Song management - AudioPlayback.Open({Song[Interaction].Path + } CatSongs.Song[Interaction].Mp3); + If (Ini.PreviewVolume = 0) then + AudioPlayback.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); //When hide then Stop Music (For Party Mode Popup on Exit) if (Display.NextScreen <> @ScreenSing) and (Display.NextScreen <> @ScreenSingModi) and (AudioPlayback <> nil) then @@ -1565,9 +1565,9 @@ begin Button[Interaction].Texture2 := Texture.GetTexture(Button[Interaction].Texture.Name, TEXTURE_TYPE_PLAIN, false); Button[Interaction].Texture2.Alpha := 1; end; - // to - do : new Song management + //Song Fade - if (CatSongs.VisibleSongs > 0) AND (Ini.PreviewVolume <> 0) {AND (Not CatSongs.Song[Interaction].Main)} AND (Ini.PreviewFading <> 0) then + if (CatSongs.VisibleSongs > 0) AND (Ini.PreviewVolume <> 0) AND (Not CatSongs.Song[Interaction].Main) AND (Ini.PreviewFading <> 0) then begin //Start Song Fade after a little Time, to prevent Song to be Played on Scrolling if (CoverTime < 0.2) and (CoverTime + TimeSkip >= 0.2) then @@ -1636,9 +1636,9 @@ 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; + SongTarget := SongTarget + 1;//Skip; Interaction := (Interaction + Skip) mod Length(Interactions); @@ -1667,8 +1667,8 @@ begin Skip := 1; - {while (not CatSongs.Song[(Interaction - Skip + Length(Interactions)) mod Length(Interactions)].Visible) do Inc(Skip); - }SongTarget := SongTarget - 1;//Skip; + while (not CatSongs.Song[(Interaction - Skip + Length(Interactions)) mod Length(Interactions)].Visible) do Inc(Skip); + SongTarget := SongTarget - 1;//Skip; Interaction := (Interaction - Skip + Length(Interactions)) mod Length(Interactions); @@ -1699,7 +1699,7 @@ begin //When Music Preview is avtivated -> then Change Music if (Ini.PreviewVolume <> 0) then begin - {if (NOT CatSongs.Song[Interaction].Main) AND(CatSongs.VisibleSongs > 0) then + if (NOT CatSongs.Song[Interaction].Main) AND(CatSongs.VisibleSongs > 0) then begin AudioPlayback.Close; if AudioPlayback.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin @@ -1712,7 +1712,7 @@ begin end; end else - AudioPlayback.Stop; } + AudioPlayback.Stop; end; end; @@ -1852,17 +1852,17 @@ begin begin //When Tabs are activated then use Tab Method if (Ini.Tabs_at_startup = 1) then - begin // to - do : new Song management - {repeat + begin + repeat I2 := Random(high(CatSongs.Song)+1) - low(CatSongs.Song)+1; - until CatSongs.Song[I2].Main = false;} + until CatSongs.Song[I2].Main = false; //Search Cat - {for I := I2 downto low(CatSongs.Song) do + for I := I2 downto low(CatSongs.Song) do begin if CatSongs.Song[I].Main then break; - end; } + end; //In I ist jetzt die Kategorie in I2 der Song //I is the CatNum, I2 is the No of the Song within this Cat @@ -2040,14 +2040,14 @@ begin end; procedure TScreenSong.OpenEditor; -begin // to - do : new Song management - {if (Songs.SongList.Count > 0) and (not CatSongs.Song[Interaction].Main) AND (Mode = smNormal) then +begin + if (Songs.SongList.Count > 0) and (not CatSongs.Song[Interaction].Main) AND (Mode = smNormal) then begin AudioPlayback.Stop; AudioPlayback.PlaySound(SoundLib.Start); CurrentSong := CatSongs.Song[Interaction]; FadeTo(@ScreenEditSub); - end; } + end; end; //Team No of Team (0-5) -- cgit v1.2.3