From 873f177f08dc7c4fe2d7e50bbe7709df98e238d3 Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Wed, 27 Aug 2008 14:58:32 +0000 Subject: rename Screen part2 git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1306 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 2019 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2019 insertions(+) create mode 100644 src/screens/UScreenSong.pas (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas new file mode 100644 index 00000000..be1320f2 --- /dev/null +++ b/src/screens/UScreenSong.pas @@ -0,0 +1,2019 @@ +unit UScreenSong; + +interface + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + +{$I switches.inc} + + +uses + UMenu, + SDL, + UMusic, + UFiles, + UTime, + UDisplay, + USongs, + SysUtils, + UCommon, + ULog, + UThemes, + UTexture, + ULanguage, + USong, + UIni; + +type + TScreenSong = class(TMenu) + private + EqualizerData: TFFTData; // moved here to avoid stack overflows + EqualizerBands: array of Byte; + EqualizerTime: Cardinal; + + procedure StartMusicPreview(); + procedure StopMusicPreview(); + 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; + MusicPreviewTimer: PSDL_TimerID; + + 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; CharCode: WideChar; PressedDown: Boolean): Boolean; override; + function Draw: boolean; override; + procedure GenerateThumbnails(); + procedure onShow; override; + procedure onHide; override; + procedure SelectNext; + procedure SelectPrev; + //procedure UpdateLCD; //TODO: maybe LCD Support as Plugin? + 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, + gl, + USkins, + UDLLManager, + UParty, + UPlaylist, + UMenuButton, + 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; + Static[StaticCat].Texture := Texture.GetTexture(Button[Cat].Texture.Name, TEXTURE_TYPE_PLAIN, true); + + //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; CharCode: WideChar; PressedDown: Boolean): Boolean; +var + I: integer; + I2: integer; + SDL_ModState: Word; + Letter: WideChar; +begin + Result := true; + + //Song Screen Extensions (Jumpto + Menu) + if (ScreenSongMenu.Visible) then + begin + Result := ScreenSongMenu.ParseInput(PressedKey, CharCode, PressedDown); + Exit; + end + else if (ScreenSongJumpto.Visible) then + begin + Result := ScreenSongJumpto.ParseInput(PressedKey, CharCode, 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)) then + begin + if (WideCharUpperCase(CharCode)[1] in ([WideChar('A')..WideChar('Z')]) ) then + begin + Letter := WideCharUpperCase(CharCode)[1]; + 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 + (WideStringUpperCase(CatSongs.Song[(I + Interaction) mod I2].Title)[1] = Letter) then + begin + SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); + + AudioPlayback.PlaySound(SoundLib.Change); + + ChangeMusic; + SetScroll4; + //UpdateLCD; //TODO: maybe LCD Support as Plugin? + //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 + (WideStringUpperCase(CatSongs.Song[(I + Interaction) mod I2].Artist)[1] = Letter) then + begin + SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); + + AudioPlayback.PlaySound(SoundLib.Change); + + ChangeMusic; + SetScroll4; + //UpdateLCD; //TODO: maybe LCD Support as Plugin? + + //Break and Exit + Exit; + end; + end; + end; + end; + + Exit; + end; + + // check normal keys + case WideCharUpperCase(CharCode)[1] of + 'Q': + begin + Result := false; + Exit; + end; + + 'M': //Show SongMenu + begin + if (Songs.SongList.Count > 0) then + begin + if (Mode = smNormal) then + begin + if (not CatSongs.Song[Interaction].Main) then // clicked on Song + begin + if CatSongs.CatNumShow = -3 then + ScreenSongMenu.MenuShow(SM_Playlist) + else + ScreenSongMenu.MenuShow(SM_Main); + end + else + begin + ScreenSongMenu.MenuShow(SM_Playlist_Load); + end; + end //Party Mode -> Show Party Menu + else + begin + ScreenSongMenu.MenuShow(SM_Party_Main); + end; + end; + Exit; + end; + + 'P': //Show Playlist Menu + begin + if (Songs.SongList.Count > 0) and (Mode = smNormal) then + begin + ScreenSongMenu.MenuShow(SM_Playlist_Load); + end; + Exit; + end; + + 'J': //Show Jumpto Menu + begin + if (Songs.SongList.Count > 0) and (Mode = smNormal) then + begin + ScreenSongJumpto.Visible := True; + end; + Exit; + end; + + 'E': + begin + OpenEditor; + Exit; + end; + + '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 + begin + if CatSongs.Song[I].Main then + Inc(I2); + end; + + 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 is now the categorie in I2 the 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; //TODO: maybe LCD Support as Plugin? + end; + Exit; + end; + end; // normal keys + + // check special keys + case PressedKey of + 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 + StopMusicPreview(); + + 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 + StopMusicPreview(); + 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; } + + // 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_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; //TODO: maybe LCD Support as Plugin? + //Light.LightOne(1, 200); //TODO: maybe Light Support as Plugin? + end; + end; + + SDLK_LEFT: + begin + if (Songs.SongList.Count > 0)and (Mode = smNormal) then + begin + AudioPlayback.PlaySound(SoundLib.Change); + SelectPrev; + ChangeMusic; + SetScroll4; + //UpdateLCD; //TODO: maybe LCD Support as Plugin? + //Light.LightOne(0, 200); //TODO: maybe Light Support as Plugin? + end; + end; + + SDLK_1: + begin //Joker // to-do : Party + {if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= 1) and (PartySession.Teams.Teaminfo[0].Joker > 0) then + begin + //Use Joker + Dec(PartySession.Teams.Teaminfo[0].Joker); + SelectRandomSong; + SetJoker; + end; } + end; + + SDLK_2: + begin //Joker + {if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= 2) and (PartySession.Teams.Teaminfo[1].Joker > 0) then + begin + //Use Joker + Dec(PartySession.Teams.Teaminfo[1].Joker); + SelectRandomSong; + SetJoker; + end; } + end; + + SDLK_3: + begin //Joker + {if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= 3) and (PartySession.Teams.Teaminfo[2].Joker > 0) then + begin + //Use Joker + Dec(PartySession.Teams.Teaminfo[2].Joker); + SelectRandomSong; + SetJoker; + end; } + end; + end; + end; +end; + +constructor TScreenSong.Create; +var + i: integer; +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(); + + + // 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; + CoverButtonIndex: integer; + CoverButton: TButton; + CoverName: string; + CoverTexture: TTexture; + Cover: TCover; + Song: TSong; +begin + if (Length(CatSongs.Song) <= 0) then + Exit; + + // set length of button array once instead for every song + SetButtonLength(Length(CatSongs.Song)); + + // create all buttons + for I := 0 to High(CatSongs.Song) do + begin + CoverButton := nil; + + // create a clickable cover + CoverButtonIndex := AddButton(300 + I*250, 140, 200, 200, '', TEXTURE_TYPE_PLAIN, Theme.Song.Cover.Reflections); + if (CoverButtonIndex > -1) then + CoverButton := Button[CoverButtonIndex]; + if (CoverButton = nil) then + Continue; + + Song := CatSongs.Song[I]; + + // if cover-image is not found then show 'no cover' + if (not FileExists(Song.Path + Song.Cover)) then + Song.Cover := ''; + + if (Song.Cover = '') then + CoverName := Skin.GetTextureFileName('SongCover') + else + CoverName := Song.Path + Song.Cover; + + // load cover and cache its texture + Cover := Covers.FindCover(CoverName); + if (Cover = nil) then + Cover := Covers.AddCover(CoverName); + + // use the cached texture + // TODO: this is a workaround until the new song-loading works. + // The TCover object should be added to the song-object. The thumbnails + // should be loaded each time the song-screen is shown (it is real fast). + // This way, we will not waste that much memory and have a link between + // song and cover. + if (Cover <> nil) then + begin + CoverTexture := Cover.GetPreviewTexture(); + Texture.AddTexture(CoverTexture, TEXTURE_TYPE_PLAIN, true); + CoverButton.Texture := CoverTexture; + end; + + Cover.Free; + 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 // Auto Removed, Unused Variable + //BMax: integer; // button max // Auto Removed, Unused Variable + 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; + +(** + * Rotation + *) +procedure TScreenSong.SetScroll4; +var + B: integer; + Angle: real; + Z, Z2: real; + VS: integer; +begin + VS := CatSongs.VisibleSongs(); + + for B := 0 to High(Button) do + begin + Button[B].Visible := CatSongs.Song[B].Visible; + if Button[B].Visible then + begin + // angle between the cover and selected song-cover in radians + Angle := 2*Pi * (CatSongs.VisibleIndex(B) - SongCurrent) / VS; + + // calc z-position from angle + Z := (1 + cos(Angle)) / 2; // scaled to range [0..1] + Z2 := (1 + 2*Z) / 3; // scaled to range [1/3..1] + + // adjust cover's width and height according its z-position + // Note: Theme.Song.Cover.W is not used as width and height are equal + // and Theme.Song.Cover.W is used as circle radius in Scroll5. + Button[B].W := Theme.Song.Cover.H * Z2; + Button[B].H := Button[B].W; + + // set cover position + Button[B].X := Theme.Song.Cover.X + + (0.185 * Theme.Song.Cover.H * VS * sin(Angle)) * Z2 - + ((Button[B].H - Theme.Song.Cover.H)/2); + Button[B].Y := Theme.Song.Cover.Y + + (Theme.Song.Cover.H - Abs(Button[B].H)) * 0.7; + Button[B].Z := Z / 2 + 0.3; + end; + end; +end; + +(** + * rotate + *) +procedure TScreenSong.SetScroll5; +var + B: integer; + Angle: real; + Pos: Real; + VS: integer; + Padding: real; + X: Real; + { + Theme.Song.CoverW: circle radius + Theme.Song.CoverX: x-pos. of the left edge of the selected cover + Theme.Song.CoverY: y-pos. of the upper edge of the selected cover + Theme.Song.CoverH: cover height + } +begin + VS := CatSongs.VisibleSongs(); + + // Update positions of all buttons + for B := 0 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 is the distance to the centered cover in the range [-VS/2..+VS/2] + Pos := (CatSongs.VisibleIndex(B) - SongCurrent); + if (Pos < -VS/2) then + Pos := Pos + VS + else if (Pos > VS/2) then + Pos := Pos - VS; + + // Avoid overlapping of the front covers. + // Use an alternate position for the five front covers. + if (Abs(Pos) < 2.5) then + begin + Angle := Pi * (Pos / 5); // Range: (-1/4*Pi .. +1/4*Pi) + + Button[B].H := Abs(Theme.Song.Cover.H * cos(Angle*0.8)); + Button[B].W := Button[B].H; + + //Button[B].Reflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + + Padding := (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 - Padding; + Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); + Button[B].Z := 0.95 - Abs(Pos) * 0.01; + end + else + begin + // Transform Pos to range [-1..-1/2, +1/2..+1] + if Pos < 0 then + Pos := Pos/VS - 0.5 + else + Pos := Pos/VS + 0.5; + + // angle in radians [-2Pi..-Pi, +Pi..+2Pi] + Angle := 2*Pi * Pos; + + Button[B].H := 0.6*(Theme.Song.Cover.H-Abs(Theme.Song.Cover.H * cos(Angle/2)*0.8)); + Button[B].W := Button[B].H; + + Padding := (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); + Button[B].Y := Theme.Song.Cover.Y - (Button[B].H - Theme.Song.Cover.H)*0.75; + 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].Reflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; + end; + 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; + 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 // 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 + inherited; +{** + * Pause background music, so we can play it again on scorescreen + *} + SoundLib.PauseBgMusic; + + 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 + StartMusicPreview(); + + SetScroll; + //UpdateLCD; //TODO: maybe LCD Support as Plugin? + 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 + // turn music volume to 100% + AudioPlayback.SetVolume(1.0); + + // if preview is deactivated: load musicfile now + If (IPreviewVolumeVals[Ini.PreviewVolume] = 0) then + AudioPlayback.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); + + // if hide then stop music (for party mode popup on exit) + if (Display.NextScreen <> @ScreenSing) and + (Display.NextScreen <> @ScreenSingModi) then + begin + StopMusicPreview(); + end; +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 + // cover fade + if (CoverTime < 1) and (CoverTime + TimeSkip >= 1) then + begin + // load new texture + Texture.GetTexture(Button[Interaction].Texture.Name, TEXTURE_TYPE_PLAIN, false); + Button[Interaction].Texture.Alpha := 1; + Button[Interaction].Texture2 := Texture.GetTexture(Button[Interaction].Texture.Name, TEXTURE_TYPE_PLAIN, false); + Button[Interaction].Texture2.Alpha := 1; + 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; + + Result := true; +end; + +procedure TScreenSong.SelectNext; +var + Skip: 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 + // show uncached texture + //Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, TEXTURE_TYPE_PLAIN, false); +end; + +procedure TScreenSong.SelectPrev; +var + Skip: 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; + + // show uncached texture + //Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, TEXTURE_TYPE_PLAIN, false); + end; +end; + +(* +procedure TScreenSong.UpdateLCD; //TODO: maybe LCD Support as Plugin? +begin + LCD.HideCursor; + LCD.Clear; + LCD.WriteText(1, Text[TextArtist].Text); + LCD.WriteText(2, Text[TextTitle].Text); + +end; +*) + +procedure TScreenSong.StartMusicPreview(); +var + Song: TSong; +begin + AudioPlayback.Close(); + + Song := CatSongs.Song[Interaction]; + if not assigned(Song) then + Exit; + + if AudioPlayback.Open(Song.Path + Song.Mp3) then + begin + AudioPlayback.Position := AudioPlayback.Length / 4; + // set preview volume + if (Ini.PreviewFading = 0) then + begin + // music fade disabled: start with full volume + AudioPlayback.SetVolume(IPreviewVolumeVals[Ini.PreviewVolume]); + AudioPlayback.Play() + end + else + begin + // music fade enabled: start muted and fade-in + AudioPlayback.SetVolume(0); + AudioPlayback.FadeIn(Ini.PreviewFading, IPreviewVolumeVals[Ini.PreviewVolume]); + end; + end; +end; + +procedure TScreenSong.StopMusicPreview(); +begin + // Cancel pending preview requests + SDL_RemoveTimer(MusicPreviewTimer); + + // Stop preview of previous song + AudioPlayback.Stop; +end; + +function MusicPreviewTimerCallback(interval: UInt32; param: Pointer): UInt32; cdecl; +var + ScreenSong: TScreenSong; +begin + ScreenSong := TScreenSong(param); + if (ScreenSong <> nil) then + ScreenSong.StartMusicPreview(); + Result := 0; +end; + +// Changes previewed song +procedure TScreenSong.ChangeMusic; +begin + StopMusicPreview(); + + // Preview song if activated and current selection is not a category cover + if (CatSongs.VisibleSongs > 0) and + (not CatSongs.Song[Interaction].Main) and + (Ini.PreviewVolume <> 0) then + begin + // Delay song fading to prevent the song from being played while scrolling + MusicPreviewTimer := SDL_AddTimer(200, MusicPreviewTimerCallback, Self); + end; +end; + +procedure TScreenSong.SkipTo(Target: Cardinal); +var + 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; + ChansPerBand: byte; // channels per band + MaxChannel: Integer; + CurBand: Integer; // current band + CurTime: Cardinal; + PosX, PosY: Integer; + Pos: Real; +begin + // Nothing to do if no music is played or an equalizer bar consists of no block + if (AudioPlayback.Finished or (Theme.Song.Equalizer.Length <= 0)) then + Exit; + + CurTime := SDL_GetTicks(); + + // Evaluate FFT-data every 44 ms + if (CurTime >= EqualizerTime) then + begin + EqualizerTime := CurTime + 44; + AudioPlayback.GetFFTData(EqualizerData); + + Pos := 0; + // use only the first approx. 92 of 256 FFT-channels (approx. up to 8kHz + ChansPerBand := ceil(92 / Theme.Song.Equalizer.Bands); // How much channels are used for one Band + MaxChannel := ChansPerBand * Theme.Song.Equalizer.Bands - 1; + + // Change Lengths + for i := 0 to MaxChannel do + begin + // Gain higher freq. data so that the bars are visible + 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; + + // clamp data + if (EqualizerData[i] > 1) then + EqualizerData[i] := 1; + + // Get max. pos + if (EqualizerData[i] * Theme.Song.Equalizer.Length > Pos) then + Pos := EqualizerData[i] * Theme.Song.Equalizer.Length; + + // Check if this is the last channel in the band + if ((i+1) mod ChansPerBand = 0) then + begin + CurBand := i div ChansPerBand; + + // Smooth delay if new equalizer is lower than the old one + if ((EqualizerBands[CurBand] > Pos) and (EqualizerBands[CurBand] > 1)) then + EqualizerBands[CurBand] := EqualizerBands[CurBand] - 1 + else + EqualizerBands[CurBand] := Round(Pos); + + Pos := 0; + end; + end; + + end; + + // Draw equalizer bands + + // Setup OpenGL + glColor4f(Theme.Song.Equalizer.ColR, Theme.Song.Equalizer.ColG, Theme.Song.Equalizer.ColB, Theme.Song.Equalizer.Alpha); + glDisable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + + // Set position of the first equalizer bar + PosY := Theme.Song.Equalizer.Y; + PosX := Theme.Song.Equalizer.X; + + // Draw bars for each band + for I := 0 to High(EqualizerBands) do + begin + // Reset to lower or left position depending on the drawing-direction + if Theme.Song.Equalizer.Direction then // Vertical bars + // FIXME: Is Theme.Song.Equalizer.Y the upper or lower coordinate? + PosY := Theme.Song.Equalizer.Y //+ (Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space) * Theme.Song.Equalizer.Length + else // Horizontal bars + PosX := Theme.Song.Equalizer.X; + + // Draw the bar as a stack of blocks + for J := 1 to EqualizerBands[I] do + begin + // Draw block + 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; + + // Calc position of the bar's next block + if Theme.Song.Equalizer.Direction then // Vertical bars + PosY := PosY - Theme.Song.Equalizer.H - Theme.Song.Equalizer.Space + else // Horizontal bars + PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space; + end; + + // Calc position of the next bar + if Theme.Song.Equalizer.Direction then // Vertical bars + PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space + else // Horizontal bars + PosY := PosY + Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space; + 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; //TODO: maybe LCD Support as Plugin? +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; + StopMusicPreview(); + + //Party Mode + if (Mode = smPartyMode) then + begin + FadeTo(@ScreenSingModi); + end + else + begin + FadeTo(@ScreenSing); + end; +end; + +procedure TScreenSong.SelectPlayers; +begin + CatSongs.Selected := Interaction; + StopMusicPreview(); + + 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 + StopMusicPreview(); + 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 + //Use Joker + 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; + + // show cached texture + Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, TEXTURE_TYPE_PLAIN, true); + Button[Interaction].Texture2.Alpha := 0; + + if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then + Texture.UnloadTexture(Button[Interaction].Texture.Name, TEXTURE_TYPE_PLAIN, false); +end; + +procedure TScreenSong.Refresh; +begin + { + CatSongs.Refresh; + CatSongs.ShowCategoryList; + Interaction := 0; + SelectNext; + FixSelected; + } +end; + +end. -- cgit v1.2.3 From 20d12d5af15bd364cbec888100de6e18bb89561e Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sat, 20 Sep 2008 18:19:37 +0000 Subject: Equalizer class written TRGB methods now in UThemes instead of ULyrics equalizer reflection now available Reading from Reflectionsettings from theme follows on sunday :P git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1387 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index be1320f2..1b5e4c41 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -24,14 +24,13 @@ uses UTexture, ULanguage, USong, - UIni; + UIni, + UMenuEqualizer; type TScreenSong = class(TMenu) private - EqualizerData: TFFTData; // moved here to avoid stack overflows - EqualizerBands: array of Byte; - EqualizerTime: Cardinal; + Equalizer: Tms_Equalizer; procedure StartMusicPreview(); procedure StopMusicPreview(); @@ -41,7 +40,7 @@ type TextNumber: integer; //Video Icon Mod - VideoIcon: Cardinal; + VideoIcon: Cardinal; TextCat: integer; StaticCat: integer; @@ -777,11 +776,13 @@ begin // Randomize Patch Randomize; - //Equalizer + {//Equalizer SetLength(EqualizerBands, Theme.Song.Equalizer.Bands); //ClearArray For I := low(EqualizerBands) to high(EqualizerBands) do - EqualizerBands[I] := 3; + EqualizerBands[I] := 3; } + + Equalizer := Tms_Equalizer.Create(AudioPlayback); if (Length(CatSongs.Song) > 0) then Interaction := 0; @@ -1496,8 +1497,7 @@ begin //Draw Equalizer - if Theme.Song.Equalizer.Visible then - DrawEqualizer; + Equalizer.Draw; DrawExtensions; @@ -1657,16 +1657,16 @@ begin end; procedure TScreenSong.DrawEqualizer; -var +{var I, J: Integer; ChansPerBand: byte; // channels per band MaxChannel: Integer; CurBand: Integer; // current band CurTime: Cardinal; PosX, PosY: Integer; - Pos: Real; + Pos: Real; } begin - // Nothing to do if no music is played or an equalizer bar consists of no block + { // Nothing to do if no music is played or an equalizer bar consists of no block if (AudioPlayback.Finished or (Theme.Song.Equalizer.Length <= 0)) then Exit; @@ -1763,7 +1763,7 @@ begin PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space else // Horizontal bars PosY := PosY + Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space; - end; + end; } end; procedure TScreenSong.SelectRandomSong; -- cgit v1.2.3 From 688182ae4f56aabaf12233f32763274286c5d634 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 21 Sep 2008 11:34:25 +0000 Subject: missing files commited Equalizer now loads reflection settings from theme old equalizer methods removed git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1388 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 120 +------------------------------------------- 1 file changed, 1 insertion(+), 119 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 1b5e4c41..f632afe0 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -110,7 +110,6 @@ type 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; @@ -776,13 +775,8 @@ begin // Randomize Patch Randomize; - {//Equalizer - SetLength(EqualizerBands, Theme.Song.Equalizer.Bands); - //ClearArray - For I := low(EqualizerBands) to high(EqualizerBands) do - EqualizerBands[I] := 3; } - Equalizer := Tms_Equalizer.Create(AudioPlayback); + Equalizer := Tms_Equalizer.Create(AudioPlayback, Theme.Song.Equalizer); if (Length(CatSongs.Song) > 0) then Interaction := 0; @@ -1495,8 +1489,6 @@ begin for I := 0 to Length(Text) - 1 do Text[I].Draw; - - //Draw Equalizer Equalizer.Draw; DrawExtensions; @@ -1656,116 +1648,6 @@ begin FixSelected2; end; -procedure TScreenSong.DrawEqualizer; -{var - I, J: Integer; - ChansPerBand: byte; // channels per band - MaxChannel: Integer; - CurBand: Integer; // current band - CurTime: Cardinal; - PosX, PosY: Integer; - Pos: Real; } -begin - { // Nothing to do if no music is played or an equalizer bar consists of no block - if (AudioPlayback.Finished or (Theme.Song.Equalizer.Length <= 0)) then - Exit; - - CurTime := SDL_GetTicks(); - - // Evaluate FFT-data every 44 ms - if (CurTime >= EqualizerTime) then - begin - EqualizerTime := CurTime + 44; - AudioPlayback.GetFFTData(EqualizerData); - - Pos := 0; - // use only the first approx. 92 of 256 FFT-channels (approx. up to 8kHz - ChansPerBand := ceil(92 / Theme.Song.Equalizer.Bands); // How much channels are used for one Band - MaxChannel := ChansPerBand * Theme.Song.Equalizer.Bands - 1; - - // Change Lengths - for i := 0 to MaxChannel do - begin - // Gain higher freq. data so that the bars are visible - 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; - - // clamp data - if (EqualizerData[i] > 1) then - EqualizerData[i] := 1; - - // Get max. pos - if (EqualizerData[i] * Theme.Song.Equalizer.Length > Pos) then - Pos := EqualizerData[i] * Theme.Song.Equalizer.Length; - - // Check if this is the last channel in the band - if ((i+1) mod ChansPerBand = 0) then - begin - CurBand := i div ChansPerBand; - - // Smooth delay if new equalizer is lower than the old one - if ((EqualizerBands[CurBand] > Pos) and (EqualizerBands[CurBand] > 1)) then - EqualizerBands[CurBand] := EqualizerBands[CurBand] - 1 - else - EqualizerBands[CurBand] := Round(Pos); - - Pos := 0; - end; - end; - - end; - - // Draw equalizer bands - - // Setup OpenGL - glColor4f(Theme.Song.Equalizer.ColR, Theme.Song.Equalizer.ColG, Theme.Song.Equalizer.ColB, Theme.Song.Equalizer.Alpha); - glDisable(GL_TEXTURE_2D); - glEnable(GL_BLEND); - - // Set position of the first equalizer bar - PosY := Theme.Song.Equalizer.Y; - PosX := Theme.Song.Equalizer.X; - - // Draw bars for each band - for I := 0 to High(EqualizerBands) do - begin - // Reset to lower or left position depending on the drawing-direction - if Theme.Song.Equalizer.Direction then // Vertical bars - // FIXME: Is Theme.Song.Equalizer.Y the upper or lower coordinate? - PosY := Theme.Song.Equalizer.Y //+ (Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space) * Theme.Song.Equalizer.Length - else // Horizontal bars - PosX := Theme.Song.Equalizer.X; - - // Draw the bar as a stack of blocks - for J := 1 to EqualizerBands[I] do - begin - // Draw block - 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; - - // Calc position of the bar's next block - if Theme.Song.Equalizer.Direction then // Vertical bars - PosY := PosY - Theme.Song.Equalizer.H - Theme.Song.Equalizer.Space - else // Horizontal bars - PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space; - end; - - // Calc position of the next bar - if Theme.Song.Equalizer.Direction then // Vertical bars - PosX := PosX + Theme.Song.Equalizer.W + Theme.Song.Equalizer.Space - else // Horizontal bars - PosY := PosY + Theme.Song.Equalizer.H + Theme.Song.Equalizer.Space; - end; } -end; - procedure TScreenSong.SelectRandomSong; var I, I2: Integer; -- cgit v1.2.3 From f16756422a5dbb24ce1b751bb9e2bb1de4f19713 Mon Sep 17 00:00:00 2001 From: tobigun Date: Tue, 23 Sep 2008 21:17:50 +0000 Subject: added file headers git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1404 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index f632afe0..a4c94e45 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -1,3 +1,28 @@ +{* UltraStar Deluxe - Karaoke Game + * + * UltraStar Deluxe is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + *} + unit UScreenSong; interface -- cgit v1.2.3 From 90226eb8cd49293af7c893e379a071ba7f9583f5 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 5 Oct 2008 16:15:09 +0000 Subject: removed some commented relicts from outdated LCD and Light support. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1434 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index a4c94e45..d0337d30 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -273,7 +273,7 @@ begin //Jump to Artist/Titel if ((SDL_ModState and KMOD_LALT <> 0) and (Mode = smNormal)) then begin - if (WideCharUpperCase(CharCode)[1] in ([WideChar('A')..WideChar('Z')]) ) then + if (WideCharUpperCase(CharCode)[1] in ([WideChar('A')..WideChar('Z'), WideChar('0') .. WideChar('9')]) ) then begin Letter := WideCharUpperCase(CharCode)[1]; I2 := Length(CatSongs.Song); @@ -293,7 +293,6 @@ begin ChangeMusic; SetScroll4; - //UpdateLCD; //TODO: maybe LCD Support as Plugin? //Break and Exit Exit; end; @@ -314,7 +313,6 @@ begin ChangeMusic; SetScroll4; - //UpdateLCD; //TODO: maybe LCD Support as Plugin? //Break and Exit Exit; @@ -457,7 +455,6 @@ begin ChangeMusic; SetScroll4; - //UpdateLCD; //TODO: maybe LCD Support as Plugin? end; Exit; end; @@ -541,9 +538,6 @@ begin 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 @@ -682,8 +676,6 @@ begin //SongTarget := Interaction; ChangeMusic; SetScroll4; - //UpdateLCD; //TODO: maybe LCD Support as Plugin? - //Light.LightOne(1, 200); //TODO: maybe Light Support as Plugin? end; end; @@ -695,8 +687,6 @@ begin SelectPrev; ChangeMusic; SetScroll4; - //UpdateLCD; //TODO: maybe LCD Support as Plugin? - //Light.LightOne(0, 200); //TODO: maybe Light Support as Plugin? end; end; @@ -1383,7 +1373,6 @@ begin StartMusicPreview(); SetScroll; - //UpdateLCD; //TODO: maybe LCD Support as Plugin? end; //Playlist Mode @@ -1584,17 +1573,6 @@ begin end; end; -(* -procedure TScreenSong.UpdateLCD; //TODO: maybe LCD Support as Plugin? -begin - LCD.HideCursor; - LCD.Clear; - LCD.WriteText(1, Text[TextArtist].Text); - LCD.WriteText(2, Text[TextTitle].Text); - -end; -*) - procedure TScreenSong.StartMusicPreview(); var Song: TSong; @@ -1735,7 +1713,6 @@ begin AudioPlayback.PlaySound(SoundLib.Change); ChangeMusic; SetScroll; - //UpdateLCD; //TODO: maybe LCD Support as Plugin? end; procedure TScreenSong.SetJoker; -- cgit v1.2.3 From 93e52c516659926933b729593885a30550017482 Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Sun, 5 Oct 2008 17:50:00 +0000 Subject: remove ULCD.pas and ULight.pas + some more cleanup of ULCD routines and {$UNDEF UseSerialPort} git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1435 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 1 - 1 file changed, 1 deletion(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index d0337d30..c340be2b 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -127,7 +127,6 @@ type procedure onHide; override; procedure SelectNext; procedure SelectPrev; - //procedure UpdateLCD; //TODO: maybe LCD Support as Plugin? procedure SkipTo(Target: Cardinal); procedure FixSelected; //Show Wrong Song when Tabs on Fix procedure FixSelected2; //Show Wrong Song when Tabs on Fix -- cgit v1.2.3 From 322b798413826681915eca1960f081cbc4dd302c Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Mon, 13 Oct 2008 14:14:32 +0000 Subject: Abstraction of the menus background 5 different bg types: none(fallback), colored, texture, video, and fade(for overlays) Some sideeffect is 5 mb less memory usage, don't know for which reasons :P git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1446 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index c340be2b..95ccae83 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -340,17 +340,25 @@ begin if (not CatSongs.Song[Interaction].Main) then // clicked on Song begin if CatSongs.CatNumShow = -3 then - ScreenSongMenu.MenuShow(SM_Playlist) + begin + ScreenSongMenu.onShow; + ScreenSongMenu.MenuShow(SM_Playlist); + end else + begin + ScreenSongMenu.onShow; ScreenSongMenu.MenuShow(SM_Main); + end; end else begin + ScreenSongMenu.onShow; ScreenSongMenu.MenuShow(SM_Playlist_Load); end; end //Party Mode -> Show Party Menu else begin + ScreenSongMenu.onShow; ScreenSongMenu.MenuShow(SM_Party_Main); end; end; @@ -361,7 +369,8 @@ begin begin if (Songs.SongList.Count > 0) and (Mode = smNormal) then begin - ScreenSongMenu.MenuShow(SM_Playlist_Load); + ScreenSongMenu.onShow; + ScreenSongMenu.MenuShow(SM_Playlist_Load); end; Exit; end; -- cgit v1.2.3 From 0a6843648a39774531733b65f1bf592f443e61fe Mon Sep 17 00:00:00 2001 From: tobigun Date: Sat, 25 Oct 2008 10:28:43 +0000 Subject: Music preview is started by the main thread now instead of the SDL timer thread. In the preview function a string is casted to WideString. As the SDL thread does not have a threadvar for an iconv context with FPC on linux (used if cwstring is enabled) the preview crashed formerly. Now we can use cwstring on linux again. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1470 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 95ccae83..9fc74aae 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -1619,13 +1619,20 @@ begin AudioPlayback.Stop; end; -function MusicPreviewTimerCallback(interval: UInt32; param: Pointer): UInt32; cdecl; +procedure StartMusicPreview(data: Pointer); var ScreenSong: TScreenSong; begin - ScreenSong := TScreenSong(param); + ScreenSong := TScreenSong(data); if (ScreenSong <> nil) then ScreenSong.StartMusicPreview(); +end; + +function MusicPreviewTimerCallback(interval: UInt32; param: Pointer): UInt32; cdecl; +begin + // delegate execution to main-thread + MainThreadExec(@StartMusicPreview, param); + // stop timer Result := 0; end; -- cgit v1.2.3 From d33f56a40d9e8325a2782f90bb253dece5127c5f Mon Sep 17 00:00:00 2001 From: tobigun Date: Mon, 3 Nov 2008 14:53:17 +0000 Subject: All comments are English now (Polish ones have been translated) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1498 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 9fc74aae..6aa8e955 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -1059,10 +1059,10 @@ end; procedure TScreenSong.SetScroll2; var B: integer; - //Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu - //Wsp2: real; + //Factor: integer; // factor of position relative to center of screen + //Factor2: real; begin - // liniowe + // line for B := 0 to High(Button) do Button[B].X := 300 + (B - Interaction) * 260; @@ -1074,12 +1074,12 @@ begin Button[0].X := 300 + 260; end; - // kolowe + // circle { 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); + Factor := (B - Interaction); // 0 to center, -1: to left, +1 to right + Factor2 := Factor / Length(Button); + Button[B].X := 300 + 10000 * sin(2*pi*Factor2); //Button[B].Y := 140 + 50 * ; end; } @@ -1089,12 +1089,12 @@ end; procedure TScreenSong.SetScroll3; // with slide var B: integer; - //Wsp: integer; // wspolczynnik przesuniecia wzgledem srodka ekranu - //Wsp2: real; + //Factor: integer; // factor of position relative to center of screen + //Factor2: real; begin SongTarget := Interaction; - // liniowe + // line for B := 0 to High(Button) do begin Button[B].X := 300 + (B - SongCurrent) * 260; @@ -1114,12 +1114,12 @@ begin end; } - // kolowe + // circle { 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); + Factor := (B - Interaction); // 0 to center, -1: to left, +1 to right + Factor2 := Factor / Length(Button); + Button[B].X := 300 + 10000 * sin(2*pi*Factor2); //Button[B].Y := 140 + 50 * ; end; } @@ -1253,25 +1253,25 @@ var VS: integer; diff: real; X: Real; - Wsp: real; + Factor: real; Z, Z2: real; begin VS := CatSongs.VisibleSongs; if VS <= 5 then begin - // kolowe + // circle for B := 0 to High(Button) do begin - Button[B].Visible := CatSongs.Song[B].Visible; // nowe + Button[B].Visible := CatSongs.Song[B].Visible; if Button[B].Visible then begin // 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 + Factor := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / VS {CatSongs.VisibleSongs};// 0.5.0 (II): takes another 16ms - Z := (1 + cos(Wsp)) / 2; + Z := (1 + cos(Factor)) / 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].Y := Theme.Song.Cover.Y + (0.185 * Theme.Song.Cover.H * VS * sin(Factor)) * 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; @@ -1547,7 +1547,7 @@ begin end; - // Interaction -> Button, ktorego okladke przeczytamy + // Interaction -> Button, load cover // show uncached texture //Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, TEXTURE_TYPE_PLAIN, false); end; -- cgit v1.2.3 From 61ffacc8a90f6777a05bef43dda84e14cb70c04c Mon Sep 17 00:00:00 2001 From: tobigun Date: Wed, 4 Feb 2009 18:01:17 +0000 Subject: Tabs_at_startup -> TabsAtStartup git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1585 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 53 +++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 26 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 6aa8e955..28358353 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -392,21 +392,22 @@ begin 'R': begin - if (Songs.SongList.Count > 0) and (Mode = smNormal) then + if (Songs.SongList.Count > 0) and + (Mode = smNormal) then begin - if (SDL_ModState = KMOD_LSHIFT) and (Ini.Tabs_at_startup = 1) then //Random Category + if (SDL_ModState = KMOD_LSHIFT) and (Ini.TabsAtStartup = 1) then //Random Category begin I2 := 0; //Count Cats - for I:= low(CatSongs.Song) to high (CatSongs.Song) do + for I:= 0 to high(CatSongs.Song) do begin if CatSongs.Song[I].Main then Inc(I2); end; - I2 := Random (I2)+1; //Zufall + I2 := Random(I2)+1; //Zufall //Find Cat: - for I:= low(CatSongs.Song) to high (CatSongs.Song) do + for I:= 0 to high(CatSongs.Song) do begin if CatSongs.Song[I].Main then Dec(I2); @@ -425,14 +426,14 @@ begin end; end; end - else if (SDL_ModState = KMOD_LCTRL) and (Ini.Tabs_at_startup = 1) then //random in All Categorys + else if (SDL_ModState = KMOD_LCTRL) and (Ini.TabsAtStartup = 1) then //random in All Categorys begin repeat - I2 := Random(high(CatSongs.Song)+1) - low(CatSongs.Song)+1; - until CatSongs.Song[I2].Main = false; + I2 := Random(high(CatSongs.Song)+1) + 1; + until (not CatSongs.Song[I2].Main); //Search Cat - for I := I2 downto low(CatSongs.Song) do + for I := I2 downto 0 do begin if CatSongs.Song[I].Main then break; @@ -476,20 +477,20 @@ begin if (Mode = smNormal) then begin //On Escape goto Cat-List Hack - if (Ini.Tabs_at_startup = 1) and (CatSongs.CatNumShow <> -1) then + if (Ini.TabsAtStartup = 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 + while (not CatSongs.Song[I].Main) do + begin + Dec(I); + if (I < 0) then break; - end; - if (I<= 1) then - Interaction := high(catsongs.Song) + end; + if (I <= 1) then + Interaction := high(CatSongs.Song) else - Interaction := I - 1; + Interaction := I - 1; //Stop Music StopMusicPreview(); @@ -544,7 +545,7 @@ begin end; SDLK_RETURN: begin - if Songs.SongList.Count > 0 then + if (Songs.SongList.Count > 0) then begin if CatSongs.Song[Interaction].Main then begin // clicked on Category Button @@ -601,7 +602,7 @@ begin if (CatSongs.CatNumShow > -2) then begin //Cat Change Hack - if Ini.Tabs_at_startup = 1 then + if Ini.TabsAtStartup = 1 then begin I := Interaction; if I <= 0 then I := 1; @@ -641,7 +642,7 @@ begin if (CatSongs.CatNumShow > -2) then begin //Cat Change Hack - if Ini.Tabs_at_startup = 1 then + if Ini.TabsAtStartup = 1 then begin I := Interaction; I2 := 0; @@ -731,7 +732,7 @@ begin end; } end; end; - end; + end; // if (PressedDown) end; constructor TScreenSong.Create; @@ -892,7 +893,7 @@ begin // Set texts Text[TextArtist].Text := CatSongs.Song[Interaction].Artist; Text[TextTitle].Text := CatSongs.Song[Interaction].Title; - if (Ini.Tabs_at_startup = 1) and (CatSongs.CatNumShow = -1) then + if (Ini.TabsAtStartup = 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') + ')'; @@ -901,7 +902,7 @@ begin 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 + else if (Ini.TabsAtStartup = 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)); @@ -1366,7 +1367,7 @@ begin if Ini.Players = 4 then PlayersPlay := 6; //Cat Mod etc - if (Ini.Tabs_at_startup = 1) and (CatSongs.CatNumShow = -1) then + if (Ini.TabsAtStartup = 1) and (CatSongs.CatNumShow = -1) then begin CatSongs.ShowCategoryList; FixSelected; @@ -1674,7 +1675,7 @@ begin smNormal: //All Songs Just Select Random Song begin //When Tabs are activated then use Tab Method - if (Ini.Tabs_at_startup = 1) then + if (Ini.TabsAtStartup = 1) then begin repeat I2 := Random(high(CatSongs.Song)+1) - low(CatSongs.Song)+1; -- cgit v1.2.3 From f469075a0335399c753ae5d2d362047dedf116b1 Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Sat, 7 Mar 2009 21:14:14 +0000 Subject: final cleanup of Umain. Creation of UNote git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1627 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 347 +++++++++++++++++++++++++------------------- 1 file changed, 194 insertions(+), 153 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 28358353..8aa5acca 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -65,7 +65,7 @@ type TextNumber: integer; //Video Icon Mod - VideoIcon: Cardinal; + VideoIcon: cardinal; TextCat: integer; StaticCat: integer; @@ -88,28 +88,28 @@ type 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; + 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; @@ -120,18 +120,18 @@ type procedure SetScroll4; procedure SetScroll5; procedure SetScroll6; - function ParseInput(PressedKey: Cardinal; CharCode: WideChar; PressedDown: Boolean): Boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: WideChar; PressedDown: boolean): boolean; override; function Draw: boolean; override; procedure GenerateThumbnails(); procedure onShow; override; procedure onHide; override; procedure SelectNext; procedure SelectPrev; - procedure SkipTo(Target: Cardinal); + 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 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 ChangeMusic; @@ -154,23 +154,25 @@ type implementation uses - UGraphic, - UMain, - UCovers, - math, + Math, gl, - USkins, + UCovers, UDLLManager, + UGraphic, + UMain, + UMenuButton, + UNote, UParty, UPlaylist, - UMenuButton, - UScreenSongMenu; + UScreenSongMenu, + USkins; // ***** Public methods ****** // //Show Wrong Song when Tabs on Fix procedure TScreenSong.FixSelected; -var I, I2: Integer; +var + I, I2: integer; begin if CatSongs.VisibleSongs > 0 then begin @@ -190,7 +192,8 @@ begin end; procedure TScreenSong.FixSelected2; -var I, I2: Integer; +var + I, I2: integer; begin if CatSongs.VisibleSongs > 0 then begin @@ -209,15 +212,15 @@ begin end; //Show Wrong Song when Tabs on Fix End -procedure TScreenSong.ShowCatTLCustom(Caption: String);// Show Custom Text in Top left +procedure TScreenSong.ShowCatTLCustom(Caption: string);// Show Custom Text in Top left begin Text[TextCat].Text := Caption; Text[TextCat].Visible := true; - Static[StaticCat].Visible := False; + Static[StaticCat].Visible := false; end; //Show Cat in Top Left Mod -procedure TScreenSong.ShowCatTL(Cat: Integer); +procedure TScreenSong.ShowCatTL(Cat: integer); begin //Change Text[TextCat].Text := CatSongs.Song[Cat].Artist; @@ -225,7 +228,7 @@ begin //Show Text[TextCat].Visible := true; - Static[StaticCat].Visible := True; + Static[StaticCat].Visible := true; end; procedure TScreenSong.HideCatTL; @@ -234,7 +237,7 @@ begin //Text[TextCat].Visible := false; Static[StaticCat].Visible := false; //New -> Show Text specified in Theme - Text[TextCat].Visible := True; + Text[TextCat].Visible := true; Text[TextCat].Text := Theme.Song.TextCat.Text; end; //Show Cat in Top Left Mod End @@ -242,7 +245,7 @@ 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; CharCode: WideChar; PressedDown: Boolean): Boolean; +function TScreenSong.ParseInput(PressedKey: cardinal; CharCode: WideChar; PressedDown: boolean): boolean; var I: integer; I2: integer; @@ -379,7 +382,7 @@ begin begin if (Songs.SongList.Count > 0) and (Mode = smNormal) then begin - ScreenSongJumpto.Visible := True; + ScreenSongJumpto.Visible := true; end; Exit; end; @@ -451,7 +454,8 @@ 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); @@ -505,7 +509,7 @@ begin SelectNext; FixSelected; //SelectPrev; - //CatSongs.Song[0].Visible := False; + //CatSongs.Song[0].Visible := false; end else begin @@ -605,7 +609,8 @@ begin if Ini.TabsAtStartup = 1 then begin I := Interaction; - if I <= 0 then I := 1; + if I <= 0 then + I := 1; while not catsongs.Song[I].Main do begin @@ -646,7 +651,8 @@ begin begin I := Interaction; I2 := 0; - if I <= 0 then I := 1; + if I <= 0 then + I := 1; while not catsongs.Song[I].Main or (I2 = 0) do begin @@ -808,7 +814,7 @@ end; procedure TScreenSong.GenerateThumbnails(); var - I: Integer; + I: integer; CoverButtonIndex: integer; CoverButton: TButton; CoverName: string; @@ -869,7 +875,7 @@ end; procedure TScreenSong.SetScroll; var - VS, B: Integer; + VS, B: integer; begin VS := CatSongs.VisibleSongs; if VS > 0 then @@ -913,7 +919,7 @@ begin Text[TextArtist].Text := ''; Text[TextTitle].Text := ''; for B := 0 to High(Button) do - Button[B].Visible := False; + Button[B].Visible := false; end; end; @@ -943,29 +949,37 @@ begin VisCount := 0; for B := 0 to High(Button) do - if CatSongs.Song[B].Visible then Inc(VisCount); + 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 CatSongs.Song[B].Visible then + Inc(VisInt); - if VisCount <= 6 then begin + if VisCount <= 6 then + begin Typ := 0; - end else begin - if VisInt <= 3 then begin + end + else + begin + if VisInt <= 3 then + begin Typ := 1; Count := 7; Ready := true; end; - if (VisCount - VisInt) <= 3 then begin + if (VisCount - VisInt) <= 3 then + begin Typ := 2; Count := 7; Ready := true; end; - if not Ready then begin + if not Ready then + begin Typ := 3; Src := Interaction; end; @@ -974,13 +988,15 @@ begin // hide all buttons - for B := 0 to High(Button) do begin + 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 + for B := Src to Dst do + begin //Button[B].Visible := true; Button[B].Visible := CatSongs.Song[B].Visible; Button[B].Selectable := Button[B].Visible; @@ -989,9 +1005,12 @@ begin } - if Typ = 0 then begin - for B := 0 to High(Button) do begin - if CatSongs.Song[B].Visible then begin + if Typ = 0 then + begin + for B := 0 to High(Button) do + begin + if CatSongs.Song[B].Visible then + begin Button[B].Visible := true; Button[B].Y := 140 + (Placed) * 60; Inc(Placed); @@ -999,10 +1018,13 @@ begin end; end; - if Typ = 1 then begin + if Typ = 1 then + begin B := 0; - while (Count > 0) do begin - if CatSongs.Song[B].Visible then begin + while (Count > 0) do + begin + if CatSongs.Song[B].Visible then + begin Button[B].Visible := true; Button[B].Y := 140 + (Placed) * 60; Inc(Placed); @@ -1012,10 +1034,13 @@ begin end; end; - if Typ = 2 then begin + if Typ = 2 then + begin B := High(Button); - while (Count > 0) do begin - if CatSongs.Song[B].Visible then begin + 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); @@ -1025,11 +1050,14 @@ begin end; end; - if Typ = 3 then begin + if Typ = 3 then + begin B := Src; Count := 4; - while (Count > 0) do begin - if CatSongs.Song[B].Visible then begin + 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); @@ -1041,8 +1069,10 @@ begin B := Src-1; Placed := 0; Count := 3; - while (Count > 0) do begin - if CatSongs.Song[B].Visible then begin + 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); @@ -1067,7 +1097,8 @@ begin for B := 0 to High(Button) do Button[B].X := 300 + (B - Interaction) * 260; - if Length(Button) >= 3 then begin + if Length(Button) >= 3 then + begin if Interaction = 0 then Button[High(Button)].X := 300 - 260; @@ -1077,7 +1108,8 @@ begin // circle { - for B := 0 to High(Button) do begin + for B := 0 to High(Button) do + begin Factor := (B - Interaction); // 0 to center, -1: to left, +1 to right Factor2 := Factor / Length(Button); Button[B].X := 300 + 10000 * sin(2*pi*Factor2); @@ -1100,13 +1132,14 @@ begin 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 + Button[B].Visible := false else - Button[B].Visible := True; + Button[B].Visible := true; end; { - if Length(Button) >= 3 then begin + if Length(Button) >= 3 then + begin if Interaction = 0 then Button[High(Button)].X := 300 - 260; @@ -1117,7 +1150,8 @@ begin // circle { - for B := 0 to High(Button) do begin + for B := 0 to High(Button) do + begin Factor := (B - Interaction); // 0 to center, -1: to left, +1 to right Factor2 := Factor / Length(Button); Button[B].X := 300 + 10000 * sin(2*pi*Factor2); @@ -1174,10 +1208,10 @@ procedure TScreenSong.SetScroll5; var B: integer; Angle: real; - Pos: Real; + Pos: real; VS: integer; Padding: real; - X: Real; + X: real; { Theme.Song.CoverW: circle radius Theme.Song.CoverX: x-pos. of the left edge of the selected cover @@ -1249,13 +1283,13 @@ end; procedure TScreenSong.SetScroll6; // rotate (slotmachine style) var B: integer; - Angle: real; - Pos: Real; + Angle: real; + Pos: real; VS: integer; - diff: real; - X: Real; - Factor: real; - Z, Z2: real; + diff: real; + X: real; + Factor: real; + Z, Z2: real; begin VS := CatSongs.VisibleSongs; if VS <= 5 then @@ -1264,22 +1298,23 @@ begin for B := 0 to High(Button) do begin Button[B].Visible := CatSongs.Song[B].Visible; - if Button[B].Visible then begin // optimization for 1000 songs - updates only visible songs, hiding in tabs becomes useful for maintaing good speed - - Factor := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / VS {CatSongs.VisibleSongs};// 0.5.0 (II): takes another 16ms + if Button[B].Visible then // optimization for 1000 songs - updates only visible songs, hiding in tabs becomes useful for maintaing good speed + begin + + Factor := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / VS {CatSongs.VisibleSongs};// 0.5.0 (II): takes another 16ms - Z := (1 + cos(Factor)) / 2; - Z2 := (1 + 2*Z) / 3; + Z := (1 + cos(Factor)) / 2; + Z2 := (1 + 2*Z) / 3; - Button[B].Y := Theme.Song.Cover.Y + (0.185 * Theme.Song.Cover.H * VS * sin(Factor)) * 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].Y := Theme.Song.Cover.Y + (0.185 * Theme.Song.Cover.H * VS * sin(Factor)) * 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].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; + //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 @@ -1287,10 +1322,10 @@ begin begin //Change Pos of all Buttons for B := low(Button) to high(Button) do - begin - Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visibility + begin + Button[B].Visible := CatSongs.Song[B].Visible; //Adjust Visibility if Button[B].Visible then //Only Change Pos for Visible Buttons - begin + begin Pos := (CatSongs.VisibleIndex(B) - SongCurrent); if (Pos < -VS/2) then Pos := Pos + VS @@ -1300,7 +1335,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); @@ -1323,8 +1358,10 @@ 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:=25; + 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 @@ -1442,9 +1479,9 @@ end; function TScreenSong.Draw: boolean; var - dx: real; - dt: real; - I: Integer; + dx: real; + dt: real; + I: integer; begin dx := SongTarget-SongCurrent; dt := TimeSkip * 7; @@ -1455,7 +1492,8 @@ begin SongCurrent := SongCurrent + dx*dt; { - if SongCurrent > Catsongs.VisibleSongs then begin + if SongCurrent > Catsongs.VisibleSongs then + begin SongCurrent := SongCurrent - Catsongs.VisibleSongs; SongTarget := SongTarget - Catsongs.VisibleSongs; end; @@ -1521,8 +1559,8 @@ end; procedure TScreenSong.SelectNext; var - Skip: integer; - VS: Integer; + Skip: integer; + VS: integer; begin VS := CatSongs.VisibleSongs; @@ -1541,7 +1579,8 @@ begin Interaction := (Interaction + Skip) mod Length(Interactions); // try to keep all at the beginning - if SongTarget > VS-1 then begin + if SongTarget > VS-1 then + begin SongTarget := SongTarget - VS; SongCurrent := SongCurrent - VS; end; @@ -1555,8 +1594,8 @@ end; procedure TScreenSong.SelectPrev; var - Skip: integer; - VS: Integer; + Skip: integer; + VS: integer; begin VS := CatSongs.VisibleSongs; @@ -1566,13 +1605,15 @@ begin Skip := 1; - while (not CatSongs.Song[(Interaction - Skip + Length(Interactions)) mod Length(Interactions)].Visible) do Inc(Skip); + while (not CatSongs.Song[(Interaction - Skip + Length(Interactions)) mod Length(Interactions)].Visible) do + Inc(Skip); SongTarget := SongTarget - 1;//Skip; Interaction := (Interaction - Skip + Length(Interactions)) mod Length(Interactions); // try to keep all at the beginning - if SongTarget < 0 then begin + if SongTarget < 0 then + begin SongTarget := SongTarget + CatSongs.VisibleSongs; SongCurrent := SongCurrent + CatSongs.VisibleSongs; end; @@ -1652,9 +1693,9 @@ begin end; end; -procedure TScreenSong.SkipTo(Target: Cardinal); +procedure TScreenSong.SkipTo(Target: cardinal); var - i: integer; + i: integer; begin UnLoadDetailedCover; @@ -1669,7 +1710,7 @@ end; procedure TScreenSong.SelectRandomSong; var - I, I2: Integer; + I, I2: integer; begin case PlaylistMan.Mode of smNormal: //All Songs Just Select Random Song @@ -1748,11 +1789,11 @@ begin end else begin - Static[StaticTeam1Joker1].Visible := False; - Static[StaticTeam1Joker2].Visible := False; - Static[StaticTeam1Joker3].Visible := False; - Static[StaticTeam1Joker4].Visible := False; - Static[StaticTeam1Joker5].Visible := False; + 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 @@ -1765,11 +1806,11 @@ begin end else begin - Static[StaticTeam2Joker1].Visible := False; - Static[StaticTeam2Joker2].Visible := False; - Static[StaticTeam2Joker3].Visible := False; - Static[StaticTeam2Joker4].Visible := False; - Static[StaticTeam2Joker5].Visible := False; + 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 @@ -1782,40 +1823,40 @@ begin end else begin - Static[StaticTeam3Joker1].Visible := False; - Static[StaticTeam3Joker2].Visible := False; - Static[StaticTeam3Joker3].Visible := False; - Static[StaticTeam3Joker4].Visible := False; - Static[StaticTeam3Joker5].Visible := False; + 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; + 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; + I: integer; + Visible: boolean; begin //Set Visibility of Party Statics and Text Visible := (Mode = smPartyMode); @@ -1859,7 +1900,7 @@ begin CatSongs.Selected := Interaction; StopMusicPreview(); - ScreenName.Goto_SingScreen := True; + ScreenName.Goto_SingScreen := true; FadeTo(@ScreenName); end; -- cgit v1.2.3 From 31b5e9286f721b7cc81f620a28d8de5d0087c63c Mon Sep 17 00:00:00 2001 From: tobigun Date: Sat, 21 Mar 2009 19:11:54 +0000 Subject: New plugin mode reverted (will be moved to a branch afterwards). Party mode might work again (untested). This might break linux compatibility. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1641 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 8aa5acca..8f6fafea 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -706,36 +706,36 @@ begin end; SDLK_1: - begin //Joker // to-do : Party - {if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= 1) and (PartySession.Teams.Teaminfo[0].Joker > 0) then + begin //Joker + if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= 1) and (PartySession.Teams.Teaminfo[0].Joker > 0) then begin //Use Joker Dec(PartySession.Teams.Teaminfo[0].Joker); SelectRandomSong; SetJoker; - end; } + end; end; SDLK_2: begin //Joker - {if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= 2) and (PartySession.Teams.Teaminfo[1].Joker > 0) then + if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= 2) and (PartySession.Teams.Teaminfo[1].Joker > 0) then begin //Use Joker Dec(PartySession.Teams.Teaminfo[1].Joker); SelectRandomSong; SetJoker; - end; } + end; end; SDLK_3: begin //Joker - {if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= 3) and (PartySession.Teams.Teaminfo[2].Joker > 0) then + if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= 3) and (PartySession.Teams.Teaminfo[2].Joker > 0) then begin //Use Joker Dec(PartySession.Teams.Teaminfo[2].Joker); SelectRandomSong; SetJoker; - end; } + end; end; end; end; // if (PressedDown) @@ -1775,10 +1775,8 @@ 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); @@ -1829,7 +1827,6 @@ begin Static[StaticTeam3Joker4].Visible := false; Static[StaticTeam3Joker5].Visible := false; end; - *) end else begin //Hide all @@ -1920,7 +1917,6 @@ 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 @@ -1930,7 +1926,6 @@ begin SelectRandomSong; SetJoker; end; - } end; //Detailed Cover Unloading. Unloads the Detailed, uncached Cover of the cur. Song -- cgit v1.2.3 From c7f5d683c1eae49e30ee42a76557661f57311b9e Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Sat, 25 Apr 2009 10:09:59 +0000 Subject: Cosmetics. No code change git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1694 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 50 +++++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 31 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 8f6fafea..8f4dd5da 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -33,7 +33,6 @@ interface {$I switches.inc} - uses UMenu, SDL, @@ -111,7 +110,6 @@ type StaticNonParty: array of cardinal; TextNonParty: array of cardinal; - constructor Create; override; procedure SetScroll; //procedure SetScroll1; @@ -142,7 +140,7 @@ type //procedures for Menu procedure StartSong; procedure OpenEditor; - procedure DoJoker(Team: Byte); + procedure DoJoker(Team: byte); procedure SelectPlayers; procedure UnloadDetailedCover; @@ -242,14 +240,13 @@ begin end; //Show Cat in Top Left Mod End - -// Method for input parsing. If False is returned, GetNextWindow +// Method for input parsing. If false is returned, GetNextWindow // should be checked to know the next window to load; function TScreenSong.ParseInput(PressedKey: cardinal; CharCode: WideChar; PressedDown: boolean): boolean; var I: integer; I2: integer; - SDL_ModState: Word; + SDL_ModState: word; Letter: WideChar; begin Result := true; @@ -455,7 +452,7 @@ begin //Fix: Not Existing Song selected: //if (I+1=I2) then - Inc(I2); + Inc(I2); //Choose Song SkipTo(I2-I); @@ -504,7 +501,6 @@ begin //Show Cat in Top Left Mod HideCatTL; - //Show Wrong Song when Tabs on Fix SelectNext; FixSelected; @@ -610,7 +606,7 @@ begin begin I := Interaction; if I <= 0 then - I := 1; + I := 1; while not catsongs.Song[I].Main do begin @@ -652,7 +648,7 @@ begin I := Interaction; I2 := 0; if I <= 0 then - I := 1; + I := 1; while not catsongs.Song[I].Main or (I2 = 0) do begin @@ -802,7 +798,6 @@ begin GenerateThumbnails(); - // Randomize Patch Randomize; @@ -957,7 +952,6 @@ begin if CatSongs.Song[B].Visible then Inc(VisInt); - if VisCount <= 6 then begin Typ := 0; @@ -986,7 +980,6 @@ begin end; - // hide all buttons for B := 0 to High(Button) do begin @@ -1004,7 +997,6 @@ begin end; } - if Typ = 0 then begin for B := 0 to High(Button) do @@ -1301,20 +1293,19 @@ begin if Button[B].Visible then // optimization for 1000 songs - updates only visible songs, hiding in tabs becomes useful for maintaing good speed begin - Factor := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / VS {CatSongs.VisibleSongs};// 0.5.0 (II): takes another 16ms - - Z := (1 + cos(Factor)) / 2; - Z2 := (1 + 2*Z) / 3; + Factor := 2 * pi * (CatSongs.VisibleIndex(B) - SongCurrent) / VS {CatSongs.VisibleSongs};// 0.5.0 (II): takes another 16ms + Z := (1 + cos(Factor)) / 2; + Z2 := (1 + 2*Z) / 3; - Button[B].Y := Theme.Song.Cover.Y + (0.185 * Theme.Song.Cover.H * VS * sin(Factor)) * 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].Y := Theme.Song.Cover.Y + (0.185 * Theme.Song.Cover.H * VS * sin(Factor)) * 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].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; + //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 @@ -1349,7 +1340,6 @@ begin 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; @@ -1359,9 +1349,9 @@ begin // limit-bg-covers hack if (abs(VS/2-abs(Pos))>10) then - Button[B].Visible := false; + Button[B].Visible := false; if VS > 25 then - VS:=25; + VS:=25; // end of limit-bg-covers hack if Pos < 0 then @@ -1379,7 +1369,6 @@ begin 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); @@ -1389,7 +1378,6 @@ begin end; end; - procedure TScreenSong.onShow; begin inherited; @@ -1453,7 +1441,7 @@ begin AudioPlayback.SetVolume(1.0); // if preview is deactivated: load musicfile now - If (IPreviewVolumeVals[Ini.PreviewVolume] = 0) then + if (IPreviewVolumeVals[Ini.PreviewVolume] = 0) then AudioPlayback.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); // if hide then stop music (for party mode popup on exit) @@ -1915,7 +1903,7 @@ begin end; //Team No of Team (0-5) -procedure TScreenSong.DoJoker (Team: Byte); +procedure TScreenSong.DoJoker (Team: byte); begin if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= Team + 1) and -- cgit v1.2.3 From 83fbcd53cb2ffb4fa930df1234e4388ca9fdf07f Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Thu, 28 May 2009 17:30:21 +0000 Subject: change range of random. was probably reason for out of range crash. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1786 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 95 ++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 48 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 8f4dd5da..f937b1dc 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -175,7 +175,7 @@ begin if CatSongs.VisibleSongs > 0 then begin I2:= 0; - for I := low(CatSongs.Song) to High(Catsongs.Song) do + for I := Low(CatSongs.Song) to High(Catsongs.Song) do begin if CatSongs.Song[I].Visible then inc(I2); @@ -196,7 +196,7 @@ begin if CatSongs.VisibleSongs > 0 then begin I2:= 0; - for I := low(CatSongs.Song) to High(Catsongs.Song) do + for I := Low(CatSongs.Song) to High(Catsongs.Song) do begin if CatSongs.Song[I].Visible then inc(I2); @@ -280,7 +280,7 @@ begin //Jump To Titel if (SDL_ModState = (KMOD_LALT or KMOD_LSHIFT)) then begin - for I := 1 to high(CatSongs.Song) do + for I := 1 to High(CatSongs.Song) do begin if (CatSongs.Song[(I + Interaction) mod I2].Visible) and (Length(CatSongs.Song[(I + Interaction) mod I2].Title)>0) and @@ -300,7 +300,7 @@ begin //Jump to Artist else if (SDL_ModState = KMOD_LALT) then begin - for I := 1 to high(CatSongs.Song) do + for I := 1 to High(CatSongs.Song) do begin if (CatSongs.Song[(I + Interaction) mod I2].Visible) and (Length(CatSongs.Song[(I + Interaction) mod I2].Artist)>0) and @@ -395,25 +395,25 @@ begin if (Songs.SongList.Count > 0) and (Mode = smNormal) then begin - if (SDL_ModState = KMOD_LSHIFT) and (Ini.TabsAtStartup = 1) then //Random Category + if (SDL_ModState = KMOD_LSHIFT) and (Ini.TabsAtStartup = 1) then // random category begin - I2 := 0; //Count Cats - for I:= 0 to high(CatSongs.Song) do + I2 := 0; // count cats + for I := 0 to High(CatSongs.Song) do begin if CatSongs.Song[I].Main then Inc(I2); end; - I2 := Random(I2)+1; //Zufall + I2 := Random(I2 + 1); // random and include I2 - //Find Cat: - for I:= 0 to high(CatSongs.Song) do + // find cat: + for I := 0 to High(CatSongs.Song) do begin if CatSongs.Song[I].Main then Dec(I2); - if (I2<=0) then + if (I2 <= 0) then begin - //Show Cat in Top Left Mod + // show cat in top left mod ShowCatTL (I); Interaction := I; @@ -426,38 +426,38 @@ begin end; end; end - else if (SDL_ModState = KMOD_LCTRL) and (Ini.TabsAtStartup = 1) then //random in All Categorys + else if (SDL_ModState = KMOD_LCTRL) and (Ini.TabsAtStartup = 1) then // random in all categories begin repeat - I2 := Random(high(CatSongs.Song)+1) + 1; + I2 := Random(High(CatSongs.Song) + 1); until (not CatSongs.Song[I2].Main); - //Search Cat + // search cat for I := I2 downto 0 do begin if CatSongs.Song[I].Main then break; end; - //In I is now the categorie in I2 the song + // in I is now the categorie in I2 the song - //Choose Cat + // choose cat CatSongs.ShowCategoryList; - //Show Cat in Top Left Mod + // show cat in top left mod ShowCatTL (I); CatSongs.ClickCategoryButton(I); SelectNext; - //Fix: Not Existing Song selected: - //if (I+1=I2) then + // Fix: not existing song selected: + //if (I + 1 = I2) then Inc(I2); - //Choose Song - SkipTo(I2-I); + // choose song + SkipTo(I2 - I); end - else //Random in one Category + else // random in one category begin SkipTo(Random(CatSongs.VisibleSongs)); end; @@ -489,7 +489,7 @@ begin break; end; if (I <= 1) then - Interaction := high(CatSongs.Song) + Interaction := High(CatSongs.Song) else Interaction := I - 1; @@ -611,8 +611,8 @@ begin while not catsongs.Song[I].Main do begin Inc (I); - if (I > high(catsongs.Song)) then - I := low(catsongs.Song); + if (I > High(catsongs.Song)) then + I := Low(catsongs.Song); end; Interaction := I; @@ -655,8 +655,8 @@ begin if catsongs.Song[I].Main then Inc(I2); Dec (I); - if (I < low(catsongs.Song)) then - I := high(catsongs.Song); + if (I < Low(catsongs.Song)) then + I := High(catsongs.Song); end; Interaction := I; @@ -1312,7 +1312,7 @@ begin else begin //Change Pos of all Buttons - for B := low(Button) to high(Button) do + 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 @@ -1701,41 +1701,40 @@ var I, I2: integer; begin case PlaylistMan.Mode of - smNormal: //All Songs Just Select Random Song + smNormal: // all songs just select random song begin - //When Tabs are activated then use Tab Method + // when tabs are activated then use tab method if (Ini.TabsAtStartup = 1) then begin repeat - I2 := Random(high(CatSongs.Song)+1) - low(CatSongs.Song)+1; + I2 := Low(CatSongs.Song) + Random(High(CatSongs.Song) + 1 - Low(CatSongs.Song)); until CatSongs.Song[I2].Main = false; - //Search Cat - for I := I2 downto low(CatSongs.Song) do + // search cat + for I := I2 downto Low(CatSongs.Song) do begin if CatSongs.Song[I].Main then break; end; - //In I ist jetzt die Kategorie in I2 der Song - //I is the CatNum, I2 is the No of the Song within this Cat + // I is the cat number, I2 is the no of the song within this cat - //Choose Cat + // choose cat CatSongs.ShowCategoryList; - //Show Cat in Top Left Mod - ShowCatTL (I); + // show cat in top left mod + ShowCatTL(I); CatSongs.ClickCategoryButton(I); SelectNext; - //Choose Song - SkipTo(I2-I); + // choose song + SkipTo(I2 - I); end - //When Tabs are deactivated use easy Method + // when tabs are deactivated use easy method else SkipTo(Random(CatSongs.VisibleSongs)); end; - smPartyMode: //One Category Select Category and Select Random Song + smPartyMode: // one category select category and select random song begin CatSongs.ShowCategoryList; CatSongs.ClickCategoryButton(PlaylistMan.CurPlayList); @@ -1746,7 +1745,7 @@ begin SkipTo(Random(CatSongs.VisibleSongs)); end; - smPlaylistRandom: //Playlist: Select Playlist and Select Random Song + smPlaylistRandom: // playlist: select playlist and select random song begin PlaylistMan.SetPlayList(PlaylistMan.CurPlayList); @@ -1846,19 +1845,19 @@ begin //Set Visibility of Party Statics and Text Visible := (Mode = smPartyMode); - for I := 0 to high(StaticParty) do + for I := 0 to High(StaticParty) do Static[StaticParty[I]].Visible := Visible; - for I := 0 to high(TextParty) do + for I := 0 to High(TextParty) do Text[TextParty[I]].Visible := Visible; //Set Visibility of Non Party Statics and Text Visible := not Visible; - for I := 0 to high(StaticNonParty) do + for I := 0 to High(StaticNonParty) do Static[StaticNonParty[I]].Visible := Visible; - for I := 0 to high(TextNonParty) do + for I := 0 to High(TextNonParty) do Text[TextNonParty[I]].Visible := Visible; end; -- cgit v1.2.3 From 257854c587f0876a912cfbeb4fe0a30970d25a9b Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 31 May 2009 14:10:42 +0000 Subject: merged (experimental) mouse support patch by d0ccrazy some changes to patch - implemented software cursor (texturable) - option to turn of mouse support or switch between hardware and software cursor - hide software cursor if there is no mouse activity for 5 seconds - soft fade in and out for software cursor - some test cursor-textures for deluxe theme (mog pls change these horible looking images) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1789 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index f937b1dc..5e794891 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -119,6 +119,7 @@ type procedure SetScroll5; procedure SetScroll6; function ParseInput(PressedKey: cardinal; CharCode: WideChar; PressedDown: boolean): boolean; override; + function ParseMouse(MouseButton: Integer; BtnDown: Boolean; X, Y: integer): boolean; override; function Draw: boolean; override; procedure GenerateThumbnails(); procedure onShow; override; @@ -737,6 +738,28 @@ begin end; // if (PressedDown) end; +function TScreenSong.ParseMouse(MouseButton: Integer; BtnDown: Boolean; X, Y: integer): boolean; +begin + Result := True; + + if RightMbESC and (MouseButton = SDL_BUTTON_RIGHT) and BtnDown then begin + //if RightMbESC is set, send ESC keypress + Result:=ParseInput(SDLK_ESCAPE, #0, True); + end; + + //song scrolling with mousewheel + if (MouseButton = SDL_BUTTON_WHEELDOWN) and BtnDown then begin + ParseInput(SDLK_RIGHT, #0, true); + end; + if (MouseButton = SDL_BUTTON_WHEELUP) and BtnDown then begin + ParseInput(SDLK_LEFT, #0, true); + end; + //LMB anywhere starts + if (MouseButton = SDL_BUTTON_LEFT) and BtnDown then begin + ParseInput(SDLK_RETURN, #0, true); + end; +end; + constructor TScreenSong.Create; var i: integer; -- cgit v1.2.3 From 133f0b4ebcc3b731e680a72ced52d00638791bf7 Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Thu, 4 Jun 2009 21:31:23 +0000 Subject: cosmetics git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1800 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 46 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 5e794891..fa3c836e 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -34,22 +34,22 @@ interface {$I switches.inc} uses - UMenu, - SDL, - UMusic, - UFiles, - UTime, - UDisplay, - USongs, SysUtils, + SDL, UCommon, - ULog, - UThemes, - UTexture, + UDisplay, + UFiles, + UIni, ULanguage, + ULog, + UMenu, + UMenuEqualizer, + UMusic, USong, - UIni, - UMenuEqualizer; + USongs, + UTexture, + UThemes, + UTime; type TScreenSong = class(TMenu) @@ -119,7 +119,7 @@ type procedure SetScroll5; procedure SetScroll6; function ParseInput(PressedKey: cardinal; CharCode: WideChar; PressedDown: boolean): boolean; override; - function ParseMouse(MouseButton: Integer; BtnDown: Boolean; X, Y: integer): boolean; override; + function ParseMouse(MouseButton: integer; BtnDown: boolean; X, Y: integer): boolean; override; function Draw: boolean; override; procedure GenerateThumbnails(); procedure onShow; override; @@ -738,26 +738,24 @@ begin end; // if (PressedDown) end; -function TScreenSong.ParseMouse(MouseButton: Integer; BtnDown: Boolean; X, Y: integer): boolean; +function TScreenSong.ParseMouse(MouseButton: integer; BtnDown: boolean; X, Y: integer): boolean; begin - Result := True; + Result := true; - if RightMbESC and (MouseButton = SDL_BUTTON_RIGHT) and BtnDown then begin + if RightMbESC and (MouseButton = SDL_BUTTON_RIGHT) and BtnDown then //if RightMbESC is set, send ESC keypress - Result:=ParseInput(SDLK_ESCAPE, #0, True); - end; + Result:=ParseInput(SDLK_ESCAPE, #0, true); //song scrolling with mousewheel - if (MouseButton = SDL_BUTTON_WHEELDOWN) and BtnDown then begin + if (MouseButton = SDL_BUTTON_WHEELDOWN) and BtnDown then ParseInput(SDLK_RIGHT, #0, true); - end; - if (MouseButton = SDL_BUTTON_WHEELUP) and BtnDown then begin + + if (MouseButton = SDL_BUTTON_WHEELUP) and BtnDown then ParseInput(SDLK_LEFT, #0, true); - end; + //LMB anywhere starts - if (MouseButton = SDL_BUTTON_LEFT) and BtnDown then begin + if (MouseButton = SDL_BUTTON_LEFT) and BtnDown then ParseInput(SDLK_RETURN, #0, true); - end; end; constructor TScreenSong.Create; -- cgit v1.2.3 From 917901e8e33438c425aef50a0a7417f32d77b760 Mon Sep 17 00:00:00 2001 From: s_alexander Date: Mon, 9 Nov 2009 00:27:55 +0000 Subject: merged unicode branch (r1931) into trunk git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1939 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 130 +++++++++++++++++++++++--------------------- 1 file changed, 69 insertions(+), 61 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index fa3c836e..5fa6de39 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -38,6 +38,7 @@ uses SDL, UCommon, UDisplay, + UPath, UFiles, UIni, ULanguage, @@ -118,19 +119,19 @@ type procedure SetScroll4; procedure SetScroll5; procedure SetScroll6; - function ParseInput(PressedKey: cardinal; CharCode: WideChar; PressedDown: boolean): boolean; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; function ParseMouse(MouseButton: integer; BtnDown: boolean; X, Y: integer): boolean; override; function Draw: boolean; override; procedure GenerateThumbnails(); - procedure onShow; override; - procedure onHide; override; + procedure OnShow; override; + procedure OnHide; override; procedure SelectNext; procedure SelectPrev; 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 ShowCatTLCustom(Caption: UTF8String);// Show Custom Text in Top left procedure HideCatTL;// Show Cat in Tob left procedure Refresh; //Refresh Song Sorting procedure ChangeMusic; @@ -164,7 +165,8 @@ uses UParty, UPlaylist, UScreenSongMenu, - USkins; + USkins, + UUnicodeUtils; // ***** Public methods ****** // @@ -211,7 +213,7 @@ begin end; //Show Wrong Song when Tabs on Fix End -procedure TScreenSong.ShowCatTLCustom(Caption: string);// Show Custom Text in Top left +procedure TScreenSong.ShowCatTLCustom(Caption: UTF8String);// Show Custom Text in Top left begin Text[TextCat].Text := Caption; Text[TextCat].Visible := true; @@ -243,12 +245,13 @@ 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; CharCode: WideChar; PressedDown: boolean): boolean; +function TScreenSong.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; var I: integer; I2: integer; SDL_ModState: word; - Letter: WideChar; + UpperLetter: UCS4Char; + TempStr: UTF8String; begin Result := true; @@ -273,9 +276,10 @@ begin //Jump to Artist/Titel if ((SDL_ModState and KMOD_LALT <> 0) and (Mode = smNormal)) then begin - if (WideCharUpperCase(CharCode)[1] in ([WideChar('A')..WideChar('Z'), WideChar('0') .. WideChar('9')]) ) then + UpperLetter := UCS4UpperCase(CharCode); + + if (UpperLetter in ([Ord('A')..Ord('Z'), Ord('0') .. Ord('9')]) ) then begin - Letter := WideCharUpperCase(CharCode)[1]; I2 := Length(CatSongs.Song); //Jump To Titel @@ -283,18 +287,21 @@ 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 - (WideStringUpperCase(CatSongs.Song[(I + Interaction) mod I2].Title)[1] = Letter) then + if (CatSongs.Song[(I + Interaction) mod I2].Visible) then begin - SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); + TempStr := CatSongs.Song[(I + Interaction) mod I2].Title; + if (Length(TempStr) > 0) and + (UCS4UpperCase(UTF8ToUCS4String(TempStr)[0]) = UpperLetter) then + begin + SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); - AudioPlayback.PlaySound(SoundLib.Change); + AudioPlayback.PlaySound(SoundLib.Change); - ChangeMusic; - SetScroll4; - //Break and Exit - Exit; + ChangeMusic; + SetScroll4; + //Break and Exit + Exit; + end; end; end; end @@ -303,19 +310,22 @@ 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 - (WideStringUpperCase(CatSongs.Song[(I + Interaction) mod I2].Artist)[1] = Letter) then + if (CatSongs.Song[(I + Interaction) mod I2].Visible) then begin - SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); + TempStr := CatSongs.Song[(I + Interaction) mod I2].Artist; + if (Length(TempStr) > 0) and + (UCS4UpperCase(UTF8ToUCS4String(TempStr)[0]) = UpperLetter) then + begin + SkipTo(CatSongs.VisibleIndex((I + Interaction) mod I2)); - AudioPlayback.PlaySound(SoundLib.Change); + AudioPlayback.PlaySound(SoundLib.Change); - ChangeMusic; - SetScroll4; + ChangeMusic; + SetScroll4; - //Break and Exit - Exit; + //Break and Exit + Exit; + end; end; end; end; @@ -325,14 +335,14 @@ begin end; // check normal keys - case WideCharUpperCase(CharCode)[1] of - 'Q': + case UCS4UpperCase(CharCode) of + Ord('Q'): begin Result := false; Exit; end; - 'M': //Show SongMenu + Ord('M'): //Show SongMenu begin if (Songs.SongList.Count > 0) then begin @@ -342,41 +352,41 @@ begin begin if CatSongs.CatNumShow = -3 then begin - ScreenSongMenu.onShow; + ScreenSongMenu.OnShow; ScreenSongMenu.MenuShow(SM_Playlist); end else begin - ScreenSongMenu.onShow; + ScreenSongMenu.OnShow; ScreenSongMenu.MenuShow(SM_Main); end; end else begin - ScreenSongMenu.onShow; + ScreenSongMenu.OnShow; ScreenSongMenu.MenuShow(SM_Playlist_Load); end; end //Party Mode -> Show Party Menu else begin - ScreenSongMenu.onShow; + ScreenSongMenu.OnShow; ScreenSongMenu.MenuShow(SM_Party_Main); end; end; Exit; end; - 'P': //Show Playlist Menu + Ord('P'): //Show Playlist Menu begin if (Songs.SongList.Count > 0) and (Mode = smNormal) then begin - ScreenSongMenu.onShow; + ScreenSongMenu.OnShow; ScreenSongMenu.MenuShow(SM_Playlist_Load); end; Exit; end; - 'J': //Show Jumpto Menu + Ord('J'): //Show Jumpto Menu begin if (Songs.SongList.Count > 0) and (Mode = smNormal) then begin @@ -385,13 +395,13 @@ begin Exit; end; - 'E': + Ord('E'): begin OpenEditor; Exit; end; - 'R': + Ord('R'): begin if (Songs.SongList.Count > 0) and (Mode = smNormal) then @@ -515,7 +525,7 @@ begin if (CatSongs.CatNumShow < -1) then begin //Atm: Set Empty Filter - CatSongs.SetFilter('', 0); + CatSongs.SetFilter('', fltAll); //Show Cat in Top Left Mod HideCatTL; @@ -744,18 +754,18 @@ begin if RightMbESC and (MouseButton = SDL_BUTTON_RIGHT) and BtnDown then //if RightMbESC is set, send ESC keypress - Result:=ParseInput(SDLK_ESCAPE, #0, true); + Result:=ParseInput(SDLK_ESCAPE, 0, true); //song scrolling with mousewheel if (MouseButton = SDL_BUTTON_WHEELDOWN) and BtnDown then - ParseInput(SDLK_RIGHT, #0, true); + ParseInput(SDLK_RIGHT, 0, true); if (MouseButton = SDL_BUTTON_WHEELUP) and BtnDown then - ParseInput(SDLK_LEFT, #0, true); + ParseInput(SDLK_LEFT, 0, true); //LMB anywhere starts if (MouseButton = SDL_BUTTON_LEFT) and BtnDown then - ParseInput(SDLK_RETURN, #0, true); + ParseInput(SDLK_RETURN, 0, true); end; constructor TScreenSong.Create; @@ -833,9 +843,9 @@ var I: integer; CoverButtonIndex: integer; CoverButton: TButton; - CoverName: string; CoverTexture: TTexture; Cover: TCover; + CoverFile: IPath; Song: TSong; begin if (Length(CatSongs.Song) <= 0) then @@ -850,7 +860,7 @@ begin CoverButton := nil; // create a clickable cover - CoverButtonIndex := AddButton(300 + I*250, 140, 200, 200, '', TEXTURE_TYPE_PLAIN, Theme.Song.Cover.Reflections); + CoverButtonIndex := AddButton(300 + I*250, 140, 200, 200, PATH_NONE, TEXTURE_TYPE_PLAIN, Theme.Song.Cover.Reflections); if (CoverButtonIndex > -1) then CoverButton := Button[CoverButtonIndex]; if (CoverButton = nil) then @@ -859,18 +869,16 @@ begin Song := CatSongs.Song[I]; // if cover-image is not found then show 'no cover' - if (not FileExists(Song.Path + Song.Cover)) then - Song.Cover := ''; - - if (Song.Cover = '') then - CoverName := Skin.GetTextureFileName('SongCover') - else - CoverName := Song.Path + Song.Cover; + CoverFile := Song.Path.Append(Song.Cover); + if (not CoverFile.IsFile()) then + Song.Cover := PATH_NONE; + if (Song.Cover.IsUnset) then + CoverFile := Skin.GetTextureFileName('SongCover'); // load cover and cache its texture - Cover := Covers.FindCover(CoverName); + Cover := Covers.FindCover(CoverFile); if (Cover = nil) then - Cover := Covers.AddCover(CoverName); + Cover := Covers.AddCover(CoverFile); // use the cached texture // TODO: this is a workaround until the new song-loading works. @@ -910,7 +918,7 @@ begin end; // Set visibility of video icon - Static[VideoIcon].Visible := (CatSongs.Song[Interaction].Video <> ''); + Static[VideoIcon].Visible := CatSongs.Song[Interaction].Video.IsSet; // Set texts Text[TextArtist].Text := CatSongs.Song[Interaction].Artist; @@ -1399,7 +1407,7 @@ begin end; end; -procedure TScreenSong.onShow; +procedure TScreenSong.OnShow; begin inherited; {** @@ -1456,14 +1464,14 @@ begin SetStatics; end; -procedure TScreenSong.onHide; +procedure TScreenSong.OnHide; begin // turn music volume to 100% AudioPlayback.SetVolume(1.0); // if preview is deactivated: load musicfile now if (IPreviewVolumeVals[Ini.PreviewVolume] = 0) then - AudioPlayback.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3); + AudioPlayback.Open(CatSongs.Song[Interaction].Path.Append(CatSongs.Song[Interaction].Mp3)); // if hide then stop music (for party mode popup on exit) if (Display.NextScreen <> @ScreenSing) and @@ -1642,7 +1650,7 @@ begin if not assigned(Song) then Exit; - if AudioPlayback.Open(Song.Path + Song.Mp3) then + if AudioPlayback.Open(Song.Path.Append(Song.Mp3)) then begin AudioPlayback.Position := AudioPlayback.Length / 4; // set preview volume -- cgit v1.2.3 From 85c7cf68848e3640238cfaa631305ae87e59cf66 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Mon, 9 Nov 2009 21:00:17 +0000 Subject: fixed folders=on bug for the moment git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1941 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 5fa6de39..9a534c51 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -868,10 +868,17 @@ begin Song := CatSongs.Song[I]; - // if cover-image is not found then show 'no cover' - CoverFile := Song.Path.Append(Song.Cover); - if (not CoverFile.IsFile()) then + if not Song.Main then + begin // to-do : load category covers again... + // just a workaround to fic folders=on for the moment... + // if cover-image is not found then show 'no cover' + CoverFile := Song.Path.Append(Song.Cover); + if (not CoverFile.IsFile()) then + Song.Cover := PATH_NONE; + end + else Song.Cover := PATH_NONE; + if (Song.Cover.IsUnset) then CoverFile := Skin.GetTextureFileName('SongCover'); -- cgit v1.2.3 From 1c86cfca45351b172e42d508cb55788c644ed392 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Tue, 17 Nov 2009 18:50:57 +0000 Subject: fixed #89: wrong mp3 playback when selecting song while scrolling the issue was caused by the delayed song loading to prevent noise when scrolling git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1947 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 9a534c51..ff2ab201 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -57,6 +57,9 @@ type private Equalizer: Tms_Equalizer; + PreviewOpened: Integer; // interaction of the Song that is loaded for preview music + // -1 if nothing is opened + procedure StartMusicPreview(); procedure StopMusicPreview(); public @@ -834,6 +837,8 @@ begin Equalizer := Tms_Equalizer.Create(AudioPlayback, Theme.Song.Equalizer); + PreviewOpened := -1; + if (Length(CatSongs.Song) > 0) then Interaction := 0; end; @@ -1440,7 +1445,9 @@ begin begin //Load Music only when Song Preview is activated if ( Ini.PreviewVolume <> 0 ) then - StartMusicPreview(); + StartMusicPreview() + else + PreviewOpened := -1; SetScroll; end; @@ -1473,13 +1480,13 @@ end; procedure TScreenSong.OnHide; begin + // if preview is not loaded: load musicfile now + if (PreviewOpened <> Interaction) then + AudioPlayback.Open(CatSongs.Song[Interaction].Path.Append(CatSongs.Song[Interaction].Mp3)); + // turn music volume to 100% AudioPlayback.SetVolume(1.0); - // if preview is deactivated: load musicfile now - if (IPreviewVolumeVals[Ini.PreviewVolume] = 0) then - AudioPlayback.Open(CatSongs.Song[Interaction].Path.Append(CatSongs.Song[Interaction].Mp3)); - // if hide then stop music (for party mode popup on exit) if (Display.NextScreen <> @ScreenSing) and (Display.NextScreen <> @ScreenSingModi) then @@ -1659,6 +1666,8 @@ begin if AudioPlayback.Open(Song.Path.Append(Song.Mp3)) then begin + PreviewOpened := Interaction; + AudioPlayback.Position := AudioPlayback.Length / 4; // set preview volume if (Ini.PreviewFading = 0) then @@ -1706,6 +1715,7 @@ end; procedure TScreenSong.ChangeMusic; begin StopMusicPreview(); + PreviewOpened := -1; // Preview song if activated and current selection is not a category cover if (CatSongs.VisibleSongs > 0) and -- cgit v1.2.3 From 9975f56cded5f6251d0110238fd97b7ee7ccae31 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 18 Nov 2009 14:42:34 +0000 Subject: some changes on mousesupport - you can click on the whole area of a button after fading - options on selects can be changed by clicking on the arrows - fix mouse parsing at the screensong extensions git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1950 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index ff2ab201..e74ea75d 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -755,20 +755,33 @@ function TScreenSong.ParseMouse(MouseButton: integer; BtnDown: boolean; X, Y: in begin Result := true; - if RightMbESC and (MouseButton = SDL_BUTTON_RIGHT) and BtnDown then - //if RightMbESC is set, send ESC keypress - Result:=ParseInput(SDLK_ESCAPE, 0, true); + if (ScreenSongMenu.Visible) then + begin + Result := ScreenSongMenu.ParseMouse(MouseButton, BtnDown, X, Y); + exit; + end + else if (ScreenSongJumpTo.Visible) then + begin + Result := ScreenSongJumpTo.ParseMouse(MouseButton, BtnDown, X, Y); + exit; + end + else // no extension visible + begin + if RightMbESC and (MouseButton = SDL_BUTTON_RIGHT) and BtnDown then + //if RightMbESC is set, send ESC keypress + Result:=ParseInput(SDLK_ESCAPE, 0, true); - //song scrolling with mousewheel - if (MouseButton = SDL_BUTTON_WHEELDOWN) and BtnDown then - ParseInput(SDLK_RIGHT, 0, true); + //song scrolling with mousewheel + if (MouseButton = SDL_BUTTON_WHEELDOWN) and BtnDown then + ParseInput(SDLK_RIGHT, 0, true); - if (MouseButton = SDL_BUTTON_WHEELUP) and BtnDown then - ParseInput(SDLK_LEFT, 0, true); + if (MouseButton = SDL_BUTTON_WHEELUP) and BtnDown then + ParseInput(SDLK_LEFT, 0, true); - //LMB anywhere starts - if (MouseButton = SDL_BUTTON_LEFT) and BtnDown then - ParseInput(SDLK_RETURN, 0, true); + //LMB anywhere starts + if (MouseButton = SDL_BUTTON_LEFT) and BtnDown then + ParseInput(SDLK_RETURN, 0, true); + end; end; constructor TScreenSong.Create; -- cgit v1.2.3 From 91bb1d1517faa4b1abe25d2e0adc7cbaecb6b84d Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 18 Nov 2009 16:04:42 +0000 Subject: select songs by clicking on them click on front song starts singing git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1952 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 77 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 10 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index e74ea75d..a9c47401 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -752,6 +752,9 @@ begin end; function TScreenSong.ParseMouse(MouseButton: integer; BtnDown: boolean; X, Y: integer): boolean; + var + I, J: Integer; + Btn: Integer; begin Result := true; @@ -767,20 +770,74 @@ begin end else // no extension visible begin - if RightMbESC and (MouseButton = SDL_BUTTON_RIGHT) and BtnDown then + if (BtnDown) then + begin //if RightMbESC is set, send ESC keypress - Result:=ParseInput(SDLK_ESCAPE, 0, true); + if RightMbESC and (MouseButton = SDL_BUTTON_RIGHT) then + Result:=ParseInput(SDLK_ESCAPE, 0, true) + + //song scrolling with mousewheel + else if (MouseButton = SDL_BUTTON_WHEELDOWN) then + ParseInput(SDLK_RIGHT, 0, true) + + else if (MouseButton = SDL_BUTTON_WHEELUP) then + ParseInput(SDLK_LEFT, 0, true) + + //LMB anywhere starts + else if (MouseButton = SDL_BUTTON_LEFT) then + begin + if (CatSongs.VisibleSongs > 4) then + begin + // select the second visible button left from selected + I := 0; + Btn := Interaction; + while (I < 2) do + begin + Dec(Btn); + if (Btn < 0) then + Btn := High(CatSongs.Song); + + if (CatSongs.Song[Btn].Visible) then + Inc(I); + end; - //song scrolling with mousewheel - if (MouseButton = SDL_BUTTON_WHEELDOWN) and BtnDown then - ParseInput(SDLK_RIGHT, 0, true); + // test the 5 front buttons for click + for I := 0 to 4 do + begin + if InRegion(X, Y, Button[Btn].GetMouseOverArea) then + begin + // song cover clicked + if (I = 2) then + begin // Selected Song clicked -> start singing + ParseInput(SDLK_RETURN, 0, true); + end + else + begin // one of the other 4 covers in the front clicked -> select it + J := I - 2; + while (J < 0) do + begin + ParseInput(SDLK_LEFT, 0, true); + Inc(J); + end; - if (MouseButton = SDL_BUTTON_WHEELUP) and BtnDown then - ParseInput(SDLK_LEFT, 0, true); + while (J > 0) do + begin + ParseInput(SDLK_RIGHT, 0, true); + Dec(J); + end; + end; + Break; + end; - //LMB anywhere starts - if (MouseButton = SDL_BUTTON_LEFT) and BtnDown then - ParseInput(SDLK_RETURN, 0, true); + Btn := CatSongs.FindNextVisible(Btn); + if (Btn = -1) then + Break; + end; + end + else + ParseInput(SDLK_RETURN, 0, true); + end; + end; end; end; -- cgit v1.2.3 From cd5c858d00c6cbc27291523e2c78d28575778c9e Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Tue, 24 Nov 2009 17:55:34 +0000 Subject: fixed assembla #92: all song covers look like selected ones git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1958 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index a9c47401..7cfb0b0a 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -908,9 +908,6 @@ begin Equalizer := Tms_Equalizer.Create(AudioPlayback, Theme.Song.Equalizer); PreviewOpened := -1; - - if (Length(CatSongs.Song) > 0) then - Interaction := 0; end; procedure TScreenSong.GenerateThumbnails(); @@ -973,10 +970,17 @@ begin CoverTexture := Cover.GetPreviewTexture(); Texture.AddTexture(CoverTexture, TEXTURE_TYPE_PLAIN, true); CoverButton.Texture := CoverTexture; + + // set selected to false -> the right texture will be displayed + CoverButton.Selected := False; end; Cover.Free; end; + + // reset selection + if (Length(CatSongs.Song) > 0) then + Interaction := 0; end; procedure TScreenSong.SetScroll; -- cgit v1.2.3 From c5c8fd69256016ebd39f2de51cad9e35974bc703 Mon Sep 17 00:00:00 2001 From: brunzelchen Date: Sun, 6 Dec 2009 22:14:34 +0000 Subject: fix performance problem on scroll git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1999 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 7cfb0b0a..c2afbfe1 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -128,8 +128,8 @@ type procedure GenerateThumbnails(); procedure OnShow; override; procedure OnHide; override; - procedure SelectNext; - procedure SelectPrev; + procedure SelectNext(UnloadCover: boolean); + procedure SelectPrev(UnloadCover: boolean); procedure SkipTo(Target: cardinal); procedure FixSelected; //Show Wrong Song when Tabs on Fix procedure FixSelected2; //Show Wrong Song when Tabs on Fix @@ -434,7 +434,7 @@ begin CatSongs.ShowCategoryList; CatSongs.ClickCategoryButton(I); - SelectNext; + SelectNext(true); FixSelected; break; end; @@ -462,7 +462,7 @@ begin ShowCatTL (I); CatSongs.ClickCategoryButton(I); - SelectNext; + SelectNext(true); // Fix: not existing song selected: //if (I + 1 = I2) then @@ -516,9 +516,9 @@ begin HideCatTL; //Show Wrong Song when Tabs on Fix - SelectNext; + SelectNext(true); FixSelected; - //SelectPrev; + //SelectPrev(true); //CatSongs.Song[0].Visible := false; end else @@ -535,7 +535,7 @@ begin Interaction := 0; //Show Wrong Song when Tabs on Fix - SelectNext; + SelectNext(true); FixSelected; ChangeMusic; @@ -575,7 +575,7 @@ begin // SetScroll4; //Show Wrong Song when Tabs on Fix - SelectNext; + SelectNext(true); FixSelected; //Play Music: @@ -635,7 +635,7 @@ begin ShowCatTL (Interaction); CatSongs.ClickCategoryButton(Interaction); - SelectNext; + SelectNext(true); FixSelected; //Play Music: @@ -679,7 +679,7 @@ begin ShowCatTL (I); CatSongs.ClickCategoryButton(I); - SelectNext; + SelectNext(true); FixSelected; //Play Music: @@ -696,7 +696,7 @@ begin if (Songs.SongList.Count > 0) and (Mode = smNormal) then begin AudioPlayback.PlaySound(SoundLib.Change); - SelectNext; + SelectNext(true); //InteractNext; //SongTarget := Interaction; ChangeMusic; @@ -709,7 +709,7 @@ begin if (Songs.SongList.Count > 0)and (Mode = smNormal) then begin AudioPlayback.PlaySound(SoundLib.Change); - SelectPrev; + SelectPrev(true); ChangeMusic; SetScroll4; end; @@ -1532,7 +1532,7 @@ begin //If Playlist Shown -> Select Next automatically if (CatSongs.CatNumShow = -3) then begin - SelectNext; + SelectNext(true); ChangeMusic; end; end @@ -1662,7 +1662,7 @@ begin Result := true; end; -procedure TScreenSong.SelectNext; +procedure TScreenSong.SelectNext(UnloadCover: boolean); var Skip: integer; VS: integer; @@ -1671,7 +1671,8 @@ begin if VS > 0 then begin - UnLoadDetailedCover; + if UnloadCover then //that should fix the performance problem on scrolling + UnLoadDetailedCover; Skip := 1; @@ -1697,7 +1698,7 @@ begin //Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, TEXTURE_TYPE_PLAIN, false); end; -procedure TScreenSong.SelectPrev; +procedure TScreenSong.SelectPrev(UnloadCover: boolean); var Skip: integer; VS: integer; @@ -1706,7 +1707,8 @@ begin if VS > 0 then begin - UnLoadDetailedCover; + if UnloadCover then + UnLoadDetailedCover; //that should fix the performance problem on scrolling Skip := 1; @@ -1811,7 +1813,7 @@ begin SongTarget := 0; for i := 1 to Target+1 do - SelectNext; + SelectNext(false); FixSelected2; end; @@ -1845,7 +1847,7 @@ begin ShowCatTL(I); CatSongs.ClickCategoryButton(I); - SelectNext; + SelectNext(true); // choose song SkipTo(I2 - I); @@ -1860,7 +1862,7 @@ begin CatSongs.ClickCategoryButton(PlaylistMan.CurPlayList); ShowCatTL(PlaylistMan.CurPlayList); - SelectNext; + SelectNext(true); FixSelected2; SkipTo(Random(CatSongs.VisibleSongs)); @@ -2054,7 +2056,7 @@ begin CatSongs.Refresh; CatSongs.ShowCategoryList; Interaction := 0; - SelectNext; + SelectNext(true); FixSelected; } end; -- cgit v1.2.3 From 9b312c379c3674e68374704a84e0926d51239584 Mon Sep 17 00:00:00 2001 From: s_alexander Date: Tue, 8 Dec 2009 19:45:14 +0000 Subject: removed if to enable folder cover loading git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2004 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index c2afbfe1..bd5eebe5 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -940,15 +940,8 @@ begin Song := CatSongs.Song[I]; - if not Song.Main then - begin // to-do : load category covers again... - // just a workaround to fic folders=on for the moment... - // if cover-image is not found then show 'no cover' - CoverFile := Song.Path.Append(Song.Cover); - if (not CoverFile.IsFile()) then - Song.Cover := PATH_NONE; - end - else + CoverFile := Song.Path.Append(Song.Cover); + if (not CoverFile.IsFile()) then Song.Cover := PATH_NONE; if (Song.Cover.IsUnset) then -- cgit v1.2.3 From 667a4f92bdd283249e4d7e525eeb7e7c665d1d17 Mon Sep 17 00:00:00 2001 From: brunzelchen Date: Sun, 13 Dec 2009 13:49:07 +0000 Subject: fixed bug: Audio-file does not exist: "" [UAudio_FFmpeg] git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2029 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index bd5eebe5..e43e2196 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -1733,6 +1733,10 @@ begin if not assigned(Song) then Exit; + //fix: if main cat than there is nothing to play + if Song.main then + Exit; + if AudioPlayback.Open(Song.Path.Append(Song.Mp3)) then begin PreviewOpened := Interaction; -- cgit v1.2.3 From bbec4bdd80154e4a29cb56cd94fded55ac5d5efb Mon Sep 17 00:00:00 2001 From: brunzelchen Date: Sun, 13 Dec 2009 14:09:10 +0000 Subject: now the Audio-file bug should be fixed git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2031 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index e43e2196..a2760ae3 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -1547,8 +1547,8 @@ end; procedure TScreenSong.OnHide; begin - // if preview is not loaded: load musicfile now - if (PreviewOpened <> Interaction) then + // if preview is not loaded: load musicfile now; not on cat-main! + if (PreviewOpened <> Interaction) and not CatSongs.Song[Interaction].main then AudioPlayback.Open(CatSongs.Song[Interaction].Path.Append(CatSongs.Song[Interaction].Mp3)); // turn music volume to 100% -- cgit v1.2.3 From 29d0e397e5201df416ff5fa2cc8101276697fffb Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Thu, 17 Dec 2009 20:24:18 +0000 Subject: Just a test. Probably ignore this! git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2045 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index a2760ae3..305088e5 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -1548,11 +1548,12 @@ end; procedure TScreenSong.OnHide; begin // if preview is not loaded: load musicfile now; not on cat-main! - if (PreviewOpened <> Interaction) and not CatSongs.Song[Interaction].main then - AudioPlayback.Open(CatSongs.Song[Interaction].Path.Append(CatSongs.Song[Interaction].Mp3)); +// if (PreviewOpened <> Interaction) then // turn music volume to 100% AudioPlayback.SetVolume(1.0); + if (IPreviewVolumeVals[Ini.PreviewVolume] = 0) then + AudioPlayback.Open(CatSongs.Song[Interaction].Path.Append(CatSongs.Song[Interaction].Mp3)); // if hide then stop music (for party mode popup on exit) if (Display.NextScreen <> @ScreenSing) and -- cgit v1.2.3 From 988ccd68a2b6b89dd1a9e622ea15be2bcc2d6270 Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Thu, 17 Dec 2009 20:51:31 +0000 Subject: revert previous commit. It did not solve the problem of non song on fedora. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2046 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 305088e5..a2760ae3 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -1548,12 +1548,11 @@ end; procedure TScreenSong.OnHide; begin // if preview is not loaded: load musicfile now; not on cat-main! -// if (PreviewOpened <> Interaction) then + if (PreviewOpened <> Interaction) and not CatSongs.Song[Interaction].main then + AudioPlayback.Open(CatSongs.Song[Interaction].Path.Append(CatSongs.Song[Interaction].Mp3)); // turn music volume to 100% AudioPlayback.SetVolume(1.0); - if (IPreviewVolumeVals[Ini.PreviewVolume] = 0) then - AudioPlayback.Open(CatSongs.Song[Interaction].Path.Append(CatSongs.Song[Interaction].Mp3)); // if hide then stop music (for party mode popup on exit) if (Display.NextScreen <> @ScreenSing) and -- cgit v1.2.3 From 4711217f127aa0c10fa52755fd567c570277a1a1 Mon Sep 17 00:00:00 2001 From: s_alexander Date: Tue, 12 Jan 2010 17:42:41 +0000 Subject: merged lua into trunk git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2071 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 78 +++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 48 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index a2760ae3..5bc42a68 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -145,7 +145,7 @@ type //procedures for Menu procedure StartSong; procedure OpenEditor; - procedure DoJoker(Team: byte); + procedure DoJoker(Team: integer); procedure SelectPlayers; procedure UnloadDetailedCover; @@ -602,7 +602,7 @@ begin if (Ini.PartyPopup = 1) then ScreenSongMenu.MenuShow(SM_Party_Main) else - ScreenSong.StartSong; + Party.CallAfterSongSelect; end; end; end; @@ -717,35 +717,17 @@ begin SDLK_1: begin //Joker - if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= 1) and (PartySession.Teams.Teaminfo[0].Joker > 0) then - begin - //Use Joker - Dec(PartySession.Teams.Teaminfo[0].Joker); - SelectRandomSong; - SetJoker; - end; + DoJoker(0); end; SDLK_2: begin //Joker - if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= 2) and (PartySession.Teams.Teaminfo[1].Joker > 0) then - begin - //Use Joker - Dec(PartySession.Teams.Teaminfo[1].Joker); - SelectRandomSong; - SetJoker; - end; + DoJoker(1); end; SDLK_3: begin //Joker - if (Mode = smPartyMode) and (PartySession.Teams.NumTeams >= 3) and (PartySession.Teams.Teaminfo[2].Joker > 0) then - begin - //Use Joker - Dec(PartySession.Teams.Teaminfo[2].Joker); - SelectRandomSong; - SetJoker; - end; + DoJoker(2); end; end; end; // if (PressedDown) @@ -1555,8 +1537,8 @@ begin AudioPlayback.SetVolume(1.0); // if 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) }then begin StopMusicPreview(); end; @@ -1883,13 +1865,13 @@ begin // If Party Mode if Mode = smPartyMode then //Show Joker that are available begin - if (PartySession.Teams.NumTeams >= 1) then + if (Length(Party.Teams) >= 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); + Static[StaticTeam1Joker1].Visible := (Party.Teams[0].JokersLeft >= 1); + Static[StaticTeam1Joker2].Visible := (Party.Teams[0].JokersLeft >= 2); + Static[StaticTeam1Joker3].Visible := (Party.Teams[0].JokersLeft >= 3); + Static[StaticTeam1Joker4].Visible := (Party.Teams[0].JokersLeft >= 4); + Static[StaticTeam1Joker5].Visible := (Party.Teams[0].JokersLeft >= 5); end else begin @@ -1900,13 +1882,13 @@ begin Static[StaticTeam1Joker5].Visible := false; end; - if (PartySession.Teams.NumTeams >= 2) then + if (Length(Party.Teams) >= 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); + Static[StaticTeam2Joker1].Visible := (Party.Teams[1].JokersLeft >= 1); + Static[StaticTeam2Joker2].Visible := (Party.Teams[1].JokersLeft >= 2); + Static[StaticTeam2Joker3].Visible := (Party.Teams[1].JokersLeft >= 3); + Static[StaticTeam2Joker4].Visible := (Party.Teams[1].JokersLeft >= 4); + Static[StaticTeam2Joker5].Visible := (Party.Teams[1].JokersLeft >= 5); end else begin @@ -1917,13 +1899,13 @@ begin Static[StaticTeam2Joker5].Visible := false; end; - if (PartySession.Teams.NumTeams >= 3) then + if (Length(Party.Teams) >= 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); + Static[StaticTeam3Joker1].Visible := (Party.Teams[2].JokersLeft >= 1); + Static[StaticTeam3Joker2].Visible := (Party.Teams[2].JokersLeft >= 2); + Static[StaticTeam3Joker3].Visible := (Party.Teams[2].JokersLeft >= 3); + Static[StaticTeam3Joker4].Visible := (Party.Teams[2].JokersLeft >= 4); + Static[StaticTeam3Joker5].Visible := (Party.Teams[2].JokersLeft >= 5); end else begin @@ -1990,7 +1972,7 @@ begin //Party Mode if (Mode = smPartyMode) then begin - FadeTo(@ScreenSingModi); + FadeTo(@ScreenSing); end else begin @@ -2021,14 +2003,14 @@ begin end; //Team No of Team (0-5) -procedure TScreenSong.DoJoker (Team: byte); +procedure TScreenSong.DoJoker (Team: integer); begin if (Mode = smPartyMode) and - (PartySession.Teams.NumTeams >= Team + 1) and - (PartySession.Teams.Teaminfo[Team].Joker > 0) then + (High(Party.Teams) >= Team) and + (Party.Teams[Team].JokersLeft > 0) then begin //Use Joker - Dec(PartySession.Teams.Teaminfo[Team].Joker); + Dec(Party.Teams[Team].JokersLeft); SelectRandomSong; SetJoker; end; -- cgit v1.2.3 From f29685523465fb0d2d0d6bbe9985cf11207cde23 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Tue, 12 Jan 2010 19:55:25 +0000 Subject: deleted leftovers from old plugin system and party mode git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2080 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 1 - 1 file changed, 1 deletion(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 5bc42a68..f1fdba4d 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -160,7 +160,6 @@ uses Math, gl, UCovers, - UDLLManager, UGraphic, UMain, UMenuButton, -- cgit v1.2.3 From 58e4a47fb4c509af436c36e74b98d98ba66a2e9c Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Thu, 14 Jan 2010 21:36:38 +0000 Subject: comment unnessecary get_texture call that seems to lead to errors git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2091 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index f1fdba4d..7b52609a 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -227,7 +227,7 @@ procedure TScreenSong.ShowCatTL(Cat: integer); begin //Change Text[TextCat].Text := CatSongs.Song[Cat].Artist; - Static[StaticCat].Texture := Texture.GetTexture(Button[Cat].Texture.Name, TEXTURE_TYPE_PLAIN, true); + //Static[StaticCat].Texture := Texture.GetTexture(Button[Cat].Texture.Name, TEXTURE_TYPE_PLAIN, true); //Show Text[TextCat].Visible := true; -- cgit v1.2.3 From 54f567282784181b99a3012fd9db03dae60f361e Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Mon, 22 Feb 2010 18:27:15 +0000 Subject: screens code cleanup git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2146 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 7b52609a..8c4c1608 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -1012,8 +1012,6 @@ end; procedure TScreenSong.SetScroll1; var B: integer; // button - //BMin: integer; // button min // Auto Removed, Unused Variable - //BMax: integer; // button max // Auto Removed, Unused Variable Src: integer; //Dst: integer; Count: integer; // Dst is not used. Count is used. -- cgit v1.2.3 From a27eaddc1e751f71eb38565848c9fae3b847dd8c Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Mon, 22 Feb 2010 20:31:55 +0000 Subject: songflow don't stop now during song scrolling and seems to be more "flowy" hopefully the last hack to this old and dirty code, should be rewritten for 1.2 UScreenSongJumpTo may need some changes git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2147 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 108 +++++++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 47 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 8c4c1608..b127c296 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -60,6 +60,8 @@ type PreviewOpened: Integer; // interaction of the Song that is loaded for preview music // -1 if nothing is opened + isScrolling: boolean; // true if song flow is about to move + procedure StartMusicPreview(); procedure StopMusicPreview(); public @@ -148,6 +150,9 @@ type procedure DoJoker(Team: integer); procedure SelectPlayers; + procedure OnSongSelect; // called when song flows movement stops at a song + procedure OnSongDeSelect; // called before current song is deselected + procedure UnloadDetailedCover; //Extensions @@ -299,7 +304,6 @@ begin AudioPlayback.PlaySound(SoundLib.Change); - ChangeMusic; SetScroll4; //Break and Exit Exit; @@ -322,7 +326,6 @@ begin AudioPlayback.PlaySound(SoundLib.Change); - ChangeMusic; SetScroll4; //Break and Exit @@ -476,7 +479,6 @@ begin end; AudioPlayback.PlaySound(SoundLib.Change); - ChangeMusic; SetScroll4; end; Exit; @@ -536,8 +538,6 @@ begin //Show Wrong Song when Tabs on Fix SelectNext(true); FixSelected; - - ChangeMusic; end else begin @@ -576,9 +576,6 @@ begin //Show Wrong Song when Tabs on Fix SelectNext(true); FixSelected; - - //Play Music: - ChangeMusic; end else begin // clicked on song @@ -639,8 +636,6 @@ begin //Play Music: AudioPlayback.PlaySound(SoundLib.Change); - ChangeMusic; - end; // @@ -683,7 +678,6 @@ begin //Play Music: AudioPlayback.PlaySound(SoundLib.Change); - ChangeMusic; end; end; //Cat Change Hack End} @@ -696,9 +690,6 @@ begin begin AudioPlayback.PlaySound(SoundLib.Change); SelectNext(true); - //InteractNext; - //SongTarget := Interaction; - ChangeMusic; SetScroll4; end; end; @@ -709,7 +700,6 @@ begin begin AudioPlayback.PlaySound(SoundLib.Change); SelectPrev(true); - ChangeMusic; SetScroll4; end; end; @@ -889,6 +879,7 @@ begin Equalizer := Tms_Equalizer.Create(AudioPlayback, Theme.Song.Equalizer); PreviewOpened := -1; + isScrolling := false; end; procedure TScreenSong.GenerateThumbnails(); @@ -957,6 +948,28 @@ begin Interaction := 0; end; +{ called when song flows movement stops at a song } +procedure TScreenSong.OnSongSelect; +begin + if (Ini.PreviewVolume <> 0) then + begin + StartMusicPreview; + end; + + // fade in detailed cover + CoverTime := 0; +end; + +{ called before current song is deselected } +procedure TScreenSong.OnSongDeSelect; +begin + CoverTime := 10; + UnLoadDetailedCover; + + StopMusicPreview(); + PreviewOpened := -1; +end; + procedure TScreenSong.SetScroll; var VS, B: integer; @@ -1474,6 +1487,7 @@ begin SoundLib.PauseBgMusic; AudioPlayback.Stop; + PreviewOpened := -1; if Ini.Players <= 3 then PlayersPlay := Ini.Players + 1; if Ini.Players = 4 then PlayersPlay := 6; @@ -1489,12 +1503,6 @@ begin if Length(CatSongs.Song) > 0 then begin - //Load Music only when Song Preview is activated - if ( Ini.PreviewVolume <> 0 ) then - StartMusicPreview() - else - PreviewOpened := -1; - SetScroll; end; @@ -1505,7 +1513,6 @@ begin if (CatSongs.CatNumShow = -3) then begin SelectNext(true); - ChangeMusic; end; end //Party Mode @@ -1520,6 +1527,7 @@ begin end; end; + isScrolling := true; SetJoker; SetStatics; end; @@ -1560,13 +1568,23 @@ var dt: real; I: integer; begin - dx := SongTarget-SongCurrent; - dt := TimeSkip * 7; + if isScrolling then + begin + dx := SongTarget-SongCurrent; + dt := TimeSkip * 7; - if dt > 1 then - dt := 1; - - SongCurrent := SongCurrent + dx*dt; + if dt > 1 then + dt := 1; + + SongCurrent := SongCurrent + dx*dt; + + if SameValue(SongCurrent, SongTarget, 0.002) and (CatSongs.VisibleSongs > 0) then + begin + isScrolling := false; + SongCurrent := SongTarget; + OnSongSelect; + end; + end; { if SongCurrent > Catsongs.VisibleSongs then @@ -1643,8 +1661,11 @@ begin if VS > 0 then begin - if UnloadCover then //that should fix the performance problem on scrolling - UnLoadDetailedCover; + if (not isScrolling) and (VS > 1) then + begin + isScrolling := true; + OnSongDeselect; + end; Skip := 1; @@ -1677,10 +1698,13 @@ var begin VS := CatSongs.VisibleSongs; - if VS > 0 then + if VS > 1 then begin - if UnloadCover then - UnLoadDetailedCover; //that should fix the performance problem on scrolling + if (not isScrolling) and (VS > 1) then + begin + isScrolling := true; + OnSongDeselect; + end; Skip := 1; @@ -1708,6 +1732,9 @@ var begin AudioPlayback.Close(); + if CatSongs.VisibleSongs = 0 then + Exit; + Song := CatSongs.Song[Interaction]; if not assigned(Song) then Exit; @@ -1768,23 +1795,13 @@ procedure TScreenSong.ChangeMusic; begin StopMusicPreview(); PreviewOpened := -1; - - // Preview song if activated and current selection is not a category cover - if (CatSongs.VisibleSongs > 0) and - (not CatSongs.Song[Interaction].Main) and - (Ini.PreviewVolume <> 0) then - begin - // Delay song fading to prevent the song from being played while scrolling - MusicPreviewTimer := SDL_AddTimer(200, MusicPreviewTimerCallback, Self); - end; + StartMusicPreview(); end; procedure TScreenSong.SkipTo(Target: cardinal); var i: integer; begin - UnLoadDetailedCover; - Interaction := High(CatSongs.Song); SongTarget := 0; @@ -1853,7 +1870,6 @@ begin end; AudioPlayback.PlaySound(SoundLib.Change); - ChangeMusic; SetScroll; end; @@ -2016,8 +2032,6 @@ end; //Detailed Cover Unloading. Unloads the Detailed, uncached Cover of the cur. Song procedure TScreenSong.UnloadDetailedCover; begin - CoverTime := 0; - // show cached texture Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, TEXTURE_TYPE_PLAIN, true); Button[Interaction].Texture2.Alpha := 0; -- cgit v1.2.3 From f22fb5843becc1824bf2ea66bfd1b0626546c8a2 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Mon, 22 Feb 2010 20:37:08 +0000 Subject: remove unused code from prev version of ScreenSong git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2148 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index b127c296..7fda384c 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -1773,23 +1773,6 @@ begin AudioPlayback.Stop; end; -procedure StartMusicPreview(data: Pointer); -var - ScreenSong: TScreenSong; -begin - ScreenSong := TScreenSong(data); - if (ScreenSong <> nil) then - ScreenSong.StartMusicPreview(); -end; - -function MusicPreviewTimerCallback(interval: UInt32; param: Pointer): UInt32; cdecl; -begin - // delegate execution to main-thread - MainThreadExec(@StartMusicPreview, param); - // stop timer - Result := 0; -end; - // Changes previewed song procedure TScreenSong.ChangeMusic; begin -- cgit v1.2.3 From 578b9415aa600bdd5323784570edc0a96c605eb5 Mon Sep 17 00:00:00 2001 From: brunzelchen Date: Sun, 14 Mar 2010 20:56:20 +0000 Subject: fixed cover loading/showing when using tabs=on; deleted unused argument in SelectNext and SelectPrev git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2199 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 7fda384c..fa45697b 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -130,8 +130,8 @@ type procedure GenerateThumbnails(); procedure OnShow; override; procedure OnHide; override; - procedure SelectNext(UnloadCover: boolean); - procedure SelectPrev(UnloadCover: boolean); + procedure SelectNext; + procedure SelectPrev; procedure SkipTo(Target: cardinal); procedure FixSelected; //Show Wrong Song when Tabs on Fix procedure FixSelected2; //Show Wrong Song when Tabs on Fix @@ -436,7 +436,7 @@ begin CatSongs.ShowCategoryList; CatSongs.ClickCategoryButton(I); - SelectNext(true); + SelectNext; FixSelected; break; end; @@ -464,7 +464,7 @@ begin ShowCatTL (I); CatSongs.ClickCategoryButton(I); - SelectNext(true); + SelectNext; // Fix: not existing song selected: //if (I + 1 = I2) then @@ -517,7 +517,7 @@ begin HideCatTL; //Show Wrong Song when Tabs on Fix - SelectNext(true); + SelectNext; FixSelected; //SelectPrev(true); //CatSongs.Song[0].Visible := false; @@ -536,7 +536,7 @@ begin Interaction := 0; //Show Wrong Song when Tabs on Fix - SelectNext(true); + SelectNext; FixSelected; end else @@ -574,7 +574,7 @@ begin // SetScroll4; //Show Wrong Song when Tabs on Fix - SelectNext(true); + SelectNext; FixSelected; end else @@ -631,7 +631,7 @@ begin ShowCatTL (Interaction); CatSongs.ClickCategoryButton(Interaction); - SelectNext(true); + SelectNext; FixSelected; //Play Music: @@ -673,7 +673,7 @@ begin ShowCatTL (I); CatSongs.ClickCategoryButton(I); - SelectNext(true); + SelectNext; FixSelected; //Play Music: @@ -689,7 +689,7 @@ begin if (Songs.SongList.Count > 0) and (Mode = smNormal) then begin AudioPlayback.PlaySound(SoundLib.Change); - SelectNext(true); + SelectNext; SetScroll4; end; end; @@ -699,7 +699,7 @@ begin if (Songs.SongList.Count > 0)and (Mode = smNormal) then begin AudioPlayback.PlaySound(SoundLib.Change); - SelectPrev(true); + SelectPrev; SetScroll4; end; end; @@ -1512,7 +1512,7 @@ begin //If Playlist Shown -> Select Next automatically if (CatSongs.CatNumShow = -3) then begin - SelectNext(true); + SelectNext; end; end //Party Mode @@ -1652,7 +1652,7 @@ begin Result := true; end; -procedure TScreenSong.SelectNext(UnloadCover: boolean); +procedure TScreenSong.SelectNext; var Skip: integer; VS: integer; @@ -1665,7 +1665,8 @@ begin begin isScrolling := true; OnSongDeselect; - end; + end else if (VS=0) then // fix for tabs=on + UnLoadDetailedCover; Skip := 1; @@ -1691,7 +1692,7 @@ begin //Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, TEXTURE_TYPE_PLAIN, false); end; -procedure TScreenSong.SelectPrev(UnloadCover: boolean); +procedure TScreenSong.SelectPrev; var Skip: integer; VS: integer; @@ -1789,7 +1790,7 @@ begin SongTarget := 0; for i := 1 to Target+1 do - SelectNext(false); + SelectNext; FixSelected2; end; @@ -1823,7 +1824,7 @@ begin ShowCatTL(I); CatSongs.ClickCategoryButton(I); - SelectNext(true); + SelectNext; // choose song SkipTo(I2 - I); @@ -1838,7 +1839,7 @@ begin CatSongs.ClickCategoryButton(PlaylistMan.CurPlayList); ShowCatTL(PlaylistMan.CurPlayList); - SelectNext(true); + SelectNext; FixSelected2; SkipTo(Random(CatSongs.VisibleSongs)); -- cgit v1.2.3 From 91d892149bdc487725e96a63aad8c37fc1f5798a Mon Sep 17 00:00:00 2001 From: brunzelchen Date: Mon, 15 Mar 2010 19:18:19 +0000 Subject: fixed cover loading/showing when using tabs=on #2 git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2200 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index fa45697b..65f3c157 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -1661,12 +1661,11 @@ begin if VS > 0 then begin - if (not isScrolling) and (VS > 1) then + if (not isScrolling) and (VS > 0) then begin isScrolling := true; OnSongDeselect; - end else if (VS=0) then // fix for tabs=on - UnLoadDetailedCover; + end; Skip := 1; @@ -1701,7 +1700,7 @@ begin if VS > 1 then begin - if (not isScrolling) and (VS > 1) then + if (not isScrolling) and (VS > 0) then begin isScrolling := true; OnSongDeselect; -- cgit v1.2.3 From f761eb20ce8d3b5ef718be4a305b78712641248d Mon Sep 17 00:00:00 2001 From: tobigun Date: Sun, 18 Apr 2010 13:43:36 +0000 Subject: change variable names "static" to "statics" - "static" is a reserved name and should not be used - code-completion in lazarus does not work as it is not able to cope with variables that are named "static" git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2246 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 114 ++++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 57 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 65f3c157..a3c5f36a 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -224,7 +224,7 @@ procedure TScreenSong.ShowCatTLCustom(Caption: UTF8String);// Show Custom Text i begin Text[TextCat].Text := Caption; Text[TextCat].Visible := true; - Static[StaticCat].Visible := false; + Statics[StaticCat].Visible := false; end; //Show Cat in Top Left Mod @@ -232,18 +232,18 @@ procedure TScreenSong.ShowCatTL(Cat: integer); begin //Change Text[TextCat].Text := CatSongs.Song[Cat].Artist; - //Static[StaticCat].Texture := Texture.GetTexture(Button[Cat].Texture.Name, TEXTURE_TYPE_PLAIN, true); + //Statics[StaticCat].Texture := Texture.GetTexture(Button[Cat].Texture.Name, TEXTURE_TYPE_PLAIN, true); //Show Text[TextCat].Visible := true; - Static[StaticCat].Visible := true; + Statics[StaticCat].Visible := true; end; procedure TScreenSong.HideCatTL; begin //Hide //Text[TextCat].Visible := false; - Static[StaticCat].Visible := false; + Statics[StaticCat].Visible := false; //New -> Show Text specified in Theme Text[TextCat].Visible := true; Text[TextCat].Text := Theme.Song.TextCat.Text; @@ -991,7 +991,7 @@ begin end; // Set visibility of video icon - Static[VideoIcon].Visible := CatSongs.Song[Interaction].Video.IsSet; + Statics[VideoIcon].Visible := CatSongs.Song[Interaction].Video.IsSet; // Set texts Text[TextArtist].Text := CatSongs.Song[Interaction].Artist; @@ -1176,7 +1176,7 @@ begin end; if Length(Button) > 0 then - Static[1].Texture.Y := Button[Interaction].Y - 5; // selection texture + Statics[1].Texture.Y := Button[Interaction].Y - 5; // selection texture end; procedure TScreenSong.SetScroll2; @@ -1638,8 +1638,8 @@ begin Button[I].Draw; // Statics - for I := 0 to Length(Static) - 1 do - Static[I].Draw; + for I := 0 to Length(Statics) - 1 do + Statics[I].Draw; // and texts for I := 0 to Length(Text) - 1 do @@ -1863,74 +1863,74 @@ begin begin if (Length(Party.Teams) >= 1) then begin - Static[StaticTeam1Joker1].Visible := (Party.Teams[0].JokersLeft >= 1); - Static[StaticTeam1Joker2].Visible := (Party.Teams[0].JokersLeft >= 2); - Static[StaticTeam1Joker3].Visible := (Party.Teams[0].JokersLeft >= 3); - Static[StaticTeam1Joker4].Visible := (Party.Teams[0].JokersLeft >= 4); - Static[StaticTeam1Joker5].Visible := (Party.Teams[0].JokersLeft >= 5); + Statics[StaticTeam1Joker1].Visible := (Party.Teams[0].JokersLeft >= 1); + Statics[StaticTeam1Joker2].Visible := (Party.Teams[0].JokersLeft >= 2); + Statics[StaticTeam1Joker3].Visible := (Party.Teams[0].JokersLeft >= 3); + Statics[StaticTeam1Joker4].Visible := (Party.Teams[0].JokersLeft >= 4); + Statics[StaticTeam1Joker5].Visible := (Party.Teams[0].JokersLeft >= 5); end else begin - Static[StaticTeam1Joker1].Visible := false; - Static[StaticTeam1Joker2].Visible := false; - Static[StaticTeam1Joker3].Visible := false; - Static[StaticTeam1Joker4].Visible := false; - Static[StaticTeam1Joker5].Visible := false; + Statics[StaticTeam1Joker1].Visible := false; + Statics[StaticTeam1Joker2].Visible := false; + Statics[StaticTeam1Joker3].Visible := false; + Statics[StaticTeam1Joker4].Visible := false; + Statics[StaticTeam1Joker5].Visible := false; end; if (Length(Party.Teams) >= 2) then begin - Static[StaticTeam2Joker1].Visible := (Party.Teams[1].JokersLeft >= 1); - Static[StaticTeam2Joker2].Visible := (Party.Teams[1].JokersLeft >= 2); - Static[StaticTeam2Joker3].Visible := (Party.Teams[1].JokersLeft >= 3); - Static[StaticTeam2Joker4].Visible := (Party.Teams[1].JokersLeft >= 4); - Static[StaticTeam2Joker5].Visible := (Party.Teams[1].JokersLeft >= 5); + Statics[StaticTeam2Joker1].Visible := (Party.Teams[1].JokersLeft >= 1); + Statics[StaticTeam2Joker2].Visible := (Party.Teams[1].JokersLeft >= 2); + Statics[StaticTeam2Joker3].Visible := (Party.Teams[1].JokersLeft >= 3); + Statics[StaticTeam2Joker4].Visible := (Party.Teams[1].JokersLeft >= 4); + Statics[StaticTeam2Joker5].Visible := (Party.Teams[1].JokersLeft >= 5); end else begin - Static[StaticTeam2Joker1].Visible := false; - Static[StaticTeam2Joker2].Visible := false; - Static[StaticTeam2Joker3].Visible := false; - Static[StaticTeam2Joker4].Visible := false; - Static[StaticTeam2Joker5].Visible := false; + Statics[StaticTeam2Joker1].Visible := false; + Statics[StaticTeam2Joker2].Visible := false; + Statics[StaticTeam2Joker3].Visible := false; + Statics[StaticTeam2Joker4].Visible := false; + Statics[StaticTeam2Joker5].Visible := false; end; if (Length(Party.Teams) >= 3) then begin - Static[StaticTeam3Joker1].Visible := (Party.Teams[2].JokersLeft >= 1); - Static[StaticTeam3Joker2].Visible := (Party.Teams[2].JokersLeft >= 2); - Static[StaticTeam3Joker3].Visible := (Party.Teams[2].JokersLeft >= 3); - Static[StaticTeam3Joker4].Visible := (Party.Teams[2].JokersLeft >= 4); - Static[StaticTeam3Joker5].Visible := (Party.Teams[2].JokersLeft >= 5); + Statics[StaticTeam3Joker1].Visible := (Party.Teams[2].JokersLeft >= 1); + Statics[StaticTeam3Joker2].Visible := (Party.Teams[2].JokersLeft >= 2); + Statics[StaticTeam3Joker3].Visible := (Party.Teams[2].JokersLeft >= 3); + Statics[StaticTeam3Joker4].Visible := (Party.Teams[2].JokersLeft >= 4); + Statics[StaticTeam3Joker5].Visible := (Party.Teams[2].JokersLeft >= 5); end else begin - Static[StaticTeam3Joker1].Visible := false; - Static[StaticTeam3Joker2].Visible := false; - Static[StaticTeam3Joker3].Visible := false; - Static[StaticTeam3Joker4].Visible := false; - Static[StaticTeam3Joker5].Visible := false; + Statics[StaticTeam3Joker1].Visible := false; + Statics[StaticTeam3Joker2].Visible := false; + Statics[StaticTeam3Joker3].Visible := false; + Statics[StaticTeam3Joker4].Visible := false; + Statics[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; + Statics[StaticTeam1Joker1].Visible := false; + Statics[StaticTeam1Joker2].Visible := false; + Statics[StaticTeam1Joker3].Visible := false; + Statics[StaticTeam1Joker4].Visible := false; + Statics[StaticTeam1Joker5].Visible := false; + + Statics[StaticTeam2Joker1].Visible := false; + Statics[StaticTeam2Joker2].Visible := false; + Statics[StaticTeam2Joker3].Visible := false; + Statics[StaticTeam2Joker4].Visible := false; + Statics[StaticTeam2Joker5].Visible := false; + + Statics[StaticTeam3Joker1].Visible := false; + Statics[StaticTeam3Joker2].Visible := false; + Statics[StaticTeam3Joker3].Visible := false; + Statics[StaticTeam3Joker4].Visible := false; + Statics[StaticTeam3Joker5].Visible := false; end; end; @@ -1943,7 +1943,7 @@ begin Visible := (Mode = smPartyMode); for I := 0 to High(StaticParty) do - Static[StaticParty[I]].Visible := Visible; + Statics[StaticParty[I]].Visible := Visible; for I := 0 to High(TextParty) do Text[TextParty[I]].Visible := Visible; @@ -1952,7 +1952,7 @@ begin Visible := not Visible; for I := 0 to High(StaticNonParty) do - Static[StaticNonParty[I]].Visible := Visible; + Statics[StaticNonParty[I]].Visible := Visible; for I := 0 to High(TextNonParty) do Text[TextNonParty[I]].Visible := Visible; -- cgit v1.2.3 From deba59815a59cc6857c72872b7ae5d6d332bcb48 Mon Sep 17 00:00:00 2001 From: tobigun Date: Wed, 21 Apr 2010 19:17:12 +0000 Subject: major bug-fix: - TScreenSong.OnHide() interfered with TScreenSing.OnShow() method as the changes of AudioPlayback in TScreenSing.OnShow() were overwritten by TScreenSong.OnHide() which is called later. -> moved AudioPlayback initialization to OnShowFinish - The audio file was opened in TScreenSong, mainly that caused the interference. Now the audio file is opened in TScreenSing. This looks more cleaner too. - this patch fixes: - some race conditions - Dead Smiling Pirates song (and others) were not played from the beginning (especially on linux) cleanup: - removed unused MusicPreviewTimer git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2262 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index a3c5f36a..34589963 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -81,7 +81,6 @@ type HighSpeed: boolean; CoverFull: boolean; CoverTime: real; - MusicPreviewTimer: PSDL_TimerID; CoverX: integer; CoverY: integer; @@ -1534,19 +1533,11 @@ end; procedure TScreenSong.OnHide; begin - // if preview is not loaded: load musicfile now; not on cat-main! - if (PreviewOpened <> Interaction) and not CatSongs.Song[Interaction].main then - AudioPlayback.Open(CatSongs.Song[Interaction].Path.Append(CatSongs.Song[Interaction].Mp3)); - // turn music volume to 100% AudioPlayback.SetVolume(1.0); - // if hide then stop music (for party mode popup on exit) - if (Display.NextScreen <> @ScreenSing) {and - (Display.NextScreen <> @ScreenSingModi) }then - begin - StopMusicPreview(); - end; + // stop preview + StopMusicPreview(); end; procedure TScreenSong.DrawExtensions; @@ -1766,9 +1757,6 @@ end; procedure TScreenSong.StopMusicPreview(); begin - // Cancel pending preview requests - SDL_RemoveTimer(MusicPreviewTimer); - // Stop preview of previous song AudioPlayback.Stop; end; -- cgit v1.2.3 From 03abb1fddd189e796fde9d8a334a78ee99d9885f Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 28 Apr 2010 15:31:10 +0000 Subject: improved cover flow: only five front covers and 3 covers in the back that show up in the gap between the front cover and its neighbors are drawn. This looks more beauty than the old solution and it should fix the massive performance loss when many songs are in the shown category. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2314 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 34589963..a4fde5f6 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -1344,13 +1344,19 @@ begin Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); Button[B].Z := 0.95 - Abs(Pos) * 0.01; end - else + { only draw 3 visible covers in the background + (the 3 that are on the opposite of the front covers} + else if (Abs(Pos) > floor(VS/2) - 1.5) then begin - // Transform Pos to range [-1..-1/2, +1/2..+1] + // Transform Pos to range [-1..-3/4, +3/4..+1] + { the 3 covers at the back will show up in the gap between the + front cover and its neighbors + one cover will be hiddenbehind the front cover, + but this will not be a lack of performance ;) } if Pos < 0 then - Pos := Pos/VS - 0.5 + Pos := (Pos - 2 + ceil(VS/2))/8 - 0.75 else - Pos := Pos/VS + 0.5; + Pos := (Pos + 2 - floor(VS/2))/8 + 0.75; // angle in radians [-2Pi..-Pi, +Pi..+2Pi] Angle := 2*Pi * Pos; @@ -1366,7 +1372,10 @@ begin //Button[B].Reflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; - end; + end + { all other covers are not visible } + else + Button[B].Visible := false; end; end; end; -- cgit v1.2.3 From d250481c0c591dd935a08841debe41b7892ff040 Mon Sep 17 00:00:00 2001 From: brunzelchen Date: Sun, 2 May 2010 15:51:44 +0000 Subject: workaround for LCTRL+R in SongMenu: it should be changed when we have a solution for the CTRL+'A'..'Z' problem git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2331 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index a4fde5f6..a9aed0f1 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -338,6 +338,13 @@ begin Exit; end; + // ********************** + // * workaround for LCTRL+R: it should be changed when we have a solution for the + // * CTRL+'A'..'Z' problem + if (SDL_ModState = KMOD_LCTRL) and (PressedKey = SDLK_R) then + CharCode := UCS4Char('R'); + // ********************** + // check normal keys case UCS4UpperCase(CharCode) of Ord('Q'): -- cgit v1.2.3 From 71083e94848dc0516d164a36453617231c912e77 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Fri, 7 May 2010 15:50:51 +0000 Subject: fix coverflow "SetScroll5" for less than 8 songs remove workaround (use SetScroll4 instead of 5) for less than 5 songs git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2340 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index a9aed0f1..6b83d522 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -986,12 +986,7 @@ begin // Set Positions case Theme.Song.Cover.Style of 3: SetScroll3; - 5:begin - if VS > 5 then - SetScroll5 - else - SetScroll4; - end; + 5: SetScroll5; 6: SetScroll6; else SetScroll4; end; @@ -1336,7 +1331,7 @@ begin // Use an alternate position for the five front covers. if (Abs(Pos) < 2.5) then begin - Angle := Pi * (Pos / 5); // Range: (-1/4*Pi .. +1/4*Pi) + Angle := Pi * (Pos / Min(VS, 5)); // Range: (-1/4*Pi .. +1/4*Pi) Button[B].H := Abs(Theme.Song.Cover.H * cos(Angle*0.8)); Button[B].W := Button[B].H; @@ -1350,10 +1345,15 @@ begin Button[B].X := Theme.Song.Cover.X + Theme.Song.Cover.W * X - Padding; Button[B].Y := (Theme.Song.Cover.Y + (Theme.Song.Cover.H - Abs(Theme.Song.Cover.H * cos(Angle))) * 0.5); Button[B].Z := 0.95 - Abs(Pos) * 0.01; + + if VS < 5 then + Button[B].Texture.Alpha := 1 - Abs(Pos) / VS * 2 + else + Button[B].Texture.Alpha := 1; end { only draw 3 visible covers in the background (the 3 that are on the opposite of the front covers} - else if (Abs(Pos) > floor(VS/2) - 1.5) then + else if (VS > 7) and (Abs(Pos) > floor(VS/2) - 1.5) then begin // Transform Pos to range [-1..-3/4, +3/4..+1] { the 3 covers at the back will show up in the gap between the @@ -1377,6 +1377,8 @@ begin Button[B].Y := Theme.Song.Cover.Y - (Button[B].H - Theme.Song.Cover.H)*0.75; 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].Texture.Alpha := 1; + //Button[B].Reflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; Button[B].DeSelectReflectionspacing := 15 * Button[B].H/Theme.Song.Cover.H; end @@ -1705,7 +1707,7 @@ var begin VS := CatSongs.VisibleSongs; - if VS > 1 then + if VS > 0 then begin if (not isScrolling) and (VS > 0) then begin -- cgit v1.2.3 From f261cd24db299daee8a0d8e470ff7d173f1a1c75 Mon Sep 17 00:00:00 2001 From: brunzelchen Date: Thu, 10 Jun 2010 18:27:53 +0000 Subject: merge of VideoPreview branch into trunk git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2475 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 123 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 115 insertions(+), 8 deletions(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 6b83d522..764a0d47 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -62,8 +62,12 @@ type isScrolling: boolean; // true if song flow is about to move + fCurrentVideo: IVideo; + procedure StartMusicPreview(); procedure StopMusicPreview(); + procedure StartVideoPreview(); + procedure StopVideoPreview(); public TextArtist: integer; TextTitle: integer; @@ -128,6 +132,7 @@ type function Draw: boolean; override; procedure GenerateThumbnails(); procedure OnShow; override; + procedure OnShowFinish; override; procedure OnHide; override; procedure SelectNext; procedure SelectPrev; @@ -886,6 +891,8 @@ begin PreviewOpened := -1; isScrolling := false; + + fCurrentVideo := nil; end; procedure TScreenSong.GenerateThumbnails(); @@ -960,6 +967,7 @@ begin if (Ini.PreviewVolume <> 0) then begin StartMusicPreview; + StartVideoPreview; end; // fade in detailed cover @@ -973,6 +981,7 @@ begin UnLoadDetailedCover; StopMusicPreview(); + StopVideoPreview(); PreviewOpened := -1; end; @@ -1506,6 +1515,9 @@ begin AudioPlayback.Stop; PreviewOpened := -1; + // reset video playback engine + fCurrentVideo := nil; + if Ini.Players <= 3 then PlayersPlay := Ini.Players + 1; if Ini.Players = 4 then PlayersPlay := 6; @@ -1544,11 +1556,17 @@ begin end; end; - isScrolling := true; + isScrolling := false; SetJoker; SetStatics; end; +procedure TScreenSong.OnShowFinish; +begin + isScrolling := true; + CoverTime := 10; +end; + procedure TScreenSong.OnHide; begin // turn music volume to 100% @@ -1556,6 +1574,7 @@ begin // stop preview StopMusicPreview(); + StopVideoPreview(); end; procedure TScreenSong.DrawExtensions; @@ -1573,9 +1592,10 @@ end; function TScreenSong.Draw: boolean; var - dx: real; - dt: real; - I: integer; + dx: real; + dt: real; + I: integer; + VideoAlpha: real; begin if isScrolling then begin @@ -1611,7 +1631,7 @@ begin //Log.LogBenchmark('SetScroll4', 5); //Fading Functions, Only if Covertime is under 5 Seconds - if (CoverTime < 5) then + if (CoverTime < 9) then begin // cover fade if (CoverTime < 1) and (CoverTime + TimeSkip >= 1) then @@ -1641,10 +1661,43 @@ begin //Draw BG DrawBG; + VideoAlpha := Button[interaction].Texture.Alpha*(CoverTime-1); //Instead of Draw FG Procedure: //We draw Buttons for our own for I := 0 to Length(Button) - 1 do - Button[I].Draw; + begin + if (I<>Interaction) or not Assigned(fCurrentVideo) or (VideoAlpha<1) or AudioPlayback.Finished then + Button[I].Draw; + end; + + if AudioPlayback.Finished then + StopVideoPreview; + + if Assigned(fCurrentVideo) then + begin + // Just call this once + // when Screens = 2 + if (ScreenAct = 1) then + fCurrentVideo.GetFrame(CatSongs.Song[Interaction].VideoGAP + AudioPlayback.Position); + + fCurrentVideo.SetScreen(ScreenAct); + fCurrentVideo.Alpha := VideoAlpha; + + //set up window + with Button[interaction] do + begin + fCurrentVideo.SetScreenPosition(X, Y, Z); + fCurrentVideo.Width := W; + fCurrentVideo.Height := H; + fCurrentVideo.ReflectionSpacing := Reflectionspacing; + end; + fCurrentVideo.AspectCorrection := acoCrop; + + fCurrentVideo.Draw; + + if Button[interaction].Reflection then + fCurrentVideo.DrawReflection; + end; // Statics for I := 0 to Length(Statics) - 1 do @@ -1743,7 +1796,7 @@ begin if CatSongs.VisibleSongs = 0 then Exit; - + Song := CatSongs.Song[Interaction]; if not assigned(Song) then Exit; @@ -1755,7 +1808,7 @@ begin if AudioPlayback.Open(Song.Path.Append(Song.Mp3)) then begin PreviewOpened := Interaction; - + AudioPlayback.Position := AudioPlayback.Length / 4; // set preview volume if (Ini.PreviewFading = 0) then @@ -1779,12 +1832,66 @@ begin AudioPlayback.Stop; end; +procedure TScreenSong.StartVideoPreview(); +var + VideoFile: IPath; + Song: TSong; + +begin + if (Ini.VideoPreview=0) then + Exit; + + if Assigned(fCurrentVideo) then + begin + fCurrentVideo.Stop(); + fCurrentVideo := nil; + end; + + //if no audio open => exit + if (PreviewOpened = -1) then + Exit; + + if CatSongs.VisibleSongs = 0 then + Exit; + + Song := CatSongs.Song[Interaction]; + if not assigned(Song) then + Exit; + + //fix: if main cat than there is nothing to play + if Song.main then + Exit; + + VideoFile := Song.Path.Append(Song.Video); + if (Song.Video.IsSet) and VideoFile.IsFile then + begin + fCurrentVideo := VideoPlayback.Open(VideoFile); + if (fCurrentVideo <> nil) then + begin + fCurrentVideo.Position := Song.VideoGAP + AudioPlayback.Position; + fCurrentVideo.Play; + end; + end; +end; + +procedure TScreenSong.StopVideoPreview(); +begin + // Stop video preview of previous song + if Assigned(fCurrentVideo) then + begin + fCurrentVideo.Stop(); + fCurrentVideo := nil; + end; +end; + // Changes previewed song procedure TScreenSong.ChangeMusic; begin StopMusicPreview(); + StopVideoPreview(); PreviewOpened := -1; StartMusicPreview(); + StartVideoPreview(); end; procedure TScreenSong.SkipTo(Target: cardinal); -- cgit v1.2.3 From fd0388550ddbe2b817a427b6ee08be9157fff287 Mon Sep 17 00:00:00 2001 From: tobigun Date: Sun, 13 Jun 2010 09:42:50 +0000 Subject: Fix for invalid song lengths git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2511 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/screens/UScreenSong.pas') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 764a0d47..6fe8d204 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -1791,6 +1791,7 @@ end; procedure TScreenSong.StartMusicPreview(); var Song: TSong; + PreviewPos: real; begin AudioPlayback.Close(); @@ -1809,7 +1810,12 @@ begin begin PreviewOpened := Interaction; - AudioPlayback.Position := AudioPlayback.Length / 4; + PreviewPos := AudioPlayback.Length / 4; + // fix for invalid music file lengths + if (PreviewPos > 60.0) then + PreviewPos := 60.0; + AudioPlayback.Position := PreviewPos; + // set preview volume if (Ini.PreviewFading = 0) then begin -- cgit v1.2.3