From 2a1be1865f68633a2385d8e55a6bd815616ec23f Mon Sep 17 00:00:00 2001 From: eddie-0815 Date: Fri, 2 Nov 2007 19:49:23 +0000 Subject: Fixed GamePath for Mac OS X. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@558 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UMain.pas | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'Game/Code/Classes') diff --git a/Game/Code/Classes/UMain.pas b/Game/Code/Classes/UMain.pas index e4acf4aa..1be4b463 100644 --- a/Game/Code/Classes/UMain.pas +++ b/Game/Code/Classes/UMain.pas @@ -1023,6 +1023,26 @@ begin Player[PlayerNum].ScoreTotalI := 0; end; +{$IFDEF DARWIN} +// Mac applications are packaged in directories. +// We have to cut the last two directories +// to get the application directory. +Function GetGamePath : String; +var + x, + i : integer; +begin + Result := ExtractFilePath(ParamStr(0)); + for x := 0 to 2 do begin + i := Length(Result); + repeat + Delete( Result, i, 1); + i := Length(Result); + until (i = 0) or (Result[i] = '/'); + end; +end; +{$ENDIF} + //-------------------- // Function sets all Absolute Paths e.g. Song Path and makes sure the Directorys exist //-------------------- @@ -1057,7 +1077,11 @@ procedure InitializePaths; begin +{$IFDEF DARWIN} + GamePath := GetGamePath; +{$ELSE} GamePath := ExtractFilePath(ParamStr(0)); +{$ENDIF} initialize_path( LogPath , GamePath ); initialize_path( SoundPath , GamePath + 'Sounds' + PathDelim ); -- cgit v1.2.3