aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/Classes/UPlaylist.pas
diff options
context:
space:
mode:
authors_alexander <s_alexander@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-03-06 21:38:02 +0000
committers_alexander <s_alexander@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-03-06 21:38:02 +0000
commita4a4e6f4f5e56345adf07d26bad98181094bd56d (patch)
treebe421b4bf57648cc2e60ddb9d530d806de2a4377 /Game/Code/Classes/UPlaylist.pas
parent30e17a410222b363fd49af7bf500987a18b621cc (diff)
downloadusdx-a4a4e6f4f5e56345adf07d26bad98181094bd56d.tar.gz
usdx-a4a4e6f4f5e56345adf07d26bad98181094bd56d.tar.xz
usdx-a4a4e6f4f5e56345adf07d26bad98181094bd56d.zip
playlists are sorted alphabeticaly
removed warnings git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@925 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game/Code/Classes/UPlaylist.pas')
-rw-r--r--Game/Code/Classes/UPlaylist.pas39
1 files changed, 29 insertions, 10 deletions
diff --git a/Game/Code/Classes/UPlaylist.pas b/Game/Code/Classes/UPlaylist.pas
index 2c09c493..4f181d73 100644
--- a/Game/Code/Classes/UPlaylist.pas
+++ b/Game/Code/Classes/UPlaylist.pas
@@ -93,6 +93,7 @@ Procedure TPlayListManager.LoadPlayLists;
var
SR: TSearchRec;
Len: Integer;
+ PlayListBuffer: TPlayList;
begin
SetLength(Playlists, 0);
@@ -103,11 +104,23 @@ begin
SetLength(Playlists, Len +1);
if not LoadPlayList (Len, Sr.Name) then
- SetLength(Playlists, Len);
+ SetLength(Playlists, Len)
+ else
+ begin
+ // Sort the Playlists - Insertion Sort
+ PlayListBuffer := Playlists[Len];
+ Dec(Len);
+ while (Len >= 0) AND (CompareText(Playlists[Len].Name, PlayListBuffer.Name) >= 0) do
+ begin
+ Playlists[Len+1] := Playlists[Len];
+ Dec(Len);
+ end;
+ Playlists[Len+1] := PlayListBuffer;
+ end;
until FindNext(SR) <> 0;
FindClose(SR);
- end;
+ end;
end;
//----------
@@ -250,7 +263,7 @@ Procedure TPlayListManager.SetPlayList(Index: Cardinal);
var
I: Integer;
begin
- If (Index > High(PlayLists)) then
+ If (Int(Index) > High(PlayLists)) then
exit;
//Hide all Songs
@@ -286,15 +299,21 @@ end;
//AddPlaylist - Adds a Playlist and Returns the Index
//----------
Function TPlayListManager.AddPlaylist(Name: String): Cardinal;
-var I: Integer;
+var
+ I: Integer;
begin
Result := Length(Playlists);
SetLength(Playlists, Result + 1);
-
+
+ // Sort the Playlists - Insertion Sort
+ while (Result > 0) AND (CompareText(Playlists[Result - 1].Name, Name) >= 0) do
+ begin
+ Dec(Result);
+ Playlists[Result+1] := Playlists[Result];
+ end;
Playlists[Result].Name := Name;
I := 1;
-
if (not FileExists(PlaylistPath + Name + '.upl')) then
Playlists[Result].Filename := Name + '.upl'
else
@@ -317,7 +336,7 @@ var
I: Integer;
Filename: String;
begin
- If Index > High(Playlists) then
+ If Int(Index) > High(Playlists) then
Exit;
Filename := PlaylistPath + Playlists[Index].Filename;
@@ -367,7 +386,7 @@ begin
else
exit;
- if (SongID <= High(CatSongs.Song)) AND (NOT CatSongs.Song[SongID].Main) then
+ if (Int(SongID) <= High(CatSongs.Song)) AND (NOT CatSongs.Song[SongID].Main) then
begin
Len := Length(Playlists[P].Items);
SetLength(Playlists[P].Items, Len + 1);
@@ -400,7 +419,7 @@ begin
else
exit;
- if (iItem <= high(Playlists[P].Items)) then
+ if (Int(iItem) <= high(Playlists[P].Items)) then
begin
//Move all entrys behind deleted one to Front
For I := iItem to High(Playlists[P].Items) - 1 do
@@ -459,7 +478,7 @@ begin
For I := 0 to high(Playlists[P].Items) do
begin
- if (Playlists[P].Items[I].SongID = SongID) then
+ if (Playlists[P].Items[I].SongID = Int(SongID)) then
begin
Result := I;
Break;