aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/Classes/UPlatform.pas
diff options
context:
space:
mode:
authoreddie-0815 <eddie-0815@b956fd51-792f-4845-bead-9b4dfca2ff2c>2007-11-20 21:02:37 +0000
committereddie-0815 <eddie-0815@b956fd51-792f-4845-bead-9b4dfca2ff2c>2007-11-20 21:02:37 +0000
commitce484ce148d1db51ddb3cda575786f0871843cb3 (patch)
tree16380707a09822ce266bc5a3e7c8427273289073 /Game/Code/Classes/UPlatform.pas
parent34b0cb8bd025b40f52cff91bd9c29cd02faee7c2 (diff)
downloadusdx-ce484ce148d1db51ddb3cda575786f0871843cb3.tar.gz
usdx-ce484ce148d1db51ddb3cda575786f0871843cb3.tar.xz
usdx-ce484ce148d1db51ddb3cda575786f0871843cb3.zip
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
Diffstat (limited to '')
-rw-r--r--Game/Code/Classes/UPlatform.pas46
1 files changed, 38 insertions, 8 deletions
diff --git a/Game/Code/Classes/UPlatform.pas b/Game/Code/Classes/UPlatform.pas
index cc971bed..878c1ec2 100644
--- a/Game/Code/Classes/UPlatform.pas
+++ b/Game/Code/Classes/UPlatform.pas
@@ -25,20 +25,25 @@ type
TDirectoryEntryArray = Array of TDirectoryEntry;
- IPlatform = interface
-
- // DirectoryFindFiles returns all files matching the filter. Do not use '*' in the filter.
- // If you set ReturnAllSubDirs = true all directories will be returned, if yout set it to false
- // directories are completely ignored.
- Function DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray;
+ TPlatform = class
+
+ // DirectoryFindFiles returns all files matching the filter. Do not use '*' in the filter.
+ // If you set ReturnAllSubDirs = true all directories will be returned, if yout set it to false
+ // directories are completely ignored.
+ Function DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; virtual; abstract;
+
+ function TerminateIfAlreadyRunning(var WndTitle : String) : Boolean; virtual;
+
+ function GetGamePath : WideString; virtual;
end;
var
- Platform : IPlatform;
+ Platform : TPlatform;
implementation
uses
+ SysUtils,
{$IFDEF MSWINDOWS}
UPlatformWindows;
{$ENDIF}
@@ -49,8 +54,33 @@ uses
UPlatformMacOSX;
{$ENDIF}
+{ TPlatform }
+
+function TPlatform.GetGamePath: WideString;
+begin
+ // Windows and Linux use this:
+ Result := ExtractFilePath(ParamStr(0));
+end;
+
+function TPlatform.TerminateIfAlreadyRunning(var WndTitle : String) : Boolean;
+begin
+ // Linux and Mac don't check for running apps at the moment
+ Result := false;
+end;
+
initialization
- Platform := TPlatform.Create;
+ {$IFDEF MSWINDOWS}
+ Platform := TPlatformWindows.Create;
+ {$ENDIF}
+ {$IFDEF LINUX}
+ Platform := TPlatformLinux.Create;
+ {$ENDIF}
+ {$IFDEF DARWIN}
+ Platform := TPlatformMacOSX.Create;
+ {$ENDIF}
+
+finalization
+ Platform.Free;
end.