diff options
author | mogguh <mogguh@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-02-13 19:58:44 +0000 |
---|---|---|
committer | mogguh <mogguh@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-02-13 19:58:44 +0000 |
commit | 949fea202f6c963ad6c8a40040e1e9e6f909161b (patch) | |
tree | 9f6f683d203d55e41e5b7483b4038103d471ce76 /Game/Code/Classes/UPlatform.pas | |
parent | 1a7da68ae6e1368dae25821b15318bd1d2d9f88e (diff) | |
parent | efe5b06fd5715f550334692d28c2218896b62ce1 (diff) | |
download | usdx-949fea202f6c963ad6c8a40040e1e9e6f909161b.tar.gz usdx-949fea202f6c963ad6c8a40040e1e9e6f909161b.tar.xz usdx-949fea202f6c963ad6c8a40040e1e9e6f909161b.zip |
First multi platform version, works on Linux and Windows
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/1.1@855 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game/Code/Classes/UPlatform.pas')
-rw-r--r-- | Game/Code/Classes/UPlatform.pas | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/Game/Code/Classes/UPlatform.pas b/Game/Code/Classes/UPlatform.pas new file mode 100644 index 00000000..bfb03d54 --- /dev/null +++ b/Game/Code/Classes/UPlatform.pas @@ -0,0 +1,80 @@ +unit UPlatform; + +// Comment by Eddie: +// This unit defines an interface for platform specific utility functions. +// The Interface is implemented in separate files for each platform: +// UPlatformWindows, UPlatformLinux and UPlatformWindows. + +interface + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + +{$I switches.inc} + +uses Classes; + +type + TDirectoryEntry = Record + Name : WideString; + IsDirectory : Boolean; + IsFile : Boolean; + end; + + TDirectoryEntryArray = Array of TDirectoryEntry; + + IPlatform = Interface + ['{63A5EBC3-3F4D-4F23-8DFB-B5165FCA23DF}'] + 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; + + function Platform : IPlatform; + +implementation + +uses + SysUtils, + {$IFDEF MSWINDOWS} + UPlatformWindows; + {$ENDIF} + {$IFDEF LINUX} + UPlatformLinux; + {$ENDIF} + {$IFDEF DARWIN} + UPlatformMacOSX; + {$ENDIF} + + +// I have modified it to use the Platform_singleton in this location ( in the implementaiton ) +// so that this variable can NOT be overwritten from anywhere else in the application. +// the accessor function platform, emulates all previous calls to work the same way. +var + Platform_singleton : IPlatform; + +function Platform : IPlatform; +begin + result := Platform_singleton;
+end; + + +initialization + {$IFDEF MSWINDOWS} + Platform_singleton := TPlatformWindows.Create; + {$ENDIF} + {$IFDEF LINUX} + Platform_singleton := TPlatformLinux.Create; + {$ENDIF} + {$IFDEF DARWIN} + Platform_singleton := TPlatformMacOSX.Create; + {$ENDIF} + +finalization + Platform_singleton := nil; +end. |