From 7f0f49979ee27f76d8dff3786194df1f43d4300f Mon Sep 17 00:00:00 2001 From: brunzelchen Date: Tue, 28 Dec 2010 06:46:38 +0000 Subject: don't close menu when adding songs git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/1.0.1 Challenge MOD@2776 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UPlaylist.pas | 26 ++++++++++++++++++++++++++ Game/Code/Screens/UScreenSong.pas | 10 +++++++--- Game/Code/Screens/UScreenSongMenu.pas | 26 ++++++++++++++++++++++---- 3 files changed, 55 insertions(+), 7 deletions(-) diff --git a/Game/Code/Classes/UPlaylist.pas b/Game/Code/Classes/UPlaylist.pas index 36bbf051..7fa621ae 100644 --- a/Game/Code/Classes/UPlaylist.pas +++ b/Game/Code/Classes/UPlaylist.pas @@ -43,6 +43,8 @@ type Function AddPlaylist(Name: String): Cardinal; Procedure DelPlaylist(const Index: Cardinal); + Function SongExists(const SongID: Cardinal; const iPlaylist: Integer): boolean; + Procedure AddItem(const SongID: Cardinal; const iPlaylist: Integer = -1); Procedure DelItem(const iItem: Cardinal; const iPlaylist: Integer = -1); @@ -342,6 +344,30 @@ begin end; end; +Function TPlayListManager.SongExists(const SongID: Cardinal; const iPlaylist: Integer): boolean; +var + P: Cardinal; + I: Cardinal; +begin + Result := false; + + if iPlaylist = -1 then + P := CurPlaylist + else if (iPlaylist >= 0) AND (iPlaylist <= high(Playlists)) then + P := iPlaylist + else + exit; + + if (SongID <= High(CatSongs.Song)) AND (NOT CatSongs.Song[SongID].Main) then + begin + for I := 0 to High(Playlists[P].Items) do + begin + if (Playlists[P].Items[I].SongID = SongID) then + Result := true; + end; + end; +end; + //---------- //AddItem - Adds an Item to a specific Playlist //---------- diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 157eed41..aa3c2bf9 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -985,7 +985,6 @@ begin Music.PlayChange; SelectNext; ChangeMusic; - SetScroll4; end; end; @@ -1001,7 +1000,6 @@ begin Music.PlayChange; SelectPrev; ChangeMusic; - SetScroll4; end; end; @@ -2580,6 +2578,13 @@ begin Static[StaticTop].Visible := false; end; + if ScreenSongMenu.Visible or ScreenSongJumpto.Visible then + begin + WaitHandler.change_time := 0; + WaitHandler.changed := false; + end else if (Mode = smNormal) then + WaitHandler.changed := true; + if (Mode = smNormal) and (Ini.ShuffleTime>0) and not MakeMedley and not CatSongs.Song[Interaction].Main and (Length(CatSongs.Song)-CatSongs.CatCount>1) then @@ -2660,7 +2665,6 @@ begin //Music.PlayChange; ChangeMusic; - SetScroll4; end else if (Ini.ShuffleTime>0) then WaitHandler.change_time := WaitHandler.change_time + TimeSkip; end; diff --git a/Game/Code/Screens/UScreenSongMenu.pas b/Game/Code/Screens/UScreenSongMenu.pas index dbdea42e..b3a77879 100644 --- a/Game/Code/Screens/UScreenSongMenu.pas +++ b/Game/Code/Screens/UScreenSongMenu.pas @@ -166,6 +166,8 @@ begin SDLK_RETURN: begin HandleReturn; + if (CurMenu = SM_Playlist_Add) then + MenuShow(CurMenu); end; SDLK_DOWN: InteractNext; @@ -186,8 +188,16 @@ begin Music.PlayChange; ScreenSong.SelectNext; ScreenSong.ChangeMusic; - ScreenSong.SetScroll4; end; + + if (CurMenu = SM_Playlist_Add) and (Interaction <> 3) then + begin + Music.PlayChange; + ScreenSong.SelectNext; + ScreenSong.ChangeMusic; + MenuShow(CurMenu); + end else if (CurMenu = SM_Playlist_Add) then + MenuShow(CurMenu); end; SDLK_LEFT: begin @@ -204,8 +214,16 @@ begin Music.PlayChange; ScreenSong.SelectPrev; ScreenSong.ChangeMusic; - ScreenSong.SetScroll4; end; + + if (CurMenu = SM_Playlist_Add) and (Interaction <> 3) then + begin + Music.PlayChange; + ScreenSong.SelectPrev; + ScreenSong.ChangeMusic; + MenuShow(CurMenu); + end else if (CurMenu = SM_Playlist_Add) then + MenuShow(CurMenu); end; SDLK_1: @@ -403,7 +421,7 @@ begin Button[0].Visible := True; Button[1].Visible := False; Button[2].Visible := False; - Button[3].Visible := True; + Button[3].Visible := not PlaylistMan.SongExists(ScreenSong.Interaction, SelectValue); SelectsS[0].Visible := True; Button[0].Text[0].Text := Language.Translate('SONG_MENU_PLAYLIST_ADD_NEW'); @@ -773,7 +791,7 @@ begin PlaylistMan.AddItem(ScreenSong.Interaction, SelectValue); ScreenSong.WaitHandler.changed := true; ScreenSong.WaitHandler.change_time := 0; - Visible := False; + //Visible := False; end; end; end; -- cgit v1.2.3