From fb4154e323aeb2cb3c601a418bd5362253b62134 Mon Sep 17 00:00:00 2001 From: eddie-0815 Date: Sun, 20 Jan 2008 18:15:00 +0000 Subject: Fixed song loading on OS X (UTF8 filenames). Added switches.inc. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@800 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/USong.pas | 107 +++++++++++++++++++++++++++----------------- 1 file changed, 66 insertions(+), 41 deletions(-) (limited to 'Game/Code') diff --git a/Game/Code/Classes/USong.pas b/Game/Code/Classes/USong.pas index 728f5055..e5777c75 100644 --- a/Game/Code/Classes/USong.pas +++ b/Game/Code/Classes/USong.pas @@ -1,9 +1,15 @@ -unit USong; - -interface - -uses - {$IFDEF MSWINDOWS} +unit USong; + +interface + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + +{$I switches.inc} + +uses + {$IFDEF MSWINDOWS} Windows, {$ifdef Delphi} DirWatch, @@ -29,8 +35,8 @@ uses PseudoThread, {$ENDIF} UCatCovers; - -type + +type TSingMode = ( smNormal, smPartyMode, smPlaylistRandom ); @@ -109,33 +115,43 @@ type function Analyse(): boolean; procedure clear(); end; - -implementation - -uses - TextGL, - UIni, - UMusic, // needed for Czesci .. ( whatever that is ) - UMain; //needed for Player - -constructor TSong.create( const aFileName : WideString ); + +implementation + +uses + TextGL, + UIni, + UMusic, // needed for Czesci .. ( whatever that is ) + UMain; //needed for Player + +constructor TSong.create( const aFileName : WideString ); begin - Mult := 1; - MultBPM := 4; - - fFileName := aFileName; - - if fileexists( aFileName ) then - begin - self.Path := ExtractFilePath( aFileName ); - self.Folder := ExtractFilePath( aFileName ); + + Mult := 1; + + MultBPM := 4; + + + fFileName := aFileName; + + + if fileexists( aFileName ) then + + begin + + self.Path := ExtractFilePath( aFileName ); + self.Folder := ExtractFilePath( aFileName ); self.FileName := ExtractFileName( aFileName ); - (* - if ReadTXTHeader( aFileName ) then - begin - LoadSong(); - end +(* + + if ReadTXTHeader( aFileName ) then + + begin + + LoadSong(); + + end else begin Log.LogError('Error Loading SongHeader, abort Song Loading'); @@ -145,9 +161,11 @@ begin end; end; - - function TSong.LoadSong(): boolean; - var + + +function TSong.LoadSong(): boolean; + +var TempC: char; Tekst: string; CP: integer; // Current Player (0 or 1) @@ -319,9 +337,11 @@ begin Result := true; end; - - function TSong.ReadTXTHeader(const aFileName : WideString): boolean; - var + + +function TSong.ReadTXTHeader(const aFileName : WideString): boolean; + +var Line, Identifier, Value: String; Temp : word; Done : byte; @@ -362,6 +382,11 @@ begin //Required Attributes //----------- + {$IFDEF UTF8_FILENAMES} + if ((Identifier = 'MP3') or (Identifier = 'BACKGROUND') or (Identifier = 'COVER') or (Identifier = 'VIDEO')) then + Value := Utf8Encode(Value); + {$ENDIF} + //Title if (Identifier = 'TITLE') then begin @@ -646,7 +671,7 @@ end; procedure TSong.clear(); begin - //Main Information + //Main Information Title := ''; Artist := ''; @@ -675,7 +700,7 @@ begin NotesGAP := 0; Resolution := 4; Creator := ''; - + end; function TSong.Analyse(): boolean; @@ -705,4 +730,4 @@ end; -end. +end. -- cgit v1.2.3