aboutsummaryrefslogtreecommitdiffstats
path: root/Game
diff options
context:
space:
mode:
authorwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2007-06-03 19:00:14 +0000
committerwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2007-06-03 19:00:14 +0000
commit514ece97aaeb8eaa8bf56e224826bc5e6169ce8b (patch)
treeb1c51a4b5d64938163b443da633d38d716a20eac /Game
parent842794d7b93443626089c00083118b532105c5ac (diff)
downloadusdx-514ece97aaeb8eaa8bf56e224826bc5e6169ce8b.tar.gz
usdx-514ece97aaeb8eaa8bf56e224826bc5e6169ce8b.tar.xz
usdx-514ece97aaeb8eaa8bf56e224826bc5e6169ce8b.zip
Some Code Cleanup in UScreenSong
Add Procedure DeletePlaylist to TPlaylistManager Add automatic Playlist Deleting if last Song is deleted Fixed some Cover displaying Bugs when JumptoMenu is left git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@242 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game')
-rw-r--r--Game/Code/Classes/UPlaylist.pas84
-rw-r--r--Game/Code/Screens/UScreenSong.pas37
-rw-r--r--Game/Code/Screens/UScreenSongJumpto.pas1
-rw-r--r--Game/Code/Screens/UScreenSongMenu.pas2
4 files changed, 87 insertions, 37 deletions
diff --git a/Game/Code/Classes/UPlaylist.pas b/Game/Code/Classes/UPlaylist.pas
index 67460ed7..55cf90ff 100644
--- a/Game/Code/Classes/UPlaylist.pas
+++ b/Game/Code/Classes/UPlaylist.pas
@@ -40,6 +40,7 @@ type
Procedure SetPlayList(Index: Cardinal);
Function AddPlaylist(Name: String): Cardinal;
+ Procedure DelPlaylist(const Index: Cardinal);
Procedure AddItem(const SongID: Cardinal; const iPlaylist: Integer = -1);
Procedure DelItem(const iItem: Cardinal; const iPlaylist: Integer = -1);
@@ -197,27 +198,29 @@ begin
//open File for Rewriting
AssignFile(F, PlaylistPath + Playlists[Index].Filename);
try
- Rewrite(F);
+ try
+ Rewrite(F);
- //Write Version (not nessecary but helpful)
- WriteLn(F, '######################################');
- WriteLn(F, '#Ultrastar Deluxe Playlist Format v1.0');
- WriteLn(F, '#Playlist "' + Playlists[Index].Name + '" with ' + InttoStr(Length(Playlists[Index].Items)) + ' Songs.');
- WriteLn(F, '######################################');
+ //Write Version (not nessecary but helpful)
+ WriteLn(F, '######################################');
+ WriteLn(F, '#Ultrastar Deluxe Playlist Format v1.0');
+ WriteLn(F, '#Playlist "' + Playlists[Index].Name + '" with ' + InttoStr(Length(Playlists[Index].Items)) + ' Songs.');
+ WriteLn(F, '######################################');
- //Write Name Information
- WriteLn(F, '#Name: ' + Playlists[Index].Name);
+ //Write Name Information
+ WriteLn(F, '#Name: ' + Playlists[Index].Name);
- //Write Song Information
- WriteLn(F, '#Songs:');
+ //Write Song Information
+ WriteLn(F, '#Songs:');
- For I := 0 to high(Playlists[Index].Items) do
- begin
- WriteLn(F, Playlists[Index].Items[I].Artist + ' : ' + Playlists[Index].Items[I].Title);
+ For I := 0 to high(Playlists[Index].Items) do
+ begin
+ WriteLn(F, Playlists[Index].Items[I].Artist + ' : ' + Playlists[Index].Items[I].Title);
+ end;
+ except
+ log.LogError('Could not write Playlistfile "' + Playlists[Index].Name + '"');
end;
-
finally
- log.LogError('Could not write Playlistfile "' + Playlists[Index].Name + '"');
CloseFile(F);
end;
end;
@@ -247,6 +250,9 @@ begin
CatSongs.CatNumShow := -3;
Mode := 2;
+ //Set CurPlaylist
+ CurPlaylist := Index;
+
//Show Cat in Topleft:
ScreenSong.ShowCatTLCustom(Format(Theme.Playlist.CatText,[Playlists[Index].Name]));
@@ -287,6 +293,47 @@ begin
end;
//----------
+//DelPlaylist - Deletes a Playlist
+//----------
+Procedure TPlayListManager.DelPlaylist(const Index: Cardinal);
+var
+ I: Integer;
+ Filename: String;
+begin
+ If Index > High(Playlists) then
+ Exit;
+
+ Filename := PlaylistPath + Playlists[Index].Filename;
+
+ //If not FileExists or File is not Writeable then exit
+ If (Not FileExists(Filename)) OR (FileisReadOnly(Filename)) then
+ Exit;
+
+
+ //Delete Playlist from FileSystem
+ if Not DeleteFile(Filename) then
+ Exit;
+
+ //Delete Playlist from Array
+ //move all PLs to the Hole
+ For I := Index to High(Playlists)-1 do
+ PlayLists[I] := PlayLists[I+1];
+
+ //Delete last Playlist
+ SetLength (Playlists, High(Playlists));
+
+ //If Playlist is Displayed atm
+ //-> Display Songs
+ if (CatSongs.CatNumShow = -3) and (Index = CurPlaylist) then
+ begin
+ ScreenSong.UnLoadDetailedCover;
+ CatSongs.SetFilter('', 0);
+ ScreenSong.Interaction := 0;
+ ScreenSong.FixSelected;
+ end;
+end;
+
+//----------
//AddItem - Adds an Item to a specific Playlist
//----------
Procedure TPlayListManager.AddItem(const SongID: Cardinal; const iPlaylist: Integer);
@@ -347,8 +394,13 @@ begin
SavePlayList(P);
end;
+ //Delete Playlist if Last Song is deleted
+ if (Length(PlayLists[P].Items) = 0) then
+ begin
+ DelPlaylist(P);
+ end
//Correct Display when Editing current Playlist
- if (CatSongs.CatNumShow = -3) and (P = CurPlaylist) then
+ else if (CatSongs.CatNumShow = -3) and (P = CurPlaylist) then
SetPlaylist(P);
end;
diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas
index 45c7c2de..3924968f 100644
--- a/Game/Code/Screens/UScreenSong.pas
+++ b/Game/Code/Screens/UScreenSong.pas
@@ -95,6 +95,8 @@ type
procedure DoJoker(Team: Byte);
procedure SelectPlayers;
+ procedure UnLoadDetailedCover;
+
//Extensions
procedure DrawExtensions;
end;
@@ -1379,13 +1381,7 @@ begin
if VS > 0 then
begin
- CoverTime := 0;
- Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', true); // 0.5.0: show cached texture
- Button[Interaction].Texture2.Alpha := 0;
-
- //0.5.0: unload old full size texture
- if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then
- Texture.UnloadTexture(Button[Interaction].Texture.Name, false);
+ UnLoadDetailedCover;
Skip := 1;
@@ -1417,13 +1413,7 @@ begin
if VS > 0 then
begin
- CoverTime := 0;
- Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', true); // 0.5.0: show cached texture
- Button[Interaction].Texture2.Alpha := 0;
-
- //0.5.0: unload old full size texture
- if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then
- Texture.UnloadTexture(Button[Interaction].Texture.Name, false);
+ UnLoadDetailedCover;
Skip := 1;
@@ -1470,12 +1460,7 @@ var
Skip: integer;
I: integer;
begin
- CoverTime := 0;
- Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', true); // 0.5.0: show cached texture
- Button[Interaction].Texture2.Alpha := 0;
-
- if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then
- Texture.UnloadTexture(Button[Interaction].Texture.Name, false);
+ UnLoadDetailedCover;
Interaction := High(CatSongs.Song);
SongTarget := 0;
@@ -1809,6 +1794,18 @@ begin
end;
end;
+//Detailed Cover Unloading. Unloads the Detailed, uncached Cover of the cur. Song
+procedure TScreenSong.UnLoadDetailedCover;
+begin
+ CoverTime := 0;
+
+ Button[Interaction].Texture := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', true); // 0.5.0: show cached texture
+ Button[Interaction].Texture2.Alpha := 0;
+
+ if Button[Interaction].Texture.Name <> Skin.GetTextureFileName('SongCover') then
+ Texture.UnloadTexture(Button[Interaction].Texture.Name, false);
+end;
+
procedure TScreenSong.Refresh;
begin {
CatSongs.Refresh;
diff --git a/Game/Code/Screens/UScreenSongJumpto.pas b/Game/Code/Screens/UScreenSongJumpto.pas
index 2ea94cdc..560868a5 100644
--- a/Game/Code/Screens/UScreenSongJumpto.pas
+++ b/Game/Code/Screens/UScreenSongJumpto.pas
@@ -97,6 +97,7 @@ begin
Music.PlayBack;
if (VisSongs = 0) AND (Length(Button[0].Text[0].Text) > 0) then
begin
+ ScreenSong.UnLoadDetailedCover;
Button[0].Text[0].Text := '';
CatSongs.SetFilter('', 0);
SetTextFound(0);
diff --git a/Game/Code/Screens/UScreenSongMenu.pas b/Game/Code/Screens/UScreenSongMenu.pas
index 2469240f..3814334c 100644
--- a/Game/Code/Screens/UScreenSongMenu.pas
+++ b/Game/Code/Screens/UScreenSongMenu.pas
@@ -414,7 +414,7 @@ begin
1: //Button 2
begin
//Select New Players then Sing:
-
+ ScreenSong.SelectPlayers;
Visible := False;
end;