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/UPlatform.pas | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Game/Code/Classes/UPlatform.pas (limited to 'Game/Code/Classes/UPlatform.pas') diff --git a/Game/Code/Classes/UPlatform.pas b/Game/Code/Classes/UPlatform.pas new file mode 100644 index 00000000..cc971bed --- /dev/null +++ b/Game/Code/Classes/UPlatform.pas @@ -0,0 +1,56 @@ +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 + + // 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; + end; + +var + Platform : IPlatform; + +implementation + +uses + {$IFDEF MSWINDOWS} + UPlatformWindows; + {$ENDIF} + {$IFDEF LINUX} + UPlatformLinux; + {$ENDIF} + {$IFDEF DARWIN} + UPlatformMacOSX; + {$ENDIF} + +initialization + + Platform := TPlatform.Create; + +end. -- 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/UPlatform.pas | 46 ++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 8 deletions(-) (limited to 'Game/Code/Classes/UPlatform.pas') 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. -- cgit v1.2.3 From 486ad8796acc5883ef83f3a78cd615f6711d77f0 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Thu, 6 Dec 2007 09:39:49 +0000 Subject: conformed projectM to IVideoPlayback still needs a little work. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@678 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UPlatform.pas | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'Game/Code/Classes/UPlatform.pas') diff --git a/Game/Code/Classes/UPlatform.pas b/Game/Code/Classes/UPlatform.pas index 878c1ec2..a06914d0 100644 --- a/Game/Code/Classes/UPlatform.pas +++ b/Game/Code/Classes/UPlatform.pas @@ -18,10 +18,10 @@ uses Classes; type TDirectoryEntry = Record - Name : WideString; - IsDirectory : Boolean; - IsFile : Boolean; - end; + Name : WideString; + IsDirectory : Boolean; + IsFile : Boolean; + end; TDirectoryEntryArray = Array of TDirectoryEntry; @@ -81,6 +81,5 @@ initialization {$ENDIF} finalization - - Platform.Free; + freeandnil( Platform ); 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/UPlatform.pas | 63 +++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 15 deletions(-) (limited to 'Game/Code/Classes/UPlatform.pas') diff --git a/Game/Code/Classes/UPlatform.pas b/Game/Code/Classes/UPlatform.pas index a06914d0..bdd6cf78 100644 --- a/Game/Code/Classes/UPlatform.pas +++ b/Game/Code/Classes/UPlatform.pas @@ -25,7 +25,17 @@ type TDirectoryEntryArray = Array of TDirectoryEntry; - TPlatform = class + IPlatform = Interface + ['{63A5EBC3-3F4D-4F23-8DFB-B5165FCA23DF}'] + Function DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; + function TerminateIfAlreadyRunning(var WndTitle : String) : Boolean; + + function GetLogPath : WideString; + function GetGameSharedPath : WideString; + function GetGameUserPath : WideString; + end; + + TPlatform = class( TInterfacedOBject, IPlatform ) // 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 @@ -34,11 +44,16 @@ type function TerminateIfAlreadyRunning(var WndTitle : String) : Boolean; virtual; - function GetGamePath : WideString; virtual; +// function GetGamePath : WideString; virtual; + function GetLogPath : WideString; virtual; + function GetGameSharedPath : WideString; virtual; + function GetGameUserPath : WideString; virtual; + end; + var - Platform : TPlatform; + Platform : IPlatform; implementation @@ -55,19 +70,37 @@ uses {$ENDIF} { TPlatform } - + +(* function TPlatform.GetGamePath: WideString; -begin - // Windows and Linux use this: - Result := ExtractFilePath(ParamStr(0)); -end; - +begin + // Windows and Linux use this: + Result := ExtractFilePath(ParamStr(0)); +end; +*) +function TPlatform.GetLogPath : WideString; +begin + result := ExtractFilePath(ParamStr(0)); +end; + +function TPlatform.GetGameSharedPath : WideString; +begin + result := ExtractFilePath(ParamStr(0)); +end; + +function TPlatform.GetGameUserPath : WideString; +begin + 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; - +begin + // Linux and Mac don't check for running apps at the moment + Result := false; +end; + initialization {$IFDEF MSWINDOWS} @@ -81,5 +114,5 @@ initialization {$ENDIF} finalization - freeandnil( Platform ); + Platform := nil; end. -- cgit v1.2.3 From 31195a7ab6e264d325a589b1dd6673d6ba3d0e5a Mon Sep 17 00:00:00 2001 From: eddie-0815 Date: Wed, 9 Jan 2008 22:29:28 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@770 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UPlatform.pas | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'Game/Code/Classes/UPlatform.pas') diff --git a/Game/Code/Classes/UPlatform.pas b/Game/Code/Classes/UPlatform.pas index bdd6cf78..19a960e7 100644 --- a/Game/Code/Classes/UPlatform.pas +++ b/Game/Code/Classes/UPlatform.pas @@ -29,7 +29,7 @@ type ['{63A5EBC3-3F4D-4F23-8DFB-B5165FCA23DF}'] Function DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; function TerminateIfAlreadyRunning(var WndTitle : String) : Boolean; - + function GetLogPath : WideString; function GetGameSharedPath : WideString; function GetGameUserPath : WideString; @@ -40,8 +40,8 @@ type // 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 DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; virtual; abstract; + function TerminateIfAlreadyRunning(var WndTitle : String) : Boolean; virtual; // function GetGamePath : WideString; virtual; @@ -93,8 +93,6 @@ begin 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 -- 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/UPlatform.pas | 74 +++++++++++------------------------------ 1 file changed, 19 insertions(+), 55 deletions(-) (limited to 'Game/Code/Classes/UPlatform.pas') diff --git a/Game/Code/Classes/UPlatform.pas b/Game/Code/Classes/UPlatform.pas index 19a960e7..bfb03d54 100644 --- a/Game/Code/Classes/UPlatform.pas +++ b/Game/Code/Classes/UPlatform.pas @@ -16,7 +16,6 @@ interface uses Classes; type - TDirectoryEntry = Record Name : WideString; IsDirectory : Boolean; @@ -27,33 +26,16 @@ type IPlatform = Interface ['{63A5EBC3-3F4D-4F23-8DFB-B5165FCA23DF}'] - Function DirectoryFindFiles(Dir, Filter : WideString; ReturnAllSubDirs : Boolean) : TDirectoryEntryArray; - function TerminateIfAlreadyRunning(var WndTitle : String) : Boolean; - - function GetLogPath : WideString; - function GetGameSharedPath : WideString; - function GetGameUserPath : WideString; - end; - - TPlatform = class( TInterfacedOBject, IPlatform ) - - // 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; - function GetLogPath : WideString; virtual; - function GetGameSharedPath : WideString; virtual; - function GetGameUserPath : WideString; virtual; - + 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; - -var - Platform : IPlatform; + function Platform : IPlatform; implementation @@ -69,48 +51,30 @@ uses UPlatformMacOSX; {$ENDIF} -{ TPlatform } -(* -function TPlatform.GetGamePath: WideString; -begin - // Windows and Linux use this: - Result := ExtractFilePath(ParamStr(0)); -end; -*) -function TPlatform.GetLogPath : WideString; -begin - result := ExtractFilePath(ParamStr(0)); -end; - -function TPlatform.GetGameSharedPath : WideString; -begin - result := ExtractFilePath(ParamStr(0)); -end; +// 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 TPlatform.GetGameUserPath : WideString; +function Platform : IPlatform; begin - result := ExtractFilePath(ParamStr(0)); + result := Platform_singleton; 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 - {$IFDEF MSWINDOWS} - Platform := TPlatformWindows.Create; + Platform_singleton := TPlatformWindows.Create; {$ENDIF} {$IFDEF LINUX} - Platform := TPlatformLinux.Create; + Platform_singleton := TPlatformLinux.Create; {$ENDIF} {$IFDEF DARWIN} - Platform := TPlatformMacOSX.Create; + Platform_singleton := TPlatformMacOSX.Create; {$ENDIF} finalization - Platform := nil; + Platform_singleton := nil; end. -- cgit v1.2.3