From 5ed6620bad808381fce94f2cd67ee911b4d45bff Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 21 Mar 2007 19:19:04 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 1690 +++++++++++++++++++++++++++++++++++++ 1 file changed, 1690 insertions(+) create mode 100644 Game/Code/Screens/UScreenSong.pas (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas new file mode 100644 index 00000000..0d7860a7 --- /dev/null +++ b/Game/Code/Screens/UScreenSong.pas @@ -0,0 +1,1690 @@ +unit UScreenSong; + +interface + +uses + UMenu, SDL, UMusic, UPliki, UTime, UDisplay, USongs, SysUtils, ULog, UThemes, UTexture, ULanguage, + ULCD, ULight, UIni; + +type + TScreenSong = class(TMenu) + public + TextArtist: integer; + TextTitle: integer; + TextNumber: integer; + + TextCat: integer; + StaticCat: integer; + + SongCurrent: real; + SongTarget: real; + + HighSpeed: boolean; + CoverFull: boolean; + CoverTime: real; + CoverX: integer; + CoverY: integer; + CoverW: integer; + is_jump: boolean; // Jump to Song Mod + is_jump_title:boolean; //Jump to SOng MOd-YTrue if search for Title + + EqualizerBands: array of Byte; + EqualizerTime: Cardinal; + EqualizerTime2: Byte; + + //Party Mod + Mode: Byte; //0 = Standard, 1= Go to PartyMode after Selection + Change to Random Song at Show + //party Statics (Joker) + StaticTeam1Joker1: Cardinal; + StaticTeam1Joker2: Cardinal; + StaticTeam1Joker3: Cardinal; + StaticTeam1Joker4: Cardinal; + StaticTeam1Joker5: Cardinal; + + StaticTeam2Joker1: Cardinal; + StaticTeam2Joker2: Cardinal; + StaticTeam2Joker3: Cardinal; + StaticTeam2Joker4: Cardinal; + StaticTeam2Joker5: Cardinal; + + StaticTeam3Joker1: Cardinal; + StaticTeam3Joker2: Cardinal; + StaticTeam3Joker3: Cardinal; + StaticTeam3Joker4: Cardinal; + StaticTeam3Joker5: Cardinal; + + constructor Create; override; + procedure SetScroll; + procedure SetScroll1; + procedure SetScroll2; + procedure SetScroll3; + procedure SetScroll4; + procedure SetScroll5; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + function Draw: boolean; override; + procedure onShow; override; + procedure SelectNext; + procedure SelectPrev; + procedure UpdateLCD; + procedure SkipTo(Target: integer); + procedure FixSelected; //Show Wrong Song when Tabs on Fix + procedure FixSelected2; //Show Wrong Song when Tabs on Fix + procedure ShowCatTL(Cat: Integer);// Show Cat in Tob left + procedure HideCatTL;// Show Cat in Tob left + procedure Refresh; //Refresh Song Sorting + procedure DrawEqualizer; + //Party Mode + procedure SelectRandomSong; + procedure SetJoker; + + //procedures for Menu + procedure StartSong; + procedure OpenEditor; + procedure DoJoker(Team: Byte); + end; + +implementation +uses UGraphic, UMain, UCovers, math, OpenGL12, Windows, USkins, UDLLManager, UParty, UScreenSongMenu; + +// ***** Public methods ****** // + +//Show Wrong Song when Tabs on Fix +procedure TScreenSong.FixSelected; +var I, I2: Integer; + 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; + + SongCurrent := I2; + SongTarget := I2; + end; + +procedure TScreenSong.FixSelected2; +var I, I2: Integer; + 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; + + SongTarget := I2; + 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, 'Plain', true); + + Static[StaticCat].Texture := Texture.GetTexture(CatSongs.Song[Cat].Path + CatSongs.Song[Cat].Cover, 'Plain', true); + //Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', false); + //Button[Cat]. + //Cover + + + //Show + Text[TextCat].Visible := true; + Static[StaticCat].Visible := True; + end; + procedure TScreenSong.HideCatTL; + begin + //Hide + Text[TextCat].Visible := false; + Static[StaticCat].Visible := false; + end; + //Show Cat in Top Left Mod End + + +// Method for input parsing. If False is returned, GetNextWindow +// should be checked to know the next window to load; +function TScreenSong.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +var + I: integer; + I2: integer; + HS: integer; + SDL_ModState: Word; + Letter: Char; +begin + Result := true; + + //Song Menu + if (ScreenSongMenu.Visible) then + begin + Result := ScreenSongMenu.ParseInput(PressedKey, ScanCode, PressedDown); + Exit; + end; + + If (PressedDown) Then + begin // Key Down + +// HS := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT); +{ if (not HighSpeed) and (HS > 0) then begin + HighSpeed := true; + SDL_EnableKeyRepeat(50, 50); + end; + if (HighSpeed) and (HS = 0) then begin + HighSpeed := false; + SDL_EnableKeyRepeat(125, 125); + end;} + + SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT + + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT); + + // Jump to Key Mod + if (SDL_ModState = KMOD_LALT) AND (Mode = 0) then //Jump to Key + begin + //get Letter + case PressedKey of + SDLK_A : Letter := 'A'; + SDLK_B : Letter := 'B'; + SDLK_C : Letter := 'C'; + SDLK_D : Letter := 'D'; + SDLK_E : Letter := 'E'; + SDLK_F : Letter := 'F'; + SDLK_G : Letter := 'G'; + SDLK_H : Letter := 'H'; + SDLK_I : Letter := 'I'; + SDLK_J : Letter := 'J'; + SDLK_K : Letter := 'K'; + SDLK_L : Letter := 'L'; + SDLK_M : Letter := 'M'; + SDLK_N : Letter := 'N'; + SDLK_O : Letter := 'O'; + SDLK_P : Letter := 'P'; + SDLK_Q : Letter := 'Q'; + SDLK_R : Letter := 'R'; + SDLK_S : Letter := 'S'; + SDLK_T : Letter := 'T'; + SDLK_U : Letter := 'U'; + SDLK_V : Letter := 'V'; + SDLK_W : Letter := 'W'; + SDLK_X : Letter := 'X'; + SDLK_Y : Letter := 'Y'; + SDLK_Z : Letter := 'Z'; + SDLK_1 : Letter := '1'; + SDLK_2 : Letter := '2'; + SDLK_3 : Letter := '3'; + SDLK_4 : Letter := '4'; + SDLK_5 : Letter := '5'; + SDLK_6 : Letter := '6'; + SDLK_7 : Letter := '7'; + SDLK_8 : Letter := '8'; + SDLK_9 : Letter := '9'; + SDLK_0 : Letter := '0'; + else exit; + end; + + {//Search Letter + for I := Interaction + 1 to high(CatSongs.Song) do + begin + if CatSongs.Song[I].Visible and (Letter = Uppercase(CatSongs.Song[I].Artist)[1]) then + break; //Found Song + if I = Interaction then //went through complete array but nothing Found + break; + if I = high(CatSongs.Song) then //At the end of the array->Go to beginning + for I2 := low(CatSongs.Song) to Interaction do + if CatSongs.Song[I].Visible and (Letter = Uppercase(CatSongs.Song[I].Artist)[1]) then + break; //Found Song + end; } + + for I := 0 to High(CatSongs.Song) do begin + if (CatSongs.Song[I].Visible) AND (UpperCase(CatSongs.Song[I].Artist[1]) = Letter) then + begin + //Select Song + Interaction := I; + SkipTo(Interaction); + break; + end; + end; + + //Don't do other Functions + exit; + end; + + if (SDL_ModState = KMOD_LALT or KMOD_LSHIFT) then //Jump to Key + begin + //get Letter + case PressedKey of + SDLK_a..SDLK_z : Letter := Chr(Ord('a')+PressedKey-97); + SDLK_1 : Letter := '1'; + SDLK_2 : Letter := '2'; + SDLK_3 : Letter := '3'; + SDLK_4 : Letter := '4'; + SDLK_5 : Letter := '5'; + SDLK_6 : Letter := '6'; + SDLK_7 : Letter := '7'; + SDLK_8 : Letter := '8'; + SDLK_9 : Letter := '9'; + SDLK_0 : Letter := '0'; + else exit; + end; + + {//Search Letter + for I := Interaction + 1 to high(CatSongs.Song) do + begin + if CatSongs.Song[I].Visible and (Letter = Uppercase(CatSongs.Song[I].Artist)[1]) then + break; //Found Song + if I = Interaction then //went through complete array but nothing Found + break; + if I = high(CatSongs.Song) then //At the end of the array->Go to beginning + for I2 := low(CatSongs.Song) to Interaction do + if CatSongs.Song[I].Visible and (Letter = Uppercase(CatSongs.Song[I].Artist)[1]) then + break; //Found Song + end; } + + {for I := 0 to High(CatSongs.Song) do begin + if (CatSongs.Song[I].Visible) AND (UpperCase(CatSongs.Song[I].Artist[1]) = Letter) then} + + for I := Interaction + 1 to high(CatSongs.Song) + 1 do + begin + if (I > high(CatSongs.Song)) then + begin + for I2 := low(CatSongs.Song) to Interaction do + begin + if CatSongs.Song[I2].Visible and (Letter = lowercase(CatSongs.Song[I2].Artist[1])) then + begin + Interaction := I2; + break; //Found Song + end; + end; + break; + end + else if CatSongs.Song[I].Visible and (Letter = lowercase(CatSongs.Song[I].Artist[1])) then + begin + Interaction := I; + break; //Found Song + end; + end; + + + //Select Song + SkipTo(Interaction); + + //Don't do other Functions + exit; + end; + + + case PressedKey of + SDLK_ESCAPE : + begin + if (Mode = 0) 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 + 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 + Music.Stop; + + CatSongs.ShowCategoryList; + + //Show Cat in Top Left Mod + HideCatTL; + + + //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 + Music.Stop; + Music.PlayBack; +// FadeTo(@ScreenLevel); + FadeTo(@ScreenMain); + +// Music.Open(Skin.SkinPath + 'Menu Music 3.mp3'); +// Music.Play; + end; + end; + end; + SDLK_RETURN: + begin + if Length(Songs.Song) > 0 then begin +// PortWriteB($378, 0); + if CatSongs.Song[Interaction].Main then begin // clicked on Category Button + + //Show Cat in Top Left Mod + ShowCatTL (Interaction); + + //I := CatSongs.VisibleIndex(Interaction); + CatSongs.ClickCategoryButton(Interaction); + {I2 := CatSongs.VisibleIndex(Interaction); + SongCurrent := SongCurrent - I + I2; + SongTarget := SongTarget - I + I2; } + +// if I<>I2 then beep; + // SetScroll4; + + //Show Wrong Song when Tabs on Fix + SelectNext; + FixSelected; + + //Play Music: + Music.Close; + if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin + Music.MoveTo(Music.Length / 4); + Music.Play; + end; + + end else begin // clicked on song + if (Mode = 0) then //Normal Mode -> Start Song + begin + StartSong; + + end + else if (Mode = 1) then //PartyMode -> Show Menu + begin + ScreenSongMenu.Visible := True; + ScreenSongMenu.MenuShow(SM_Party_Main); + end; + end; + end; + end; + + SDLK_M: //Show SongMenu + begin + if Length(Songs.Song) > 0 then begin + if not CatSongs.Song[Interaction].Main then begin // clicked on Song + ScreenSongMenu.Visible := True; + ScreenSongMenu.MenuShow(SM_Main); + end; + end; + end; + + SDLK_DOWN: + begin + if (Mode = 0) then + begin +{ if Length(Songs.Song) > 0 then begin + Music.PlayChange; + InteractNext; + Music.Close; + if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then Music.Play; + SetScroll; + end;} + + //Cat Change Hack + if Ini.Tabs_at_startup = 1 then + begin + I := Interaction; + if I <= 0 then I := 1; + + while not catsongs.Song[I].Main do + begin + Inc (I); + if (I > high(catsongs.Song)) then + I := low(catsongs.Song); + end; + + Interaction := I; + + //Show Cat in Top Left Mod + ShowCatTL (Interaction); + + CatSongs.ClickCategoryButton(Interaction); + SelectNext; + FixSelected; + + //Play Music: + Music.PlayChange; + Music.Close; + if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin + Music.MoveTo(Music.Length / 4); + Music.Play; + end; + + end; + + // + //Cat Change Hack End} + end; + end; + SDLK_UP: + begin + if (Mode = 0) then + begin +{ if Length(Songs.Song) > 0 then begin + Music.PlayChange; + InteractPrev; + Music.Close; + if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then Music.Play; + SetScroll; + end;} + //Cat Change Hack + if Ini.Tabs_at_startup = 1 then + begin + I := Interaction; + I2 := 0; + if I <= 0 then I := 1; + + 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; + + Interaction := I; + + //Show Cat in Top Left Mod + ShowCatTL (I); + + CatSongs.ClickCategoryButton(I); + SelectNext; + FixSelected; + + //Play Music: + Music.PlayChange; + Music.Close; + if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin + Music.MoveTo(Music.Length / 4); + Music.Play; + end; + + end; + + // + //Cat Change Hack End} + end; + end; + + SDLK_RIGHT: + begin + if (Length(Songs.Song) > 0) AND (Mode = 0) then begin + Music.PlayChange; + SelectNext; +// InteractNext; +// SongTarget := Interaction; + Music.Close; + if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin + Music.MoveTo(Music.Length / 4); + Music.Play; + end; + SetScroll4; + UpdateLCD; + Light.LightOne(1, 200); + end; + end; + + SDLK_LEFT: + begin + if (Length(Songs.Song) > 0)AND (Mode = 0) then begin + Music.PlayChange; + SelectPrev; + Music.Close; + if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin + Music.MoveTo(Music.Length / 4); + Music.Play; + end; + SetScroll4; + UpdateLCD; + Light.LightOne(0, 200); + end; + end; + + SDLK_E: + begin + OpenEditor; + end; + + SDLK_R: + begin + if (Length(Songs.Song) > 0) AND (Mode = 0) 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 := 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 + begin + //Show Cat in Top Left Mod + ShowCatTL (I); + + Interaction := I; + + 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 + begin + 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 + begin + if CatSongs.Song[I].Main then + break; + end; + //In I ist jetzt die Kategorie in I2 der Song + + //Choose Cat + CatSongs.ShowCategoryList; + + //Show Cat in Top Left Mod + ShowCatTL (I); + + CatSongs.ClickCategoryButton(I); + SelectNext; + + //Fix: Not Existing Song selected: + if (I+1=I2) then Inc(I2); + + //Choose Song + SkipTo(I2-I); + + end + else //Random in one Category + begin + SkipTo(2+Random(CatSongs.VisibleSongs-1)); + end; + Music.PlayChange; + + Music.Close; + if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin + Music.MoveTo(Music.Length / 4); + Music.Play; + end; + SetScroll4; + UpdateLCD; + end; + end; + + SDLK_1: + begin //Jocker + if (Mode = 1) AND (PartySession.Teams.NumTeams >= 1) AND (PartySession.Teams.Teaminfo[0].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[0].Joker); + SelectRandomSong; + SetJoker; + end; + end; + + SDLK_2: + begin //Jocker + if (Mode = 1) AND (PartySession.Teams.NumTeams >= 2) AND (PartySession.Teams.Teaminfo[1].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[1].Joker); + SelectRandomSong; + SetJoker; + end; + end; + + SDLK_3: + begin //Jocker + if (Mode = 1) AND (PartySession.Teams.NumTeams >= 3) AND (PartySession.Teams.Teaminfo[2].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[2].Joker); + SelectRandomSong; + SetJoker; + end; + end; + + SDLK_Q: + begin + Result := false; + end; + end; + end + else // Key Up + case PressedKey of + SDLK_RETURN : + begin + end; + end; +end; + +constructor TScreenSong.Create; +var + Pet: integer; + I: integer; +begin + inherited Create; + +// AddStatic(200, 10, 400, 90, Skin.SelectSong); +// AddStatic(200-10, 140-5, 400+20, 50+10, Skin.Selection, 'JPG', 'Font Gray'); + + AddBackground(Theme.Song.Background.Tex); + + for I := 0 to High(Theme.Song.Static) do + AddStatic(Theme.Song.Static[I]); + + for I := 0 to High(Theme.Song.Text) do + AddText(Theme.Song.Text[I]); + + TextArtist := AddText(Theme.Song.TextArtist); + TextTitle := AddText(Theme.Song.TextTitle); + TextNumber := AddText(Theme.Song.TextNumber); + + //Show Cat in Top Left mod + TextCat := AddText(Theme.Song.TextCat); + StaticCat := AddStatic(Theme.Song.StaticCat); + + //Party Mode + StaticTeam1Joker1 := AddStatic(Theme.Song.StaticTeam1Joker1); + StaticTeam1Joker2 := AddStatic(Theme.Song.StaticTeam1Joker2); + StaticTeam1Joker3 := AddStatic(Theme.Song.StaticTeam1Joker3); + StaticTeam1Joker4 := AddStatic(Theme.Song.StaticTeam1Joker4); + StaticTeam1Joker5 := AddStatic(Theme.Song.StaticTeam1Joker5); + + StaticTeam2Joker1 := AddStatic(Theme.Song.StaticTeam2Joker1); + StaticTeam2Joker2 := AddStatic(Theme.Song.StaticTeam2Joker2); + StaticTeam2Joker3 := AddStatic(Theme.Song.StaticTeam2Joker3); + StaticTeam2Joker4 := AddStatic(Theme.Song.StaticTeam2Joker4); + StaticTeam2Joker5 := AddStatic(Theme.Song.StaticTeam2Joker5); + + StaticTeam3Joker1 := AddStatic(Theme.Song.StaticTeam3Joker1); + StaticTeam3Joker2 := AddStatic(Theme.Song.StaticTeam3Joker2); + StaticTeam3Joker3 := AddStatic(Theme.Song.StaticTeam3Joker3); + StaticTeam3Joker4 := AddStatic(Theme.Song.StaticTeam3Joker4); + StaticTeam3Joker5 := AddStatic(Theme.Song.StaticTeam3Joker5); + + // Song List +// Songs.LoadSongList; // moved to the UltraStar unit + CatSongs.Refresh; + for Pet := 0 to High(CatSongs.Song) do begin // creating all buttons + // 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 + CatSongs.Song[Pet].Cover := ''; // 0.5.0: if cover not found then show 'no cover' + + if CatSongs.Song[Pet].Cover = '' then + AddButton(300 + Pet*250, 140, 200, 200, Skin.GetTextureFileName('SongCover'), 'JPG', '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 begin + Texture.CreateCacheMipmap := true; + Texture.GetTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, '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); + + // unload full size texture + Texture.UnloadTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, 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, 'JPG', 'Plain', Theme.Song.Cover.Reflections); + end; + Texture.Limit := 1024*1024; + + +// AddButtonText(11, 10, CatSongs.Song[Pet].Title); // new way + end; +// Covers.Save; + + { if Length(CatSongs.Song) > 0 then // setting to first song + Interaction := 0 + else begin // no song detected + AddButton(400-200, 140, 400, 50, Skin.Button, 'JPG', 'Transparent Range'); + AddButtonText(11, 10, 'No songs detected'); + end;} + + // Randomize Patch + Randomize; + //Equalizer + SetLength(EqualizerBands, Theme.Song.Equalizer.Bands); + //ClearArray + For I := low(EqualizerBands) to high(EqualizerBands) do + EqualizerBands[I] := 3; +end; + +procedure TScreenSong.SetScroll; +begin +//Set Positions + Case Theme.Song.Cover.Style of + 3: SetScroll3; + 5: SetScroll5 + else SetScroll4; + end; +//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 + 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') + ')'; + end + 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)); +end; + +procedure TScreenSong.SetScroll1; +var + B: integer; // button + BMin: integer; // button min + BMax: integer; // button max + Src: integer; +// Dst: integer; + Count: integer; // Dst is not used. Count is used. + Ready: boolean; + + VisCount: integer; // count of visible (or selectable) buttons + VisInt: integer; // visible position of interacted button + Typ: integer; // 0 when all songs fits the screen + Placed: integer; // number of placed visible buttons +begin +// Src := 0; +// Dst := -1; + Count := 1; + Typ := 0; + Ready := false; + Placed := 0; + + VisCount := 0; + 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); + + + if VisCount <= 6 then begin + Typ := 0; + end else begin + if VisInt <= 3 then begin + Typ := 1; + Count := 7; + Ready := true; + end; + + if (VisCount - VisInt) <= 3 then begin + Typ := 2; + Count := 7; + Ready := true; + end; + + if not Ready then begin + Typ := 3; + Src := Interaction; + end; + end; + + + + // hide all buttons + for B := 0 to High(Button) do begin + Button[B].Visible := false; + Button[B].Selectable := CatSongs.Song[B].Visible; + end; + +{ 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;} + + + if Typ = 0 then begin + for B := 0 to High(Button) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (Placed) * 60; + Inc(Placed); + end; + end; + end; + + if Typ = 1 then begin + B := 0; + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Inc(B); + end; + end; + + if Typ = 2 then begin + B := High(Button); + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (6-Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Dec(B); + end; + end; + + if Typ = 3 then begin + B := Src; + Count := 4; + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (3+Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Inc(B); + end; + + B := Src-1; + Placed := 0; + Count := 3; + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (2-Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Dec(B); + end; + + end; + + if Length(Button) > 0 then + Static[1].Texture.Y := Button[Interaction].Y - 5; // selection texture +end; + +procedure TScreenSong.SetScroll2; +var + B: integer; + Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu + Wsp2: real; +begin + // liniowe + for B := 0 to High(Button) do + Button[B].X := 300 + (B - Interaction) * 260; + + 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; + + // kolowe +{ 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;} +end; + +procedure TScreenSong.SetScroll3; // with slide +var + B: integer; + Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu + Wsp2: real; +begin + SongTarget := Interaction; + + // liniowe + for B := 0 to High(Button) do + begin + Button[B].X := 300 + (B - SongCurrent) * 260; + if (Button[B].X < -Button[B].W) OR (Button[B].X > 800) then + Button[B].Visible := False + else + Button[B].Visible := True; + end; + +{ 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;} + + // kolowe +{ 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;} +end; + +procedure TScreenSong.SetScroll4; // rotate +var + B: integer; + Wsp: real; + Z, Z2: real; + VS: integer; +begin + VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important + + // kolowe + 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 + +// Wsp := 2 * pi * (B - SongCurrent) / Length(Button); +// Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - 0) / CatSongs.VisibleSongs; + 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; + + Button[B].X := Theme.Song.Cover.X + (300 + 37 * VS {CatSongs.VisibleSongs} {Length(Button)} * sin(Wsp) - 400) * Z2; // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs + Button[B].Z := Z; + + Button[B].H := Theme.Song.Cover.H * Z2; + Button[B].W := Button[B].H; + +// Button[B].Y := {50 +} 140 + 50 - 50 * Z2; + Button[B].Y := Theme.Song.Cover.Y + (Theme.Song.Cover.H - Button[B].H) * 0.65; + end; + end; +end; + +{procedure TScreenSong.SetScroll4; // rotate +var + B: integer; + Wsp: real; + Z: real; + Z2, Z3: real; + VS: integer; + function modreal (const X, Y: real):real; + begin + Result := Frac(x / y) * y; + if Result < -3 then + Result := Result + Y + else if Result > 3 then + Result := Result - Y; + end; +begin + VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important + Z3 := 1; + if VS < 12 then + Z2 := VS + else + Z2 := 12; + + // kolowe + 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 + begin + if CatSongs.VisibleIndex(B)> SongCurrent then + Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / Z2 + else + Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / Z2; + + Z3 := 2; + Z := (1 + cos(Wsp)) / 2; + //Z2 := (1 + 2*Z) / 3; + //Z2 := (0.5 + Z/2); + //Z2 := sin(Wsp); + + //Z2 := Power (Z2,Z3); + + Button[B].W := Theme.Song.CoverW * Power(cos(Wsp), Z3);//Power(Z2, 3); + + //Button[B].X := Theme.Song.CoverX + ({Theme.Song.CoverX + Theme.Song.CoverW/2 + Theme.Song.CoverW*0.18 * VS {CatSongs.VisibleSongs {Length(Button) * sin(Wsp) {- Theme.Song.CoverX - Theme.Song.CoverW) * Z2; // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs + if (sin(Wsp)<0) then + Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX + Theme.Song.CoverW - Button[B].W + else //*Theme.Song.CoverW*0.004*Z3 + 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 := (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 + begin + Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / 12 ;// 0.5.0 (II): takes another 16ms + + Z := (1 + cos(Wsp)) / 2 -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers + + Button[B].W := Theme.Song.CoverW * Power(cos(Wsp), Z3);//Power(Z2, 3); + + if (sin(Wsp)<0) then + Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX + Theme.Song.CoverW - Button[B].W + else + Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX; + + Button[B].Z := Z; + + Button[B].Y := (Theme.Song.CoverY + Theme.Song.CoverW - Button[B].W); + + Button[B].H := Button[B].W; + Button[B].Visible := True; + end + else Button[B].Visible := False; + end; + end; +end; } + +procedure TScreenSong.SetScroll5; // rotate +var + B: integer; + Angle: real; + Pos: Real; + VS: integer; + diff: real; + X: Real; + {function margin (const X, Y, VS: real):real; //Margin of to Buttons + begin + Result := Frac(x / y) * y; + if (X - VS) >= -3 then + Result := X - VS - Y + else if (X + 3) >= VS then + Result := X - VS + Y + else + Result := X - Y; + end; } +begin + VS := CatSongs.VisibleSongs; // cache Visible Songs + {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 + Theme.Song.CoverH: Höhe der Cover + + (CatSongs.VisibleIndex(B) - SongCurrent)/VS = Abstand zum MIttleren Cover in % + } + + //Change Pos of all Buttons + for B := low(Button) to high(Button) do + begin + Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visability + if Button[B].Visible then //Only Change Pos for Visible Buttons + begin + Pos := (CatSongs.VisibleIndex(B) - SongCurrent); + if (Pos < -VS) then + Pos := Pos + VS + else if (Pos > VS) then + Pos := Pos - VS; + + if (Abs(Pos) < 3) then {fixed Positions} + begin + Angle := Pi * (Pos / 5); + //Button[B].Visible := False; + + Button[B].H := Theme.Song.Cover.H * cos(Angle);//Power(Z2, 3); + + Button[B].Z := 0.95 - Abs(Pos) * 0.01; + + Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Button[B].H) * 0.7); + + Button[B].W := Button[B].H; + + Diff := (Button[B].H - Theme.Song.Cover.H)/2;; + + if (X < 0) then + Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * Sin(Angle){ - Theme.Song.Cover.H/2} - Diff + else + Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * Sin(Angle){ - Theme.Song.Cover.H/2}- Diff; + + Button[B].Visible := True; + end + else + begin {Behind the Front Covers} + //Button[B].Visible := False; + Pos := Frac(Pos / VS); + if Pos < 0 then + Pos := Pos + 1; + + Angle := Abs(2 * pi * ((Pos) / VS / 2)); + //Pos := Power(Pos*2 - 1, 3); + + Button[B].Z := (0.2 + Pos/2) -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers + + //Pos := abs(Pos) mod 1; + + X := sin(Angle); + //Button[B].H := (0.2 + 0.4 * Abs(Pos)) * Theme.Song.Cover.H; //Cover High + Width + Button[B].H := 80; + Button[B].W := Button[B].H; + + Diff := (Theme.Song.Cover.H - Button[B].H)/2; + + //Button[B].X := Theme.Song.Cover.X + (Theme.Song.Cover.W) * Sin(Angle) - diff + //Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * Pos - Diff; + + if (X < 0) then + Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * Sin(Angle) - Theme.Song.Cover.H/2 + Diff + else + Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * Sin(Angle) - Theme.Song.Cover.H/2; + + 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 + + {X := sin(Angle); + + Button[B].H := (0.5 + Power(cos(Angle), 1.7))/1.5 * Theme.Song.Cover.H; //Cover High + Width + Button[B].W := Button[B].H; + + {if (X < 0) then + Diff := Theme.Song.Cover.H - Button[B].H + else + Diff := 0; + + if (((CatSongs.VisibleIndex(B) - SongCurrent)>= -3) AND ((CatSongs.VisibleIndex(B) - SongCurrent) <= 3)) OR (((CatSongs.VisibleIndex(B) - SongCurrent)>= -3 + VS) AND ((CatSongs.VisibleIndex(B) - SongCurrent) <= 3 + VS)) OR (((CatSongs.VisibleIndex(B) - SongCurrent)>= -3 - VS) AND ((CatSongs.VisibleIndex(B) - SongCurrent) <= 3 - VS)) then + Button[B].X := Theme.Song.Cover.X + diff + margin(CatSongs.VisibleIndex(B), SongCurrent, VS)* 30 + else + Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * X + diff;}{ + + Diff := (Button[B].H - Theme.Song.Cover.H)/2; + + if X < 0 then + Button[B].X := Theme.Song.Cover.X + (Theme.Song.Cover.W) * -Power(-X, 1/2) - diff + else + Button[B].X := Theme.Song.Cover.X + (Theme.Song.Cover.W) * Power(X, 1/2) - diff;} + end; + end; +end; + +procedure TScreenSong.onShow; +begin + Music.Stop; + + if Ini.Players <= 3 then PlayersPlay := Ini.Players + 1; + if Ini.Players = 4 then PlayersPlay := 6; + + //Cat Mod etc + if (Ini.Tabs_at_startup = 1) AND (CatSongs.CatNumShow = -1) then + begin + CatSongs.ShowCategoryList; + SelectNext;SelectPrev; //Workaround <- must be fixed sometime + FixSelected; + //Show Cat in Top Left Mod + HideCatTL; + end; + + + if Length(CatSongs.Song) > 0 then begin + Music.SetLoop(false); + Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); + Music.MoveTo(Music.Length / 4); + Music.Play; + SetScroll; + UpdateLCD; + end; + + //Party Mode + if (Mode = 1) then + begin + SelectRandomSong; + end; + + SetJoker; +end; + +function TScreenSong.Draw: boolean; +var + dx: real; + dt: real; +begin + dx := SongTarget-SongCurrent; + dt := TimeSkip*7; + if dt > 1 then dt := 1; + SongCurrent := SongCurrent + dx*dt; + +{ if SongCurrent > Catsongs.VisibleSongs then begin + SongCurrent := SongCurrent - Catsongs.VisibleSongs; + SongTarget := SongTarget - Catsongs.VisibleSongs; + end;} + +// Log.BenchmarkStart(5); + SetScroll; +// Log.BenchmarkEnd(5); +// Log.LogBenchmark('SetScroll4', 5); + + + // 0.5.0: cover fade + if (CoverTime < 1) and (CoverTime + TimeSkip >= 1) then begin + // load new texture + Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); + Button[Interaction].Texture.Alpha := 1; + Button[Interaction].Texture2 := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); + Button[Interaction].Texture2.Alpha := 1; + end; + CoverTime := CoverTime + TimeSkip; + Button[Interaction].Texture2.Alpha := (CoverTime - 1) * 1.5; + if Button[Interaction].Texture2.Alpha > 1 then Button[Interaction].Texture2.Alpha := 1; + + inherited Draw; + + //Draw Equalizer + if Theme.Song.Equalizer.Visible then + DrawEqualizer; + + //Draw Song Menu + if (ScreenSongMenu.Visible) then + begin + ScreenSongMenu.Draw; + end; +end; + +procedure TScreenSong.SelectNext; +var + Skip: integer; + I: integer; +begin + CoverTime := 0; + Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', true); // 0.5.0: show cached texture + Button[Interaction].Texture2.Alpha := 0; + + //0.5.0: unload old full size texture + if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then + Texture.UnloadTexture(Button[Interaction].Texture.Name, false); + + Skip := 1; + + // this 1 could be changed by CatSongs.FindNextVisible + while (not CatSongs.Song[(Interaction + Skip) mod Length(Interactions)].Visible) do Inc(Skip); + SongTarget := SongTarget + 1;//Skip; + + Interaction := (Interaction + Skip) mod Length(Interactions); + + // try to keep all at the beginning + if SongTarget > CatSongs.VisibleSongs-1 then begin + SongTarget := SongTarget - CatSongs.VisibleSongs; + SongCurrent := SongCurrent - CatSongs.VisibleSongs; + end; + + // Interaction -> Button, ktorego okladke przeczytamy +// Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture +end; + +procedure TScreenSong.SelectPrev; +var + Skip: integer; + I: integer; +begin + CoverTime := 0; + Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', true); // 0.5.0: show cached texture + Button[Interaction].Texture2.Alpha := 0; + + //0.5.0: unload old full size texture + if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then + Texture.UnloadTexture(Button[Interaction].Texture.Name, false); + + Skip := 1; + + 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); + + // try to keep all at the beginning + if SongTarget < 0 then begin + SongTarget := SongTarget + CatSongs.VisibleSongs; + SongCurrent := SongCurrent + CatSongs.VisibleSongs; + end; + +// Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture +end; + +procedure TScreenSong.UpdateLCD; +begin + LCD.HideCursor; + LCD.Clear; + LCD.WriteText(1, Text[TextArtist].Text); + LCD.WriteText(2, Text[TextTitle].Text); +end; + +procedure TScreenSong.SkipTo(Target: integer); // 0.5.0 +var + Skip: integer; + I: integer; +begin + CoverTime := 0; + Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', true); // 0.5.0: show cached texture + Button[Interaction].Texture2.Alpha := 0; + + if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then + Texture.UnloadTexture(Button[Interaction].Texture.Name, false); + + Interaction := 0; + SongTarget := 0; + + for I := 2 to Target do + SelectNext; + + FixSelected2; +end; + +procedure TScreenSong.DrawEqualizer; +var + Data: TFFTData; //Audio Data + I, J: Integer; + Res: byte; + A, B: Integer; + PosX, PosY: Integer; + Pos: Real; +begin +if (not Music.Finished) AND (Theme.Song.Equalizer.Length > 0) then +begin + + + A := GetTickCount div 44; + + if (A <> EqualizerTime) then + begin + EqualizerTime := A; + Data := Music.GetFFTData; + + B:=0; + Pos := 0; + Res := floor(92/Theme.Song.Equalizer.Bands);//How much channels are used for one Band + //Change Lengths + for I := 0 to 92 do + begin + A := floor(I/Res); + + if (A<>B) then //Band changed + begin + if (Pos <= Theme.Song.Equalizer.Length) then + begin + if ((Pos < EqualizerBands[B]) AND (EqualizerBands[B]>1)) then + EqualizerBands[B] := EqualizerBands[B] - 1 + else + EqualizerBands[B] := floor(Pos); + end + else + EqualizerBands[B] := 1; + + B := A; + Pos := 0; + end; + + if I > 35 then + Data[i] := Data[i] * 8 + else if I > 11 then + Data[i] := Data[i] * 4.5 + else + Data[i] := Data[i] * 1.1; + + if (Data[i] >= 1) then + Data[i] := 0.9999999999999; + + if Data[i]*Theme.Song.Equalizer.Length > Pos then + Pos := Data[i]*Theme.Song.Equalizer.Length; + end; + + //Change Last Band + if (EqualizerBands[B] <= Theme.Song.Equalizer.Length) then + begin + if ((Pos < EqualizerBands[B]) AND (EqualizerBands[B]>1)) then + EqualizerBands[B] := EqualizerBands[B] - 1 + else + EqualizerBands[B] := floor(Pos) + end + else + EqualizerBands[B] := 1; + end; + + //Draw every Channel + glColor4f(Theme.Song.Equalizer.ColR, Theme.Song.Equalizer.ColG, Theme.Song.Equalizer.ColB, Theme.Song.Equalizer.Alpha); //Set Color + glDisable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + + PosY := Theme.Song.Equalizer.Y; + PosX := Theme.Song.Equalizer.X; + + For I := 0 to Theme.Song.Equalizer.Bands do + begin + if Theme.Song.Equalizer.Direction then + PosY := Theme.Song.Equalizer.Y //+ (Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space) * Theme.Song.Equalizer.Length + else + PosX := Theme.Song.Equalizer.X; + //Draw for every visible quad + for J := 1 to EqualizerBands[I] do + begin + glBegin(GL_QUADS); + glVertex3f(PosX, PosY, Theme.Song.Equalizer.Z); + glVertex3f(PosX, PosY+Theme.Song.Equalizer.H, Theme.Song.Equalizer.Z); + glVertex3f(PosX+Theme.Song.Equalizer.W, PosY+Theme.Song.Equalizer.H, Theme.Song.Equalizer.Z); + glVertex3f(PosX+Theme.Song.Equalizer.W, PosY, Theme.Song.Equalizer.Z); + glEnd; + + if Theme.Song.Equalizer.Direction then //Vertically + PosY := PosY - Theme.Song.Equalizer.H - Theme.Song.Equalizer.Space + else //Horizontally + PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space; + end; + if Theme.Song.Equalizer.Direction then //Horizontally + PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space + else //Vertically + PosY := PosY + Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space; + end; +end; +end; + +Procedure TScreenSong.SelectRandomSong; +var + I, I2: Integer; +begin + 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 + begin + if CatSongs.Song[I].Main then + break; + end; + //In I ist jetzt die Kategorie in I2 der Song + + //Choose Cat + CatSongs.ShowCategoryList; + + //Show Cat in Top Left Mod + ShowCatTL (I); + + CatSongs.ClickCategoryButton(I); + SelectNext; + + //Fix: Not Existing Song selected: + if (I+1=I2) then Inc(I2); + + //Choose Song + SkipTo(I2-I); + + Music.Close; + if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin + Music.MoveTo(Music.Length / 4); + Music.Play; + end; +end; + +procedure TScreenSong.SetJoker; +begin + //If Party Mode + if Mode = 1 then //Show Joker that are available + begin + if (PartySession.Teams.NumTeams >= 1) then + begin + Static[StaticTeam1Joker1].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 1); + Static[StaticTeam1Joker2].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 2); + Static[StaticTeam1Joker3].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 3); + Static[StaticTeam1Joker4].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 4); + Static[StaticTeam1Joker5].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 5); + end + else + begin + Static[StaticTeam1Joker1].Visible := False; + Static[StaticTeam1Joker2].Visible := False; + Static[StaticTeam1Joker3].Visible := False; + Static[StaticTeam1Joker4].Visible := False; + Static[StaticTeam1Joker5].Visible := False; + end; + + if (PartySession.Teams.NumTeams >= 2) then + begin + Static[StaticTeam2Joker1].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 1); + Static[StaticTeam2Joker2].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 2); + Static[StaticTeam2Joker3].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 3); + Static[StaticTeam2Joker4].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 4); + Static[StaticTeam2Joker5].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 5); + end + else + begin + Static[StaticTeam2Joker1].Visible := False; + Static[StaticTeam2Joker2].Visible := False; + Static[StaticTeam2Joker3].Visible := False; + Static[StaticTeam2Joker4].Visible := False; + Static[StaticTeam2Joker5].Visible := False; + end; + + if (PartySession.Teams.NumTeams >= 3) then + begin + Static[StaticTeam3Joker1].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 1); + Static[StaticTeam3Joker2].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 2); + Static[StaticTeam3Joker3].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 3); + Static[StaticTeam3Joker4].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 4); + Static[StaticTeam3Joker5].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 5); + end + else + begin + Static[StaticTeam3Joker1].Visible := False; + Static[StaticTeam3Joker2].Visible := False; + Static[StaticTeam3Joker3].Visible := False; + Static[StaticTeam3Joker4].Visible := False; + Static[StaticTeam3Joker5].Visible := False; + end; + end + else + begin //Hide all + Static[StaticTeam1Joker1].Visible := False; + Static[StaticTeam1Joker2].Visible := False; + Static[StaticTeam1Joker3].Visible := False; + Static[StaticTeam1Joker4].Visible := False; + Static[StaticTeam1Joker5].Visible := False; + + Static[StaticTeam2Joker1].Visible := False; + Static[StaticTeam2Joker2].Visible := False; + Static[StaticTeam2Joker3].Visible := False; + Static[StaticTeam2Joker4].Visible := False; + Static[StaticTeam2Joker5].Visible := False; + + Static[StaticTeam3Joker1].Visible := False; + Static[StaticTeam3Joker2].Visible := False; + Static[StaticTeam3Joker3].Visible := False; + Static[StaticTeam3Joker4].Visible := False; + Static[StaticTeam3Joker5].Visible := False; + end; +end; + +//Procedures for Menu + +procedure TScreenSong.StartSong; +begin + CatSongs.Selected := Interaction; + Music.Stop; + //Party Mode + if (Mode = 1) then + begin + FadeTo(@ScreenSingModi); + end + else + begin + FadeTo(@ScreenSing); + end; +end; + +procedure TScreenSong.OpenEditor; +begin + if (Length(Songs.Song) > 0) and (not CatSongs.Song[Interaction].Main) AND (Mode = 0) then begin + Music.Stop; + Music.PlayStart; + ScreenEditSub.Path := CatSongs.Song[Interaction].Path; + ScreenEditSub.FileName := CatSongs.Song[Interaction].FileName; + FadeTo(@ScreenEditSub); + end; +end; + +//Team No of Team (0-5) +procedure TScreenSong.DoJoker (Team: Byte); +begin + if (Mode = 1) AND (PartySession.Teams.NumTeams >= Team + 1) AND (PartySession.Teams.Teaminfo[Team].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[Team].Joker); + SelectRandomSong; + SetJoker; + end; +end; + +procedure TScreenSong.Refresh; +begin { +CatSongs.Refresh; +CatSongs.ShowCategoryList; +Interaction := 0; +SelectNext; +FixSelected; } + +end; + +end. -- cgit v1.2.3 From 60521ca33e23a91f2ea8aecf506b9aa5e6bda54a Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 25 Mar 2007 10:41:53 +0000 Subject: 2 Bugs in Cover Positions fixed: Style4 (Classic): Positions now Readed from Theme, No Overlapping Style5 (Deluxe): correct Positions of Covers in the Front No Cut from Last to First Todo: Correct Positions of Covers in the back(Now Invisible) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@32 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 82 ++++++++++++--------------------------- 1 file changed, 25 insertions(+), 57 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 0d7860a7..cd412ceb 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1021,21 +1021,19 @@ 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 -// Wsp := 2 * pi * (B - SongCurrent) / Length(Button); -// Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - 0) / CatSongs.VisibleSongs; Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / VS {CatSongs.VisibleSongs};// 0.5.0 (II): takes another 16ms - Z := (1 + cos(Wsp)) / 2; + Z := (1 + cos(Wsp)) / 2 - 0.02; Z2 := (1 + 2*Z) / 3; - Button[B].X := Theme.Song.Cover.X + (300 + 37 * VS {CatSongs.VisibleSongs} {Length(Button)} * sin(Wsp) - 400) * Z2; // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs + Button[B].X := Theme.Song.Cover.X + (Theme.Song.Cover.W + 0.185 * Theme.Song.Cover.H * VS * sin(Wsp) - Theme.Song.Cover.X) * Z2; // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs Button[B].Z := Z; - Button[B].H := Theme.Song.Cover.H * Z2; - Button[B].W := Button[B].H; + 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 - Button[B].H) * 0.65; + 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; @@ -1158,17 +1156,17 @@ begin if Button[B].Visible then //Only Change Pos for Visible Buttons begin Pos := (CatSongs.VisibleIndex(B) - SongCurrent); - if (Pos < -VS) then + if (Pos < -VS/2) then Pos := Pos + VS - else if (Pos > VS) then + else if (Pos > VS/2) then Pos := Pos - VS; - if (Abs(Pos) < 3) then {fixed Positions} + if (Abs(Pos) < 2.5) then {fixed Positions} begin Angle := Pi * (Pos / 5); //Button[B].Visible := False; - Button[B].H := Theme.Song.Cover.H * cos(Angle);//Power(Z2, 3); + Button[B].H := Abs(Theme.Song.Cover.H * cos(Angle));//Power(Z2, 3); Button[B].Z := 0.95 - Abs(Pos) * 0.01; @@ -1178,67 +1176,37 @@ begin Diff := (Button[B].H - Theme.Song.Cover.H)/2;; - if (X < 0) then - Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * Sin(Angle){ - Theme.Song.Cover.H/2} - Diff - else - Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * Sin(Angle){ - Theme.Song.Cover.H/2}- Diff; + Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * Sin(Angle) - Diff; - Button[B].Visible := True; end else begin {Behind the Front Covers} - //Button[B].Visible := False; - Pos := Frac(Pos / VS); - if Pos < 0 then - Pos := Pos + 1; - - Angle := Abs(2 * pi * ((Pos) / VS / 2)); - //Pos := Power(Pos*2 - 1, 3); + Button[B].Visible := False; - Button[B].Z := (0.2 + Pos/2) -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers + if Pos < 0 then + Pos := (Pos - VS/2) /VS + else + Pos := (Pos + VS/2) /VS; - //Pos := abs(Pos) mod 1; + Angle := 2 * pi * Pos; - X := sin(Angle); - //Button[B].H := (0.2 + 0.4 * Abs(Pos)) * Theme.Song.Cover.H; //Cover High + Width - Button[B].H := 80; - Button[B].W := Button[B].H; + Button[B].Z := (0.5 - Abs(Pos/4)) -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers - Diff := (Theme.Song.Cover.H - Button[B].H)/2; + Button[B].H := Abs(Theme.Song.Cover.H * cos(Angle));//Power(Z2, 3); - //Button[B].X := Theme.Song.Cover.X + (Theme.Song.Cover.W) * Sin(Angle) - diff - //Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * Pos - Diff; + Button[B].W := Button[B].H; - if (X < 0) then - Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * Sin(Angle) - Theme.Song.Cover.H/2 + Diff - else - Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * Sin(Angle) - Theme.Song.Cover.H/2; - - end; + 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)/1.5); //Cover at down border of the change field + Diff := (Button[B].H - Theme.Song.Cover.H)/2;; - {X := sin(Angle); + Button[B].X := Theme.Song.Cover.X + (Theme.Song.Cover.W + Theme.Song.Cover.H*VS*0.185)* Sin(Angle) - Diff - Button[B].H := (0.5 + Power(cos(Angle), 1.7))/1.5 * Theme.Song.Cover.H; //Cover High + Width - Button[B].W := Button[B].H; - - {if (X < 0) then - Diff := Theme.Song.Cover.H - Button[B].H - else - Diff := 0; - - if (((CatSongs.VisibleIndex(B) - SongCurrent)>= -3) AND ((CatSongs.VisibleIndex(B) - SongCurrent) <= 3)) OR (((CatSongs.VisibleIndex(B) - SongCurrent)>= -3 + VS) AND ((CatSongs.VisibleIndex(B) - SongCurrent) <= 3 + VS)) OR (((CatSongs.VisibleIndex(B) - SongCurrent)>= -3 - VS) AND ((CatSongs.VisibleIndex(B) - SongCurrent) <= 3 - VS)) then - Button[B].X := Theme.Song.Cover.X + diff + margin(CatSongs.VisibleIndex(B), SongCurrent, VS)* 30 - else - Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * X + diff;}{ + end; - Diff := (Button[B].H - Theme.Song.Cover.H)/2; + //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); - if X < 0 then - Button[B].X := Theme.Song.Cover.X + (Theme.Song.Cover.W) * -Power(-X, 1/2) - diff - else - Button[B].X := Theme.Song.Cover.X + (Theme.Song.Cover.W) * Power(X, 1/2) - diff;} end; end; end; -- cgit v1.2.3 From 3ba33f8e920a9e9a3114f159e2b6fda4273a6efb Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 28 Mar 2007 13:08:41 +0000 Subject: Added Jumpto Ability to SongScreen (Press J) Fixed: Golden Notes are not shown in PartyMode git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@39 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 371 +++++++++++++++----------------------- 1 file changed, 149 insertions(+), 222 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index cd412ceb..69ec8639 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -69,7 +69,8 @@ type procedure SkipTo(Target: integer); procedure FixSelected; //Show Wrong Song when Tabs on Fix procedure FixSelected2; //Show Wrong Song when Tabs on Fix - procedure ShowCatTL(Cat: Integer);// Show Cat in Tob left + procedure ShowCatTL(Cat: Integer);// Show Cat in Top left + procedure ShowCatTLCustom(Caption: String);// Show Custom Text in Top left procedure HideCatTL;// Show Cat in Tob left procedure Refresh; //Refresh Song Sorting procedure DrawEqualizer; @@ -81,6 +82,9 @@ type procedure StartSong; procedure OpenEditor; procedure DoJoker(Team: Byte); + + //Extensions + procedure DrawExtensions; end; implementation @@ -92,37 +96,50 @@ uses UGraphic, UMain, UCovers, math, OpenGL12, Windows, USkins, UDLLManager, UPa procedure TScreenSong.FixSelected; var I, I2: Integer; begin - I2:= 0; - for I := low(CatSongs.Song) to High(Catsongs.Song) do + if CatSongs.VisibleSongs > 0 then begin - if CatSongs.Song[I].Visible then - inc(I2); + 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 I = Interaction - 1 then + break; + end; - SongCurrent := I2; - SongTarget := I2; + SongCurrent := I2; + SongTarget := I2; + end; end; procedure TScreenSong.FixSelected2; var I, I2: Integer; begin - I2:= 0; - for I := low(CatSongs.Song) to High(Catsongs.Song) do + if CatSongs.VisibleSongs > 0 then begin - if CatSongs.Song[I].Visible then - inc(I2); + 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 I = Interaction - 1 then + break; + end; - SongTarget := I2; + SongTarget := I2; + 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; + end; + //Show Cat in Top Left Mod procedure TScreenSong.ShowCatTL(Cat: Integer); begin @@ -162,164 +179,24 @@ var begin Result := true; - //Song Menu + //Song Screen Extensions (Jumpto + Menu) if (ScreenSongMenu.Visible) then begin Result := ScreenSongMenu.ParseInput(PressedKey, ScanCode, PressedDown); Exit; + end + else if (ScreenSongJumpto.Visible) then + begin + Result := ScreenSongJumpto.ParseInput(PressedKey, ScanCode, PressedDown); + Exit; end; If (PressedDown) Then begin // Key Down -// HS := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT); -{ if (not HighSpeed) and (HS > 0) then begin - HighSpeed := true; - SDL_EnableKeyRepeat(50, 50); - end; - if (HighSpeed) and (HS = 0) then begin - HighSpeed := false; - SDL_EnableKeyRepeat(125, 125); - end;} - - SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT + SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT); - // Jump to Key Mod - if (SDL_ModState = KMOD_LALT) AND (Mode = 0) then //Jump to Key - begin - //get Letter - case PressedKey of - SDLK_A : Letter := 'A'; - SDLK_B : Letter := 'B'; - SDLK_C : Letter := 'C'; - SDLK_D : Letter := 'D'; - SDLK_E : Letter := 'E'; - SDLK_F : Letter := 'F'; - SDLK_G : Letter := 'G'; - SDLK_H : Letter := 'H'; - SDLK_I : Letter := 'I'; - SDLK_J : Letter := 'J'; - SDLK_K : Letter := 'K'; - SDLK_L : Letter := 'L'; - SDLK_M : Letter := 'M'; - SDLK_N : Letter := 'N'; - SDLK_O : Letter := 'O'; - SDLK_P : Letter := 'P'; - SDLK_Q : Letter := 'Q'; - SDLK_R : Letter := 'R'; - SDLK_S : Letter := 'S'; - SDLK_T : Letter := 'T'; - SDLK_U : Letter := 'U'; - SDLK_V : Letter := 'V'; - SDLK_W : Letter := 'W'; - SDLK_X : Letter := 'X'; - SDLK_Y : Letter := 'Y'; - SDLK_Z : Letter := 'Z'; - SDLK_1 : Letter := '1'; - SDLK_2 : Letter := '2'; - SDLK_3 : Letter := '3'; - SDLK_4 : Letter := '4'; - SDLK_5 : Letter := '5'; - SDLK_6 : Letter := '6'; - SDLK_7 : Letter := '7'; - SDLK_8 : Letter := '8'; - SDLK_9 : Letter := '9'; - SDLK_0 : Letter := '0'; - else exit; - end; - - {//Search Letter - for I := Interaction + 1 to high(CatSongs.Song) do - begin - if CatSongs.Song[I].Visible and (Letter = Uppercase(CatSongs.Song[I].Artist)[1]) then - break; //Found Song - if I = Interaction then //went through complete array but nothing Found - break; - if I = high(CatSongs.Song) then //At the end of the array->Go to beginning - for I2 := low(CatSongs.Song) to Interaction do - if CatSongs.Song[I].Visible and (Letter = Uppercase(CatSongs.Song[I].Artist)[1]) then - break; //Found Song - end; } - - for I := 0 to High(CatSongs.Song) do begin - if (CatSongs.Song[I].Visible) AND (UpperCase(CatSongs.Song[I].Artist[1]) = Letter) then - begin - //Select Song - Interaction := I; - SkipTo(Interaction); - break; - end; - end; - - //Don't do other Functions - exit; - end; - - if (SDL_ModState = KMOD_LALT or KMOD_LSHIFT) then //Jump to Key - begin - //get Letter - case PressedKey of - SDLK_a..SDLK_z : Letter := Chr(Ord('a')+PressedKey-97); - SDLK_1 : Letter := '1'; - SDLK_2 : Letter := '2'; - SDLK_3 : Letter := '3'; - SDLK_4 : Letter := '4'; - SDLK_5 : Letter := '5'; - SDLK_6 : Letter := '6'; - SDLK_7 : Letter := '7'; - SDLK_8 : Letter := '8'; - SDLK_9 : Letter := '9'; - SDLK_0 : Letter := '0'; - else exit; - end; - - {//Search Letter - for I := Interaction + 1 to high(CatSongs.Song) do - begin - if CatSongs.Song[I].Visible and (Letter = Uppercase(CatSongs.Song[I].Artist)[1]) then - break; //Found Song - if I = Interaction then //went through complete array but nothing Found - break; - if I = high(CatSongs.Song) then //At the end of the array->Go to beginning - for I2 := low(CatSongs.Song) to Interaction do - if CatSongs.Song[I].Visible and (Letter = Uppercase(CatSongs.Song[I].Artist)[1]) then - break; //Found Song - end; } - - {for I := 0 to High(CatSongs.Song) do begin - if (CatSongs.Song[I].Visible) AND (UpperCase(CatSongs.Song[I].Artist[1]) = Letter) then} - - for I := Interaction + 1 to high(CatSongs.Song) + 1 do - begin - if (I > high(CatSongs.Song)) then - begin - for I2 := low(CatSongs.Song) to Interaction do - begin - if CatSongs.Song[I2].Visible and (Letter = lowercase(CatSongs.Song[I2].Artist[1])) then - begin - Interaction := I2; - break; //Found Song - end; - end; - break; - end - else if CatSongs.Song[I].Visible and (Letter = lowercase(CatSongs.Song[I].Artist[1])) then - begin - Interaction := I; - break; //Found Song - end; - end; - - - //Select Song - SkipTo(Interaction); - - //Don't do other Functions - exit; - end; - - case PressedKey of SDLK_ESCAPE : begin @@ -406,7 +283,6 @@ begin end else if (Mode = 1) then //PartyMode -> Show Menu begin - ScreenSongMenu.Visible := True; ScreenSongMenu.MenuShow(SM_Party_Main); end; end; @@ -417,12 +293,19 @@ begin begin if Length(Songs.Song) > 0 then begin if not CatSongs.Song[Interaction].Main then begin // clicked on Song - ScreenSongMenu.Visible := True; ScreenSongMenu.MenuShow(SM_Main); end; end; end; + SDLK_J: //Show SongMenu + begin + if Length(Songs.Song) > 0 then + begin + ScreenSongJumpto.Visible := True; + end; + end; + SDLK_DOWN: begin if (Mode = 0) then @@ -788,25 +671,47 @@ begin end; procedure TScreenSong.SetScroll; +var + VS, B: Integer; begin -//Set Positions - Case Theme.Song.Cover.Style of - 3: SetScroll3; - 5: SetScroll5 - else SetScroll4; - end; -//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 + VS := CatSongs.VisibleSongs; + if VS > 0 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') + ')'; + //Set Positions + Case Theme.Song.Cover.Style of + 3: SetScroll3; + 5:begin + if VS > 5 then + SetScroll5 + else + SetScroll4; + end; + else SetScroll4; + end; + //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 + 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') + ')'; + end + else if (CatSongs.CatNumShow = -2) then + Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) + 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)); end - 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)); + begin + Text[TextNumber].Text := '0/0'; + Text[TextArtist].Text := ''; + Text[TextTitle].Text := ''; + for B := 0 to High(Button) do + Button[B].Visible := False; + + end; end; procedure TScreenSong.SetScroll1; @@ -1023,7 +928,7 @@ begin Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / VS {CatSongs.VisibleSongs};// 0.5.0 (II): takes another 16ms - Z := (1 + cos(Wsp)) / 2 - 0.02; + Z := (1 + cos(Wsp)) / 2 - 0.2; Z2 := (1 + 2*Z) / 3; Button[B].X := Theme.Song.Cover.X + (Theme.Song.Cover.W + 0.185 * Theme.Song.Cover.H * VS * sin(Wsp) - Theme.Song.Cover.X) * Z2; // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs @@ -1247,6 +1152,19 @@ begin SetJoker; end; +procedure TScreenSong.DrawExtensions; +begin + //Draw Song Menu + if (ScreenSongMenu.Visible) then + begin + ScreenSongMenu.Draw; + end + else if (ScreenSongJumpto.Visible) then + begin + ScreenSongJumpto.Draw; + end +end; + function TScreenSong.Draw: boolean; var dx: real; @@ -1286,71 +1204,80 @@ begin if Theme.Song.Equalizer.Visible then DrawEqualizer; - //Draw Song Menu - if (ScreenSongMenu.Visible) then - begin - ScreenSongMenu.Draw; - end; + DrawExtensions; end; procedure TScreenSong.SelectNext; var Skip: integer; I: integer; + VS: Integer; begin - CoverTime := 0; - Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', true); // 0.5.0: show cached texture - Button[Interaction].Texture2.Alpha := 0; + VS := CatSongs.VisibleSongs; - //0.5.0: unload old full size texture - if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then - Texture.UnloadTexture(Button[Interaction].Texture.Name, false); + if VS > 0 then + begin + CoverTime := 0; + Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', true); // 0.5.0: show cached texture + Button[Interaction].Texture2.Alpha := 0; - Skip := 1; + //0.5.0: unload old full size texture + if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then + Texture.UnloadTexture(Button[Interaction].Texture.Name, false); - // this 1 could be changed by CatSongs.FindNextVisible - while (not CatSongs.Song[(Interaction + Skip) mod Length(Interactions)].Visible) do Inc(Skip); - SongTarget := SongTarget + 1;//Skip; + Skip := 1; - Interaction := (Interaction + Skip) mod Length(Interactions); + // this 1 could be changed by CatSongs.FindNextVisible + while (not CatSongs.Song[(Interaction + Skip) mod Length(Interactions)].Visible) do Inc(Skip); - // try to keep all at the beginning - if SongTarget > CatSongs.VisibleSongs-1 then begin - SongTarget := SongTarget - CatSongs.VisibleSongs; - SongCurrent := SongCurrent - CatSongs.VisibleSongs; - end; + SongTarget := SongTarget + 1;//Skip; - // Interaction -> Button, ktorego okladke przeczytamy -// Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture + Interaction := (Interaction + Skip) mod Length(Interactions); + + // try to keep all at the beginning + if SongTarget > VS-1 then begin + SongTarget := SongTarget - VS; + SongCurrent := SongCurrent - VS; + end; + + end; + // Interaction -> Button, ktorego okladke przeczytamy + // Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture end; procedure TScreenSong.SelectPrev; var Skip: integer; I: integer; + VS: Integer; begin - CoverTime := 0; - Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', true); // 0.5.0: show cached texture - Button[Interaction].Texture2.Alpha := 0; + VS := CatSongs.VisibleSongs; - //0.5.0: unload old full size texture - if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then - Texture.UnloadTexture(Button[Interaction].Texture.Name, false); + if VS > 0 then + begin + CoverTime := 0; + Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', true); // 0.5.0: show cached texture + Button[Interaction].Texture2.Alpha := 0; - Skip := 1; + //0.5.0: unload old full size texture + if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then + Texture.UnloadTexture(Button[Interaction].Texture.Name, false); - while (not CatSongs.Song[(Interaction - Skip + Length(Interactions)) mod Length(Interactions)].Visible) do Inc(Skip); - SongTarget := SongTarget - 1;//Skip; + Skip := 1; - Interaction := (Interaction - Skip + Length(Interactions)) mod Length(Interactions); + while (not CatSongs.Song[(Interaction - Skip + Length(Interactions)) mod Length(Interactions)].Visible) do Inc(Skip); + SongTarget := SongTarget - 1;//Skip; - // try to keep all at the beginning - if SongTarget < 0 then begin - SongTarget := SongTarget + CatSongs.VisibleSongs; - SongCurrent := SongCurrent + CatSongs.VisibleSongs; - end; + Interaction := (Interaction - Skip + Length(Interactions)) mod Length(Interactions); -// Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture + // try to keep all at the beginning + if SongTarget < 0 then begin + SongTarget := SongTarget + CatSongs.VisibleSongs; + SongCurrent := SongCurrent + CatSongs.VisibleSongs; + end; + + // Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture + end; end; procedure TScreenSong.UpdateLCD; -- cgit v1.2.3 From 8d591b8344e0cb87e1a987961b3790fa26d323a6 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Thu, 29 Mar 2007 12:40:11 +0000 Subject: Fixed Some Bugs in JumpTo Screen: Now plays correct music Space Bug is gone Added onSentenceChange Procedure to ScreenSing git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@48 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 58 ++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 35 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 69ec8639..9202717d 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -74,6 +74,7 @@ type procedure HideCatTL;// Show Cat in Tob left procedure Refresh; //Refresh Song Sorting procedure DrawEqualizer; + procedure ChangeMusic; //Party Mode procedure SelectRandomSong; procedure SetJoker; @@ -269,11 +270,7 @@ begin FixSelected; //Play Music: - Music.Close; - if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin - Music.MoveTo(Music.Length / 4); - Music.Play; - end; + ChangeMusic; end else begin // clicked on song if (Mode = 0) then //Normal Mode -> Start Song @@ -342,11 +339,7 @@ begin //Play Music: Music.PlayChange; - Music.Close; - if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin - Music.MoveTo(Music.Length / 4); - Music.Play; - end; + ChangeMusic; end; @@ -392,11 +385,7 @@ begin //Play Music: Music.PlayChange; - Music.Close; - if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin - Music.MoveTo(Music.Length / 4); - Music.Play; - end; + ChangeMusic; end; @@ -412,11 +401,7 @@ begin SelectNext; // InteractNext; // SongTarget := Interaction; - Music.Close; - if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin - Music.MoveTo(Music.Length / 4); - Music.Play; - end; + ChangeMusic; SetScroll4; UpdateLCD; Light.LightOne(1, 200); @@ -428,11 +413,7 @@ begin if (Length(Songs.Song) > 0)AND (Mode = 0) then begin Music.PlayChange; SelectPrev; - Music.Close; - if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin - Music.MoveTo(Music.Length / 4); - Music.Play; - end; + ChangeMusic; SetScroll4; UpdateLCD; Light.LightOne(0, 200); @@ -514,11 +495,7 @@ begin end; Music.PlayChange; - Music.Close; - if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin - Music.MoveTo(Music.Length / 4); - Music.Play; - end; + ChangeMusic; SetScroll4; UpdateLCD; end; @@ -1288,6 +1265,21 @@ begin LCD.WriteText(2, Text[TextTitle].Text); end; +//Procedure Change current played Preview +procedure TScreenSong.ChangeMusic; +begin + if (NOT CatSongs.Song[Interaction].Main) AND(CatSongs.VisibleSongs > 0) then + begin + Music.Close; + if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin + Music.MoveTo(Music.Length / 4); + Music.Play; + end; + end + else + Music.Stop; +end; + procedure TScreenSong.SkipTo(Target: integer); // 0.5.0 var Skip: integer; @@ -1447,11 +1439,7 @@ begin //Choose Song SkipTo(I2-I); - Music.Close; - if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin - Music.MoveTo(Music.Length / 4); - Music.Play; - end; + ChangeMusic; end; procedure TScreenSong.SetJoker; -- cgit v1.2.3 From 563375e18e4aeba0152a9761f1f84d66aaeb27d2 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Fri, 30 Mar 2007 12:19:08 +0000 Subject: Finished Code for Plugin Sound PlayBack Removed Debug Message from ULanguage git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@50 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 9202717d..694ecc39 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -149,7 +149,7 @@ var I, I2: Integer; //showmessage(CatSongs.Song[Cat].Path + CatSongs.Song[Cat].Cover); //Static[StaticCat].Texture := Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', true); - Static[StaticCat].Texture := Texture.GetTexture(CatSongs.Song[Cat].Path + CatSongs.Song[Cat].Cover, 'Plain', true); + Static[StaticCat].Texture := Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', true); //Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', false); //Button[Cat]. //Cover @@ -198,6 +198,30 @@ begin SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT); + {//Jump To + if (SDL_ModState = KMOD_LALT) AND (PressedKey > SDLK_A) AND (PressedKey < SDLK_Z) then + begin + Letter := UpCase(Chr(ScanCode)); + Log.LogError(Letter); + I2 := Length(CatSongs.Song); + 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 (UpCase(CatSongs.Song[(I + Interaction) mod I2].Title[1]) = Letter) then + begin + SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); + + Music.PlayChange; + + ChangeMusic; + SetScroll4; + UpdateLCD; + //Break and Exit + Exit; + end; + end; + Exit; + end; } + case PressedKey of SDLK_ESCAPE : begin -- cgit v1.2.3 From e2cd03822f28a4866f98fb0893a73b02bd60ce03 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Thu, 5 Apr 2007 14:37:58 +0000 Subject: Added Playlist Support Working correct with Standard Mode Only for now Now working on Playlist Support for Party Mode git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@59 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 694ecc39..6a1df197 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -314,12 +314,26 @@ begin begin if Length(Songs.Song) > 0 then begin if not CatSongs.Song[Interaction].Main then begin // clicked on Song - ScreenSongMenu.MenuShow(SM_Main); + if CatSongs.CatNumShow = -3 then + ScreenSongMenu.MenuShow(SM_Playlist) + else + ScreenSongMenu.MenuShow(SM_Main); + end + else + begin + ScreenSongMenu.MenuShow(SM_Playlist_Load); end; end; end; - SDLK_J: //Show SongMenu + SDLK_P: //Show Playlist Menu + begin + if Length(Songs.Song) > 0 then begin + ScreenSongMenu.MenuShow(SM_Playlist_Load); + end; + end; + + SDLK_J: //Show Jumpto Menu begin if Length(Songs.Song) > 0 then begin @@ -699,6 +713,8 @@ begin end else if (CatSongs.CatNumShow = -2) then Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) + else if (CatSongs.CatNumShow = -3) then + Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) 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 @@ -1144,8 +1160,18 @@ begin UpdateLCD; end; + //Playlist Mode + if (Mode = 0) then + begin + //If Playlist Shown -> Select Next automatically + if (CatSongs.CatNumShow = -3) then + begin + SelectNext; + ChangeMusic; + end; + end //Party Mode - if (Mode = 1) then + else if (Mode = 1) then begin SelectRandomSong; end; -- cgit v1.2.3 From 4f7bf28056fefdcd000499c583a47738ce7d9b07 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Fri, 6 Apr 2007 10:32:24 +0000 Subject: Fixed a Bug in Optionsscreen after adding OptionsAdvanced Screen Added Jump to Title HotKey (Alt + A..Z) Added Playlist Support to Party Mode, Category Only Mode is still buggy. Fixed: Team3 Players are now Hidden when only 2 Teams are Selected git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@67 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 89 ++++++++++++++++++++++++++------------- 1 file changed, 60 insertions(+), 29 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 6a1df197..2af37dd5 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -89,7 +89,7 @@ type end; implementation -uses UGraphic, UMain, UCovers, math, OpenGL12, Windows, USkins, UDLLManager, UParty, UScreenSongMenu; +uses UGraphic, UMain, UCovers, math, OpenGL12, Windows, USkins, UDLLManager, UParty, UPlaylist, UScreenSongMenu; // ***** Public methods ****** // @@ -198,8 +198,8 @@ begin SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT); - {//Jump To - if (SDL_ModState = KMOD_LALT) AND (PressedKey > SDLK_A) AND (PressedKey < SDLK_Z) then + //Jump To + if (SDL_ModState = KMOD_LALT) AND (Mode = 0) AND (PressedKey > SDLK_A) AND (PressedKey < SDLK_Z) then begin Letter := UpCase(Chr(ScanCode)); Log.LogError(Letter); @@ -208,7 +208,7 @@ begin begin if (CatSongs.Song[(I + Interaction) mod I2].Visible) AND (Length(CatSongs.Song[(I + Interaction) mod I2].Title)>0) AND (UpCase(CatSongs.Song[(I + Interaction) mod I2].Title[1]) = Letter) then begin - SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); + SkipTo(2 + CatSongs.VisibleIndex((I + Interaction) mod I2)); Music.PlayChange; @@ -220,7 +220,7 @@ begin end; end; Exit; - end; } + end; case PressedKey of SDLK_ESCAPE : @@ -312,7 +312,7 @@ begin SDLK_M: //Show SongMenu begin - if Length(Songs.Song) > 0 then begin + if (Length(Songs.Song) > 0) AND (Mode = 0) then begin if not CatSongs.Song[Interaction].Main then begin // clicked on Song if CatSongs.CatNumShow = -3 then ScreenSongMenu.MenuShow(SM_Playlist) @@ -328,14 +328,14 @@ begin SDLK_P: //Show Playlist Menu begin - if Length(Songs.Song) > 0 then begin + if (Length(Songs.Song) > 0) AND (Mode = 0) then begin ScreenSongMenu.MenuShow(SM_Playlist_Load); end; end; SDLK_J: //Show Jumpto Menu begin - if Length(Songs.Song) > 0 then + if (Length(Songs.Song) > 0) AND (Mode = 0) then begin ScreenSongJumpto.Visible := True; end; @@ -1462,34 +1462,65 @@ Procedure TScreenSong.SelectRandomSong; var I, I2: Integer; begin - repeat - I2 := Random(high(CatSongs.Song)+1) - low(CatSongs.Song)+1; - until CatSongs.Song[I2].Main = false; + Case PlaylistMan.Mode of + 0: //All Songs Just Select Random Song + begin + 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 - begin - if CatSongs.Song[I].Main then - break; - end; - //In I ist jetzt die Kategorie in I2 der Song + //Search Cat + for I := I2 downto low(CatSongs.Song) do + begin + if CatSongs.Song[I].Main then + break; + end; + //In I ist jetzt die Kategorie in I2 der Song - //Choose Cat - CatSongs.ShowCategoryList; + //Choose Cat + CatSongs.ShowCategoryList; - //Show Cat in Top Left Mod - ShowCatTL (I); + //Show Cat in Top Left Mod + ShowCatTL (I); + + CatSongs.ClickCategoryButton(I); + SelectNext; + + //Fix: Not Existing Song selected: + if (I+1=I2) then Inc(I2); + + //Choose Song + SkipTo(I2-I); + end; + 1: //One Category Select Category and Select Random Song + begin + CatSongs.HideCategory(-1); + CatSongs.ShowCategory(PlaylistMan.CurPlayList); + ShowCatTL(PlaylistMan.CurPlayList); - CatSongs.ClickCategoryButton(I); - SelectNext; + SelectNext; + FixSelected; - //Fix: Not Existing Song selected: - if (I+1=I2) then Inc(I2); + SkipTo(2+Random(CatSongs.VisibleSongs-1)); + Music.PlayChange; + ChangeMusic; + SetScroll4; + UpdateLCD; + end; + 2: //Playlist: Select Playlist and Select Random Song + begin + PlaylistMan.SetPlayList(PlaylistMan.CurPlayList); - //Choose Song - SkipTo(I2-I); + SkipTo(2+Random(CatSongs.VisibleSongs-1)); + Music.PlayChange; + ChangeMusic; + SetScroll4; + UpdateLCD; + FixSelected; + end; + end; - ChangeMusic; + ChangeMusic; end; procedure TScreenSong.SetJoker; -- cgit v1.2.3 From d28350b7fe6e1c827e9994d28f7f95cae4ac2db6 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Tue, 10 Apr 2007 10:15:14 +0000 Subject: Corrected Coverpositions in Style 4 git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@75 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 2af37dd5..e873d287 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -945,11 +945,12 @@ begin Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / VS {CatSongs.VisibleSongs};// 0.5.0 (II): takes another 16ms - Z := (1 + cos(Wsp)) / 2 - 0.2; + Z := (1 + cos(Wsp)) / 2; Z2 := (1 + 2*Z) / 3; - Button[B].X := Theme.Song.Cover.X + (Theme.Song.Cover.W + 0.185 * Theme.Song.Cover.H * VS * sin(Wsp) - Theme.Song.Cover.X) * Z2; // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs - Button[B].Z := Z; + + Button[B].X := Theme.Song.Cover.X + (0.185 * Theme.Song.Cover.H * VS * sin(Wsp)) * Z2 - ((Button[B].H - Theme.Song.Cover.H)/2); // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs + Button[B].Z := Z / 2 + 0.3; Button[B].W := Theme.Song.Cover.H * Z2; @@ -1050,16 +1051,6 @@ var VS: integer; diff: real; X: Real; - {function margin (const X, Y, VS: real):real; //Margin of to Buttons - begin - Result := Frac(x / y) * y; - if (X - VS) >= -3 then - Result := X - VS - Y - else if (X + 3) >= VS then - Result := X - VS + Y - else - Result := X - Y; - end; } begin VS := CatSongs.VisibleSongs; // cache Visible Songs {Vars @@ -1096,9 +1087,12 @@ begin Button[B].W := Button[B].H; - Diff := (Button[B].H - Theme.Song.Cover.H)/2;; + Diff := (Button[B].H - Theme.Song.Cover.H)/2; + + + X := Sin(Angle); - Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * Sin(Angle) - Diff; + Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * X - Diff; end else -- cgit v1.2.3 From 0d4f50f6a2ba32a0176d768646208dbec3136084 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Fri, 13 Apr 2007 16:28:45 +0000 Subject: Fixed some Bugs in Skipto and Random Methods Now the last Song of a Category could be the Result of Randomize when there is an odd number of Songs. Also a little bit better Random Results git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@85 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index e873d287..7ea5d268 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -66,7 +66,7 @@ type procedure SelectNext; procedure SelectPrev; procedure UpdateLCD; - procedure SkipTo(Target: integer); + procedure SkipTo(Target: Cardinal); procedure FixSelected; //Show Wrong Song when Tabs on Fix procedure FixSelected2; //Show Wrong Song when Tabs on Fix procedure ShowCatTL(Cat: Integer);// Show Cat in Top left @@ -208,7 +208,7 @@ begin begin if (CatSongs.Song[(I + Interaction) mod I2].Visible) AND (Length(CatSongs.Song[(I + Interaction) mod I2].Title)>0) AND (UpCase(CatSongs.Song[(I + Interaction) mod I2].Title[1]) = Letter) then begin - SkipTo(2 + CatSongs.VisibleIndex((I + Interaction) mod I2)); + SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); Music.PlayChange; @@ -521,7 +521,7 @@ begin SelectNext; //Fix: Not Existing Song selected: - if (I+1=I2) then Inc(I2); + //if (I+1=I2) then Inc(I2); //Choose Song SkipTo(I2-I); @@ -529,7 +529,7 @@ begin end else //Random in one Category begin - SkipTo(2+Random(CatSongs.VisibleSongs-1)); + SkipTo(Random(CatSongs.VisibleSongs)); end; Music.PlayChange; @@ -1324,7 +1324,7 @@ begin Music.Stop; end; -procedure TScreenSong.SkipTo(Target: integer); // 0.5.0 +procedure TScreenSong.SkipTo(Target: Cardinal); // 0.5.0 var Skip: integer; I: integer; @@ -1339,7 +1339,7 @@ begin Interaction := 0; SongTarget := 0; - for I := 2 to Target do + for I := 1 to Target+1 do SelectNext; FixSelected2; @@ -1481,7 +1481,7 @@ begin SelectNext; //Fix: Not Existing Song selected: - if (I+1=I2) then Inc(I2); + //if (I+1=I2) then Inc(I2); //Choose Song SkipTo(I2-I); @@ -1495,7 +1495,7 @@ begin SelectNext; FixSelected; - SkipTo(2+Random(CatSongs.VisibleSongs-1)); + SkipTo(Random(CatSongs.VisibleSongs)); Music.PlayChange; ChangeMusic; SetScroll4; @@ -1505,7 +1505,7 @@ begin begin PlaylistMan.SetPlayList(PlaylistMan.CurPlayList); - SkipTo(2+Random(CatSongs.VisibleSongs-1)); + SkipTo(Random(CatSongs.VisibleSongs)); Music.PlayChange; ChangeMusic; SetScroll4; -- cgit v1.2.3 From fae5839e8025f020638b4cd0583a9a992c5a7a1e Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 15 Apr 2007 11:05:10 +0000 Subject: Fixed some Bugs in Party Mode Fixed Support CategoryOnly Playlist Support git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@93 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 7ea5d268..7c8447ee 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1488,8 +1488,8 @@ begin end; 1: //One Category Select Category and Select Random Song begin - CatSongs.HideCategory(-1); - CatSongs.ShowCategory(PlaylistMan.CurPlayList); + CatSongs.ShowCategoryList; + CatSongs.ClickCategoryButton(PlaylistMan.CurPlayList); ShowCatTL(PlaylistMan.CurPlayList); SelectNext; -- cgit v1.2.3 From 34988301a511ca8552a954c231fafde007cb94a1 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Fri, 20 Apr 2007 15:29:48 +0000 Subject: Some Memory tweaking (13 MB Less Ram using at 800 Songs) Some Loading Time tweaking (From 8 Secs to 6 Secs on my Computer) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@123 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 7c8447ee..79a5abb1 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -634,6 +634,9 @@ begin // Song List // Songs.LoadSongList; // moved to the UltraStar unit CatSongs.Refresh; + + //Set Length of Button Array one Time Instead of one time for every Song + SetButtonLength(Length(CatSongs.Song)); for Pet := 0 to High(CatSongs.Song) do begin // creating all buttons // new Texture.Limit := 512;// 256 0.4.2 value, 512 in 0.5.0 -- cgit v1.2.3 From e79530fd2165c92a9291076b05dfb0e0236fc222 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Tue, 24 Apr 2007 12:59:54 +0000 Subject: Added ability to Select Players before Song Make Option OnSongClick Work git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@131 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 79a5abb1..5814efbf 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -83,6 +83,7 @@ type procedure StartSong; procedure OpenEditor; procedure DoJoker(Team: Byte); + procedure SelectPlayers; //Extensions procedure DrawExtensions; @@ -299,8 +300,17 @@ begin end else begin // clicked on song if (Mode = 0) then //Normal Mode -> Start Song begin - StartSong; - + //Do the Action that is specified in Ini + case Ini.OnSongClick of + 0: StartSong; + 1: SelectPlayers; + 2:begin + If (CatSongs.CatNumShow = -3) then + ScreenSongMenu.MenuShow(SM_Playlist) + else + ScreenSongMenu.MenuShow(SM_Main); + end; + end; end else if (Mode = 1) then //PartyMode -> Show Menu begin @@ -1615,6 +1625,15 @@ begin end; end; +procedure TScreenSong.SelectPlayers; +begin + CatSongs.Selected := Interaction; + Music.Stop; + + ScreenName.Goto_SingScreen := True; + FadeTo(@ScreenName); +end; + procedure TScreenSong.OpenEditor; begin if (Length(Songs.Song) > 0) and (not CatSongs.Song[Interaction].Main) AND (Mode = 0) then begin -- cgit v1.2.3 From ef87bafc41e7321c8559a23005c79de88b625741 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sat, 28 Apr 2007 09:25:53 +0000 Subject: SongScreen: Changed Alt+Letter now Jump to Artist Added Alt+Shift+Letter: Jump to Title git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@147 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 48 +++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 12 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 5814efbf..16ac46ab 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -199,25 +199,49 @@ begin SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT); - //Jump To - if (SDL_ModState = KMOD_LALT) AND (Mode = 0) AND (PressedKey > SDLK_A) AND (PressedKey < SDLK_Z) then + //Jump to Artist/Titel + if (SDL_ModState and KMOD_LALT <> 0) AND (Mode = 0) AND (PressedKey > SDLK_A) AND (PressedKey < SDLK_Z) then begin Letter := UpCase(Chr(ScanCode)); - Log.LogError(Letter); I2 := Length(CatSongs.Song); - For I := 1 to high(CatSongs.Song) do + + //Jump To Titel + if (SDL_ModState = KMOD_LALT or KMOD_LSHIFT) then begin - if (CatSongs.Song[(I + Interaction) mod I2].Visible) AND (Length(CatSongs.Song[(I + Interaction) mod I2].Title)>0) AND (UpCase(CatSongs.Song[(I + Interaction) mod I2].Title[1]) = Letter) then + For I := 1 to high(CatSongs.Song) do begin - SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); + if (CatSongs.Song[(I + Interaction) mod I2].Visible) AND (Length(CatSongs.Song[(I + Interaction) mod I2].Title)>0) AND (UpCase(CatSongs.Song[(I + Interaction) mod I2].Title[1]) = Letter) then + begin + SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); - Music.PlayChange; + Music.PlayChange; - ChangeMusic; - SetScroll4; - UpdateLCD; - //Break and Exit - Exit; + ChangeMusic; + SetScroll4; + UpdateLCD; + //Break and Exit + Exit; + end; + end; + end + //Jump to Artist + else if (SDL_ModState = KMOD_LALT) then + begin + 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 (UpCase(CatSongs.Song[(I + Interaction) mod I2].Artist[1]) = Letter) then + begin + SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); + + Music.PlayChange; + + ChangeMusic; + SetScroll4; + UpdateLCD; + + //Break and Exit + Exit; + end; end; end; Exit; -- cgit v1.2.3 From bda4fa8e57ca63a1d591433f120b4226d6a5d327 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 29 Apr 2007 17:50:29 +0000 Subject: Added 2 new Buttons to ScreenMain: Multi and Stats Updated Language Fiels to Fit with new Buttons Some CodeClean Up in Menu Class and in Screens Some minor Bug fixes I forgot about Added ability to group Buttons within a Screen New Theme Object: ButtonCollection: Same Attributes as a Button Plus FirstChild: Defining the First Button in the Group. For Example: SingSolo is 1, SingMulti Button is 2, in ScreenMain Added Attribute to Theme Button: Parent: Number of the assigned Group, 0 for no Group Used new Abilitys in MainScreen git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@149 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 16ac46ab..5c383168 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -630,13 +630,7 @@ begin // AddStatic(200, 10, 400, 90, Skin.SelectSong); // AddStatic(200-10, 140-5, 400+20, 50+10, Skin.Selection, 'JPG', 'Font Gray'); - AddBackground(Theme.Song.Background.Tex); - - for I := 0 to High(Theme.Song.Static) do - AddStatic(Theme.Song.Static[I]); - - for I := 0 to High(Theme.Song.Text) do - AddText(Theme.Song.Text[I]); + LoadFromTheme(Theme.Song); TextArtist := AddText(Theme.Song.TextArtist); TextTitle := AddText(Theme.Song.TextTitle); -- cgit v1.2.3 From dfa0f5a144b8bf018b29d801f7d8a7c54ae6d108 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 2 May 2007 17:44:23 +0000 Subject: 2 Bugs Fixed: Select Last Song instead First Song when showing Song Screen for the first Time Go to MainScreen instead of Song Screen when pressing Esc in the Name Screen after Selecting Select Players from Menu git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@154 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 5c383168..1f3c7c8f 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1169,7 +1169,7 @@ begin if (Ini.Tabs_at_startup = 1) AND (CatSongs.CatNumShow = -1) then begin CatSongs.ShowCategoryList; - SelectNext;SelectPrev; //Workaround <- must be fixed sometime + SelectNext; //Workaround <- must be fixed sometime FixSelected; //Show Cat in Top Left Mod HideCatTL; -- cgit v1.2.3 From 3114977b5509c775c93d5ba3d5220a1ff9d363a7 Mon Sep 17 00:00:00 2001 From: b1indy Date: Thu, 3 May 2007 20:12:20 +0000 Subject: slight changes to positions of song covers (in SetScroll5) ReflectionSpacing now varies with the size of the cover -- the further back a cover, the smaller it is... as should be the reflection spacing git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@163 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 1f3c7c8f..e0714c2d 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1104,24 +1104,26 @@ begin Pos := Pos + VS else if (Pos > VS/2) then Pos := Pos - VS; - + if (Abs(Pos) < 2.5) then {fixed Positions} begin Angle := Pi * (Pos / 5); //Button[B].Visible := False; - Button[B].H := Abs(Theme.Song.Cover.H * cos(Angle));//Power(Z2, 3); + Button[B].H := Abs(Theme.Song.Cover.H * cos(Angle*0.8));//Power(Z2, 3); + + Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; Button[B].Z := 0.95 - Abs(Pos) * 0.01; - 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 - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.7); Button[B].W := Button[B].H; Diff := (Button[B].H - Theme.Song.Cover.H)/2; - X := Sin(Angle); + X := Sin(Angle*1.3)*0.9; Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * X - Diff; -- cgit v1.2.3 From a1624a62face0dc4edb0908ba09b6bcd2f43d065 Mon Sep 17 00:00:00 2001 From: b1indy Date: Thu, 3 May 2007 22:45:08 +0000 Subject: re-enabled covers behind the 5 front-covers in songselection fiddled with position-calculations until it looked not too bad git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@166 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index e0714c2d..738eb01e 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1116,7 +1116,7 @@ begin Button[B].Z := 0.95 - Abs(Pos) * 0.01; - Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.7); + Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); Button[B].W := Button[B].H; @@ -1130,31 +1130,34 @@ begin end else begin {Behind the Front Covers} - Button[B].Visible := False; +// Button[B].Visible := False; +// if VS/2-abs(Pos)>VS*0.4 then Button[B].Visible := False; if Pos < 0 then Pos := (Pos - VS/2) /VS else Pos := (Pos + VS/2) /VS; - Angle := 2 * pi * Pos; + Angle := 2 * pi * Pos*1.2; - Button[B].Z := (0.5 - Abs(Pos/4)) -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers + Button[B].Z := (0.4 - Abs(Pos/4)) -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers - Button[B].H := Abs(Theme.Song.Cover.H * cos(Angle));//Power(Z2, 3); + Button[B].H :=0.6*(Theme.Song.Cover.H-Abs(Theme.Song.Cover.H * cos(Angle/2)*0.8));//Power(Z2, 3); Button[B].W := Button[B].H; - Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Button[B].H) * 0.7); + Button[B].Y := Theme.Song.Cover.Y - (Button[B].H - Theme.Song.Cover.H)*0.75; - Diff := (Button[B].H - Theme.Song.Cover.H)/2;; + Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; - Button[B].X := Theme.Song.Cover.X + (Theme.Song.Cover.W + Theme.Song.Cover.H*VS*0.185)* Sin(Angle) - Diff + Diff := (Button[B].H - Theme.Song.Cover.H)/2; + + Button[B].X := Theme.Song.Cover.X+Theme.Song.Cover.H/2-Button[b].H/2 + (Theme.Song.Cover.H)*sin(Angle/2)*1.52; 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; -- cgit v1.2.3 From 73347d4f77edb7e79709b7af9f23e0faa2b38f8b Mon Sep 17 00:00:00 2001 From: b1indy Date: Fri, 4 May 2007 00:12:38 +0000 Subject: reflections were gone after my last hack in UMenuButton... should be back now git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@168 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 738eb01e..b32571c8 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1112,7 +1112,7 @@ begin Button[B].H := Abs(Theme.Song.Cover.H * cos(Angle*0.8));//Power(Z2, 3); - Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + Button[B].Reflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; Button[B].Z := 0.95 - Abs(Pos) * 0.01; @@ -1148,7 +1148,7 @@ begin Button[B].Y := Theme.Song.Cover.Y - (Button[B].H - Theme.Song.Cover.H)*0.75; - Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + Button[B].Reflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; Diff := (Button[B].H - Theme.Song.Cover.H)/2; -- cgit v1.2.3 From 188929aca69791bc755db6562582acfcf10df2e5 Mon Sep 17 00:00:00 2001 From: b1indy Date: Fri, 4 May 2007 16:21:40 +0000 Subject: well... changed Button Reflections back to old behavior git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@173 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index b32571c8..e4ab8854 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1112,7 +1112,8 @@ begin 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; @@ -1148,7 +1149,8 @@ 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; -- cgit v1.2.3 From b61e647b67ac0d449d764b89b117a3ac8b603403 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Tue, 8 May 2007 19:00:47 +0000 Subject: Readded Q Shortcut (Exit Application) on all Screens Clean up Popup Code a little bit git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@180 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index e4ab8854..139d6984 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -248,6 +248,10 @@ begin end; case PressedKey of + SDLK_Q: + begin + Result := false; + end; SDLK_ESCAPE : begin if (Mode = 0) then @@ -605,19 +609,8 @@ begin SetJoker; end; end; - - SDLK_Q: - begin - Result := false; - end; - end; - end - else // Key Up - case PressedKey of - SDLK_RETURN : - begin - end; end; + end; end; constructor TScreenSong.Create; -- cgit v1.2.3 From 5270a02d1dea4f660349f0414d63c3b969def187 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Tue, 8 May 2007 19:23:02 +0000 Subject: Added Ability to Leave Song Screen in Party Mode with Popup. Show Menu directly in Songscreen in PartyMode git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@181 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 139d6984..296b6d2f 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -63,6 +63,7 @@ type function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; function Draw: boolean; override; procedure onShow; override; + procedure onHide; override; procedure SelectNext; procedure SelectPrev; procedure UpdateLCD; @@ -298,6 +299,12 @@ begin // Music.Open(Skin.SkinPath + 'Menu Music 3.mp3'); // Music.Play; end; + end + //When in party Mode then Ask before Close + else if (Mode = 1) then + begin + Music.PlayBack; + CheckFadeTo(@ScreenMain,'MSG_END_PARTY'); end; end; SDLK_RETURN: @@ -1198,12 +1205,21 @@ begin //Party Mode else if (Mode = 1) then begin + SelectRandomSong; + //Show Mennu direct in PartyMode + ScreenSongMenu.MenuShow(SM_Party_Main); end; SetJoker; end; +procedure TScreenSong.onHide; +begin + //When hide then Stop Music (For Party Mode Popup on Exit) + Music.Stop; +end; + procedure TScreenSong.DrawExtensions; begin //Draw Song Menu @@ -1631,7 +1647,7 @@ end; procedure TScreenSong.StartSong; begin CatSongs.Selected := Interaction; - Music.Stop; + //Music.Stop; //Party Mode if (Mode = 1) then begin -- cgit v1.2.3 From 48e9a9faea54c6fa5b2b98e242444ae4c0183a7a Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 9 May 2007 16:45:46 +0000 Subject: Fix: Readded ability to close the Window Fix: Crash when SongScreen is opened in PartyMode when Tabs = On. Caused by SelectRandomSong procedure Upd: M in SongScreen works now in PartyMode, too git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@184 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 85 ++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 41 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 296b6d2f..3f733210 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -357,17 +357,20 @@ begin SDLK_M: //Show SongMenu begin - if (Length(Songs.Song) > 0) AND (Mode = 0) then begin - if not CatSongs.Song[Interaction].Main then begin // clicked on Song - if CatSongs.CatNumShow = -3 then - ScreenSongMenu.MenuShow(SM_Playlist) + if (Length(Songs.Song) > 0) then begin + if (Mode = 0) then begin + if not CatSongs.Song[Interaction].Main then begin // clicked on Song + if CatSongs.CatNumShow = -3 then + ScreenSongMenu.MenuShow(SM_Playlist) + else + ScreenSongMenu.MenuShow(SM_Main); + end else - ScreenSongMenu.MenuShow(SM_Main); - end - else - begin - ScreenSongMenu.MenuShow(SM_Playlist_Load); - end; + begin + ScreenSongMenu.MenuShow(SM_Playlist_Load); + end; + end //Party Mode -> Show Party Menu + else ScreenSongMenu.MenuShow(SM_Party_Main); end; end; @@ -1506,32 +1509,37 @@ begin Case PlaylistMan.Mode of 0: //All Songs Just Select Random Song begin - 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 + //When Tabs are activated then use Tab Method + if (Ini.Tabs_at_startup = 1) then begin - if CatSongs.Song[I].Main then - break; - end; - //In I ist jetzt die Kategorie in I2 der Song + repeat + I2 := Random(high(CatSongs.Song)+1) - low(CatSongs.Song)+1; + until CatSongs.Song[I2].Main = false; - //Choose Cat - CatSongs.ShowCategoryList; + //Search Cat + for I := I2 downto low(CatSongs.Song) do + begin + if CatSongs.Song[I].Main then + break; + 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 - //Show Cat in Top Left Mod - ShowCatTL (I); + //Choose Cat + CatSongs.ShowCategoryList; - CatSongs.ClickCategoryButton(I); - SelectNext; + //Show Cat in Top Left Mod + ShowCatTL (I); - //Fix: Not Existing Song selected: - //if (I+1=I2) then Inc(I2); + CatSongs.ClickCategoryButton(I); + SelectNext; - //Choose Song - SkipTo(I2-I); + //Choose Song + SkipTo(I2-I); + end + //When Tabs are deactivated use easy Method + else + SkipTo(Random(CatSongs.VisibleSongs)); end; 1: //One Category Select Category and Select Random Song begin @@ -1540,28 +1548,23 @@ begin ShowCatTL(PlaylistMan.CurPlayList); SelectNext; - FixSelected; + FixSelected2; SkipTo(Random(CatSongs.VisibleSongs)); - Music.PlayChange; - ChangeMusic; - SetScroll4; - UpdateLCD; end; 2: //Playlist: Select Playlist and Select Random Song begin PlaylistMan.SetPlayList(PlaylistMan.CurPlayList); SkipTo(Random(CatSongs.VisibleSongs)); - Music.PlayChange; - ChangeMusic; - SetScroll4; - UpdateLCD; - FixSelected; + FixSelected2; end; end; - ChangeMusic; + Music.PlayChange; + ChangeMusic; + SetScroll; + UpdateLCD; end; procedure TScreenSong.SetJoker; -- cgit v1.2.3 From 00a4cc524dc2d60c95970def337155b7b57fb4ce Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 9 May 2007 17:44:12 +0000 Subject: Fixed a bug in UScreenSong that causes a little gap between lyrics and Singing in UScreenSing git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@185 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 3f733210..114c52a3 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1220,7 +1220,8 @@ end; procedure TScreenSong.onHide; begin //When hide then Stop Music (For Party Mode Popup on Exit) - Music.Stop; + if (Display.NextScreen <> @ScreenSing) and (Display.NextScreen <> @ScreenSingModi) then + Music.Stop; end; procedure TScreenSong.DrawExtensions; @@ -1650,7 +1651,7 @@ end; procedure TScreenSong.StartSong; begin CatSongs.Selected := Interaction; - //Music.Stop; + Music.Stop; //Party Mode if (Mode = 1) then begin -- cgit v1.2.3 From 78ddfd6d20e419716dfa5085e01b059d40dd61ed Mon Sep 17 00:00:00 2001 From: b1indy Date: Tue, 15 May 2007 17:49:27 +0000 Subject: fixed angle calculation of covers in the background git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@193 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 114c52a3..9fcb7ee8 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1142,7 +1142,7 @@ begin else Pos := (Pos + VS/2) /VS; - Angle := 2 * pi * Pos*1.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 -- cgit v1.2.3 From 66f4c5511f1cc61b68e75d874ea6a1dc88f9e75a Mon Sep 17 00:00:00 2001 From: mota23 Date: Tue, 15 May 2007 18:04:42 +0000 Subject: Added: Keys 1.2.3 to use Joker in Popup-Party-Menu Added: 2 sets of Statics for Song-Screen. (need work, just startet) Some Fixes in Deluxe Theme. (missing texts, fixed positions etc.) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@194 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 9fcb7ee8..2ce6b6df 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -52,7 +52,9 @@ type StaticTeam3Joker3: Cardinal; StaticTeam3Joker4: Cardinal; StaticTeam3Joker5: Cardinal; - + StaticKeys1: Cardinal; + TextKeys1: integer; + constructor Create; override; procedure SetScroll; procedure SetScroll1; @@ -79,7 +81,7 @@ type //Party Mode procedure SelectRandomSong; procedure SetJoker; - + procedure SetStatics; //procedures for Menu procedure StartSong; procedure OpenEditor; @@ -662,6 +664,10 @@ begin StaticTeam3Joker4 := AddStatic(Theme.Song.StaticTeam3Joker4); StaticTeam3Joker5 := AddStatic(Theme.Song.StaticTeam3Joker5); + StaticKeys1 := AddStatic(Theme.Song.StaticKeys1); + + TextKeys1 := AddText(Theme.Song.TextKeys1); + // Song List // Songs.LoadSongList; // moved to the UltraStar unit CatSongs.Refresh; @@ -1215,6 +1221,7 @@ begin end; SetJoker; + SetStatics; end; procedure TScreenSong.onHide; @@ -1646,6 +1653,21 @@ begin end; end; +procedure TScreenSong.SetStatics; +begin + //If Party Mode + if Mode = 1 then //Use Statics for Party-Song-Selection + begin + Static[StaticKeys1].Visible := false; + Text[TextKeys1].Visible := false; + end + else //Use regular Statics for Song-Selection + begin //Hide all + Static[StaticKeys1].Visible := true; + Text[TextKeys1].Visible := true; + end; +end; + //Procedures for Menu procedure TScreenSong.StartSong; -- cgit v1.2.3 From 4a731514163a14bd3a9222d99707880b56772663 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 16 May 2007 19:19:35 +0000 Subject: all SongFile Loading and Saving procedures moved to UFiles. Added Some Tolerance in Song File Loading and Song Header Loading. Fix: Programm doesn't Crash anymore when a coruppted Song is loaded for Singing or Editing. Now Jump back to SongScreen and show an Error Message. Also Party Mode is not Interupted, a new Song will be selected automatically. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@197 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 2ce6b6df..33a6752d 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -3,7 +3,7 @@ unit UScreenSong; interface uses - UMenu, SDL, UMusic, UPliki, UTime, UDisplay, USongs, SysUtils, ULog, UThemes, UTexture, ULanguage, + UMenu, SDL, UMusic, UFiles, UTime, UDisplay, USongs, SysUtils, ULog, UThemes, UTexture, ULanguage, ULCD, ULight, UIni; type @@ -1227,7 +1227,7 @@ end; procedure TScreenSong.onHide; begin //When hide then Stop Music (For Party Mode Popup on Exit) - if (Display.NextScreen <> @ScreenSing) and (Display.NextScreen <> @ScreenSingModi) then + if (Display.NextScreen <> @ScreenSing) and (Display.NextScreen <> @ScreenSingModi) and (Music <> nil) then Music.Stop; end; -- cgit v1.2.3 From 955e54f098cf8c282fdf72f3bca5f87c1db79df6 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 16 May 2007 20:59:37 +0000 Subject: Fixed a Bug in SongScreen that causes Playlist and Search is unclosable when Tabs=Off git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@201 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 33a6752d..48c6597a 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -292,14 +292,31 @@ begin end else begin - //On Escape goto Cat-List Hack End - Music.Stop; - Music.PlayBack; -// FadeTo(@ScreenLevel); - FadeTo(@ScreenMain); + //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); + + //Show Cat in Top Left Mod + HideCatTL; + Interaction := 0; + + //Show Wrong Song when Tabs on Fix + SelectNext; + FixSelected; + + ChangeMusic; + end + else + begin + Music.Stop; + Music.PlayBack; + + FadeTo(@ScreenMain); + end; -// Music.Open(Skin.SkinPath + 'Menu Music 3.mp3'); -// Music.Play; end; end //When in party Mode then Ask before Close -- cgit v1.2.3 From fb785ffee0bc3e1db1022a2c8286f5b9f8944b37 Mon Sep 17 00:00:00 2001 From: mota23 Date: Thu, 17 May 2007 01:10:39 +0000 Subject: Added: New Options/Advanced item "auto party-menu": Switches automatic popup-menu in party-mode on/off. "on" is better usability for joypad, "off" for keyboard. Changed: Keys in Party Song Selection, "m" is popup-menu and "enter" direkt to singscreen. Added: new Statics and Texts to UScreenSong, 2 sets, one for "normal" the other for party-mode. Added: dismissed sound for party-mode. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@202 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 178 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 170 insertions(+), 8 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 48c6597a..26fcba2e 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -52,8 +52,46 @@ type StaticTeam3Joker3: Cardinal; StaticTeam3Joker4: Cardinal; StaticTeam3Joker5: Cardinal; + StaticKeys1: Cardinal; TextKeys1: integer; + StaticKeys1Party: Cardinal; + TextKeys1Party: integer; + + StaticKeys2: Cardinal; + TextKeys2: integer; + StaticKeys2Party: Cardinal; + TextKeys2Party: integer; + + StaticKeys3: Cardinal; + TextKeys3: integer; + StaticKeys3Party: Cardinal; + TextKeys3Party: integer; + + StaticKeys4: Cardinal; + TextKeys4: integer; + StaticKeys4Party: Cardinal; + TextKeys4Party: integer; + + StaticKeys5: Cardinal; + TextKeys5: integer; + StaticKeys5Party: Cardinal; + TextKeys5Party: integer; + + StaticKeys6: Cardinal; + TextKeys6: integer; + StaticKeys6Party: Cardinal; + TextKeys6Party: integer; + + StaticKeys7: Cardinal; + TextKeys7: integer; + StaticKeys7Party: Cardinal; + TextKeys7Party: integer; + + StaticKeys8: Cardinal; + TextKeys8: integer; + StaticKeys8Party: Cardinal; + TextKeys8Party: integer; constructor Create; override; procedure SetScroll; @@ -163,6 +201,7 @@ var I, I2: Integer; Text[TextCat].Visible := true; Static[StaticCat].Visible := True; end; + procedure TScreenSong.HideCatTL; begin //Hide @@ -368,7 +407,9 @@ begin end else if (Mode = 1) then //PartyMode -> Show Menu begin - ScreenSongMenu.MenuShow(SM_Party_Main); + //Is this Right? + ScreenSong.StartSong; + //ScreenSongMenu.MenuShow(SM_Party_Main); end; end; end; @@ -682,8 +723,44 @@ begin StaticTeam3Joker5 := AddStatic(Theme.Song.StaticTeam3Joker5); StaticKeys1 := AddStatic(Theme.Song.StaticKeys1); - TextKeys1 := AddText(Theme.Song.TextKeys1); + StaticKeys1Party := AddStatic(Theme.Song.StaticKeys1Party); + TextKeys1Party := AddText(Theme.Song.TextKeys1Party); + + StaticKeys2 := AddStatic(Theme.Song.StaticKeys2); + TextKeys2 := AddText(Theme.Song.TextKeys2); + StaticKeys2Party := AddStatic(Theme.Song.StaticKeys2Party); + TextKeys2Party := AddText(Theme.Song.TextKeys2Party); + + StaticKeys3 := AddStatic(Theme.Song.StaticKeys3); + TextKeys3 := AddText(Theme.Song.TextKeys3); + StaticKeys3Party := AddStatic(Theme.Song.StaticKeys3Party); + TextKeys3Party := AddText(Theme.Song.TextKeys3Party); + + StaticKeys4 := AddStatic(Theme.Song.StaticKeys4); + TextKeys4 := AddText(Theme.Song.TextKeys4); + StaticKeys4Party := AddStatic(Theme.Song.StaticKeys4Party); + TextKeys4Party := AddText(Theme.Song.TextKeys4Party); + + StaticKeys5 := AddStatic(Theme.Song.StaticKeys5); + TextKeys5 := AddText(Theme.Song.TextKeys5); + StaticKeys5Party := AddStatic(Theme.Song.StaticKeys5Party); + TextKeys5Party := AddText(Theme.Song.TextKeys5Party); + + StaticKeys6 := AddStatic(Theme.Song.StaticKeys6); + TextKeys6 := AddText(Theme.Song.TextKeys6); + StaticKeys6Party := AddStatic(Theme.Song.StaticKeys6Party); + TextKeys6Party := AddText(Theme.Song.TextKeys6Party); + + StaticKeys7 := AddStatic(Theme.Song.StaticKeys7); + TextKeys7 := AddText(Theme.Song.TextKeys7); + StaticKeys7Party := AddStatic(Theme.Song.StaticKeys7Party); + TextKeys7Party := AddText(Theme.Song.TextKeys7Party); + + StaticKeys8 := AddStatic(Theme.Song.StaticKeys8); + TextKeys8 := AddText(Theme.Song.TextKeys8); + StaticKeys8Party := AddStatic(Theme.Song.StaticKeys8Party); + TextKeys8Party := AddText(Theme.Song.TextKeys8Party); // Song List // Songs.LoadSongList; // moved to the UltraStar unit @@ -1234,7 +1311,13 @@ begin SelectRandomSong; //Show Mennu direct in PartyMode - ScreenSongMenu.MenuShow(SM_Party_Main); + //But only if selected in Options + if (Ini.PartyPopup = 1) then + begin + ScreenSongMenu.MenuShow(SM_Party_Main); + end; + + end; SetJoker; @@ -1675,13 +1758,92 @@ begin //If Party Mode if Mode = 1 then //Use Statics for Party-Song-Selection begin - Static[StaticKeys1].Visible := false; - Text[TextKeys1].Visible := false; + Static[StaticKeys1].Visible := False; + Text[TextKeys1].Visible := False; + Static[StaticKeys1Party].Visible := True; + Text[TextKeys1Party].Visible := True; + + Static[StaticKeys2].Visible := False; + Text[TextKeys2].Visible := False; + Static[StaticKeys2Party].Visible := True; + Text[TextKeys2Party].Visible := True; + + Static[StaticKeys3].Visible := False; + Text[TextKeys3].Visible := False; + Static[StaticKeys3Party].Visible := True; + Text[TextKeys3Party].Visible := True; + + Static[StaticKeys4].Visible := False; + Text[TextKeys4].Visible := False; + Static[StaticKeys4Party].Visible := True; + Text[TextKeys4Party].Visible := True; + + Static[StaticKeys5].Visible := False; + Text[TextKeys5].Visible := False; + Static[StaticKeys5Party].Visible := True; + Text[TextKeys5Party].Visible := True; + + Static[StaticKeys6].Visible := False; + Text[TextKeys6].Visible := False; + Static[StaticKeys6Party].Visible := True; + Text[TextKeys6Party].Visible := True; + + Static[StaticKeys7].Visible := False; + Text[TextKeys7].Visible := False; + Static[StaticKeys7Party].Visible := True; + Text[TextKeys7Party].Visible := True; + + Static[StaticKeys8].Visible := False; + Text[TextKeys8].Visible := False; + Static[StaticKeys8Party].Visible := True; + Text[TextKeys8Party].Visible := True; end else //Use regular Statics for Song-Selection - begin //Hide all - Static[StaticKeys1].Visible := true; - Text[TextKeys1].Visible := true; + begin + Static[StaticKeys1].Visible := True; + Text[TextKeys1].Visible := True; + Static[StaticKeys1Party].Visible := False; + Text[TextKeys1Party].Visible := False; + + Static[StaticKeys2].Visible := True; + Text[TextKeys2].Visible := True; + Static[StaticKeys2Party].Visible := False; + Text[TextKeys2Party].Visible := False; + + Static[StaticKeys2].Visible := True; + Text[TextKeys2].Visible := True; + Static[StaticKeys2Party].Visible := False; + Text[TextKeys2Party].Visible := False; + + Static[StaticKeys3].Visible := True; + Text[TextKeys3].Visible := True; + Static[StaticKeys3Party].Visible := False; + Text[TextKeys3Party].Visible := False; + + Static[StaticKeys4].Visible := True; + Text[TextKeys4].Visible := True; + Static[StaticKeys4Party].Visible := False; + Text[TextKeys4Party].Visible := False; + + Static[StaticKeys5].Visible := True; + Text[TextKeys5].Visible := True; + Static[StaticKeys5Party].Visible := False; + Text[TextKeys5Party].Visible := False; + + Static[StaticKeys6].Visible := True; + Text[TextKeys6].Visible := True; + Static[StaticKeys6Party].Visible := False; + Text[TextKeys6Party].Visible := False; + + Static[StaticKeys7].Visible := True; + Text[TextKeys7].Visible := True; + Static[StaticKeys7Party].Visible := False; + Text[TextKeys7Party].Visible := False; + + Static[StaticKeys8].Visible := True; + Text[TextKeys8].Visible := True; + Static[StaticKeys8Party].Visible := False; + Text[TextKeys8Party].Visible := False; end; end; -- cgit v1.2.3 From f11d9806f4623dc4dbf14e521624109b7a69b86b Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Thu, 17 May 2007 10:33:27 +0000 Subject: Deleted Motas Methods to display variable Statics and Texts in Party Mode. Added a new, more extendable and easier in Code Method for displaying Statics in Party Mode or in Normal Mode only Enter in Songscreen in Party Mode Opens now SongMenu again when PartyPopup=1 Changed Theme to Fit these changes git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@206 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 222 +++++++++----------------------------- 1 file changed, 48 insertions(+), 174 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 26fcba2e..95550a32 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -53,45 +53,10 @@ type StaticTeam3Joker4: Cardinal; StaticTeam3Joker5: Cardinal; - StaticKeys1: Cardinal; - TextKeys1: integer; - StaticKeys1Party: Cardinal; - TextKeys1Party: integer; - - StaticKeys2: Cardinal; - TextKeys2: integer; - StaticKeys2Party: Cardinal; - TextKeys2Party: integer; - - StaticKeys3: Cardinal; - TextKeys3: integer; - StaticKeys3Party: Cardinal; - TextKeys3Party: integer; - - StaticKeys4: Cardinal; - TextKeys4: integer; - StaticKeys4Party: Cardinal; - TextKeys4Party: integer; - - StaticKeys5: Cardinal; - TextKeys5: integer; - StaticKeys5Party: Cardinal; - TextKeys5Party: integer; - - StaticKeys6: Cardinal; - TextKeys6: integer; - StaticKeys6Party: Cardinal; - TextKeys6Party: integer; - - StaticKeys7: Cardinal; - TextKeys7: integer; - StaticKeys7Party: Cardinal; - TextKeys7Party: integer; - - StaticKeys8: Cardinal; - TextKeys8: integer; - StaticKeys8Party: Cardinal; - TextKeys8Party: integer; + StaticParty: Array of Cardinal; + TextParty: Array of Cardinal; + StaticNonParty: Array of Cardinal; + TextNonParty: Array of Cardinal; constructor Create; override; procedure SetScroll; @@ -407,9 +372,11 @@ begin end else if (Mode = 1) then //PartyMode -> Show Menu begin - //Is this Right? - ScreenSong.StartSong; - //ScreenSongMenu.MenuShow(SM_Party_Main); + //Is this Right? + if (Ini.PartyPopup = 1) then + ScreenSongMenu.MenuShow(SM_Party_Main) + else + ScreenSong.StartSong; end; end; end; @@ -722,45 +689,22 @@ begin StaticTeam3Joker4 := AddStatic(Theme.Song.StaticTeam3Joker4); StaticTeam3Joker5 := AddStatic(Theme.Song.StaticTeam3Joker5); - StaticKeys1 := AddStatic(Theme.Song.StaticKeys1); - TextKeys1 := AddText(Theme.Song.TextKeys1); - StaticKeys1Party := AddStatic(Theme.Song.StaticKeys1Party); - TextKeys1Party := AddText(Theme.Song.TextKeys1Party); - - StaticKeys2 := AddStatic(Theme.Song.StaticKeys2); - TextKeys2 := AddText(Theme.Song.TextKeys2); - StaticKeys2Party := AddStatic(Theme.Song.StaticKeys2Party); - TextKeys2Party := AddText(Theme.Song.TextKeys2Party); - - StaticKeys3 := AddStatic(Theme.Song.StaticKeys3); - TextKeys3 := AddText(Theme.Song.TextKeys3); - StaticKeys3Party := AddStatic(Theme.Song.StaticKeys3Party); - TextKeys3Party := AddText(Theme.Song.TextKeys3Party); - - StaticKeys4 := AddStatic(Theme.Song.StaticKeys4); - TextKeys4 := AddText(Theme.Song.TextKeys4); - StaticKeys4Party := AddStatic(Theme.Song.StaticKeys4Party); - TextKeys4Party := AddText(Theme.Song.TextKeys4Party); - - StaticKeys5 := AddStatic(Theme.Song.StaticKeys5); - TextKeys5 := AddText(Theme.Song.TextKeys5); - StaticKeys5Party := AddStatic(Theme.Song.StaticKeys5Party); - TextKeys5Party := AddText(Theme.Song.TextKeys5Party); - - StaticKeys6 := AddStatic(Theme.Song.StaticKeys6); - TextKeys6 := AddText(Theme.Song.TextKeys6); - StaticKeys6Party := AddStatic(Theme.Song.StaticKeys6Party); - TextKeys6Party := AddText(Theme.Song.TextKeys6Party); - - StaticKeys7 := AddStatic(Theme.Song.StaticKeys7); - TextKeys7 := AddText(Theme.Song.TextKeys7); - StaticKeys7Party := AddStatic(Theme.Song.StaticKeys7Party); - TextKeys7Party := AddText(Theme.Song.TextKeys7Party); - - StaticKeys8 := AddStatic(Theme.Song.StaticKeys8); - TextKeys8 := AddText(Theme.Song.TextKeys8); - StaticKeys8Party := AddStatic(Theme.Song.StaticKeys8Party); - TextKeys8Party := AddText(Theme.Song.TextKeys8Party); + //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]); + + SetLength(TextParty, Length(Theme.Song.TextParty)); + 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]); + + SetLength(TextNonParty, Length(Theme.Song.TextNonParty)); + 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 @@ -1310,12 +1254,12 @@ begin begin SelectRandomSong; - //Show Mennu direct in PartyMode + //Show Menu directly in PartyMode //But only if selected in Options if (Ini.PartyPopup = 1) then - begin + begin ScreenSongMenu.MenuShow(SM_Party_Main); - end; + end; end; @@ -1754,97 +1698,27 @@ begin end; procedure TScreenSong.SetStatics; +var + I: Integer; + Visible: Boolean; begin - //If Party Mode - if Mode = 1 then //Use Statics for Party-Song-Selection - begin - Static[StaticKeys1].Visible := False; - Text[TextKeys1].Visible := False; - Static[StaticKeys1Party].Visible := True; - Text[TextKeys1Party].Visible := True; - - Static[StaticKeys2].Visible := False; - Text[TextKeys2].Visible := False; - Static[StaticKeys2Party].Visible := True; - Text[TextKeys2Party].Visible := True; - - Static[StaticKeys3].Visible := False; - Text[TextKeys3].Visible := False; - Static[StaticKeys3Party].Visible := True; - Text[TextKeys3Party].Visible := True; - - Static[StaticKeys4].Visible := False; - Text[TextKeys4].Visible := False; - Static[StaticKeys4Party].Visible := True; - Text[TextKeys4Party].Visible := True; - - Static[StaticKeys5].Visible := False; - Text[TextKeys5].Visible := False; - Static[StaticKeys5Party].Visible := True; - Text[TextKeys5Party].Visible := True; - - Static[StaticKeys6].Visible := False; - Text[TextKeys6].Visible := False; - Static[StaticKeys6Party].Visible := True; - Text[TextKeys6Party].Visible := True; - - Static[StaticKeys7].Visible := False; - Text[TextKeys7].Visible := False; - Static[StaticKeys7Party].Visible := True; - Text[TextKeys7Party].Visible := True; - - Static[StaticKeys8].Visible := False; - Text[TextKeys8].Visible := False; - Static[StaticKeys8Party].Visible := True; - Text[TextKeys8Party].Visible := True; - end - else //Use regular Statics for Song-Selection - begin - Static[StaticKeys1].Visible := True; - Text[TextKeys1].Visible := True; - Static[StaticKeys1Party].Visible := False; - Text[TextKeys1Party].Visible := False; - - Static[StaticKeys2].Visible := True; - Text[TextKeys2].Visible := True; - Static[StaticKeys2Party].Visible := False; - Text[TextKeys2Party].Visible := False; - - Static[StaticKeys2].Visible := True; - Text[TextKeys2].Visible := True; - Static[StaticKeys2Party].Visible := False; - Text[TextKeys2Party].Visible := False; - - Static[StaticKeys3].Visible := True; - Text[TextKeys3].Visible := True; - Static[StaticKeys3Party].Visible := False; - Text[TextKeys3Party].Visible := False; - - Static[StaticKeys4].Visible := True; - Text[TextKeys4].Visible := True; - Static[StaticKeys4Party].Visible := False; - Text[TextKeys4Party].Visible := False; - - Static[StaticKeys5].Visible := True; - Text[TextKeys5].Visible := True; - Static[StaticKeys5Party].Visible := False; - Text[TextKeys5Party].Visible := False; - - Static[StaticKeys6].Visible := True; - Text[TextKeys6].Visible := True; - Static[StaticKeys6Party].Visible := False; - Text[TextKeys6Party].Visible := False; - - Static[StaticKeys7].Visible := True; - Text[TextKeys7].Visible := True; - Static[StaticKeys7Party].Visible := False; - Text[TextKeys7Party].Visible := False; - - Static[StaticKeys8].Visible := True; - Text[TextKeys8].Visible := True; - Static[StaticKeys8Party].Visible := False; - Text[TextKeys8Party].Visible := False; - end; + //Set Visibility of Party Statics and Text + Visible := (Mode = 1); + + For I := 0 to high(StaticParty) do + Static[StaticParty[I]].Visible := Visible; + + 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 + Static[StaticNonParty[I]].Visible := Visible; + + For I := 0 to high(TextNonParty) do + Text[TextNonParty[I]].Visible := Visible; end; //Procedures for Menu -- cgit v1.2.3 From 718855f7191c9d4963da9977ee49d155e376691b Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Thu, 17 May 2007 10:42:45 +0000 Subject: Now when no Cat, Search or Playlist is shown, the Text specified in Theme for TextCat is shown git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@207 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 95550a32..31d05dce 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -170,8 +170,11 @@ var I, I2: Integer; procedure TScreenSong.HideCatTL; begin //Hide - Text[TextCat].Visible := false; + //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 -- cgit v1.2.3 From 04189268afb620a6a0d09a675f771c0df9f1264f Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Thu, 17 May 2007 11:33:40 +0000 Subject: Fixed a Bug in Jump to Letter: A and Z now Works correctly Fixed a Bug in Skipto funktion that causes a wrong Song is Selected when Tabs=0. This was the Reason for some Bugs in Jump to and Random Functions. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@210 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 31d05dce..6f3bbc63 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -210,7 +210,7 @@ begin + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT); //Jump to Artist/Titel - if (SDL_ModState and KMOD_LALT <> 0) AND (Mode = 0) AND (PressedKey > SDLK_A) AND (PressedKey < SDLK_Z) then + if (SDL_ModState and KMOD_LALT <> 0) AND (Mode = 0) AND (PressedKey >= SDLK_A) AND (PressedKey <= SDLK_Z) then begin Letter := UpCase(Chr(ScanCode)); I2 := Length(CatSongs.Song); @@ -1441,7 +1441,7 @@ begin if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then Texture.UnloadTexture(Button[Interaction].Texture.Name, false); - Interaction := 0; + Interaction := High(CatSongs.Song); SongTarget := 0; for I := 1 to Target+1 do -- cgit v1.2.3 From d52cb874cd39eac4a4aff100c22bf3280eea4275 Mon Sep 17 00:00:00 2001 From: mota23 Date: Thu, 17 May 2007 14:04:07 +0000 Subject: added: Video Icon. Shows if Video is present in Song-Selection. Needs to be fixed. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@212 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 6f3bbc63..4fe679f7 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -13,6 +13,9 @@ type TextTitle: integer; TextNumber: integer; + //Video Icon Mod + VideoIcon: Cardinal; + TextCat: integer; StaticCat: integer; @@ -58,6 +61,7 @@ type StaticNonParty: Array of Cardinal; TextNonParty: Array of Cardinal; + constructor Create; override; procedure SetScroll; procedure SetScroll1; @@ -1326,6 +1330,13 @@ begin inherited Draw; + //Draw Video Icon if Video is present + if CatSongs.Song[Interaction].Video <> '' then + Static[VideoIcon].Visible := True + else + Static[VideoIcon].Visible := False; + + //Draw Equalizer if Theme.Song.Equalizer.Visible then DrawEqualizer; -- cgit v1.2.3 From 8c035bb950519a86c90f64aab7c58aa98089569c Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Thu, 17 May 2007 14:15:50 +0000 Subject: Some Code Cleanup in UScreenSong Fixed VideoIcon Display git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@213 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 4fe679f7..82dad1ed 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -664,9 +664,6 @@ var begin inherited Create; -// AddStatic(200, 10, 400, 90, Skin.SelectSong); -// AddStatic(200-10, 140-5, 400+20, 50+10, Skin.Selection, 'JPG', 'Font Gray'); - LoadFromTheme(Theme.Song); TextArtist := AddText(Theme.Song.TextArtist); @@ -677,6 +674,9 @@ begin TextCat := AddText(Theme.Song.TextCat); StaticCat := AddStatic(Theme.Song.StaticCat); + //Show Video Icon Mod + VideoIcon := AddStatic(Theme.Song.VideoIcon); + //Party Mode StaticTeam1Joker1 := AddStatic(Theme.Song.StaticTeam1Joker1); StaticTeam1Joker2 := AddStatic(Theme.Song.StaticTeam1Joker2); @@ -748,21 +748,12 @@ begin AddButton(300 + Pet*250, 140, 200, 200, CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, 'JPG', 'Plain', Theme.Song.Cover.Reflections); end; Texture.Limit := 1024*1024; - - -// AddButtonText(11, 10, CatSongs.Song[Pet].Title); // new way end; -// Covers.Save; - { if Length(CatSongs.Song) > 0 then // setting to first song - Interaction := 0 - else begin // no song detected - AddButton(400-200, 140, 400, 50, Skin.Button, 'JPG', 'Transparent Range'); - AddButtonText(11, 10, 'No songs detected'); - end;} + // Randomize Patch - Randomize; + Randomize; //Equalizer SetLength(EqualizerBands, Theme.Song.Equalizer.Bands); //ClearArray @@ -788,6 +779,9 @@ begin end; else SetScroll4; end; + //Set Visibility of Video Icon + Static[VideoIcon].Visible := (CatSongs.Song[Interaction].Video <> ''); + //Set Texts: Text[TextArtist].Text := CatSongs.Song[Interaction].Artist; Text[TextTitle].Text := CatSongs.Song[Interaction].Title; @@ -1330,12 +1324,6 @@ begin inherited Draw; - //Draw Video Icon if Video is present - if CatSongs.Song[Interaction].Video <> '' then - Static[VideoIcon].Visible := True - else - Static[VideoIcon].Visible := False; - //Draw Equalizer if Theme.Song.Equalizer.Visible then -- cgit v1.2.3 From 2a172c386d2c69a5a4157d8a6c0d4e64875b7011 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 20 May 2007 09:37:38 +0000 Subject: Fixed a Bug in UScreenSong. Everytime the Category List is shown, the next Song was selected. (Tabs=On) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@224 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 82dad1ed..12929629 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -218,7 +218,7 @@ begin begin Letter := UpCase(Chr(ScanCode)); I2 := Length(CatSongs.Song); - + //Jump To Titel if (SDL_ModState = KMOD_LALT or KMOD_LSHIFT) then begin @@ -252,7 +252,7 @@ begin ChangeMusic; SetScroll4; UpdateLCD; - + //Break and Exit Exit; end; @@ -664,7 +664,7 @@ var begin inherited Create; - LoadFromTheme(Theme.Song); + LoadFromTheme(Theme.Song); TextArtist := AddText(Theme.Song.TextArtist); TextTitle := AddText(Theme.Song.TextTitle); @@ -759,6 +759,9 @@ begin //ClearArray For I := low(EqualizerBands) to high(EqualizerBands) do EqualizerBands[I] := 3; + + if (Length(CatSongs.Song) > 0) then + Interaction := 0; end; procedure TScreenSong.SetScroll; @@ -1222,13 +1225,12 @@ begin //Cat Mod etc if (Ini.Tabs_at_startup = 1) AND (CatSongs.CatNumShow = -1) then - begin + begin CatSongs.ShowCategoryList; - SelectNext; //Workaround <- must be fixed sometime FixSelected; //Show Cat in Top Left Mod - HideCatTL; - end; + HideCatTL; + end; if Length(CatSongs.Song) > 0 then begin @@ -1782,4 +1784,4 @@ FixSelected; } end; -end. +end. \ No newline at end of file -- cgit v1.2.3 From 10391b4d011dc60f1585643398b772bed3bb4beb Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sat, 26 May 2007 15:30:36 +0000 Subject: Added Workaround and Error Reporting for Errors during Cover loading. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@229 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 75 ++++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 21 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 12929629..db5eb2b2 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -661,6 +661,7 @@ constructor TScreenSong.Create; var Pet: integer; I: integer; +Label CreateSongButtons; begin inherited Create; @@ -719,37 +720,69 @@ begin //Set Length of Button Array one Time Instead of one time for every Song SetButtonLength(Length(CatSongs.Song)); - for Pet := 0 to High(CatSongs.Song) do begin // creating all buttons - // 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 - CatSongs.Song[Pet].Cover := ''; // 0.5.0: if cover not found then show 'no cover' + I := 0; + CreateSongButtons: - if CatSongs.Song[Pet].Cover = '' then - AddButton(300 + Pet*250, 140, 200, 200, Skin.GetTextureFileName('SongCover'), 'JPG', '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 begin - Texture.CreateCacheMipmap := true; - Texture.GetTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, 'Plain', true); // preloads textures and creates cache mipmap - Texture.CreateCacheMipmap := false; + try + for Pet := I to High(CatSongs.Song) do begin // creating all buttons + // new + Texture.Limit := 512;// 256 0.4.2 value, 512 in 0.5.0 - // puts this texture to the cache file - Covers.AddCover(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover); + 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' - // unload full size texture - Texture.UnloadTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, false); + if CatSongs.Song[Pet].Cover = '' then + AddButton(300 + Pet*250, 140, 200, 200, Skin.GetTextureFileName('SongCover'), 'JPG', '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 begin + Texture.CreateCacheMipmap := true; + Texture.GetTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, 'Plain', true); // preloads textures and creates cache mipmap + Texture.CreateCacheMipmap := false; - // we should also add mipmap texture by calling createtexture and use mipmap cache as data source + // puts this texture to the cache file + Covers.AddCover(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover); + + // unload full size texture + Texture.UnloadTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, 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, 'JPG', 'Plain', Theme.Song.Cover.Reflections); end; + Texture.Limit := 1024*1024; + I := -1; + end; + except + //When Error is reported the First time for this Song + if (I <> Pet) then + begin + //Some Error reporting: + Log.LogError('Could not load Cover: ' + CatSongs.Song[Pet].Cover); - // 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, 'JPG', 'Plain', Theme.Song.Cover.Reflections); + //Change Cover to NoCover and Continue Loading + CatSongs.Song[Pet].Cover := ''; + I := Pet; + end + else //when Error occurs Multiple Times(NoSong Cover is damaged), then start loading next Song + begin + Log.LogError('NoCover Cover is damaged!'); + try + AddButton(300 + Pet*250, 140, 200, 200, '', 'JPG', 'Plain', Theme.Song.Cover.Reflections); + except + Messagebox(0, PChar('No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'), PChar(Language.Translate('US_VERSION')), MB_ICONERROR or MB_OK); + Halt; + end; + I := Pet + 1; end; - Texture.Limit := 1024*1024; end; + if (I <> -1) then + GoTo CreateSongButtons; + // Randomize Patch -- cgit v1.2.3 From 0a558c269217ea1eff20805e8fab8ce3ef0a2910 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Mon, 28 May 2007 19:29:24 +0000 Subject: Fixed a bug in Coverloading, that could end up in an endless loop. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@233 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 106 +++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 52 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index db5eb2b2..45c7c2de 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -718,72 +718,74 @@ begin // Songs.LoadSongList; // moved to the UltraStar unit CatSongs.Refresh; - //Set Length of Button Array one Time Instead of one time for every Song - SetButtonLength(Length(CatSongs.Song)); + 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)); - I := 0; - CreateSongButtons: + I := 0; + CreateSongButtons: - try - for Pet := I to High(CatSongs.Song) do begin // creating all buttons - // new - Texture.Limit := 512;// 256 0.4.2 value, 512 in 0.5.0 + try + for Pet := I to High(CatSongs.Song) do begin // creating all buttons + // 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 - CatSongs.Song[Pet].Cover := ''; // 0.5.0: if cover not found then show 'no cover' + 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' - if CatSongs.Song[Pet].Cover = '' then - AddButton(300 + Pet*250, 140, 200, 200, Skin.GetTextureFileName('SongCover'), 'JPG', '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 begin - Texture.CreateCacheMipmap := true; - Texture.GetTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, 'Plain', true); // preloads textures and creates cache mipmap - Texture.CreateCacheMipmap := false; + if CatSongs.Song[Pet].Cover = '' then + AddButton(300 + Pet*250, 140, 200, 200, Skin.GetTextureFileName('SongCover'), 'JPG', '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 begin + Texture.CreateCacheMipmap := true; + Texture.GetTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, '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); + // puts this texture to the cache file + Covers.AddCover(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover); - // unload full size texture - Texture.UnloadTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, false); + // unload full size texture + Texture.UnloadTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, false); - // we should also add mipmap texture by calling createtexture and use mipmap cache as data source - end; + // 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, 'JPG', 'Plain', Theme.Song.Cover.Reflections); + // 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, 'JPG', 'Plain', Theme.Song.Cover.Reflections); + end; + Texture.Limit := 1024*1024; + I := -1; end; - Texture.Limit := 1024*1024; - I := -1; - end; - except - //When Error is reported the First time for this Song - if (I <> Pet) then - begin - //Some Error reporting: - Log.LogError('Could not load Cover: ' + CatSongs.Song[Pet].Cover); + except + //When Error is reported the First time for this Song + if (I <> Pet) then + begin + //Some Error reporting: + Log.LogError('Could not load Cover: ' + CatSongs.Song[Pet].Cover); - //Change Cover to NoCover and Continue Loading - CatSongs.Song[Pet].Cover := ''; - I := Pet; - end - else //when Error occurs Multiple Times(NoSong Cover is damaged), then start loading next Song - begin - Log.LogError('NoCover Cover is damaged!'); - try - AddButton(300 + Pet*250, 140, 200, 200, '', 'JPG', 'Plain', Theme.Song.Cover.Reflections); - except - Messagebox(0, PChar('No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'), PChar(Language.Translate('US_VERSION')), MB_ICONERROR or MB_OK); - Halt; + //Change Cover to NoCover and Continue Loading + CatSongs.Song[Pet].Cover := ''; + I := Pet; + end + else //when Error occurs Multiple Times(NoSong Cover is damaged), then start loading next Song + begin + Log.LogError('NoCover Cover is damaged!'); + try + AddButton(300 + Pet*250, 140, 200, 200, '', 'JPG', 'Plain', Theme.Song.Cover.Reflections); + except + Messagebox(0, PChar('No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'), PChar(Language.Translate('US_VERSION')), MB_ICONERROR or MB_OK); + Halt; + end; + I := Pet + 1; end; - I := Pet + 1; end; - end; - - if (I <> -1) then - GoTo CreateSongButtons; + if (I <> -1) then + GoTo CreateSongButtons; + end; // Randomize Patch Randomize; -- cgit v1.2.3 From 514ece97aaeb8eaa8bf56e224826bc5e6169ce8b Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 3 Jun 2007 19:00:14 +0000 Subject: Some Code Cleanup in UScreenSong Add Procedure DeletePlaylist to TPlaylistManager Add automatic Playlist Deleting if last Song is deleted Fixed some Cover displaying Bugs when JumptoMenu is left git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@242 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 45c7c2de..3924968f 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -95,6 +95,8 @@ type procedure DoJoker(Team: Byte); procedure SelectPlayers; + procedure UnLoadDetailedCover; + //Extensions procedure DrawExtensions; end; @@ -1379,13 +1381,7 @@ begin if VS > 0 then begin - CoverTime := 0; - Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', true); // 0.5.0: show cached texture - Button[Interaction].Texture2.Alpha := 0; - - //0.5.0: unload old full size texture - if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then - Texture.UnloadTexture(Button[Interaction].Texture.Name, false); + UnLoadDetailedCover; Skip := 1; @@ -1417,13 +1413,7 @@ begin if VS > 0 then begin - CoverTime := 0; - Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', true); // 0.5.0: show cached texture - Button[Interaction].Texture2.Alpha := 0; - - //0.5.0: unload old full size texture - if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then - Texture.UnloadTexture(Button[Interaction].Texture.Name, false); + UnLoadDetailedCover; Skip := 1; @@ -1470,12 +1460,7 @@ var Skip: integer; I: integer; begin - CoverTime := 0; - Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', true); // 0.5.0: show cached texture - Button[Interaction].Texture2.Alpha := 0; - - if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then - Texture.UnloadTexture(Button[Interaction].Texture.Name, false); + UnLoadDetailedCover; Interaction := High(CatSongs.Song); SongTarget := 0; @@ -1809,6 +1794,18 @@ begin 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, 'Plain', true); // 0.5.0: show cached texture + Button[Interaction].Texture2.Alpha := 0; + + if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then + Texture.UnloadTexture(Button[Interaction].Texture.Name, false); +end; + procedure TScreenSong.Refresh; begin { CatSongs.Refresh; -- cgit v1.2.3 From 49ada15c935658c5d90416e26acfb360f1e7c047 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 3 Jun 2007 19:45:43 +0000 Subject: Added SongPreview Fading Song Preview Max Volume is now 70 % Need Testing because of timing git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@243 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 3924968f..ae02b2f4 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1275,6 +1275,8 @@ begin Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); Music.MoveTo(Music.Length / 4); Music.Play; + //Music Fade (Start not with max Volume) + Music.SetMusicVolume(70); SetScroll; UpdateLCD; end; @@ -1349,18 +1351,25 @@ begin // Log.LogBenchmark('SetScroll4', 5); - // 0.5.0: cover fade + // 0.5.0: cover fade and Song Fade if (CoverTime < 1) and (CoverTime + TimeSkip >= 1) then begin // load new texture Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); Button[Interaction].Texture.Alpha := 1; Button[Interaction].Texture2 := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); Button[Interaction].Texture2.Alpha := 1; + + //Play Song + Music.SetMusicVolume(20); + Music.Play; end; CoverTime := CoverTime + TimeSkip; Button[Interaction].Texture2.Alpha := (CoverTime - 1) * 1.5; if Button[Interaction].Texture2.Alpha > 1 then Button[Interaction].Texture2.Alpha := 1; + if (CoverTime > 1) and (CoverTime <= 3.5) then + Music.SetMusicVolume(Round((CoverTime-1)* 20)); + inherited Draw; @@ -1448,7 +1457,8 @@ begin Music.Close; if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin Music.MoveTo(Music.Length / 4); - Music.Play; + //Song Fading: Not Play Directly + //Music.Play; end; end else -- cgit v1.2.3 From d08356e3b64d8738ff9672229c1bbe963b58337c Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 6 Jun 2007 20:24:29 +0000 Subject: Fixed some Bugs in Song Fading Added Ini Values to change the Fading and the Preview Volume git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@245 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 103 ++++++++++++++++++++++++++------------ 1 file changed, 70 insertions(+), 33 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index ae02b2f4..ee05c11c 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1271,12 +1271,21 @@ begin if Length(CatSongs.Song) > 0 then begin - Music.SetLoop(false); - Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); - Music.MoveTo(Music.Length / 4); - Music.Play; - //Music Fade (Start not with max Volume) - Music.SetMusicVolume(70); + //Load Music only when Song Preview is activated + if (Ini.PreviewVolume <> 0) then + begin + Music.SetLoop(false); + Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); + Music.MoveTo(Music.Length / 4); + Music.Play; + + //Set Preview Volume + Music.SetMusicVolume (Ini.PreviewVolume * 10); + {//if Music Fade is activated, Set Volume to 0 % + if (Ini.PreviewFading <> 0) then + Music.SetMusicVolume(0);} + end; + SetScroll; UpdateLCD; end; @@ -1312,6 +1321,10 @@ end; procedure TScreenSong.onHide; begin + //When Music Fading is activated, Turn Music to 100 % + If (Ini.PreviewVolume <> 100) or (Ini.PreviewFading <> 0) then + Music.SetMusicVolume(100); + //When hide then Stop Music (For Party Mode Popup on Exit) if (Display.NextScreen <> @ScreenSing) and (Display.NextScreen <> @ScreenSingModi) and (Music <> nil) then Music.Stop; @@ -1350,25 +1363,42 @@ begin // Log.BenchmarkEnd(5); // Log.LogBenchmark('SetScroll4', 5); + //Fading Functions, Only if Covertime is under 5 Seconds + If (CoverTime < 5) then + begin + // 0.5.0: cover fade + if (CoverTime < 1) and (CoverTime + TimeSkip >= 1) then begin + // load new texture + Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); + Button[Interaction].Texture.Alpha := 1; + Button[Interaction].Texture2 := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); + Button[Interaction].Texture2.Alpha := 1; + end; - // 0.5.0: cover fade and Song Fade - if (CoverTime < 1) and (CoverTime + TimeSkip >= 1) then begin - // load new texture - Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); - Button[Interaction].Texture.Alpha := 1; - Button[Interaction].Texture2 := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); - Button[Interaction].Texture2.Alpha := 1; + //Song Fade + 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 + Music.Play; - //Play Song - Music.SetMusicVolume(20); - Music.Play; - end; - CoverTime := CoverTime + TimeSkip; - Button[Interaction].Texture2.Alpha := (CoverTime - 1) * 1.5; - if Button[Interaction].Texture2.Alpha > 1 then Button[Interaction].Texture2.Alpha := 1; + //Update Song Volume + if (CoverTime < Ini.PreviewFading) then + Music.SetMusicVolume(Round (CoverTime * Ini.PreviewVolume / Ini.PreviewFading * 10)) + else + Music.SetMusicVolume(Ini.PreviewVolume * 10); + + end; - if (CoverTime > 1) and (CoverTime <= 3.5) then - Music.SetMusicVolume(Round((CoverTime-1)* 20)); + + //Update Fading Time + CoverTime := CoverTime + TimeSkip; + + //Update Fading Texture + Button[Interaction].Texture2.Alpha := (CoverTime - 1) * 1.5; + if Button[Interaction].Texture2.Alpha > 1 then Button[Interaction].Texture2.Alpha := 1; + + end; inherited Draw; @@ -1452,17 +1482,24 @@ end; //Procedure Change current played Preview procedure TScreenSong.ChangeMusic; begin - if (NOT CatSongs.Song[Interaction].Main) AND(CatSongs.VisibleSongs > 0) then - begin - Music.Close; - if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin - Music.MoveTo(Music.Length / 4); - //Song Fading: Not Play Directly - //Music.Play; - end; - end - else - Music.Stop; + //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 + begin + Music.Close; + if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin + Music.MoveTo(Music.Length / 4); + //If Song Fading is activated then don't Play directly, and Set Volume to Null, else Play normal + if (Ini.PreviewVolume <> 0) then + Music.SetMusicVolume(0) + else + Music.Play; + end; + end + else + Music.Stop; + end; end; procedure TScreenSong.SkipTo(Target: Cardinal); // 0.5.0 -- cgit v1.2.3 From 18579e1d865dc0fbd9c179fc5d45b1fff2b9033b Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Thu, 7 Jun 2007 07:42:38 +0000 Subject: Fixed 2 Bugs in Song Preview Fading git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@247 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index ee05c11c..1a5b41b8 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1325,6 +1325,10 @@ begin If (Ini.PreviewVolume <> 100) or (Ini.PreviewFading <> 0) then Music.SetMusicVolume(100); + //If Preview is deactivated: Load MUsicfile now + If (Ini.PreviewVolume = 0) then + Music.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 (Music <> nil) then Music.Stop; @@ -1491,10 +1495,10 @@ begin if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin Music.MoveTo(Music.Length / 4); //If Song Fading is activated then don't Play directly, and Set Volume to Null, else Play normal - if (Ini.PreviewVolume <> 0) then - Music.SetMusicVolume(0) + if (Ini.PreviewFading = 0) then + Music.Play else - Music.Play; + Music.SetMusicVolume(0); end; end else -- cgit v1.2.3 From 6130b0841429920015301a661e5133cfd1ed3cb3 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Fri, 8 Jun 2007 18:43:34 +0000 Subject: Fixed: Up and Down now don't leave Playlist and Search Mode anymore git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@250 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 127 +++++++++++++++++--------------------- 1 file changed, 58 insertions(+), 69 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 1a5b41b8..2ce06d7a 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -381,7 +381,6 @@ begin end else if (Mode = 1) then //PartyMode -> Show Menu begin - //Is this Right? if (Ini.PartyPopup = 1) then ScreenSongMenu.MenuShow(SM_Party_Main) else @@ -427,93 +426,83 @@ begin SDLK_DOWN: begin - if (Mode = 0) then - begin -{ if Length(Songs.Song) > 0 then begin - Music.PlayChange; - InteractNext; - Music.Close; - if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then Music.Play; - SetScroll; - end;} - - //Cat Change Hack - if Ini.Tabs_at_startup = 1 then + if (Mode = 0) then + begin + //Only Change Cat when not in Playlist or Search Mode + if (CatSongs.CatNumShow > -2) then begin - I := Interaction; - if I <= 0 then I := 1; - - while not catsongs.Song[I].Main do + //Cat Change Hack + if Ini.Tabs_at_startup = 1 then begin - Inc (I); - if (I > high(catsongs.Song)) then - I := low(catsongs.Song); - end; + I := Interaction; + if I <= 0 then I := 1; - Interaction := I; + while not catsongs.Song[I].Main do + begin + Inc (I); + if (I > high(catsongs.Song)) then + I := low(catsongs.Song); + end; - //Show Cat in Top Left Mod - ShowCatTL (Interaction); + Interaction := I; - CatSongs.ClickCategoryButton(Interaction); - SelectNext; - FixSelected; + //Show Cat in Top Left Mod + ShowCatTL (Interaction); - //Play Music: - Music.PlayChange; - ChangeMusic; + CatSongs.ClickCategoryButton(Interaction); + SelectNext; + FixSelected; - end; + //Play Music: + Music.PlayChange; + ChangeMusic; - // - //Cat Change Hack End} - end; + end; + + // + //Cat Change Hack End} + end; + end; end; SDLK_UP: begin - if (Mode = 0) then - begin -{ if Length(Songs.Song) > 0 then begin - Music.PlayChange; - InteractPrev; - Music.Close; - if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then Music.Play; - SetScroll; - end;} - //Cat Change Hack - if Ini.Tabs_at_startup = 1 then + if (Mode = 0) then + begin + //Only Change Cat when not in Playlist or Search Mode + if (CatSongs.CatNumShow > -2) then begin - I := Interaction; - I2 := 0; - if I <= 0 then I := 1; - - while not catsongs.Song[I].Main or (I2 = 0) do + //Cat Change Hack + if Ini.Tabs_at_startup = 1 then begin - if catsongs.Song[I].Main then - Inc(I2); - Dec (I); - if (I < low(catsongs.Song)) then - I := high(catsongs.Song); - end; + I := Interaction; + I2 := 0; + if I <= 0 then I := 1; - Interaction := I; + 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; - //Show Cat in Top Left Mod - ShowCatTL (I); + Interaction := I; - CatSongs.ClickCategoryButton(I); - SelectNext; - FixSelected; + //Show Cat in Top Left Mod + ShowCatTL (I); - //Play Music: - Music.PlayChange; - ChangeMusic; + CatSongs.ClickCategoryButton(I); + SelectNext; + FixSelected; + //Play Music: + Music.PlayChange; + ChangeMusic; + end; end; - - // - //Cat Change Hack End} - end; + //Cat Change Hack End} + end; end; SDLK_RIGHT: -- cgit v1.2.3 From 03c2049c1685ca6ec0046e422d65de1e996fc209 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 10 Jun 2007 14:40:20 +0000 Subject: Fixed a Bug in ScreenSong Equalizer that causes an Invalid Pointer Exception when US is closed. Changed Themes to fit the changes git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@258 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 2ce06d7a..87aa122e 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1533,9 +1533,10 @@ begin B:=0; Pos := 0; - Res := floor(92/Theme.Song.Equalizer.Bands);//How much channels are used for one Band + Res := ceil(92/Theme.Song.Equalizer.Bands);//How much channels are used for one Band + //Change Lengths - for I := 0 to 92 do + for I := 0 to (Res * Theme.Song.Equalizer.Bands - 1) do begin A := floor(I/Res); @@ -1589,7 +1590,7 @@ begin PosY := Theme.Song.Equalizer.Y; PosX := Theme.Song.Equalizer.X; - For I := 0 to Theme.Song.Equalizer.Bands do + For I := 0 to Theme.Song.Equalizer.Bands-1 do begin if Theme.Song.Equalizer.Direction then PosY := Theme.Song.Equalizer.Y //+ (Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space) * Theme.Song.Equalizer.Length -- cgit v1.2.3 From 2722fcd0ddec2fa8f7cd9af74efd54870cc94e8d Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 18 Jul 2007 20:18:27 +0000 Subject: Little hack in SongScreen that fixes problems with blending. Drawing order changed only for SongScreen: Buttons -> Statics -> Texts git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@301 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 87aa122e..3221f21e 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1340,6 +1340,7 @@ function TScreenSong.Draw: boolean; var dx: real; dt: real; + I: Integer; begin dx := SongTarget-SongCurrent; dt := TimeSkip*7; @@ -1393,7 +1394,26 @@ begin end; - inherited Draw; + //inherited Draw; + //heres a little Hack, that causes the Statics + //are Drawn after the Buttons because of some Blending Problems. + //This should cause no Problems because all Buttons on this screen + //Has Z Position. + //Draw BG + DrawBG; + + //Instead of Draw FG Procedure: + //We draw Buttons for our own + for I := 0 to Length(Button) - 1 do + Button[I].Draw; + + // Statics + for I := 0 to Length(Static) - 1 do + Static[I].Draw; + + // and texts + for I := 0 to Length(Text) - 1 do + Text[I].Draw; //Draw Equalizer -- cgit v1.2.3 From bcc359df110e8fbd6737aba1e3365f880d1413e4 Mon Sep 17 00:00:00 2001 From: b1indy Date: Wed, 22 Aug 2007 13:40:42 +0000 Subject: limit number of displayed background covers to no more than 21 - need comments on this git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@352 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 3221f21e..9d3111cb 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -4,7 +4,7 @@ interface uses UMenu, SDL, UMusic, UFiles, UTime, UDisplay, USongs, SysUtils, ULog, UThemes, UTexture, ULanguage, - ULCD, ULight, UIni; + ULCD, ULight, UIni, TextGL; type TScreenSong = class(TMenu) @@ -1185,7 +1185,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); @@ -1208,13 +1208,16 @@ begin end else begin {Behind the Front Covers} -// Button[B].Visible := False; -// if VS/2-abs(Pos)>VS*0.4 then Button[B].Visible := False; + + // limit-bg-covers hack + if (abs(VS/2-abs(Pos))>10) then Button[B].Visible:=False; + if VS > 25 then VS:=25; + // end of limit-bg-covers hack if Pos < 0 then - Pos := (Pos - VS/2) /VS + Pos := (Pos - VS/2)/VS else - Pos := (Pos + VS/2) /VS; + Pos := (Pos + VS/2)/VS; Angle := pi * Pos*2; @@ -1381,7 +1384,7 @@ begin Music.SetMusicVolume(Round (CoverTime * Ini.PreviewVolume / Ini.PreviewFading * 10)) else Music.SetMusicVolume(Ini.PreviewVolume * 10); - + end; @@ -1421,6 +1424,16 @@ begin DrawEqualizer; DrawExtensions; + + + glColor4f(1, 1, 1, 1); + SetFontStyle (2); + SetFontItalic(False); + SetFontSize(9); + SetFontPos (5, 0); + glPrint(pAnsiChar(inttostr(floor(CatSongs.VisibleSongs)))); + + end; procedure TScreenSong.SelectNext; -- cgit v1.2.3 From 1c21e36f56107091ca675559c440688fd95b384f Mon Sep 17 00:00:00 2001 From: b1indy Date: Wed, 22 Aug 2007 14:58:19 +0000 Subject: fixed a bug in drawing of background covers (when style=5 (usdx theme default)) added a new style for the song covers ("slotmachine" like, style=6) - still needs adjustments git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@353 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 123 ++++++++++++++++++++++++++++++++++---- 1 file changed, 111 insertions(+), 12 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 9d3111cb..e346d59e 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -4,7 +4,7 @@ interface uses UMenu, SDL, UMusic, UFiles, UTime, UDisplay, USongs, SysUtils, ULog, UThemes, UTexture, ULanguage, - ULCD, ULight, UIni, TextGL; + ULCD, ULight, UIni; type TScreenSong = class(TMenu) @@ -69,6 +69,7 @@ type procedure SetScroll3; procedure SetScroll4; procedure SetScroll5; + procedure SetScroll6; function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; function Draw: boolean; override; procedure onShow; override; @@ -806,6 +807,7 @@ begin else SetScroll4; end; + 6: SetScroll6; else SetScroll4; end; //Set Visibility of Video Icon @@ -1173,7 +1175,7 @@ begin //Change Pos of all Buttons for B := low(Button) to high(Button) do begin - Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visability + Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visibility if Button[B].Visible then //Only Change Pos for Visible Buttons begin Pos := (CatSongs.VisibleIndex(B) - SongCurrent); @@ -1234,7 +1236,7 @@ begin Diff := (Button[B].H - Theme.Song.Cover.H)/2; - Button[B].X := Theme.Song.Cover.X+Theme.Song.Cover.H/2-Button[b].H/2 + (Theme.Song.Cover.H)*sin(Angle/2)*1.52; + Button[B].X := Theme.Song.Cover.X+Theme.Song.Cover.H/2-Button[b].H/2+Theme.Song.Cover.W/320*((Theme.Song.Cover.H)*sin(Angle/2)*1.52); end; @@ -1245,6 +1247,112 @@ begin end; end; +procedure TScreenSong.SetScroll6; // rotate (slotmachine style) +var + B: integer; + Angle: real; + Pos: Real; + VS: integer; + diff: real; + X: Real; + Wsp: real; + Z, Z2: real; +begin + VS := CatSongs.VisibleSongs; // cache Visible Songs + if VS <=5 then begin + // kolowe + 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 + + 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; + + + Button[B].Y := Theme.Song.Cover.Y + (0.185 * Theme.Song.Cover.H * VS * sin(Wsp)) * Z2 - ((Button[B].H - Theme.Song.Cover.H)/2); // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs + Button[B].Z := Z / 2 + 0.3; + + Button[B].W := Theme.Song.Cover.H * 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; + end; + end + else begin + + //Change Pos of all Buttons + for B := low(Button) to high(Button) do + begin + Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visibility + if Button[B].Visible then //Only Change Pos for Visible Buttons + begin + Pos := (CatSongs.VisibleIndex(B) - SongCurrent); + if (Pos < -VS/2) then + Pos := Pos + VS + else if (Pos > VS/2) then + Pos := Pos - VS; + + if (Abs(Pos) < 2.5) then {fixed Positions} + begin + Angle := Pi * (Pos / 5); +// Button[B].Visible := False; + + Button[B].H := Abs(Theme.Song.Cover.H * cos(Angle*0.8));//Power(Z2, 3); + + Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + + Button[B].Z := 0.95 - Abs(Pos) * 0.01; + + Button[B].X := (Theme.Song.Cover.X + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); + + Button[B].W := Button[B].H; + + Diff := (Button[B].H - Theme.Song.Cover.H)/2; + + + X := Sin(Angle*1.3)*0.9; + + Button[B].Y := Theme.Song.Cover.Y + Theme.Song.Cover.W * X - Diff; + end + else + begin {Behind the Front Covers} + + // limit-bg-covers hack + if (abs(VS/2-abs(Pos))>10) then Button[B].Visible:=False; + if VS > 25 then VS:=25; + // end of limit-bg-covers hack + + if Pos < 0 then + Pos := (Pos - VS/2)/VS + else + Pos := (Pos + VS/2)/VS; + + 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 + + Button[B].H :=0.6*(Theme.Song.Cover.H-Abs(Theme.Song.Cover.H * cos(Angle/2)*0.8));//Power(Z2, 3); + + Button[B].W := Button[B].H; + + Button[B].X := Theme.Song.Cover.X - (Button[B].H - Theme.Song.Cover.H)*0.5; + + + Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + + Button[B].Y := Theme.Song.Cover.Y+Theme.Song.Cover.H/2-Button[b].H/2+Theme.Song.Cover.W/320*(Theme.Song.Cover.H*sin(Angle/2)*1.52); + end; + end; + end; + end; +end; + + procedure TScreenSong.onShow; begin Music.Stop; @@ -1425,15 +1533,6 @@ begin DrawExtensions; - - glColor4f(1, 1, 1, 1); - SetFontStyle (2); - SetFontItalic(False); - SetFontSize(9); - SetFontPos (5, 0); - glPrint(pAnsiChar(inttostr(floor(CatSongs.VisibleSongs)))); - - end; procedure TScreenSong.SelectNext; -- cgit v1.2.3 From 789d722dace2725d78479da4edb268440a52959c Mon Sep 17 00:00:00 2001 From: b1indy Date: Sat, 1 Sep 2007 10:58:56 +0000 Subject: fixed bug that caused display of wrong covers git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@355 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index e346d59e..e75ed1ab 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1159,6 +1159,7 @@ var Angle: real; Pos: Real; VS: integer; + VS_hack: integer; // visible songs for the diff: real; X: Real; begin @@ -1213,13 +1214,13 @@ begin // limit-bg-covers hack if (abs(VS/2-abs(Pos))>10) then Button[B].Visible:=False; - if VS > 25 then VS:=25; + if VS > 25 then VS_hack:=25 else VS_hack:=VS; // end of limit-bg-covers hack if Pos < 0 then - Pos := (Pos - VS/2)/VS + Pos := (Pos - VS_hack/2)/VS_hack else - Pos := (Pos + VS/2)/VS; + Pos := (Pos + VS_hack/2)/VS_hack; Angle := pi * Pos*2; -- cgit v1.2.3 From e5ddd8163c2fa0efefb07e08ba7d0cf392944d16 Mon Sep 17 00:00:00 2001 From: b1indy Date: Sat, 1 Sep 2007 12:45:08 +0000 Subject: finally really fixed the covers (i hope) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@356 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index e75ed1ab..cddf864e 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1159,9 +1159,9 @@ var Angle: real; Pos: Real; VS: integer; - VS_hack: integer; // visible songs for the diff: real; X: Real; + helper: real; begin VS := CatSongs.VisibleSongs; // cache Visible Songs {Vars @@ -1213,16 +1213,22 @@ begin begin {Behind the Front Covers} // limit-bg-covers hack - if (abs(VS/2-abs(Pos))>10) then Button[B].Visible:=False; - if VS > 25 then VS_hack:=25 else VS_hack:=VS; + if (abs(abs(Pos)-VS/2)>10) then Button[B].Visible:=False; // end of limit-bg-covers hack if Pos < 0 then - Pos := (Pos - VS_hack/2)/VS_hack + Pos := (Pos - VS/2)/VS else - Pos := (Pos + VS_hack/2)/VS_hack; + Pos := (Pos + VS/2)/VS; Angle := pi * Pos*2; + if VS > 24 then + begin + if Angle < 0 then helper:=-1 else helper:=1; + Angle:=2*pi-abs(Angle); + Angle:=Angle*(VS/24); + Angle:=(2*pi-Angle)*helper; + end; Button[B].Z := (0.4 - Abs(Pos/4)) -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers -- cgit v1.2.3 From 3043d3db91c3a541881aa951bbd4f8ccb5e3ce40 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Wed, 5 Sep 2007 12:35:19 +0000 Subject: modified ParseInput so Backspace will perform same function as ESC in most screens ( Except where text input is required, and backspace is used for text input ) This has been done, so that when used with Windows Media Center IR Remotes ( needs SDL 1.2 dll at runtime ) users can navigate throug the game without sitting in front of the PC keyboard. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@370 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index cddf864e..38266797 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -269,7 +269,9 @@ begin begin Result := false; end; - SDLK_ESCAPE : + + SDLK_ESCAPE, + SDLK_BACKSPACE : begin if (Mode = 0) then begin -- cgit v1.2.3 From e3fc5e2c58302159b79e0e25e183aa3e75397a41 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Tue, 18 Sep 2007 11:16:30 +0000 Subject: added switches.inc , which will contain compiler directives used ( at least ) for porting to linux. this file now contains compiler directive UseSerialPort, which is conditionally set depending on the compiler. at this point lazarus will not use the serial port ( LCD or Light ) units. however this functionality should be maintained at this point in delphi. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@390 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 38266797..2d10c9dc 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1,6 +1,7 @@ unit UScreenSong; interface +{$I switches.inc} uses UMenu, SDL, UMusic, UFiles, UTime, UDisplay, USongs, SysUtils, ULog, UThemes, UTexture, ULanguage, @@ -344,9 +345,13 @@ begin end; SDLK_RETURN: begin - if Length(Songs.Song) > 0 then begin -// PortWriteB($378, 0); - if CatSongs.Song[Interaction].Main then begin // clicked on Category Button + if Length(Songs.Song) > 0 then + begin + {$IFDEF UseSerialPort} + // PortWriteB($378, 0); + {$ENDIF} + if CatSongs.Song[Interaction].Main then + begin // clicked on Category Button //Show Cat in Top Left Mod ShowCatTL (Interaction); -- cgit v1.2.3 From 62c82114318ed04ce42617fa9ce2e179834dbda4 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Wed, 19 Sep 2007 11:44:10 +0000 Subject: added UCommon ( in classes ) for lazarus... common functions needed for lazarus ( and others ) can be put in here. also this now compiles on lazarus.. ( dosnt link yet... but I dont get any critical compiler errors ) tested to compile in my delphi, and basic functionality is fine. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@395 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 2d10c9dc..7b16c315 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1078,7 +1078,8 @@ begin end; end; -{procedure TScreenSong.SetScroll4; // rotate +(* +procedure TScreenSong.SetScroll4; // rotate var B: integer; Wsp: real; @@ -1158,7 +1159,7 @@ begin else Button[B].Visible := False; end; end; -end; } +end; *) procedure TScreenSong.SetScroll5; // rotate var @@ -2003,4 +2004,4 @@ FixSelected; } end; -end. \ No newline at end of file +end. -- cgit v1.2.3 From db82b7e30a1b58b56fdb4bfc6089b47200ca1da1 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Thu, 20 Sep 2007 06:36:58 +0000 Subject: Ultrastar-DX now compiles in linux (using lazarus) Bass etc is commented out.. but it compiles, and im working through the runtime errors. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@408 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 4047 +++++++++++++++++++------------------ 1 file changed, 2040 insertions(+), 2007 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 7b16c315..569645d4 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1,2007 +1,2040 @@ -unit UScreenSong; - -interface -{$I switches.inc} - -uses - UMenu, SDL, UMusic, UFiles, UTime, UDisplay, USongs, SysUtils, ULog, UThemes, UTexture, ULanguage, - ULCD, ULight, UIni; - -type - TScreenSong = class(TMenu) - public - TextArtist: integer; - TextTitle: integer; - TextNumber: integer; - - //Video Icon Mod - VideoIcon: Cardinal; - - TextCat: integer; - StaticCat: integer; - - SongCurrent: real; - SongTarget: real; - - HighSpeed: boolean; - CoverFull: boolean; - CoverTime: real; - CoverX: integer; - CoverY: integer; - CoverW: integer; - is_jump: boolean; // Jump to Song Mod - is_jump_title:boolean; //Jump to SOng MOd-YTrue if search for Title - - EqualizerBands: array of Byte; - EqualizerTime: Cardinal; - EqualizerTime2: Byte; - - //Party Mod - Mode: Byte; //0 = Standard, 1= Go to PartyMode after Selection + Change to Random Song at Show - //party Statics (Joker) - StaticTeam1Joker1: Cardinal; - StaticTeam1Joker2: Cardinal; - StaticTeam1Joker3: Cardinal; - StaticTeam1Joker4: Cardinal; - StaticTeam1Joker5: Cardinal; - - StaticTeam2Joker1: Cardinal; - StaticTeam2Joker2: Cardinal; - StaticTeam2Joker3: Cardinal; - StaticTeam2Joker4: Cardinal; - StaticTeam2Joker5: Cardinal; - - StaticTeam3Joker1: Cardinal; - StaticTeam3Joker2: Cardinal; - StaticTeam3Joker3: Cardinal; - StaticTeam3Joker4: Cardinal; - StaticTeam3Joker5: Cardinal; - - StaticParty: Array of Cardinal; - TextParty: Array of Cardinal; - StaticNonParty: Array of Cardinal; - TextNonParty: Array of Cardinal; - - - constructor Create; override; - procedure SetScroll; - procedure SetScroll1; - procedure SetScroll2; - procedure SetScroll3; - procedure SetScroll4; - procedure SetScroll5; - procedure SetScroll6; - function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; - function Draw: boolean; override; - procedure onShow; override; - procedure onHide; override; - procedure SelectNext; - procedure SelectPrev; - procedure UpdateLCD; - procedure SkipTo(Target: Cardinal); - procedure FixSelected; //Show Wrong Song when Tabs on Fix - procedure FixSelected2; //Show Wrong Song when Tabs on Fix - procedure ShowCatTL(Cat: Integer);// Show Cat in Top left - procedure ShowCatTLCustom(Caption: String);// Show Custom Text in Top left - procedure HideCatTL;// Show Cat in Tob left - procedure Refresh; //Refresh Song Sorting - procedure DrawEqualizer; - procedure ChangeMusic; - //Party Mode - procedure SelectRandomSong; - procedure SetJoker; - procedure SetStatics; - //procedures for Menu - procedure StartSong; - procedure OpenEditor; - procedure DoJoker(Team: Byte); - procedure SelectPlayers; - - procedure UnLoadDetailedCover; - - //Extensions - procedure DrawExtensions; - end; - -implementation -uses UGraphic, UMain, UCovers, math, OpenGL12, Windows, 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 - 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; - - SongCurrent := I2; - SongTarget := I2; - end; - end; - -procedure TScreenSong.FixSelected2; -var I, I2: Integer; - begin - if CatSongs.VisibleSongs > 0 then - 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; - - SongTarget := I2; - 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; - 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, 'Plain', true); - - Static[StaticCat].Texture := Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', true); - //Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', false); - //Button[Cat]. - //Cover - - - //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 - - -// Method for input parsing. If False is returned, GetNextWindow -// should be checked to know the next window to load; -function TScreenSong.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; -var - I: integer; - I2: integer; - HS: integer; - SDL_ModState: Word; - Letter: Char; -begin - Result := true; - - //Song Screen Extensions (Jumpto + Menu) - if (ScreenSongMenu.Visible) then - begin - Result := ScreenSongMenu.ParseInput(PressedKey, ScanCode, PressedDown); - Exit; - end - else if (ScreenSongJumpto.Visible) then - begin - Result := ScreenSongJumpto.ParseInput(PressedKey, ScanCode, PressedDown); - Exit; - end; - - 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 = 0) AND (PressedKey >= SDLK_A) AND (PressedKey <= SDLK_Z) then - begin - Letter := UpCase(Chr(ScanCode)); - I2 := Length(CatSongs.Song); - - //Jump To Titel - if (SDL_ModState = KMOD_LALT or KMOD_LSHIFT) then - begin - 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 (UpCase(CatSongs.Song[(I + Interaction) mod I2].Title[1]) = Letter) then - begin - SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); - - Music.PlayChange; - - ChangeMusic; - SetScroll4; - UpdateLCD; - //Break and Exit - Exit; - end; - end; - end - //Jump to Artist - else if (SDL_ModState = KMOD_LALT) then - begin - 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 (UpCase(CatSongs.Song[(I + Interaction) mod I2].Artist[1]) = Letter) then - begin - SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); - - Music.PlayChange; - - ChangeMusic; - SetScroll4; - UpdateLCD; - - //Break and Exit - Exit; - end; - end; - end; - Exit; - end; - - case PressedKey of - SDLK_Q: - begin - Result := false; - end; - - SDLK_ESCAPE, - SDLK_BACKSPACE : - begin - if (Mode = 0) 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 - 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 - Music.Stop; - - CatSongs.ShowCategoryList; - - //Show Cat in Top Left Mod - HideCatTL; - - - //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); - - //Show Cat in Top Left Mod - HideCatTL; - Interaction := 0; - - //Show Wrong Song when Tabs on Fix - SelectNext; - FixSelected; - - ChangeMusic; - end - else - begin - Music.Stop; - Music.PlayBack; - - FadeTo(@ScreenMain); - end; - - end; - end - //When in party Mode then Ask before Close - else if (Mode = 1) then - begin - Music.PlayBack; - CheckFadeTo(@ScreenMain,'MSG_END_PARTY'); - end; - end; - SDLK_RETURN: - begin - if Length(Songs.Song) > 0 then - begin - {$IFDEF UseSerialPort} - // PortWriteB($378, 0); - {$ENDIF} - if CatSongs.Song[Interaction].Main then - begin // clicked on Category Button - - //Show Cat in Top Left Mod - ShowCatTL (Interaction); - - //I := CatSongs.VisibleIndex(Interaction); - CatSongs.ClickCategoryButton(Interaction); - {I2 := CatSongs.VisibleIndex(Interaction); - SongCurrent := SongCurrent - I + I2; - SongTarget := SongTarget - I + I2; } - -// if I<>I2 then beep; - // SetScroll4; - - //Show Wrong Song when Tabs on Fix - SelectNext; - FixSelected; - - //Play Music: - ChangeMusic; - - end else begin // clicked on song - if (Mode = 0) then //Normal Mode -> Start Song - begin - //Do the Action that is specified in Ini - case Ini.OnSongClick of - 0: StartSong; - 1: SelectPlayers; - 2:begin - If (CatSongs.CatNumShow = -3) then - ScreenSongMenu.MenuShow(SM_Playlist) - else - ScreenSongMenu.MenuShow(SM_Main); - end; - end; - end - else if (Mode = 1) then //PartyMode -> Show Menu - begin - if (Ini.PartyPopup = 1) then - ScreenSongMenu.MenuShow(SM_Party_Main) - else - ScreenSong.StartSong; - end; - end; - end; - end; - - SDLK_M: //Show SongMenu - begin - if (Length(Songs.Song) > 0) then begin - if (Mode = 0) then begin - if not CatSongs.Song[Interaction].Main then begin // clicked on Song - if CatSongs.CatNumShow = -3 then - ScreenSongMenu.MenuShow(SM_Playlist) - else - ScreenSongMenu.MenuShow(SM_Main); - end - else - begin - ScreenSongMenu.MenuShow(SM_Playlist_Load); - end; - end //Party Mode -> Show Party Menu - else ScreenSongMenu.MenuShow(SM_Party_Main); - end; - end; - - SDLK_P: //Show Playlist Menu - begin - if (Length(Songs.Song) > 0) AND (Mode = 0) then begin - ScreenSongMenu.MenuShow(SM_Playlist_Load); - end; - end; - - SDLK_J: //Show Jumpto Menu - begin - if (Length(Songs.Song) > 0) AND (Mode = 0) then - begin - ScreenSongJumpto.Visible := True; - end; - end; - - SDLK_DOWN: - begin - if (Mode = 0) then - begin - //Only Change Cat when not in Playlist or Search Mode - if (CatSongs.CatNumShow > -2) then - begin - //Cat Change Hack - if Ini.Tabs_at_startup = 1 then - begin - I := Interaction; - if I <= 0 then I := 1; - - while not catsongs.Song[I].Main do - begin - Inc (I); - if (I > high(catsongs.Song)) then - I := low(catsongs.Song); - end; - - Interaction := I; - - //Show Cat in Top Left Mod - ShowCatTL (Interaction); - - CatSongs.ClickCategoryButton(Interaction); - SelectNext; - FixSelected; - - //Play Music: - Music.PlayChange; - ChangeMusic; - - end; - - // - //Cat Change Hack End} - end; - end; - end; - SDLK_UP: - begin - if (Mode = 0) then - begin - //Only Change Cat when not in Playlist or Search Mode - if (CatSongs.CatNumShow > -2) then - begin - //Cat Change Hack - if Ini.Tabs_at_startup = 1 then - begin - I := Interaction; - I2 := 0; - if I <= 0 then I := 1; - - 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; - - Interaction := I; - - //Show Cat in Top Left Mod - ShowCatTL (I); - - CatSongs.ClickCategoryButton(I); - SelectNext; - FixSelected; - - //Play Music: - Music.PlayChange; - ChangeMusic; - end; - end; - //Cat Change Hack End} - end; - end; - - SDLK_RIGHT: - begin - if (Length(Songs.Song) > 0) AND (Mode = 0) then begin - Music.PlayChange; - SelectNext; -// InteractNext; -// SongTarget := Interaction; - ChangeMusic; - SetScroll4; - UpdateLCD; - Light.LightOne(1, 200); - end; - end; - - SDLK_LEFT: - begin - if (Length(Songs.Song) > 0)AND (Mode = 0) then begin - Music.PlayChange; - SelectPrev; - ChangeMusic; - SetScroll4; - UpdateLCD; - Light.LightOne(0, 200); - end; - end; - - SDLK_E: - begin - OpenEditor; - end; - - SDLK_R: - begin - if (Length(Songs.Song) > 0) AND (Mode = 0) 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 := 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 - begin - //Show Cat in Top Left Mod - ShowCatTL (I); - - Interaction := I; - - 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 - begin - 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 - begin - if CatSongs.Song[I].Main then - break; - end; - //In I ist jetzt die Kategorie in I2 der Song - - //Choose Cat - CatSongs.ShowCategoryList; - - //Show Cat in Top Left Mod - ShowCatTL (I); - - CatSongs.ClickCategoryButton(I); - SelectNext; - - //Fix: Not Existing Song selected: - //if (I+1=I2) then Inc(I2); - - //Choose Song - SkipTo(I2-I); - - end - else //Random in one Category - begin - SkipTo(Random(CatSongs.VisibleSongs)); - end; - Music.PlayChange; - - ChangeMusic; - SetScroll4; - UpdateLCD; - end; - end; - - SDLK_1: - begin //Jocker - if (Mode = 1) AND (PartySession.Teams.NumTeams >= 1) AND (PartySession.Teams.Teaminfo[0].Joker > 0) then - begin - //Joker spielen - Dec(PartySession.Teams.Teaminfo[0].Joker); - SelectRandomSong; - SetJoker; - end; - end; - - SDLK_2: - begin //Jocker - if (Mode = 1) AND (PartySession.Teams.NumTeams >= 2) AND (PartySession.Teams.Teaminfo[1].Joker > 0) then - begin - //Joker spielen - Dec(PartySession.Teams.Teaminfo[1].Joker); - SelectRandomSong; - SetJoker; - end; - end; - - SDLK_3: - begin //Jocker - if (Mode = 1) AND (PartySession.Teams.NumTeams >= 3) AND (PartySession.Teams.Teaminfo[2].Joker > 0) then - begin - //Joker spielen - Dec(PartySession.Teams.Teaminfo[2].Joker); - SelectRandomSong; - SetJoker; - end; - end; - end; - end; -end; - -constructor TScreenSong.Create; -var - Pet: integer; - I: integer; -Label CreateSongButtons; -begin - inherited Create; - - LoadFromTheme(Theme.Song); - - TextArtist := AddText(Theme.Song.TextArtist); - TextTitle := AddText(Theme.Song.TextTitle); - TextNumber := AddText(Theme.Song.TextNumber); - - //Show Cat in Top Left mod - TextCat := AddText(Theme.Song.TextCat); - StaticCat := AddStatic(Theme.Song.StaticCat); - - //Show Video Icon Mod - VideoIcon := AddStatic(Theme.Song.VideoIcon); - - //Party Mode - StaticTeam1Joker1 := AddStatic(Theme.Song.StaticTeam1Joker1); - StaticTeam1Joker2 := AddStatic(Theme.Song.StaticTeam1Joker2); - StaticTeam1Joker3 := AddStatic(Theme.Song.StaticTeam1Joker3); - StaticTeam1Joker4 := AddStatic(Theme.Song.StaticTeam1Joker4); - StaticTeam1Joker5 := AddStatic(Theme.Song.StaticTeam1Joker5); - - StaticTeam2Joker1 := AddStatic(Theme.Song.StaticTeam2Joker1); - StaticTeam2Joker2 := AddStatic(Theme.Song.StaticTeam2Joker2); - StaticTeam2Joker3 := AddStatic(Theme.Song.StaticTeam2Joker3); - StaticTeam2Joker4 := AddStatic(Theme.Song.StaticTeam2Joker4); - StaticTeam2Joker5 := AddStatic(Theme.Song.StaticTeam2Joker5); - - StaticTeam3Joker1 := AddStatic(Theme.Song.StaticTeam3Joker1); - StaticTeam3Joker2 := AddStatic(Theme.Song.StaticTeam3Joker2); - StaticTeam3Joker3 := AddStatic(Theme.Song.StaticTeam3Joker3); - StaticTeam3Joker4 := AddStatic(Theme.Song.StaticTeam3Joker4); - StaticTeam3Joker5 := AddStatic(Theme.Song.StaticTeam3Joker5); - - //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]); - - SetLength(TextParty, Length(Theme.Song.TextParty)); - 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]); - - SetLength(TextNonParty, Length(Theme.Song.TextNonParty)); - 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 - CatSongs.Refresh; - - 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)); - - I := 0; - CreateSongButtons: - - try - for Pet := I to High(CatSongs.Song) do begin // creating all buttons - // 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 - CatSongs.Song[Pet].Cover := ''; // 0.5.0: if cover not found then show 'no cover' - - if CatSongs.Song[Pet].Cover = '' then - AddButton(300 + Pet*250, 140, 200, 200, Skin.GetTextureFileName('SongCover'), 'JPG', '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 begin - Texture.CreateCacheMipmap := true; - Texture.GetTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, '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); - - // unload full size texture - Texture.UnloadTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, 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, 'JPG', 'Plain', Theme.Song.Cover.Reflections); - end; - Texture.Limit := 1024*1024; - I := -1; - end; - except - //When Error is reported the First time for this Song - if (I <> Pet) then - begin - //Some Error reporting: - Log.LogError('Could not load Cover: ' + CatSongs.Song[Pet].Cover); - - //Change Cover to NoCover and Continue Loading - CatSongs.Song[Pet].Cover := ''; - I := Pet; - end - else //when Error occurs Multiple Times(NoSong Cover is damaged), then start loading next Song - begin - Log.LogError('NoCover Cover is damaged!'); - try - AddButton(300 + Pet*250, 140, 200, 200, '', 'JPG', 'Plain', Theme.Song.Cover.Reflections); - except - Messagebox(0, PChar('No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'), PChar(Language.Translate('US_VERSION')), MB_ICONERROR or MB_OK); - Halt; - end; - I := Pet + 1; - end; - end; - - if (I <> -1) then - GoTo CreateSongButtons; - - end; - - // Randomize Patch - Randomize; - //Equalizer - SetLength(EqualizerBands, Theme.Song.Equalizer.Bands); - //ClearArray - For I := low(EqualizerBands) to high(EqualizerBands) do - EqualizerBands[I] := 3; - - if (Length(CatSongs.Song) > 0) then - Interaction := 0; -end; - -procedure TScreenSong.SetScroll; -var - VS, B: Integer; -begin - VS := CatSongs.VisibleSongs; - if VS > 0 then - begin - //Set Positions - Case Theme.Song.Cover.Style of - 3: SetScroll3; - 5:begin - if VS > 5 then - SetScroll5 - else - SetScroll4; - end; - 6: SetScroll6; - else SetScroll4; - end; - //Set Visibility of Video Icon - Static[VideoIcon].Visible := (CatSongs.Song[Interaction].Video <> ''); - - //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 - 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') + ')'; - end - else if (CatSongs.CatNumShow = -2) then - Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) - else if (CatSongs.CatNumShow = -3) then - Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) - 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)); - 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; - - end; -end; - -procedure TScreenSong.SetScroll1; -var - B: integer; // button - BMin: integer; // button min - BMax: integer; // button max - Src: integer; -// Dst: integer; - Count: integer; // Dst is not used. Count is used. - Ready: boolean; - - VisCount: integer; // count of visible (or selectable) buttons - VisInt: integer; // visible position of interacted button - Typ: integer; // 0 when all songs fits the screen - Placed: integer; // number of placed visible buttons -begin -// Src := 0; -// Dst := -1; - Count := 1; - Typ := 0; - Ready := false; - Placed := 0; - - VisCount := 0; - 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); - - - if VisCount <= 6 then begin - Typ := 0; - end else begin - if VisInt <= 3 then begin - Typ := 1; - Count := 7; - Ready := true; - end; - - if (VisCount - VisInt) <= 3 then begin - Typ := 2; - Count := 7; - Ready := true; - end; - - if not Ready then begin - Typ := 3; - Src := Interaction; - end; - end; - - - - // hide all buttons - for B := 0 to High(Button) do begin - Button[B].Visible := false; - Button[B].Selectable := CatSongs.Song[B].Visible; - end; - -{ 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;} - - - if Typ = 0 then begin - for B := 0 to High(Button) do begin - if CatSongs.Song[B].Visible then begin - Button[B].Visible := true; - Button[B].Y := 140 + (Placed) * 60; - Inc(Placed); - end; - end; - end; - - if Typ = 1 then begin - B := 0; - while (Count > 0) do begin - if CatSongs.Song[B].Visible then begin - Button[B].Visible := true; - Button[B].Y := 140 + (Placed) * 60; - Inc(Placed); - Dec(Count); - end; - Inc(B); - end; - end; - - if Typ = 2 then begin - B := High(Button); - while (Count > 0) do begin - if CatSongs.Song[B].Visible then begin - Button[B].Visible := true; - Button[B].Y := 140 + (6-Placed) * 60; - Inc(Placed); - Dec(Count); - end; - Dec(B); - end; - end; - - if Typ = 3 then begin - B := Src; - Count := 4; - while (Count > 0) do begin - if CatSongs.Song[B].Visible then begin - Button[B].Visible := true; - Button[B].Y := 140 + (3+Placed) * 60; - Inc(Placed); - Dec(Count); - end; - Inc(B); - end; - - B := Src-1; - Placed := 0; - Count := 3; - while (Count > 0) do begin - if CatSongs.Song[B].Visible then begin - Button[B].Visible := true; - Button[B].Y := 140 + (2-Placed) * 60; - Inc(Placed); - Dec(Count); - end; - Dec(B); - end; - - end; - - if Length(Button) > 0 then - Static[1].Texture.Y := Button[Interaction].Y - 5; // selection texture -end; - -procedure TScreenSong.SetScroll2; -var - B: integer; - Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu - Wsp2: real; -begin - // liniowe - for B := 0 to High(Button) do - Button[B].X := 300 + (B - Interaction) * 260; - - 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; - - // kolowe -{ 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;} -end; - -procedure TScreenSong.SetScroll3; // with slide -var - B: integer; - Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu - Wsp2: real; -begin - SongTarget := Interaction; - - // liniowe - for B := 0 to High(Button) do - begin - Button[B].X := 300 + (B - SongCurrent) * 260; - if (Button[B].X < -Button[B].W) OR (Button[B].X > 800) then - Button[B].Visible := False - else - Button[B].Visible := True; - end; - -{ 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;} - - // kolowe -{ 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;} -end; - -procedure TScreenSong.SetScroll4; // rotate -var - B: integer; - Wsp: real; - Z, Z2: real; - VS: integer; -begin - VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important - - // kolowe - 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 - - 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; - - - Button[B].X := Theme.Song.Cover.X + (0.185 * Theme.Song.Cover.H * VS * sin(Wsp)) * Z2 - ((Button[B].H - Theme.Song.Cover.H)/2); // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs - Button[B].Z := Z / 2 + 0.3; - - 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].H := Button[B].W; - end; - end; -end; - -(* -procedure TScreenSong.SetScroll4; // rotate -var - B: integer; - Wsp: real; - Z: real; - Z2, Z3: real; - VS: integer; - function modreal (const X, Y: real):real; - begin - Result := Frac(x / y) * y; - if Result < -3 then - Result := Result + Y - else if Result > 3 then - Result := Result - Y; - end; -begin - VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important - Z3 := 1; - if VS < 12 then - Z2 := VS - else - Z2 := 12; - - // kolowe - 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 - begin - if CatSongs.VisibleIndex(B)> SongCurrent then - Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / Z2 - else - Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / Z2; - - Z3 := 2; - Z := (1 + cos(Wsp)) / 2; - //Z2 := (1 + 2*Z) / 3; - //Z2 := (0.5 + Z/2); - //Z2 := sin(Wsp); - - //Z2 := Power (Z2,Z3); - - Button[B].W := Theme.Song.CoverW * Power(cos(Wsp), Z3);//Power(Z2, 3); - - //Button[B].X := Theme.Song.CoverX + ({Theme.Song.CoverX + Theme.Song.CoverW/2 + Theme.Song.CoverW*0.18 * VS {CatSongs.VisibleSongs {Length(Button) * sin(Wsp) {- Theme.Song.CoverX - Theme.Song.CoverW) * Z2; // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs - if (sin(Wsp)<0) then - Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX + Theme.Song.CoverW - Button[B].W - else //*Theme.Song.CoverW*0.004*Z3 - 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 := (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 - begin - Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / 12 ;// 0.5.0 (II): takes another 16ms - - Z := (1 + cos(Wsp)) / 2 -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers - - Button[B].W := Theme.Song.CoverW * Power(cos(Wsp), Z3);//Power(Z2, 3); - - if (sin(Wsp)<0) then - Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX + Theme.Song.CoverW - Button[B].W - else - Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX; - - Button[B].Z := Z; - - Button[B].Y := (Theme.Song.CoverY + Theme.Song.CoverW - Button[B].W); - - Button[B].H := Button[B].W; - Button[B].Visible := True; - end - else Button[B].Visible := False; - end; - end; -end; *) - -procedure TScreenSong.SetScroll5; // rotate -var - B: integer; - Angle: real; - Pos: Real; - VS: integer; - diff: real; - X: Real; - helper: real; -begin - VS := CatSongs.VisibleSongs; // cache Visible Songs - {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 - Theme.Song.CoverH: Höhe der Cover - - (CatSongs.VisibleIndex(B) - SongCurrent)/VS = Abstand zum MIttleren Cover in % - } - - //Change Pos of all Buttons - for B := low(Button) to high(Button) do - begin - Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visibility - if Button[B].Visible then //Only Change Pos for Visible Buttons - begin - Pos := (CatSongs.VisibleIndex(B) - SongCurrent); - if (Pos < -VS/2) then - Pos := Pos + VS - else if (Pos > VS/2) then - Pos := Pos - VS; - - if (Abs(Pos) < 2.5) then {fixed Positions} - begin - Angle := Pi * (Pos / 5); -// 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].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; - - Button[B].Z := 0.95 - Abs(Pos) * 0.01; - - Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); - - Button[B].W := Button[B].H; - - Diff := (Button[B].H - Theme.Song.Cover.H)/2; - - - X := Sin(Angle*1.3)*0.9; - - Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * X - Diff; - - end - else - begin {Behind the Front Covers} - - // limit-bg-covers hack - if (abs(abs(Pos)-VS/2)>10) then Button[B].Visible:=False; - // end of limit-bg-covers hack - - if Pos < 0 then - Pos := (Pos - VS/2)/VS - else - Pos := (Pos + VS/2)/VS; - - Angle := pi * Pos*2; - if VS > 24 then - begin - if Angle < 0 then helper:=-1 else helper:=1; - Angle:=2*pi-abs(Angle); - Angle:=Angle*(VS/24); - Angle:=(2*pi-Angle)*helper; - end; - - Button[B].Z := (0.4 - Abs(Pos/4)) -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers - - Button[B].H :=0.6*(Theme.Song.Cover.H-Abs(Theme.Song.Cover.H * cos(Angle/2)*0.8));//Power(Z2, 3); - - Button[B].W := Button[B].H; - - 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].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; - - Diff := (Button[B].H - Theme.Song.Cover.H)/2; - - Button[B].X := Theme.Song.Cover.X+Theme.Song.Cover.H/2-Button[b].H/2+Theme.Song.Cover.W/320*((Theme.Song.Cover.H)*sin(Angle/2)*1.52); - - 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); - - end; - end; -end; - -procedure TScreenSong.SetScroll6; // rotate (slotmachine style) -var - B: integer; - Angle: real; - Pos: Real; - VS: integer; - diff: real; - X: Real; - Wsp: real; - Z, Z2: real; -begin - VS := CatSongs.VisibleSongs; // cache Visible Songs - if VS <=5 then begin - // kolowe - 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 - - 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; - - - Button[B].Y := Theme.Song.Cover.Y + (0.185 * Theme.Song.Cover.H * VS * sin(Wsp)) * Z2 - ((Button[B].H - Theme.Song.Cover.H)/2); // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs - Button[B].Z := Z / 2 + 0.3; - - Button[B].W := Theme.Song.Cover.H * 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; - end; - end - else begin - - //Change Pos of all Buttons - for B := low(Button) to high(Button) do - begin - Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visibility - if Button[B].Visible then //Only Change Pos for Visible Buttons - begin - Pos := (CatSongs.VisibleIndex(B) - SongCurrent); - if (Pos < -VS/2) then - Pos := Pos + VS - else if (Pos > VS/2) then - Pos := Pos - VS; - - if (Abs(Pos) < 2.5) then {fixed Positions} - begin - Angle := Pi * (Pos / 5); -// Button[B].Visible := False; - - Button[B].H := Abs(Theme.Song.Cover.H * cos(Angle*0.8));//Power(Z2, 3); - - Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; - - Button[B].Z := 0.95 - Abs(Pos) * 0.01; - - Button[B].X := (Theme.Song.Cover.X + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); - - Button[B].W := Button[B].H; - - Diff := (Button[B].H - Theme.Song.Cover.H)/2; - - - X := Sin(Angle*1.3)*0.9; - - Button[B].Y := Theme.Song.Cover.Y + Theme.Song.Cover.W * X - Diff; - end - else - begin {Behind the Front Covers} - - // limit-bg-covers hack - if (abs(VS/2-abs(Pos))>10) then Button[B].Visible:=False; - if VS > 25 then VS:=25; - // end of limit-bg-covers hack - - if Pos < 0 then - Pos := (Pos - VS/2)/VS - else - Pos := (Pos + VS/2)/VS; - - 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 - - Button[B].H :=0.6*(Theme.Song.Cover.H-Abs(Theme.Song.Cover.H * cos(Angle/2)*0.8));//Power(Z2, 3); - - Button[B].W := Button[B].H; - - Button[B].X := Theme.Song.Cover.X - (Button[B].H - Theme.Song.Cover.H)*0.5; - - - Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; - - Button[B].Y := Theme.Song.Cover.Y+Theme.Song.Cover.H/2-Button[b].H/2+Theme.Song.Cover.W/320*(Theme.Song.Cover.H*sin(Angle/2)*1.52); - end; - end; - end; - end; -end; - - -procedure TScreenSong.onShow; -begin - Music.Stop; - - if Ini.Players <= 3 then PlayersPlay := Ini.Players + 1; - 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 Length(CatSongs.Song) > 0 then begin - //Load Music only when Song Preview is activated - if (Ini.PreviewVolume <> 0) then - begin - Music.SetLoop(false); - Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); - Music.MoveTo(Music.Length / 4); - Music.Play; - - //Set Preview Volume - Music.SetMusicVolume (Ini.PreviewVolume * 10); - {//if Music Fade is activated, Set Volume to 0 % - if (Ini.PreviewFading <> 0) then - Music.SetMusicVolume(0);} - end; - - SetScroll; - UpdateLCD; - end; - - //Playlist Mode - if (Mode = 0) then - begin - //If Playlist Shown -> Select Next automatically - if (CatSongs.CatNumShow = -3) then - begin - SelectNext; - ChangeMusic; - end; - end - //Party Mode - else if (Mode = 1) then - begin - - SelectRandomSong; - //Show Menu directly in PartyMode - //But only if selected in Options - if (Ini.PartyPopup = 1) then - begin - ScreenSongMenu.MenuShow(SM_Party_Main); - end; - - - end; - - SetJoker; - SetStatics; -end; - -procedure TScreenSong.onHide; -begin - //When Music Fading is activated, Turn Music to 100 % - If (Ini.PreviewVolume <> 100) or (Ini.PreviewFading <> 0) then - Music.SetMusicVolume(100); - - //If Preview is deactivated: Load MUsicfile now - If (Ini.PreviewVolume = 0) then - Music.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 (Music <> nil) then - Music.Stop; -end; - -procedure TScreenSong.DrawExtensions; -begin - //Draw Song Menu - if (ScreenSongMenu.Visible) then - begin - ScreenSongMenu.Draw; - end - else if (ScreenSongJumpto.Visible) then - begin - ScreenSongJumpto.Draw; - end -end; - -function TScreenSong.Draw: boolean; -var - dx: real; - dt: real; - I: Integer; -begin - dx := SongTarget-SongCurrent; - dt := TimeSkip*7; - if dt > 1 then dt := 1; - SongCurrent := SongCurrent + dx*dt; - -{ if SongCurrent > Catsongs.VisibleSongs then begin - SongCurrent := SongCurrent - Catsongs.VisibleSongs; - SongTarget := SongTarget - Catsongs.VisibleSongs; - end;} - -// Log.BenchmarkStart(5); - SetScroll; -// Log.BenchmarkEnd(5); -// Log.LogBenchmark('SetScroll4', 5); - - //Fading Functions, Only if Covertime is under 5 Seconds - If (CoverTime < 5) then - begin - // 0.5.0: cover fade - if (CoverTime < 1) and (CoverTime + TimeSkip >= 1) then begin - // load new texture - Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); - Button[Interaction].Texture.Alpha := 1; - Button[Interaction].Texture2 := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); - Button[Interaction].Texture2.Alpha := 1; - end; - - //Song Fade - 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 - Music.Play; - - //Update Song Volume - if (CoverTime < Ini.PreviewFading) then - Music.SetMusicVolume(Round (CoverTime * Ini.PreviewVolume / Ini.PreviewFading * 10)) - else - Music.SetMusicVolume(Ini.PreviewVolume * 10); - - end; - - - //Update Fading Time - CoverTime := CoverTime + TimeSkip; - - //Update Fading Texture - Button[Interaction].Texture2.Alpha := (CoverTime - 1) * 1.5; - if Button[Interaction].Texture2.Alpha > 1 then Button[Interaction].Texture2.Alpha := 1; - - end; - - //inherited Draw; - //heres a little Hack, that causes the Statics - //are Drawn after the Buttons because of some Blending Problems. - //This should cause no Problems because all Buttons on this screen - //Has Z Position. - //Draw BG - DrawBG; - - //Instead of Draw FG Procedure: - //We draw Buttons for our own - for I := 0 to Length(Button) - 1 do - Button[I].Draw; - - // Statics - for I := 0 to Length(Static) - 1 do - Static[I].Draw; - - // and texts - for I := 0 to Length(Text) - 1 do - Text[I].Draw; - - - //Draw Equalizer - if Theme.Song.Equalizer.Visible then - DrawEqualizer; - - DrawExtensions; - -end; - -procedure TScreenSong.SelectNext; -var - Skip: integer; - I: integer; - VS: Integer; -begin - VS := CatSongs.VisibleSongs; - - if VS > 0 then - begin - UnLoadDetailedCover; - - Skip := 1; - - // this 1 could be changed by CatSongs.FindNextVisible - while (not CatSongs.Song[(Interaction + Skip) mod Length(Interactions)].Visible) do Inc(Skip); - - SongTarget := SongTarget + 1;//Skip; - - Interaction := (Interaction + Skip) mod Length(Interactions); - - // try to keep all at the beginning - if SongTarget > VS-1 then begin - SongTarget := SongTarget - VS; - SongCurrent := SongCurrent - VS; - end; - - end; - // Interaction -> Button, ktorego okladke przeczytamy - // Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture -end; - -procedure TScreenSong.SelectPrev; -var - Skip: integer; - I: integer; - VS: Integer; -begin - VS := CatSongs.VisibleSongs; - - if VS > 0 then - begin - UnLoadDetailedCover; - - Skip := 1; - - 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); - - // try to keep all at the beginning - if SongTarget < 0 then begin - SongTarget := SongTarget + CatSongs.VisibleSongs; - SongCurrent := SongCurrent + CatSongs.VisibleSongs; - end; - - // Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture - end; -end; - -procedure TScreenSong.UpdateLCD; -begin - LCD.HideCursor; - LCD.Clear; - LCD.WriteText(1, Text[TextArtist].Text); - LCD.WriteText(2, Text[TextTitle].Text); -end; - -//Procedure Change current played Preview -procedure TScreenSong.ChangeMusic; -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 - begin - Music.Close; - if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin - Music.MoveTo(Music.Length / 4); - //If Song Fading is activated then don't Play directly, and Set Volume to Null, else Play normal - if (Ini.PreviewFading = 0) then - Music.Play - else - Music.SetMusicVolume(0); - end; - end - else - Music.Stop; - end; -end; - -procedure TScreenSong.SkipTo(Target: Cardinal); // 0.5.0 -var - Skip: integer; - I: integer; -begin - UnLoadDetailedCover; - - Interaction := High(CatSongs.Song); - SongTarget := 0; - - for I := 1 to Target+1 do - SelectNext; - - FixSelected2; -end; - -procedure TScreenSong.DrawEqualizer; -var - Data: TFFTData; //Audio Data - I, J: Integer; - Res: byte; - A, B: Integer; - PosX, PosY: Integer; - Pos: Real; -begin -if (not Music.Finished) AND (Theme.Song.Equalizer.Length > 0) then -begin - - - A := GetTickCount div 44; - - if (A <> EqualizerTime) then - begin - EqualizerTime := A; - Data := Music.GetFFTData; - - B:=0; - Pos := 0; - Res := ceil(92/Theme.Song.Equalizer.Bands);//How much channels are used for one Band - - //Change Lengths - for I := 0 to (Res * Theme.Song.Equalizer.Bands - 1) do - begin - A := floor(I/Res); - - if (A<>B) then //Band changed - begin - if (Pos <= Theme.Song.Equalizer.Length) then - begin - if ((Pos < EqualizerBands[B]) AND (EqualizerBands[B]>1)) then - EqualizerBands[B] := EqualizerBands[B] - 1 - else - EqualizerBands[B] := floor(Pos); - end - else - EqualizerBands[B] := 1; - - B := A; - Pos := 0; - end; - - if I > 35 then - Data[i] := Data[i] * 8 - else if I > 11 then - Data[i] := Data[i] * 4.5 - else - Data[i] := Data[i] * 1.1; - - if (Data[i] >= 1) then - Data[i] := 0.9999999999999; - - if Data[i]*Theme.Song.Equalizer.Length > Pos then - Pos := Data[i]*Theme.Song.Equalizer.Length; - end; - - //Change Last Band - if (EqualizerBands[B] <= Theme.Song.Equalizer.Length) then - begin - if ((Pos < EqualizerBands[B]) AND (EqualizerBands[B]>1)) then - EqualizerBands[B] := EqualizerBands[B] - 1 - else - EqualizerBands[B] := floor(Pos) - end - else - EqualizerBands[B] := 1; - end; - - //Draw every Channel - glColor4f(Theme.Song.Equalizer.ColR, Theme.Song.Equalizer.ColG, Theme.Song.Equalizer.ColB, Theme.Song.Equalizer.Alpha); //Set Color - glDisable(GL_TEXTURE_2D); - glEnable(GL_BLEND); - - PosY := Theme.Song.Equalizer.Y; - PosX := Theme.Song.Equalizer.X; - - For I := 0 to Theme.Song.Equalizer.Bands-1 do - begin - if Theme.Song.Equalizer.Direction then - PosY := Theme.Song.Equalizer.Y //+ (Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space) * Theme.Song.Equalizer.Length - else - PosX := Theme.Song.Equalizer.X; - //Draw for every visible quad - for J := 1 to EqualizerBands[I] do - begin - glBegin(GL_QUADS); - glVertex3f(PosX, PosY, Theme.Song.Equalizer.Z); - glVertex3f(PosX, PosY+Theme.Song.Equalizer.H, Theme.Song.Equalizer.Z); - glVertex3f(PosX+Theme.Song.Equalizer.W, PosY+Theme.Song.Equalizer.H, Theme.Song.Equalizer.Z); - glVertex3f(PosX+Theme.Song.Equalizer.W, PosY, Theme.Song.Equalizer.Z); - glEnd; - - if Theme.Song.Equalizer.Direction then //Vertically - PosY := PosY - Theme.Song.Equalizer.H - Theme.Song.Equalizer.Space - else //Horizontally - PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space; - end; - if Theme.Song.Equalizer.Direction then //Horizontally - PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space - else //Vertically - PosY := PosY + Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space; - end; -end; -end; - -Procedure TScreenSong.SelectRandomSong; -var - I, I2: Integer; -begin - Case PlaylistMan.Mode of - 0: //All Songs Just Select Random Song - begin - //When Tabs are activated then use Tab Method - if (Ini.Tabs_at_startup = 1) then - begin - 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 - begin - if CatSongs.Song[I].Main then - break; - 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 - - //Choose Cat - CatSongs.ShowCategoryList; - - //Show Cat in Top Left Mod - ShowCatTL (I); - - CatSongs.ClickCategoryButton(I); - SelectNext; - - //Choose Song - SkipTo(I2-I); - end - //When Tabs are deactivated use easy Method - else - SkipTo(Random(CatSongs.VisibleSongs)); - end; - 1: //One Category Select Category and Select Random Song - begin - CatSongs.ShowCategoryList; - CatSongs.ClickCategoryButton(PlaylistMan.CurPlayList); - ShowCatTL(PlaylistMan.CurPlayList); - - SelectNext; - FixSelected2; - - SkipTo(Random(CatSongs.VisibleSongs)); - end; - 2: //Playlist: Select Playlist and Select Random Song - begin - PlaylistMan.SetPlayList(PlaylistMan.CurPlayList); - - SkipTo(Random(CatSongs.VisibleSongs)); - FixSelected2; - end; - end; - - Music.PlayChange; - ChangeMusic; - SetScroll; - UpdateLCD; -end; - -procedure TScreenSong.SetJoker; -begin - //If Party Mode - if Mode = 1 then //Show Joker that are available - begin - if (PartySession.Teams.NumTeams >= 1) then - begin - Static[StaticTeam1Joker1].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 1); - Static[StaticTeam1Joker2].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 2); - Static[StaticTeam1Joker3].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 3); - Static[StaticTeam1Joker4].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 4); - Static[StaticTeam1Joker5].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 5); - end - else - begin - Static[StaticTeam1Joker1].Visible := False; - Static[StaticTeam1Joker2].Visible := False; - Static[StaticTeam1Joker3].Visible := False; - Static[StaticTeam1Joker4].Visible := False; - Static[StaticTeam1Joker5].Visible := False; - end; - - if (PartySession.Teams.NumTeams >= 2) then - begin - Static[StaticTeam2Joker1].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 1); - Static[StaticTeam2Joker2].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 2); - Static[StaticTeam2Joker3].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 3); - Static[StaticTeam2Joker4].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 4); - Static[StaticTeam2Joker5].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 5); - end - else - begin - Static[StaticTeam2Joker1].Visible := False; - Static[StaticTeam2Joker2].Visible := False; - Static[StaticTeam2Joker3].Visible := False; - Static[StaticTeam2Joker4].Visible := False; - Static[StaticTeam2Joker5].Visible := False; - end; - - if (PartySession.Teams.NumTeams >= 3) then - begin - Static[StaticTeam3Joker1].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 1); - Static[StaticTeam3Joker2].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 2); - Static[StaticTeam3Joker3].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 3); - Static[StaticTeam3Joker4].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 4); - Static[StaticTeam3Joker5].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 5); - end - else - begin - Static[StaticTeam3Joker1].Visible := False; - Static[StaticTeam3Joker2].Visible := False; - Static[StaticTeam3Joker3].Visible := False; - Static[StaticTeam3Joker4].Visible := False; - Static[StaticTeam3Joker5].Visible := False; - end; - end - else - begin //Hide all - Static[StaticTeam1Joker1].Visible := False; - Static[StaticTeam1Joker2].Visible := False; - Static[StaticTeam1Joker3].Visible := False; - Static[StaticTeam1Joker4].Visible := False; - Static[StaticTeam1Joker5].Visible := False; - - Static[StaticTeam2Joker1].Visible := False; - Static[StaticTeam2Joker2].Visible := False; - Static[StaticTeam2Joker3].Visible := False; - Static[StaticTeam2Joker4].Visible := False; - Static[StaticTeam2Joker5].Visible := False; - - Static[StaticTeam3Joker1].Visible := False; - Static[StaticTeam3Joker2].Visible := False; - Static[StaticTeam3Joker3].Visible := False; - Static[StaticTeam3Joker4].Visible := False; - Static[StaticTeam3Joker5].Visible := False; - end; -end; - -procedure TScreenSong.SetStatics; -var - I: Integer; - Visible: Boolean; -begin - //Set Visibility of Party Statics and Text - Visible := (Mode = 1); - - For I := 0 to high(StaticParty) do - Static[StaticParty[I]].Visible := Visible; - - 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 - Static[StaticNonParty[I]].Visible := Visible; - - For I := 0 to high(TextNonParty) do - Text[TextNonParty[I]].Visible := Visible; -end; - -//Procedures for Menu - -procedure TScreenSong.StartSong; -begin - CatSongs.Selected := Interaction; - Music.Stop; - //Party Mode - if (Mode = 1) then - begin - FadeTo(@ScreenSingModi); - end - else - begin - FadeTo(@ScreenSing); - end; -end; - -procedure TScreenSong.SelectPlayers; -begin - CatSongs.Selected := Interaction; - Music.Stop; - - ScreenName.Goto_SingScreen := True; - FadeTo(@ScreenName); -end; - -procedure TScreenSong.OpenEditor; -begin - if (Length(Songs.Song) > 0) and (not CatSongs.Song[Interaction].Main) AND (Mode = 0) then begin - Music.Stop; - Music.PlayStart; - ScreenEditSub.Path := CatSongs.Song[Interaction].Path; - ScreenEditSub.FileName := CatSongs.Song[Interaction].FileName; - FadeTo(@ScreenEditSub); - end; -end; - -//Team No of Team (0-5) -procedure TScreenSong.DoJoker (Team: Byte); -begin - if (Mode = 1) AND (PartySession.Teams.NumTeams >= Team + 1) AND (PartySession.Teams.Teaminfo[Team].Joker > 0) then - begin - //Joker spielen - Dec(PartySession.Teams.Teaminfo[Team].Joker); - SelectRandomSong; - SetJoker; - 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, 'Plain', true); // 0.5.0: show cached texture - Button[Interaction].Texture2.Alpha := 0; - - if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then - Texture.UnloadTexture(Button[Interaction].Texture.Name, false); -end; - -procedure TScreenSong.Refresh; -begin { -CatSongs.Refresh; -CatSongs.ShowCategoryList; -Interaction := 0; -SelectNext; -FixSelected; } - -end; - -end. +unit UScreenSong; + +interface +{$I switches.inc} + +uses + UMenu, + SDL, + UMusic, + UFiles, + UTime, + UDisplay, + USongs, + SysUtils, + ULog, + UThemes, + UTexture, + ULanguage, + ULCD, + ULight, + UIni; + +type + TScreenSong = class(TMenu) + public + TextArtist: integer; + TextTitle: integer; + TextNumber: integer; + + //Video Icon Mod + VideoIcon: Cardinal; + + TextCat: integer; + StaticCat: integer; + + SongCurrent: real; + SongTarget: real; + + HighSpeed: boolean; + CoverFull: boolean; + CoverTime: real; + CoverX: integer; + CoverY: integer; + CoverW: integer; + is_jump: boolean; // Jump to Song Mod + is_jump_title:boolean; //Jump to SOng MOd-YTrue if search for Title + + EqualizerBands: array of Byte; + EqualizerTime: Cardinal; + EqualizerTime2: Byte; + + //Party Mod + Mode: Byte; //0 = Standard, 1= Go to PartyMode after Selection + Change to Random Song at Show + //party Statics (Joker) + StaticTeam1Joker1: Cardinal; + StaticTeam1Joker2: Cardinal; + StaticTeam1Joker3: Cardinal; + StaticTeam1Joker4: Cardinal; + StaticTeam1Joker5: Cardinal; + + StaticTeam2Joker1: Cardinal; + StaticTeam2Joker2: Cardinal; + StaticTeam2Joker3: Cardinal; + StaticTeam2Joker4: Cardinal; + StaticTeam2Joker5: Cardinal; + + StaticTeam3Joker1: Cardinal; + StaticTeam3Joker2: Cardinal; + StaticTeam3Joker3: Cardinal; + StaticTeam3Joker4: Cardinal; + StaticTeam3Joker5: Cardinal; + + StaticParty: Array of Cardinal; + TextParty: Array of Cardinal; + StaticNonParty: Array of Cardinal; + TextNonParty: Array of Cardinal; + + + constructor Create; override; + procedure SetScroll; + procedure SetScroll1; + procedure SetScroll2; + procedure SetScroll3; + procedure SetScroll4; + procedure SetScroll5; + procedure SetScroll6; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + function Draw: boolean; override; + procedure onShow; override; + procedure onHide; override; + procedure SelectNext; + procedure SelectPrev; + procedure UpdateLCD; + procedure SkipTo(Target: Cardinal); + procedure FixSelected; //Show Wrong Song when Tabs on Fix + procedure FixSelected2; //Show Wrong Song when Tabs on Fix + procedure ShowCatTL(Cat: Integer);// Show Cat in Top left + procedure ShowCatTLCustom(Caption: String);// Show Custom Text in Top left + procedure HideCatTL;// Show Cat in Tob left + procedure Refresh; //Refresh Song Sorting + procedure DrawEqualizer; + procedure ChangeMusic; + //Party Mode + procedure SelectRandomSong; + procedure SetJoker; + procedure SetStatics; + //procedures for Menu + procedure StartSong; + procedure OpenEditor; + procedure DoJoker(Team: Byte); + procedure SelectPlayers; + + procedure UnLoadDetailedCover; + + //Extensions + procedure DrawExtensions; + end; + +implementation +uses UGraphic, + UMain, + UCovers, + math, + OpenGL12, + {$IFDEF win32} + windows, + {$ELSE} + lclintf, + {$ENDIF} + 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 + 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; + + SongCurrent := I2; + SongTarget := I2; + end; + end; + +procedure TScreenSong.FixSelected2; +var I, I2: Integer; + begin + if CatSongs.VisibleSongs > 0 then + 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; + + SongTarget := I2; + 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; + 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, 'Plain', true); + + Static[StaticCat].Texture := Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', true); + //Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', false); + //Button[Cat]. + //Cover + + + //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 + + +// Method for input parsing. If False is returned, GetNextWindow +// should be checked to know the next window to load; +function TScreenSong.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +var + I: integer; + I2: integer; + HS: integer; + SDL_ModState: Word; + Letter: Char; +begin + Result := true; + + //Song Screen Extensions (Jumpto + Menu) + if (ScreenSongMenu.Visible) then + begin + Result := ScreenSongMenu.ParseInput(PressedKey, ScanCode, PressedDown); + Exit; + end + else if (ScreenSongJumpto.Visible) then + begin + Result := ScreenSongJumpto.ParseInput(PressedKey, ScanCode, PressedDown); + Exit; + end; + + 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 = 0) AND (PressedKey >= SDLK_A) AND (PressedKey <= SDLK_Z) then + begin + Letter := UpCase(Chr(ScanCode)); + I2 := Length(CatSongs.Song); + + //Jump To Titel + if (SDL_ModState = KMOD_LALT or KMOD_LSHIFT) then + begin + 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 (UpCase(CatSongs.Song[(I + Interaction) mod I2].Title[1]) = Letter) then + begin + SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); + + Music.PlayChange; + + ChangeMusic; + SetScroll4; + UpdateLCD; + //Break and Exit + Exit; + end; + end; + end + //Jump to Artist + else if (SDL_ModState = KMOD_LALT) then + begin + 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 (UpCase(CatSongs.Song[(I + Interaction) mod I2].Artist[1]) = Letter) then + begin + SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); + + Music.PlayChange; + + ChangeMusic; + SetScroll4; + UpdateLCD; + + //Break and Exit + Exit; + end; + end; + end; + Exit; + end; + + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + if (Mode = 0) 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 + 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 + Music.Stop; + + CatSongs.ShowCategoryList; + + //Show Cat in Top Left Mod + HideCatTL; + + + //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); + + //Show Cat in Top Left Mod + HideCatTL; + Interaction := 0; + + //Show Wrong Song when Tabs on Fix + SelectNext; + FixSelected; + + ChangeMusic; + end + else + begin + Music.Stop; + Music.PlayBack; + + FadeTo(@ScreenMain); + end; + + end; + end + //When in party Mode then Ask before Close + else if (Mode = 1) then + begin + Music.PlayBack; + CheckFadeTo(@ScreenMain,'MSG_END_PARTY'); + end; + end; + SDLK_RETURN: + begin + if Length(Songs.Song) > 0 then + begin + {$IFDEF UseSerialPort} + // PortWriteB($378, 0); + {$ENDIF} + if CatSongs.Song[Interaction].Main then + begin // clicked on Category Button + + //Show Cat in Top Left Mod + ShowCatTL (Interaction); + + //I := CatSongs.VisibleIndex(Interaction); + CatSongs.ClickCategoryButton(Interaction); + {I2 := CatSongs.VisibleIndex(Interaction); + SongCurrent := SongCurrent - I + I2; + SongTarget := SongTarget - I + I2; } + +// if I<>I2 then beep; + // SetScroll4; + + //Show Wrong Song when Tabs on Fix + SelectNext; + FixSelected; + + //Play Music: + ChangeMusic; + + end else begin // clicked on song + if (Mode = 0) then //Normal Mode -> Start Song + begin + //Do the Action that is specified in Ini + case Ini.OnSongClick of + 0: StartSong; + 1: SelectPlayers; + 2:begin + If (CatSongs.CatNumShow = -3) then + ScreenSongMenu.MenuShow(SM_Playlist) + else + ScreenSongMenu.MenuShow(SM_Main); + end; + end; + end + else if (Mode = 1) then //PartyMode -> Show Menu + begin + if (Ini.PartyPopup = 1) then + ScreenSongMenu.MenuShow(SM_Party_Main) + else + ScreenSong.StartSong; + end; + end; + end; + end; + + SDLK_M: //Show SongMenu + begin + if (Length(Songs.Song) > 0) then begin + if (Mode = 0) then begin + if not CatSongs.Song[Interaction].Main then begin // clicked on Song + if CatSongs.CatNumShow = -3 then + ScreenSongMenu.MenuShow(SM_Playlist) + else + ScreenSongMenu.MenuShow(SM_Main); + end + else + begin + ScreenSongMenu.MenuShow(SM_Playlist_Load); + end; + end //Party Mode -> Show Party Menu + else ScreenSongMenu.MenuShow(SM_Party_Main); + end; + end; + + SDLK_P: //Show Playlist Menu + begin + if (Length(Songs.Song) > 0) AND (Mode = 0) then begin + ScreenSongMenu.MenuShow(SM_Playlist_Load); + end; + end; + + SDLK_J: //Show Jumpto Menu + begin + if (Length(Songs.Song) > 0) AND (Mode = 0) then + begin + ScreenSongJumpto.Visible := True; + end; + end; + + SDLK_DOWN: + begin + if (Mode = 0) then + begin + //Only Change Cat when not in Playlist or Search Mode + if (CatSongs.CatNumShow > -2) then + begin + //Cat Change Hack + if Ini.Tabs_at_startup = 1 then + begin + I := Interaction; + if I <= 0 then I := 1; + + while not catsongs.Song[I].Main do + begin + Inc (I); + if (I > high(catsongs.Song)) then + I := low(catsongs.Song); + end; + + Interaction := I; + + //Show Cat in Top Left Mod + ShowCatTL (Interaction); + + CatSongs.ClickCategoryButton(Interaction); + SelectNext; + FixSelected; + + //Play Music: + Music.PlayChange; + ChangeMusic; + + end; + + // + //Cat Change Hack End} + end; + end; + end; + SDLK_UP: + begin + if (Mode = 0) then + begin + //Only Change Cat when not in Playlist or Search Mode + if (CatSongs.CatNumShow > -2) then + begin + //Cat Change Hack + if Ini.Tabs_at_startup = 1 then + begin + I := Interaction; + I2 := 0; + if I <= 0 then I := 1; + + 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; + + Interaction := I; + + //Show Cat in Top Left Mod + ShowCatTL (I); + + CatSongs.ClickCategoryButton(I); + SelectNext; + FixSelected; + + //Play Music: + Music.PlayChange; + ChangeMusic; + end; + end; + //Cat Change Hack End} + end; + end; + + SDLK_RIGHT: + begin + if (Length(Songs.Song) > 0) AND (Mode = 0) then begin + Music.PlayChange; + SelectNext; +// InteractNext; +// SongTarget := Interaction; + ChangeMusic; + SetScroll4; + UpdateLCD; + Light.LightOne(1, 200); + end; + end; + + SDLK_LEFT: + begin + if (Length(Songs.Song) > 0)AND (Mode = 0) then begin + Music.PlayChange; + SelectPrev; + ChangeMusic; + SetScroll4; + UpdateLCD; + Light.LightOne(0, 200); + end; + end; + + SDLK_E: + begin + OpenEditor; + end; + + SDLK_R: + begin + if (Length(Songs.Song) > 0) AND (Mode = 0) 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 := 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 + begin + //Show Cat in Top Left Mod + ShowCatTL (I); + + Interaction := I; + + 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 + begin + 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 + begin + if CatSongs.Song[I].Main then + break; + end; + //In I ist jetzt die Kategorie in I2 der Song + + //Choose Cat + CatSongs.ShowCategoryList; + + //Show Cat in Top Left Mod + ShowCatTL (I); + + CatSongs.ClickCategoryButton(I); + SelectNext; + + //Fix: Not Existing Song selected: + //if (I+1=I2) then Inc(I2); + + //Choose Song + SkipTo(I2-I); + + end + else //Random in one Category + begin + SkipTo(Random(CatSongs.VisibleSongs)); + end; + Music.PlayChange; + + ChangeMusic; + SetScroll4; + UpdateLCD; + end; + end; + + SDLK_1: + begin //Jocker + if (Mode = 1) AND (PartySession.Teams.NumTeams >= 1) AND (PartySession.Teams.Teaminfo[0].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[0].Joker); + SelectRandomSong; + SetJoker; + end; + end; + + SDLK_2: + begin //Jocker + if (Mode = 1) AND (PartySession.Teams.NumTeams >= 2) AND (PartySession.Teams.Teaminfo[1].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[1].Joker); + SelectRandomSong; + SetJoker; + end; + end; + + SDLK_3: + begin //Jocker + if (Mode = 1) AND (PartySession.Teams.NumTeams >= 3) AND (PartySession.Teams.Teaminfo[2].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[2].Joker); + SelectRandomSong; + SetJoker; + end; + end; + end; + end; +end; + +constructor TScreenSong.Create; +var + Pet: integer; + I: integer; +Label CreateSongButtons; +begin + inherited Create; + + LoadFromTheme(Theme.Song); + + TextArtist := AddText(Theme.Song.TextArtist); + TextTitle := AddText(Theme.Song.TextTitle); + TextNumber := AddText(Theme.Song.TextNumber); + + //Show Cat in Top Left mod + TextCat := AddText(Theme.Song.TextCat); + StaticCat := AddStatic(Theme.Song.StaticCat); + + //Show Video Icon Mod + VideoIcon := AddStatic(Theme.Song.VideoIcon); + + //Party Mode + StaticTeam1Joker1 := AddStatic(Theme.Song.StaticTeam1Joker1); + StaticTeam1Joker2 := AddStatic(Theme.Song.StaticTeam1Joker2); + StaticTeam1Joker3 := AddStatic(Theme.Song.StaticTeam1Joker3); + StaticTeam1Joker4 := AddStatic(Theme.Song.StaticTeam1Joker4); + StaticTeam1Joker5 := AddStatic(Theme.Song.StaticTeam1Joker5); + + StaticTeam2Joker1 := AddStatic(Theme.Song.StaticTeam2Joker1); + StaticTeam2Joker2 := AddStatic(Theme.Song.StaticTeam2Joker2); + StaticTeam2Joker3 := AddStatic(Theme.Song.StaticTeam2Joker3); + StaticTeam2Joker4 := AddStatic(Theme.Song.StaticTeam2Joker4); + StaticTeam2Joker5 := AddStatic(Theme.Song.StaticTeam2Joker5); + + StaticTeam3Joker1 := AddStatic(Theme.Song.StaticTeam3Joker1); + StaticTeam3Joker2 := AddStatic(Theme.Song.StaticTeam3Joker2); + StaticTeam3Joker3 := AddStatic(Theme.Song.StaticTeam3Joker3); + StaticTeam3Joker4 := AddStatic(Theme.Song.StaticTeam3Joker4); + StaticTeam3Joker5 := AddStatic(Theme.Song.StaticTeam3Joker5); + + //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]); + + SetLength(TextParty, Length(Theme.Song.TextParty)); + 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]); + + SetLength(TextNonParty, Length(Theme.Song.TextNonParty)); + 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 + CatSongs.Refresh; + + 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)); + + I := 0; + CreateSongButtons: + + try + for Pet := I to High(CatSongs.Song) do begin // creating all buttons + // 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 + CatSongs.Song[Pet].Cover := ''; // 0.5.0: if cover not found then show 'no cover' + + if CatSongs.Song[Pet].Cover = '' then + AddButton(300 + Pet*250, 140, 200, 200, Skin.GetTextureFileName('SongCover'), 'JPG', '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 begin + Texture.CreateCacheMipmap := true; + Texture.GetTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, '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); + + // unload full size texture + Texture.UnloadTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, 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, 'JPG', 'Plain', Theme.Song.Cover.Reflections); + end; + Texture.Limit := 1024*1024; + I := -1; + end; + except + //When Error is reported the First time for this Song + if (I <> Pet) then + begin + //Some Error reporting: + Log.LogError('Could not load Cover: ' + CatSongs.Song[Pet].Cover); + + //Change Cover to NoCover and Continue Loading + CatSongs.Song[Pet].Cover := ''; + I := Pet; + end + else //when Error occurs Multiple Times(NoSong Cover is damaged), then start loading next Song + begin + Log.LogError('NoCover Cover is damaged!'); + try + AddButton(300 + Pet*250, 140, 200, 200, '', 'JPG', 'Plain', Theme.Song.Cover.Reflections); + except + {$IFDEF win32} + Messagebox(0, PChar('No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'), PChar(Language.Translate('US_VERSION')), MB_ICONERROR or MB_OK); + {$ELSE} + // TODO : JB_linux - better handle this message and display to user.. + writeln( 'No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'); + Log.LogError( 'No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.' ); + {$ENDIF} + Halt; + end; + I := Pet + 1; + end; + end; + + if (I <> -1) then + GoTo CreateSongButtons; + + end; + + // Randomize Patch + Randomize; + //Equalizer + SetLength(EqualizerBands, Theme.Song.Equalizer.Bands); + //ClearArray + For I := low(EqualizerBands) to high(EqualizerBands) do + EqualizerBands[I] := 3; + + if (Length(CatSongs.Song) > 0) then + Interaction := 0; +end; + +procedure TScreenSong.SetScroll; +var + VS, B: Integer; +begin + VS := CatSongs.VisibleSongs; + if VS > 0 then + begin + //Set Positions + Case Theme.Song.Cover.Style of + 3: SetScroll3; + 5:begin + if VS > 5 then + SetScroll5 + else + SetScroll4; + end; + 6: SetScroll6; + else SetScroll4; + end; + //Set Visibility of Video Icon + Static[VideoIcon].Visible := (CatSongs.Song[Interaction].Video <> ''); + + //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 + 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') + ')'; + end + else if (CatSongs.CatNumShow = -2) then + Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) + else if (CatSongs.CatNumShow = -3) then + Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) + 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)); + 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; + + end; +end; + +procedure TScreenSong.SetScroll1; +var + B: integer; // button + BMin: integer; // button min + BMax: integer; // button max + Src: integer; +// Dst: integer; + Count: integer; // Dst is not used. Count is used. + Ready: boolean; + + VisCount: integer; // count of visible (or selectable) buttons + VisInt: integer; // visible position of interacted button + Typ: integer; // 0 when all songs fits the screen + Placed: integer; // number of placed visible buttons +begin +// Src := 0; +// Dst := -1; + Count := 1; + Typ := 0; + Ready := false; + Placed := 0; + + VisCount := 0; + 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); + + + if VisCount <= 6 then begin + Typ := 0; + end else begin + if VisInt <= 3 then begin + Typ := 1; + Count := 7; + Ready := true; + end; + + if (VisCount - VisInt) <= 3 then begin + Typ := 2; + Count := 7; + Ready := true; + end; + + if not Ready then begin + Typ := 3; + Src := Interaction; + end; + end; + + + + // hide all buttons + for B := 0 to High(Button) do begin + Button[B].Visible := false; + Button[B].Selectable := CatSongs.Song[B].Visible; + end; + +{ 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;} + + + if Typ = 0 then begin + for B := 0 to High(Button) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (Placed) * 60; + Inc(Placed); + end; + end; + end; + + if Typ = 1 then begin + B := 0; + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Inc(B); + end; + end; + + if Typ = 2 then begin + B := High(Button); + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (6-Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Dec(B); + end; + end; + + if Typ = 3 then begin + B := Src; + Count := 4; + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (3+Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Inc(B); + end; + + B := Src-1; + Placed := 0; + Count := 3; + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (2-Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Dec(B); + end; + + end; + + if Length(Button) > 0 then + Static[1].Texture.Y := Button[Interaction].Y - 5; // selection texture +end; + +procedure TScreenSong.SetScroll2; +var + B: integer; + Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu + Wsp2: real; +begin + // liniowe + for B := 0 to High(Button) do + Button[B].X := 300 + (B - Interaction) * 260; + + 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; + + // kolowe +{ 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;} +end; + +procedure TScreenSong.SetScroll3; // with slide +var + B: integer; + Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu + Wsp2: real; +begin + SongTarget := Interaction; + + // liniowe + for B := 0 to High(Button) do + begin + Button[B].X := 300 + (B - SongCurrent) * 260; + if (Button[B].X < -Button[B].W) OR (Button[B].X > 800) then + Button[B].Visible := False + else + Button[B].Visible := True; + end; + +{ 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;} + + // kolowe +{ 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;} +end; + +procedure TScreenSong.SetScroll4; // rotate +var + B: integer; + Wsp: real; + Z, Z2: real; + VS: integer; +begin + VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important + + // kolowe + 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 + + 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; + + + Button[B].X := Theme.Song.Cover.X + (0.185 * Theme.Song.Cover.H * VS * sin(Wsp)) * Z2 - ((Button[B].H - Theme.Song.Cover.H)/2); // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs + Button[B].Z := Z / 2 + 0.3; + + 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].H := Button[B].W; + end; + end; +end; + +(* +procedure TScreenSong.SetScroll4; // rotate +var + B: integer; + Wsp: real; + Z: real; + Z2, Z3: real; + VS: integer; + function modreal (const X, Y: real):real; + begin + Result := Frac(x / y) * y; + if Result < -3 then + Result := Result + Y + else if Result > 3 then + Result := Result - Y; + end; +begin + VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important + Z3 := 1; + if VS < 12 then + Z2 := VS + else + Z2 := 12; + + // kolowe + 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 + begin + if CatSongs.VisibleIndex(B)> SongCurrent then + Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / Z2 + else + Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / Z2; + + Z3 := 2; + Z := (1 + cos(Wsp)) / 2; + //Z2 := (1 + 2*Z) / 3; + //Z2 := (0.5 + Z/2); + //Z2 := sin(Wsp); + + //Z2 := Power (Z2,Z3); + + Button[B].W := Theme.Song.CoverW * Power(cos(Wsp), Z3);//Power(Z2, 3); + + //Button[B].X := Theme.Song.CoverX + ({Theme.Song.CoverX + Theme.Song.CoverW/2 + Theme.Song.CoverW*0.18 * VS {CatSongs.VisibleSongs {Length(Button) * sin(Wsp) {- Theme.Song.CoverX - Theme.Song.CoverW) * Z2; // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs + if (sin(Wsp)<0) then + Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX + Theme.Song.CoverW - Button[B].W + else //*Theme.Song.CoverW*0.004*Z3 + 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 := (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 + begin + Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / 12 ;// 0.5.0 (II): takes another 16ms + + Z := (1 + cos(Wsp)) / 2 -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers + + Button[B].W := Theme.Song.CoverW * Power(cos(Wsp), Z3);//Power(Z2, 3); + + if (sin(Wsp)<0) then + Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX + Theme.Song.CoverW - Button[B].W + else + Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX; + + Button[B].Z := Z; + + Button[B].Y := (Theme.Song.CoverY + Theme.Song.CoverW - Button[B].W); + + Button[B].H := Button[B].W; + Button[B].Visible := True; + end + else Button[B].Visible := False; + end; + end; +end; *) + +procedure TScreenSong.SetScroll5; // rotate +var + B: integer; + Angle: real; + Pos: Real; + VS: integer; + diff: real; + X: Real; + helper: real; +begin + VS := CatSongs.VisibleSongs; // cache Visible Songs + {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 + Theme.Song.CoverH: Höhe der Cover + + (CatSongs.VisibleIndex(B) - SongCurrent)/VS = Abstand zum MIttleren Cover in % + } + + //Change Pos of all Buttons + for B := low(Button) to high(Button) do + begin + Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visibility + if Button[B].Visible then //Only Change Pos for Visible Buttons + begin + Pos := (CatSongs.VisibleIndex(B) - SongCurrent); + if (Pos < -VS/2) then + Pos := Pos + VS + else if (Pos > VS/2) then + Pos := Pos - VS; + + if (Abs(Pos) < 2.5) then {fixed Positions} + begin + Angle := Pi * (Pos / 5); +// 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].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + + Button[B].Z := 0.95 - Abs(Pos) * 0.01; + + Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); + + Button[B].W := Button[B].H; + + Diff := (Button[B].H - Theme.Song.Cover.H)/2; + + + X := Sin(Angle*1.3)*0.9; + + Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * X - Diff; + + end + else + begin {Behind the Front Covers} + + // limit-bg-covers hack + if (abs(abs(Pos)-VS/2)>10) then Button[B].Visible:=False; + // end of limit-bg-covers hack + + if Pos < 0 then + Pos := (Pos - VS/2)/VS + else + Pos := (Pos + VS/2)/VS; + + Angle := pi * Pos*2; + if VS > 24 then + begin + if Angle < 0 then helper:=-1 else helper:=1; + Angle:=2*pi-abs(Angle); + Angle:=Angle*(VS/24); + Angle:=(2*pi-Angle)*helper; + end; + + Button[B].Z := (0.4 - Abs(Pos/4)) -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers + + Button[B].H :=0.6*(Theme.Song.Cover.H-Abs(Theme.Song.Cover.H * cos(Angle/2)*0.8));//Power(Z2, 3); + + Button[B].W := Button[B].H; + + 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].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + + Diff := (Button[B].H - Theme.Song.Cover.H)/2; + + Button[B].X := Theme.Song.Cover.X+Theme.Song.Cover.H/2-Button[b].H/2+Theme.Song.Cover.W/320*((Theme.Song.Cover.H)*sin(Angle/2)*1.52); + + 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); + + end; + end; +end; + +procedure TScreenSong.SetScroll6; // rotate (slotmachine style) +var + B: integer; + Angle: real; + Pos: Real; + VS: integer; + diff: real; + X: Real; + Wsp: real; + Z, Z2: real; +begin + VS := CatSongs.VisibleSongs; // cache Visible Songs + if VS <=5 then begin + // kolowe + 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 + + 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; + + + Button[B].Y := Theme.Song.Cover.Y + (0.185 * Theme.Song.Cover.H * VS * sin(Wsp)) * Z2 - ((Button[B].H - Theme.Song.Cover.H)/2); // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs + Button[B].Z := Z / 2 + 0.3; + + Button[B].W := Theme.Song.Cover.H * 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; + end; + end + else begin + + //Change Pos of all Buttons + for B := low(Button) to high(Button) do + begin + Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visibility + if Button[B].Visible then //Only Change Pos for Visible Buttons + begin + Pos := (CatSongs.VisibleIndex(B) - SongCurrent); + if (Pos < -VS/2) then + Pos := Pos + VS + else if (Pos > VS/2) then + Pos := Pos - VS; + + if (Abs(Pos) < 2.5) then {fixed Positions} + begin + Angle := Pi * (Pos / 5); +// Button[B].Visible := False; + + Button[B].H := Abs(Theme.Song.Cover.H * cos(Angle*0.8));//Power(Z2, 3); + + Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + + Button[B].Z := 0.95 - Abs(Pos) * 0.01; + + Button[B].X := (Theme.Song.Cover.X + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); + + Button[B].W := Button[B].H; + + Diff := (Button[B].H - Theme.Song.Cover.H)/2; + + + X := Sin(Angle*1.3)*0.9; + + Button[B].Y := Theme.Song.Cover.Y + Theme.Song.Cover.W * X - Diff; + end + else + begin {Behind the Front Covers} + + // limit-bg-covers hack + if (abs(VS/2-abs(Pos))>10) then Button[B].Visible:=False; + if VS > 25 then VS:=25; + // end of limit-bg-covers hack + + if Pos < 0 then + Pos := (Pos - VS/2)/VS + else + Pos := (Pos + VS/2)/VS; + + 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 + + Button[B].H :=0.6*(Theme.Song.Cover.H-Abs(Theme.Song.Cover.H * cos(Angle/2)*0.8));//Power(Z2, 3); + + Button[B].W := Button[B].H; + + Button[B].X := Theme.Song.Cover.X - (Button[B].H - Theme.Song.Cover.H)*0.5; + + + Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + + Button[B].Y := Theme.Song.Cover.Y+Theme.Song.Cover.H/2-Button[b].H/2+Theme.Song.Cover.W/320*(Theme.Song.Cover.H*sin(Angle/2)*1.52); + end; + end; + end; + end; +end; + + +procedure TScreenSong.onShow; +begin + Music.Stop; + + if Ini.Players <= 3 then PlayersPlay := Ini.Players + 1; + 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 Length(CatSongs.Song) > 0 then begin + //Load Music only when Song Preview is activated + if (Ini.PreviewVolume <> 0) then + begin + Music.SetLoop(false); + Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); + Music.MoveTo(Music.Length / 4); + Music.Play; + + //Set Preview Volume + Music.SetMusicVolume (Ini.PreviewVolume * 10); + {//if Music Fade is activated, Set Volume to 0 % + if (Ini.PreviewFading <> 0) then + Music.SetMusicVolume(0);} + end; + + SetScroll; + UpdateLCD; + end; + + //Playlist Mode + if (Mode = 0) then + begin + //If Playlist Shown -> Select Next automatically + if (CatSongs.CatNumShow = -3) then + begin + SelectNext; + ChangeMusic; + end; + end + //Party Mode + else if (Mode = 1) then + begin + + SelectRandomSong; + //Show Menu directly in PartyMode + //But only if selected in Options + if (Ini.PartyPopup = 1) then + begin + ScreenSongMenu.MenuShow(SM_Party_Main); + end; + + + end; + + SetJoker; + SetStatics; +end; + +procedure TScreenSong.onHide; +begin + //When Music Fading is activated, Turn Music to 100 % + If (Ini.PreviewVolume <> 100) or (Ini.PreviewFading <> 0) then + Music.SetMusicVolume(100); + + //If Preview is deactivated: Load MUsicfile now + If (Ini.PreviewVolume = 0) then + Music.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 (Music <> nil) then + Music.Stop; +end; + +procedure TScreenSong.DrawExtensions; +begin + //Draw Song Menu + if (ScreenSongMenu.Visible) then + begin + ScreenSongMenu.Draw; + end + else if (ScreenSongJumpto.Visible) then + begin + ScreenSongJumpto.Draw; + end +end; + +function TScreenSong.Draw: boolean; +var + dx: real; + dt: real; + I: Integer; +begin + dx := SongTarget-SongCurrent; + dt := TimeSkip*7; + if dt > 1 then dt := 1; + SongCurrent := SongCurrent + dx*dt; + +{ if SongCurrent > Catsongs.VisibleSongs then begin + SongCurrent := SongCurrent - Catsongs.VisibleSongs; + SongTarget := SongTarget - Catsongs.VisibleSongs; + end;} + +// Log.BenchmarkStart(5); + SetScroll; +// Log.BenchmarkEnd(5); +// Log.LogBenchmark('SetScroll4', 5); + + //Fading Functions, Only if Covertime is under 5 Seconds + If (CoverTime < 5) then + begin + // 0.5.0: cover fade + if (CoverTime < 1) and (CoverTime + TimeSkip >= 1) then begin + // load new texture + Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); + Button[Interaction].Texture.Alpha := 1; + Button[Interaction].Texture2 := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); + Button[Interaction].Texture2.Alpha := 1; + end; + + //Song Fade + 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 + Music.Play; + + //Update Song Volume + if (CoverTime < Ini.PreviewFading) then + Music.SetMusicVolume(Round (CoverTime * Ini.PreviewVolume / Ini.PreviewFading * 10)) + else + Music.SetMusicVolume(Ini.PreviewVolume * 10); + + end; + + + //Update Fading Time + CoverTime := CoverTime + TimeSkip; + + //Update Fading Texture + Button[Interaction].Texture2.Alpha := (CoverTime - 1) * 1.5; + if Button[Interaction].Texture2.Alpha > 1 then Button[Interaction].Texture2.Alpha := 1; + + end; + + //inherited Draw; + //heres a little Hack, that causes the Statics + //are Drawn after the Buttons because of some Blending Problems. + //This should cause no Problems because all Buttons on this screen + //Has Z Position. + //Draw BG + DrawBG; + + //Instead of Draw FG Procedure: + //We draw Buttons for our own + for I := 0 to Length(Button) - 1 do + Button[I].Draw; + + // Statics + for I := 0 to Length(Static) - 1 do + Static[I].Draw; + + // and texts + for I := 0 to Length(Text) - 1 do + Text[I].Draw; + + + //Draw Equalizer + if Theme.Song.Equalizer.Visible then + DrawEqualizer; + + DrawExtensions; + +end; + +procedure TScreenSong.SelectNext; +var + Skip: integer; + I: integer; + VS: Integer; +begin + VS := CatSongs.VisibleSongs; + + if VS > 0 then + begin + UnLoadDetailedCover; + + Skip := 1; + + // this 1 could be changed by CatSongs.FindNextVisible + while (not CatSongs.Song[(Interaction + Skip) mod Length(Interactions)].Visible) do Inc(Skip); + + SongTarget := SongTarget + 1;//Skip; + + Interaction := (Interaction + Skip) mod Length(Interactions); + + // try to keep all at the beginning + if SongTarget > VS-1 then begin + SongTarget := SongTarget - VS; + SongCurrent := SongCurrent - VS; + end; + + end; + // Interaction -> Button, ktorego okladke przeczytamy + // Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture +end; + +procedure TScreenSong.SelectPrev; +var + Skip: integer; + I: integer; + VS: Integer; +begin + VS := CatSongs.VisibleSongs; + + if VS > 0 then + begin + UnLoadDetailedCover; + + Skip := 1; + + 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); + + // try to keep all at the beginning + if SongTarget < 0 then begin + SongTarget := SongTarget + CatSongs.VisibleSongs; + SongCurrent := SongCurrent + CatSongs.VisibleSongs; + end; + + // Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture + end; +end; + +procedure TScreenSong.UpdateLCD; +begin + LCD.HideCursor; + LCD.Clear; + LCD.WriteText(1, Text[TextArtist].Text); + LCD.WriteText(2, Text[TextTitle].Text); +end; + +//Procedure Change current played Preview +procedure TScreenSong.ChangeMusic; +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 + begin + Music.Close; + if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin + Music.MoveTo(Music.Length / 4); + //If Song Fading is activated then don't Play directly, and Set Volume to Null, else Play normal + if (Ini.PreviewFading = 0) then + Music.Play + else + Music.SetMusicVolume(0); + end; + end + else + Music.Stop; + end; +end; + +procedure TScreenSong.SkipTo(Target: Cardinal); // 0.5.0 +var + Skip: integer; + I: integer; +begin + UnLoadDetailedCover; + + Interaction := High(CatSongs.Song); + SongTarget := 0; + + for I := 1 to Target+1 do + SelectNext; + + FixSelected2; +end; + +procedure TScreenSong.DrawEqualizer; +var + Data: TFFTData; //Audio Data + I, J: Integer; + Res: byte; + A, B: Integer; + PosX, PosY: Integer; + Pos: Real; +begin +if (not Music.Finished) AND (Theme.Song.Equalizer.Length > 0) then +begin + + + A := GetTickCount div 44; + + if (A <> EqualizerTime) then + begin + EqualizerTime := A; + Data := Music.GetFFTData; + + B:=0; + Pos := 0; + Res := ceil(92/Theme.Song.Equalizer.Bands);//How much channels are used for one Band + + //Change Lengths + for I := 0 to (Res * Theme.Song.Equalizer.Bands - 1) do + begin + A := floor(I/Res); + + if (A<>B) then //Band changed + begin + if (Pos <= Theme.Song.Equalizer.Length) then + begin + if ((Pos < EqualizerBands[B]) AND (EqualizerBands[B]>1)) then + EqualizerBands[B] := EqualizerBands[B] - 1 + else + EqualizerBands[B] := floor(Pos); + end + else + EqualizerBands[B] := 1; + + B := A; + Pos := 0; + end; + + if I > 35 then + Data[i] := Data[i] * 8 + else if I > 11 then + Data[i] := Data[i] * 4.5 + else + Data[i] := Data[i] * 1.1; + + if (Data[i] >= 1) then + Data[i] := 0.9999999999999; + + if Data[i]*Theme.Song.Equalizer.Length > Pos then + Pos := Data[i]*Theme.Song.Equalizer.Length; + end; + + //Change Last Band + if (EqualizerBands[B] <= Theme.Song.Equalizer.Length) then + begin + if ((Pos < EqualizerBands[B]) AND (EqualizerBands[B]>1)) then + EqualizerBands[B] := EqualizerBands[B] - 1 + else + EqualizerBands[B] := floor(Pos) + end + else + EqualizerBands[B] := 1; + end; + + //Draw every Channel + glColor4f(Theme.Song.Equalizer.ColR, Theme.Song.Equalizer.ColG, Theme.Song.Equalizer.ColB, Theme.Song.Equalizer.Alpha); //Set Color + glDisable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + + PosY := Theme.Song.Equalizer.Y; + PosX := Theme.Song.Equalizer.X; + + For I := 0 to Theme.Song.Equalizer.Bands-1 do + begin + if Theme.Song.Equalizer.Direction then + PosY := Theme.Song.Equalizer.Y //+ (Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space) * Theme.Song.Equalizer.Length + else + PosX := Theme.Song.Equalizer.X; + //Draw for every visible quad + for J := 1 to EqualizerBands[I] do + begin + glBegin(GL_QUADS); + glVertex3f(PosX, PosY, Theme.Song.Equalizer.Z); + glVertex3f(PosX, PosY+Theme.Song.Equalizer.H, Theme.Song.Equalizer.Z); + glVertex3f(PosX+Theme.Song.Equalizer.W, PosY+Theme.Song.Equalizer.H, Theme.Song.Equalizer.Z); + glVertex3f(PosX+Theme.Song.Equalizer.W, PosY, Theme.Song.Equalizer.Z); + glEnd; + + if Theme.Song.Equalizer.Direction then //Vertically + PosY := PosY - Theme.Song.Equalizer.H - Theme.Song.Equalizer.Space + else //Horizontally + PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space; + end; + if Theme.Song.Equalizer.Direction then //Horizontally + PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space + else //Vertically + PosY := PosY + Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space; + end; +end; +end; + +Procedure TScreenSong.SelectRandomSong; +var + I, I2: Integer; +begin + Case PlaylistMan.Mode of + 0: //All Songs Just Select Random Song + begin + //When Tabs are activated then use Tab Method + if (Ini.Tabs_at_startup = 1) then + begin + 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 + begin + if CatSongs.Song[I].Main then + break; + 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 + + //Choose Cat + CatSongs.ShowCategoryList; + + //Show Cat in Top Left Mod + ShowCatTL (I); + + CatSongs.ClickCategoryButton(I); + SelectNext; + + //Choose Song + SkipTo(I2-I); + end + //When Tabs are deactivated use easy Method + else + SkipTo(Random(CatSongs.VisibleSongs)); + end; + 1: //One Category Select Category and Select Random Song + begin + CatSongs.ShowCategoryList; + CatSongs.ClickCategoryButton(PlaylistMan.CurPlayList); + ShowCatTL(PlaylistMan.CurPlayList); + + SelectNext; + FixSelected2; + + SkipTo(Random(CatSongs.VisibleSongs)); + end; + 2: //Playlist: Select Playlist and Select Random Song + begin + PlaylistMan.SetPlayList(PlaylistMan.CurPlayList); + + SkipTo(Random(CatSongs.VisibleSongs)); + FixSelected2; + end; + end; + + Music.PlayChange; + ChangeMusic; + SetScroll; + UpdateLCD; +end; + +procedure TScreenSong.SetJoker; +begin + //If Party Mode + if Mode = 1 then //Show Joker that are available + begin + if (PartySession.Teams.NumTeams >= 1) then + begin + Static[StaticTeam1Joker1].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 1); + Static[StaticTeam1Joker2].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 2); + Static[StaticTeam1Joker3].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 3); + Static[StaticTeam1Joker4].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 4); + Static[StaticTeam1Joker5].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 5); + end + else + begin + Static[StaticTeam1Joker1].Visible := False; + Static[StaticTeam1Joker2].Visible := False; + Static[StaticTeam1Joker3].Visible := False; + Static[StaticTeam1Joker4].Visible := False; + Static[StaticTeam1Joker5].Visible := False; + end; + + if (PartySession.Teams.NumTeams >= 2) then + begin + Static[StaticTeam2Joker1].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 1); + Static[StaticTeam2Joker2].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 2); + Static[StaticTeam2Joker3].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 3); + Static[StaticTeam2Joker4].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 4); + Static[StaticTeam2Joker5].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 5); + end + else + begin + Static[StaticTeam2Joker1].Visible := False; + Static[StaticTeam2Joker2].Visible := False; + Static[StaticTeam2Joker3].Visible := False; + Static[StaticTeam2Joker4].Visible := False; + Static[StaticTeam2Joker5].Visible := False; + end; + + if (PartySession.Teams.NumTeams >= 3) then + begin + Static[StaticTeam3Joker1].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 1); + Static[StaticTeam3Joker2].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 2); + Static[StaticTeam3Joker3].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 3); + Static[StaticTeam3Joker4].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 4); + Static[StaticTeam3Joker5].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 5); + end + else + begin + Static[StaticTeam3Joker1].Visible := False; + Static[StaticTeam3Joker2].Visible := False; + Static[StaticTeam3Joker3].Visible := False; + Static[StaticTeam3Joker4].Visible := False; + Static[StaticTeam3Joker5].Visible := False; + end; + end + else + begin //Hide all + Static[StaticTeam1Joker1].Visible := False; + Static[StaticTeam1Joker2].Visible := False; + Static[StaticTeam1Joker3].Visible := False; + Static[StaticTeam1Joker4].Visible := False; + Static[StaticTeam1Joker5].Visible := False; + + Static[StaticTeam2Joker1].Visible := False; + Static[StaticTeam2Joker2].Visible := False; + Static[StaticTeam2Joker3].Visible := False; + Static[StaticTeam2Joker4].Visible := False; + Static[StaticTeam2Joker5].Visible := False; + + Static[StaticTeam3Joker1].Visible := False; + Static[StaticTeam3Joker2].Visible := False; + Static[StaticTeam3Joker3].Visible := False; + Static[StaticTeam3Joker4].Visible := False; + Static[StaticTeam3Joker5].Visible := False; + end; +end; + +procedure TScreenSong.SetStatics; +var + I: Integer; + Visible: Boolean; +begin + //Set Visibility of Party Statics and Text + Visible := (Mode = 1); + + For I := 0 to high(StaticParty) do + Static[StaticParty[I]].Visible := Visible; + + 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 + Static[StaticNonParty[I]].Visible := Visible; + + For I := 0 to high(TextNonParty) do + Text[TextNonParty[I]].Visible := Visible; +end; + +//Procedures for Menu + +procedure TScreenSong.StartSong; +begin + CatSongs.Selected := Interaction; + Music.Stop; + //Party Mode + if (Mode = 1) then + begin + FadeTo(@ScreenSingModi); + end + else + begin + FadeTo(@ScreenSing); + end; +end; + +procedure TScreenSong.SelectPlayers; +begin + CatSongs.Selected := Interaction; + Music.Stop; + + ScreenName.Goto_SingScreen := True; + FadeTo(@ScreenName); +end; + +procedure TScreenSong.OpenEditor; +begin + if (Length(Songs.Song) > 0) and (not CatSongs.Song[Interaction].Main) AND (Mode = 0) then begin + Music.Stop; + Music.PlayStart; + ScreenEditSub.Path := CatSongs.Song[Interaction].Path; + ScreenEditSub.FileName := CatSongs.Song[Interaction].FileName; + FadeTo(@ScreenEditSub); + end; +end; + +//Team No of Team (0-5) +procedure TScreenSong.DoJoker (Team: Byte); +begin + if (Mode = 1) AND (PartySession.Teams.NumTeams >= Team + 1) AND (PartySession.Teams.Teaminfo[Team].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[Team].Joker); + SelectRandomSong; + SetJoker; + 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, 'Plain', true); // 0.5.0: show cached texture + Button[Interaction].Texture2.Alpha := 0; + + if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then + Texture.UnloadTexture(Button[Interaction].Texture.Name, false); +end; + +procedure TScreenSong.Refresh; +begin { +CatSongs.Refresh; +CatSongs.ShowCategoryList; +Interaction := 0; +SelectNext; +FixSelected; } + +end; + +end. -- cgit v1.2.3 From 95662b4cb8252ae665de8222762f9fc320f11ea0 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Sat, 29 Sep 2007 01:47:49 +0000 Subject: small fixes for lazarus build. cleanup on some code. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@445 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 4081 +++++++++++++++++++------------------ 1 file changed, 2041 insertions(+), 2040 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 569645d4..0a3c1d02 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1,2040 +1,2041 @@ -unit UScreenSong; - -interface -{$I switches.inc} - -uses - UMenu, - SDL, - UMusic, - UFiles, - UTime, - UDisplay, - USongs, - SysUtils, - ULog, - UThemes, - UTexture, - ULanguage, - ULCD, - ULight, - UIni; - -type - TScreenSong = class(TMenu) - public - TextArtist: integer; - TextTitle: integer; - TextNumber: integer; - - //Video Icon Mod - VideoIcon: Cardinal; - - TextCat: integer; - StaticCat: integer; - - SongCurrent: real; - SongTarget: real; - - HighSpeed: boolean; - CoverFull: boolean; - CoverTime: real; - CoverX: integer; - CoverY: integer; - CoverW: integer; - is_jump: boolean; // Jump to Song Mod - is_jump_title:boolean; //Jump to SOng MOd-YTrue if search for Title - - EqualizerBands: array of Byte; - EqualizerTime: Cardinal; - EqualizerTime2: Byte; - - //Party Mod - Mode: Byte; //0 = Standard, 1= Go to PartyMode after Selection + Change to Random Song at Show - //party Statics (Joker) - StaticTeam1Joker1: Cardinal; - StaticTeam1Joker2: Cardinal; - StaticTeam1Joker3: Cardinal; - StaticTeam1Joker4: Cardinal; - StaticTeam1Joker5: Cardinal; - - StaticTeam2Joker1: Cardinal; - StaticTeam2Joker2: Cardinal; - StaticTeam2Joker3: Cardinal; - StaticTeam2Joker4: Cardinal; - StaticTeam2Joker5: Cardinal; - - StaticTeam3Joker1: Cardinal; - StaticTeam3Joker2: Cardinal; - StaticTeam3Joker3: Cardinal; - StaticTeam3Joker4: Cardinal; - StaticTeam3Joker5: Cardinal; - - StaticParty: Array of Cardinal; - TextParty: Array of Cardinal; - StaticNonParty: Array of Cardinal; - TextNonParty: Array of Cardinal; - - - constructor Create; override; - procedure SetScroll; - procedure SetScroll1; - procedure SetScroll2; - procedure SetScroll3; - procedure SetScroll4; - procedure SetScroll5; - procedure SetScroll6; - function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; - function Draw: boolean; override; - procedure onShow; override; - procedure onHide; override; - procedure SelectNext; - procedure SelectPrev; - procedure UpdateLCD; - procedure SkipTo(Target: Cardinal); - procedure FixSelected; //Show Wrong Song when Tabs on Fix - procedure FixSelected2; //Show Wrong Song when Tabs on Fix - procedure ShowCatTL(Cat: Integer);// Show Cat in Top left - procedure ShowCatTLCustom(Caption: String);// Show Custom Text in Top left - procedure HideCatTL;// Show Cat in Tob left - procedure Refresh; //Refresh Song Sorting - procedure DrawEqualizer; - procedure ChangeMusic; - //Party Mode - procedure SelectRandomSong; - procedure SetJoker; - procedure SetStatics; - //procedures for Menu - procedure StartSong; - procedure OpenEditor; - procedure DoJoker(Team: Byte); - procedure SelectPlayers; - - procedure UnLoadDetailedCover; - - //Extensions - procedure DrawExtensions; - end; - -implementation -uses UGraphic, - UMain, - UCovers, - math, - OpenGL12, - {$IFDEF win32} - windows, - {$ELSE} - lclintf, - {$ENDIF} - 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 - 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; - - SongCurrent := I2; - SongTarget := I2; - end; - end; - -procedure TScreenSong.FixSelected2; -var I, I2: Integer; - begin - if CatSongs.VisibleSongs > 0 then - 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; - - SongTarget := I2; - 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; - 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, 'Plain', true); - - Static[StaticCat].Texture := Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', true); - //Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', false); - //Button[Cat]. - //Cover - - - //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 - - -// Method for input parsing. If False is returned, GetNextWindow -// should be checked to know the next window to load; -function TScreenSong.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; -var - I: integer; - I2: integer; - HS: integer; - SDL_ModState: Word; - Letter: Char; -begin - Result := true; - - //Song Screen Extensions (Jumpto + Menu) - if (ScreenSongMenu.Visible) then - begin - Result := ScreenSongMenu.ParseInput(PressedKey, ScanCode, PressedDown); - Exit; - end - else if (ScreenSongJumpto.Visible) then - begin - Result := ScreenSongJumpto.ParseInput(PressedKey, ScanCode, PressedDown); - Exit; - end; - - 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 = 0) AND (PressedKey >= SDLK_A) AND (PressedKey <= SDLK_Z) then - begin - Letter := UpCase(Chr(ScanCode)); - I2 := Length(CatSongs.Song); - - //Jump To Titel - if (SDL_ModState = KMOD_LALT or KMOD_LSHIFT) then - begin - 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 (UpCase(CatSongs.Song[(I + Interaction) mod I2].Title[1]) = Letter) then - begin - SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); - - Music.PlayChange; - - ChangeMusic; - SetScroll4; - UpdateLCD; - //Break and Exit - Exit; - end; - end; - end - //Jump to Artist - else if (SDL_ModState = KMOD_LALT) then - begin - 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 (UpCase(CatSongs.Song[(I + Interaction) mod I2].Artist[1]) = Letter) then - begin - SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); - - Music.PlayChange; - - ChangeMusic; - SetScroll4; - UpdateLCD; - - //Break and Exit - Exit; - end; - end; - end; - Exit; - end; - - case PressedKey of - SDLK_Q: - begin - Result := false; - end; - - SDLK_ESCAPE, - SDLK_BACKSPACE : - begin - if (Mode = 0) 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 - 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 - Music.Stop; - - CatSongs.ShowCategoryList; - - //Show Cat in Top Left Mod - HideCatTL; - - - //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); - - //Show Cat in Top Left Mod - HideCatTL; - Interaction := 0; - - //Show Wrong Song when Tabs on Fix - SelectNext; - FixSelected; - - ChangeMusic; - end - else - begin - Music.Stop; - Music.PlayBack; - - FadeTo(@ScreenMain); - end; - - end; - end - //When in party Mode then Ask before Close - else if (Mode = 1) then - begin - Music.PlayBack; - CheckFadeTo(@ScreenMain,'MSG_END_PARTY'); - end; - end; - SDLK_RETURN: - begin - if Length(Songs.Song) > 0 then - begin - {$IFDEF UseSerialPort} - // PortWriteB($378, 0); - {$ENDIF} - if CatSongs.Song[Interaction].Main then - begin // clicked on Category Button - - //Show Cat in Top Left Mod - ShowCatTL (Interaction); - - //I := CatSongs.VisibleIndex(Interaction); - CatSongs.ClickCategoryButton(Interaction); - {I2 := CatSongs.VisibleIndex(Interaction); - SongCurrent := SongCurrent - I + I2; - SongTarget := SongTarget - I + I2; } - -// if I<>I2 then beep; - // SetScroll4; - - //Show Wrong Song when Tabs on Fix - SelectNext; - FixSelected; - - //Play Music: - ChangeMusic; - - end else begin // clicked on song - if (Mode = 0) then //Normal Mode -> Start Song - begin - //Do the Action that is specified in Ini - case Ini.OnSongClick of - 0: StartSong; - 1: SelectPlayers; - 2:begin - If (CatSongs.CatNumShow = -3) then - ScreenSongMenu.MenuShow(SM_Playlist) - else - ScreenSongMenu.MenuShow(SM_Main); - end; - end; - end - else if (Mode = 1) then //PartyMode -> Show Menu - begin - if (Ini.PartyPopup = 1) then - ScreenSongMenu.MenuShow(SM_Party_Main) - else - ScreenSong.StartSong; - end; - end; - end; - end; - - SDLK_M: //Show SongMenu - begin - if (Length(Songs.Song) > 0) then begin - if (Mode = 0) then begin - if not CatSongs.Song[Interaction].Main then begin // clicked on Song - if CatSongs.CatNumShow = -3 then - ScreenSongMenu.MenuShow(SM_Playlist) - else - ScreenSongMenu.MenuShow(SM_Main); - end - else - begin - ScreenSongMenu.MenuShow(SM_Playlist_Load); - end; - end //Party Mode -> Show Party Menu - else ScreenSongMenu.MenuShow(SM_Party_Main); - end; - end; - - SDLK_P: //Show Playlist Menu - begin - if (Length(Songs.Song) > 0) AND (Mode = 0) then begin - ScreenSongMenu.MenuShow(SM_Playlist_Load); - end; - end; - - SDLK_J: //Show Jumpto Menu - begin - if (Length(Songs.Song) > 0) AND (Mode = 0) then - begin - ScreenSongJumpto.Visible := True; - end; - end; - - SDLK_DOWN: - begin - if (Mode = 0) then - begin - //Only Change Cat when not in Playlist or Search Mode - if (CatSongs.CatNumShow > -2) then - begin - //Cat Change Hack - if Ini.Tabs_at_startup = 1 then - begin - I := Interaction; - if I <= 0 then I := 1; - - while not catsongs.Song[I].Main do - begin - Inc (I); - if (I > high(catsongs.Song)) then - I := low(catsongs.Song); - end; - - Interaction := I; - - //Show Cat in Top Left Mod - ShowCatTL (Interaction); - - CatSongs.ClickCategoryButton(Interaction); - SelectNext; - FixSelected; - - //Play Music: - Music.PlayChange; - ChangeMusic; - - end; - - // - //Cat Change Hack End} - end; - end; - end; - SDLK_UP: - begin - if (Mode = 0) then - begin - //Only Change Cat when not in Playlist or Search Mode - if (CatSongs.CatNumShow > -2) then - begin - //Cat Change Hack - if Ini.Tabs_at_startup = 1 then - begin - I := Interaction; - I2 := 0; - if I <= 0 then I := 1; - - 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; - - Interaction := I; - - //Show Cat in Top Left Mod - ShowCatTL (I); - - CatSongs.ClickCategoryButton(I); - SelectNext; - FixSelected; - - //Play Music: - Music.PlayChange; - ChangeMusic; - end; - end; - //Cat Change Hack End} - end; - end; - - SDLK_RIGHT: - begin - if (Length(Songs.Song) > 0) AND (Mode = 0) then begin - Music.PlayChange; - SelectNext; -// InteractNext; -// SongTarget := Interaction; - ChangeMusic; - SetScroll4; - UpdateLCD; - Light.LightOne(1, 200); - end; - end; - - SDLK_LEFT: - begin - if (Length(Songs.Song) > 0)AND (Mode = 0) then begin - Music.PlayChange; - SelectPrev; - ChangeMusic; - SetScroll4; - UpdateLCD; - Light.LightOne(0, 200); - end; - end; - - SDLK_E: - begin - OpenEditor; - end; - - SDLK_R: - begin - if (Length(Songs.Song) > 0) AND (Mode = 0) 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 := 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 - begin - //Show Cat in Top Left Mod - ShowCatTL (I); - - Interaction := I; - - 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 - begin - 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 - begin - if CatSongs.Song[I].Main then - break; - end; - //In I ist jetzt die Kategorie in I2 der Song - - //Choose Cat - CatSongs.ShowCategoryList; - - //Show Cat in Top Left Mod - ShowCatTL (I); - - CatSongs.ClickCategoryButton(I); - SelectNext; - - //Fix: Not Existing Song selected: - //if (I+1=I2) then Inc(I2); - - //Choose Song - SkipTo(I2-I); - - end - else //Random in one Category - begin - SkipTo(Random(CatSongs.VisibleSongs)); - end; - Music.PlayChange; - - ChangeMusic; - SetScroll4; - UpdateLCD; - end; - end; - - SDLK_1: - begin //Jocker - if (Mode = 1) AND (PartySession.Teams.NumTeams >= 1) AND (PartySession.Teams.Teaminfo[0].Joker > 0) then - begin - //Joker spielen - Dec(PartySession.Teams.Teaminfo[0].Joker); - SelectRandomSong; - SetJoker; - end; - end; - - SDLK_2: - begin //Jocker - if (Mode = 1) AND (PartySession.Teams.NumTeams >= 2) AND (PartySession.Teams.Teaminfo[1].Joker > 0) then - begin - //Joker spielen - Dec(PartySession.Teams.Teaminfo[1].Joker); - SelectRandomSong; - SetJoker; - end; - end; - - SDLK_3: - begin //Jocker - if (Mode = 1) AND (PartySession.Teams.NumTeams >= 3) AND (PartySession.Teams.Teaminfo[2].Joker > 0) then - begin - //Joker spielen - Dec(PartySession.Teams.Teaminfo[2].Joker); - SelectRandomSong; - SetJoker; - end; - end; - end; - end; -end; - -constructor TScreenSong.Create; -var - Pet: integer; - I: integer; -Label CreateSongButtons; -begin - inherited Create; - - LoadFromTheme(Theme.Song); - - TextArtist := AddText(Theme.Song.TextArtist); - TextTitle := AddText(Theme.Song.TextTitle); - TextNumber := AddText(Theme.Song.TextNumber); - - //Show Cat in Top Left mod - TextCat := AddText(Theme.Song.TextCat); - StaticCat := AddStatic(Theme.Song.StaticCat); - - //Show Video Icon Mod - VideoIcon := AddStatic(Theme.Song.VideoIcon); - - //Party Mode - StaticTeam1Joker1 := AddStatic(Theme.Song.StaticTeam1Joker1); - StaticTeam1Joker2 := AddStatic(Theme.Song.StaticTeam1Joker2); - StaticTeam1Joker3 := AddStatic(Theme.Song.StaticTeam1Joker3); - StaticTeam1Joker4 := AddStatic(Theme.Song.StaticTeam1Joker4); - StaticTeam1Joker5 := AddStatic(Theme.Song.StaticTeam1Joker5); - - StaticTeam2Joker1 := AddStatic(Theme.Song.StaticTeam2Joker1); - StaticTeam2Joker2 := AddStatic(Theme.Song.StaticTeam2Joker2); - StaticTeam2Joker3 := AddStatic(Theme.Song.StaticTeam2Joker3); - StaticTeam2Joker4 := AddStatic(Theme.Song.StaticTeam2Joker4); - StaticTeam2Joker5 := AddStatic(Theme.Song.StaticTeam2Joker5); - - StaticTeam3Joker1 := AddStatic(Theme.Song.StaticTeam3Joker1); - StaticTeam3Joker2 := AddStatic(Theme.Song.StaticTeam3Joker2); - StaticTeam3Joker3 := AddStatic(Theme.Song.StaticTeam3Joker3); - StaticTeam3Joker4 := AddStatic(Theme.Song.StaticTeam3Joker4); - StaticTeam3Joker5 := AddStatic(Theme.Song.StaticTeam3Joker5); - - //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]); - - SetLength(TextParty, Length(Theme.Song.TextParty)); - 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]); - - SetLength(TextNonParty, Length(Theme.Song.TextNonParty)); - 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 - CatSongs.Refresh; - - 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)); - - I := 0; - CreateSongButtons: - - try - for Pet := I to High(CatSongs.Song) do begin // creating all buttons - // 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 - CatSongs.Song[Pet].Cover := ''; // 0.5.0: if cover not found then show 'no cover' - - if CatSongs.Song[Pet].Cover = '' then - AddButton(300 + Pet*250, 140, 200, 200, Skin.GetTextureFileName('SongCover'), 'JPG', '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 begin - Texture.CreateCacheMipmap := true; - Texture.GetTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, '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); - - // unload full size texture - Texture.UnloadTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, 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, 'JPG', 'Plain', Theme.Song.Cover.Reflections); - end; - Texture.Limit := 1024*1024; - I := -1; - end; - except - //When Error is reported the First time for this Song - if (I <> Pet) then - begin - //Some Error reporting: - Log.LogError('Could not load Cover: ' + CatSongs.Song[Pet].Cover); - - //Change Cover to NoCover and Continue Loading - CatSongs.Song[Pet].Cover := ''; - I := Pet; - end - else //when Error occurs Multiple Times(NoSong Cover is damaged), then start loading next Song - begin - Log.LogError('NoCover Cover is damaged!'); - try - AddButton(300 + Pet*250, 140, 200, 200, '', 'JPG', 'Plain', Theme.Song.Cover.Reflections); - except - {$IFDEF win32} - Messagebox(0, PChar('No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'), PChar(Language.Translate('US_VERSION')), MB_ICONERROR or MB_OK); - {$ELSE} - // TODO : JB_linux - better handle this message and display to user.. - writeln( 'No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'); - Log.LogError( 'No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.' ); - {$ENDIF} - Halt; - end; - I := Pet + 1; - end; - end; - - if (I <> -1) then - GoTo CreateSongButtons; - - end; - - // Randomize Patch - Randomize; - //Equalizer - SetLength(EqualizerBands, Theme.Song.Equalizer.Bands); - //ClearArray - For I := low(EqualizerBands) to high(EqualizerBands) do - EqualizerBands[I] := 3; - - if (Length(CatSongs.Song) > 0) then - Interaction := 0; -end; - -procedure TScreenSong.SetScroll; -var - VS, B: Integer; -begin - VS := CatSongs.VisibleSongs; - if VS > 0 then - begin - //Set Positions - Case Theme.Song.Cover.Style of - 3: SetScroll3; - 5:begin - if VS > 5 then - SetScroll5 - else - SetScroll4; - end; - 6: SetScroll6; - else SetScroll4; - end; - //Set Visibility of Video Icon - Static[VideoIcon].Visible := (CatSongs.Song[Interaction].Video <> ''); - - //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 - 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') + ')'; - end - else if (CatSongs.CatNumShow = -2) then - Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) - else if (CatSongs.CatNumShow = -3) then - Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) - 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)); - 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; - - end; -end; - -procedure TScreenSong.SetScroll1; -var - B: integer; // button - BMin: integer; // button min - BMax: integer; // button max - Src: integer; -// Dst: integer; - Count: integer; // Dst is not used. Count is used. - Ready: boolean; - - VisCount: integer; // count of visible (or selectable) buttons - VisInt: integer; // visible position of interacted button - Typ: integer; // 0 when all songs fits the screen - Placed: integer; // number of placed visible buttons -begin -// Src := 0; -// Dst := -1; - Count := 1; - Typ := 0; - Ready := false; - Placed := 0; - - VisCount := 0; - 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); - - - if VisCount <= 6 then begin - Typ := 0; - end else begin - if VisInt <= 3 then begin - Typ := 1; - Count := 7; - Ready := true; - end; - - if (VisCount - VisInt) <= 3 then begin - Typ := 2; - Count := 7; - Ready := true; - end; - - if not Ready then begin - Typ := 3; - Src := Interaction; - end; - end; - - - - // hide all buttons - for B := 0 to High(Button) do begin - Button[B].Visible := false; - Button[B].Selectable := CatSongs.Song[B].Visible; - end; - -{ 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;} - - - if Typ = 0 then begin - for B := 0 to High(Button) do begin - if CatSongs.Song[B].Visible then begin - Button[B].Visible := true; - Button[B].Y := 140 + (Placed) * 60; - Inc(Placed); - end; - end; - end; - - if Typ = 1 then begin - B := 0; - while (Count > 0) do begin - if CatSongs.Song[B].Visible then begin - Button[B].Visible := true; - Button[B].Y := 140 + (Placed) * 60; - Inc(Placed); - Dec(Count); - end; - Inc(B); - end; - end; - - if Typ = 2 then begin - B := High(Button); - while (Count > 0) do begin - if CatSongs.Song[B].Visible then begin - Button[B].Visible := true; - Button[B].Y := 140 + (6-Placed) * 60; - Inc(Placed); - Dec(Count); - end; - Dec(B); - end; - end; - - if Typ = 3 then begin - B := Src; - Count := 4; - while (Count > 0) do begin - if CatSongs.Song[B].Visible then begin - Button[B].Visible := true; - Button[B].Y := 140 + (3+Placed) * 60; - Inc(Placed); - Dec(Count); - end; - Inc(B); - end; - - B := Src-1; - Placed := 0; - Count := 3; - while (Count > 0) do begin - if CatSongs.Song[B].Visible then begin - Button[B].Visible := true; - Button[B].Y := 140 + (2-Placed) * 60; - Inc(Placed); - Dec(Count); - end; - Dec(B); - end; - - end; - - if Length(Button) > 0 then - Static[1].Texture.Y := Button[Interaction].Y - 5; // selection texture -end; - -procedure TScreenSong.SetScroll2; -var - B: integer; - Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu - Wsp2: real; -begin - // liniowe - for B := 0 to High(Button) do - Button[B].X := 300 + (B - Interaction) * 260; - - 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; - - // kolowe -{ 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;} -end; - -procedure TScreenSong.SetScroll3; // with slide -var - B: integer; - Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu - Wsp2: real; -begin - SongTarget := Interaction; - - // liniowe - for B := 0 to High(Button) do - begin - Button[B].X := 300 + (B - SongCurrent) * 260; - if (Button[B].X < -Button[B].W) OR (Button[B].X > 800) then - Button[B].Visible := False - else - Button[B].Visible := True; - end; - -{ 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;} - - // kolowe -{ 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;} -end; - -procedure TScreenSong.SetScroll4; // rotate -var - B: integer; - Wsp: real; - Z, Z2: real; - VS: integer; -begin - VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important - - // kolowe - 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 - - 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; - - - Button[B].X := Theme.Song.Cover.X + (0.185 * Theme.Song.Cover.H * VS * sin(Wsp)) * Z2 - ((Button[B].H - Theme.Song.Cover.H)/2); // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs - Button[B].Z := Z / 2 + 0.3; - - 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].H := Button[B].W; - end; - end; -end; - -(* -procedure TScreenSong.SetScroll4; // rotate -var - B: integer; - Wsp: real; - Z: real; - Z2, Z3: real; - VS: integer; - function modreal (const X, Y: real):real; - begin - Result := Frac(x / y) * y; - if Result < -3 then - Result := Result + Y - else if Result > 3 then - Result := Result - Y; - end; -begin - VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important - Z3 := 1; - if VS < 12 then - Z2 := VS - else - Z2 := 12; - - // kolowe - 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 - begin - if CatSongs.VisibleIndex(B)> SongCurrent then - Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / Z2 - else - Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / Z2; - - Z3 := 2; - Z := (1 + cos(Wsp)) / 2; - //Z2 := (1 + 2*Z) / 3; - //Z2 := (0.5 + Z/2); - //Z2 := sin(Wsp); - - //Z2 := Power (Z2,Z3); - - Button[B].W := Theme.Song.CoverW * Power(cos(Wsp), Z3);//Power(Z2, 3); - - //Button[B].X := Theme.Song.CoverX + ({Theme.Song.CoverX + Theme.Song.CoverW/2 + Theme.Song.CoverW*0.18 * VS {CatSongs.VisibleSongs {Length(Button) * sin(Wsp) {- Theme.Song.CoverX - Theme.Song.CoverW) * Z2; // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs - if (sin(Wsp)<0) then - Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX + Theme.Song.CoverW - Button[B].W - else //*Theme.Song.CoverW*0.004*Z3 - 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 := (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 - begin - Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / 12 ;// 0.5.0 (II): takes another 16ms - - Z := (1 + cos(Wsp)) / 2 -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers - - Button[B].W := Theme.Song.CoverW * Power(cos(Wsp), Z3);//Power(Z2, 3); - - if (sin(Wsp)<0) then - Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX + Theme.Song.CoverW - Button[B].W - else - Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX; - - Button[B].Z := Z; - - Button[B].Y := (Theme.Song.CoverY + Theme.Song.CoverW - Button[B].W); - - Button[B].H := Button[B].W; - Button[B].Visible := True; - end - else Button[B].Visible := False; - end; - end; -end; *) - -procedure TScreenSong.SetScroll5; // rotate -var - B: integer; - Angle: real; - Pos: Real; - VS: integer; - diff: real; - X: Real; - helper: real; -begin - VS := CatSongs.VisibleSongs; // cache Visible Songs - {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 - Theme.Song.CoverH: Höhe der Cover - - (CatSongs.VisibleIndex(B) - SongCurrent)/VS = Abstand zum MIttleren Cover in % - } - - //Change Pos of all Buttons - for B := low(Button) to high(Button) do - begin - Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visibility - if Button[B].Visible then //Only Change Pos for Visible Buttons - begin - Pos := (CatSongs.VisibleIndex(B) - SongCurrent); - if (Pos < -VS/2) then - Pos := Pos + VS - else if (Pos > VS/2) then - Pos := Pos - VS; - - if (Abs(Pos) < 2.5) then {fixed Positions} - begin - Angle := Pi * (Pos / 5); -// 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].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; - - Button[B].Z := 0.95 - Abs(Pos) * 0.01; - - Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); - - Button[B].W := Button[B].H; - - Diff := (Button[B].H - Theme.Song.Cover.H)/2; - - - X := Sin(Angle*1.3)*0.9; - - Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * X - Diff; - - end - else - begin {Behind the Front Covers} - - // limit-bg-covers hack - if (abs(abs(Pos)-VS/2)>10) then Button[B].Visible:=False; - // end of limit-bg-covers hack - - if Pos < 0 then - Pos := (Pos - VS/2)/VS - else - Pos := (Pos + VS/2)/VS; - - Angle := pi * Pos*2; - if VS > 24 then - begin - if Angle < 0 then helper:=-1 else helper:=1; - Angle:=2*pi-abs(Angle); - Angle:=Angle*(VS/24); - Angle:=(2*pi-Angle)*helper; - end; - - Button[B].Z := (0.4 - Abs(Pos/4)) -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers - - Button[B].H :=0.6*(Theme.Song.Cover.H-Abs(Theme.Song.Cover.H * cos(Angle/2)*0.8));//Power(Z2, 3); - - Button[B].W := Button[B].H; - - 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].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; - - Diff := (Button[B].H - Theme.Song.Cover.H)/2; - - Button[B].X := Theme.Song.Cover.X+Theme.Song.Cover.H/2-Button[b].H/2+Theme.Song.Cover.W/320*((Theme.Song.Cover.H)*sin(Angle/2)*1.52); - - 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); - - end; - end; -end; - -procedure TScreenSong.SetScroll6; // rotate (slotmachine style) -var - B: integer; - Angle: real; - Pos: Real; - VS: integer; - diff: real; - X: Real; - Wsp: real; - Z, Z2: real; -begin - VS := CatSongs.VisibleSongs; // cache Visible Songs - if VS <=5 then begin - // kolowe - 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 - - 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; - - - Button[B].Y := Theme.Song.Cover.Y + (0.185 * Theme.Song.Cover.H * VS * sin(Wsp)) * Z2 - ((Button[B].H - Theme.Song.Cover.H)/2); // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs - Button[B].Z := Z / 2 + 0.3; - - Button[B].W := Theme.Song.Cover.H * 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; - end; - end - else begin - - //Change Pos of all Buttons - for B := low(Button) to high(Button) do - begin - Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visibility - if Button[B].Visible then //Only Change Pos for Visible Buttons - begin - Pos := (CatSongs.VisibleIndex(B) - SongCurrent); - if (Pos < -VS/2) then - Pos := Pos + VS - else if (Pos > VS/2) then - Pos := Pos - VS; - - if (Abs(Pos) < 2.5) then {fixed Positions} - begin - Angle := Pi * (Pos / 5); -// Button[B].Visible := False; - - Button[B].H := Abs(Theme.Song.Cover.H * cos(Angle*0.8));//Power(Z2, 3); - - Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; - - Button[B].Z := 0.95 - Abs(Pos) * 0.01; - - Button[B].X := (Theme.Song.Cover.X + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); - - Button[B].W := Button[B].H; - - Diff := (Button[B].H - Theme.Song.Cover.H)/2; - - - X := Sin(Angle*1.3)*0.9; - - Button[B].Y := Theme.Song.Cover.Y + Theme.Song.Cover.W * X - Diff; - end - else - begin {Behind the Front Covers} - - // limit-bg-covers hack - if (abs(VS/2-abs(Pos))>10) then Button[B].Visible:=False; - if VS > 25 then VS:=25; - // end of limit-bg-covers hack - - if Pos < 0 then - Pos := (Pos - VS/2)/VS - else - Pos := (Pos + VS/2)/VS; - - 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 - - Button[B].H :=0.6*(Theme.Song.Cover.H-Abs(Theme.Song.Cover.H * cos(Angle/2)*0.8));//Power(Z2, 3); - - Button[B].W := Button[B].H; - - Button[B].X := Theme.Song.Cover.X - (Button[B].H - Theme.Song.Cover.H)*0.5; - - - Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; - - Button[B].Y := Theme.Song.Cover.Y+Theme.Song.Cover.H/2-Button[b].H/2+Theme.Song.Cover.W/320*(Theme.Song.Cover.H*sin(Angle/2)*1.52); - end; - end; - end; - end; -end; - - -procedure TScreenSong.onShow; -begin - Music.Stop; - - if Ini.Players <= 3 then PlayersPlay := Ini.Players + 1; - 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 Length(CatSongs.Song) > 0 then begin - //Load Music only when Song Preview is activated - if (Ini.PreviewVolume <> 0) then - begin - Music.SetLoop(false); - Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); - Music.MoveTo(Music.Length / 4); - Music.Play; - - //Set Preview Volume - Music.SetMusicVolume (Ini.PreviewVolume * 10); - {//if Music Fade is activated, Set Volume to 0 % - if (Ini.PreviewFading <> 0) then - Music.SetMusicVolume(0);} - end; - - SetScroll; - UpdateLCD; - end; - - //Playlist Mode - if (Mode = 0) then - begin - //If Playlist Shown -> Select Next automatically - if (CatSongs.CatNumShow = -3) then - begin - SelectNext; - ChangeMusic; - end; - end - //Party Mode - else if (Mode = 1) then - begin - - SelectRandomSong; - //Show Menu directly in PartyMode - //But only if selected in Options - if (Ini.PartyPopup = 1) then - begin - ScreenSongMenu.MenuShow(SM_Party_Main); - end; - - - end; - - SetJoker; - SetStatics; -end; - -procedure TScreenSong.onHide; -begin - //When Music Fading is activated, Turn Music to 100 % - If (Ini.PreviewVolume <> 100) or (Ini.PreviewFading <> 0) then - Music.SetMusicVolume(100); - - //If Preview is deactivated: Load MUsicfile now - If (Ini.PreviewVolume = 0) then - Music.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 (Music <> nil) then - Music.Stop; -end; - -procedure TScreenSong.DrawExtensions; -begin - //Draw Song Menu - if (ScreenSongMenu.Visible) then - begin - ScreenSongMenu.Draw; - end - else if (ScreenSongJumpto.Visible) then - begin - ScreenSongJumpto.Draw; - end -end; - -function TScreenSong.Draw: boolean; -var - dx: real; - dt: real; - I: Integer; -begin - dx := SongTarget-SongCurrent; - dt := TimeSkip*7; - if dt > 1 then dt := 1; - SongCurrent := SongCurrent + dx*dt; - -{ if SongCurrent > Catsongs.VisibleSongs then begin - SongCurrent := SongCurrent - Catsongs.VisibleSongs; - SongTarget := SongTarget - Catsongs.VisibleSongs; - end;} - -// Log.BenchmarkStart(5); - SetScroll; -// Log.BenchmarkEnd(5); -// Log.LogBenchmark('SetScroll4', 5); - - //Fading Functions, Only if Covertime is under 5 Seconds - If (CoverTime < 5) then - begin - // 0.5.0: cover fade - if (CoverTime < 1) and (CoverTime + TimeSkip >= 1) then begin - // load new texture - Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); - Button[Interaction].Texture.Alpha := 1; - Button[Interaction].Texture2 := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); - Button[Interaction].Texture2.Alpha := 1; - end; - - //Song Fade - 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 - Music.Play; - - //Update Song Volume - if (CoverTime < Ini.PreviewFading) then - Music.SetMusicVolume(Round (CoverTime * Ini.PreviewVolume / Ini.PreviewFading * 10)) - else - Music.SetMusicVolume(Ini.PreviewVolume * 10); - - end; - - - //Update Fading Time - CoverTime := CoverTime + TimeSkip; - - //Update Fading Texture - Button[Interaction].Texture2.Alpha := (CoverTime - 1) * 1.5; - if Button[Interaction].Texture2.Alpha > 1 then Button[Interaction].Texture2.Alpha := 1; - - end; - - //inherited Draw; - //heres a little Hack, that causes the Statics - //are Drawn after the Buttons because of some Blending Problems. - //This should cause no Problems because all Buttons on this screen - //Has Z Position. - //Draw BG - DrawBG; - - //Instead of Draw FG Procedure: - //We draw Buttons for our own - for I := 0 to Length(Button) - 1 do - Button[I].Draw; - - // Statics - for I := 0 to Length(Static) - 1 do - Static[I].Draw; - - // and texts - for I := 0 to Length(Text) - 1 do - Text[I].Draw; - - - //Draw Equalizer - if Theme.Song.Equalizer.Visible then - DrawEqualizer; - - DrawExtensions; - -end; - -procedure TScreenSong.SelectNext; -var - Skip: integer; - I: integer; - VS: Integer; -begin - VS := CatSongs.VisibleSongs; - - if VS > 0 then - begin - UnLoadDetailedCover; - - Skip := 1; - - // this 1 could be changed by CatSongs.FindNextVisible - while (not CatSongs.Song[(Interaction + Skip) mod Length(Interactions)].Visible) do Inc(Skip); - - SongTarget := SongTarget + 1;//Skip; - - Interaction := (Interaction + Skip) mod Length(Interactions); - - // try to keep all at the beginning - if SongTarget > VS-1 then begin - SongTarget := SongTarget - VS; - SongCurrent := SongCurrent - VS; - end; - - end; - // Interaction -> Button, ktorego okladke przeczytamy - // Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture -end; - -procedure TScreenSong.SelectPrev; -var - Skip: integer; - I: integer; - VS: Integer; -begin - VS := CatSongs.VisibleSongs; - - if VS > 0 then - begin - UnLoadDetailedCover; - - Skip := 1; - - 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); - - // try to keep all at the beginning - if SongTarget < 0 then begin - SongTarget := SongTarget + CatSongs.VisibleSongs; - SongCurrent := SongCurrent + CatSongs.VisibleSongs; - end; - - // Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture - end; -end; - -procedure TScreenSong.UpdateLCD; -begin - LCD.HideCursor; - LCD.Clear; - LCD.WriteText(1, Text[TextArtist].Text); - LCD.WriteText(2, Text[TextTitle].Text); -end; - -//Procedure Change current played Preview -procedure TScreenSong.ChangeMusic; -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 - begin - Music.Close; - if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin - Music.MoveTo(Music.Length / 4); - //If Song Fading is activated then don't Play directly, and Set Volume to Null, else Play normal - if (Ini.PreviewFading = 0) then - Music.Play - else - Music.SetMusicVolume(0); - end; - end - else - Music.Stop; - end; -end; - -procedure TScreenSong.SkipTo(Target: Cardinal); // 0.5.0 -var - Skip: integer; - I: integer; -begin - UnLoadDetailedCover; - - Interaction := High(CatSongs.Song); - SongTarget := 0; - - for I := 1 to Target+1 do - SelectNext; - - FixSelected2; -end; - -procedure TScreenSong.DrawEqualizer; -var - Data: TFFTData; //Audio Data - I, J: Integer; - Res: byte; - A, B: Integer; - PosX, PosY: Integer; - Pos: Real; -begin -if (not Music.Finished) AND (Theme.Song.Equalizer.Length > 0) then -begin - - - A := GetTickCount div 44; - - if (A <> EqualizerTime) then - begin - EqualizerTime := A; - Data := Music.GetFFTData; - - B:=0; - Pos := 0; - Res := ceil(92/Theme.Song.Equalizer.Bands);//How much channels are used for one Band - - //Change Lengths - for I := 0 to (Res * Theme.Song.Equalizer.Bands - 1) do - begin - A := floor(I/Res); - - if (A<>B) then //Band changed - begin - if (Pos <= Theme.Song.Equalizer.Length) then - begin - if ((Pos < EqualizerBands[B]) AND (EqualizerBands[B]>1)) then - EqualizerBands[B] := EqualizerBands[B] - 1 - else - EqualizerBands[B] := floor(Pos); - end - else - EqualizerBands[B] := 1; - - B := A; - Pos := 0; - end; - - if I > 35 then - Data[i] := Data[i] * 8 - else if I > 11 then - Data[i] := Data[i] * 4.5 - else - Data[i] := Data[i] * 1.1; - - if (Data[i] >= 1) then - Data[i] := 0.9999999999999; - - if Data[i]*Theme.Song.Equalizer.Length > Pos then - Pos := Data[i]*Theme.Song.Equalizer.Length; - end; - - //Change Last Band - if (EqualizerBands[B] <= Theme.Song.Equalizer.Length) then - begin - if ((Pos < EqualizerBands[B]) AND (EqualizerBands[B]>1)) then - EqualizerBands[B] := EqualizerBands[B] - 1 - else - EqualizerBands[B] := floor(Pos) - end - else - EqualizerBands[B] := 1; - end; - - //Draw every Channel - glColor4f(Theme.Song.Equalizer.ColR, Theme.Song.Equalizer.ColG, Theme.Song.Equalizer.ColB, Theme.Song.Equalizer.Alpha); //Set Color - glDisable(GL_TEXTURE_2D); - glEnable(GL_BLEND); - - PosY := Theme.Song.Equalizer.Y; - PosX := Theme.Song.Equalizer.X; - - For I := 0 to Theme.Song.Equalizer.Bands-1 do - begin - if Theme.Song.Equalizer.Direction then - PosY := Theme.Song.Equalizer.Y //+ (Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space) * Theme.Song.Equalizer.Length - else - PosX := Theme.Song.Equalizer.X; - //Draw for every visible quad - for J := 1 to EqualizerBands[I] do - begin - glBegin(GL_QUADS); - glVertex3f(PosX, PosY, Theme.Song.Equalizer.Z); - glVertex3f(PosX, PosY+Theme.Song.Equalizer.H, Theme.Song.Equalizer.Z); - glVertex3f(PosX+Theme.Song.Equalizer.W, PosY+Theme.Song.Equalizer.H, Theme.Song.Equalizer.Z); - glVertex3f(PosX+Theme.Song.Equalizer.W, PosY, Theme.Song.Equalizer.Z); - glEnd; - - if Theme.Song.Equalizer.Direction then //Vertically - PosY := PosY - Theme.Song.Equalizer.H - Theme.Song.Equalizer.Space - else //Horizontally - PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space; - end; - if Theme.Song.Equalizer.Direction then //Horizontally - PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space - else //Vertically - PosY := PosY + Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space; - end; -end; -end; - -Procedure TScreenSong.SelectRandomSong; -var - I, I2: Integer; -begin - Case PlaylistMan.Mode of - 0: //All Songs Just Select Random Song - begin - //When Tabs are activated then use Tab Method - if (Ini.Tabs_at_startup = 1) then - begin - 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 - begin - if CatSongs.Song[I].Main then - break; - 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 - - //Choose Cat - CatSongs.ShowCategoryList; - - //Show Cat in Top Left Mod - ShowCatTL (I); - - CatSongs.ClickCategoryButton(I); - SelectNext; - - //Choose Song - SkipTo(I2-I); - end - //When Tabs are deactivated use easy Method - else - SkipTo(Random(CatSongs.VisibleSongs)); - end; - 1: //One Category Select Category and Select Random Song - begin - CatSongs.ShowCategoryList; - CatSongs.ClickCategoryButton(PlaylistMan.CurPlayList); - ShowCatTL(PlaylistMan.CurPlayList); - - SelectNext; - FixSelected2; - - SkipTo(Random(CatSongs.VisibleSongs)); - end; - 2: //Playlist: Select Playlist and Select Random Song - begin - PlaylistMan.SetPlayList(PlaylistMan.CurPlayList); - - SkipTo(Random(CatSongs.VisibleSongs)); - FixSelected2; - end; - end; - - Music.PlayChange; - ChangeMusic; - SetScroll; - UpdateLCD; -end; - -procedure TScreenSong.SetJoker; -begin - //If Party Mode - if Mode = 1 then //Show Joker that are available - begin - if (PartySession.Teams.NumTeams >= 1) then - begin - Static[StaticTeam1Joker1].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 1); - Static[StaticTeam1Joker2].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 2); - Static[StaticTeam1Joker3].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 3); - Static[StaticTeam1Joker4].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 4); - Static[StaticTeam1Joker5].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 5); - end - else - begin - Static[StaticTeam1Joker1].Visible := False; - Static[StaticTeam1Joker2].Visible := False; - Static[StaticTeam1Joker3].Visible := False; - Static[StaticTeam1Joker4].Visible := False; - Static[StaticTeam1Joker5].Visible := False; - end; - - if (PartySession.Teams.NumTeams >= 2) then - begin - Static[StaticTeam2Joker1].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 1); - Static[StaticTeam2Joker2].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 2); - Static[StaticTeam2Joker3].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 3); - Static[StaticTeam2Joker4].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 4); - Static[StaticTeam2Joker5].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 5); - end - else - begin - Static[StaticTeam2Joker1].Visible := False; - Static[StaticTeam2Joker2].Visible := False; - Static[StaticTeam2Joker3].Visible := False; - Static[StaticTeam2Joker4].Visible := False; - Static[StaticTeam2Joker5].Visible := False; - end; - - if (PartySession.Teams.NumTeams >= 3) then - begin - Static[StaticTeam3Joker1].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 1); - Static[StaticTeam3Joker2].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 2); - Static[StaticTeam3Joker3].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 3); - Static[StaticTeam3Joker4].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 4); - Static[StaticTeam3Joker5].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 5); - end - else - begin - Static[StaticTeam3Joker1].Visible := False; - Static[StaticTeam3Joker2].Visible := False; - Static[StaticTeam3Joker3].Visible := False; - Static[StaticTeam3Joker4].Visible := False; - Static[StaticTeam3Joker5].Visible := False; - end; - end - else - begin //Hide all - Static[StaticTeam1Joker1].Visible := False; - Static[StaticTeam1Joker2].Visible := False; - Static[StaticTeam1Joker3].Visible := False; - Static[StaticTeam1Joker4].Visible := False; - Static[StaticTeam1Joker5].Visible := False; - - Static[StaticTeam2Joker1].Visible := False; - Static[StaticTeam2Joker2].Visible := False; - Static[StaticTeam2Joker3].Visible := False; - Static[StaticTeam2Joker4].Visible := False; - Static[StaticTeam2Joker5].Visible := False; - - Static[StaticTeam3Joker1].Visible := False; - Static[StaticTeam3Joker2].Visible := False; - Static[StaticTeam3Joker3].Visible := False; - Static[StaticTeam3Joker4].Visible := False; - Static[StaticTeam3Joker5].Visible := False; - end; -end; - -procedure TScreenSong.SetStatics; -var - I: Integer; - Visible: Boolean; -begin - //Set Visibility of Party Statics and Text - Visible := (Mode = 1); - - For I := 0 to high(StaticParty) do - Static[StaticParty[I]].Visible := Visible; - - 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 - Static[StaticNonParty[I]].Visible := Visible; - - For I := 0 to high(TextNonParty) do - Text[TextNonParty[I]].Visible := Visible; -end; - -//Procedures for Menu - -procedure TScreenSong.StartSong; -begin - CatSongs.Selected := Interaction; - Music.Stop; - //Party Mode - if (Mode = 1) then - begin - FadeTo(@ScreenSingModi); - end - else - begin - FadeTo(@ScreenSing); - end; -end; - -procedure TScreenSong.SelectPlayers; -begin - CatSongs.Selected := Interaction; - Music.Stop; - - ScreenName.Goto_SingScreen := True; - FadeTo(@ScreenName); -end; - -procedure TScreenSong.OpenEditor; -begin - if (Length(Songs.Song) > 0) and (not CatSongs.Song[Interaction].Main) AND (Mode = 0) then begin - Music.Stop; - Music.PlayStart; - ScreenEditSub.Path := CatSongs.Song[Interaction].Path; - ScreenEditSub.FileName := CatSongs.Song[Interaction].FileName; - FadeTo(@ScreenEditSub); - end; -end; - -//Team No of Team (0-5) -procedure TScreenSong.DoJoker (Team: Byte); -begin - if (Mode = 1) AND (PartySession.Teams.NumTeams >= Team + 1) AND (PartySession.Teams.Teaminfo[Team].Joker > 0) then - begin - //Joker spielen - Dec(PartySession.Teams.Teaminfo[Team].Joker); - SelectRandomSong; - SetJoker; - 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, 'Plain', true); // 0.5.0: show cached texture - Button[Interaction].Texture2.Alpha := 0; - - if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then - Texture.UnloadTexture(Button[Interaction].Texture.Name, false); -end; - -procedure TScreenSong.Refresh; -begin { -CatSongs.Refresh; -CatSongs.ShowCategoryList; -Interaction := 0; -SelectNext; -FixSelected; } - -end; - -end. +unit UScreenSong; + +interface +{$I switches.inc} + +uses + UMenu, + SDL, + UMusic, + UFiles, + UTime, + UDisplay, + USongs, + SysUtils, + ULog, + UThemes, + UTexture, + ULanguage, + ULCD, + ULight, + UIni; + +type + TScreenSong = class(TMenu) + public + TextArtist: integer; + TextTitle: integer; + TextNumber: integer; + + //Video Icon Mod + VideoIcon: Cardinal; + + TextCat: integer; + StaticCat: integer; + + SongCurrent: real; + SongTarget: real; + + HighSpeed: boolean; + CoverFull: boolean; + CoverTime: real; + CoverX: integer; + CoverY: integer; + CoverW: integer; + is_jump: boolean; // Jump to Song Mod + is_jump_title:boolean; //Jump to SOng MOd-YTrue if search for Title + + EqualizerBands: array of Byte; + EqualizerTime: Cardinal; + EqualizerTime2: Byte; + + //Party Mod + Mode: Byte; //0 = Standard, 1= Go to PartyMode after Selection + Change to Random Song at Show + //party Statics (Joker) + StaticTeam1Joker1: Cardinal; + StaticTeam1Joker2: Cardinal; + StaticTeam1Joker3: Cardinal; + StaticTeam1Joker4: Cardinal; + StaticTeam1Joker5: Cardinal; + + StaticTeam2Joker1: Cardinal; + StaticTeam2Joker2: Cardinal; + StaticTeam2Joker3: Cardinal; + StaticTeam2Joker4: Cardinal; + StaticTeam2Joker5: Cardinal; + + StaticTeam3Joker1: Cardinal; + StaticTeam3Joker2: Cardinal; + StaticTeam3Joker3: Cardinal; + StaticTeam3Joker4: Cardinal; + StaticTeam3Joker5: Cardinal; + + StaticParty: Array of Cardinal; + TextParty: Array of Cardinal; + StaticNonParty: Array of Cardinal; + TextNonParty: Array of Cardinal; + + + constructor Create; override; + procedure SetScroll; + procedure SetScroll1; + procedure SetScroll2; + procedure SetScroll3; + procedure SetScroll4; + procedure SetScroll5; + procedure SetScroll6; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + function Draw: boolean; override; + procedure onShow; override; + procedure onHide; override; + procedure SelectNext; + procedure SelectPrev; + procedure UpdateLCD; + procedure SkipTo(Target: Cardinal); + procedure FixSelected; //Show Wrong Song when Tabs on Fix + procedure FixSelected2; //Show Wrong Song when Tabs on Fix + procedure ShowCatTL(Cat: Integer);// Show Cat in Top left + procedure ShowCatTLCustom(Caption: String);// Show Custom Text in Top left + procedure HideCatTL;// Show Cat in Tob left + procedure Refresh; //Refresh Song Sorting + procedure DrawEqualizer; + procedure ChangeMusic; + //Party Mode + procedure SelectRandomSong; + procedure SetJoker; + procedure SetStatics; + //procedures for Menu + procedure StartSong; + procedure OpenEditor; + procedure DoJoker(Team: Byte); + procedure SelectPlayers; + + procedure UnLoadDetailedCover; + + //Extensions + procedure DrawExtensions; + end; + +implementation +uses UGraphic, + UMain, + UCovers, + math, + OpenGL12, + {$IFDEF win32} + windows, + {$ELSE} + lclintf, + {$ENDIF} + 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 + 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; + + SongCurrent := I2; + SongTarget := I2; + end; + end; + +procedure TScreenSong.FixSelected2; +var I, I2: Integer; + begin + if CatSongs.VisibleSongs > 0 then + 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; + + SongTarget := I2; + 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; + 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, 'Plain', true); + + Static[StaticCat].Texture := Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', true); + //Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', false); + //Button[Cat]. + //Cover + + + //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 + + +// Method for input parsing. If False is returned, GetNextWindow +// should be checked to know the next window to load; +function TScreenSong.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +var + I: integer; + I2: integer; + HS: integer; + SDL_ModState: Word; + Letter: Char; +begin + Result := true; + + //Song Screen Extensions (Jumpto + Menu) + if (ScreenSongMenu.Visible) then + begin + Result := ScreenSongMenu.ParseInput(PressedKey, ScanCode, PressedDown); + Exit; + end + else if (ScreenSongJumpto.Visible) then + begin + Result := ScreenSongJumpto.ParseInput(PressedKey, ScanCode, PressedDown); + Exit; + end; + + 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 = 0) AND (PressedKey >= SDLK_A) AND (PressedKey <= SDLK_Z) then + begin + Letter := UpCase(Chr(ScanCode)); + I2 := Length(CatSongs.Song); + + //Jump To Titel + if (SDL_ModState = KMOD_LALT or KMOD_LSHIFT) then + begin + 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 (UpCase(CatSongs.Song[(I + Interaction) mod I2].Title[1]) = Letter) then + begin + SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); + + Music.PlayChange; + + ChangeMusic; + SetScroll4; + UpdateLCD; + //Break and Exit + Exit; + end; + end; + end + //Jump to Artist + else if (SDL_ModState = KMOD_LALT) then + begin + 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 (UpCase(CatSongs.Song[(I + Interaction) mod I2].Artist[1]) = Letter) then + begin + SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); + + Music.PlayChange; + + ChangeMusic; + SetScroll4; + UpdateLCD; + + //Break and Exit + Exit; + end; + end; + end; + Exit; + end; + + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + if (Mode = 0) 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 + 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 + Music.Stop; + + CatSongs.ShowCategoryList; + + //Show Cat in Top Left Mod + HideCatTL; + + + //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); + + //Show Cat in Top Left Mod + HideCatTL; + Interaction := 0; + + //Show Wrong Song when Tabs on Fix + SelectNext; + FixSelected; + + ChangeMusic; + end + else + begin + Music.Stop; + Music.PlayBack; + + FadeTo(@ScreenMain); + end; + + end; + end + //When in party Mode then Ask before Close + else if (Mode = 1) then + begin + Music.PlayBack; + CheckFadeTo(@ScreenMain,'MSG_END_PARTY'); + end; + end; + SDLK_RETURN: + begin + if Length(Songs.Song) > 0 then + begin + {$IFDEF UseSerialPort} + // PortWriteB($378, 0); + {$ENDIF} + if CatSongs.Song[Interaction].Main then + begin // clicked on Category Button + + //Show Cat in Top Left Mod + ShowCatTL (Interaction); + + //I := CatSongs.VisibleIndex(Interaction); + CatSongs.ClickCategoryButton(Interaction); + {I2 := CatSongs.VisibleIndex(Interaction); + SongCurrent := SongCurrent - I + I2; + SongTarget := SongTarget - I + I2; } + +// if I<>I2 then beep; + // SetScroll4; + + //Show Wrong Song when Tabs on Fix + SelectNext; + FixSelected; + + //Play Music: + ChangeMusic; + + end else begin // clicked on song + if (Mode = 0) then //Normal Mode -> Start Song + begin + //Do the Action that is specified in Ini + case Ini.OnSongClick of + 0: StartSong; + 1: SelectPlayers; + 2:begin + If (CatSongs.CatNumShow = -3) then + ScreenSongMenu.MenuShow(SM_Playlist) + else + ScreenSongMenu.MenuShow(SM_Main); + end; + end; + end + else if (Mode = 1) then //PartyMode -> Show Menu + begin + if (Ini.PartyPopup = 1) then + ScreenSongMenu.MenuShow(SM_Party_Main) + else + ScreenSong.StartSong; + end; + end; + end; + end; + + SDLK_M: //Show SongMenu + begin + if (Length(Songs.Song) > 0) then begin + if (Mode = 0) then begin + if not CatSongs.Song[Interaction].Main then begin // clicked on Song + if CatSongs.CatNumShow = -3 then + ScreenSongMenu.MenuShow(SM_Playlist) + else + ScreenSongMenu.MenuShow(SM_Main); + end + else + begin + ScreenSongMenu.MenuShow(SM_Playlist_Load); + end; + end //Party Mode -> Show Party Menu + else ScreenSongMenu.MenuShow(SM_Party_Main); + end; + end; + + SDLK_P: //Show Playlist Menu + begin + if (Length(Songs.Song) > 0) AND (Mode = 0) then begin + ScreenSongMenu.MenuShow(SM_Playlist_Load); + end; + end; + + SDLK_J: //Show Jumpto Menu + begin + if (Length(Songs.Song) > 0) AND (Mode = 0) then + begin + ScreenSongJumpto.Visible := True; + end; + end; + + SDLK_DOWN: + begin + if (Mode = 0) then + begin + //Only Change Cat when not in Playlist or Search Mode + if (CatSongs.CatNumShow > -2) then + begin + //Cat Change Hack + if Ini.Tabs_at_startup = 1 then + begin + I := Interaction; + if I <= 0 then I := 1; + + while not catsongs.Song[I].Main do + begin + Inc (I); + if (I > high(catsongs.Song)) then + I := low(catsongs.Song); + end; + + Interaction := I; + + //Show Cat in Top Left Mod + ShowCatTL (Interaction); + + CatSongs.ClickCategoryButton(Interaction); + SelectNext; + FixSelected; + + //Play Music: + Music.PlayChange; + ChangeMusic; + + end; + + // + //Cat Change Hack End} + end; + end; + end; + SDLK_UP: + begin + if (Mode = 0) then + begin + //Only Change Cat when not in Playlist or Search Mode + if (CatSongs.CatNumShow > -2) then + begin + //Cat Change Hack + if Ini.Tabs_at_startup = 1 then + begin + I := Interaction; + I2 := 0; + if I <= 0 then I := 1; + + 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; + + Interaction := I; + + //Show Cat in Top Left Mod + ShowCatTL (I); + + CatSongs.ClickCategoryButton(I); + SelectNext; + FixSelected; + + //Play Music: + Music.PlayChange; + ChangeMusic; + end; + end; + //Cat Change Hack End} + end; + end; + + SDLK_RIGHT: + begin + if (Length(Songs.Song) > 0) AND (Mode = 0) then begin + Music.PlayChange; + SelectNext; +// InteractNext; +// SongTarget := Interaction; + ChangeMusic; + SetScroll4; + UpdateLCD; + Light.LightOne(1, 200); + end; + end; + + SDLK_LEFT: + begin + if (Length(Songs.Song) > 0)AND (Mode = 0) then begin + Music.PlayChange; + SelectPrev; + ChangeMusic; + SetScroll4; + UpdateLCD; + Light.LightOne(0, 200); + end; + end; + + SDLK_E: + begin + OpenEditor; + end; + + SDLK_R: + begin + if (Length(Songs.Song) > 0) AND (Mode = 0) 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 := 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 + begin + //Show Cat in Top Left Mod + ShowCatTL (I); + + Interaction := I; + + 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 + begin + 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 + begin + if CatSongs.Song[I].Main then + break; + end; + //In I ist jetzt die Kategorie in I2 der Song + + //Choose Cat + CatSongs.ShowCategoryList; + + //Show Cat in Top Left Mod + ShowCatTL (I); + + CatSongs.ClickCategoryButton(I); + SelectNext; + + //Fix: Not Existing Song selected: + //if (I+1=I2) then Inc(I2); + + //Choose Song + SkipTo(I2-I); + + end + else //Random in one Category + begin + SkipTo(Random(CatSongs.VisibleSongs)); + end; + Music.PlayChange; + + ChangeMusic; + SetScroll4; + UpdateLCD; + end; + end; + + SDLK_1: + begin //Jocker + if (Mode = 1) AND (PartySession.Teams.NumTeams >= 1) AND (PartySession.Teams.Teaminfo[0].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[0].Joker); + SelectRandomSong; + SetJoker; + end; + end; + + SDLK_2: + begin //Jocker + if (Mode = 1) AND (PartySession.Teams.NumTeams >= 2) AND (PartySession.Teams.Teaminfo[1].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[1].Joker); + SelectRandomSong; + SetJoker; + end; + end; + + SDLK_3: + begin //Jocker + if (Mode = 1) AND (PartySession.Teams.NumTeams >= 3) AND (PartySession.Teams.Teaminfo[2].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[2].Joker); + SelectRandomSong; + SetJoker; + end; + end; + end; + end; +end; + +constructor TScreenSong.Create; +var + Pet: integer; + I: integer; +Label CreateSongButtons; +begin + inherited Create; + + LoadFromTheme(Theme.Song); + + TextArtist := AddText(Theme.Song.TextArtist); + TextTitle := AddText(Theme.Song.TextTitle); + TextNumber := AddText(Theme.Song.TextNumber); + + //Show Cat in Top Left mod + TextCat := AddText(Theme.Song.TextCat); + StaticCat := AddStatic(Theme.Song.StaticCat); + + //Show Video Icon Mod + VideoIcon := AddStatic(Theme.Song.VideoIcon); + + //Party Mode + StaticTeam1Joker1 := AddStatic(Theme.Song.StaticTeam1Joker1); + StaticTeam1Joker2 := AddStatic(Theme.Song.StaticTeam1Joker2); + StaticTeam1Joker3 := AddStatic(Theme.Song.StaticTeam1Joker3); + StaticTeam1Joker4 := AddStatic(Theme.Song.StaticTeam1Joker4); + StaticTeam1Joker5 := AddStatic(Theme.Song.StaticTeam1Joker5); + + StaticTeam2Joker1 := AddStatic(Theme.Song.StaticTeam2Joker1); + StaticTeam2Joker2 := AddStatic(Theme.Song.StaticTeam2Joker2); + StaticTeam2Joker3 := AddStatic(Theme.Song.StaticTeam2Joker3); + StaticTeam2Joker4 := AddStatic(Theme.Song.StaticTeam2Joker4); + StaticTeam2Joker5 := AddStatic(Theme.Song.StaticTeam2Joker5); + + StaticTeam3Joker1 := AddStatic(Theme.Song.StaticTeam3Joker1); + StaticTeam3Joker2 := AddStatic(Theme.Song.StaticTeam3Joker2); + StaticTeam3Joker3 := AddStatic(Theme.Song.StaticTeam3Joker3); + StaticTeam3Joker4 := AddStatic(Theme.Song.StaticTeam3Joker4); + StaticTeam3Joker5 := AddStatic(Theme.Song.StaticTeam3Joker5); + + //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]); + + SetLength(TextParty, Length(Theme.Song.TextParty)); + 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]); + + SetLength(TextNonParty, Length(Theme.Song.TextNonParty)); + 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 + CatSongs.Refresh; + + 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)); + + I := 0; + CreateSongButtons: + + try + for Pet := I to High(CatSongs.Song) do begin // creating all buttons + // 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 + CatSongs.Song[Pet].Cover := ''; // 0.5.0: if cover not found then show 'no cover' + + if CatSongs.Song[Pet].Cover = '' then + AddButton(300 + Pet*250, 140, 200, 200, Skin.GetTextureFileName('SongCover'), 'JPG', '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 + begin + Texture.CreateCacheMipmap := true; + Texture.GetTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, '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); + + // unload full size texture + Texture.UnloadTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, 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, 'JPG', 'Plain', Theme.Song.Cover.Reflections); + end; + Texture.Limit := 1024*1024; + I := -1; + end; + except + //When Error is reported the First time for this Song + if (I <> Pet) then + begin + //Some Error reporting: + Log.LogError('Could not load Cover: ' + CatSongs.Song[Pet].Cover); + + //Change Cover to NoCover and Continue Loading + CatSongs.Song[Pet].Cover := ''; + I := Pet; + end + else //when Error occurs Multiple Times(NoSong Cover is damaged), then start loading next Song + begin + Log.LogError('NoCover Cover is damaged!'); + try + AddButton(300 + Pet*250, 140, 200, 200, '', 'JPG', 'Plain', Theme.Song.Cover.Reflections); + except + {$IFDEF win32} + Messagebox(0, PChar('No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'), PChar(Language.Translate('US_VERSION')), MB_ICONERROR or MB_OK); + {$ELSE} + // TODO : JB_linux - better handle this message and display to user.. + writeln( 'No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'); + Log.LogError( 'No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.' ); + {$ENDIF} + Halt; + end; + I := Pet + 1; + end; + end; + + if (I <> -1) then + GoTo CreateSongButtons; + + end; + + // Randomize Patch + Randomize; + //Equalizer + SetLength(EqualizerBands, Theme.Song.Equalizer.Bands); + //ClearArray + For I := low(EqualizerBands) to high(EqualizerBands) do + EqualizerBands[I] := 3; + + if (Length(CatSongs.Song) > 0) then + Interaction := 0; +end; + +procedure TScreenSong.SetScroll; +var + VS, B: Integer; +begin + VS := CatSongs.VisibleSongs; + if VS > 0 then + begin + //Set Positions + Case Theme.Song.Cover.Style of + 3: SetScroll3; + 5:begin + if VS > 5 then + SetScroll5 + else + SetScroll4; + end; + 6: SetScroll6; + else SetScroll4; + end; + //Set Visibility of Video Icon + Static[VideoIcon].Visible := (CatSongs.Song[Interaction].Video <> ''); + + //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 + 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') + ')'; + end + else if (CatSongs.CatNumShow = -2) then + Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) + else if (CatSongs.CatNumShow = -3) then + Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) + 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)); + 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; + + end; +end; + +procedure TScreenSong.SetScroll1; +var + B: integer; // button + BMin: integer; // button min + BMax: integer; // button max + Src: integer; +// Dst: integer; + Count: integer; // Dst is not used. Count is used. + Ready: boolean; + + VisCount: integer; // count of visible (or selectable) buttons + VisInt: integer; // visible position of interacted button + Typ: integer; // 0 when all songs fits the screen + Placed: integer; // number of placed visible buttons +begin +// Src := 0; +// Dst := -1; + Count := 1; + Typ := 0; + Ready := false; + Placed := 0; + + VisCount := 0; + 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); + + + if VisCount <= 6 then begin + Typ := 0; + end else begin + if VisInt <= 3 then begin + Typ := 1; + Count := 7; + Ready := true; + end; + + if (VisCount - VisInt) <= 3 then begin + Typ := 2; + Count := 7; + Ready := true; + end; + + if not Ready then begin + Typ := 3; + Src := Interaction; + end; + end; + + + + // hide all buttons + for B := 0 to High(Button) do begin + Button[B].Visible := false; + Button[B].Selectable := CatSongs.Song[B].Visible; + end; + +{ 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;} + + + if Typ = 0 then begin + for B := 0 to High(Button) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (Placed) * 60; + Inc(Placed); + end; + end; + end; + + if Typ = 1 then begin + B := 0; + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Inc(B); + end; + end; + + if Typ = 2 then begin + B := High(Button); + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (6-Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Dec(B); + end; + end; + + if Typ = 3 then begin + B := Src; + Count := 4; + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (3+Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Inc(B); + end; + + B := Src-1; + Placed := 0; + Count := 3; + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (2-Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Dec(B); + end; + + end; + + if Length(Button) > 0 then + Static[1].Texture.Y := Button[Interaction].Y - 5; // selection texture +end; + +procedure TScreenSong.SetScroll2; +var + B: integer; + Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu + Wsp2: real; +begin + // liniowe + for B := 0 to High(Button) do + Button[B].X := 300 + (B - Interaction) * 260; + + 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; + + // kolowe +{ 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;} +end; + +procedure TScreenSong.SetScroll3; // with slide +var + B: integer; + Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu + Wsp2: real; +begin + SongTarget := Interaction; + + // liniowe + for B := 0 to High(Button) do + begin + Button[B].X := 300 + (B - SongCurrent) * 260; + if (Button[B].X < -Button[B].W) OR (Button[B].X > 800) then + Button[B].Visible := False + else + Button[B].Visible := True; + end; + +{ 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;} + + // kolowe +{ 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;} +end; + +procedure TScreenSong.SetScroll4; // rotate +var + B: integer; + Wsp: real; + Z, Z2: real; + VS: integer; +begin + VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important + + // kolowe + 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 + + 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; + + + Button[B].X := Theme.Song.Cover.X + (0.185 * Theme.Song.Cover.H * VS * sin(Wsp)) * Z2 - ((Button[B].H - Theme.Song.Cover.H)/2); // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs + Button[B].Z := Z / 2 + 0.3; + + 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].H := Button[B].W; + end; + end; +end; + +(* +procedure TScreenSong.SetScroll4; // rotate +var + B: integer; + Wsp: real; + Z: real; + Z2, Z3: real; + VS: integer; + function modreal (const X, Y: real):real; + begin + Result := Frac(x / y) * y; + if Result < -3 then + Result := Result + Y + else if Result > 3 then + Result := Result - Y; + end; +begin + VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important + Z3 := 1; + if VS < 12 then + Z2 := VS + else + Z2 := 12; + + // kolowe + 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 + begin + if CatSongs.VisibleIndex(B)> SongCurrent then + Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / Z2 + else + Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / Z2; + + Z3 := 2; + Z := (1 + cos(Wsp)) / 2; + //Z2 := (1 + 2*Z) / 3; + //Z2 := (0.5 + Z/2); + //Z2 := sin(Wsp); + + //Z2 := Power (Z2,Z3); + + Button[B].W := Theme.Song.CoverW * Power(cos(Wsp), Z3);//Power(Z2, 3); + + //Button[B].X := Theme.Song.CoverX + ({Theme.Song.CoverX + Theme.Song.CoverW/2 + Theme.Song.CoverW*0.18 * VS {CatSongs.VisibleSongs {Length(Button) * sin(Wsp) {- Theme.Song.CoverX - Theme.Song.CoverW) * Z2; // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs + if (sin(Wsp)<0) then + Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX + Theme.Song.CoverW - Button[B].W + else //*Theme.Song.CoverW*0.004*Z3 + 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 := (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 + begin + Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / 12 ;// 0.5.0 (II): takes another 16ms + + Z := (1 + cos(Wsp)) / 2 -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers + + Button[B].W := Theme.Song.CoverW * Power(cos(Wsp), Z3);//Power(Z2, 3); + + if (sin(Wsp)<0) then + Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX + Theme.Song.CoverW - Button[B].W + else + Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX; + + Button[B].Z := Z; + + Button[B].Y := (Theme.Song.CoverY + Theme.Song.CoverW - Button[B].W); + + Button[B].H := Button[B].W; + Button[B].Visible := True; + end + else Button[B].Visible := False; + end; + end; +end; *) + +procedure TScreenSong.SetScroll5; // rotate +var + B: integer; + Angle: real; + Pos: Real; + VS: integer; + diff: real; + X: Real; + helper: real; +begin + VS := CatSongs.VisibleSongs; // cache Visible Songs + {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 + Theme.Song.CoverH: Höhe der Cover + + (CatSongs.VisibleIndex(B) - SongCurrent)/VS = Abstand zum MIttleren Cover in % + } + + //Change Pos of all Buttons + for B := low(Button) to high(Button) do + begin + Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visibility + if Button[B].Visible then //Only Change Pos for Visible Buttons + begin + Pos := (CatSongs.VisibleIndex(B) - SongCurrent); + if (Pos < -VS/2) then + Pos := Pos + VS + else if (Pos > VS/2) then + Pos := Pos - VS; + + if (Abs(Pos) < 2.5) then {fixed Positions} + begin + Angle := Pi * (Pos / 5); +// 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].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + + Button[B].Z := 0.95 - Abs(Pos) * 0.01; + + Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); + + Button[B].W := Button[B].H; + + Diff := (Button[B].H - Theme.Song.Cover.H)/2; + + + X := Sin(Angle*1.3)*0.9; + + Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * X - Diff; + + end + else + begin {Behind the Front Covers} + + // limit-bg-covers hack + if (abs(abs(Pos)-VS/2)>10) then Button[B].Visible:=False; + // end of limit-bg-covers hack + + if Pos < 0 then + Pos := (Pos - VS/2)/VS + else + Pos := (Pos + VS/2)/VS; + + Angle := pi * Pos*2; + if VS > 24 then + begin + if Angle < 0 then helper:=-1 else helper:=1; + Angle:=2*pi-abs(Angle); + Angle:=Angle*(VS/24); + Angle:=(2*pi-Angle)*helper; + end; + + Button[B].Z := (0.4 - Abs(Pos/4)) -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers + + Button[B].H :=0.6*(Theme.Song.Cover.H-Abs(Theme.Song.Cover.H * cos(Angle/2)*0.8));//Power(Z2, 3); + + Button[B].W := Button[B].H; + + 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].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + + Diff := (Button[B].H - Theme.Song.Cover.H)/2; + + Button[B].X := Theme.Song.Cover.X+Theme.Song.Cover.H/2-Button[b].H/2+Theme.Song.Cover.W/320*((Theme.Song.Cover.H)*sin(Angle/2)*1.52); + + 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); + + end; + end; +end; + +procedure TScreenSong.SetScroll6; // rotate (slotmachine style) +var + B: integer; + Angle: real; + Pos: Real; + VS: integer; + diff: real; + X: Real; + Wsp: real; + Z, Z2: real; +begin + VS := CatSongs.VisibleSongs; // cache Visible Songs + if VS <=5 then begin + // kolowe + 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 + + 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; + + + Button[B].Y := Theme.Song.Cover.Y + (0.185 * Theme.Song.Cover.H * VS * sin(Wsp)) * Z2 - ((Button[B].H - Theme.Song.Cover.H)/2); // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs + Button[B].Z := Z / 2 + 0.3; + + Button[B].W := Theme.Song.Cover.H * 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; + end; + end + else begin + + //Change Pos of all Buttons + for B := low(Button) to high(Button) do + begin + Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visibility + if Button[B].Visible then //Only Change Pos for Visible Buttons + begin + Pos := (CatSongs.VisibleIndex(B) - SongCurrent); + if (Pos < -VS/2) then + Pos := Pos + VS + else if (Pos > VS/2) then + Pos := Pos - VS; + + if (Abs(Pos) < 2.5) then {fixed Positions} + begin + Angle := Pi * (Pos / 5); +// Button[B].Visible := False; + + Button[B].H := Abs(Theme.Song.Cover.H * cos(Angle*0.8));//Power(Z2, 3); + + Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + + Button[B].Z := 0.95 - Abs(Pos) * 0.01; + + Button[B].X := (Theme.Song.Cover.X + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); + + Button[B].W := Button[B].H; + + Diff := (Button[B].H - Theme.Song.Cover.H)/2; + + + X := Sin(Angle*1.3)*0.9; + + Button[B].Y := Theme.Song.Cover.Y + Theme.Song.Cover.W * X - Diff; + end + else + begin {Behind the Front Covers} + + // limit-bg-covers hack + if (abs(VS/2-abs(Pos))>10) then Button[B].Visible:=False; + if VS > 25 then VS:=25; + // end of limit-bg-covers hack + + if Pos < 0 then + Pos := (Pos - VS/2)/VS + else + Pos := (Pos + VS/2)/VS; + + 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 + + Button[B].H :=0.6*(Theme.Song.Cover.H-Abs(Theme.Song.Cover.H * cos(Angle/2)*0.8));//Power(Z2, 3); + + Button[B].W := Button[B].H; + + Button[B].X := Theme.Song.Cover.X - (Button[B].H - Theme.Song.Cover.H)*0.5; + + + Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + + Button[B].Y := Theme.Song.Cover.Y+Theme.Song.Cover.H/2-Button[b].H/2+Theme.Song.Cover.W/320*(Theme.Song.Cover.H*sin(Angle/2)*1.52); + end; + end; + end; + end; +end; + + +procedure TScreenSong.onShow; +begin + Music.Stop; + + if Ini.Players <= 3 then PlayersPlay := Ini.Players + 1; + 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 Length(CatSongs.Song) > 0 then begin + //Load Music only when Song Preview is activated + if (Ini.PreviewVolume <> 0) then + begin + Music.SetLoop(false); + Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); + Music.MoveTo(Music.Length / 4); + Music.Play; + + //Set Preview Volume + Music.SetMusicVolume (Ini.PreviewVolume * 10); + {//if Music Fade is activated, Set Volume to 0 % + if (Ini.PreviewFading <> 0) then + Music.SetMusicVolume(0);} + end; + + SetScroll; + UpdateLCD; + end; + + //Playlist Mode + if (Mode = 0) then + begin + //If Playlist Shown -> Select Next automatically + if (CatSongs.CatNumShow = -3) then + begin + SelectNext; + ChangeMusic; + end; + end + //Party Mode + else if (Mode = 1) then + begin + + SelectRandomSong; + //Show Menu directly in PartyMode + //But only if selected in Options + if (Ini.PartyPopup = 1) then + begin + ScreenSongMenu.MenuShow(SM_Party_Main); + end; + + + end; + + SetJoker; + SetStatics; +end; + +procedure TScreenSong.onHide; +begin + //When Music Fading is activated, Turn Music to 100 % + If (Ini.PreviewVolume <> 100) or (Ini.PreviewFading <> 0) then + Music.SetMusicVolume(100); + + //If Preview is deactivated: Load MUsicfile now + If (Ini.PreviewVolume = 0) then + Music.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 (Music <> nil) then + Music.Stop; +end; + +procedure TScreenSong.DrawExtensions; +begin + //Draw Song Menu + if (ScreenSongMenu.Visible) then + begin + ScreenSongMenu.Draw; + end + else if (ScreenSongJumpto.Visible) then + begin + ScreenSongJumpto.Draw; + end +end; + +function TScreenSong.Draw: boolean; +var + dx: real; + dt: real; + I: Integer; +begin + dx := SongTarget-SongCurrent; + dt := TimeSkip*7; + if dt > 1 then dt := 1; + SongCurrent := SongCurrent + dx*dt; + +{ if SongCurrent > Catsongs.VisibleSongs then begin + SongCurrent := SongCurrent - Catsongs.VisibleSongs; + SongTarget := SongTarget - Catsongs.VisibleSongs; + end;} + +// Log.BenchmarkStart(5); + SetScroll; +// Log.BenchmarkEnd(5); +// Log.LogBenchmark('SetScroll4', 5); + + //Fading Functions, Only if Covertime is under 5 Seconds + If (CoverTime < 5) then + begin + // 0.5.0: cover fade + if (CoverTime < 1) and (CoverTime + TimeSkip >= 1) then begin + // load new texture + Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); + Button[Interaction].Texture.Alpha := 1; + Button[Interaction].Texture2 := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); + Button[Interaction].Texture2.Alpha := 1; + end; + + //Song Fade + 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 + Music.Play; + + //Update Song Volume + if (CoverTime < Ini.PreviewFading) then + Music.SetMusicVolume(Round (CoverTime * Ini.PreviewVolume / Ini.PreviewFading * 10)) + else + Music.SetMusicVolume(Ini.PreviewVolume * 10); + + end; + + + //Update Fading Time + CoverTime := CoverTime + TimeSkip; + + //Update Fading Texture + Button[Interaction].Texture2.Alpha := (CoverTime - 1) * 1.5; + if Button[Interaction].Texture2.Alpha > 1 then Button[Interaction].Texture2.Alpha := 1; + + end; + + //inherited Draw; + //heres a little Hack, that causes the Statics + //are Drawn after the Buttons because of some Blending Problems. + //This should cause no Problems because all Buttons on this screen + //Has Z Position. + //Draw BG + DrawBG; + + //Instead of Draw FG Procedure: + //We draw Buttons for our own + for I := 0 to Length(Button) - 1 do + Button[I].Draw; + + // Statics + for I := 0 to Length(Static) - 1 do + Static[I].Draw; + + // and texts + for I := 0 to Length(Text) - 1 do + Text[I].Draw; + + + //Draw Equalizer + if Theme.Song.Equalizer.Visible then + DrawEqualizer; + + DrawExtensions; + +end; + +procedure TScreenSong.SelectNext; +var + Skip: integer; + I: integer; + VS: Integer; +begin + VS := CatSongs.VisibleSongs; + + if VS > 0 then + begin + UnLoadDetailedCover; + + Skip := 1; + + // this 1 could be changed by CatSongs.FindNextVisible + while (not CatSongs.Song[(Interaction + Skip) mod Length(Interactions)].Visible) do Inc(Skip); + + SongTarget := SongTarget + 1;//Skip; + + Interaction := (Interaction + Skip) mod Length(Interactions); + + // try to keep all at the beginning + if SongTarget > VS-1 then begin + SongTarget := SongTarget - VS; + SongCurrent := SongCurrent - VS; + end; + + end; + // Interaction -> Button, ktorego okladke przeczytamy + // Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture +end; + +procedure TScreenSong.SelectPrev; +var + Skip: integer; + I: integer; + VS: Integer; +begin + VS := CatSongs.VisibleSongs; + + if VS > 0 then + begin + UnLoadDetailedCover; + + Skip := 1; + + 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); + + // try to keep all at the beginning + if SongTarget < 0 then begin + SongTarget := SongTarget + CatSongs.VisibleSongs; + SongCurrent := SongCurrent + CatSongs.VisibleSongs; + end; + + // Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture + end; +end; + +procedure TScreenSong.UpdateLCD; +begin + LCD.HideCursor; + LCD.Clear; + LCD.WriteText(1, Text[TextArtist].Text); + LCD.WriteText(2, Text[TextTitle].Text); +end; + +//Procedure Change current played Preview +procedure TScreenSong.ChangeMusic; +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 + begin + Music.Close; + if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin + Music.MoveTo(Music.Length / 4); + //If Song Fading is activated then don't Play directly, and Set Volume to Null, else Play normal + if (Ini.PreviewFading = 0) then + Music.Play + else + Music.SetMusicVolume(0); + end; + end + else + Music.Stop; + end; +end; + +procedure TScreenSong.SkipTo(Target: Cardinal); // 0.5.0 +var + Skip: integer; + I: integer; +begin + UnLoadDetailedCover; + + Interaction := High(CatSongs.Song); + SongTarget := 0; + + for I := 1 to Target+1 do + SelectNext; + + FixSelected2; +end; + +procedure TScreenSong.DrawEqualizer; +var + Data: TFFTData; //Audio Data + I, J: Integer; + Res: byte; + A, B: Integer; + PosX, PosY: Integer; + Pos: Real; +begin +if (not Music.Finished) AND (Theme.Song.Equalizer.Length > 0) then +begin + + + A := GetTickCount div 44; + + if (A <> EqualizerTime) then + begin + EqualizerTime := A; + Data := Music.GetFFTData; + + B:=0; + Pos := 0; + Res := ceil(92/Theme.Song.Equalizer.Bands);//How much channels are used for one Band + + //Change Lengths + for I := 0 to (Res * Theme.Song.Equalizer.Bands - 1) do + begin + A := floor(I/Res); + + if (A<>B) then //Band changed + begin + if (Pos <= Theme.Song.Equalizer.Length) then + begin + if ((Pos < EqualizerBands[B]) AND (EqualizerBands[B]>1)) then + EqualizerBands[B] := EqualizerBands[B] - 1 + else + EqualizerBands[B] := floor(Pos); + end + else + EqualizerBands[B] := 1; + + B := A; + Pos := 0; + end; + + if I > 35 then + Data[i] := Data[i] * 8 + else if I > 11 then + Data[i] := Data[i] * 4.5 + else + Data[i] := Data[i] * 1.1; + + if (Data[i] >= 1) then + Data[i] := 0.9999999999999; + + if Data[i]*Theme.Song.Equalizer.Length > Pos then + Pos := Data[i]*Theme.Song.Equalizer.Length; + end; + + //Change Last Band + if (EqualizerBands[B] <= Theme.Song.Equalizer.Length) then + begin + if ((Pos < EqualizerBands[B]) AND (EqualizerBands[B]>1)) then + EqualizerBands[B] := EqualizerBands[B] - 1 + else + EqualizerBands[B] := floor(Pos) + end + else + EqualizerBands[B] := 1; + end; + + //Draw every Channel + glColor4f(Theme.Song.Equalizer.ColR, Theme.Song.Equalizer.ColG, Theme.Song.Equalizer.ColB, Theme.Song.Equalizer.Alpha); //Set Color + glDisable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + + PosY := Theme.Song.Equalizer.Y; + PosX := Theme.Song.Equalizer.X; + + For I := 0 to Theme.Song.Equalizer.Bands-1 do + begin + if Theme.Song.Equalizer.Direction then + PosY := Theme.Song.Equalizer.Y //+ (Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space) * Theme.Song.Equalizer.Length + else + PosX := Theme.Song.Equalizer.X; + //Draw for every visible quad + for J := 1 to EqualizerBands[I] do + begin + glBegin(GL_QUADS); + glVertex3f(PosX, PosY, Theme.Song.Equalizer.Z); + glVertex3f(PosX, PosY+Theme.Song.Equalizer.H, Theme.Song.Equalizer.Z); + glVertex3f(PosX+Theme.Song.Equalizer.W, PosY+Theme.Song.Equalizer.H, Theme.Song.Equalizer.Z); + glVertex3f(PosX+Theme.Song.Equalizer.W, PosY, Theme.Song.Equalizer.Z); + glEnd; + + if Theme.Song.Equalizer.Direction then //Vertically + PosY := PosY - Theme.Song.Equalizer.H - Theme.Song.Equalizer.Space + else //Horizontally + PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space; + end; + if Theme.Song.Equalizer.Direction then //Horizontally + PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space + else //Vertically + PosY := PosY + Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space; + end; +end; +end; + +Procedure TScreenSong.SelectRandomSong; +var + I, I2: Integer; +begin + Case PlaylistMan.Mode of + 0: //All Songs Just Select Random Song + begin + //When Tabs are activated then use Tab Method + if (Ini.Tabs_at_startup = 1) then + begin + 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 + begin + if CatSongs.Song[I].Main then + break; + 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 + + //Choose Cat + CatSongs.ShowCategoryList; + + //Show Cat in Top Left Mod + ShowCatTL (I); + + CatSongs.ClickCategoryButton(I); + SelectNext; + + //Choose Song + SkipTo(I2-I); + end + //When Tabs are deactivated use easy Method + else + SkipTo(Random(CatSongs.VisibleSongs)); + end; + 1: //One Category Select Category and Select Random Song + begin + CatSongs.ShowCategoryList; + CatSongs.ClickCategoryButton(PlaylistMan.CurPlayList); + ShowCatTL(PlaylistMan.CurPlayList); + + SelectNext; + FixSelected2; + + SkipTo(Random(CatSongs.VisibleSongs)); + end; + 2: //Playlist: Select Playlist and Select Random Song + begin + PlaylistMan.SetPlayList(PlaylistMan.CurPlayList); + + SkipTo(Random(CatSongs.VisibleSongs)); + FixSelected2; + end; + end; + + Music.PlayChange; + ChangeMusic; + SetScroll; + UpdateLCD; +end; + +procedure TScreenSong.SetJoker; +begin + //If Party Mode + if Mode = 1 then //Show Joker that are available + begin + if (PartySession.Teams.NumTeams >= 1) then + begin + Static[StaticTeam1Joker1].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 1); + Static[StaticTeam1Joker2].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 2); + Static[StaticTeam1Joker3].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 3); + Static[StaticTeam1Joker4].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 4); + Static[StaticTeam1Joker5].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 5); + end + else + begin + Static[StaticTeam1Joker1].Visible := False; + Static[StaticTeam1Joker2].Visible := False; + Static[StaticTeam1Joker3].Visible := False; + Static[StaticTeam1Joker4].Visible := False; + Static[StaticTeam1Joker5].Visible := False; + end; + + if (PartySession.Teams.NumTeams >= 2) then + begin + Static[StaticTeam2Joker1].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 1); + Static[StaticTeam2Joker2].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 2); + Static[StaticTeam2Joker3].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 3); + Static[StaticTeam2Joker4].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 4); + Static[StaticTeam2Joker5].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 5); + end + else + begin + Static[StaticTeam2Joker1].Visible := False; + Static[StaticTeam2Joker2].Visible := False; + Static[StaticTeam2Joker3].Visible := False; + Static[StaticTeam2Joker4].Visible := False; + Static[StaticTeam2Joker5].Visible := False; + end; + + if (PartySession.Teams.NumTeams >= 3) then + begin + Static[StaticTeam3Joker1].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 1); + Static[StaticTeam3Joker2].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 2); + Static[StaticTeam3Joker3].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 3); + Static[StaticTeam3Joker4].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 4); + Static[StaticTeam3Joker5].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 5); + end + else + begin + Static[StaticTeam3Joker1].Visible := False; + Static[StaticTeam3Joker2].Visible := False; + Static[StaticTeam3Joker3].Visible := False; + Static[StaticTeam3Joker4].Visible := False; + Static[StaticTeam3Joker5].Visible := False; + end; + end + else + begin //Hide all + Static[StaticTeam1Joker1].Visible := False; + Static[StaticTeam1Joker2].Visible := False; + Static[StaticTeam1Joker3].Visible := False; + Static[StaticTeam1Joker4].Visible := False; + Static[StaticTeam1Joker5].Visible := False; + + Static[StaticTeam2Joker1].Visible := False; + Static[StaticTeam2Joker2].Visible := False; + Static[StaticTeam2Joker3].Visible := False; + Static[StaticTeam2Joker4].Visible := False; + Static[StaticTeam2Joker5].Visible := False; + + Static[StaticTeam3Joker1].Visible := False; + Static[StaticTeam3Joker2].Visible := False; + Static[StaticTeam3Joker3].Visible := False; + Static[StaticTeam3Joker4].Visible := False; + Static[StaticTeam3Joker5].Visible := False; + end; +end; + +procedure TScreenSong.SetStatics; +var + I: Integer; + Visible: Boolean; +begin + //Set Visibility of Party Statics and Text + Visible := (Mode = 1); + + For I := 0 to high(StaticParty) do + Static[StaticParty[I]].Visible := Visible; + + 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 + Static[StaticNonParty[I]].Visible := Visible; + + For I := 0 to high(TextNonParty) do + Text[TextNonParty[I]].Visible := Visible; +end; + +//Procedures for Menu + +procedure TScreenSong.StartSong; +begin + CatSongs.Selected := Interaction; + Music.Stop; + //Party Mode + if (Mode = 1) then + begin + FadeTo(@ScreenSingModi); + end + else + begin + FadeTo(@ScreenSing); + end; +end; + +procedure TScreenSong.SelectPlayers; +begin + CatSongs.Selected := Interaction; + Music.Stop; + + ScreenName.Goto_SingScreen := True; + FadeTo(@ScreenName); +end; + +procedure TScreenSong.OpenEditor; +begin + if (Length(Songs.Song) > 0) and (not CatSongs.Song[Interaction].Main) AND (Mode = 0) then begin + Music.Stop; + Music.PlayStart; + ScreenEditSub.Path := CatSongs.Song[Interaction].Path; + ScreenEditSub.FileName := CatSongs.Song[Interaction].FileName; + FadeTo(@ScreenEditSub); + end; +end; + +//Team No of Team (0-5) +procedure TScreenSong.DoJoker (Team: Byte); +begin + if (Mode = 1) AND (PartySession.Teams.NumTeams >= Team + 1) AND (PartySession.Teams.Teaminfo[Team].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[Team].Joker); + SelectRandomSong; + SetJoker; + 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, 'Plain', true); // 0.5.0: show cached texture + Button[Interaction].Texture2.Alpha := 0; + + if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then + Texture.UnloadTexture(Button[Interaction].Texture.Name, false); +end; + +procedure TScreenSong.Refresh; +begin { +CatSongs.Refresh; +CatSongs.ShowCategoryList; +Interaction := 0; +SelectNext; +FixSelected; } + +end; + +end. -- cgit v1.2.3 From 4d693075a4b5078a9e08430d003e2bdb918b68c2 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Mon, 8 Oct 2007 02:02:07 +0000 Subject: trying to fix linux runtime errors with database ( Stats screen ) and Song Selection screen ( now back to kina working ) Testing Fisheye Links (please ignore): jira#USDX-1 sf#1790165 build#USDX-DELPHI-26 git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@469 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 4108 +++++++++++++++++++------------------ 1 file changed, 2067 insertions(+), 2041 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 0a3c1d02..859d5026 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1,2041 +1,2067 @@ -unit UScreenSong; - -interface -{$I switches.inc} - -uses - UMenu, - SDL, - UMusic, - UFiles, - UTime, - UDisplay, - USongs, - SysUtils, - ULog, - UThemes, - UTexture, - ULanguage, - ULCD, - ULight, - UIni; - -type - TScreenSong = class(TMenu) - public - TextArtist: integer; - TextTitle: integer; - TextNumber: integer; - - //Video Icon Mod - VideoIcon: Cardinal; - - TextCat: integer; - StaticCat: integer; - - SongCurrent: real; - SongTarget: real; - - HighSpeed: boolean; - CoverFull: boolean; - CoverTime: real; - CoverX: integer; - CoverY: integer; - CoverW: integer; - is_jump: boolean; // Jump to Song Mod - is_jump_title:boolean; //Jump to SOng MOd-YTrue if search for Title - - EqualizerBands: array of Byte; - EqualizerTime: Cardinal; - EqualizerTime2: Byte; - - //Party Mod - Mode: Byte; //0 = Standard, 1= Go to PartyMode after Selection + Change to Random Song at Show - //party Statics (Joker) - StaticTeam1Joker1: Cardinal; - StaticTeam1Joker2: Cardinal; - StaticTeam1Joker3: Cardinal; - StaticTeam1Joker4: Cardinal; - StaticTeam1Joker5: Cardinal; - - StaticTeam2Joker1: Cardinal; - StaticTeam2Joker2: Cardinal; - StaticTeam2Joker3: Cardinal; - StaticTeam2Joker4: Cardinal; - StaticTeam2Joker5: Cardinal; - - StaticTeam3Joker1: Cardinal; - StaticTeam3Joker2: Cardinal; - StaticTeam3Joker3: Cardinal; - StaticTeam3Joker4: Cardinal; - StaticTeam3Joker5: Cardinal; - - StaticParty: Array of Cardinal; - TextParty: Array of Cardinal; - StaticNonParty: Array of Cardinal; - TextNonParty: Array of Cardinal; - - - constructor Create; override; - procedure SetScroll; - procedure SetScroll1; - procedure SetScroll2; - procedure SetScroll3; - procedure SetScroll4; - procedure SetScroll5; - procedure SetScroll6; - function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; - function Draw: boolean; override; - procedure onShow; override; - procedure onHide; override; - procedure SelectNext; - procedure SelectPrev; - procedure UpdateLCD; - procedure SkipTo(Target: Cardinal); - procedure FixSelected; //Show Wrong Song when Tabs on Fix - procedure FixSelected2; //Show Wrong Song when Tabs on Fix - procedure ShowCatTL(Cat: Integer);// Show Cat in Top left - procedure ShowCatTLCustom(Caption: String);// Show Custom Text in Top left - procedure HideCatTL;// Show Cat in Tob left - procedure Refresh; //Refresh Song Sorting - procedure DrawEqualizer; - procedure ChangeMusic; - //Party Mode - procedure SelectRandomSong; - procedure SetJoker; - procedure SetStatics; - //procedures for Menu - procedure StartSong; - procedure OpenEditor; - procedure DoJoker(Team: Byte); - procedure SelectPlayers; - - procedure UnLoadDetailedCover; - - //Extensions - procedure DrawExtensions; - end; - -implementation -uses UGraphic, - UMain, - UCovers, - math, - OpenGL12, - {$IFDEF win32} - windows, - {$ELSE} - lclintf, - {$ENDIF} - 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 - 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; - - SongCurrent := I2; - SongTarget := I2; - end; - end; - -procedure TScreenSong.FixSelected2; -var I, I2: Integer; - begin - if CatSongs.VisibleSongs > 0 then - 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; - - SongTarget := I2; - 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; - 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, 'Plain', true); - - Static[StaticCat].Texture := Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', true); - //Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', false); - //Button[Cat]. - //Cover - - - //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 - - -// Method for input parsing. If False is returned, GetNextWindow -// should be checked to know the next window to load; -function TScreenSong.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; -var - I: integer; - I2: integer; - HS: integer; - SDL_ModState: Word; - Letter: Char; -begin - Result := true; - - //Song Screen Extensions (Jumpto + Menu) - if (ScreenSongMenu.Visible) then - begin - Result := ScreenSongMenu.ParseInput(PressedKey, ScanCode, PressedDown); - Exit; - end - else if (ScreenSongJumpto.Visible) then - begin - Result := ScreenSongJumpto.ParseInput(PressedKey, ScanCode, PressedDown); - Exit; - end; - - 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 = 0) AND (PressedKey >= SDLK_A) AND (PressedKey <= SDLK_Z) then - begin - Letter := UpCase(Chr(ScanCode)); - I2 := Length(CatSongs.Song); - - //Jump To Titel - if (SDL_ModState = KMOD_LALT or KMOD_LSHIFT) then - begin - 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 (UpCase(CatSongs.Song[(I + Interaction) mod I2].Title[1]) = Letter) then - begin - SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); - - Music.PlayChange; - - ChangeMusic; - SetScroll4; - UpdateLCD; - //Break and Exit - Exit; - end; - end; - end - //Jump to Artist - else if (SDL_ModState = KMOD_LALT) then - begin - 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 (UpCase(CatSongs.Song[(I + Interaction) mod I2].Artist[1]) = Letter) then - begin - SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); - - Music.PlayChange; - - ChangeMusic; - SetScroll4; - UpdateLCD; - - //Break and Exit - Exit; - end; - end; - end; - Exit; - end; - - case PressedKey of - SDLK_Q: - begin - Result := false; - end; - - SDLK_ESCAPE, - SDLK_BACKSPACE : - begin - if (Mode = 0) 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 - 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 - Music.Stop; - - CatSongs.ShowCategoryList; - - //Show Cat in Top Left Mod - HideCatTL; - - - //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); - - //Show Cat in Top Left Mod - HideCatTL; - Interaction := 0; - - //Show Wrong Song when Tabs on Fix - SelectNext; - FixSelected; - - ChangeMusic; - end - else - begin - Music.Stop; - Music.PlayBack; - - FadeTo(@ScreenMain); - end; - - end; - end - //When in party Mode then Ask before Close - else if (Mode = 1) then - begin - Music.PlayBack; - CheckFadeTo(@ScreenMain,'MSG_END_PARTY'); - end; - end; - SDLK_RETURN: - begin - if Length(Songs.Song) > 0 then - begin - {$IFDEF UseSerialPort} - // PortWriteB($378, 0); - {$ENDIF} - if CatSongs.Song[Interaction].Main then - begin // clicked on Category Button - - //Show Cat in Top Left Mod - ShowCatTL (Interaction); - - //I := CatSongs.VisibleIndex(Interaction); - CatSongs.ClickCategoryButton(Interaction); - {I2 := CatSongs.VisibleIndex(Interaction); - SongCurrent := SongCurrent - I + I2; - SongTarget := SongTarget - I + I2; } - -// if I<>I2 then beep; - // SetScroll4; - - //Show Wrong Song when Tabs on Fix - SelectNext; - FixSelected; - - //Play Music: - ChangeMusic; - - end else begin // clicked on song - if (Mode = 0) then //Normal Mode -> Start Song - begin - //Do the Action that is specified in Ini - case Ini.OnSongClick of - 0: StartSong; - 1: SelectPlayers; - 2:begin - If (CatSongs.CatNumShow = -3) then - ScreenSongMenu.MenuShow(SM_Playlist) - else - ScreenSongMenu.MenuShow(SM_Main); - end; - end; - end - else if (Mode = 1) then //PartyMode -> Show Menu - begin - if (Ini.PartyPopup = 1) then - ScreenSongMenu.MenuShow(SM_Party_Main) - else - ScreenSong.StartSong; - end; - end; - end; - end; - - SDLK_M: //Show SongMenu - begin - if (Length(Songs.Song) > 0) then begin - if (Mode = 0) then begin - if not CatSongs.Song[Interaction].Main then begin // clicked on Song - if CatSongs.CatNumShow = -3 then - ScreenSongMenu.MenuShow(SM_Playlist) - else - ScreenSongMenu.MenuShow(SM_Main); - end - else - begin - ScreenSongMenu.MenuShow(SM_Playlist_Load); - end; - end //Party Mode -> Show Party Menu - else ScreenSongMenu.MenuShow(SM_Party_Main); - end; - end; - - SDLK_P: //Show Playlist Menu - begin - if (Length(Songs.Song) > 0) AND (Mode = 0) then begin - ScreenSongMenu.MenuShow(SM_Playlist_Load); - end; - end; - - SDLK_J: //Show Jumpto Menu - begin - if (Length(Songs.Song) > 0) AND (Mode = 0) then - begin - ScreenSongJumpto.Visible := True; - end; - end; - - SDLK_DOWN: - begin - if (Mode = 0) then - begin - //Only Change Cat when not in Playlist or Search Mode - if (CatSongs.CatNumShow > -2) then - begin - //Cat Change Hack - if Ini.Tabs_at_startup = 1 then - begin - I := Interaction; - if I <= 0 then I := 1; - - while not catsongs.Song[I].Main do - begin - Inc (I); - if (I > high(catsongs.Song)) then - I := low(catsongs.Song); - end; - - Interaction := I; - - //Show Cat in Top Left Mod - ShowCatTL (Interaction); - - CatSongs.ClickCategoryButton(Interaction); - SelectNext; - FixSelected; - - //Play Music: - Music.PlayChange; - ChangeMusic; - - end; - - // - //Cat Change Hack End} - end; - end; - end; - SDLK_UP: - begin - if (Mode = 0) then - begin - //Only Change Cat when not in Playlist or Search Mode - if (CatSongs.CatNumShow > -2) then - begin - //Cat Change Hack - if Ini.Tabs_at_startup = 1 then - begin - I := Interaction; - I2 := 0; - if I <= 0 then I := 1; - - 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; - - Interaction := I; - - //Show Cat in Top Left Mod - ShowCatTL (I); - - CatSongs.ClickCategoryButton(I); - SelectNext; - FixSelected; - - //Play Music: - Music.PlayChange; - ChangeMusic; - end; - end; - //Cat Change Hack End} - end; - end; - - SDLK_RIGHT: - begin - if (Length(Songs.Song) > 0) AND (Mode = 0) then begin - Music.PlayChange; - SelectNext; -// InteractNext; -// SongTarget := Interaction; - ChangeMusic; - SetScroll4; - UpdateLCD; - Light.LightOne(1, 200); - end; - end; - - SDLK_LEFT: - begin - if (Length(Songs.Song) > 0)AND (Mode = 0) then begin - Music.PlayChange; - SelectPrev; - ChangeMusic; - SetScroll4; - UpdateLCD; - Light.LightOne(0, 200); - end; - end; - - SDLK_E: - begin - OpenEditor; - end; - - SDLK_R: - begin - if (Length(Songs.Song) > 0) AND (Mode = 0) 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 := 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 - begin - //Show Cat in Top Left Mod - ShowCatTL (I); - - Interaction := I; - - 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 - begin - 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 - begin - if CatSongs.Song[I].Main then - break; - end; - //In I ist jetzt die Kategorie in I2 der Song - - //Choose Cat - CatSongs.ShowCategoryList; - - //Show Cat in Top Left Mod - ShowCatTL (I); - - CatSongs.ClickCategoryButton(I); - SelectNext; - - //Fix: Not Existing Song selected: - //if (I+1=I2) then Inc(I2); - - //Choose Song - SkipTo(I2-I); - - end - else //Random in one Category - begin - SkipTo(Random(CatSongs.VisibleSongs)); - end; - Music.PlayChange; - - ChangeMusic; - SetScroll4; - UpdateLCD; - end; - end; - - SDLK_1: - begin //Jocker - if (Mode = 1) AND (PartySession.Teams.NumTeams >= 1) AND (PartySession.Teams.Teaminfo[0].Joker > 0) then - begin - //Joker spielen - Dec(PartySession.Teams.Teaminfo[0].Joker); - SelectRandomSong; - SetJoker; - end; - end; - - SDLK_2: - begin //Jocker - if (Mode = 1) AND (PartySession.Teams.NumTeams >= 2) AND (PartySession.Teams.Teaminfo[1].Joker > 0) then - begin - //Joker spielen - Dec(PartySession.Teams.Teaminfo[1].Joker); - SelectRandomSong; - SetJoker; - end; - end; - - SDLK_3: - begin //Jocker - if (Mode = 1) AND (PartySession.Teams.NumTeams >= 3) AND (PartySession.Teams.Teaminfo[2].Joker > 0) then - begin - //Joker spielen - Dec(PartySession.Teams.Teaminfo[2].Joker); - SelectRandomSong; - SetJoker; - end; - end; - end; - end; -end; - -constructor TScreenSong.Create; -var - Pet: integer; - I: integer; -Label CreateSongButtons; -begin - inherited Create; - - LoadFromTheme(Theme.Song); - - TextArtist := AddText(Theme.Song.TextArtist); - TextTitle := AddText(Theme.Song.TextTitle); - TextNumber := AddText(Theme.Song.TextNumber); - - //Show Cat in Top Left mod - TextCat := AddText(Theme.Song.TextCat); - StaticCat := AddStatic(Theme.Song.StaticCat); - - //Show Video Icon Mod - VideoIcon := AddStatic(Theme.Song.VideoIcon); - - //Party Mode - StaticTeam1Joker1 := AddStatic(Theme.Song.StaticTeam1Joker1); - StaticTeam1Joker2 := AddStatic(Theme.Song.StaticTeam1Joker2); - StaticTeam1Joker3 := AddStatic(Theme.Song.StaticTeam1Joker3); - StaticTeam1Joker4 := AddStatic(Theme.Song.StaticTeam1Joker4); - StaticTeam1Joker5 := AddStatic(Theme.Song.StaticTeam1Joker5); - - StaticTeam2Joker1 := AddStatic(Theme.Song.StaticTeam2Joker1); - StaticTeam2Joker2 := AddStatic(Theme.Song.StaticTeam2Joker2); - StaticTeam2Joker3 := AddStatic(Theme.Song.StaticTeam2Joker3); - StaticTeam2Joker4 := AddStatic(Theme.Song.StaticTeam2Joker4); - StaticTeam2Joker5 := AddStatic(Theme.Song.StaticTeam2Joker5); - - StaticTeam3Joker1 := AddStatic(Theme.Song.StaticTeam3Joker1); - StaticTeam3Joker2 := AddStatic(Theme.Song.StaticTeam3Joker2); - StaticTeam3Joker3 := AddStatic(Theme.Song.StaticTeam3Joker3); - StaticTeam3Joker4 := AddStatic(Theme.Song.StaticTeam3Joker4); - StaticTeam3Joker5 := AddStatic(Theme.Song.StaticTeam3Joker5); - - //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]); - - SetLength(TextParty, Length(Theme.Song.TextParty)); - 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]); - - SetLength(TextNonParty, Length(Theme.Song.TextNonParty)); - 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 - CatSongs.Refresh; - - 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)); - - I := 0; - CreateSongButtons: - - try - for Pet := I to High(CatSongs.Song) do begin // creating all buttons - // 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 - CatSongs.Song[Pet].Cover := ''; // 0.5.0: if cover not found then show 'no cover' - - if CatSongs.Song[Pet].Cover = '' then - AddButton(300 + Pet*250, 140, 200, 200, Skin.GetTextureFileName('SongCover'), 'JPG', '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 - begin - Texture.CreateCacheMipmap := true; - Texture.GetTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, '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); - - // unload full size texture - Texture.UnloadTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, 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, 'JPG', 'Plain', Theme.Song.Cover.Reflections); - end; - Texture.Limit := 1024*1024; - I := -1; - end; - except - //When Error is reported the First time for this Song - if (I <> Pet) then - begin - //Some Error reporting: - Log.LogError('Could not load Cover: ' + CatSongs.Song[Pet].Cover); - - //Change Cover to NoCover and Continue Loading - CatSongs.Song[Pet].Cover := ''; - I := Pet; - end - else //when Error occurs Multiple Times(NoSong Cover is damaged), then start loading next Song - begin - Log.LogError('NoCover Cover is damaged!'); - try - AddButton(300 + Pet*250, 140, 200, 200, '', 'JPG', 'Plain', Theme.Song.Cover.Reflections); - except - {$IFDEF win32} - Messagebox(0, PChar('No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'), PChar(Language.Translate('US_VERSION')), MB_ICONERROR or MB_OK); - {$ELSE} - // TODO : JB_linux - better handle this message and display to user.. - writeln( 'No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'); - Log.LogError( 'No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.' ); - {$ENDIF} - Halt; - end; - I := Pet + 1; - end; - end; - - if (I <> -1) then - GoTo CreateSongButtons; - - end; - - // Randomize Patch - Randomize; - //Equalizer - SetLength(EqualizerBands, Theme.Song.Equalizer.Bands); - //ClearArray - For I := low(EqualizerBands) to high(EqualizerBands) do - EqualizerBands[I] := 3; - - if (Length(CatSongs.Song) > 0) then - Interaction := 0; -end; - -procedure TScreenSong.SetScroll; -var - VS, B: Integer; -begin - VS := CatSongs.VisibleSongs; - if VS > 0 then - begin - //Set Positions - Case Theme.Song.Cover.Style of - 3: SetScroll3; - 5:begin - if VS > 5 then - SetScroll5 - else - SetScroll4; - end; - 6: SetScroll6; - else SetScroll4; - end; - //Set Visibility of Video Icon - Static[VideoIcon].Visible := (CatSongs.Song[Interaction].Video <> ''); - - //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 - 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') + ')'; - end - else if (CatSongs.CatNumShow = -2) then - Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) - else if (CatSongs.CatNumShow = -3) then - Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) - 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)); - 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; - - end; -end; - -procedure TScreenSong.SetScroll1; -var - B: integer; // button - BMin: integer; // button min - BMax: integer; // button max - Src: integer; -// Dst: integer; - Count: integer; // Dst is not used. Count is used. - Ready: boolean; - - VisCount: integer; // count of visible (or selectable) buttons - VisInt: integer; // visible position of interacted button - Typ: integer; // 0 when all songs fits the screen - Placed: integer; // number of placed visible buttons -begin -// Src := 0; -// Dst := -1; - Count := 1; - Typ := 0; - Ready := false; - Placed := 0; - - VisCount := 0; - 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); - - - if VisCount <= 6 then begin - Typ := 0; - end else begin - if VisInt <= 3 then begin - Typ := 1; - Count := 7; - Ready := true; - end; - - if (VisCount - VisInt) <= 3 then begin - Typ := 2; - Count := 7; - Ready := true; - end; - - if not Ready then begin - Typ := 3; - Src := Interaction; - end; - end; - - - - // hide all buttons - for B := 0 to High(Button) do begin - Button[B].Visible := false; - Button[B].Selectable := CatSongs.Song[B].Visible; - end; - -{ 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;} - - - if Typ = 0 then begin - for B := 0 to High(Button) do begin - if CatSongs.Song[B].Visible then begin - Button[B].Visible := true; - Button[B].Y := 140 + (Placed) * 60; - Inc(Placed); - end; - end; - end; - - if Typ = 1 then begin - B := 0; - while (Count > 0) do begin - if CatSongs.Song[B].Visible then begin - Button[B].Visible := true; - Button[B].Y := 140 + (Placed) * 60; - Inc(Placed); - Dec(Count); - end; - Inc(B); - end; - end; - - if Typ = 2 then begin - B := High(Button); - while (Count > 0) do begin - if CatSongs.Song[B].Visible then begin - Button[B].Visible := true; - Button[B].Y := 140 + (6-Placed) * 60; - Inc(Placed); - Dec(Count); - end; - Dec(B); - end; - end; - - if Typ = 3 then begin - B := Src; - Count := 4; - while (Count > 0) do begin - if CatSongs.Song[B].Visible then begin - Button[B].Visible := true; - Button[B].Y := 140 + (3+Placed) * 60; - Inc(Placed); - Dec(Count); - end; - Inc(B); - end; - - B := Src-1; - Placed := 0; - Count := 3; - while (Count > 0) do begin - if CatSongs.Song[B].Visible then begin - Button[B].Visible := true; - Button[B].Y := 140 + (2-Placed) * 60; - Inc(Placed); - Dec(Count); - end; - Dec(B); - end; - - end; - - if Length(Button) > 0 then - Static[1].Texture.Y := Button[Interaction].Y - 5; // selection texture -end; - -procedure TScreenSong.SetScroll2; -var - B: integer; - Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu - Wsp2: real; -begin - // liniowe - for B := 0 to High(Button) do - Button[B].X := 300 + (B - Interaction) * 260; - - 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; - - // kolowe -{ 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;} -end; - -procedure TScreenSong.SetScroll3; // with slide -var - B: integer; - Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu - Wsp2: real; -begin - SongTarget := Interaction; - - // liniowe - for B := 0 to High(Button) do - begin - Button[B].X := 300 + (B - SongCurrent) * 260; - if (Button[B].X < -Button[B].W) OR (Button[B].X > 800) then - Button[B].Visible := False - else - Button[B].Visible := True; - end; - -{ 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;} - - // kolowe -{ 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;} -end; - -procedure TScreenSong.SetScroll4; // rotate -var - B: integer; - Wsp: real; - Z, Z2: real; - VS: integer; -begin - VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important - - // kolowe - 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 - - 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; - - - Button[B].X := Theme.Song.Cover.X + (0.185 * Theme.Song.Cover.H * VS * sin(Wsp)) * Z2 - ((Button[B].H - Theme.Song.Cover.H)/2); // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs - Button[B].Z := Z / 2 + 0.3; - - 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].H := Button[B].W; - end; - end; -end; - -(* -procedure TScreenSong.SetScroll4; // rotate -var - B: integer; - Wsp: real; - Z: real; - Z2, Z3: real; - VS: integer; - function modreal (const X, Y: real):real; - begin - Result := Frac(x / y) * y; - if Result < -3 then - Result := Result + Y - else if Result > 3 then - Result := Result - Y; - end; -begin - VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important - Z3 := 1; - if VS < 12 then - Z2 := VS - else - Z2 := 12; - - // kolowe - 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 - begin - if CatSongs.VisibleIndex(B)> SongCurrent then - Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / Z2 - else - Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / Z2; - - Z3 := 2; - Z := (1 + cos(Wsp)) / 2; - //Z2 := (1 + 2*Z) / 3; - //Z2 := (0.5 + Z/2); - //Z2 := sin(Wsp); - - //Z2 := Power (Z2,Z3); - - Button[B].W := Theme.Song.CoverW * Power(cos(Wsp), Z3);//Power(Z2, 3); - - //Button[B].X := Theme.Song.CoverX + ({Theme.Song.CoverX + Theme.Song.CoverW/2 + Theme.Song.CoverW*0.18 * VS {CatSongs.VisibleSongs {Length(Button) * sin(Wsp) {- Theme.Song.CoverX - Theme.Song.CoverW) * Z2; // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs - if (sin(Wsp)<0) then - Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX + Theme.Song.CoverW - Button[B].W - else //*Theme.Song.CoverW*0.004*Z3 - 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 := (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 - begin - Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / 12 ;// 0.5.0 (II): takes another 16ms - - Z := (1 + cos(Wsp)) / 2 -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers - - Button[B].W := Theme.Song.CoverW * Power(cos(Wsp), Z3);//Power(Z2, 3); - - if (sin(Wsp)<0) then - Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX + Theme.Song.CoverW - Button[B].W - else - Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX; - - Button[B].Z := Z; - - Button[B].Y := (Theme.Song.CoverY + Theme.Song.CoverW - Button[B].W); - - Button[B].H := Button[B].W; - Button[B].Visible := True; - end - else Button[B].Visible := False; - end; - end; -end; *) - -procedure TScreenSong.SetScroll5; // rotate -var - B: integer; - Angle: real; - Pos: Real; - VS: integer; - diff: real; - X: Real; - helper: real; -begin - VS := CatSongs.VisibleSongs; // cache Visible Songs - {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 - Theme.Song.CoverH: Höhe der Cover - - (CatSongs.VisibleIndex(B) - SongCurrent)/VS = Abstand zum MIttleren Cover in % - } - - //Change Pos of all Buttons - for B := low(Button) to high(Button) do - begin - Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visibility - if Button[B].Visible then //Only Change Pos for Visible Buttons - begin - Pos := (CatSongs.VisibleIndex(B) - SongCurrent); - if (Pos < -VS/2) then - Pos := Pos + VS - else if (Pos > VS/2) then - Pos := Pos - VS; - - if (Abs(Pos) < 2.5) then {fixed Positions} - begin - Angle := Pi * (Pos / 5); -// 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].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; - - Button[B].Z := 0.95 - Abs(Pos) * 0.01; - - Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); - - Button[B].W := Button[B].H; - - Diff := (Button[B].H - Theme.Song.Cover.H)/2; - - - X := Sin(Angle*1.3)*0.9; - - Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * X - Diff; - - end - else - begin {Behind the Front Covers} - - // limit-bg-covers hack - if (abs(abs(Pos)-VS/2)>10) then Button[B].Visible:=False; - // end of limit-bg-covers hack - - if Pos < 0 then - Pos := (Pos - VS/2)/VS - else - Pos := (Pos + VS/2)/VS; - - Angle := pi * Pos*2; - if VS > 24 then - begin - if Angle < 0 then helper:=-1 else helper:=1; - Angle:=2*pi-abs(Angle); - Angle:=Angle*(VS/24); - Angle:=(2*pi-Angle)*helper; - end; - - Button[B].Z := (0.4 - Abs(Pos/4)) -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers - - Button[B].H :=0.6*(Theme.Song.Cover.H-Abs(Theme.Song.Cover.H * cos(Angle/2)*0.8));//Power(Z2, 3); - - Button[B].W := Button[B].H; - - 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].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; - - Diff := (Button[B].H - Theme.Song.Cover.H)/2; - - Button[B].X := Theme.Song.Cover.X+Theme.Song.Cover.H/2-Button[b].H/2+Theme.Song.Cover.W/320*((Theme.Song.Cover.H)*sin(Angle/2)*1.52); - - 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); - - end; - end; -end; - -procedure TScreenSong.SetScroll6; // rotate (slotmachine style) -var - B: integer; - Angle: real; - Pos: Real; - VS: integer; - diff: real; - X: Real; - Wsp: real; - Z, Z2: real; -begin - VS := CatSongs.VisibleSongs; // cache Visible Songs - if VS <=5 then begin - // kolowe - 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 - - 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; - - - Button[B].Y := Theme.Song.Cover.Y + (0.185 * Theme.Song.Cover.H * VS * sin(Wsp)) * Z2 - ((Button[B].H - Theme.Song.Cover.H)/2); // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs - Button[B].Z := Z / 2 + 0.3; - - Button[B].W := Theme.Song.Cover.H * 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; - end; - end - else begin - - //Change Pos of all Buttons - for B := low(Button) to high(Button) do - begin - Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visibility - if Button[B].Visible then //Only Change Pos for Visible Buttons - begin - Pos := (CatSongs.VisibleIndex(B) - SongCurrent); - if (Pos < -VS/2) then - Pos := Pos + VS - else if (Pos > VS/2) then - Pos := Pos - VS; - - if (Abs(Pos) < 2.5) then {fixed Positions} - begin - Angle := Pi * (Pos / 5); -// Button[B].Visible := False; - - Button[B].H := Abs(Theme.Song.Cover.H * cos(Angle*0.8));//Power(Z2, 3); - - Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; - - Button[B].Z := 0.95 - Abs(Pos) * 0.01; - - Button[B].X := (Theme.Song.Cover.X + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); - - Button[B].W := Button[B].H; - - Diff := (Button[B].H - Theme.Song.Cover.H)/2; - - - X := Sin(Angle*1.3)*0.9; - - Button[B].Y := Theme.Song.Cover.Y + Theme.Song.Cover.W * X - Diff; - end - else - begin {Behind the Front Covers} - - // limit-bg-covers hack - if (abs(VS/2-abs(Pos))>10) then Button[B].Visible:=False; - if VS > 25 then VS:=25; - // end of limit-bg-covers hack - - if Pos < 0 then - Pos := (Pos - VS/2)/VS - else - Pos := (Pos + VS/2)/VS; - - 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 - - Button[B].H :=0.6*(Theme.Song.Cover.H-Abs(Theme.Song.Cover.H * cos(Angle/2)*0.8));//Power(Z2, 3); - - Button[B].W := Button[B].H; - - Button[B].X := Theme.Song.Cover.X - (Button[B].H - Theme.Song.Cover.H)*0.5; - - - Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; - - Button[B].Y := Theme.Song.Cover.Y+Theme.Song.Cover.H/2-Button[b].H/2+Theme.Song.Cover.W/320*(Theme.Song.Cover.H*sin(Angle/2)*1.52); - end; - end; - end; - end; -end; - - -procedure TScreenSong.onShow; -begin - Music.Stop; - - if Ini.Players <= 3 then PlayersPlay := Ini.Players + 1; - 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 Length(CatSongs.Song) > 0 then begin - //Load Music only when Song Preview is activated - if (Ini.PreviewVolume <> 0) then - begin - Music.SetLoop(false); - Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); - Music.MoveTo(Music.Length / 4); - Music.Play; - - //Set Preview Volume - Music.SetMusicVolume (Ini.PreviewVolume * 10); - {//if Music Fade is activated, Set Volume to 0 % - if (Ini.PreviewFading <> 0) then - Music.SetMusicVolume(0);} - end; - - SetScroll; - UpdateLCD; - end; - - //Playlist Mode - if (Mode = 0) then - begin - //If Playlist Shown -> Select Next automatically - if (CatSongs.CatNumShow = -3) then - begin - SelectNext; - ChangeMusic; - end; - end - //Party Mode - else if (Mode = 1) then - begin - - SelectRandomSong; - //Show Menu directly in PartyMode - //But only if selected in Options - if (Ini.PartyPopup = 1) then - begin - ScreenSongMenu.MenuShow(SM_Party_Main); - end; - - - end; - - SetJoker; - SetStatics; -end; - -procedure TScreenSong.onHide; -begin - //When Music Fading is activated, Turn Music to 100 % - If (Ini.PreviewVolume <> 100) or (Ini.PreviewFading <> 0) then - Music.SetMusicVolume(100); - - //If Preview is deactivated: Load MUsicfile now - If (Ini.PreviewVolume = 0) then - Music.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 (Music <> nil) then - Music.Stop; -end; - -procedure TScreenSong.DrawExtensions; -begin - //Draw Song Menu - if (ScreenSongMenu.Visible) then - begin - ScreenSongMenu.Draw; - end - else if (ScreenSongJumpto.Visible) then - begin - ScreenSongJumpto.Draw; - end -end; - -function TScreenSong.Draw: boolean; -var - dx: real; - dt: real; - I: Integer; -begin - dx := SongTarget-SongCurrent; - dt := TimeSkip*7; - if dt > 1 then dt := 1; - SongCurrent := SongCurrent + dx*dt; - -{ if SongCurrent > Catsongs.VisibleSongs then begin - SongCurrent := SongCurrent - Catsongs.VisibleSongs; - SongTarget := SongTarget - Catsongs.VisibleSongs; - end;} - -// Log.BenchmarkStart(5); - SetScroll; -// Log.BenchmarkEnd(5); -// Log.LogBenchmark('SetScroll4', 5); - - //Fading Functions, Only if Covertime is under 5 Seconds - If (CoverTime < 5) then - begin - // 0.5.0: cover fade - if (CoverTime < 1) and (CoverTime + TimeSkip >= 1) then begin - // load new texture - Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); - Button[Interaction].Texture.Alpha := 1; - Button[Interaction].Texture2 := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); - Button[Interaction].Texture2.Alpha := 1; - end; - - //Song Fade - 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 - Music.Play; - - //Update Song Volume - if (CoverTime < Ini.PreviewFading) then - Music.SetMusicVolume(Round (CoverTime * Ini.PreviewVolume / Ini.PreviewFading * 10)) - else - Music.SetMusicVolume(Ini.PreviewVolume * 10); - - end; - - - //Update Fading Time - CoverTime := CoverTime + TimeSkip; - - //Update Fading Texture - Button[Interaction].Texture2.Alpha := (CoverTime - 1) * 1.5; - if Button[Interaction].Texture2.Alpha > 1 then Button[Interaction].Texture2.Alpha := 1; - - end; - - //inherited Draw; - //heres a little Hack, that causes the Statics - //are Drawn after the Buttons because of some Blending Problems. - //This should cause no Problems because all Buttons on this screen - //Has Z Position. - //Draw BG - DrawBG; - - //Instead of Draw FG Procedure: - //We draw Buttons for our own - for I := 0 to Length(Button) - 1 do - Button[I].Draw; - - // Statics - for I := 0 to Length(Static) - 1 do - Static[I].Draw; - - // and texts - for I := 0 to Length(Text) - 1 do - Text[I].Draw; - - - //Draw Equalizer - if Theme.Song.Equalizer.Visible then - DrawEqualizer; - - DrawExtensions; - -end; - -procedure TScreenSong.SelectNext; -var - Skip: integer; - I: integer; - VS: Integer; -begin - VS := CatSongs.VisibleSongs; - - if VS > 0 then - begin - UnLoadDetailedCover; - - Skip := 1; - - // this 1 could be changed by CatSongs.FindNextVisible - while (not CatSongs.Song[(Interaction + Skip) mod Length(Interactions)].Visible) do Inc(Skip); - - SongTarget := SongTarget + 1;//Skip; - - Interaction := (Interaction + Skip) mod Length(Interactions); - - // try to keep all at the beginning - if SongTarget > VS-1 then begin - SongTarget := SongTarget - VS; - SongCurrent := SongCurrent - VS; - end; - - end; - // Interaction -> Button, ktorego okladke przeczytamy - // Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture -end; - -procedure TScreenSong.SelectPrev; -var - Skip: integer; - I: integer; - VS: Integer; -begin - VS := CatSongs.VisibleSongs; - - if VS > 0 then - begin - UnLoadDetailedCover; - - Skip := 1; - - 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); - - // try to keep all at the beginning - if SongTarget < 0 then begin - SongTarget := SongTarget + CatSongs.VisibleSongs; - SongCurrent := SongCurrent + CatSongs.VisibleSongs; - end; - - // Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture - end; -end; - -procedure TScreenSong.UpdateLCD; -begin - LCD.HideCursor; - LCD.Clear; - LCD.WriteText(1, Text[TextArtist].Text); - LCD.WriteText(2, Text[TextTitle].Text); -end; - -//Procedure Change current played Preview -procedure TScreenSong.ChangeMusic; -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 - begin - Music.Close; - if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin - Music.MoveTo(Music.Length / 4); - //If Song Fading is activated then don't Play directly, and Set Volume to Null, else Play normal - if (Ini.PreviewFading = 0) then - Music.Play - else - Music.SetMusicVolume(0); - end; - end - else - Music.Stop; - end; -end; - -procedure TScreenSong.SkipTo(Target: Cardinal); // 0.5.0 -var - Skip: integer; - I: integer; -begin - UnLoadDetailedCover; - - Interaction := High(CatSongs.Song); - SongTarget := 0; - - for I := 1 to Target+1 do - SelectNext; - - FixSelected2; -end; - -procedure TScreenSong.DrawEqualizer; -var - Data: TFFTData; //Audio Data - I, J: Integer; - Res: byte; - A, B: Integer; - PosX, PosY: Integer; - Pos: Real; -begin -if (not Music.Finished) AND (Theme.Song.Equalizer.Length > 0) then -begin - - - A := GetTickCount div 44; - - if (A <> EqualizerTime) then - begin - EqualizerTime := A; - Data := Music.GetFFTData; - - B:=0; - Pos := 0; - Res := ceil(92/Theme.Song.Equalizer.Bands);//How much channels are used for one Band - - //Change Lengths - for I := 0 to (Res * Theme.Song.Equalizer.Bands - 1) do - begin - A := floor(I/Res); - - if (A<>B) then //Band changed - begin - if (Pos <= Theme.Song.Equalizer.Length) then - begin - if ((Pos < EqualizerBands[B]) AND (EqualizerBands[B]>1)) then - EqualizerBands[B] := EqualizerBands[B] - 1 - else - EqualizerBands[B] := floor(Pos); - end - else - EqualizerBands[B] := 1; - - B := A; - Pos := 0; - end; - - if I > 35 then - Data[i] := Data[i] * 8 - else if I > 11 then - Data[i] := Data[i] * 4.5 - else - Data[i] := Data[i] * 1.1; - - if (Data[i] >= 1) then - Data[i] := 0.9999999999999; - - if Data[i]*Theme.Song.Equalizer.Length > Pos then - Pos := Data[i]*Theme.Song.Equalizer.Length; - end; - - //Change Last Band - if (EqualizerBands[B] <= Theme.Song.Equalizer.Length) then - begin - if ((Pos < EqualizerBands[B]) AND (EqualizerBands[B]>1)) then - EqualizerBands[B] := EqualizerBands[B] - 1 - else - EqualizerBands[B] := floor(Pos) - end - else - EqualizerBands[B] := 1; - end; - - //Draw every Channel - glColor4f(Theme.Song.Equalizer.ColR, Theme.Song.Equalizer.ColG, Theme.Song.Equalizer.ColB, Theme.Song.Equalizer.Alpha); //Set Color - glDisable(GL_TEXTURE_2D); - glEnable(GL_BLEND); - - PosY := Theme.Song.Equalizer.Y; - PosX := Theme.Song.Equalizer.X; - - For I := 0 to Theme.Song.Equalizer.Bands-1 do - begin - if Theme.Song.Equalizer.Direction then - PosY := Theme.Song.Equalizer.Y //+ (Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space) * Theme.Song.Equalizer.Length - else - PosX := Theme.Song.Equalizer.X; - //Draw for every visible quad - for J := 1 to EqualizerBands[I] do - begin - glBegin(GL_QUADS); - glVertex3f(PosX, PosY, Theme.Song.Equalizer.Z); - glVertex3f(PosX, PosY+Theme.Song.Equalizer.H, Theme.Song.Equalizer.Z); - glVertex3f(PosX+Theme.Song.Equalizer.W, PosY+Theme.Song.Equalizer.H, Theme.Song.Equalizer.Z); - glVertex3f(PosX+Theme.Song.Equalizer.W, PosY, Theme.Song.Equalizer.Z); - glEnd; - - if Theme.Song.Equalizer.Direction then //Vertically - PosY := PosY - Theme.Song.Equalizer.H - Theme.Song.Equalizer.Space - else //Horizontally - PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space; - end; - if Theme.Song.Equalizer.Direction then //Horizontally - PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space - else //Vertically - PosY := PosY + Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space; - end; -end; -end; - -Procedure TScreenSong.SelectRandomSong; -var - I, I2: Integer; -begin - Case PlaylistMan.Mode of - 0: //All Songs Just Select Random Song - begin - //When Tabs are activated then use Tab Method - if (Ini.Tabs_at_startup = 1) then - begin - 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 - begin - if CatSongs.Song[I].Main then - break; - 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 - - //Choose Cat - CatSongs.ShowCategoryList; - - //Show Cat in Top Left Mod - ShowCatTL (I); - - CatSongs.ClickCategoryButton(I); - SelectNext; - - //Choose Song - SkipTo(I2-I); - end - //When Tabs are deactivated use easy Method - else - SkipTo(Random(CatSongs.VisibleSongs)); - end; - 1: //One Category Select Category and Select Random Song - begin - CatSongs.ShowCategoryList; - CatSongs.ClickCategoryButton(PlaylistMan.CurPlayList); - ShowCatTL(PlaylistMan.CurPlayList); - - SelectNext; - FixSelected2; - - SkipTo(Random(CatSongs.VisibleSongs)); - end; - 2: //Playlist: Select Playlist and Select Random Song - begin - PlaylistMan.SetPlayList(PlaylistMan.CurPlayList); - - SkipTo(Random(CatSongs.VisibleSongs)); - FixSelected2; - end; - end; - - Music.PlayChange; - ChangeMusic; - SetScroll; - UpdateLCD; -end; - -procedure TScreenSong.SetJoker; -begin - //If Party Mode - if Mode = 1 then //Show Joker that are available - begin - if (PartySession.Teams.NumTeams >= 1) then - begin - Static[StaticTeam1Joker1].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 1); - Static[StaticTeam1Joker2].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 2); - Static[StaticTeam1Joker3].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 3); - Static[StaticTeam1Joker4].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 4); - Static[StaticTeam1Joker5].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 5); - end - else - begin - Static[StaticTeam1Joker1].Visible := False; - Static[StaticTeam1Joker2].Visible := False; - Static[StaticTeam1Joker3].Visible := False; - Static[StaticTeam1Joker4].Visible := False; - Static[StaticTeam1Joker5].Visible := False; - end; - - if (PartySession.Teams.NumTeams >= 2) then - begin - Static[StaticTeam2Joker1].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 1); - Static[StaticTeam2Joker2].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 2); - Static[StaticTeam2Joker3].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 3); - Static[StaticTeam2Joker4].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 4); - Static[StaticTeam2Joker5].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 5); - end - else - begin - Static[StaticTeam2Joker1].Visible := False; - Static[StaticTeam2Joker2].Visible := False; - Static[StaticTeam2Joker3].Visible := False; - Static[StaticTeam2Joker4].Visible := False; - Static[StaticTeam2Joker5].Visible := False; - end; - - if (PartySession.Teams.NumTeams >= 3) then - begin - Static[StaticTeam3Joker1].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 1); - Static[StaticTeam3Joker2].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 2); - Static[StaticTeam3Joker3].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 3); - Static[StaticTeam3Joker4].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 4); - Static[StaticTeam3Joker5].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 5); - end - else - begin - Static[StaticTeam3Joker1].Visible := False; - Static[StaticTeam3Joker2].Visible := False; - Static[StaticTeam3Joker3].Visible := False; - Static[StaticTeam3Joker4].Visible := False; - Static[StaticTeam3Joker5].Visible := False; - end; - end - else - begin //Hide all - Static[StaticTeam1Joker1].Visible := False; - Static[StaticTeam1Joker2].Visible := False; - Static[StaticTeam1Joker3].Visible := False; - Static[StaticTeam1Joker4].Visible := False; - Static[StaticTeam1Joker5].Visible := False; - - Static[StaticTeam2Joker1].Visible := False; - Static[StaticTeam2Joker2].Visible := False; - Static[StaticTeam2Joker3].Visible := False; - Static[StaticTeam2Joker4].Visible := False; - Static[StaticTeam2Joker5].Visible := False; - - Static[StaticTeam3Joker1].Visible := False; - Static[StaticTeam3Joker2].Visible := False; - Static[StaticTeam3Joker3].Visible := False; - Static[StaticTeam3Joker4].Visible := False; - Static[StaticTeam3Joker5].Visible := False; - end; -end; - -procedure TScreenSong.SetStatics; -var - I: Integer; - Visible: Boolean; -begin - //Set Visibility of Party Statics and Text - Visible := (Mode = 1); - - For I := 0 to high(StaticParty) do - Static[StaticParty[I]].Visible := Visible; - - 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 - Static[StaticNonParty[I]].Visible := Visible; - - For I := 0 to high(TextNonParty) do - Text[TextNonParty[I]].Visible := Visible; -end; - -//Procedures for Menu - -procedure TScreenSong.StartSong; -begin - CatSongs.Selected := Interaction; - Music.Stop; - //Party Mode - if (Mode = 1) then - begin - FadeTo(@ScreenSingModi); - end - else - begin - FadeTo(@ScreenSing); - end; -end; - -procedure TScreenSong.SelectPlayers; -begin - CatSongs.Selected := Interaction; - Music.Stop; - - ScreenName.Goto_SingScreen := True; - FadeTo(@ScreenName); -end; - -procedure TScreenSong.OpenEditor; -begin - if (Length(Songs.Song) > 0) and (not CatSongs.Song[Interaction].Main) AND (Mode = 0) then begin - Music.Stop; - Music.PlayStart; - ScreenEditSub.Path := CatSongs.Song[Interaction].Path; - ScreenEditSub.FileName := CatSongs.Song[Interaction].FileName; - FadeTo(@ScreenEditSub); - end; -end; - -//Team No of Team (0-5) -procedure TScreenSong.DoJoker (Team: Byte); -begin - if (Mode = 1) AND (PartySession.Teams.NumTeams >= Team + 1) AND (PartySession.Teams.Teaminfo[Team].Joker > 0) then - begin - //Joker spielen - Dec(PartySession.Teams.Teaminfo[Team].Joker); - SelectRandomSong; - SetJoker; - 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, 'Plain', true); // 0.5.0: show cached texture - Button[Interaction].Texture2.Alpha := 0; - - if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then - Texture.UnloadTexture(Button[Interaction].Texture.Name, false); -end; - -procedure TScreenSong.Refresh; -begin { -CatSongs.Refresh; -CatSongs.ShowCategoryList; -Interaction := 0; -SelectNext; -FixSelected; } - -end; - -end. +unit UScreenSong; + +interface +{$I switches.inc} + + +{$IFDEF FPC} + {$MODE DELPHI} +{$ENDIF} + + +uses + UMenu, + SDL, + UMusic, + UFiles, + UTime, + UDisplay, + USongs, + SysUtils, + ULog, + UThemes, + UTexture, + ULanguage, + ULCD, + ULight, + UIni; + +type + TScreenSong = class(TMenu) + public + TextArtist: integer; + TextTitle: integer; + TextNumber: integer; + + //Video Icon Mod + VideoIcon: Cardinal; + + TextCat: integer; + StaticCat: integer; + + SongCurrent: real; + SongTarget: real; + + HighSpeed: boolean; + CoverFull: boolean; + CoverTime: real; + CoverX: integer; + CoverY: integer; + CoverW: integer; + is_jump: boolean; // Jump to Song Mod + is_jump_title:boolean; //Jump to SOng MOd-YTrue if search for Title + + EqualizerBands: array of Byte; + EqualizerTime: Cardinal; + EqualizerTime2: Byte; + + //Party Mod + Mode: Byte; //0 = Standard, 1= Go to PartyMode after Selection + Change to Random Song at Show + //party Statics (Joker) + StaticTeam1Joker1: Cardinal; + StaticTeam1Joker2: Cardinal; + StaticTeam1Joker3: Cardinal; + StaticTeam1Joker4: Cardinal; + StaticTeam1Joker5: Cardinal; + + StaticTeam2Joker1: Cardinal; + StaticTeam2Joker2: Cardinal; + StaticTeam2Joker3: Cardinal; + StaticTeam2Joker4: Cardinal; + StaticTeam2Joker5: Cardinal; + + StaticTeam3Joker1: Cardinal; + StaticTeam3Joker2: Cardinal; + StaticTeam3Joker3: Cardinal; + StaticTeam3Joker4: Cardinal; + StaticTeam3Joker5: Cardinal; + + StaticParty: Array of Cardinal; + TextParty: Array of Cardinal; + StaticNonParty: Array of Cardinal; + TextNonParty: Array of Cardinal; + + + constructor Create; override; + procedure SetScroll; + procedure SetScroll1; + procedure SetScroll2; + procedure SetScroll3; + procedure SetScroll4; + procedure SetScroll5; + procedure SetScroll6; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + function Draw: boolean; override; + procedure onShow; override; + procedure onHide; override; + procedure SelectNext; + procedure SelectPrev; + procedure UpdateLCD; + procedure SkipTo(Target: Cardinal); + procedure FixSelected; //Show Wrong Song when Tabs on Fix + procedure FixSelected2; //Show Wrong Song when Tabs on Fix + procedure ShowCatTL(Cat: Integer);// Show Cat in Top left + procedure ShowCatTLCustom(Caption: String);// Show Custom Text in Top left + procedure HideCatTL;// Show Cat in Tob left + procedure Refresh; //Refresh Song Sorting + procedure DrawEqualizer; + procedure ChangeMusic; + //Party Mode + procedure SelectRandomSong; + procedure SetJoker; + procedure SetStatics; + //procedures for Menu + procedure StartSong; + procedure OpenEditor; + procedure DoJoker(Team: Byte); + procedure SelectPlayers; + + procedure UnLoadDetailedCover; + + //Extensions + procedure DrawExtensions; + end; + +implementation +uses UGraphic, + UMain, + UCovers, + math, + OpenGL12, + {$IFDEF win32} + windows, + {$ELSE} + lclintf, + {$ENDIF} + 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 + 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; + + SongCurrent := I2; + SongTarget := I2; + end; + end; + +procedure TScreenSong.FixSelected2; +var I, I2: Integer; + begin + if CatSongs.VisibleSongs > 0 then + 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; + + SongTarget := I2; + 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; + 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, 'Plain', true); + + Static[StaticCat].Texture := Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', true); + //Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', false); + //Button[Cat]. + //Cover + + + //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 + + +// Method for input parsing. If False is returned, GetNextWindow +// should be checked to know the next window to load; +function TScreenSong.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +var + I: integer; + I2: integer; + HS: integer; + SDL_ModState: Word; + Letter: Char; +begin + Result := true; + + //Song Screen Extensions (Jumpto + Menu) + if (ScreenSongMenu.Visible) then + begin + Result := ScreenSongMenu.ParseInput(PressedKey, ScanCode, PressedDown); + Exit; + end + else if (ScreenSongJumpto.Visible) then + begin + Result := ScreenSongJumpto.ParseInput(PressedKey, ScanCode, PressedDown); + Exit; + end; + + 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 = 0) AND (PressedKey >= SDLK_A) AND (PressedKey <= SDLK_Z) then + begin + Letter := UpCase(Chr(ScanCode)); + I2 := Length(CatSongs.Song); + + //Jump To Titel + if (SDL_ModState = KMOD_LALT or KMOD_LSHIFT) then + begin + 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 (UpCase(CatSongs.Song[(I + Interaction) mod I2].Title[1]) = Letter) then + begin + SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); + + Music.PlayChange; + + ChangeMusic; + SetScroll4; + UpdateLCD; + //Break and Exit + Exit; + end; + end; + end + //Jump to Artist + else if (SDL_ModState = KMOD_LALT) then + begin + 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 (UpCase(CatSongs.Song[(I + Interaction) mod I2].Artist[1]) = Letter) then + begin + SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); + + Music.PlayChange; + + ChangeMusic; + SetScroll4; + UpdateLCD; + + //Break and Exit + Exit; + end; + end; + end; + Exit; + end; + + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + if (Mode = 0) 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 + 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 + Music.Stop; + + CatSongs.ShowCategoryList; + + //Show Cat in Top Left Mod + HideCatTL; + + + //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); + + //Show Cat in Top Left Mod + HideCatTL; + Interaction := 0; + + //Show Wrong Song when Tabs on Fix + SelectNext; + FixSelected; + + ChangeMusic; + end + else + begin + Music.Stop; + Music.PlayBack; + + FadeTo(@ScreenMain); + end; + + end; + end + //When in party Mode then Ask before Close + else if (Mode = 1) then + begin + Music.PlayBack; + CheckFadeTo(@ScreenMain,'MSG_END_PARTY'); + end; + end; + SDLK_RETURN: + begin + if Length(Songs.Song) > 0 then + begin + {$IFDEF UseSerialPort} + // PortWriteB($378, 0); + {$ENDIF} + if CatSongs.Song[Interaction].Main then + begin // clicked on Category Button + + //Show Cat in Top Left Mod + ShowCatTL (Interaction); + + //I := CatSongs.VisibleIndex(Interaction); + CatSongs.ClickCategoryButton(Interaction); + {I2 := CatSongs.VisibleIndex(Interaction); + SongCurrent := SongCurrent - I + I2; + SongTarget := SongTarget - I + I2; } + +// if I<>I2 then beep; + // SetScroll4; + + //Show Wrong Song when Tabs on Fix + SelectNext; + FixSelected; + + //Play Music: + ChangeMusic; + + end else begin // clicked on song + if (Mode = 0) then //Normal Mode -> Start Song + begin + //Do the Action that is specified in Ini + case Ini.OnSongClick of + 0: StartSong; + 1: SelectPlayers; + 2:begin + If (CatSongs.CatNumShow = -3) then + ScreenSongMenu.MenuShow(SM_Playlist) + else + ScreenSongMenu.MenuShow(SM_Main); + end; + end; + end + else if (Mode = 1) then //PartyMode -> Show Menu + begin + if (Ini.PartyPopup = 1) then + ScreenSongMenu.MenuShow(SM_Party_Main) + else + ScreenSong.StartSong; + end; + end; + end; + end; + + SDLK_M: //Show SongMenu + begin + if (Length(Songs.Song) > 0) then begin + if (Mode = 0) then begin + if not CatSongs.Song[Interaction].Main then begin // clicked on Song + if CatSongs.CatNumShow = -3 then + ScreenSongMenu.MenuShow(SM_Playlist) + else + ScreenSongMenu.MenuShow(SM_Main); + end + else + begin + ScreenSongMenu.MenuShow(SM_Playlist_Load); + end; + end //Party Mode -> Show Party Menu + else ScreenSongMenu.MenuShow(SM_Party_Main); + end; + end; + + SDLK_P: //Show Playlist Menu + begin + if (Length(Songs.Song) > 0) AND (Mode = 0) then begin + ScreenSongMenu.MenuShow(SM_Playlist_Load); + end; + end; + + SDLK_J: //Show Jumpto Menu + begin + if (Length(Songs.Song) > 0) AND (Mode = 0) then + begin + ScreenSongJumpto.Visible := True; + end; + end; + + SDLK_DOWN: + begin + if (Mode = 0) then + begin + //Only Change Cat when not in Playlist or Search Mode + if (CatSongs.CatNumShow > -2) then + begin + //Cat Change Hack + if Ini.Tabs_at_startup = 1 then + begin + I := Interaction; + if I <= 0 then I := 1; + + while not catsongs.Song[I].Main do + begin + Inc (I); + if (I > high(catsongs.Song)) then + I := low(catsongs.Song); + end; + + Interaction := I; + + //Show Cat in Top Left Mod + ShowCatTL (Interaction); + + CatSongs.ClickCategoryButton(Interaction); + SelectNext; + FixSelected; + + //Play Music: + Music.PlayChange; + ChangeMusic; + + end; + + // + //Cat Change Hack End} + end; + end; + end; + SDLK_UP: + begin + if (Mode = 0) then + begin + //Only Change Cat when not in Playlist or Search Mode + if (CatSongs.CatNumShow > -2) then + begin + //Cat Change Hack + if Ini.Tabs_at_startup = 1 then + begin + I := Interaction; + I2 := 0; + if I <= 0 then I := 1; + + 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; + + Interaction := I; + + //Show Cat in Top Left Mod + ShowCatTL (I); + + CatSongs.ClickCategoryButton(I); + SelectNext; + FixSelected; + + //Play Music: + Music.PlayChange; + ChangeMusic; + end; + end; + //Cat Change Hack End} + end; + end; + + SDLK_RIGHT: + begin + if (Length(Songs.Song) > 0) AND (Mode = 0) then begin + Music.PlayChange; + SelectNext; +// InteractNext; +// SongTarget := Interaction; + ChangeMusic; + SetScroll4; + UpdateLCD; + Light.LightOne(1, 200); + end; + end; + + SDLK_LEFT: + begin + if (Length(Songs.Song) > 0)AND (Mode = 0) then begin + Music.PlayChange; + SelectPrev; + ChangeMusic; + SetScroll4; + UpdateLCD; + Light.LightOne(0, 200); + end; + end; + + SDLK_E: + begin + OpenEditor; + end; + + SDLK_R: + begin + if (Length(Songs.Song) > 0) AND (Mode = 0) 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 := 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 + begin + //Show Cat in Top Left Mod + ShowCatTL (I); + + Interaction := I; + + 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 + begin + 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 + begin + if CatSongs.Song[I].Main then + break; + end; + //In I ist jetzt die Kategorie in I2 der Song + + //Choose Cat + CatSongs.ShowCategoryList; + + //Show Cat in Top Left Mod + ShowCatTL (I); + + CatSongs.ClickCategoryButton(I); + SelectNext; + + //Fix: Not Existing Song selected: + //if (I+1=I2) then Inc(I2); + + //Choose Song + SkipTo(I2-I); + + end + else //Random in one Category + begin + SkipTo(Random(CatSongs.VisibleSongs)); + end; + Music.PlayChange; + + ChangeMusic; + SetScroll4; + UpdateLCD; + end; + end; + + SDLK_1: + begin //Jocker + if (Mode = 1) AND (PartySession.Teams.NumTeams >= 1) AND (PartySession.Teams.Teaminfo[0].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[0].Joker); + SelectRandomSong; + SetJoker; + end; + end; + + SDLK_2: + begin //Jocker + if (Mode = 1) AND (PartySession.Teams.NumTeams >= 2) AND (PartySession.Teams.Teaminfo[1].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[1].Joker); + SelectRandomSong; + SetJoker; + end; + end; + + SDLK_3: + begin //Jocker + if (Mode = 1) AND (PartySession.Teams.NumTeams >= 3) AND (PartySession.Teams.Teaminfo[2].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[2].Joker); + SelectRandomSong; + SetJoker; + end; + end; + end; + end; +end; + +constructor TScreenSong.Create; +var + Pet: integer; + I: integer; +Label CreateSongButtons; +begin + inherited Create; + + LoadFromTheme(Theme.Song); + + TextArtist := AddText(Theme.Song.TextArtist); + TextTitle := AddText(Theme.Song.TextTitle); + TextNumber := AddText(Theme.Song.TextNumber); + + //Show Cat in Top Left mod + TextCat := AddText(Theme.Song.TextCat); + StaticCat := AddStatic(Theme.Song.StaticCat); + + //Show Video Icon Mod + VideoIcon := AddStatic(Theme.Song.VideoIcon); + + //Party Mode + StaticTeam1Joker1 := AddStatic(Theme.Song.StaticTeam1Joker1); + StaticTeam1Joker2 := AddStatic(Theme.Song.StaticTeam1Joker2); + StaticTeam1Joker3 := AddStatic(Theme.Song.StaticTeam1Joker3); + StaticTeam1Joker4 := AddStatic(Theme.Song.StaticTeam1Joker4); + StaticTeam1Joker5 := AddStatic(Theme.Song.StaticTeam1Joker5); + + StaticTeam2Joker1 := AddStatic(Theme.Song.StaticTeam2Joker1); + StaticTeam2Joker2 := AddStatic(Theme.Song.StaticTeam2Joker2); + StaticTeam2Joker3 := AddStatic(Theme.Song.StaticTeam2Joker3); + StaticTeam2Joker4 := AddStatic(Theme.Song.StaticTeam2Joker4); + StaticTeam2Joker5 := AddStatic(Theme.Song.StaticTeam2Joker5); + + StaticTeam3Joker1 := AddStatic(Theme.Song.StaticTeam3Joker1); + StaticTeam3Joker2 := AddStatic(Theme.Song.StaticTeam3Joker2); + StaticTeam3Joker3 := AddStatic(Theme.Song.StaticTeam3Joker3); + StaticTeam3Joker4 := AddStatic(Theme.Song.StaticTeam3Joker4); + StaticTeam3Joker5 := AddStatic(Theme.Song.StaticTeam3Joker5); + + //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]); + + SetLength(TextParty, Length(Theme.Song.TextParty)); + 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]); + + SetLength(TextNonParty, Length(Theme.Song.TextNonParty)); + 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 + CatSongs.Refresh; + + 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)); + + I := 0; + CreateSongButtons: + + try + for Pet := I to High(CatSongs.Song) do begin // creating all buttons + // 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 + CatSongs.Song[Pet].Cover := ''; // 0.5.0: if cover not found then show 'no cover' + + if CatSongs.Song[Pet].Cover = '' then + AddButton(300 + Pet*250, 140, 200, 200, Skin.GetTextureFileName('SongCover'), 'JPG', '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 + begin + Texture.CreateCacheMipmap := true; + Texture.GetTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, '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); + + // unload full size texture + Texture.UnloadTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, 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, 'JPG', 'Plain', Theme.Song.Cover.Reflections); + end; + Texture.Limit := 1024*1024; + I := -1; + end; + except + //When Error is reported the First time for this Song + if (I <> Pet) then + begin + //Some Error reporting: + Log.LogError('Could not load Cover: ' + CatSongs.Song[Pet].Cover); + + //Change Cover to NoCover and Continue Loading + CatSongs.Song[Pet].Cover := ''; + I := Pet; + end + else //when Error occurs Multiple Times(NoSong Cover is damaged), then start loading next Song + begin + Log.LogError('NoCover Cover is damaged!'); + try + AddButton(300 + Pet*250, 140, 200, 200, '', 'JPG', 'Plain', Theme.Song.Cover.Reflections); + except + {$IFDEF win32} + Messagebox(0, PChar('No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'), PChar(Language.Translate('US_VERSION')), MB_ICONERROR or MB_OK); + {$ELSE} + // TODO : JB_linux - better handle this message and display to user.. + writeln( 'No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'); + Log.LogError( 'No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.' ); + {$ENDIF} + Halt; + end; + I := Pet + 1; + end; + end; + + if (I <> -1) then + GoTo CreateSongButtons; + + end; + + // Randomize Patch + Randomize; + //Equalizer + SetLength(EqualizerBands, Theme.Song.Equalizer.Bands); + //ClearArray + For I := low(EqualizerBands) to high(EqualizerBands) do + EqualizerBands[I] := 3; + + if (Length(CatSongs.Song) > 0) then + Interaction := 0; +end; + +procedure TScreenSong.SetScroll; +var + VS, B: Integer; +begin + VS := CatSongs.VisibleSongs; + if VS > 0 then + begin + //Set Positions + Case Theme.Song.Cover.Style of + 3: SetScroll3; + 5:begin + if VS > 5 then + SetScroll5 + else + SetScroll4; + end; + 6: SetScroll6; + else SetScroll4; + end; + //Set Visibility of Video Icon + Static[VideoIcon].Visible := (CatSongs.Song[Interaction].Video <> ''); + + //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 + 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') + ')'; + end + else if (CatSongs.CatNumShow = -2) then + Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) + else if (CatSongs.CatNumShow = -3) then + Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) + 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)); + 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; + + end; +end; + +procedure TScreenSong.SetScroll1; +var + B: integer; // button + BMin: integer; // button min + BMax: integer; // button max + Src: integer; +// Dst: integer; + Count: integer; // Dst is not used. Count is used. + Ready: boolean; + + VisCount: integer; // count of visible (or selectable) buttons + VisInt: integer; // visible position of interacted button + Typ: integer; // 0 when all songs fits the screen + Placed: integer; // number of placed visible buttons +begin +// Src := 0; +// Dst := -1; + Count := 1; + Typ := 0; + Ready := false; + Placed := 0; + + VisCount := 0; + 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); + + + if VisCount <= 6 then begin + Typ := 0; + end else begin + if VisInt <= 3 then begin + Typ := 1; + Count := 7; + Ready := true; + end; + + if (VisCount - VisInt) <= 3 then begin + Typ := 2; + Count := 7; + Ready := true; + end; + + if not Ready then begin + Typ := 3; + Src := Interaction; + end; + end; + + + + // hide all buttons + for B := 0 to High(Button) do begin + Button[B].Visible := false; + Button[B].Selectable := CatSongs.Song[B].Visible; + end; + +{ 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;} + + + if Typ = 0 then begin + for B := 0 to High(Button) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (Placed) * 60; + Inc(Placed); + end; + end; + end; + + if Typ = 1 then begin + B := 0; + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Inc(B); + end; + end; + + if Typ = 2 then begin + B := High(Button); + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (6-Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Dec(B); + end; + end; + + if Typ = 3 then begin + B := Src; + Count := 4; + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (3+Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Inc(B); + end; + + B := Src-1; + Placed := 0; + Count := 3; + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (2-Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Dec(B); + end; + + end; + + if Length(Button) > 0 then + Static[1].Texture.Y := Button[Interaction].Y - 5; // selection texture +end; + +procedure TScreenSong.SetScroll2; +var + B: integer; + Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu + Wsp2: real; +begin + // liniowe + for B := 0 to High(Button) do + Button[B].X := 300 + (B - Interaction) * 260; + + 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; + + // kolowe +{ 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;} +end; + +procedure TScreenSong.SetScroll3; // with slide +var + B: integer; + Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu + Wsp2: real; +begin + SongTarget := Interaction; + + // liniowe + for B := 0 to High(Button) do + begin + Button[B].X := 300 + (B - SongCurrent) * 260; + if (Button[B].X < -Button[B].W) OR (Button[B].X > 800) then + Button[B].Visible := False + else + Button[B].Visible := True; + end; + +{ 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;} + + // kolowe +{ 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;} +end; + +procedure TScreenSong.SetScroll4; // rotate +var + B: integer; + Wsp: real; + Z, Z2: real; + VS: integer; +begin + VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important + + // kolowe + 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 + + 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; + + + Button[B].X := Theme.Song.Cover.X + (0.185 * Theme.Song.Cover.H * VS * sin(Wsp)) * Z2 - ((Button[B].H - Theme.Song.Cover.H)/2); // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs + Button[B].Z := Z / 2 + 0.3; + + 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].H := Button[B].W; + end; + end; +end; + +(* +procedure TScreenSong.SetScroll4; // rotate +var + B: integer; + Wsp: real; + Z: real; + Z2, Z3: real; + VS: integer; + function modreal (const X, Y: real):real; + begin + Result := Frac(x / y) * y; + if Result < -3 then + Result := Result + Y + else if Result > 3 then + Result := Result - Y; + end; +begin + VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important + Z3 := 1; + if VS < 12 then + Z2 := VS + else + Z2 := 12; + + // kolowe + 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 + begin + if CatSongs.VisibleIndex(B)> SongCurrent then + Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / Z2 + else + Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / Z2; + + Z3 := 2; + Z := (1 + cos(Wsp)) / 2; + //Z2 := (1 + 2*Z) / 3; + //Z2 := (0.5 + Z/2); + //Z2 := sin(Wsp); + + //Z2 := Power (Z2,Z3); + + Button[B].W := Theme.Song.CoverW * Power(cos(Wsp), Z3);//Power(Z2, 3); + + //Button[B].X := Theme.Song.CoverX + ({Theme.Song.CoverX + Theme.Song.CoverW/2 + Theme.Song.CoverW*0.18 * VS {CatSongs.VisibleSongs {Length(Button) * sin(Wsp) {- Theme.Song.CoverX - Theme.Song.CoverW) * Z2; // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs + if (sin(Wsp)<0) then + Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX + Theme.Song.CoverW - Button[B].W + else //*Theme.Song.CoverW*0.004*Z3 + 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 := (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 + begin + Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / 12 ;// 0.5.0 (II): takes another 16ms + + Z := (1 + cos(Wsp)) / 2 -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers + + Button[B].W := Theme.Song.CoverW * Power(cos(Wsp), Z3);//Power(Z2, 3); + + if (sin(Wsp)<0) then + Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX + Theme.Song.CoverW - Button[B].W + else + Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX; + + Button[B].Z := Z; + + Button[B].Y := (Theme.Song.CoverY + Theme.Song.CoverW - Button[B].W); + + Button[B].H := Button[B].W; + Button[B].Visible := True; + end + else Button[B].Visible := False; + end; + end; +end; *) + +procedure TScreenSong.SetScroll5; // rotate +var + B: integer; + Angle: real; + Pos: Real; + VS: integer; + diff: real; + X: Real; + helper: real; +begin + VS := CatSongs.VisibleSongs; // cache Visible Songs + {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 + Theme.Song.CoverH: Höhe der Cover + + (CatSongs.VisibleIndex(B) - SongCurrent)/VS = Abstand zum MIttleren Cover in % + } + + //Change Pos of all Buttons + for B := low(Button) to high(Button) do + begin + Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visibility + if Button[B].Visible then //Only Change Pos for Visible Buttons + begin + Pos := (CatSongs.VisibleIndex(B) - SongCurrent); + if (Pos < -VS/2) then + Pos := Pos + VS + else if (Pos > VS/2) then + Pos := Pos - VS; + + if (Abs(Pos) < 2.5) then {fixed Positions} + begin + Angle := Pi * (Pos / 5); +// 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].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + + Button[B].Z := 0.95 - Abs(Pos) * 0.01; + + Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); + + Button[B].W := Button[B].H; + + Diff := (Button[B].H - Theme.Song.Cover.H)/2; + + + X := Sin(Angle*1.3)*0.9; + + Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * X - Diff; + + end + else + begin {Behind the Front Covers} + + // limit-bg-covers hack + if (abs(abs(Pos)-VS/2)>10) then Button[B].Visible:=False; + // end of limit-bg-covers hack + + if Pos < 0 then + Pos := (Pos - VS/2)/VS + else + Pos := (Pos + VS/2)/VS; + + Angle := pi * Pos*2; + if VS > 24 then + begin + if Angle < 0 then helper:=-1 else helper:=1; + Angle:=2*pi-abs(Angle); + Angle:=Angle*(VS/24); + Angle:=(2*pi-Angle)*helper; + end; + + Button[B].Z := (0.4 - Abs(Pos/4)) -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers + + Button[B].H :=0.6*(Theme.Song.Cover.H-Abs(Theme.Song.Cover.H * cos(Angle/2)*0.8));//Power(Z2, 3); + + Button[B].W := Button[B].H; + + 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].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + + Diff := (Button[B].H - Theme.Song.Cover.H)/2; + + Button[B].X := Theme.Song.Cover.X+Theme.Song.Cover.H/2-Button[b].H/2+Theme.Song.Cover.W/320*((Theme.Song.Cover.H)*sin(Angle/2)*1.52); + + 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); + + end; + end; +end; + +procedure TScreenSong.SetScroll6; // rotate (slotmachine style) +var + B: integer; + Angle: real; + Pos: Real; + VS: integer; + diff: real; + X: Real; + Wsp: real; + Z, Z2: real; +begin + VS := CatSongs.VisibleSongs; // cache Visible Songs + if VS <=5 then begin + // kolowe + 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 + + 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; + + + Button[B].Y := Theme.Song.Cover.Y + (0.185 * Theme.Song.Cover.H * VS * sin(Wsp)) * Z2 - ((Button[B].H - Theme.Song.Cover.H)/2); // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs + Button[B].Z := Z / 2 + 0.3; + + Button[B].W := Theme.Song.Cover.H * 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; + end; + end + else begin + + //Change Pos of all Buttons + for B := low(Button) to high(Button) do + begin + Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visibility + if Button[B].Visible then //Only Change Pos for Visible Buttons + begin + Pos := (CatSongs.VisibleIndex(B) - SongCurrent); + if (Pos < -VS/2) then + Pos := Pos + VS + else if (Pos > VS/2) then + Pos := Pos - VS; + + if (Abs(Pos) < 2.5) then {fixed Positions} + begin + Angle := Pi * (Pos / 5); +// Button[B].Visible := False; + + Button[B].H := Abs(Theme.Song.Cover.H * cos(Angle*0.8));//Power(Z2, 3); + + Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + + Button[B].Z := 0.95 - Abs(Pos) * 0.01; + + Button[B].X := (Theme.Song.Cover.X + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); + + Button[B].W := Button[B].H; + + Diff := (Button[B].H - Theme.Song.Cover.H)/2; + + + X := Sin(Angle*1.3)*0.9; + + Button[B].Y := Theme.Song.Cover.Y + Theme.Song.Cover.W * X - Diff; + end + else + begin {Behind the Front Covers} + + // limit-bg-covers hack + if (abs(VS/2-abs(Pos))>10) then Button[B].Visible:=False; + if VS > 25 then VS:=25; + // end of limit-bg-covers hack + + if Pos < 0 then + Pos := (Pos - VS/2)/VS + else + Pos := (Pos + VS/2)/VS; + + 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 + + Button[B].H :=0.6*(Theme.Song.Cover.H-Abs(Theme.Song.Cover.H * cos(Angle/2)*0.8));//Power(Z2, 3); + + Button[B].W := Button[B].H; + + Button[B].X := Theme.Song.Cover.X - (Button[B].H - Theme.Song.Cover.H)*0.5; + + + Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + + Button[B].Y := Theme.Song.Cover.Y+Theme.Song.Cover.H/2-Button[b].H/2+Theme.Song.Cover.W/320*(Theme.Song.Cover.H*sin(Angle/2)*1.52); + end; + end; + end; + end; +end; + + +procedure TScreenSong.onShow; +begin + Music.Stop; + + if Ini.Players <= 3 then PlayersPlay := Ini.Players + 1; + 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 Length(CatSongs.Song) > 0 then begin + //Load Music only when Song Preview is activated + if (Ini.PreviewVolume <> 0) then + begin + Music.SetLoop(false); + Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); + Music.MoveTo(Music.Length / 4); + Music.Play; + + //Set Preview Volume + Music.SetMusicVolume (Ini.PreviewVolume * 10); + {//if Music Fade is activated, Set Volume to 0 % + if (Ini.PreviewFading <> 0) then + Music.SetMusicVolume(0);} + end; + + SetScroll; + UpdateLCD; + end; + + //Playlist Mode + if (Mode = 0) then + begin + //If Playlist Shown -> Select Next automatically + if (CatSongs.CatNumShow = -3) then + begin + SelectNext; + ChangeMusic; + end; + end + //Party Mode + else if (Mode = 1) then + begin + + SelectRandomSong; + //Show Menu directly in PartyMode + //But only if selected in Options + if (Ini.PartyPopup = 1) then + begin + ScreenSongMenu.MenuShow(SM_Party_Main); + end; + + + end; + + SetJoker; + SetStatics; +end; + +procedure TScreenSong.onHide; +begin + //When Music Fading is activated, Turn Music to 100 % + If (Ini.PreviewVolume <> 100) or (Ini.PreviewFading <> 0) then + Music.SetMusicVolume(100); + + //If Preview is deactivated: Load MUsicfile now + If (Ini.PreviewVolume = 0) then + Music.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 (Music <> nil) then + Music.Stop; +end; + +procedure TScreenSong.DrawExtensions; +begin + //Draw Song Menu + if (ScreenSongMenu.Visible) then + begin + ScreenSongMenu.Draw; + end + else if (ScreenSongJumpto.Visible) then + begin + ScreenSongJumpto.Draw; + end +end; + +function TScreenSong.Draw: boolean; +var + dx: real; + dt: real; + I: Integer; +begin + dx := SongTarget-SongCurrent; + dt := TimeSkip*7; + if dt > 1 then dt := 1; + SongCurrent := SongCurrent + dx*dt; + +{ if SongCurrent > Catsongs.VisibleSongs then begin + SongCurrent := SongCurrent - Catsongs.VisibleSongs; + SongTarget := SongTarget - Catsongs.VisibleSongs; + end;} + +// Log.BenchmarkStart(5); + SetScroll; +// Log.BenchmarkEnd(5); +// Log.LogBenchmark('SetScroll4', 5); + + //Fading Functions, Only if Covertime is under 5 Seconds + If (CoverTime < 5) then + begin + // 0.5.0: cover fade + if (CoverTime < 1) and (CoverTime + TimeSkip >= 1) then begin + // load new texture + Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); + Button[Interaction].Texture.Alpha := 1; + Button[Interaction].Texture2 := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); + Button[Interaction].Texture2.Alpha := 1; + end; + + //Song Fade + 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 + Music.Play; + + //Update Song Volume + if (CoverTime < Ini.PreviewFading) then + Music.SetMusicVolume(Round (CoverTime * Ini.PreviewVolume / Ini.PreviewFading * 10)) + else + Music.SetMusicVolume(Ini.PreviewVolume * 10); + + end; + + + //Update Fading Time + CoverTime := CoverTime + TimeSkip; + + //Update Fading Texture + Button[Interaction].Texture2.Alpha := (CoverTime - 1) * 1.5; + if Button[Interaction].Texture2.Alpha > 1 then Button[Interaction].Texture2.Alpha := 1; + + end; + + //inherited Draw; + //heres a little Hack, that causes the Statics + //are Drawn after the Buttons because of some Blending Problems. + //This should cause no Problems because all Buttons on this screen + //Has Z Position. + //Draw BG + DrawBG; + + //Instead of Draw FG Procedure: + //We draw Buttons for our own + for I := 0 to Length(Button) - 1 do + Button[I].Draw; + + // Statics + for I := 0 to Length(Static) - 1 do + Static[I].Draw; + + // and texts + for I := 0 to Length(Text) - 1 do + Text[I].Draw; + + + //Draw Equalizer + if Theme.Song.Equalizer.Visible then + DrawEqualizer; + + DrawExtensions; + +end; + +procedure TScreenSong.SelectNext; +var + Skip: integer; + I: integer; + VS: Integer; +begin + VS := CatSongs.VisibleSongs; + + if VS > 0 then + begin + UnLoadDetailedCover; + + Skip := 1; + + // this 1 could be changed by CatSongs.FindNextVisible + while (not CatSongs.Song[(Interaction + Skip) mod Length(Interactions)].Visible) do Inc(Skip); + + SongTarget := SongTarget + 1;//Skip; + + Interaction := (Interaction + Skip) mod Length(Interactions); + + // try to keep all at the beginning + if SongTarget > VS-1 then begin + SongTarget := SongTarget - VS; + SongCurrent := SongCurrent - VS; + end; + + end; + // Interaction -> Button, ktorego okladke przeczytamy + // Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture +end; + +procedure TScreenSong.SelectPrev; +var + Skip: integer; + I: integer; + VS: Integer; +begin + VS := CatSongs.VisibleSongs; + + if VS > 0 then + begin + UnLoadDetailedCover; + + Skip := 1; + + 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); + + // try to keep all at the beginning + if SongTarget < 0 then begin + SongTarget := SongTarget + CatSongs.VisibleSongs; + SongCurrent := SongCurrent + CatSongs.VisibleSongs; + end; + + // Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture + end; +end; + +procedure TScreenSong.UpdateLCD; +begin + LCD.HideCursor; + LCD.Clear; + LCD.WriteText(1, Text[TextArtist].Text); + LCD.WriteText(2, Text[TextTitle].Text); +end; + +//Procedure Change current played Preview +procedure TScreenSong.ChangeMusic; +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 + begin + Music.Close; + if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin + Music.MoveTo(Music.Length / 4); + //If Song Fading is activated then don't Play directly, and Set Volume to Null, else Play normal + if (Ini.PreviewFading = 0) then + Music.Play + else + Music.SetMusicVolume(0); + end; + end + else + Music.Stop; + end; +end; + +procedure TScreenSong.SkipTo(Target: Cardinal); // 0.5.0 +var + Skip: integer; + I: integer; +begin + UnLoadDetailedCover; + + Interaction := High(CatSongs.Song); + SongTarget := 0; + + for I := 1 to Target+1 do + SelectNext; + + FixSelected2; +end; + +procedure TScreenSong.DrawEqualizer; +var + Data: TFFTData; //Audio Data + I, J: Integer; + Res: byte; + A, B: Integer; + PosX, PosY: Integer; + Pos: Real; + lTmp : double; +begin + +if (not Music.Finished) AND (Theme.Song.Equalizer.Length > 0) then +begin + + + A := GetTickCount div 44; + + if (A <> EqualizerTime) then + begin + EqualizerTime := A; + Data := Music.GetFFTData; + + B:=0; + Pos := 0; + Res := ceil(92/Theme.Song.Equalizer.Bands);//How much channels are used for one Band + + //Change Lengths + for I := 0 to (Res * Theme.Song.Equalizer.Bands - 1) do + begin + A := floor(I/Res); + + if (A<>B) then //Band changed + begin + if (Pos <= Theme.Song.Equalizer.Length) then + begin + if ((Pos < EqualizerBands[B]) AND (EqualizerBands[B]>1)) then + EqualizerBands[B] := EqualizerBands[B] - 1 + else + EqualizerBands[B] := floor(Pos); + end + else + EqualizerBands[B] := 1; + + B := A; + Pos := 0; + end; + + if I > 35 then + Data[i] := Data[i] * 8 + else if I > 11 then + Data[i] := Data[i] * 4.5 + else + Data[i] := Data[i] * 1.1; + + if (Data[i] >= 1) then + Data[i] := 0.9999999999999; + + try + if ( assigned( Theme ) ) AND + ( assigned( Theme.Song ) ) AND + ( i < length( Data ) ) THEN + begin + writeln( '!!!!!!!!! - '+ inttostr( i ) + ' - ' + inttostr( Theme.Song.Equalizer.Length ) ); + + if Single(Data[i]) > 0 then + begin + lTmp := Single(Data[i]) * Theme.Song.Equalizer.Length; + if lTmp > Pos then + Pos := lTmp; + end; + end; + except + // TODO: JB_Linux..... why does this happen ! + on E:EInvalidOp do + writeln( 'UScreenSong - DOH !!!!' ); + end + + end; + + //Change Last Band + if (EqualizerBands[B] <= Theme.Song.Equalizer.Length) then + begin + if ((Pos < EqualizerBands[B]) AND (EqualizerBands[B]>1)) then + EqualizerBands[B] := EqualizerBands[B] - 1 + else + EqualizerBands[B] := floor(Pos) + end + else + EqualizerBands[B] := 1; + end; + + //Draw every Channel + glColor4f(Theme.Song.Equalizer.ColR, Theme.Song.Equalizer.ColG, Theme.Song.Equalizer.ColB, Theme.Song.Equalizer.Alpha); //Set Color + glDisable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + + PosY := Theme.Song.Equalizer.Y; + PosX := Theme.Song.Equalizer.X; + + For I := 0 to Theme.Song.Equalizer.Bands-1 do + begin + if Theme.Song.Equalizer.Direction then + PosY := Theme.Song.Equalizer.Y //+ (Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space) * Theme.Song.Equalizer.Length + else + PosX := Theme.Song.Equalizer.X; + //Draw for every visible quad + for J := 1 to EqualizerBands[I] do + begin + glBegin(GL_QUADS); + glVertex3f(PosX, PosY, Theme.Song.Equalizer.Z); + glVertex3f(PosX, PosY+Theme.Song.Equalizer.H, Theme.Song.Equalizer.Z); + glVertex3f(PosX+Theme.Song.Equalizer.W, PosY+Theme.Song.Equalizer.H, Theme.Song.Equalizer.Z); + glVertex3f(PosX+Theme.Song.Equalizer.W, PosY, Theme.Song.Equalizer.Z); + glEnd; + + if Theme.Song.Equalizer.Direction then //Vertically + PosY := PosY - Theme.Song.Equalizer.H - Theme.Song.Equalizer.Space + else //Horizontally + PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space; + end; + if Theme.Song.Equalizer.Direction then //Horizontally + PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space + else //Vertically + PosY := PosY + Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space; + end; +end; +end; + +Procedure TScreenSong.SelectRandomSong; +var + I, I2: Integer; +begin + Case PlaylistMan.Mode of + 0: //All Songs Just Select Random Song + begin + //When Tabs are activated then use Tab Method + if (Ini.Tabs_at_startup = 1) then + begin + 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 + begin + if CatSongs.Song[I].Main then + break; + 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 + + //Choose Cat + CatSongs.ShowCategoryList; + + //Show Cat in Top Left Mod + ShowCatTL (I); + + CatSongs.ClickCategoryButton(I); + SelectNext; + + //Choose Song + SkipTo(I2-I); + end + //When Tabs are deactivated use easy Method + else + SkipTo(Random(CatSongs.VisibleSongs)); + end; + 1: //One Category Select Category and Select Random Song + begin + CatSongs.ShowCategoryList; + CatSongs.ClickCategoryButton(PlaylistMan.CurPlayList); + ShowCatTL(PlaylistMan.CurPlayList); + + SelectNext; + FixSelected2; + + SkipTo(Random(CatSongs.VisibleSongs)); + end; + 2: //Playlist: Select Playlist and Select Random Song + begin + PlaylistMan.SetPlayList(PlaylistMan.CurPlayList); + + SkipTo(Random(CatSongs.VisibleSongs)); + FixSelected2; + end; + end; + + Music.PlayChange; + ChangeMusic; + SetScroll; + UpdateLCD; +end; + +procedure TScreenSong.SetJoker; +begin + //If Party Mode + if Mode = 1 then //Show Joker that are available + begin + if (PartySession.Teams.NumTeams >= 1) then + begin + Static[StaticTeam1Joker1].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 1); + Static[StaticTeam1Joker2].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 2); + Static[StaticTeam1Joker3].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 3); + Static[StaticTeam1Joker4].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 4); + Static[StaticTeam1Joker5].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 5); + end + else + begin + Static[StaticTeam1Joker1].Visible := False; + Static[StaticTeam1Joker2].Visible := False; + Static[StaticTeam1Joker3].Visible := False; + Static[StaticTeam1Joker4].Visible := False; + Static[StaticTeam1Joker5].Visible := False; + end; + + if (PartySession.Teams.NumTeams >= 2) then + begin + Static[StaticTeam2Joker1].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 1); + Static[StaticTeam2Joker2].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 2); + Static[StaticTeam2Joker3].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 3); + Static[StaticTeam2Joker4].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 4); + Static[StaticTeam2Joker5].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 5); + end + else + begin + Static[StaticTeam2Joker1].Visible := False; + Static[StaticTeam2Joker2].Visible := False; + Static[StaticTeam2Joker3].Visible := False; + Static[StaticTeam2Joker4].Visible := False; + Static[StaticTeam2Joker5].Visible := False; + end; + + if (PartySession.Teams.NumTeams >= 3) then + begin + Static[StaticTeam3Joker1].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 1); + Static[StaticTeam3Joker2].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 2); + Static[StaticTeam3Joker3].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 3); + Static[StaticTeam3Joker4].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 4); + Static[StaticTeam3Joker5].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 5); + end + else + begin + Static[StaticTeam3Joker1].Visible := False; + Static[StaticTeam3Joker2].Visible := False; + Static[StaticTeam3Joker3].Visible := False; + Static[StaticTeam3Joker4].Visible := False; + Static[StaticTeam3Joker5].Visible := False; + end; + end + else + begin //Hide all + Static[StaticTeam1Joker1].Visible := False; + Static[StaticTeam1Joker2].Visible := False; + Static[StaticTeam1Joker3].Visible := False; + Static[StaticTeam1Joker4].Visible := False; + Static[StaticTeam1Joker5].Visible := False; + + Static[StaticTeam2Joker1].Visible := False; + Static[StaticTeam2Joker2].Visible := False; + Static[StaticTeam2Joker3].Visible := False; + Static[StaticTeam2Joker4].Visible := False; + Static[StaticTeam2Joker5].Visible := False; + + Static[StaticTeam3Joker1].Visible := False; + Static[StaticTeam3Joker2].Visible := False; + Static[StaticTeam3Joker3].Visible := False; + Static[StaticTeam3Joker4].Visible := False; + Static[StaticTeam3Joker5].Visible := False; + end; +end; + +procedure TScreenSong.SetStatics; +var + I: Integer; + Visible: Boolean; +begin + //Set Visibility of Party Statics and Text + Visible := (Mode = 1); + + For I := 0 to high(StaticParty) do + Static[StaticParty[I]].Visible := Visible; + + 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 + Static[StaticNonParty[I]].Visible := Visible; + + For I := 0 to high(TextNonParty) do + Text[TextNonParty[I]].Visible := Visible; +end; + +//Procedures for Menu + +procedure TScreenSong.StartSong; +begin + CatSongs.Selected := Interaction; + Music.Stop; + //Party Mode + if (Mode = 1) then + begin + FadeTo(@ScreenSingModi); + end + else + begin + FadeTo(@ScreenSing); + end; +end; + +procedure TScreenSong.SelectPlayers; +begin + CatSongs.Selected := Interaction; + Music.Stop; + + ScreenName.Goto_SingScreen := True; + FadeTo(@ScreenName); +end; + +procedure TScreenSong.OpenEditor; +begin + if (Length(Songs.Song) > 0) and (not CatSongs.Song[Interaction].Main) AND (Mode = 0) then begin + Music.Stop; + Music.PlayStart; + ScreenEditSub.Path := CatSongs.Song[Interaction].Path; + ScreenEditSub.FileName := CatSongs.Song[Interaction].FileName; + FadeTo(@ScreenEditSub); + end; +end; + +//Team No of Team (0-5) +procedure TScreenSong.DoJoker (Team: Byte); +begin + if (Mode = 1) AND (PartySession.Teams.NumTeams >= Team + 1) AND (PartySession.Teams.Teaminfo[Team].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[Team].Joker); + SelectRandomSong; + SetJoker; + 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, 'Plain', true); // 0.5.0: show cached texture + Button[Interaction].Texture2.Alpha := 0; + + if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then + Texture.UnloadTexture(Button[Interaction].Texture.Name, false); +end; + +procedure TScreenSong.Refresh; +begin { +CatSongs.Refresh; +CatSongs.ShowCategoryList; +Interaction := 0; +SelectNext; +FixSelected; } + +end; + +end. -- cgit v1.2.3 From d123263213fba448d5695df35660f7de4cbed433 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Thu, 11 Oct 2007 08:11:47 +0000 Subject: modified UTime to utilise SDL timer... this allows for reliable cross platform timers. Tested working on linux. Modified UVideo and screens to get Video playback working on linux currently only video stream... no audio.. but I Will be working towards this, for all audio playback ( at least for linux ) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@501 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 859d5026..b5a34f46 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1509,8 +1509,13 @@ var I: Integer; begin dx := SongTarget-SongCurrent; - dt := TimeSkip*7; - if dt > 1 then dt := 1; + dt := TimeSkip * 7; + +// writeln( 'TScreenSong.Draw '+ inttostr(trunc(TimeSkip)) ); + + if dt > 1 then + dt := 1; + SongCurrent := SongCurrent + dx*dt; { if SongCurrent > Catsongs.VisibleSongs then begin @@ -1527,7 +1532,8 @@ begin If (CoverTime < 5) then begin // 0.5.0: cover fade - if (CoverTime < 1) and (CoverTime + TimeSkip >= 1) then begin + if (CoverTime < 1) and (CoverTime + TimeSkip >= 1) then + begin // load new texture Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); Button[Interaction].Texture.Alpha := 1; @@ -1756,27 +1762,24 @@ begin Data[i] := 0.9999999999999; try - if ( assigned( Theme ) ) AND - ( assigned( Theme.Song ) ) AND - ( i < length( Data ) ) THEN - begin - writeln( '!!!!!!!!! - '+ inttostr( i ) + ' - ' + inttostr( Theme.Song.Equalizer.Length ) ); - - if Single(Data[i]) > 0 then + if ( assigned( Theme ) ) AND + ( assigned( Theme.Song ) ) AND + ( i < length( Data ) ) THEN begin - lTmp := Single(Data[i]) * Theme.Song.Equalizer.Length; - if lTmp > Pos then - Pos := lTmp; + if single( Data[i] ) > single( 1 ) then + begin + lTmp := Single(Data[i]) * Theme.Song.Equalizer.Length; + if lTmp > Pos then + Pos := lTmp; + end; end; - end; except - // TODO: JB_Linux..... why does this happen ! on E:EInvalidOp do - writeln( 'UScreenSong - DOH !!!!' ); + writeln( 'UScreenSong - DOH !!!! ('+inttostr(i)+' '+ inttostr( integer( single( Data[i] ) ) )+' * '+ ')' ); end end; - + //Change Last Band if (EqualizerBands[B] <= Theme.Song.Equalizer.Length) then begin -- cgit v1.2.3 From 0d997f8433e982584a0ab67a6d630d12f4314759 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Thu, 11 Oct 2007 10:50:01 +0000 Subject: fixes so codebase builds in delphi now, after major FFMpeg changse for linux. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@503 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index b5a34f46..0bf411c1 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1766,7 +1766,7 @@ begin ( assigned( Theme.Song ) ) AND ( i < length( Data ) ) THEN begin - if single( Data[i] ) > single( 1 ) then + if single( Data[i] ) > 1 then begin lTmp := Single(Data[i]) * Theme.Song.Equalizer.Length; if lTmp > Pos then @@ -1774,8 +1774,10 @@ begin end; end; except + {$IFDEF FPC} on E:EInvalidOp do - writeln( 'UScreenSong - DOH !!!! ('+inttostr(i)+' '+ inttostr( integer( single( Data[i] ) ) )+' * '+ ')' ); + writeln( 'UScreenSong - DOH !!!! ('+inttostr(i)+' '+ inttostr( integer( Data[i] ) )+' * '+ ')' ); + {$ENDIF} end end; -- cgit v1.2.3 From 44554c7908f7e2405a249331f00a35703f5939c2 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Thu, 11 Oct 2007 12:02:20 +0000 Subject: Added IAudioPlayback Interface and implementation for BASS. Created "AudioPlayback" Global Singleton, which removed the need for the "Music" Global variable. This was done because global singleton objects are a recognized better "design pattern" achieving the same thing as global variables, but in a nicer way. I will be working to a) separate IAudioPlayback in to separate "Playback" and "Input" Interfaces b) build a FFMpeg class that implements IAudioPlayback git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@504 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 82 ++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 40 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 0bf411c1..df4ec87a 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -265,7 +265,7 @@ begin begin SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); - Music.PlayChange; + AudioPlayback.PlayChange; ChangeMusic; SetScroll4; @@ -284,7 +284,7 @@ begin begin SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); - Music.PlayChange; + AudioPlayback.PlayChange; ChangeMusic; SetScroll4; @@ -326,7 +326,7 @@ begin Interaction := I - 1; //Stop Music - Music.Stop; + AudioPlayback.Stop; CatSongs.ShowCategoryList; @@ -361,8 +361,8 @@ begin end else begin - Music.Stop; - Music.PlayBack; + AudioPlayback.Stop; + AudioPlayback.PlayBack; FadeTo(@ScreenMain); end; @@ -372,7 +372,7 @@ begin //When in party Mode then Ask before Close else if (Mode = 1) then begin - Music.PlayBack; + AudioPlayback.PlayBack; CheckFadeTo(@ScreenMain,'MSG_END_PARTY'); end; end; @@ -495,7 +495,7 @@ begin FixSelected; //Play Music: - Music.PlayChange; + AudioPlayback.PlayChange; ChangeMusic; end; @@ -538,7 +538,7 @@ begin FixSelected; //Play Music: - Music.PlayChange; + AudioPlayback.PlayChange; ChangeMusic; end; end; @@ -548,8 +548,9 @@ begin SDLK_RIGHT: begin - if (Length(Songs.Song) > 0) AND (Mode = 0) then begin - Music.PlayChange; + if (Length(Songs.Song) > 0) AND (Mode = 0) then + begin + AudioPlayback.PlayChange; SelectNext; // InteractNext; // SongTarget := Interaction; @@ -563,7 +564,7 @@ begin SDLK_LEFT: begin if (Length(Songs.Song) > 0)AND (Mode = 0) then begin - Music.PlayChange; + AudioPlayback.PlayChange; SelectPrev; ChangeMusic; SetScroll4; @@ -643,9 +644,9 @@ begin end else //Random in one Category begin - SkipTo(Random(CatSongs.VisibleSongs)); + SkipTo(Random(CatSongs.VisibleSongs)); end; - Music.PlayChange; + AudioPlayback.PlayChange; ChangeMusic; SetScroll4; @@ -1410,7 +1411,7 @@ end; procedure TScreenSong.onShow; begin - Music.Stop; + AudioPlayback.Stop; if Ini.Players <= 3 then PlayersPlay := Ini.Players + 1; if Ini.Players = 4 then PlayersPlay := 6; @@ -1429,13 +1430,13 @@ begin //Load Music only when Song Preview is activated if (Ini.PreviewVolume <> 0) then begin - Music.SetLoop(false); - Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); - Music.MoveTo(Music.Length / 4); - Music.Play; + AudioPlayback.SetLoop(false); + AudioPlayback.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); + AudioPlayback.MoveTo(AudioPlayback.Length / 4); + AudioPlayback.Play; //Set Preview Volume - Music.SetMusicVolume (Ini.PreviewVolume * 10); + AudioPlayback.SetMusicVolume (Ini.PreviewVolume * 10); {//if Music Fade is activated, Set Volume to 0 % if (Ini.PreviewFading <> 0) then Music.SetMusicVolume(0);} @@ -1478,15 +1479,15 @@ procedure TScreenSong.onHide; begin //When Music Fading is activated, Turn Music to 100 % If (Ini.PreviewVolume <> 100) or (Ini.PreviewFading <> 0) then - Music.SetMusicVolume(100); + AudioPlayback.SetMusicVolume(100); //If Preview is deactivated: Load MUsicfile now If (Ini.PreviewVolume = 0) then - Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); + 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 (Music <> nil) then - Music.Stop; + if (Display.NextScreen <> @ScreenSing) and (Display.NextScreen <> @ScreenSingModi) and (AudioPlayback <> nil) then + AudioPlayback.Stop; end; procedure TScreenSong.DrawExtensions; @@ -1546,13 +1547,13 @@ begin 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 - Music.Play; + AudioPlayback.Play; //Update Song Volume if (CoverTime < Ini.PreviewFading) then - Music.SetMusicVolume(Round (CoverTime * Ini.PreviewVolume / Ini.PreviewFading * 10)) + AudioPlayback.SetMusicVolume(Round (CoverTime * Ini.PreviewVolume / Ini.PreviewFading * 10)) else - Music.SetMusicVolume(Ini.PreviewVolume * 10); + AudioPlayback.SetMusicVolume(Ini.PreviewVolume * 10); end; @@ -1673,18 +1674,18 @@ begin begin if (NOT CatSongs.Song[Interaction].Main) AND(CatSongs.VisibleSongs > 0) then begin - Music.Close; - if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin - Music.MoveTo(Music.Length / 4); + AudioPlayback.Close; + if AudioPlayback.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin + AudioPlayback.MoveTo(AudioPlayback.Length / 4); //If Song Fading is activated then don't Play directly, and Set Volume to Null, else Play normal if (Ini.PreviewFading = 0) then - Music.Play + AudioPlayback.Play else - Music.SetMusicVolume(0); + AudioPlayback.SetMusicVolume(0); end; end else - Music.Stop; + AudioPlayback.Stop; end; end; @@ -1715,7 +1716,7 @@ var lTmp : double; begin -if (not Music.Finished) AND (Theme.Song.Equalizer.Length > 0) then +if (not AudioPlayback.Finished) AND (Theme.Song.Equalizer.Length > 0) then begin @@ -1724,7 +1725,7 @@ begin if (A <> EqualizerTime) then begin EqualizerTime := A; - Data := Music.GetFFTData; + Data := AudioPlayback.GetFFTData; B:=0; Pos := 0; @@ -1890,7 +1891,7 @@ begin end; end; - Music.PlayChange; + AudioPlayback.PlayChange; ChangeMusic; SetScroll; UpdateLCD; @@ -2003,7 +2004,7 @@ end; procedure TScreenSong.StartSong; begin CatSongs.Selected := Interaction; - Music.Stop; + AudioPlayback.Stop; //Party Mode if (Mode = 1) then begin @@ -2018,7 +2019,7 @@ end; procedure TScreenSong.SelectPlayers; begin CatSongs.Selected := Interaction; - Music.Stop; + AudioPlayback.Stop; ScreenName.Goto_SingScreen := True; FadeTo(@ScreenName); @@ -2026,9 +2027,10 @@ end; procedure TScreenSong.OpenEditor; begin - if (Length(Songs.Song) > 0) and (not CatSongs.Song[Interaction].Main) AND (Mode = 0) then begin - Music.Stop; - Music.PlayStart; + if (Length(Songs.Song) > 0) and (not CatSongs.Song[Interaction].Main) AND (Mode = 0) then + begin + AudioPlayback.Stop; + AudioPlayback.PlayStart; ScreenEditSub.Path := CatSongs.Song[Interaction].Path; ScreenEditSub.FileName := CatSongs.Song[Interaction].FileName; FadeTo(@ScreenEditSub); -- cgit v1.2.3 From 6292440f6da3c11e85bb9fc3a741a26540e429be Mon Sep 17 00:00:00 2001 From: jaybinks Date: Thu, 11 Oct 2007 12:12:37 +0000 Subject: separated IAudioPlayback in to separate "Playback" and "Input" Interfaces ( both interfaces provided by same TMusic_Bass class... git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@505 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index df4ec87a..ea1dd8a5 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1725,7 +1725,7 @@ begin if (A <> EqualizerTime) then begin EqualizerTime := A; - Data := AudioPlayback.GetFFTData; + Data := AudioInput.GetFFTData; B:=0; Pos := 0; -- cgit v1.2.3 From 8cca9e3e6f591c35d35d132a9d3f93ffc7cdfee8 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Sat, 27 Oct 2007 06:31:04 +0000 Subject: made some major progress with ffmpeg audio playback !!! YAY !!! still a little choppy, so I suspect incorrect buffer sizes or something like that. also made some mods to support Unicode song file iteration on windows, this is no worse than what we had before, but is not complete.. oh this code only supports win 2000 and up .. no Win 98... git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@533 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index ea1dd8a5..4d146283 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -261,7 +261,9 @@ begin begin 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 (UpCase(CatSongs.Song[(I + Interaction) mod I2].Title[1]) = Letter) then + if (CatSongs.Song[(I + Interaction) mod I2].Visible) AND + (Length(CatSongs.Song[(I + Interaction) mod I2].Title)>0) AND + (widechar(UpperCase(CatSongs.Song[(I + Interaction) mod I2].Title)[1]) = widechar(Letter)) then begin SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); @@ -280,7 +282,9 @@ begin begin 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 (UpCase(CatSongs.Song[(I + Interaction) mod I2].Artist[1]) = Letter) then + if (CatSongs.Song[(I + Interaction) mod I2].Visible) AND + (Length(CatSongs.Song[(I + Interaction) mod I2].Artist)>0) AND + (widechar(uppercase(CatSongs.Song[(I + Interaction) mod I2].Artist)[1]) = widechar(Letter)) then begin SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); -- cgit v1.2.3 From 391d30716d48dc709f6444b19c008e82311623b9 Mon Sep 17 00:00:00 2001 From: eddie-0815 Date: Thu, 1 Nov 2007 19:34:40 +0000 Subject: Mac OS X version compiles and links. I hope I didn't break too many files on windows/linux. Added switches.inc to all files. Changed many IFDEFs. For Windows-only code please use MSWINDOWS instead of WIN32 now. WIN32 is also used by the Mac port. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@546 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 4d146283..3f2f5d58 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1,12 +1,8 @@ unit UScreenSong; interface -{$I switches.inc} - -{$IFDEF FPC} - {$MODE DELPHI} -{$ENDIF} +{$I switches.inc} uses @@ -813,7 +809,7 @@ begin try AddButton(300 + Pet*250, 140, 200, 200, '', 'JPG', 'Plain', Theme.Song.Cover.Reflections); except - {$IFDEF win32} + {$IFDEF MSWINDOWS} Messagebox(0, PChar('No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'), PChar(Language.Translate('US_VERSION')), MB_ICONERROR or MB_OK); {$ELSE} // TODO : JB_linux - better handle this message and display to user.. -- cgit v1.2.3 From 99955c78f63d1cb0d8bec666bc33953590a74c8a Mon Sep 17 00:00:00 2001 From: jaybinks Date: Thu, 1 Nov 2007 23:22:01 +0000 Subject: fixed failed builds build:USDX-LAZLIN-75 build:USDX-LAZLIN-76 for some reason we can not use {$MODE Delphi} in an included file. ( Probably because of the way the compier scopes this switch to each pas file ) ive had to revert this part of eddies changes. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@548 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 3f2f5d58..85c38c26 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -2,6 +2,10 @@ unit UScreenSong; interface +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + {$I switches.inc} @@ -1719,7 +1723,7 @@ begin if (not AudioPlayback.Finished) AND (Theme.Song.Equalizer.Length > 0) then begin - + {$ifdef win32} A := GetTickCount div 44; if (A <> EqualizerTime) then @@ -1794,6 +1798,7 @@ begin else EqualizerBands[B] := 1; end; + {$endif} //Draw every Channel glColor4f(Theme.Song.Equalizer.ColR, Theme.Song.Equalizer.ColG, Theme.Song.Equalizer.ColB, Theme.Song.Equalizer.Alpha); //Set Color -- cgit v1.2.3 From ae057627ff135d55891e9f04f399608fbc47e9ee Mon Sep 17 00:00:00 2001 From: jaybinks Date: Fri, 2 Nov 2007 12:16:50 +0000 Subject: Runtime Song Addition jira:USDX-157 git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@553 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 95 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 91 insertions(+), 4 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 85c38c26..bd9e5e67 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -92,6 +92,7 @@ type procedure SetScroll6; function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; function Draw: boolean; override; + procedure GenerateThumbnails(); procedure onShow; override; procedure onHide; override; procedure SelectNext; @@ -696,9 +697,9 @@ end; constructor TScreenSong.Create; var - Pet: integer; +// Pet: integer; I: integer; -Label CreateSongButtons; +//Label CreateSongButtons; begin inherited Create; @@ -755,6 +756,8 @@ begin // Songs.LoadSongList; // moved to the UltraStar unit CatSongs.Refresh; + GenerateThumbnails(); +(* if (length(CatSongs.Song) > 0) then begin //Set Length of Button Array one Time Instead of one time for every Song @@ -830,6 +833,7 @@ begin GoTo CreateSongButtons; end; +*) // Randomize Patch Randomize; @@ -843,6 +847,89 @@ begin Interaction := 0; end; +procedure TScreenSong.GenerateThumbnails(); +var + I : Integer; + Pet: integer; +Label CreateSongButtons; +begin + 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)); + + I := 0; + CreateSongButtons: + + try + for Pet := I to High(CatSongs.Song) do begin // creating all buttons + // 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 + CatSongs.Song[Pet].Cover := ''; // 0.5.0: if cover not found then show 'no cover' + + if CatSongs.Song[Pet].Cover = '' then + AddButton(300 + Pet*250, 140, 200, 200, Skin.GetTextureFileName('SongCover'), 'JPG', '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 + begin + Texture.CreateCacheMipmap := true; + Texture.GetTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, '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); + + // unload full size texture + Texture.UnloadTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, 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, 'JPG', 'Plain', Theme.Song.Cover.Reflections); + end; + Texture.Limit := 1024*1024; + I := -1; + end; + except + //When Error is reported the First time for this Song + if (I <> Pet) then + begin + //Some Error reporting: + Log.LogError('Could not load Cover: ' + CatSongs.Song[Pet].Cover); + + //Change Cover to NoCover and Continue Loading + CatSongs.Song[Pet].Cover := ''; + I := Pet; + end + else //when Error occurs Multiple Times(NoSong Cover is damaged), then start loading next Song + begin + Log.LogError('NoCover Cover is damaged!'); + try + AddButton(300 + Pet*250, 140, 200, 200, '', 'JPG', 'Plain', Theme.Song.Cover.Reflections); + except + {$IFDEF MSWINDOWS} + Messagebox(0, PChar('No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'), PChar(Language.Translate('US_VERSION')), MB_ICONERROR or MB_OK); + {$ELSE} + // TODO : JB_linux - better handle this message and display to user.. + writeln( 'No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'); + Log.LogError( 'No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.' ); + {$ENDIF} + Halt; + end; + I := Pet + 1; + end; + end; + + if (I <> -1) then + GoTo CreateSongButtons; + + end; +end; + procedure TScreenSong.SetScroll; var VS, B: Integer; @@ -1418,7 +1505,7 @@ begin AudioPlayback.Stop; if Ini.Players <= 3 then PlayersPlay := Ini.Players + 1; - if Ini.Players = 4 then PlayersPlay := 6; + if Ini.Players = 4 then PlayersPlay := 6; //Cat Mod etc if (Ini.Tabs_at_startup = 1) AND (CatSongs.CatNumShow = -1) then @@ -1701,7 +1788,7 @@ begin UnLoadDetailedCover; Interaction := High(CatSongs.Song); - SongTarget := 0; + SongTarget := 0; for I := 1 to Target+1 do SelectNext; -- cgit v1.2.3 From 5e733f7e9cb2118651df90171db1892c9155e089 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 4 Nov 2007 21:00:20 +0000 Subject: Partymodule finished. All PartyScreens and SingScreen needs some adapting. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@583 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index bd9e5e67..8123ef03 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -660,36 +660,36 @@ begin end; SDLK_1: - begin //Jocker - if (Mode = 1) AND (PartySession.Teams.NumTeams >= 1) AND (PartySession.Teams.Teaminfo[0].Joker > 0) then + begin //Jocker // to-do : Party + {if (Mode = 1) AND (PartySession.Teams.NumTeams >= 1) AND (PartySession.Teams.Teaminfo[0].Joker > 0) then begin //Joker spielen Dec(PartySession.Teams.Teaminfo[0].Joker); SelectRandomSong; SetJoker; - end; + end; } end; SDLK_2: begin //Jocker - if (Mode = 1) AND (PartySession.Teams.NumTeams >= 2) AND (PartySession.Teams.Teaminfo[1].Joker > 0) then + {if (Mode = 1) AND (PartySession.Teams.NumTeams >= 2) AND (PartySession.Teams.Teaminfo[1].Joker > 0) then begin //Joker spielen Dec(PartySession.Teams.Teaminfo[1].Joker); SelectRandomSong; SetJoker; - end; + end; } end; SDLK_3: begin //Jocker - if (Mode = 1) AND (PartySession.Teams.NumTeams >= 3) AND (PartySession.Teams.Teaminfo[2].Joker > 0) then + {if (Mode = 1) AND (PartySession.Teams.NumTeams >= 3) AND (PartySession.Teams.Teaminfo[2].Joker > 0) then begin //Joker spielen Dec(PartySession.Teams.Teaminfo[2].Joker); SelectRandomSong; SetJoker; - end; + end; } end; end; end; @@ -1991,7 +1991,8 @@ end; procedure TScreenSong.SetJoker; begin - //If Party Mode + {//If Party Mode + // to-do : Party if Mode = 1 then //Show Joker that are available begin if (PartySession.Teams.NumTeams >= 1) then @@ -2064,7 +2065,7 @@ begin Static[StaticTeam3Joker3].Visible := False; Static[StaticTeam3Joker4].Visible := False; Static[StaticTeam3Joker5].Visible := False; - end; + end; } end; procedure TScreenSong.SetStatics; @@ -2132,13 +2133,13 @@ end; //Team No of Team (0-5) procedure TScreenSong.DoJoker (Team: Byte); begin - if (Mode = 1) AND (PartySession.Teams.NumTeams >= Team + 1) AND (PartySession.Teams.Teaminfo[Team].Joker > 0) then + {if (Mode = 1) AND (PartySession.Teams.NumTeams >= Team + 1) AND (PartySession.Teams.Teaminfo[Team].Joker > 0) then begin //Joker spielen Dec(PartySession.Teams.Teaminfo[Team].Joker); SelectRandomSong; SetJoker; - end; + end; } end; //Detailed Cover Unloading. Unloads the Detailed, uncached Cover of the cur. Song -- cgit v1.2.3 From 0723a3058fd34826251f2dbd8169131863b69df5 Mon Sep 17 00:00:00 2001 From: tobigun Date: Wed, 5 Dec 2007 21:56:25 +0000 Subject: GetFFTData() is an output- and not an input-interface's function git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@671 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 8123ef03..0def87ab 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1816,7 +1816,7 @@ begin if (A <> EqualizerTime) then begin EqualizerTime := A; - Data := AudioInput.GetFFTData; + Data := AudioPlayback.GetFFTData; B:=0; Pos := 0; -- cgit v1.2.3 From c7e01792aaf8f16bb17d7254d93157d617271391 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Tue, 18 Dec 2007 03:51:24 +0000 Subject: fixed crash on song play, if the AudioInterface reports the song as 0 length. fixed ffmpeg bug with song length. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@722 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 0def87ab..03ef793b 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1519,7 +1519,8 @@ begin if Length(CatSongs.Song) > 0 then begin //Load Music only when Song Preview is activated - if (Ini.PreviewVolume <> 0) then + if ( Ini.PreviewVolume <> 0 ) AND + ( AudioPlayback.Length > 1 ) then begin AudioPlayback.SetLoop(false); AudioPlayback.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); -- cgit v1.2.3 From bc01e7c70cf07c9758e09b07af5f788a45297eee Mon Sep 17 00:00:00 2001 From: tobigun Date: Fri, 11 Jan 2008 12:41:51 +0000 Subject: Cleanup: Use the property Position in favor of MoveTo() (MoveTo() will be SetPosition() soon) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@784 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 03ef793b..4f90e2ca 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1524,7 +1524,7 @@ begin begin AudioPlayback.SetLoop(false); AudioPlayback.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); - AudioPlayback.MoveTo(AudioPlayback.Length / 4); + AudioPlayback.Position := AudioPlayback.Length / 4; AudioPlayback.Play; //Set Preview Volume @@ -1768,7 +1768,7 @@ begin begin AudioPlayback.Close; if AudioPlayback.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin - AudioPlayback.MoveTo(AudioPlayback.Length / 4); + AudioPlayback.Position := AudioPlayback.Length / 4; //If Song Fading is activated then don't Play directly, and Set Volume to Null, else Play normal if (Ini.PreviewFading = 0) then AudioPlayback.Play -- cgit v1.2.3 From e74bd57c12f470257111c1c0530fb38f0fd34414 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Sat, 12 Jan 2008 12:31:43 +0000 Subject: bunch of smaller changes... some changes to song loading... Record global changed to singleton object started implementing mic volume display in Settings-Record hope this dosnt break anything.. :P git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@789 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 4f90e2ca..4b42288a 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -383,7 +383,7 @@ begin end; SDLK_RETURN: begin - if Length(Songs.Song) > 0 then + if Songs.SongList.Count > 0 then begin {$IFDEF UseSerialPort} // PortWriteB($378, 0); @@ -438,7 +438,7 @@ begin SDLK_M: //Show SongMenu begin - if (Length(Songs.Song) > 0) then begin + if (Songs.SongList.Count > 0) then begin if (Mode = 0) then begin if not CatSongs.Song[Interaction].Main then begin // clicked on Song if CatSongs.CatNumShow = -3 then @@ -457,14 +457,14 @@ begin SDLK_P: //Show Playlist Menu begin - if (Length(Songs.Song) > 0) AND (Mode = 0) then begin + if (Songs.SongList.Count > 0) AND (Mode = 0) then begin ScreenSongMenu.MenuShow(SM_Playlist_Load); end; end; SDLK_J: //Show Jumpto Menu begin - if (Length(Songs.Song) > 0) AND (Mode = 0) then + if (Songs.SongList.Count > 0) AND (Mode = 0) then begin ScreenSongJumpto.Visible := True; end; @@ -553,7 +553,7 @@ begin SDLK_RIGHT: begin - if (Length(Songs.Song) > 0) AND (Mode = 0) then + if (Songs.SongList.Count > 0) AND (Mode = 0) then begin AudioPlayback.PlayChange; SelectNext; @@ -568,7 +568,7 @@ begin SDLK_LEFT: begin - if (Length(Songs.Song) > 0)AND (Mode = 0) then begin + if (Songs.SongList.Count > 0)AND (Mode = 0) then begin AudioPlayback.PlayChange; SelectPrev; ChangeMusic; @@ -585,7 +585,7 @@ begin SDLK_R: begin - if (Length(Songs.Song) > 0) AND (Mode = 0) then begin + if (Songs.SongList.Count > 0) AND (Mode = 0) then begin if (SDL_ModState = KMOD_LSHIFT) AND (Ini.Tabs_at_startup = 1) then //Random Category begin @@ -1819,7 +1819,7 @@ begin EqualizerTime := A; Data := AudioPlayback.GetFFTData; - B:=0; + B := 0; Pos := 0; Res := ceil(92/Theme.Song.Equalizer.Bands);//How much channels are used for one Band @@ -2121,7 +2121,7 @@ end; procedure TScreenSong.OpenEditor; begin - if (Length(Songs.Song) > 0) and (not CatSongs.Song[Interaction].Main) AND (Mode = 0) then + if (Songs.SongList.Count > 0) and (not CatSongs.Song[Interaction].Main) AND (Mode = 0) then begin AudioPlayback.Stop; AudioPlayback.PlayStart; -- cgit v1.2.3 From f153a656e343f043673f97203ca680797196335e Mon Sep 17 00:00:00 2001 From: tobigun Date: Mon, 14 Jan 2008 00:31:20 +0000 Subject: Bugfix: when entering the song-screen the preview on the first song was never played. Reason: Length of audio-file was checked _before_ it was opened. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@793 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 4b42288a..a54bda9f 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1519,19 +1519,20 @@ begin if Length(CatSongs.Song) > 0 then begin //Load Music only when Song Preview is activated - if ( Ini.PreviewVolume <> 0 ) AND - ( AudioPlayback.Length > 1 ) then + if ( Ini.PreviewVolume <> 0 ) then begin - AudioPlayback.SetLoop(false); - AudioPlayback.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); - AudioPlayback.Position := AudioPlayback.Length / 4; - AudioPlayback.Play; - - //Set Preview Volume - AudioPlayback.SetMusicVolume (Ini.PreviewVolume * 10); - {//if Music Fade is activated, Set Volume to 0 % - if (Ini.PreviewFading <> 0) then - Music.SetMusicVolume(0);} + if(AudioPlayback.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3)) then + begin + AudioPlayback.SetLoop(false); + AudioPlayback.Position := AudioPlayback.Length / 4; + AudioPlayback.Play; + + //Set Preview Volume + AudioPlayback.SetMusicVolume (Ini.PreviewVolume * 10); + {//if Music Fade is activated, Set Volume to 0 % + if (Ini.PreviewFading <> 0) then + Music.SetMusicVolume(0);} + end; end; SetScroll; -- cgit v1.2.3 From 1b458d8b1f4723ce82bb74f2157982980274e79c Mon Sep 17 00:00:00 2001 From: jaybinks Date: Mon, 14 Jan 2008 12:27:38 +0000 Subject: tidy up sing mode, to be an enum now. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@794 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 60 +++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 28 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index a54bda9f..4773cdac 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -24,6 +24,7 @@ uses ULanguage, ULCD, ULight, + USong, UIni; type @@ -56,7 +57,8 @@ type EqualizerTime2: Byte; //Party Mod - Mode: Byte; //0 = Standard, 1= Go to PartyMode after Selection + Change to Random Song at Show + Mode: TSingMode; + //party Statics (Joker) StaticTeam1Joker1: Cardinal; StaticTeam1Joker2: Cardinal; @@ -252,7 +254,7 @@ begin + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT); //Jump to Artist/Titel - if (SDL_ModState and KMOD_LALT <> 0) AND (Mode = 0) AND (PressedKey >= SDLK_A) AND (PressedKey <= SDLK_Z) then + if (SDL_ModState and KMOD_LALT <> 0) AND (Mode = smNormal) AND (PressedKey >= SDLK_A) AND (PressedKey <= SDLK_Z) then begin Letter := UpCase(Chr(ScanCode)); I2 := Length(CatSongs.Song); @@ -312,7 +314,7 @@ begin SDLK_ESCAPE, SDLK_BACKSPACE : begin - if (Mode = 0) then + if (Mode = smNormal) then begin //On Escape goto Cat-List Hack if (Ini.Tabs_at_startup = 1) AND (CatSongs.CatNumShow <> -1) then @@ -375,7 +377,7 @@ begin end; end //When in party Mode then Ask before Close - else if (Mode = 1) then + else if (Mode = smPartyMode) then begin AudioPlayback.PlayBack; CheckFadeTo(@ScreenMain,'MSG_END_PARTY'); @@ -410,8 +412,10 @@ begin //Play Music: ChangeMusic; - end else begin // clicked on song - if (Mode = 0) then //Normal Mode -> Start Song + end + else + begin // clicked on song + if (Mode = smNormal) then //Normal Mode -> Start Song begin //Do the Action that is specified in Ini case Ini.OnSongClick of @@ -425,7 +429,7 @@ begin end; end; end - else if (Mode = 1) then //PartyMode -> Show Menu + else if (Mode = smPartyMode) then //PartyMode -> Show Menu begin if (Ini.PartyPopup = 1) then ScreenSongMenu.MenuShow(SM_Party_Main) @@ -439,7 +443,7 @@ begin SDLK_M: //Show SongMenu begin if (Songs.SongList.Count > 0) then begin - if (Mode = 0) then begin + 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) @@ -457,14 +461,14 @@ begin SDLK_P: //Show Playlist Menu begin - if (Songs.SongList.Count > 0) AND (Mode = 0) then begin + if (Songs.SongList.Count > 0) AND (Mode = smNormal) then begin ScreenSongMenu.MenuShow(SM_Playlist_Load); end; end; SDLK_J: //Show Jumpto Menu begin - if (Songs.SongList.Count > 0) AND (Mode = 0) then + if (Songs.SongList.Count > 0) AND (Mode = smNormal) then begin ScreenSongJumpto.Visible := True; end; @@ -472,7 +476,7 @@ begin SDLK_DOWN: begin - if (Mode = 0) then + if (Mode = smNormal) then begin //Only Change Cat when not in Playlist or Search Mode if (CatSongs.CatNumShow > -2) then @@ -512,7 +516,7 @@ begin end; SDLK_UP: begin - if (Mode = 0) then + if (Mode = smNormal) then begin //Only Change Cat when not in Playlist or Search Mode if (CatSongs.CatNumShow > -2) then @@ -553,7 +557,7 @@ begin SDLK_RIGHT: begin - if (Songs.SongList.Count > 0) AND (Mode = 0) then + if (Songs.SongList.Count > 0) AND (Mode = smNormal) then begin AudioPlayback.PlayChange; SelectNext; @@ -568,7 +572,7 @@ begin SDLK_LEFT: begin - if (Songs.SongList.Count > 0)AND (Mode = 0) then begin + if (Songs.SongList.Count > 0)AND (Mode = smNormal) then begin AudioPlayback.PlayChange; SelectPrev; ChangeMusic; @@ -585,7 +589,7 @@ begin SDLK_R: begin - if (Songs.SongList.Count > 0) AND (Mode = 0) then 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 begin @@ -661,7 +665,7 @@ begin SDLK_1: begin //Jocker // to-do : Party - {if (Mode = 1) 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 //Joker spielen Dec(PartySession.Teams.Teaminfo[0].Joker); @@ -672,7 +676,7 @@ begin SDLK_2: begin //Jocker - {if (Mode = 1) 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 //Joker spielen Dec(PartySession.Teams.Teaminfo[1].Joker); @@ -683,7 +687,7 @@ begin SDLK_3: begin //Jocker - {if (Mode = 1) 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 //Joker spielen Dec(PartySession.Teams.Teaminfo[2].Joker); @@ -1540,7 +1544,7 @@ begin end; //Playlist Mode - if (Mode = 0) then + if (Mode = smNormal) then begin //If Playlist Shown -> Select Next automatically if (CatSongs.CatNumShow = -3) then @@ -1550,7 +1554,7 @@ begin end; end //Party Mode - else if (Mode = 1) then + else if (Mode = smPartyMode) then begin SelectRandomSong; @@ -1931,7 +1935,7 @@ var I, I2: Integer; begin Case PlaylistMan.Mode of - 0: //All Songs Just Select Random Song + smNormal: //All Songs Just Select Random Song begin //When Tabs are activated then use Tab Method if (Ini.Tabs_at_startup = 1) then @@ -1965,7 +1969,7 @@ begin else SkipTo(Random(CatSongs.VisibleSongs)); end; - 1: //One Category Select Category and Select Random Song + smPartyMode: //One Category Select Category and Select Random Song begin CatSongs.ShowCategoryList; CatSongs.ClickCategoryButton(PlaylistMan.CurPlayList); @@ -1976,7 +1980,7 @@ begin SkipTo(Random(CatSongs.VisibleSongs)); end; - 2: //Playlist: Select Playlist and Select Random Song + smPlaylistRandom: //Playlist: Select Playlist and Select Random Song begin PlaylistMan.SetPlayList(PlaylistMan.CurPlayList); @@ -1995,7 +1999,7 @@ procedure TScreenSong.SetJoker; begin {//If Party Mode // to-do : Party - if Mode = 1 then //Show Joker that are available + if Mode = smPartyMode then //Show Joker that are available begin if (PartySession.Teams.NumTeams >= 1) then begin @@ -2076,7 +2080,7 @@ var Visible: Boolean; begin //Set Visibility of Party Statics and Text - Visible := (Mode = 1); + Visible := (Mode = smPartyMode); For I := 0 to high(StaticParty) do Static[StaticParty[I]].Visible := Visible; @@ -2101,7 +2105,7 @@ begin CatSongs.Selected := Interaction; AudioPlayback.Stop; //Party Mode - if (Mode = 1) then + if (Mode = smPartyMode) then begin FadeTo(@ScreenSingModi); end @@ -2122,7 +2126,7 @@ end; procedure TScreenSong.OpenEditor; begin - if (Songs.SongList.Count > 0) and (not CatSongs.Song[Interaction].Main) AND (Mode = 0) then + if (Songs.SongList.Count > 0) and (not CatSongs.Song[Interaction].Main) AND (Mode = smNormal) then begin AudioPlayback.Stop; AudioPlayback.PlayStart; @@ -2135,7 +2139,7 @@ end; //Team No of Team (0-5) procedure TScreenSong.DoJoker (Team: Byte); begin - {if (Mode = 1) 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 //Joker spielen Dec(PartySession.Teams.Teaminfo[Team].Joker); -- cgit v1.2.3 From dee94f5dae9e6b5ae6c7b54a12a567745abc8dc3 Mon Sep 17 00:00:00 2001 From: tobigun Date: Tue, 5 Feb 2008 20:36:19 +0000 Subject: General: - cleanup and adaption of SingDrawOscilloscope Portaudio/SDL audio output: - stuttering in portaudio output has been fixed (SDL_MixBuffers cannot be used without initializing the SDL audio stuff first, so it is not usable with portaudio. Now SDL is used for audio-output instead of portaudio (although the file-name is UAudioPlayback_Portaudio.pas at the moment). - cleaner file closing - volume adjustment UMusic: - cleanup of the audio-interfaces - introduced TNoteType = (ntFreestyle, ntNormal, ntGolden) - some bug-fixes - introduced TSoundLibrary. This is library for all in-game sounds used by USDX. Instead of calling AudioPlayer.PlaySwoosh you should call AudioPlayer.PlaySound(SoundLib.Swoosh) now. You might call SoundLib.Swoosh.Play too, but this is not recommended at the moment because SoundLib.Swoosh could be nil if the file was not found. The SoundLibrary approach is much cleaner than the previous one. The AudioPlayer does not have to specify a Play... and Stop... method for every available sound anymore. In addition it is not an AudioPlayers responsibility to init the in-game sounds. URecord: - polish to english translation of some variables - CaptureSoundLeft/Right is CaptureChannel[0/1] now - TSoundCardInput -> TAudioInputDeviceSource - TGenericSoundCard.Input -> TGenericSoundCard.Source - autocorrelation algorithm more readable now - Clean-up of the audio-input interface - moved cloned code of the input-classes to one base class (TAudioInputBase) - Cleaner finalization - Start-/StopCapture will not crash anymore in the recording-options menu - Fixed several bugs in the autocorrelation stuff (e.g. wrong usage of $10000) - SzczytJest (now ToneValid) was not used correctly. ToneValid is set to true if a valid tone was found (= the sound was louder than the threshold -> no background noise). If i remember correctly the sound was accepted although the tone was invalid. So the old data was used although noone was singing. This resulted in some sort of ghost-singer effect. UIni: - moved TIni.Card to TScreenOptionsRecord.Card because it is not stored in the ini-file and will not be in the future. - TIni.CardList ist now TIni.InputDeviceConfig. The name cardlist was misleading because it just specifies input- but no output-devices. In addition a soundcard can have multiple input-devices (at least in linux). - bugfix on InputDeviceConfig (formerly CardList) usage. USDX expected that the indices of the corresponding elements in TIni.InputDeviceConfig[] and TAudioInputProcessor.Device[] were the same. This is wrong. If device 2 was defined at first place in the ini and device 1 at the second, the indices of the two arrays didn't match (they were swapped) erroneously. To fix this and to support the item listed below the index to TIni.InputDeviceConfig[] is now stored in TAudioInputDevice.CfgIndex. NOTE: InputDeviceConfig[] contains configurations of non-available (unplugged) devices. Iterate over TAudioInputProcessor.Device[] for available devices. - configurations of external devices that are not plugged in will not be deleted anymore. - multiple definitions of one device in the ini-file will not crash USDX anymore - CardList[I].ChannelL/R now are InputDeviceConfig[I].ChannelToPlayerMap[0/1]. I think the new name is more intuitive because it maps a channel to a player number. Now the both vars are joint to one array. Now it is possible to use loops to process them and we might support more than two input channels on one device in the future (if such devices exist) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@827 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 52 +++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 4773cdac..3be0be84 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -29,6 +29,11 @@ uses type TScreenSong = class(TMenu) + private + EqualizerData: TFFTData; // moved here to avoid stack overflows + EqualizerBands: array of Byte; + EqualizerTime: Cardinal; + EqualizerTime2: Byte; public TextArtist: integer; TextTitle: integer; @@ -52,10 +57,6 @@ type is_jump: boolean; // Jump to Song Mod is_jump_title:boolean; //Jump to SOng MOd-YTrue if search for Title - EqualizerBands: array of Byte; - EqualizerTime: Cardinal; - EqualizerTime2: Byte; - //Party Mod Mode: TSingMode; @@ -270,7 +271,7 @@ begin begin SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); - AudioPlayback.PlayChange; + AudioPlayback.PlaySound(SoundLib.Change); ChangeMusic; SetScroll4; @@ -291,7 +292,7 @@ begin begin SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); - AudioPlayback.PlayChange; + AudioPlayback.PlaySound(SoundLib.Change); ChangeMusic; SetScroll4; @@ -369,7 +370,7 @@ begin else begin AudioPlayback.Stop; - AudioPlayback.PlayBack; + AudioPlayback.PlaySound(SoundLib.Back); FadeTo(@ScreenMain); end; @@ -379,7 +380,7 @@ begin //When in party Mode then Ask before Close else if (Mode = smPartyMode) then begin - AudioPlayback.PlayBack; + AudioPlayback.PlaySound(SoundLib.Back); CheckFadeTo(@ScreenMain,'MSG_END_PARTY'); end; end; @@ -504,7 +505,7 @@ begin FixSelected; //Play Music: - AudioPlayback.PlayChange; + AudioPlayback.PlaySound(SoundLib.Change); ChangeMusic; end; @@ -547,7 +548,7 @@ begin FixSelected; //Play Music: - AudioPlayback.PlayChange; + AudioPlayback.PlaySound(SoundLib.Change); ChangeMusic; end; end; @@ -559,7 +560,7 @@ begin begin if (Songs.SongList.Count > 0) AND (Mode = smNormal) then begin - AudioPlayback.PlayChange; + AudioPlayback.PlaySound(SoundLib.Change); SelectNext; // InteractNext; // SongTarget := Interaction; @@ -573,7 +574,7 @@ begin SDLK_LEFT: begin if (Songs.SongList.Count > 0)AND (Mode = smNormal) then begin - AudioPlayback.PlayChange; + AudioPlayback.PlaySound(SoundLib.Change); SelectPrev; ChangeMusic; SetScroll4; @@ -655,7 +656,7 @@ begin begin SkipTo(Random(CatSongs.VisibleSongs)); end; - AudioPlayback.PlayChange; + AudioPlayback.PlaySound(SoundLib.Change); ChangeMusic; SetScroll4; @@ -1804,7 +1805,6 @@ end; procedure TScreenSong.DrawEqualizer; var - Data: TFFTData; //Audio Data I, J: Integer; Res: byte; A, B: Integer; @@ -1822,7 +1822,7 @@ begin if (A <> EqualizerTime) then begin EqualizerTime := A; - Data := AudioPlayback.GetFFTData; + AudioPlayback.GetFFTData(EqualizerData); B := 0; Pos := 0; @@ -1850,23 +1850,23 @@ begin end; if I > 35 then - Data[i] := Data[i] * 8 + EqualizerData[i] := EqualizerData[i] * 8 else if I > 11 then - Data[i] := Data[i] * 4.5 + EqualizerData[i] := EqualizerData[i] * 4.5 else - Data[i] := Data[i] * 1.1; + EqualizerData[i] := EqualizerData[i] * 1.1; - if (Data[i] >= 1) then - Data[i] := 0.9999999999999; + if (EqualizerData[i] >= 1) then + EqualizerData[i] := 0.9999999999999; try if ( assigned( Theme ) ) AND ( assigned( Theme.Song ) ) AND - ( i < length( Data ) ) THEN + ( i < length( EqualizerData ) ) THEN begin - if single( Data[i] ) > 1 then + if single( EqualizerData[i] ) > 1 then begin - lTmp := Single(Data[i]) * Theme.Song.Equalizer.Length; + lTmp := Single(EqualizerData[i]) * Theme.Song.Equalizer.Length; if lTmp > Pos then Pos := lTmp; end; @@ -1874,7 +1874,7 @@ begin except {$IFDEF FPC} on E:EInvalidOp do - writeln( 'UScreenSong - DOH !!!! ('+inttostr(i)+' '+ inttostr( integer( Data[i] ) )+' * '+ ')' ); + writeln( 'UScreenSong - DOH !!!! ('+inttostr(i)+' '+ inttostr( integer( EqualizerData[i] ) )+' * '+ ')' ); {$ENDIF} end @@ -1989,7 +1989,7 @@ begin end; end; - AudioPlayback.PlayChange; + AudioPlayback.PlaySound(SoundLib.Change); ChangeMusic; SetScroll; UpdateLCD; @@ -2129,7 +2129,7 @@ begin if (Songs.SongList.Count > 0) and (not CatSongs.Song[Interaction].Main) AND (Mode = smNormal) then begin AudioPlayback.Stop; - AudioPlayback.PlayStart; + AudioPlayback.PlaySound(SoundLib.Start); ScreenEditSub.Path := CatSongs.Song[Interaction].Path; ScreenEditSub.FileName := CatSongs.Song[Interaction].FileName; FadeTo(@ScreenEditSub); -- cgit v1.2.3 From b4371d97f409af8ab9dc942c39f143ae400854da Mon Sep 17 00:00:00 2001 From: tobigun Date: Tue, 5 Feb 2008 21:43:57 +0000 Subject: bugfix to get the editor working again. Path and FileName have not been set. In addtion LoadSong was not used to actually load the song. Jay or some other dev: please revise the changes. The Lyric var is not set too, so it crashes on Lyric.Clear in TScreenEditSub.onShow. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@829 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenSong.pas | 4345 ++++++++++++++++++------------------- 1 file changed, 2172 insertions(+), 2173 deletions(-) (limited to 'Game/Code/Screens/UScreenSong.pas') diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 3be0be84..b142b4dc 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1,2173 +1,2172 @@ -unit UScreenSong; - -interface - -{$IFDEF FPC} - {$MODE Delphi} -{$ENDIF} - -{$I switches.inc} - - -uses - UMenu, - SDL, - UMusic, - UFiles, - UTime, - UDisplay, - USongs, - SysUtils, - ULog, - UThemes, - UTexture, - ULanguage, - ULCD, - ULight, - USong, - UIni; - -type - TScreenSong = class(TMenu) - private - EqualizerData: TFFTData; // moved here to avoid stack overflows - EqualizerBands: array of Byte; - EqualizerTime: Cardinal; - EqualizerTime2: Byte; - public - TextArtist: integer; - TextTitle: integer; - TextNumber: integer; - - //Video Icon Mod - VideoIcon: Cardinal; - - TextCat: integer; - StaticCat: integer; - - SongCurrent: real; - SongTarget: real; - - HighSpeed: boolean; - CoverFull: boolean; - CoverTime: real; - CoverX: integer; - CoverY: integer; - CoverW: integer; - is_jump: boolean; // Jump to Song Mod - is_jump_title:boolean; //Jump to SOng MOd-YTrue if search for Title - - //Party Mod - Mode: TSingMode; - - //party Statics (Joker) - StaticTeam1Joker1: Cardinal; - StaticTeam1Joker2: Cardinal; - StaticTeam1Joker3: Cardinal; - StaticTeam1Joker4: Cardinal; - StaticTeam1Joker5: Cardinal; - - StaticTeam2Joker1: Cardinal; - StaticTeam2Joker2: Cardinal; - StaticTeam2Joker3: Cardinal; - StaticTeam2Joker4: Cardinal; - StaticTeam2Joker5: Cardinal; - - StaticTeam3Joker1: Cardinal; - StaticTeam3Joker2: Cardinal; - StaticTeam3Joker3: Cardinal; - StaticTeam3Joker4: Cardinal; - StaticTeam3Joker5: Cardinal; - - StaticParty: Array of Cardinal; - TextParty: Array of Cardinal; - StaticNonParty: Array of Cardinal; - TextNonParty: Array of Cardinal; - - - constructor Create; override; - procedure SetScroll; - procedure SetScroll1; - procedure SetScroll2; - procedure SetScroll3; - procedure SetScroll4; - procedure SetScroll5; - procedure SetScroll6; - function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; - function Draw: boolean; override; - procedure GenerateThumbnails(); - procedure onShow; override; - procedure onHide; override; - procedure SelectNext; - procedure SelectPrev; - procedure UpdateLCD; - procedure SkipTo(Target: Cardinal); - procedure FixSelected; //Show Wrong Song when Tabs on Fix - procedure FixSelected2; //Show Wrong Song when Tabs on Fix - procedure ShowCatTL(Cat: Integer);// Show Cat in Top left - procedure ShowCatTLCustom(Caption: String);// Show Custom Text in Top left - procedure HideCatTL;// Show Cat in Tob left - procedure Refresh; //Refresh Song Sorting - procedure DrawEqualizer; - procedure ChangeMusic; - //Party Mode - procedure SelectRandomSong; - procedure SetJoker; - procedure SetStatics; - //procedures for Menu - procedure StartSong; - procedure OpenEditor; - procedure DoJoker(Team: Byte); - procedure SelectPlayers; - - procedure UnLoadDetailedCover; - - //Extensions - procedure DrawExtensions; - end; - -implementation -uses UGraphic, - UMain, - UCovers, - math, - OpenGL12, - {$IFDEF win32} - windows, - {$ELSE} - lclintf, - {$ENDIF} - 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 - 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; - - SongCurrent := I2; - SongTarget := I2; - end; - end; - -procedure TScreenSong.FixSelected2; -var I, I2: Integer; - begin - if CatSongs.VisibleSongs > 0 then - 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; - - SongTarget := I2; - 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; - 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, 'Plain', true); - - Static[StaticCat].Texture := Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', true); - //Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', false); - //Button[Cat]. - //Cover - - - //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 - - -// Method for input parsing. If False is returned, GetNextWindow -// should be checked to know the next window to load; -function TScreenSong.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; -var - I: integer; - I2: integer; - HS: integer; - SDL_ModState: Word; - Letter: Char; -begin - Result := true; - - //Song Screen Extensions (Jumpto + Menu) - if (ScreenSongMenu.Visible) then - begin - Result := ScreenSongMenu.ParseInput(PressedKey, ScanCode, PressedDown); - Exit; - end - else if (ScreenSongJumpto.Visible) then - begin - Result := ScreenSongJumpto.ParseInput(PressedKey, ScanCode, PressedDown); - Exit; - end; - - 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) AND (PressedKey >= SDLK_A) AND (PressedKey <= SDLK_Z) then - begin - Letter := UpCase(Chr(ScanCode)); - I2 := Length(CatSongs.Song); - - //Jump To Titel - if (SDL_ModState = KMOD_LALT or KMOD_LSHIFT) then - begin - 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 - (widechar(UpperCase(CatSongs.Song[(I + Interaction) mod I2].Title)[1]) = widechar(Letter)) then - begin - SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); - - AudioPlayback.PlaySound(SoundLib.Change); - - ChangeMusic; - SetScroll4; - UpdateLCD; - //Break and Exit - Exit; - end; - end; - end - //Jump to Artist - else if (SDL_ModState = KMOD_LALT) then - begin - 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 - (widechar(uppercase(CatSongs.Song[(I + Interaction) mod I2].Artist)[1]) = widechar(Letter)) then - begin - SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); - - AudioPlayback.PlaySound(SoundLib.Change); - - ChangeMusic; - SetScroll4; - UpdateLCD; - - //Break and Exit - Exit; - end; - end; - end; - Exit; - end; - - case PressedKey of - SDLK_Q: - begin - Result := false; - end; - - 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 - 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; - - - //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); - - //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; - SDLK_RETURN: - begin - if Songs.SongList.Count > 0 then - begin - {$IFDEF UseSerialPort} - // PortWriteB($378, 0); - {$ENDIF} - if CatSongs.Song[Interaction].Main then - begin // clicked on Category Button - - //Show Cat in Top Left Mod - ShowCatTL (Interaction); - - //I := CatSongs.VisibleIndex(Interaction); - CatSongs.ClickCategoryButton(Interaction); - {I2 := CatSongs.VisibleIndex(Interaction); - SongCurrent := SongCurrent - I + I2; - SongTarget := SongTarget - I + I2; } - -// if I<>I2 then beep; - // SetScroll4; - - //Show Wrong Song when Tabs on Fix - SelectNext; - FixSelected; - - //Play Music: - ChangeMusic; - - end - else - begin // clicked on song - if (Mode = smNormal) then //Normal Mode -> Start Song - begin - //Do the Action that is specified in Ini - case Ini.OnSongClick of - 0: StartSong; - 1: SelectPlayers; - 2:begin - If (CatSongs.CatNumShow = -3) then - ScreenSongMenu.MenuShow(SM_Playlist) - else - ScreenSongMenu.MenuShow(SM_Main); - end; - end; - end - else if (Mode = smPartyMode) then //PartyMode -> Show Menu - begin - if (Ini.PartyPopup = 1) then - ScreenSongMenu.MenuShow(SM_Party_Main) - else - ScreenSong.StartSong; - end; - end; - end; - end; - - SDLK_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 CatSongs.CatNumShow = -3 then - ScreenSongMenu.MenuShow(SM_Playlist) - else - ScreenSongMenu.MenuShow(SM_Main); - end - else - begin - ScreenSongMenu.MenuShow(SM_Playlist_Load); - end; - end //Party Mode -> Show Party Menu - else ScreenSongMenu.MenuShow(SM_Party_Main); - end; - end; - - SDLK_P: //Show Playlist Menu - begin - if (Songs.SongList.Count > 0) AND (Mode = smNormal) then begin - ScreenSongMenu.MenuShow(SM_Playlist_Load); - end; - end; - - SDLK_J: //Show Jumpto Menu - begin - if (Songs.SongList.Count > 0) AND (Mode = smNormal) then - begin - ScreenSongJumpto.Visible := True; - end; - end; - - SDLK_DOWN: - begin - if (Mode = smNormal) then - begin - //Only Change Cat when not in Playlist or Search Mode - if (CatSongs.CatNumShow > -2) then - begin - //Cat Change Hack - if Ini.Tabs_at_startup = 1 then - begin - I := Interaction; - if I <= 0 then I := 1; - - while not catsongs.Song[I].Main do - begin - Inc (I); - if (I > high(catsongs.Song)) then - I := low(catsongs.Song); - end; - - Interaction := I; - - //Show Cat in Top Left Mod - ShowCatTL (Interaction); - - CatSongs.ClickCategoryButton(Interaction); - SelectNext; - FixSelected; - - //Play Music: - AudioPlayback.PlaySound(SoundLib.Change); - ChangeMusic; - - end; - - // - //Cat Change Hack End} - end; - end; - end; - SDLK_UP: - begin - if (Mode = smNormal) then - begin - //Only Change Cat when not in Playlist or Search Mode - if (CatSongs.CatNumShow > -2) then - begin - //Cat Change Hack - if Ini.Tabs_at_startup = 1 then - begin - I := Interaction; - I2 := 0; - if I <= 0 then I := 1; - - 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; - - Interaction := I; - - //Show Cat in Top Left Mod - ShowCatTL (I); - - CatSongs.ClickCategoryButton(I); - SelectNext; - FixSelected; - - //Play Music: - AudioPlayback.PlaySound(SoundLib.Change); - ChangeMusic; - end; - end; - //Cat Change Hack End} - end; - end; - - SDLK_RIGHT: - begin - if (Songs.SongList.Count > 0) AND (Mode = smNormal) then - begin - AudioPlayback.PlaySound(SoundLib.Change); - SelectNext; -// InteractNext; -// SongTarget := Interaction; - ChangeMusic; - SetScroll4; - UpdateLCD; - Light.LightOne(1, 200); - end; - end; - - SDLK_LEFT: - begin - if (Songs.SongList.Count > 0)AND (Mode = smNormal) then begin - AudioPlayback.PlaySound(SoundLib.Change); - SelectPrev; - ChangeMusic; - SetScroll4; - UpdateLCD; - Light.LightOne(0, 200); - end; - end; - - SDLK_E: - begin - OpenEditor; - end; - - SDLK_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 - begin - 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 - Dec(I2); - if (I2<=0) then - begin - //Show Cat in Top Left Mod - ShowCatTL (I); - - Interaction := I; - - 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 - begin - 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 - begin - if CatSongs.Song[I].Main then - break; - end; - //In I ist jetzt die Kategorie in I2 der Song - - //Choose Cat - CatSongs.ShowCategoryList; - - //Show Cat in Top Left Mod - ShowCatTL (I); - - CatSongs.ClickCategoryButton(I); - SelectNext; - - //Fix: Not Existing Song selected: - //if (I+1=I2) then Inc(I2); - - //Choose Song - SkipTo(I2-I); - - end - else //Random in one Category - begin - SkipTo(Random(CatSongs.VisibleSongs)); - end; - AudioPlayback.PlaySound(SoundLib.Change); - - ChangeMusic; - SetScroll4; - UpdateLCD; - end; - end; - - SDLK_1: - begin //Jocker // to-do : Party - {if (Mode = smPartyMode) AND (PartySession.Teams.NumTeams >= 1) AND (PartySession.Teams.Teaminfo[0].Joker > 0) then - begin - //Joker spielen - Dec(PartySession.Teams.Teaminfo[0].Joker); - SelectRandomSong; - SetJoker; - end; } - end; - - SDLK_2: - begin //Jocker - {if (Mode = smPartyMode) AND (PartySession.Teams.NumTeams >= 2) AND (PartySession.Teams.Teaminfo[1].Joker > 0) then - begin - //Joker spielen - Dec(PartySession.Teams.Teaminfo[1].Joker); - SelectRandomSong; - SetJoker; - end; } - end; - - SDLK_3: - begin //Jocker - {if (Mode = smPartyMode) AND (PartySession.Teams.NumTeams >= 3) AND (PartySession.Teams.Teaminfo[2].Joker > 0) then - begin - //Joker spielen - Dec(PartySession.Teams.Teaminfo[2].Joker); - SelectRandomSong; - SetJoker; - end; } - end; - end; - end; -end; - -constructor TScreenSong.Create; -var -// Pet: integer; - I: integer; -//Label CreateSongButtons; -begin - inherited Create; - - LoadFromTheme(Theme.Song); - - TextArtist := AddText(Theme.Song.TextArtist); - TextTitle := AddText(Theme.Song.TextTitle); - TextNumber := AddText(Theme.Song.TextNumber); - - //Show Cat in Top Left mod - TextCat := AddText(Theme.Song.TextCat); - StaticCat := AddStatic(Theme.Song.StaticCat); - - //Show Video Icon Mod - VideoIcon := AddStatic(Theme.Song.VideoIcon); - - //Party Mode - StaticTeam1Joker1 := AddStatic(Theme.Song.StaticTeam1Joker1); - StaticTeam1Joker2 := AddStatic(Theme.Song.StaticTeam1Joker2); - StaticTeam1Joker3 := AddStatic(Theme.Song.StaticTeam1Joker3); - StaticTeam1Joker4 := AddStatic(Theme.Song.StaticTeam1Joker4); - StaticTeam1Joker5 := AddStatic(Theme.Song.StaticTeam1Joker5); - - StaticTeam2Joker1 := AddStatic(Theme.Song.StaticTeam2Joker1); - StaticTeam2Joker2 := AddStatic(Theme.Song.StaticTeam2Joker2); - StaticTeam2Joker3 := AddStatic(Theme.Song.StaticTeam2Joker3); - StaticTeam2Joker4 := AddStatic(Theme.Song.StaticTeam2Joker4); - StaticTeam2Joker5 := AddStatic(Theme.Song.StaticTeam2Joker5); - - StaticTeam3Joker1 := AddStatic(Theme.Song.StaticTeam3Joker1); - StaticTeam3Joker2 := AddStatic(Theme.Song.StaticTeam3Joker2); - StaticTeam3Joker3 := AddStatic(Theme.Song.StaticTeam3Joker3); - StaticTeam3Joker4 := AddStatic(Theme.Song.StaticTeam3Joker4); - StaticTeam3Joker5 := AddStatic(Theme.Song.StaticTeam3Joker5); - - //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]); - - SetLength(TextParty, Length(Theme.Song.TextParty)); - 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]); - - SetLength(TextNonParty, Length(Theme.Song.TextNonParty)); - 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 - CatSongs.Refresh; - - GenerateThumbnails(); -(* - 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)); - - I := 0; - CreateSongButtons: - - try - for Pet := I to High(CatSongs.Song) do begin // creating all buttons - // 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 - CatSongs.Song[Pet].Cover := ''; // 0.5.0: if cover not found then show 'no cover' - - if CatSongs.Song[Pet].Cover = '' then - AddButton(300 + Pet*250, 140, 200, 200, Skin.GetTextureFileName('SongCover'), 'JPG', '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 - begin - Texture.CreateCacheMipmap := true; - Texture.GetTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, '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); - - // unload full size texture - Texture.UnloadTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, 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, 'JPG', 'Plain', Theme.Song.Cover.Reflections); - end; - Texture.Limit := 1024*1024; - I := -1; - end; - except - //When Error is reported the First time for this Song - if (I <> Pet) then - begin - //Some Error reporting: - Log.LogError('Could not load Cover: ' + CatSongs.Song[Pet].Cover); - - //Change Cover to NoCover and Continue Loading - CatSongs.Song[Pet].Cover := ''; - I := Pet; - end - else //when Error occurs Multiple Times(NoSong Cover is damaged), then start loading next Song - begin - Log.LogError('NoCover Cover is damaged!'); - try - AddButton(300 + Pet*250, 140, 200, 200, '', 'JPG', 'Plain', Theme.Song.Cover.Reflections); - except - {$IFDEF MSWINDOWS} - Messagebox(0, PChar('No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'), PChar(Language.Translate('US_VERSION')), MB_ICONERROR or MB_OK); - {$ELSE} - // TODO : JB_linux - better handle this message and display to user.. - writeln( 'No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'); - Log.LogError( 'No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.' ); - {$ENDIF} - Halt; - end; - I := Pet + 1; - end; - end; - - if (I <> -1) then - GoTo CreateSongButtons; - - end; -*) - - // Randomize Patch - Randomize; - //Equalizer - SetLength(EqualizerBands, Theme.Song.Equalizer.Bands); - //ClearArray - For I := low(EqualizerBands) to high(EqualizerBands) do - EqualizerBands[I] := 3; - - if (Length(CatSongs.Song) > 0) then - Interaction := 0; -end; - -procedure TScreenSong.GenerateThumbnails(); -var - I : Integer; - Pet: integer; -Label CreateSongButtons; -begin - 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)); - - I := 0; - CreateSongButtons: - - try - for Pet := I to High(CatSongs.Song) do begin // creating all buttons - // 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 - CatSongs.Song[Pet].Cover := ''; // 0.5.0: if cover not found then show 'no cover' - - if CatSongs.Song[Pet].Cover = '' then - AddButton(300 + Pet*250, 140, 200, 200, Skin.GetTextureFileName('SongCover'), 'JPG', '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 - begin - Texture.CreateCacheMipmap := true; - Texture.GetTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, '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); - - // unload full size texture - Texture.UnloadTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, 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, 'JPG', 'Plain', Theme.Song.Cover.Reflections); - end; - Texture.Limit := 1024*1024; - I := -1; - end; - except - //When Error is reported the First time for this Song - if (I <> Pet) then - begin - //Some Error reporting: - Log.LogError('Could not load Cover: ' + CatSongs.Song[Pet].Cover); - - //Change Cover to NoCover and Continue Loading - CatSongs.Song[Pet].Cover := ''; - I := Pet; - end - else //when Error occurs Multiple Times(NoSong Cover is damaged), then start loading next Song - begin - Log.LogError('NoCover Cover is damaged!'); - try - AddButton(300 + Pet*250, 140, 200, 200, '', 'JPG', 'Plain', Theme.Song.Cover.Reflections); - except - {$IFDEF MSWINDOWS} - Messagebox(0, PChar('No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'), PChar(Language.Translate('US_VERSION')), MB_ICONERROR or MB_OK); - {$ELSE} - // TODO : JB_linux - better handle this message and display to user.. - writeln( 'No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'); - Log.LogError( 'No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.' ); - {$ENDIF} - Halt; - end; - I := Pet + 1; - end; - end; - - if (I <> -1) then - GoTo CreateSongButtons; - - end; -end; - -procedure TScreenSong.SetScroll; -var - VS, B: Integer; -begin - VS := CatSongs.VisibleSongs; - if VS > 0 then - begin - //Set Positions - Case Theme.Song.Cover.Style of - 3: SetScroll3; - 5:begin - if VS > 5 then - SetScroll5 - else - SetScroll4; - end; - 6: SetScroll6; - else SetScroll4; - end; - //Set Visibility of Video Icon - Static[VideoIcon].Visible := (CatSongs.Song[Interaction].Video <> ''); - - //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 - 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') + ')'; - end - else if (CatSongs.CatNumShow = -2) then - Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) - else if (CatSongs.CatNumShow = -3) then - Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) - 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)); - 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; - - end; -end; - -procedure TScreenSong.SetScroll1; -var - B: integer; // button - BMin: integer; // button min - BMax: integer; // button max - Src: integer; -// Dst: integer; - Count: integer; // Dst is not used. Count is used. - Ready: boolean; - - VisCount: integer; // count of visible (or selectable) buttons - VisInt: integer; // visible position of interacted button - Typ: integer; // 0 when all songs fits the screen - Placed: integer; // number of placed visible buttons -begin -// Src := 0; -// Dst := -1; - Count := 1; - Typ := 0; - Ready := false; - Placed := 0; - - VisCount := 0; - 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); - - - if VisCount <= 6 then begin - Typ := 0; - end else begin - if VisInt <= 3 then begin - Typ := 1; - Count := 7; - Ready := true; - end; - - if (VisCount - VisInt) <= 3 then begin - Typ := 2; - Count := 7; - Ready := true; - end; - - if not Ready then begin - Typ := 3; - Src := Interaction; - end; - end; - - - - // hide all buttons - for B := 0 to High(Button) do begin - Button[B].Visible := false; - Button[B].Selectable := CatSongs.Song[B].Visible; - end; - -{ 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;} - - - if Typ = 0 then begin - for B := 0 to High(Button) do begin - if CatSongs.Song[B].Visible then begin - Button[B].Visible := true; - Button[B].Y := 140 + (Placed) * 60; - Inc(Placed); - end; - end; - end; - - if Typ = 1 then begin - B := 0; - while (Count > 0) do begin - if CatSongs.Song[B].Visible then begin - Button[B].Visible := true; - Button[B].Y := 140 + (Placed) * 60; - Inc(Placed); - Dec(Count); - end; - Inc(B); - end; - end; - - if Typ = 2 then begin - B := High(Button); - while (Count > 0) do begin - if CatSongs.Song[B].Visible then begin - Button[B].Visible := true; - Button[B].Y := 140 + (6-Placed) * 60; - Inc(Placed); - Dec(Count); - end; - Dec(B); - end; - end; - - if Typ = 3 then begin - B := Src; - Count := 4; - while (Count > 0) do begin - if CatSongs.Song[B].Visible then begin - Button[B].Visible := true; - Button[B].Y := 140 + (3+Placed) * 60; - Inc(Placed); - Dec(Count); - end; - Inc(B); - end; - - B := Src-1; - Placed := 0; - Count := 3; - while (Count > 0) do begin - if CatSongs.Song[B].Visible then begin - Button[B].Visible := true; - Button[B].Y := 140 + (2-Placed) * 60; - Inc(Placed); - Dec(Count); - end; - Dec(B); - end; - - end; - - if Length(Button) > 0 then - Static[1].Texture.Y := Button[Interaction].Y - 5; // selection texture -end; - -procedure TScreenSong.SetScroll2; -var - B: integer; - Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu - Wsp2: real; -begin - // liniowe - for B := 0 to High(Button) do - Button[B].X := 300 + (B - Interaction) * 260; - - 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; - - // kolowe -{ 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;} -end; - -procedure TScreenSong.SetScroll3; // with slide -var - B: integer; - Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu - Wsp2: real; -begin - SongTarget := Interaction; - - // liniowe - for B := 0 to High(Button) do - begin - Button[B].X := 300 + (B - SongCurrent) * 260; - if (Button[B].X < -Button[B].W) OR (Button[B].X > 800) then - Button[B].Visible := False - else - Button[B].Visible := True; - end; - -{ 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;} - - // kolowe -{ 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;} -end; - -procedure TScreenSong.SetScroll4; // rotate -var - B: integer; - Wsp: real; - Z, Z2: real; - VS: integer; -begin - VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important - - // kolowe - 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 - - 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; - - - Button[B].X := Theme.Song.Cover.X + (0.185 * Theme.Song.Cover.H * VS * sin(Wsp)) * Z2 - ((Button[B].H - Theme.Song.Cover.H)/2); // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs - Button[B].Z := Z / 2 + 0.3; - - 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].H := Button[B].W; - end; - end; -end; - -(* -procedure TScreenSong.SetScroll4; // rotate -var - B: integer; - Wsp: real; - Z: real; - Z2, Z3: real; - VS: integer; - function modreal (const X, Y: real):real; - begin - Result := Frac(x / y) * y; - if Result < -3 then - Result := Result + Y - else if Result > 3 then - Result := Result - Y; - end; -begin - VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important - Z3 := 1; - if VS < 12 then - Z2 := VS - else - Z2 := 12; - - // kolowe - 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 - begin - if CatSongs.VisibleIndex(B)> SongCurrent then - Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / Z2 - else - Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / Z2; - - Z3 := 2; - Z := (1 + cos(Wsp)) / 2; - //Z2 := (1 + 2*Z) / 3; - //Z2 := (0.5 + Z/2); - //Z2 := sin(Wsp); - - //Z2 := Power (Z2,Z3); - - Button[B].W := Theme.Song.CoverW * Power(cos(Wsp), Z3);//Power(Z2, 3); - - //Button[B].X := Theme.Song.CoverX + ({Theme.Song.CoverX + Theme.Song.CoverW/2 + Theme.Song.CoverW*0.18 * VS {CatSongs.VisibleSongs {Length(Button) * sin(Wsp) {- Theme.Song.CoverX - Theme.Song.CoverW) * Z2; // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs - if (sin(Wsp)<0) then - Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX + Theme.Song.CoverW - Button[B].W - else //*Theme.Song.CoverW*0.004*Z3 - 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 := (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 - begin - Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / 12 ;// 0.5.0 (II): takes another 16ms - - Z := (1 + cos(Wsp)) / 2 -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers - - Button[B].W := Theme.Song.CoverW * Power(cos(Wsp), Z3);//Power(Z2, 3); - - if (sin(Wsp)<0) then - Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX + Theme.Song.CoverW - Button[B].W - else - Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX; - - Button[B].Z := Z; - - Button[B].Y := (Theme.Song.CoverY + Theme.Song.CoverW - Button[B].W); - - Button[B].H := Button[B].W; - Button[B].Visible := True; - end - else Button[B].Visible := False; - end; - end; -end; *) - -procedure TScreenSong.SetScroll5; // rotate -var - B: integer; - Angle: real; - Pos: Real; - VS: integer; - diff: real; - X: Real; - helper: real; -begin - VS := CatSongs.VisibleSongs; // cache Visible Songs - {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 - Theme.Song.CoverH: Höhe der Cover - - (CatSongs.VisibleIndex(B) - SongCurrent)/VS = Abstand zum MIttleren Cover in % - } - - //Change Pos of all Buttons - for B := low(Button) to high(Button) do - begin - Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visibility - if Button[B].Visible then //Only Change Pos for Visible Buttons - begin - Pos := (CatSongs.VisibleIndex(B) - SongCurrent); - if (Pos < -VS/2) then - Pos := Pos + VS - else if (Pos > VS/2) then - Pos := Pos - VS; - - if (Abs(Pos) < 2.5) then {fixed Positions} - begin - Angle := Pi * (Pos / 5); -// 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].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; - - Button[B].Z := 0.95 - Abs(Pos) * 0.01; - - Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); - - Button[B].W := Button[B].H; - - Diff := (Button[B].H - Theme.Song.Cover.H)/2; - - - X := Sin(Angle*1.3)*0.9; - - Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * X - Diff; - - end - else - begin {Behind the Front Covers} - - // limit-bg-covers hack - if (abs(abs(Pos)-VS/2)>10) then Button[B].Visible:=False; - // end of limit-bg-covers hack - - if Pos < 0 then - Pos := (Pos - VS/2)/VS - else - Pos := (Pos + VS/2)/VS; - - Angle := pi * Pos*2; - if VS > 24 then - begin - if Angle < 0 then helper:=-1 else helper:=1; - Angle:=2*pi-abs(Angle); - Angle:=Angle*(VS/24); - Angle:=(2*pi-Angle)*helper; - end; - - Button[B].Z := (0.4 - Abs(Pos/4)) -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers - - Button[B].H :=0.6*(Theme.Song.Cover.H-Abs(Theme.Song.Cover.H * cos(Angle/2)*0.8));//Power(Z2, 3); - - Button[B].W := Button[B].H; - - 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].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; - - Diff := (Button[B].H - Theme.Song.Cover.H)/2; - - Button[B].X := Theme.Song.Cover.X+Theme.Song.Cover.H/2-Button[b].H/2+Theme.Song.Cover.W/320*((Theme.Song.Cover.H)*sin(Angle/2)*1.52); - - 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); - - end; - end; -end; - -procedure TScreenSong.SetScroll6; // rotate (slotmachine style) -var - B: integer; - Angle: real; - Pos: Real; - VS: integer; - diff: real; - X: Real; - Wsp: real; - Z, Z2: real; -begin - VS := CatSongs.VisibleSongs; // cache Visible Songs - if VS <=5 then begin - // kolowe - 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 - - 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; - - - Button[B].Y := Theme.Song.Cover.Y + (0.185 * Theme.Song.Cover.H * VS * sin(Wsp)) * Z2 - ((Button[B].H - Theme.Song.Cover.H)/2); // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs - Button[B].Z := Z / 2 + 0.3; - - Button[B].W := Theme.Song.Cover.H * 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; - end; - end - else begin - - //Change Pos of all Buttons - for B := low(Button) to high(Button) do - begin - Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visibility - if Button[B].Visible then //Only Change Pos for Visible Buttons - begin - Pos := (CatSongs.VisibleIndex(B) - SongCurrent); - if (Pos < -VS/2) then - Pos := Pos + VS - else if (Pos > VS/2) then - Pos := Pos - VS; - - if (Abs(Pos) < 2.5) then {fixed Positions} - begin - Angle := Pi * (Pos / 5); -// Button[B].Visible := False; - - Button[B].H := Abs(Theme.Song.Cover.H * cos(Angle*0.8));//Power(Z2, 3); - - Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; - - Button[B].Z := 0.95 - Abs(Pos) * 0.01; - - Button[B].X := (Theme.Song.Cover.X + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); - - Button[B].W := Button[B].H; - - Diff := (Button[B].H - Theme.Song.Cover.H)/2; - - - X := Sin(Angle*1.3)*0.9; - - Button[B].Y := Theme.Song.Cover.Y + Theme.Song.Cover.W * X - Diff; - end - else - begin {Behind the Front Covers} - - // limit-bg-covers hack - if (abs(VS/2-abs(Pos))>10) then Button[B].Visible:=False; - if VS > 25 then VS:=25; - // end of limit-bg-covers hack - - if Pos < 0 then - Pos := (Pos - VS/2)/VS - else - Pos := (Pos + VS/2)/VS; - - 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 - - Button[B].H :=0.6*(Theme.Song.Cover.H-Abs(Theme.Song.Cover.H * cos(Angle/2)*0.8));//Power(Z2, 3); - - Button[B].W := Button[B].H; - - Button[B].X := Theme.Song.Cover.X - (Button[B].H - Theme.Song.Cover.H)*0.5; - - - Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; - - Button[B].Y := Theme.Song.Cover.Y+Theme.Song.Cover.H/2-Button[b].H/2+Theme.Song.Cover.W/320*(Theme.Song.Cover.H*sin(Angle/2)*1.52); - end; - end; - end; - end; -end; - - -procedure TScreenSong.onShow; -begin - AudioPlayback.Stop; - - if Ini.Players <= 3 then PlayersPlay := Ini.Players + 1; - 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 Length(CatSongs.Song) > 0 then begin - //Load Music only when Song Preview is activated - if ( Ini.PreviewVolume <> 0 ) then - begin - if(AudioPlayback.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3)) then - begin - AudioPlayback.SetLoop(false); - AudioPlayback.Position := AudioPlayback.Length / 4; - AudioPlayback.Play; - - //Set Preview Volume - AudioPlayback.SetMusicVolume (Ini.PreviewVolume * 10); - {//if Music Fade is activated, Set Volume to 0 % - if (Ini.PreviewFading <> 0) then - Music.SetMusicVolume(0);} - end; - end; - - SetScroll; - UpdateLCD; - end; - - //Playlist Mode - if (Mode = smNormal) then - begin - //If Playlist Shown -> Select Next automatically - if (CatSongs.CatNumShow = -3) then - begin - SelectNext; - ChangeMusic; - end; - end - //Party Mode - else if (Mode = smPartyMode) then - begin - - SelectRandomSong; - //Show Menu directly in PartyMode - //But only if selected in Options - if (Ini.PartyPopup = 1) then - begin - ScreenSongMenu.MenuShow(SM_Party_Main); - end; - - - end; - - SetJoker; - SetStatics; -end; - -procedure TScreenSong.onHide; -begin - //When Music Fading is activated, Turn Music to 100 % - If (Ini.PreviewVolume <> 100) or (Ini.PreviewFading <> 0) then - AudioPlayback.SetMusicVolume(100); - - //If Preview is deactivated: Load MUsicfile now - 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 - AudioPlayback.Stop; -end; - -procedure TScreenSong.DrawExtensions; -begin - //Draw Song Menu - if (ScreenSongMenu.Visible) then - begin - ScreenSongMenu.Draw; - end - else if (ScreenSongJumpto.Visible) then - begin - ScreenSongJumpto.Draw; - end -end; - -function TScreenSong.Draw: boolean; -var - dx: real; - dt: real; - I: Integer; -begin - dx := SongTarget-SongCurrent; - dt := TimeSkip * 7; - -// writeln( 'TScreenSong.Draw '+ inttostr(trunc(TimeSkip)) ); - - if dt > 1 then - dt := 1; - - SongCurrent := SongCurrent + dx*dt; - -{ if SongCurrent > Catsongs.VisibleSongs then begin - SongCurrent := SongCurrent - Catsongs.VisibleSongs; - SongTarget := SongTarget - Catsongs.VisibleSongs; - end;} - -// Log.BenchmarkStart(5); - SetScroll; -// Log.BenchmarkEnd(5); -// Log.LogBenchmark('SetScroll4', 5); - - //Fading Functions, Only if Covertime is under 5 Seconds - If (CoverTime < 5) then - begin - // 0.5.0: cover fade - if (CoverTime < 1) and (CoverTime + TimeSkip >= 1) then - begin - // load new texture - Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); - Button[Interaction].Texture.Alpha := 1; - Button[Interaction].Texture2 := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); - Button[Interaction].Texture2.Alpha := 1; - end; - - //Song Fade - 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 - AudioPlayback.Play; - - //Update Song Volume - if (CoverTime < Ini.PreviewFading) then - AudioPlayback.SetMusicVolume(Round (CoverTime * Ini.PreviewVolume / Ini.PreviewFading * 10)) - else - AudioPlayback.SetMusicVolume(Ini.PreviewVolume * 10); - - end; - - - //Update Fading Time - CoverTime := CoverTime + TimeSkip; - - //Update Fading Texture - Button[Interaction].Texture2.Alpha := (CoverTime - 1) * 1.5; - if Button[Interaction].Texture2.Alpha > 1 then Button[Interaction].Texture2.Alpha := 1; - - end; - - //inherited Draw; - //heres a little Hack, that causes the Statics - //are Drawn after the Buttons because of some Blending Problems. - //This should cause no Problems because all Buttons on this screen - //Has Z Position. - //Draw BG - DrawBG; - - //Instead of Draw FG Procedure: - //We draw Buttons for our own - for I := 0 to Length(Button) - 1 do - Button[I].Draw; - - // Statics - for I := 0 to Length(Static) - 1 do - Static[I].Draw; - - // and texts - for I := 0 to Length(Text) - 1 do - Text[I].Draw; - - - //Draw Equalizer - if Theme.Song.Equalizer.Visible then - DrawEqualizer; - - DrawExtensions; - -end; - -procedure TScreenSong.SelectNext; -var - Skip: integer; - I: integer; - VS: Integer; -begin - VS := CatSongs.VisibleSongs; - - if VS > 0 then - begin - UnLoadDetailedCover; - - Skip := 1; - - // this 1 could be changed by CatSongs.FindNextVisible - while (not CatSongs.Song[(Interaction + Skip) mod Length(Interactions)].Visible) do Inc(Skip); - - SongTarget := SongTarget + 1;//Skip; - - Interaction := (Interaction + Skip) mod Length(Interactions); - - // try to keep all at the beginning - if SongTarget > VS-1 then begin - SongTarget := SongTarget - VS; - SongCurrent := SongCurrent - VS; - end; - - end; - // Interaction -> Button, ktorego okladke przeczytamy - // Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture -end; - -procedure TScreenSong.SelectPrev; -var - Skip: integer; - I: integer; - VS: Integer; -begin - VS := CatSongs.VisibleSongs; - - if VS > 0 then - begin - UnLoadDetailedCover; - - Skip := 1; - - 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); - - // try to keep all at the beginning - if SongTarget < 0 then begin - SongTarget := SongTarget + CatSongs.VisibleSongs; - SongCurrent := SongCurrent + CatSongs.VisibleSongs; - end; - - // Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture - end; -end; - -procedure TScreenSong.UpdateLCD; -begin - LCD.HideCursor; - LCD.Clear; - LCD.WriteText(1, Text[TextArtist].Text); - LCD.WriteText(2, Text[TextTitle].Text); -end; - -//Procedure Change current played Preview -procedure TScreenSong.ChangeMusic; -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 - begin - AudioPlayback.Close; - if AudioPlayback.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin - AudioPlayback.Position := AudioPlayback.Length / 4; - //If Song Fading is activated then don't Play directly, and Set Volume to Null, else Play normal - if (Ini.PreviewFading = 0) then - AudioPlayback.Play - else - AudioPlayback.SetMusicVolume(0); - end; - end - else - AudioPlayback.Stop; - end; -end; - -procedure TScreenSong.SkipTo(Target: Cardinal); // 0.5.0 -var - Skip: integer; - I: integer; -begin - UnLoadDetailedCover; - - Interaction := High(CatSongs.Song); - SongTarget := 0; - - for I := 1 to Target+1 do - SelectNext; - - FixSelected2; -end; - -procedure TScreenSong.DrawEqualizer; -var - I, J: Integer; - Res: byte; - A, B: Integer; - PosX, PosY: Integer; - Pos: Real; - lTmp : double; -begin - -if (not AudioPlayback.Finished) AND (Theme.Song.Equalizer.Length > 0) then -begin - - {$ifdef win32} - A := GetTickCount div 44; - - if (A <> EqualizerTime) then - begin - EqualizerTime := A; - AudioPlayback.GetFFTData(EqualizerData); - - B := 0; - Pos := 0; - Res := ceil(92/Theme.Song.Equalizer.Bands);//How much channels are used for one Band - - //Change Lengths - for I := 0 to (Res * Theme.Song.Equalizer.Bands - 1) do - begin - A := floor(I/Res); - - if (A<>B) then //Band changed - begin - if (Pos <= Theme.Song.Equalizer.Length) then - begin - if ((Pos < EqualizerBands[B]) AND (EqualizerBands[B]>1)) then - EqualizerBands[B] := EqualizerBands[B] - 1 - else - EqualizerBands[B] := floor(Pos); - end - else - EqualizerBands[B] := 1; - - B := A; - Pos := 0; - end; - - if I > 35 then - EqualizerData[i] := EqualizerData[i] * 8 - else if I > 11 then - EqualizerData[i] := EqualizerData[i] * 4.5 - else - EqualizerData[i] := EqualizerData[i] * 1.1; - - if (EqualizerData[i] >= 1) then - EqualizerData[i] := 0.9999999999999; - - try - if ( assigned( Theme ) ) AND - ( assigned( Theme.Song ) ) AND - ( i < length( EqualizerData ) ) THEN - begin - if single( EqualizerData[i] ) > 1 then - begin - lTmp := Single(EqualizerData[i]) * Theme.Song.Equalizer.Length; - if lTmp > Pos then - Pos := lTmp; - end; - end; - except - {$IFDEF FPC} - on E:EInvalidOp do - writeln( 'UScreenSong - DOH !!!! ('+inttostr(i)+' '+ inttostr( integer( EqualizerData[i] ) )+' * '+ ')' ); - {$ENDIF} - end - - end; - - //Change Last Band - if (EqualizerBands[B] <= Theme.Song.Equalizer.Length) then - begin - if ((Pos < EqualizerBands[B]) AND (EqualizerBands[B]>1)) then - EqualizerBands[B] := EqualizerBands[B] - 1 - else - EqualizerBands[B] := floor(Pos) - end - else - EqualizerBands[B] := 1; - end; - {$endif} - - //Draw every Channel - glColor4f(Theme.Song.Equalizer.ColR, Theme.Song.Equalizer.ColG, Theme.Song.Equalizer.ColB, Theme.Song.Equalizer.Alpha); //Set Color - glDisable(GL_TEXTURE_2D); - glEnable(GL_BLEND); - - PosY := Theme.Song.Equalizer.Y; - PosX := Theme.Song.Equalizer.X; - - For I := 0 to Theme.Song.Equalizer.Bands-1 do - begin - if Theme.Song.Equalizer.Direction then - PosY := Theme.Song.Equalizer.Y //+ (Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space) * Theme.Song.Equalizer.Length - else - PosX := Theme.Song.Equalizer.X; - //Draw for every visible quad - for J := 1 to EqualizerBands[I] do - begin - glBegin(GL_QUADS); - glVertex3f(PosX, PosY, Theme.Song.Equalizer.Z); - glVertex3f(PosX, PosY+Theme.Song.Equalizer.H, Theme.Song.Equalizer.Z); - glVertex3f(PosX+Theme.Song.Equalizer.W, PosY+Theme.Song.Equalizer.H, Theme.Song.Equalizer.Z); - glVertex3f(PosX+Theme.Song.Equalizer.W, PosY, Theme.Song.Equalizer.Z); - glEnd; - - if Theme.Song.Equalizer.Direction then //Vertically - PosY := PosY - Theme.Song.Equalizer.H - Theme.Song.Equalizer.Space - else //Horizontally - PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space; - end; - if Theme.Song.Equalizer.Direction then //Horizontally - PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space - else //Vertically - PosY := PosY + Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space; - end; -end; -end; - -Procedure TScreenSong.SelectRandomSong; -var - I, I2: Integer; -begin - Case PlaylistMan.Mode of - smNormal: //All Songs Just Select Random Song - begin - //When Tabs are activated then use Tab Method - if (Ini.Tabs_at_startup = 1) then - begin - 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 - begin - if CatSongs.Song[I].Main then - break; - 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 - - //Choose Cat - CatSongs.ShowCategoryList; - - //Show Cat in Top Left Mod - ShowCatTL (I); - - CatSongs.ClickCategoryButton(I); - SelectNext; - - //Choose Song - SkipTo(I2-I); - end - //When Tabs are deactivated use easy Method - else - SkipTo(Random(CatSongs.VisibleSongs)); - end; - smPartyMode: //One Category Select Category and Select Random Song - begin - CatSongs.ShowCategoryList; - CatSongs.ClickCategoryButton(PlaylistMan.CurPlayList); - ShowCatTL(PlaylistMan.CurPlayList); - - SelectNext; - FixSelected2; - - SkipTo(Random(CatSongs.VisibleSongs)); - end; - smPlaylistRandom: //Playlist: Select Playlist and Select Random Song - begin - PlaylistMan.SetPlayList(PlaylistMan.CurPlayList); - - SkipTo(Random(CatSongs.VisibleSongs)); - FixSelected2; - end; - end; - - AudioPlayback.PlaySound(SoundLib.Change); - ChangeMusic; - SetScroll; - UpdateLCD; -end; - -procedure TScreenSong.SetJoker; -begin - {//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); - Static[StaticTeam1Joker2].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 2); - Static[StaticTeam1Joker3].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 3); - Static[StaticTeam1Joker4].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 4); - Static[StaticTeam1Joker5].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 5); - end - else - begin - Static[StaticTeam1Joker1].Visible := False; - Static[StaticTeam1Joker2].Visible := False; - Static[StaticTeam1Joker3].Visible := False; - Static[StaticTeam1Joker4].Visible := False; - Static[StaticTeam1Joker5].Visible := False; - end; - - if (PartySession.Teams.NumTeams >= 2) then - begin - Static[StaticTeam2Joker1].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 1); - Static[StaticTeam2Joker2].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 2); - Static[StaticTeam2Joker3].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 3); - Static[StaticTeam2Joker4].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 4); - Static[StaticTeam2Joker5].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 5); - end - else - begin - Static[StaticTeam2Joker1].Visible := False; - Static[StaticTeam2Joker2].Visible := False; - Static[StaticTeam2Joker3].Visible := False; - Static[StaticTeam2Joker4].Visible := False; - Static[StaticTeam2Joker5].Visible := False; - end; - - if (PartySession.Teams.NumTeams >= 3) then - begin - Static[StaticTeam3Joker1].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 1); - Static[StaticTeam3Joker2].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 2); - Static[StaticTeam3Joker3].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 3); - Static[StaticTeam3Joker4].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 4); - Static[StaticTeam3Joker5].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 5); - end - else - begin - Static[StaticTeam3Joker1].Visible := False; - Static[StaticTeam3Joker2].Visible := False; - Static[StaticTeam3Joker3].Visible := False; - Static[StaticTeam3Joker4].Visible := False; - Static[StaticTeam3Joker5].Visible := False; - end; - end - else - begin //Hide all - Static[StaticTeam1Joker1].Visible := False; - Static[StaticTeam1Joker2].Visible := False; - Static[StaticTeam1Joker3].Visible := False; - Static[StaticTeam1Joker4].Visible := False; - Static[StaticTeam1Joker5].Visible := False; - - Static[StaticTeam2Joker1].Visible := False; - Static[StaticTeam2Joker2].Visible := False; - Static[StaticTeam2Joker3].Visible := False; - Static[StaticTeam2Joker4].Visible := False; - Static[StaticTeam2Joker5].Visible := False; - - Static[StaticTeam3Joker1].Visible := False; - Static[StaticTeam3Joker2].Visible := False; - Static[StaticTeam3Joker3].Visible := False; - Static[StaticTeam3Joker4].Visible := False; - Static[StaticTeam3Joker5].Visible := False; - end; } -end; - -procedure TScreenSong.SetStatics; -var - I: Integer; - Visible: Boolean; -begin - //Set Visibility of Party Statics and Text - Visible := (Mode = smPartyMode); - - For I := 0 to high(StaticParty) do - Static[StaticParty[I]].Visible := Visible; - - 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 - Static[StaticNonParty[I]].Visible := Visible; - - For I := 0 to high(TextNonParty) do - Text[TextNonParty[I]].Visible := Visible; -end; - -//Procedures for Menu - -procedure TScreenSong.StartSong; -begin - CatSongs.Selected := Interaction; - AudioPlayback.Stop; - //Party Mode - if (Mode = smPartyMode) then - begin - FadeTo(@ScreenSingModi); - end - else - begin - FadeTo(@ScreenSing); - end; -end; - -procedure TScreenSong.SelectPlayers; -begin - CatSongs.Selected := Interaction; - AudioPlayback.Stop; - - ScreenName.Goto_SingScreen := True; - FadeTo(@ScreenName); -end; - -procedure TScreenSong.OpenEditor; -begin - if (Songs.SongList.Count > 0) and (not CatSongs.Song[Interaction].Main) AND (Mode = smNormal) then - begin - AudioPlayback.Stop; - AudioPlayback.PlaySound(SoundLib.Start); - ScreenEditSub.Path := CatSongs.Song[Interaction].Path; - ScreenEditSub.FileName := CatSongs.Song[Interaction].FileName; - FadeTo(@ScreenEditSub); - end; -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 - begin - //Joker spielen - Dec(PartySession.Teams.Teaminfo[Team].Joker); - SelectRandomSong; - SetJoker; - 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, 'Plain', true); // 0.5.0: show cached texture - Button[Interaction].Texture2.Alpha := 0; - - if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then - Texture.UnloadTexture(Button[Interaction].Texture.Name, false); -end; - -procedure TScreenSong.Refresh; -begin { -CatSongs.Refresh; -CatSongs.ShowCategoryList; -Interaction := 0; -SelectNext; -FixSelected; } - -end; - -end. +unit UScreenSong; + +interface + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + +{$I switches.inc} + + +uses + UMenu, + SDL, + UMusic, + UFiles, + UTime, + UDisplay, + USongs, + SysUtils, + ULog, + UThemes, + UTexture, + ULanguage, + ULCD, + ULight, + USong, + UIni; + +type + TScreenSong = class(TMenu) + private + EqualizerData: TFFTData; // moved here to avoid stack overflows + EqualizerBands: array of Byte; + EqualizerTime: Cardinal; + EqualizerTime2: Byte; + public + TextArtist: integer; + TextTitle: integer; + TextNumber: integer; + + //Video Icon Mod + VideoIcon: Cardinal; + + TextCat: integer; + StaticCat: integer; + + SongCurrent: real; + SongTarget: real; + + HighSpeed: boolean; + CoverFull: boolean; + CoverTime: real; + CoverX: integer; + CoverY: integer; + CoverW: integer; + is_jump: boolean; // Jump to Song Mod + is_jump_title:boolean; //Jump to SOng MOd-YTrue if search for Title + + //Party Mod + Mode: TSingMode; + + //party Statics (Joker) + StaticTeam1Joker1: Cardinal; + StaticTeam1Joker2: Cardinal; + StaticTeam1Joker3: Cardinal; + StaticTeam1Joker4: Cardinal; + StaticTeam1Joker5: Cardinal; + + StaticTeam2Joker1: Cardinal; + StaticTeam2Joker2: Cardinal; + StaticTeam2Joker3: Cardinal; + StaticTeam2Joker4: Cardinal; + StaticTeam2Joker5: Cardinal; + + StaticTeam3Joker1: Cardinal; + StaticTeam3Joker2: Cardinal; + StaticTeam3Joker3: Cardinal; + StaticTeam3Joker4: Cardinal; + StaticTeam3Joker5: Cardinal; + + StaticParty: Array of Cardinal; + TextParty: Array of Cardinal; + StaticNonParty: Array of Cardinal; + TextNonParty: Array of Cardinal; + + + constructor Create; override; + procedure SetScroll; + procedure SetScroll1; + procedure SetScroll2; + procedure SetScroll3; + procedure SetScroll4; + procedure SetScroll5; + procedure SetScroll6; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + function Draw: boolean; override; + procedure GenerateThumbnails(); + procedure onShow; override; + procedure onHide; override; + procedure SelectNext; + procedure SelectPrev; + procedure UpdateLCD; + procedure SkipTo(Target: Cardinal); + procedure FixSelected; //Show Wrong Song when Tabs on Fix + procedure FixSelected2; //Show Wrong Song when Tabs on Fix + procedure ShowCatTL(Cat: Integer);// Show Cat in Top left + procedure ShowCatTLCustom(Caption: String);// Show Custom Text in Top left + procedure HideCatTL;// Show Cat in Tob left + procedure Refresh; //Refresh Song Sorting + procedure DrawEqualizer; + procedure ChangeMusic; + //Party Mode + procedure SelectRandomSong; + procedure SetJoker; + procedure SetStatics; + //procedures for Menu + procedure StartSong; + procedure OpenEditor; + procedure DoJoker(Team: Byte); + procedure SelectPlayers; + + procedure UnLoadDetailedCover; + + //Extensions + procedure DrawExtensions; + end; + +implementation +uses UGraphic, + UMain, + UCovers, + math, + OpenGL12, + {$IFDEF win32} + windows, + {$ELSE} + lclintf, + {$ENDIF} + 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 + 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; + + SongCurrent := I2; + SongTarget := I2; + end; + end; + +procedure TScreenSong.FixSelected2; +var I, I2: Integer; + begin + if CatSongs.VisibleSongs > 0 then + 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; + + SongTarget := I2; + 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; + 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, 'Plain', true); + + Static[StaticCat].Texture := Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', true); + //Texture.GetTexture(Button[Cat].Texture.Name, 'Plain', false); + //Button[Cat]. + //Cover + + + //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 + + +// Method for input parsing. If False is returned, GetNextWindow +// should be checked to know the next window to load; +function TScreenSong.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +var + I: integer; + I2: integer; + HS: integer; + SDL_ModState: Word; + Letter: Char; +begin + Result := true; + + //Song Screen Extensions (Jumpto + Menu) + if (ScreenSongMenu.Visible) then + begin + Result := ScreenSongMenu.ParseInput(PressedKey, ScanCode, PressedDown); + Exit; + end + else if (ScreenSongJumpto.Visible) then + begin + Result := ScreenSongJumpto.ParseInput(PressedKey, ScanCode, PressedDown); + Exit; + end; + + 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) AND (PressedKey >= SDLK_A) AND (PressedKey <= SDLK_Z) then + begin + Letter := UpCase(Chr(ScanCode)); + I2 := Length(CatSongs.Song); + + //Jump To Titel + if (SDL_ModState = KMOD_LALT or KMOD_LSHIFT) then + begin + 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 + (widechar(UpperCase(CatSongs.Song[(I + Interaction) mod I2].Title)[1]) = widechar(Letter)) then + begin + SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); + + AudioPlayback.PlaySound(SoundLib.Change); + + ChangeMusic; + SetScroll4; + UpdateLCD; + //Break and Exit + Exit; + end; + end; + end + //Jump to Artist + else if (SDL_ModState = KMOD_LALT) then + begin + 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 + (widechar(uppercase(CatSongs.Song[(I + Interaction) mod I2].Artist)[1]) = widechar(Letter)) then + begin + SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); + + AudioPlayback.PlaySound(SoundLib.Change); + + ChangeMusic; + SetScroll4; + UpdateLCD; + + //Break and Exit + Exit; + end; + end; + end; + Exit; + end; + + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + + 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 + 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; + + + //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); + + //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; + SDLK_RETURN: + begin + if Songs.SongList.Count > 0 then + begin + {$IFDEF UseSerialPort} + // PortWriteB($378, 0); + {$ENDIF} + if CatSongs.Song[Interaction].Main then + begin // clicked on Category Button + + //Show Cat in Top Left Mod + ShowCatTL (Interaction); + + //I := CatSongs.VisibleIndex(Interaction); + CatSongs.ClickCategoryButton(Interaction); + {I2 := CatSongs.VisibleIndex(Interaction); + SongCurrent := SongCurrent - I + I2; + SongTarget := SongTarget - I + I2; } + +// if I<>I2 then beep; + // SetScroll4; + + //Show Wrong Song when Tabs on Fix + SelectNext; + FixSelected; + + //Play Music: + ChangeMusic; + + end + else + begin // clicked on song + if (Mode = smNormal) then //Normal Mode -> Start Song + begin + //Do the Action that is specified in Ini + case Ini.OnSongClick of + 0: StartSong; + 1: SelectPlayers; + 2:begin + If (CatSongs.CatNumShow = -3) then + ScreenSongMenu.MenuShow(SM_Playlist) + else + ScreenSongMenu.MenuShow(SM_Main); + end; + end; + end + else if (Mode = smPartyMode) then //PartyMode -> Show Menu + begin + if (Ini.PartyPopup = 1) then + ScreenSongMenu.MenuShow(SM_Party_Main) + else + ScreenSong.StartSong; + end; + end; + end; + end; + + SDLK_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 CatSongs.CatNumShow = -3 then + ScreenSongMenu.MenuShow(SM_Playlist) + else + ScreenSongMenu.MenuShow(SM_Main); + end + else + begin + ScreenSongMenu.MenuShow(SM_Playlist_Load); + end; + end //Party Mode -> Show Party Menu + else ScreenSongMenu.MenuShow(SM_Party_Main); + end; + end; + + SDLK_P: //Show Playlist Menu + begin + if (Songs.SongList.Count > 0) AND (Mode = smNormal) then begin + ScreenSongMenu.MenuShow(SM_Playlist_Load); + end; + end; + + SDLK_J: //Show Jumpto Menu + begin + if (Songs.SongList.Count > 0) AND (Mode = smNormal) then + begin + ScreenSongJumpto.Visible := True; + end; + end; + + SDLK_DOWN: + begin + if (Mode = smNormal) then + begin + //Only Change Cat when not in Playlist or Search Mode + if (CatSongs.CatNumShow > -2) then + begin + //Cat Change Hack + if Ini.Tabs_at_startup = 1 then + begin + I := Interaction; + if I <= 0 then I := 1; + + while not catsongs.Song[I].Main do + begin + Inc (I); + if (I > high(catsongs.Song)) then + I := low(catsongs.Song); + end; + + Interaction := I; + + //Show Cat in Top Left Mod + ShowCatTL (Interaction); + + CatSongs.ClickCategoryButton(Interaction); + SelectNext; + FixSelected; + + //Play Music: + AudioPlayback.PlaySound(SoundLib.Change); + ChangeMusic; + + end; + + // + //Cat Change Hack End} + end; + end; + end; + SDLK_UP: + begin + if (Mode = smNormal) then + begin + //Only Change Cat when not in Playlist or Search Mode + if (CatSongs.CatNumShow > -2) then + begin + //Cat Change Hack + if Ini.Tabs_at_startup = 1 then + begin + I := Interaction; + I2 := 0; + if I <= 0 then I := 1; + + 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; + + Interaction := I; + + //Show Cat in Top Left Mod + ShowCatTL (I); + + CatSongs.ClickCategoryButton(I); + SelectNext; + FixSelected; + + //Play Music: + AudioPlayback.PlaySound(SoundLib.Change); + ChangeMusic; + end; + end; + //Cat Change Hack End} + end; + end; + + SDLK_RIGHT: + begin + if (Songs.SongList.Count > 0) AND (Mode = smNormal) then + begin + AudioPlayback.PlaySound(SoundLib.Change); + SelectNext; +// InteractNext; +// SongTarget := Interaction; + ChangeMusic; + SetScroll4; + UpdateLCD; + Light.LightOne(1, 200); + end; + end; + + SDLK_LEFT: + begin + if (Songs.SongList.Count > 0)AND (Mode = smNormal) then begin + AudioPlayback.PlaySound(SoundLib.Change); + SelectPrev; + ChangeMusic; + SetScroll4; + UpdateLCD; + Light.LightOne(0, 200); + end; + end; + + SDLK_E: + begin + OpenEditor; + end; + + SDLK_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 + begin + 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 + Dec(I2); + if (I2<=0) then + begin + //Show Cat in Top Left Mod + ShowCatTL (I); + + Interaction := I; + + 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 + begin + 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 + begin + if CatSongs.Song[I].Main then + break; + end; + //In I ist jetzt die Kategorie in I2 der Song + + //Choose Cat + CatSongs.ShowCategoryList; + + //Show Cat in Top Left Mod + ShowCatTL (I); + + CatSongs.ClickCategoryButton(I); + SelectNext; + + //Fix: Not Existing Song selected: + //if (I+1=I2) then Inc(I2); + + //Choose Song + SkipTo(I2-I); + + end + else //Random in one Category + begin + SkipTo(Random(CatSongs.VisibleSongs)); + end; + AudioPlayback.PlaySound(SoundLib.Change); + + ChangeMusic; + SetScroll4; + UpdateLCD; + end; + end; + + SDLK_1: + begin //Jocker // to-do : Party + {if (Mode = smPartyMode) AND (PartySession.Teams.NumTeams >= 1) AND (PartySession.Teams.Teaminfo[0].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[0].Joker); + SelectRandomSong; + SetJoker; + end; } + end; + + SDLK_2: + begin //Jocker + {if (Mode = smPartyMode) AND (PartySession.Teams.NumTeams >= 2) AND (PartySession.Teams.Teaminfo[1].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[1].Joker); + SelectRandomSong; + SetJoker; + end; } + end; + + SDLK_3: + begin //Jocker + {if (Mode = smPartyMode) AND (PartySession.Teams.NumTeams >= 3) AND (PartySession.Teams.Teaminfo[2].Joker > 0) then + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[2].Joker); + SelectRandomSong; + SetJoker; + end; } + end; + end; + end; +end; + +constructor TScreenSong.Create; +var +// Pet: integer; + I: integer; +//Label CreateSongButtons; +begin + inherited Create; + + LoadFromTheme(Theme.Song); + + TextArtist := AddText(Theme.Song.TextArtist); + TextTitle := AddText(Theme.Song.TextTitle); + TextNumber := AddText(Theme.Song.TextNumber); + + //Show Cat in Top Left mod + TextCat := AddText(Theme.Song.TextCat); + StaticCat := AddStatic(Theme.Song.StaticCat); + + //Show Video Icon Mod + VideoIcon := AddStatic(Theme.Song.VideoIcon); + + //Party Mode + StaticTeam1Joker1 := AddStatic(Theme.Song.StaticTeam1Joker1); + StaticTeam1Joker2 := AddStatic(Theme.Song.StaticTeam1Joker2); + StaticTeam1Joker3 := AddStatic(Theme.Song.StaticTeam1Joker3); + StaticTeam1Joker4 := AddStatic(Theme.Song.StaticTeam1Joker4); + StaticTeam1Joker5 := AddStatic(Theme.Song.StaticTeam1Joker5); + + StaticTeam2Joker1 := AddStatic(Theme.Song.StaticTeam2Joker1); + StaticTeam2Joker2 := AddStatic(Theme.Song.StaticTeam2Joker2); + StaticTeam2Joker3 := AddStatic(Theme.Song.StaticTeam2Joker3); + StaticTeam2Joker4 := AddStatic(Theme.Song.StaticTeam2Joker4); + StaticTeam2Joker5 := AddStatic(Theme.Song.StaticTeam2Joker5); + + StaticTeam3Joker1 := AddStatic(Theme.Song.StaticTeam3Joker1); + StaticTeam3Joker2 := AddStatic(Theme.Song.StaticTeam3Joker2); + StaticTeam3Joker3 := AddStatic(Theme.Song.StaticTeam3Joker3); + StaticTeam3Joker4 := AddStatic(Theme.Song.StaticTeam3Joker4); + StaticTeam3Joker5 := AddStatic(Theme.Song.StaticTeam3Joker5); + + //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]); + + SetLength(TextParty, Length(Theme.Song.TextParty)); + 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]); + + SetLength(TextNonParty, Length(Theme.Song.TextNonParty)); + 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 + CatSongs.Refresh; + + GenerateThumbnails(); +(* + 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)); + + I := 0; + CreateSongButtons: + + try + for Pet := I to High(CatSongs.Song) do begin // creating all buttons + // 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 + CatSongs.Song[Pet].Cover := ''; // 0.5.0: if cover not found then show 'no cover' + + if CatSongs.Song[Pet].Cover = '' then + AddButton(300 + Pet*250, 140, 200, 200, Skin.GetTextureFileName('SongCover'), 'JPG', '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 + begin + Texture.CreateCacheMipmap := true; + Texture.GetTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, '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); + + // unload full size texture + Texture.UnloadTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, 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, 'JPG', 'Plain', Theme.Song.Cover.Reflections); + end; + Texture.Limit := 1024*1024; + I := -1; + end; + except + //When Error is reported the First time for this Song + if (I <> Pet) then + begin + //Some Error reporting: + Log.LogError('Could not load Cover: ' + CatSongs.Song[Pet].Cover); + + //Change Cover to NoCover and Continue Loading + CatSongs.Song[Pet].Cover := ''; + I := Pet; + end + else //when Error occurs Multiple Times(NoSong Cover is damaged), then start loading next Song + begin + Log.LogError('NoCover Cover is damaged!'); + try + AddButton(300 + Pet*250, 140, 200, 200, '', 'JPG', 'Plain', Theme.Song.Cover.Reflections); + except + {$IFDEF MSWINDOWS} + Messagebox(0, PChar('No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'), PChar(Language.Translate('US_VERSION')), MB_ICONERROR or MB_OK); + {$ELSE} + // TODO : JB_linux - better handle this message and display to user.. + writeln( 'No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'); + Log.LogError( 'No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.' ); + {$ENDIF} + Halt; + end; + I := Pet + 1; + end; + end; + + if (I <> -1) then + GoTo CreateSongButtons; + + end; +*) + + // Randomize Patch + Randomize; + //Equalizer + SetLength(EqualizerBands, Theme.Song.Equalizer.Bands); + //ClearArray + For I := low(EqualizerBands) to high(EqualizerBands) do + EqualizerBands[I] := 3; + + if (Length(CatSongs.Song) > 0) then + Interaction := 0; +end; + +procedure TScreenSong.GenerateThumbnails(); +var + I : Integer; + Pet: integer; +Label CreateSongButtons; +begin + 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)); + + I := 0; + CreateSongButtons: + + try + for Pet := I to High(CatSongs.Song) do begin // creating all buttons + // 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 + CatSongs.Song[Pet].Cover := ''; // 0.5.0: if cover not found then show 'no cover' + + if CatSongs.Song[Pet].Cover = '' then + AddButton(300 + Pet*250, 140, 200, 200, Skin.GetTextureFileName('SongCover'), 'JPG', '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 + begin + Texture.CreateCacheMipmap := true; + Texture.GetTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, '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); + + // unload full size texture + Texture.UnloadTexture(CatSongs.Song[Pet].Path + CatSongs.Song[Pet].Cover, 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, 'JPG', 'Plain', Theme.Song.Cover.Reflections); + end; + Texture.Limit := 1024*1024; + I := -1; + end; + except + //When Error is reported the First time for this Song + if (I <> Pet) then + begin + //Some Error reporting: + Log.LogError('Could not load Cover: ' + CatSongs.Song[Pet].Cover); + + //Change Cover to NoCover and Continue Loading + CatSongs.Song[Pet].Cover := ''; + I := Pet; + end + else //when Error occurs Multiple Times(NoSong Cover is damaged), then start loading next Song + begin + Log.LogError('NoCover Cover is damaged!'); + try + AddButton(300 + Pet*250, 140, 200, 200, '', 'JPG', 'Plain', Theme.Song.Cover.Reflections); + except + {$IFDEF MSWINDOWS} + Messagebox(0, PChar('No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'), PChar(Language.Translate('US_VERSION')), MB_ICONERROR or MB_OK); + {$ELSE} + // TODO : JB_linux - better handle this message and display to user.. + writeln( 'No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.'); + Log.LogError( 'No Cover Image is damage. Could not Workaround Song Loading, Ultrastar will exit now.' ); + {$ENDIF} + Halt; + end; + I := Pet + 1; + end; + end; + + if (I <> -1) then + GoTo CreateSongButtons; + + end; +end; + +procedure TScreenSong.SetScroll; +var + VS, B: Integer; +begin + VS := CatSongs.VisibleSongs; + if VS > 0 then + begin + //Set Positions + Case Theme.Song.Cover.Style of + 3: SetScroll3; + 5:begin + if VS > 5 then + SetScroll5 + else + SetScroll4; + end; + 6: SetScroll6; + else SetScroll4; + end; + //Set Visibility of Video Icon + Static[VideoIcon].Visible := (CatSongs.Song[Interaction].Video <> ''); + + //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 + 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') + ')'; + end + else if (CatSongs.CatNumShow = -2) then + Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) + else if (CatSongs.CatNumShow = -3) then + Text[TextNumber].Text := IntToStr(CatSongs.VisibleIndex(Interaction)+1) + '/' + IntToStr(VS) + 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)); + 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; + + end; +end; + +procedure TScreenSong.SetScroll1; +var + B: integer; // button + BMin: integer; // button min + BMax: integer; // button max + Src: integer; +// Dst: integer; + Count: integer; // Dst is not used. Count is used. + Ready: boolean; + + VisCount: integer; // count of visible (or selectable) buttons + VisInt: integer; // visible position of interacted button + Typ: integer; // 0 when all songs fits the screen + Placed: integer; // number of placed visible buttons +begin +// Src := 0; +// Dst := -1; + Count := 1; + Typ := 0; + Ready := false; + Placed := 0; + + VisCount := 0; + 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); + + + if VisCount <= 6 then begin + Typ := 0; + end else begin + if VisInt <= 3 then begin + Typ := 1; + Count := 7; + Ready := true; + end; + + if (VisCount - VisInt) <= 3 then begin + Typ := 2; + Count := 7; + Ready := true; + end; + + if not Ready then begin + Typ := 3; + Src := Interaction; + end; + end; + + + + // hide all buttons + for B := 0 to High(Button) do begin + Button[B].Visible := false; + Button[B].Selectable := CatSongs.Song[B].Visible; + end; + +{ 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;} + + + if Typ = 0 then begin + for B := 0 to High(Button) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (Placed) * 60; + Inc(Placed); + end; + end; + end; + + if Typ = 1 then begin + B := 0; + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Inc(B); + end; + end; + + if Typ = 2 then begin + B := High(Button); + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (6-Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Dec(B); + end; + end; + + if Typ = 3 then begin + B := Src; + Count := 4; + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (3+Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Inc(B); + end; + + B := Src-1; + Placed := 0; + Count := 3; + while (Count > 0) do begin + if CatSongs.Song[B].Visible then begin + Button[B].Visible := true; + Button[B].Y := 140 + (2-Placed) * 60; + Inc(Placed); + Dec(Count); + end; + Dec(B); + end; + + end; + + if Length(Button) > 0 then + Static[1].Texture.Y := Button[Interaction].Y - 5; // selection texture +end; + +procedure TScreenSong.SetScroll2; +var + B: integer; + Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu + Wsp2: real; +begin + // liniowe + for B := 0 to High(Button) do + Button[B].X := 300 + (B - Interaction) * 260; + + 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; + + // kolowe +{ 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;} +end; + +procedure TScreenSong.SetScroll3; // with slide +var + B: integer; + Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu + Wsp2: real; +begin + SongTarget := Interaction; + + // liniowe + for B := 0 to High(Button) do + begin + Button[B].X := 300 + (B - SongCurrent) * 260; + if (Button[B].X < -Button[B].W) OR (Button[B].X > 800) then + Button[B].Visible := False + else + Button[B].Visible := True; + end; + +{ 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;} + + // kolowe +{ 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;} +end; + +procedure TScreenSong.SetScroll4; // rotate +var + B: integer; + Wsp: real; + Z, Z2: real; + VS: integer; +begin + VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important + + // kolowe + 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 + + 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; + + + Button[B].X := Theme.Song.Cover.X + (0.185 * Theme.Song.Cover.H * VS * sin(Wsp)) * Z2 - ((Button[B].H - Theme.Song.Cover.H)/2); // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs + Button[B].Z := Z / 2 + 0.3; + + 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].H := Button[B].W; + end; + end; +end; + +(* +procedure TScreenSong.SetScroll4; // rotate +var + B: integer; + Wsp: real; + Z: real; + Z2, Z3: real; + VS: integer; + function modreal (const X, Y: real):real; + begin + Result := Frac(x / y) * y; + if Result < -3 then + Result := Result + Y + else if Result > 3 then + Result := Result - Y; + end; +begin + VS := CatSongs.VisibleSongs; // 0.5.0 (I): cached, very important + Z3 := 1; + if VS < 12 then + Z2 := VS + else + Z2 := 12; + + // kolowe + 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 + begin + if CatSongs.VisibleIndex(B)> SongCurrent then + Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / Z2 + else + Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / Z2; + + Z3 := 2; + Z := (1 + cos(Wsp)) / 2; + //Z2 := (1 + 2*Z) / 3; + //Z2 := (0.5 + Z/2); + //Z2 := sin(Wsp); + + //Z2 := Power (Z2,Z3); + + Button[B].W := Theme.Song.CoverW * Power(cos(Wsp), Z3);//Power(Z2, 3); + + //Button[B].X := Theme.Song.CoverX + ({Theme.Song.CoverX + Theme.Song.CoverW/2 + Theme.Song.CoverW*0.18 * VS {CatSongs.VisibleSongs {Length(Button) * sin(Wsp) {- Theme.Song.CoverX - Theme.Song.CoverW) * Z2; // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs + if (sin(Wsp)<0) then + Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX + Theme.Song.CoverW - Button[B].W + else //*Theme.Song.CoverW*0.004*Z3 + 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 := (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 + begin + Wsp := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / 12 ;// 0.5.0 (II): takes another 16ms + + Z := (1 + cos(Wsp)) / 2 -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers + + Button[B].W := Theme.Song.CoverW * Power(cos(Wsp), Z3);//Power(Z2, 3); + + if (sin(Wsp)<0) then + Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX + Theme.Song.CoverW - Button[B].W + else + Button[B].X := sin(Wsp)*Theme.Song.CoverX*Theme.Song.CoverW*0.007 + Theme.Song.CoverX; + + Button[B].Z := Z; + + Button[B].Y := (Theme.Song.CoverY + Theme.Song.CoverW - Button[B].W); + + Button[B].H := Button[B].W; + Button[B].Visible := True; + end + else Button[B].Visible := False; + end; + end; +end; *) + +procedure TScreenSong.SetScroll5; // rotate +var + B: integer; + Angle: real; + Pos: Real; + VS: integer; + diff: real; + X: Real; + helper: real; +begin + VS := CatSongs.VisibleSongs; // cache Visible Songs + {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 + Theme.Song.CoverH: Höhe der Cover + + (CatSongs.VisibleIndex(B) - SongCurrent)/VS = Abstand zum MIttleren Cover in % + } + + //Change Pos of all Buttons + for B := low(Button) to high(Button) do + begin + Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visibility + if Button[B].Visible then //Only Change Pos for Visible Buttons + begin + Pos := (CatSongs.VisibleIndex(B) - SongCurrent); + if (Pos < -VS/2) then + Pos := Pos + VS + else if (Pos > VS/2) then + Pos := Pos - VS; + + if (Abs(Pos) < 2.5) then {fixed Positions} + begin + Angle := Pi * (Pos / 5); +// 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].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + + Button[B].Z := 0.95 - Abs(Pos) * 0.01; + + Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); + + Button[B].W := Button[B].H; + + Diff := (Button[B].H - Theme.Song.Cover.H)/2; + + + X := Sin(Angle*1.3)*0.9; + + Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * X - Diff; + + end + else + begin {Behind the Front Covers} + + // limit-bg-covers hack + if (abs(abs(Pos)-VS/2)>10) then Button[B].Visible:=False; + // end of limit-bg-covers hack + + if Pos < 0 then + Pos := (Pos - VS/2)/VS + else + Pos := (Pos + VS/2)/VS; + + Angle := pi * Pos*2; + if VS > 24 then + begin + if Angle < 0 then helper:=-1 else helper:=1; + Angle:=2*pi-abs(Angle); + Angle:=Angle*(VS/24); + Angle:=(2*pi-Angle)*helper; + end; + + Button[B].Z := (0.4 - Abs(Pos/4)) -0.00001; //z < 0.49999 is behind the cover 1 is in front of the covers + + Button[B].H :=0.6*(Theme.Song.Cover.H-Abs(Theme.Song.Cover.H * cos(Angle/2)*0.8));//Power(Z2, 3); + + Button[B].W := Button[B].H; + + 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].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + + Diff := (Button[B].H - Theme.Song.Cover.H)/2; + + Button[B].X := Theme.Song.Cover.X+Theme.Song.Cover.H/2-Button[b].H/2+Theme.Song.Cover.W/320*((Theme.Song.Cover.H)*sin(Angle/2)*1.52); + + 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); + + end; + end; +end; + +procedure TScreenSong.SetScroll6; // rotate (slotmachine style) +var + B: integer; + Angle: real; + Pos: Real; + VS: integer; + diff: real; + X: Real; + Wsp: real; + Z, Z2: real; +begin + VS := CatSongs.VisibleSongs; // cache Visible Songs + if VS <=5 then begin + // kolowe + 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 + + 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; + + + Button[B].Y := Theme.Song.Cover.Y + (0.185 * Theme.Song.Cover.H * VS * sin(Wsp)) * Z2 - ((Button[B].H - Theme.Song.Cover.H)/2); // 0.5.0 (I): 2 times faster by not calling CatSongs.VisibleSongs + Button[B].Z := Z / 2 + 0.3; + + Button[B].W := Theme.Song.Cover.H * 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; + end; + end + else begin + + //Change Pos of all Buttons + for B := low(Button) to high(Button) do + begin + Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visibility + if Button[B].Visible then //Only Change Pos for Visible Buttons + begin + Pos := (CatSongs.VisibleIndex(B) - SongCurrent); + if (Pos < -VS/2) then + Pos := Pos + VS + else if (Pos > VS/2) then + Pos := Pos - VS; + + if (Abs(Pos) < 2.5) then {fixed Positions} + begin + Angle := Pi * (Pos / 5); +// Button[B].Visible := False; + + Button[B].H := Abs(Theme.Song.Cover.H * cos(Angle*0.8));//Power(Z2, 3); + + Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + + Button[B].Z := 0.95 - Abs(Pos) * 0.01; + + Button[B].X := (Theme.Song.Cover.X + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); + + Button[B].W := Button[B].H; + + Diff := (Button[B].H - Theme.Song.Cover.H)/2; + + + X := Sin(Angle*1.3)*0.9; + + Button[B].Y := Theme.Song.Cover.Y + Theme.Song.Cover.W * X - Diff; + end + else + begin {Behind the Front Covers} + + // limit-bg-covers hack + if (abs(VS/2-abs(Pos))>10) then Button[B].Visible:=False; + if VS > 25 then VS:=25; + // end of limit-bg-covers hack + + if Pos < 0 then + Pos := (Pos - VS/2)/VS + else + Pos := (Pos + VS/2)/VS; + + 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 + + Button[B].H :=0.6*(Theme.Song.Cover.H-Abs(Theme.Song.Cover.H * cos(Angle/2)*0.8));//Power(Z2, 3); + + Button[B].W := Button[B].H; + + Button[B].X := Theme.Song.Cover.X - (Button[B].H - Theme.Song.Cover.H)*0.5; + + + Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + + Button[B].Y := Theme.Song.Cover.Y+Theme.Song.Cover.H/2-Button[b].H/2+Theme.Song.Cover.W/320*(Theme.Song.Cover.H*sin(Angle/2)*1.52); + end; + end; + end; + end; +end; + + +procedure TScreenSong.onShow; +begin + AudioPlayback.Stop; + + if Ini.Players <= 3 then PlayersPlay := Ini.Players + 1; + 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 Length(CatSongs.Song) > 0 then begin + //Load Music only when Song Preview is activated + if ( Ini.PreviewVolume <> 0 ) then + begin + if(AudioPlayback.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3)) then + begin + AudioPlayback.SetLoop(false); + AudioPlayback.Position := AudioPlayback.Length / 4; + AudioPlayback.Play; + + //Set Preview Volume + AudioPlayback.SetMusicVolume (Ini.PreviewVolume * 10); + {//if Music Fade is activated, Set Volume to 0 % + if (Ini.PreviewFading <> 0) then + Music.SetMusicVolume(0);} + end; + end; + + SetScroll; + UpdateLCD; + end; + + //Playlist Mode + if (Mode = smNormal) then + begin + //If Playlist Shown -> Select Next automatically + if (CatSongs.CatNumShow = -3) then + begin + SelectNext; + ChangeMusic; + end; + end + //Party Mode + else if (Mode = smPartyMode) then + begin + + SelectRandomSong; + //Show Menu directly in PartyMode + //But only if selected in Options + if (Ini.PartyPopup = 1) then + begin + ScreenSongMenu.MenuShow(SM_Party_Main); + end; + + + end; + + SetJoker; + SetStatics; +end; + +procedure TScreenSong.onHide; +begin + //When Music Fading is activated, Turn Music to 100 % + If (Ini.PreviewVolume <> 100) or (Ini.PreviewFading <> 0) then + AudioPlayback.SetMusicVolume(100); + + //If Preview is deactivated: Load MUsicfile now + 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 + AudioPlayback.Stop; +end; + +procedure TScreenSong.DrawExtensions; +begin + //Draw Song Menu + if (ScreenSongMenu.Visible) then + begin + ScreenSongMenu.Draw; + end + else if (ScreenSongJumpto.Visible) then + begin + ScreenSongJumpto.Draw; + end +end; + +function TScreenSong.Draw: boolean; +var + dx: real; + dt: real; + I: Integer; +begin + dx := SongTarget-SongCurrent; + dt := TimeSkip * 7; + +// writeln( 'TScreenSong.Draw '+ inttostr(trunc(TimeSkip)) ); + + if dt > 1 then + dt := 1; + + SongCurrent := SongCurrent + dx*dt; + +{ if SongCurrent > Catsongs.VisibleSongs then begin + SongCurrent := SongCurrent - Catsongs.VisibleSongs; + SongTarget := SongTarget - Catsongs.VisibleSongs; + end;} + +// Log.BenchmarkStart(5); + SetScroll; +// Log.BenchmarkEnd(5); +// Log.LogBenchmark('SetScroll4', 5); + + //Fading Functions, Only if Covertime is under 5 Seconds + If (CoverTime < 5) then + begin + // 0.5.0: cover fade + if (CoverTime < 1) and (CoverTime + TimeSkip >= 1) then + begin + // load new texture + Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); + Button[Interaction].Texture.Alpha := 1; + Button[Interaction].Texture2 := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); + Button[Interaction].Texture2.Alpha := 1; + end; + + //Song Fade + 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 + AudioPlayback.Play; + + //Update Song Volume + if (CoverTime < Ini.PreviewFading) then + AudioPlayback.SetMusicVolume(Round (CoverTime * Ini.PreviewVolume / Ini.PreviewFading * 10)) + else + AudioPlayback.SetMusicVolume(Ini.PreviewVolume * 10); + + end; + + + //Update Fading Time + CoverTime := CoverTime + TimeSkip; + + //Update Fading Texture + Button[Interaction].Texture2.Alpha := (CoverTime - 1) * 1.5; + if Button[Interaction].Texture2.Alpha > 1 then Button[Interaction].Texture2.Alpha := 1; + + end; + + //inherited Draw; + //heres a little Hack, that causes the Statics + //are Drawn after the Buttons because of some Blending Problems. + //This should cause no Problems because all Buttons on this screen + //Has Z Position. + //Draw BG + DrawBG; + + //Instead of Draw FG Procedure: + //We draw Buttons for our own + for I := 0 to Length(Button) - 1 do + Button[I].Draw; + + // Statics + for I := 0 to Length(Static) - 1 do + Static[I].Draw; + + // and texts + for I := 0 to Length(Text) - 1 do + Text[I].Draw; + + + //Draw Equalizer + if Theme.Song.Equalizer.Visible then + DrawEqualizer; + + DrawExtensions; + +end; + +procedure TScreenSong.SelectNext; +var + Skip: integer; + I: integer; + VS: Integer; +begin + VS := CatSongs.VisibleSongs; + + if VS > 0 then + begin + UnLoadDetailedCover; + + Skip := 1; + + // this 1 could be changed by CatSongs.FindNextVisible + while (not CatSongs.Song[(Interaction + Skip) mod Length(Interactions)].Visible) do Inc(Skip); + + SongTarget := SongTarget + 1;//Skip; + + Interaction := (Interaction + Skip) mod Length(Interactions); + + // try to keep all at the beginning + if SongTarget > VS-1 then begin + SongTarget := SongTarget - VS; + SongCurrent := SongCurrent - VS; + end; + + end; + // Interaction -> Button, ktorego okladke przeczytamy + // Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture +end; + +procedure TScreenSong.SelectPrev; +var + Skip: integer; + I: integer; + VS: Integer; +begin + VS := CatSongs.VisibleSongs; + + if VS > 0 then + begin + UnLoadDetailedCover; + + Skip := 1; + + 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); + + // try to keep all at the beginning + if SongTarget < 0 then begin + SongTarget := SongTarget + CatSongs.VisibleSongs; + SongCurrent := SongCurrent + CatSongs.VisibleSongs; + end; + + // Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false); // 0.5.0: show uncached texture + end; +end; + +procedure TScreenSong.UpdateLCD; +begin + LCD.HideCursor; + LCD.Clear; + LCD.WriteText(1, Text[TextArtist].Text); + LCD.WriteText(2, Text[TextTitle].Text); +end; + +//Procedure Change current played Preview +procedure TScreenSong.ChangeMusic; +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 + begin + AudioPlayback.Close; + if AudioPlayback.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin + AudioPlayback.Position := AudioPlayback.Length / 4; + //If Song Fading is activated then don't Play directly, and Set Volume to Null, else Play normal + if (Ini.PreviewFading = 0) then + AudioPlayback.Play + else + AudioPlayback.SetMusicVolume(0); + end; + end + else + AudioPlayback.Stop; + end; +end; + +procedure TScreenSong.SkipTo(Target: Cardinal); // 0.5.0 +var + Skip: integer; + I: integer; +begin + UnLoadDetailedCover; + + Interaction := High(CatSongs.Song); + SongTarget := 0; + + for I := 1 to Target+1 do + SelectNext; + + FixSelected2; +end; + +procedure TScreenSong.DrawEqualizer; +var + I, J: Integer; + Res: byte; + A, B: Integer; + PosX, PosY: Integer; + Pos: Real; + lTmp : double; +begin + +if (not AudioPlayback.Finished) AND (Theme.Song.Equalizer.Length > 0) then +begin + + {$ifdef win32} + A := GetTickCount div 44; + + if (A <> EqualizerTime) then + begin + EqualizerTime := A; + AudioPlayback.GetFFTData(EqualizerData); + + B := 0; + Pos := 0; + Res := ceil(92/Theme.Song.Equalizer.Bands);//How much channels are used for one Band + + //Change Lengths + for I := 0 to (Res * Theme.Song.Equalizer.Bands - 1) do + begin + A := floor(I/Res); + + if (A<>B) then //Band changed + begin + if (Pos <= Theme.Song.Equalizer.Length) then + begin + if ((Pos < EqualizerBands[B]) AND (EqualizerBands[B]>1)) then + EqualizerBands[B] := EqualizerBands[B] - 1 + else + EqualizerBands[B] := floor(Pos); + end + else + EqualizerBands[B] := 1; + + B := A; + Pos := 0; + end; + + if I > 35 then + EqualizerData[i] := EqualizerData[i] * 8 + else if I > 11 then + EqualizerData[i] := EqualizerData[i] * 4.5 + else + EqualizerData[i] := EqualizerData[i] * 1.1; + + if (EqualizerData[i] >= 1) then + EqualizerData[i] := 0.9999999999999; + + try + if ( assigned( Theme ) ) AND + ( assigned( Theme.Song ) ) AND + ( i < length( EqualizerData ) ) THEN + begin + if single( EqualizerData[i] ) > 1 then + begin + lTmp := Single(EqualizerData[i]) * Theme.Song.Equalizer.Length; + if lTmp > Pos then + Pos := lTmp; + end; + end; + except + {$IFDEF FPC} + on E:EInvalidOp do + writeln( 'UScreenSong - DOH !!!! ('+inttostr(i)+' '+ inttostr( integer( EqualizerData[i] ) )+' * '+ ')' ); + {$ENDIF} + end + + end; + + //Change Last Band + if (EqualizerBands[B] <= Theme.Song.Equalizer.Length) then + begin + if ((Pos < EqualizerBands[B]) AND (EqualizerBands[B]>1)) then + EqualizerBands[B] := EqualizerBands[B] - 1 + else + EqualizerBands[B] := floor(Pos) + end + else + EqualizerBands[B] := 1; + end; + {$endif} + + //Draw every Channel + glColor4f(Theme.Song.Equalizer.ColR, Theme.Song.Equalizer.ColG, Theme.Song.Equalizer.ColB, Theme.Song.Equalizer.Alpha); //Set Color + glDisable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + + PosY := Theme.Song.Equalizer.Y; + PosX := Theme.Song.Equalizer.X; + + For I := 0 to Theme.Song.Equalizer.Bands-1 do + begin + if Theme.Song.Equalizer.Direction then + PosY := Theme.Song.Equalizer.Y //+ (Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space) * Theme.Song.Equalizer.Length + else + PosX := Theme.Song.Equalizer.X; + //Draw for every visible quad + for J := 1 to EqualizerBands[I] do + begin + glBegin(GL_QUADS); + glVertex3f(PosX, PosY, Theme.Song.Equalizer.Z); + glVertex3f(PosX, PosY+Theme.Song.Equalizer.H, Theme.Song.Equalizer.Z); + glVertex3f(PosX+Theme.Song.Equalizer.W, PosY+Theme.Song.Equalizer.H, Theme.Song.Equalizer.Z); + glVertex3f(PosX+Theme.Song.Equalizer.W, PosY, Theme.Song.Equalizer.Z); + glEnd; + + if Theme.Song.Equalizer.Direction then //Vertically + PosY := PosY - Theme.Song.Equalizer.H - Theme.Song.Equalizer.Space + else //Horizontally + PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space; + end; + if Theme.Song.Equalizer.Direction then //Horizontally + PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space + else //Vertically + PosY := PosY + Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space; + end; +end; +end; + +Procedure TScreenSong.SelectRandomSong; +var + I, I2: Integer; +begin + Case PlaylistMan.Mode of + smNormal: //All Songs Just Select Random Song + begin + //When Tabs are activated then use Tab Method + if (Ini.Tabs_at_startup = 1) then + begin + 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 + begin + if CatSongs.Song[I].Main then + break; + 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 + + //Choose Cat + CatSongs.ShowCategoryList; + + //Show Cat in Top Left Mod + ShowCatTL (I); + + CatSongs.ClickCategoryButton(I); + SelectNext; + + //Choose Song + SkipTo(I2-I); + end + //When Tabs are deactivated use easy Method + else + SkipTo(Random(CatSongs.VisibleSongs)); + end; + smPartyMode: //One Category Select Category and Select Random Song + begin + CatSongs.ShowCategoryList; + CatSongs.ClickCategoryButton(PlaylistMan.CurPlayList); + ShowCatTL(PlaylistMan.CurPlayList); + + SelectNext; + FixSelected2; + + SkipTo(Random(CatSongs.VisibleSongs)); + end; + smPlaylistRandom: //Playlist: Select Playlist and Select Random Song + begin + PlaylistMan.SetPlayList(PlaylistMan.CurPlayList); + + SkipTo(Random(CatSongs.VisibleSongs)); + FixSelected2; + end; + end; + + AudioPlayback.PlaySound(SoundLib.Change); + ChangeMusic; + SetScroll; + UpdateLCD; +end; + +procedure TScreenSong.SetJoker; +begin + {//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); + Static[StaticTeam1Joker2].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 2); + Static[StaticTeam1Joker3].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 3); + Static[StaticTeam1Joker4].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 4); + Static[StaticTeam1Joker5].Visible := (PartySession.Teams.Teaminfo[0].Joker >= 5); + end + else + begin + Static[StaticTeam1Joker1].Visible := False; + Static[StaticTeam1Joker2].Visible := False; + Static[StaticTeam1Joker3].Visible := False; + Static[StaticTeam1Joker4].Visible := False; + Static[StaticTeam1Joker5].Visible := False; + end; + + if (PartySession.Teams.NumTeams >= 2) then + begin + Static[StaticTeam2Joker1].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 1); + Static[StaticTeam2Joker2].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 2); + Static[StaticTeam2Joker3].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 3); + Static[StaticTeam2Joker4].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 4); + Static[StaticTeam2Joker5].Visible := (PartySession.Teams.Teaminfo[1].Joker >= 5); + end + else + begin + Static[StaticTeam2Joker1].Visible := False; + Static[StaticTeam2Joker2].Visible := False; + Static[StaticTeam2Joker3].Visible := False; + Static[StaticTeam2Joker4].Visible := False; + Static[StaticTeam2Joker5].Visible := False; + end; + + if (PartySession.Teams.NumTeams >= 3) then + begin + Static[StaticTeam3Joker1].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 1); + Static[StaticTeam3Joker2].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 2); + Static[StaticTeam3Joker3].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 3); + Static[StaticTeam3Joker4].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 4); + Static[StaticTeam3Joker5].Visible := (PartySession.Teams.Teaminfo[2].Joker >= 5); + end + else + begin + Static[StaticTeam3Joker1].Visible := False; + Static[StaticTeam3Joker2].Visible := False; + Static[StaticTeam3Joker3].Visible := False; + Static[StaticTeam3Joker4].Visible := False; + Static[StaticTeam3Joker5].Visible := False; + end; + end + else + begin //Hide all + Static[StaticTeam1Joker1].Visible := False; + Static[StaticTeam1Joker2].Visible := False; + Static[StaticTeam1Joker3].Visible := False; + Static[StaticTeam1Joker4].Visible := False; + Static[StaticTeam1Joker5].Visible := False; + + Static[StaticTeam2Joker1].Visible := False; + Static[StaticTeam2Joker2].Visible := False; + Static[StaticTeam2Joker3].Visible := False; + Static[StaticTeam2Joker4].Visible := False; + Static[StaticTeam2Joker5].Visible := False; + + Static[StaticTeam3Joker1].Visible := False; + Static[StaticTeam3Joker2].Visible := False; + Static[StaticTeam3Joker3].Visible := False; + Static[StaticTeam3Joker4].Visible := False; + Static[StaticTeam3Joker5].Visible := False; + end; } +end; + +procedure TScreenSong.SetStatics; +var + I: Integer; + Visible: Boolean; +begin + //Set Visibility of Party Statics and Text + Visible := (Mode = smPartyMode); + + For I := 0 to high(StaticParty) do + Static[StaticParty[I]].Visible := Visible; + + 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 + Static[StaticNonParty[I]].Visible := Visible; + + For I := 0 to high(TextNonParty) do + Text[TextNonParty[I]].Visible := Visible; +end; + +//Procedures for Menu + +procedure TScreenSong.StartSong; +begin + CatSongs.Selected := Interaction; + AudioPlayback.Stop; + //Party Mode + if (Mode = smPartyMode) then + begin + FadeTo(@ScreenSingModi); + end + else + begin + FadeTo(@ScreenSing); + end; +end; + +procedure TScreenSong.SelectPlayers; +begin + CatSongs.Selected := Interaction; + AudioPlayback.Stop; + + ScreenName.Goto_SingScreen := True; + FadeTo(@ScreenName); +end; + +procedure TScreenSong.OpenEditor; +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; + +//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 + begin + //Joker spielen + Dec(PartySession.Teams.Teaminfo[Team].Joker); + SelectRandomSong; + SetJoker; + 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, 'Plain', true); // 0.5.0: show cached texture + Button[Interaction].Texture2.Alpha := 0; + + if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then + Texture.UnloadTexture(Button[Interaction].Texture.Name, false); +end; + +procedure TScreenSong.Refresh; +begin { +CatSongs.Refresh; +CatSongs.ShowCategoryList; +Interaction := 0; +SelectNext; +FixSelected; } + +end; + +end. -- cgit v1.2.3