aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/Classes/USongs.pas
diff options
context:
space:
mode:
authoreddie-0815 <eddie-0815@b956fd51-792f-4845-bead-9b4dfca2ff2c>2007-11-01 19:34:40 +0000
committereddie-0815 <eddie-0815@b956fd51-792f-4845-bead-9b4dfca2ff2c>2007-11-01 19:34:40 +0000
commit391d30716d48dc709f6444b19c008e82311623b9 (patch)
treee922181e99262c06e6d48a6df5cda71a2338e0bd /Game/Code/Classes/USongs.pas
parent39c1fdef33f512a36334e689e38b90cfe4aceb82 (diff)
downloadusdx-391d30716d48dc709f6444b19c008e82311623b9.tar.gz
usdx-391d30716d48dc709f6444b19c008e82311623b9.tar.xz
usdx-391d30716d48dc709f6444b19c008e82311623b9.zip
Mac OS X version compiles and links. I hope I didn't break too many files on windows/linux.
Added switches.inc to all files. Changed many IFDEFs. For Windows-only code please use MSWINDOWS instead of WIN32 now. WIN32 is also used by the Mac port. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@546 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game/Code/Classes/USongs.pas')
-rw-r--r--Game/Code/Classes/USongs.pas88
1 files changed, 78 insertions, 10 deletions
diff --git a/Game/Code/Classes/USongs.pas b/Game/Code/Classes/USongs.pas
index 5ce35201..9e0d6ca5 100644
--- a/Game/Code/Classes/USongs.pas
+++ b/Game/Code/Classes/USongs.pas
@@ -2,14 +2,15 @@ unit USongs;
interface
-{$IFDEF FPC}
- {$MODE DELPHI}
-{$ENDIF}
-
+{$I switches.inc}
uses SysUtils,
- {$ifndef win32}
- oldlinux,
+ {$ifndef MSWINDOWS}
+ {$IFDEF DARWIN}
+ baseunix,
+ {$ELSE}
+ oldlinux,
+ {$ENDIF}
{$endif}
ULog,
UTexture,
@@ -115,6 +116,12 @@ uses StrUtils,
UMain,
UIni;
+{$IFDEF DARWIN}
+function AnsiContainsText(const AText, ASubText: string): Boolean;
+begin
+ Result := AnsiPos(AnsiUppercase(ASubText), AnsiUppercase(AText)) > 0;
+end;
+{$ENDIF}
procedure TSongs.LoadSongList;
begin
@@ -136,7 +143,7 @@ procedure TSongs.BrowseDir(Dir: widestring);
var
SLen: integer;
- {$ifdef win32}
+ {$ifdef MSWINDOWS}
SR: TSearchRecW; // for parsing Songs Directory
{$else} // This should work on all posix systems.
TheDir : pdir;
@@ -145,7 +152,7 @@ var
info : stat;
{$endif}
begin
- {$ifdef win32}
+ {$ifdef MSWINDOWS}
if FindFirstW(Dir + '*', faDirectory, SR) = 0 then // JB_Unicode - windows
begin
repeat
@@ -186,8 +193,9 @@ begin
until FindNextW(SR) <> 0;
end; // if FindFirst
FindCloseW(SR);
-
- {$else}
+ {$ENDIF}
+
+ {$IFDEF LINUX}
// Itterate the Songs Directory... ( With unicode capable functions for linux )
TheDir := opendir( Dir ); // JB_Unicode - linux
if TheDir <> nil then
@@ -245,6 +253,66 @@ begin
Until ADirent=Nil;
end; // if FindFirst
+ {$endif}
+
+ {$IFDEF DARWIN}
+ // Itterate the Songs Directory... ( With unicode capable functions for linux )
+ TheDir := FPOpenDir( Dir ); // JB_Unicode - linux
+ if TheDir <> nil then
+ begin
+ repeat
+ ADirent := FPReadDir(TheDir);
+
+ If ADirent<>Nil then
+ begin
+ With ADirent^ do
+ begin
+
+ if ( d_name[0] <> '.') then
+ BrowseDir( Dir + d_name + pathdelim );
+
+ end;
+ end;
+ Until ADirent=Nil;
+ end;
+
+
+
+ TheDir := FPOpenDir( Dir ); // JB_Unicode - linux
+ if TheDir <> nil then
+ begin
+ repeat
+ ADirent := FPReadDir(TheDir);
+
+ if ( ADirent <> Nil ) AND
+ ( pos( '.txt', ADirent^.d_name ) > -1 ) then
+ begin
+ SLen := BrowsePos;
+
+ Song[SLen].Path := Dir;
+ Song[SLen].Folder := Copy(Dir, Length(SongPath)+1, 10000);
+ Song[SLen].Folder := Copy(Song[SLen].Folder, 1, Pos( PathDelim , Song[SLen].Folder)-1);
+ Song[SLen].FileName := ADirent^.d_name;
+
+ if (AnalyseFile(Song[SLen]) = false) then
+ Dec(BrowsePos)
+ else
+ begin
+ if Song[SLen].Cover = '' then
+ Song[SLen].Cover := FindSongFile(Dir, '*[CO].jpg');
+ end;
+
+ //Change Length Only every 50 Entrys
+ Inc(BrowsePos);
+
+ if (BrowsePos mod 50 = 0) AND (BrowsePos <> 0) then
+ begin
+ SetLength(Song, Length(Song) + 50);
+ end;
+ end;
+
+ Until ADirent=Nil;
+ end; // if FindFirst
{$endif}