From a0ff0b75e3562e04f17f11fc41f2e49040d620c5 Mon Sep 17 00:00:00 2001 From: eddie-0815 Date: Thu, 8 Nov 2007 21:02:07 +0000 Subject: Added UPlatform.pas. This should be the first step to move the simple platform specific code to one file for each platform to reduce the IFDEFs in the remaining files. The first available function is a unicode capable DirectoryFindFiles. It is now used in the BrowseDir function in file USongs.pas. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@595 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UPlatformLinux.pas | 66 ++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Game/Code/Classes/UPlatformLinux.pas (limited to 'Game/Code/Classes/UPlatformLinux.pas') diff --git a/Game/Code/Classes/UPlatformLinux.pas b/Game/Code/Classes/UPlatformLinux.pas new file mode 100644 index 00000000..1713df1c --- /dev/null +++ b/Game/Code/Classes/UPlatformLinux.pas @@ -0,0 +1,66 @@ +unit UPlatformLinux; + +interface + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + +{$I switches.inc} + +uses Classes, UPlatform; + +type + + TPlatform = class(TInterfacedObject, IPlatform) + public + Function DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; + end; + +implementation + +uses SysUtils, oldlinux; + +Function TPlatform.DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; +var + i : Integer; + TheDir : oldlinux.pdir; + ADirent : oldlinux.pDirent; + Entry : Longint; + info : oldlinux.stat; + lAttrib : integer; +begin + i := 0; + Filter := LowerCase(Filter); + + TheDir := oldlinux.opendir( Dir ); + if Assigned(TheDir) then + repeat + ADirent := oldlinux.ReadDir(TheDir); + + If Assigned(ADirent) and (ADirent^.d_name <> '.') and (ADirent^.d_name <> '..') then + begin + lAttrib := FileGetAttr(Dir + ADirent^.d_name); + if ReturnAllSubDirs and ((lAttrib and faDirectory) <> 0) then + begin + SetLength( Result, i + 1); + Result[i].Name := ADirent^.d_name; + Result[i].IsDirectory := true; + Result[i].IsFile := false; + i := i + 1; + end + else if (Length(Filter) = 0) or (Pos( Filter, LowerCase(ADirent^.d_name)) > 0) then + begin + SetLength( Result, i + 1); + Result[i].Name := ADirent^.d_name; + Result[i].IsDirectory := false; + Result[i].IsFile := true; + i := i + 1; + end; + end; + Until ADirent = nil; + + oldlinux.CloseDir(TheDir); +end; + +end. -- cgit v1.2.3 From 5b4785d36f83f3361f89b33c84839591969d24a6 Mon Sep 17 00:00:00 2001 From: eddie-0815 Date: Thu, 8 Nov 2007 21:15:01 +0000 Subject: Changed d_name to name. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@597 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UPlatformLinux.pas | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Game/Code/Classes/UPlatformLinux.pas') diff --git a/Game/Code/Classes/UPlatformLinux.pas b/Game/Code/Classes/UPlatformLinux.pas index 1713df1c..fd06097d 100644 --- a/Game/Code/Classes/UPlatformLinux.pas +++ b/Game/Code/Classes/UPlatformLinux.pas @@ -38,21 +38,21 @@ begin repeat ADirent := oldlinux.ReadDir(TheDir); - If Assigned(ADirent) and (ADirent^.d_name <> '.') and (ADirent^.d_name <> '..') then + If Assigned(ADirent) and (ADirent^.name <> '.') and (ADirent^.name <> '..') then begin - lAttrib := FileGetAttr(Dir + ADirent^.d_name); + lAttrib := FileGetAttr(Dir + ADirent^.name); if ReturnAllSubDirs and ((lAttrib and faDirectory) <> 0) then begin SetLength( Result, i + 1); - Result[i].Name := ADirent^.d_name; + Result[i].Name := ADirent^.name; Result[i].IsDirectory := true; Result[i].IsFile := false; i := i + 1; end - else if (Length(Filter) = 0) or (Pos( Filter, LowerCase(ADirent^.d_name)) > 0) then + else if (Length(Filter) = 0) or (Pos( Filter, LowerCase(ADirent^.name)) > 0) then begin SetLength( Result, i + 1); - Result[i].Name := ADirent^.d_name; + Result[i].Name := ADirent^.name; Result[i].IsDirectory := false; Result[i].IsFile := true; i := i + 1; -- cgit v1.2.3 From ce484ce148d1db51ddb3cda575786f0871843cb3 Mon Sep 17 00:00:00 2001 From: eddie-0815 Date: Tue, 20 Nov 2007 21:02:37 +0000 Subject: Changed Platform from Interface to Class. Added TerminateIfAlreadyRunning and GetGamePath to UPlatform.pas. Fixed a bug in THookManager.Create ("SpacetoAllocate-1"). git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@617 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UPlatformLinux.pas | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Game/Code/Classes/UPlatformLinux.pas') diff --git a/Game/Code/Classes/UPlatformLinux.pas b/Game/Code/Classes/UPlatformLinux.pas index fd06097d..e6d90e20 100644 --- a/Game/Code/Classes/UPlatformLinux.pas +++ b/Game/Code/Classes/UPlatformLinux.pas @@ -12,16 +12,16 @@ uses Classes, UPlatform; type - TPlatform = class(TInterfacedObject, IPlatform) + TPlatform = class(TPlatform) public - Function DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; + Function DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; override; end; implementation uses SysUtils, oldlinux; -Function TPlatform.DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; +Function TPlatformLinux.DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; var i : Integer; TheDir : oldlinux.pdir; -- cgit v1.2.3 From d3e475ad32f82e770981b8035621ce52d8faccae Mon Sep 17 00:00:00 2001 From: eddie-0815 Date: Tue, 20 Nov 2007 21:08:33 +0000 Subject: Fixed UPlatformLinux.pas git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@618 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UPlatformLinux.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Game/Code/Classes/UPlatformLinux.pas') diff --git a/Game/Code/Classes/UPlatformLinux.pas b/Game/Code/Classes/UPlatformLinux.pas index e6d90e20..741662cd 100644 --- a/Game/Code/Classes/UPlatformLinux.pas +++ b/Game/Code/Classes/UPlatformLinux.pas @@ -12,7 +12,7 @@ uses Classes, UPlatform; type - TPlatform = class(TPlatform) + TPlatformLinux = class(TPlatform) public Function DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; override; end; -- cgit v1.2.3 From 47d6da8f4e8eb47e3c9b26b7d231d91f3cebafd0 Mon Sep 17 00:00:00 2001 From: tobigun Date: Wed, 5 Dec 2007 22:03:49 +0000 Subject: - compatibility changes for fpc 2.2.0 and lazarus 0.9.24. Changes are enabled if {$DEFINE LAZARUS_V0924} and/or {$DEFINE FPC_V220} are defined in switches.inc. - this is a very ugly HACK and should be replaced by something different (not in switches.inc and some sort of {$IF FPC_VERSION > VERSION(2, 2, 0)} git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@672 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UPlatformLinux.pas | 182 ++++++++++++++++++++++------------- 1 file changed, 116 insertions(+), 66 deletions(-) (limited to 'Game/Code/Classes/UPlatformLinux.pas') diff --git a/Game/Code/Classes/UPlatformLinux.pas b/Game/Code/Classes/UPlatformLinux.pas index 741662cd..8119346e 100644 --- a/Game/Code/Classes/UPlatformLinux.pas +++ b/Game/Code/Classes/UPlatformLinux.pas @@ -1,66 +1,116 @@ -unit UPlatformLinux; - -interface - -{$IFDEF FPC} - {$MODE Delphi} -{$ENDIF} - -{$I switches.inc} - -uses Classes, UPlatform; - -type - - TPlatformLinux = class(TPlatform) - public - Function DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; override; - end; - -implementation - -uses SysUtils, oldlinux; - -Function TPlatformLinux.DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; -var - i : Integer; - TheDir : oldlinux.pdir; - ADirent : oldlinux.pDirent; - Entry : Longint; - info : oldlinux.stat; - lAttrib : integer; -begin - i := 0; - Filter := LowerCase(Filter); - - TheDir := oldlinux.opendir( Dir ); - if Assigned(TheDir) then - repeat - ADirent := oldlinux.ReadDir(TheDir); - - If Assigned(ADirent) and (ADirent^.name <> '.') and (ADirent^.name <> '..') then - begin - lAttrib := FileGetAttr(Dir + ADirent^.name); - if ReturnAllSubDirs and ((lAttrib and faDirectory) <> 0) then - begin - SetLength( Result, i + 1); - Result[i].Name := ADirent^.name; - Result[i].IsDirectory := true; - Result[i].IsFile := false; - i := i + 1; - end - else if (Length(Filter) = 0) or (Pos( Filter, LowerCase(ADirent^.name)) > 0) then - begin - SetLength( Result, i + 1); - Result[i].Name := ADirent^.name; - Result[i].IsDirectory := false; - Result[i].IsFile := true; - i := i + 1; - end; - end; - Until ADirent = nil; - - oldlinux.CloseDir(TheDir); -end; - -end. +unit UPlatformLinux; + +interface + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + +{$I switches.inc} + +uses Classes, UPlatform; + +type + + TPlatformLinux = class(TPlatform) + public + Function DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; override; + end; + +implementation + +uses +{$IFNDEF FPC_V220} + oldlinux, +{$ELSE} + BaseUnix, +{$ENDIF} + SysUtils; + +{$IFDEF FPC_V220} +Function TPlatformLinux.DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; +var + i : Integer; + TheDir : pDir; + ADirent : pDirent; + Entry : Longint; + //info : oldlinux.stat; + lAttrib : integer; +begin + i := 0; + Filter := LowerCase(Filter); + + TheDir := FpOpenDir( Dir ); + if Assigned(TheDir) then + repeat + ADirent := FpReadDir(TheDir^); + + If Assigned(ADirent) and (ADirent^.d_name <> '.') and (ADirent^.d_name <> '..') then + begin + lAttrib := FileGetAttr(Dir + ADirent^.d_name); + if ReturnAllSubDirs and ((lAttrib and faDirectory) <> 0) then + begin + SetLength( Result, i + 1); + Result[i].Name := ADirent^.d_name; + Result[i].IsDirectory := true; + Result[i].IsFile := false; + i := i + 1; + end + else if (Length(Filter) = 0) or (Pos( Filter, LowerCase(ADirent^.d_name)) > 0) then + begin + SetLength( Result, i + 1); + Result[i].Name := ADirent^.d_name; + Result[i].IsDirectory := false; + Result[i].IsFile := true; + i := i + 1; + end; + end; + Until ADirent = nil; + + FpCloseDir(TheDir^); +end; +{$ELSE} +Function TPlatformLinux.DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; +var + i : Integer; + TheDir : oldlinux.pdir; + ADirent : oldlinux.pDirent; + Entry : Longint; + info : oldlinux.stat; + lAttrib : integer; +begin + i := 0; + Filter := LowerCase(Filter); + + TheDir := oldlinux.opendir( Dir ); + if Assigned(TheDir) then + repeat + ADirent := oldlinux.ReadDir(TheDir); + + If Assigned(ADirent) and (ADirent^.name <> '.') and (ADirent^.name <> '..') then + begin + lAttrib := FileGetAttr(Dir + ADirent^.name); + if ReturnAllSubDirs and ((lAttrib and faDirectory) <> 0) then + begin + SetLength( Result, i + 1); + Result[i].Name := ADirent^.name; + Result[i].IsDirectory := true; + Result[i].IsFile := false; + i := i + 1; + end + else if (Length(Filter) = 0) or (Pos( Filter, LowerCase(ADirent^.name)) > 0) then + begin + SetLength( Result, i + 1); + Result[i].Name := ADirent^.name; + Result[i].IsDirectory := false; + Result[i].IsFile := true; + i := i + 1; + end; + end; + Until ADirent = nil; + + oldlinux.CloseDir(TheDir); +end; +{$ENDIF} + +end. -- cgit v1.2.3 From 7d61a98f807803a337fd12342c29eb0f5f69fc76 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Thu, 20 Dec 2007 03:33:14 +0000 Subject: made USDX function when file paths differ from previous expectations.. ( most of the software was still using hard coded paths ) also added ability to have multiple song directories. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@735 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UPlatformLinux.pas | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'Game/Code/Classes/UPlatformLinux.pas') diff --git a/Game/Code/Classes/UPlatformLinux.pas b/Game/Code/Classes/UPlatformLinux.pas index 8119346e..03e04560 100644 --- a/Game/Code/Classes/UPlatformLinux.pas +++ b/Game/Code/Classes/UPlatformLinux.pas @@ -13,13 +13,20 @@ uses Classes, UPlatform; type TPlatformLinux = class(TPlatform) + function get_homedir(): string; public Function DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; override; + function TerminateIfAlreadyRunning(var WndTitle : String) : Boolean; override; + + function GetLogPath : WideString; override; + function GetGameSharedPath : WideString; override; + function GetGameUserPath : WideString; override; end; implementation uses + libc, {$IFNDEF FPC_V220} oldlinux, {$ELSE} @@ -113,4 +120,35 @@ begin end; {$ENDIF} + +function TPlatformLinux.GetLogPath : WideString; +begin + result := '/var/log/UltraStarDeluxe/'; +end; + +function TPlatformLinux.GetGameSharedPath : WideString; +begin + result := '/usr/share/UltraStarDeluxe/'; +end; + +function TPlatformLinux.GetGameUserPath : WideString; +begin + result := get_homedir()+'/.UltraStarDeluxe/'; +end; + +function TPlatformLinux.get_homedir(): string; +var + pPasswdEntry : Ppasswd; + lUserName : String; +begin + pPasswdEntry := getpwuid( getuid() ); + result := pPasswdEntry^.pw_dir; +end; + +function TPlatformLinux.TerminateIfAlreadyRunning(var WndTitle : String) : Boolean; +begin + // Linux and Mac don't check for running apps at the moment + Result := false; +end; + end. -- cgit v1.2.3 From d808dde8310ecfd659d36bfe1ba77e76ea43b6c0 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Thu, 20 Dec 2007 22:53:06 +0000 Subject: added -localpaths command line switch so we dont always have to use the packaged locations. ( profox ) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@737 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UPlatformLinux.pas | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'Game/Code/Classes/UPlatformLinux.pas') diff --git a/Game/Code/Classes/UPlatformLinux.pas b/Game/Code/Classes/UPlatformLinux.pas index 03e04560..0098baee 100644 --- a/Game/Code/Classes/UPlatformLinux.pas +++ b/Game/Code/Classes/UPlatformLinux.pas @@ -27,6 +27,7 @@ implementation uses libc, + uCommandLine, {$IFNDEF FPC_V220} oldlinux, {$ELSE} @@ -123,17 +124,26 @@ end; function TPlatformLinux.GetLogPath : WideString; begin - result := '/var/log/UltraStarDeluxe/'; + if FindCmdLineSwitch( cUseLocalPaths ) then + result := inherited + else + result := '/var/log/UltraStarDeluxe/'; end; function TPlatformLinux.GetGameSharedPath : WideString; begin - result := '/usr/share/UltraStarDeluxe/'; + if FindCmdLineSwitch( cUseLocalPaths ) then + result := inherited + else + result := '/usr/share/UltraStarDeluxe/'; end; function TPlatformLinux.GetGameUserPath : WideString; begin - result := get_homedir()+'/.UltraStarDeluxe/'; + if FindCmdLineSwitch( cUseLocalPaths ) then + result := inherited + else + result := get_homedir()+'/.UltraStarDeluxe/'; end; function TPlatformLinux.get_homedir(): string; -- cgit v1.2.3 From e74bd57c12f470257111c1c0530fb38f0fd34414 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Sat, 12 Jan 2008 12:31:43 +0000 Subject: bunch of smaller changes... some changes to song loading... Record global changed to singleton object started implementing mic volume display in Settings-Record hope this dosnt break anything.. :P git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@789 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UPlatformLinux.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Game/Code/Classes/UPlatformLinux.pas') diff --git a/Game/Code/Classes/UPlatformLinux.pas b/Game/Code/Classes/UPlatformLinux.pas index 0098baee..cde737b6 100644 --- a/Game/Code/Classes/UPlatformLinux.pas +++ b/Game/Code/Classes/UPlatformLinux.pas @@ -12,7 +12,7 @@ uses Classes, UPlatform; type - TPlatformLinux = class(TPlatform) + TPlatformLinux = class(TInterfacedObject, IPlatform) function get_homedir(): string; public Function DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; override; -- cgit v1.2.3 From 7870ce72a56d56736550376a15e3469fed3afd5d Mon Sep 17 00:00:00 2001 From: tobigun Date: Fri, 25 Jan 2008 17:03:38 +0000 Subject: Bugfix: some inherited functions were missing. Jay please check for correctness (did you forget to check your file in?)! git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@804 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UPlatformLinux.pas | 39 ++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) (limited to 'Game/Code/Classes/UPlatformLinux.pas') diff --git a/Game/Code/Classes/UPlatformLinux.pas b/Game/Code/Classes/UPlatformLinux.pas index cde737b6..2115428f 100644 --- a/Game/Code/Classes/UPlatformLinux.pas +++ b/Game/Code/Classes/UPlatformLinux.pas @@ -15,12 +15,15 @@ type TPlatformLinux = class(TInterfacedObject, IPlatform) function get_homedir(): string; public - Function DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; override; - function TerminateIfAlreadyRunning(var WndTitle : String) : Boolean; override; - - function GetLogPath : WideString; override; - function GetGameSharedPath : WideString; override; - function GetGameUserPath : WideString; override; + function DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; + function TerminateIfAlreadyRunning(var WndTitle : String) : Boolean; + function FindSongFile(Dir, Mask: widestring): widestring; + + procedure Halt; + + function GetLogPath : WideString; + function GetGameSharedPath : WideString; + function GetGameUserPath : WideString; end; implementation @@ -155,10 +158,34 @@ begin result := pPasswdEntry^.pw_dir; end; +// FIXME: just a dirty-fix to make the linux build work again. +// This i the same as the corresponding function for windows +// and MacOSX. +// Maybe this should be TPlatformBase.Halt() +procedure TPlatformLinux.Halt; +begin + application.terminate; +end; + function TPlatformLinux.TerminateIfAlreadyRunning(var WndTitle : String) : Boolean; begin // Linux and Mac don't check for running apps at the moment Result := false; end; +// FIXME: just a dirty-fix to make the linux build work again. +// This i the same as the corresponding function for windows +// (and MacOSX?). +// Maybe this should be TPlatformBase.FindSongFile() +function TPlatformLinux.FindSongFile(Dir, Mask: widestring): widestring; +var + SR: TSearchRec; // for parsing song directory +begin + Result := ''; + if SysUtils.FindFirst(Dir + Mask, faDirectory, SR) = 0 then begin + Result := SR.Name; + end; // if + SysUtils.FindClose(SR); +end; + end. -- cgit v1.2.3 From 6fa012e73a04959d69307911b90f526148c8352a Mon Sep 17 00:00:00 2001 From: jaybinks Date: Mon, 4 Feb 2008 23:10:16 +0000 Subject: small changes to check linux compilation. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@808 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UPlatformLinux.pas | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'Game/Code/Classes/UPlatformLinux.pas') diff --git a/Game/Code/Classes/UPlatformLinux.pas b/Game/Code/Classes/UPlatformLinux.pas index 2115428f..882376a2 100644 --- a/Game/Code/Classes/UPlatformLinux.pas +++ b/Game/Code/Classes/UPlatformLinux.pas @@ -128,7 +128,7 @@ end; function TPlatformLinux.GetLogPath : WideString; begin if FindCmdLineSwitch( cUseLocalPaths ) then - result := inherited + result := ExtractFilePath(ParamStr(0)) else result := '/var/log/UltraStarDeluxe/'; end; @@ -136,7 +136,7 @@ end; function TPlatformLinux.GetGameSharedPath : WideString; begin if FindCmdLineSwitch( cUseLocalPaths ) then - result := inherited + result := ExtractFilePath(ParamStr(0)) else result := '/usr/share/UltraStarDeluxe/'; end; @@ -144,7 +144,7 @@ end; function TPlatformLinux.GetGameUserPath : WideString; begin if FindCmdLineSwitch( cUseLocalPaths ) then - result := inherited + result := ExtractFilePath(ParamStr(0)) else result := get_homedir()+'/.UltraStarDeluxe/'; end; @@ -164,7 +164,7 @@ end; // Maybe this should be TPlatformBase.Halt() procedure TPlatformLinux.Halt; begin - application.terminate; + halt(); end; function TPlatformLinux.TerminateIfAlreadyRunning(var WndTitle : String) : Boolean; @@ -182,7 +182,8 @@ var SR: TSearchRec; // for parsing song directory begin Result := ''; - if SysUtils.FindFirst(Dir + Mask, faDirectory, SR) = 0 then begin + if SysUtils.FindFirst(Dir + Mask, faDirectory, SR) = 0 then + begin Result := SR.Name; end; // if SysUtils.FindClose(SR); -- cgit v1.2.3 From 0d445e4ef186d6daee3a1545609a1528fe31fa10 Mon Sep 17 00:00:00 2001 From: tobigun Date: Tue, 5 Feb 2008 14:15:34 +0000 Subject: Removed the FPC_V220 define. Now the build-in FPC_VERSION, FPC_RELEASE and FPC_PATCH macros are used. So no need to define the version in a config-file anymore (especially in windows). git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@816 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UPlatformLinux.pas | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'Game/Code/Classes/UPlatformLinux.pas') diff --git a/Game/Code/Classes/UPlatformLinux.pas b/Game/Code/Classes/UPlatformLinux.pas index 882376a2..b962d8a5 100644 --- a/Game/Code/Classes/UPlatformLinux.pas +++ b/Game/Code/Classes/UPlatformLinux.pas @@ -28,18 +28,25 @@ type implementation +// check for version of FPC >= 2.2.0 +{$IFDEF FPC} + {$IF (FPC_VERSION > 2) or ((FPC_VERSION = 2) and (FPC_RELEASE >= 2))} + {$DEFINE FPC_VERSION_2_2_0_PLUS} + {$IFEND} +{$ENDIF} + uses libc, uCommandLine, -{$IFNDEF FPC_V220} - oldlinux, -{$ELSE} +{$IFDEF FPC_VERSION_2_2_0_PLUS} BaseUnix, +{$ELSE} + oldlinux, {$ENDIF} SysUtils; -{$IFDEF FPC_V220} -Function TPlatformLinux.DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; +{$IFDEF FPC_VERSION_2_2_0_PLUS} +Function TPlatformLinux.DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; var i : Integer; TheDir : pDir; @@ -159,8 +166,7 @@ begin end; // FIXME: just a dirty-fix to make the linux build work again. -// This i the same as the corresponding function for windows -// and MacOSX. +// This i the same as the corresponding function for MacOSX. // Maybe this should be TPlatformBase.Halt() procedure TPlatformLinux.Halt; begin -- cgit v1.2.3 From e0f79449eedac343fbac90b72b7a6792e8e940e9 Mon Sep 17 00:00:00 2001 From: tobigun Date: Wed, 6 Feb 2008 09:59:51 +0000 Subject: fixed the configure stuff though it needs some further adjustments git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@835 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UPlatformLinux.pas | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'Game/Code/Classes/UPlatformLinux.pas') diff --git a/Game/Code/Classes/UPlatformLinux.pas b/Game/Code/Classes/UPlatformLinux.pas index b962d8a5..fe4bbf11 100644 --- a/Game/Code/Classes/UPlatformLinux.pas +++ b/Game/Code/Classes/UPlatformLinux.pas @@ -43,7 +43,8 @@ uses {$ELSE} oldlinux, {$ENDIF} - SysUtils; + SysUtils, + UConfig; {$IFDEF FPC_VERSION_2_2_0_PLUS} Function TPlatformLinux.DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; @@ -137,7 +138,11 @@ begin if FindCmdLineSwitch( cUseLocalPaths ) then result := ExtractFilePath(ParamStr(0)) else - result := '/var/log/UltraStarDeluxe/'; +{$IFDEF UseLocalDirs} + result := ExtractFilePath(ParamStr(0)) +{$ELSE} + result := LogPath+'/'; +{$ENDIF} end; function TPlatformLinux.GetGameSharedPath : WideString; @@ -145,7 +150,11 @@ begin if FindCmdLineSwitch( cUseLocalPaths ) then result := ExtractFilePath(ParamStr(0)) else - result := '/usr/share/UltraStarDeluxe/'; +{$IFDEF UseLocalDirs} + result := ExtractFilePath(ParamStr(0)) +{$ELSE} + result := SharedPath+'/'; +{$ENDIF} end; function TPlatformLinux.GetGameUserPath : WideString; @@ -153,7 +162,11 @@ begin if FindCmdLineSwitch( cUseLocalPaths ) then result := ExtractFilePath(ParamStr(0)) else - result := get_homedir()+'/.UltraStarDeluxe/'; +{$IFDEF UseLocalDirs} + result := ExtractFilePath(ParamStr(0)) +{$ELSE} + result := get_homedir()+'/.'+PathSuffix+'/'; +{$ENDIF} end; function TPlatformLinux.get_homedir(): string; -- cgit v1.2.3 From c63d80995c2c618b9cd293d9eecd3eb9e0e9b871 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Tue, 12 Feb 2008 13:43:34 +0000 Subject: builds nice... and builds deb also that runs / works .. mostly :P git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@846 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UPlatformLinux.pas | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Game/Code/Classes/UPlatformLinux.pas') diff --git a/Game/Code/Classes/UPlatformLinux.pas b/Game/Code/Classes/UPlatformLinux.pas index fe4bbf11..0883b0f8 100644 --- a/Game/Code/Classes/UPlatformLinux.pas +++ b/Game/Code/Classes/UPlatformLinux.pas @@ -143,6 +143,9 @@ begin {$ELSE} result := LogPath+'/'; {$ENDIF} + + forcedirectories( result ); + end; function TPlatformLinux.GetGameSharedPath : WideString; -- cgit v1.2.3