2010-09-21 06:33:18 +00:00
|
|
|
unit chessconfig;
|
|
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2011-07-21 14:44:39 +00:00
|
|
|
Classes, SysUtils, Forms;
|
2010-09-21 06:33:18 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
|
|
|
|
{ TChessConfig }
|
|
|
|
|
|
|
|
TChessConfig = class
|
|
|
|
public
|
|
|
|
function GetResourcesDir: string;
|
|
|
|
function GetCurrentSkinDir: string;
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
vChessConfig: TChessConfig;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
2011-04-07 06:35:58 +00:00
|
|
|
{$ifdef Darwin}
|
|
|
|
uses
|
|
|
|
MacOSAll;
|
|
|
|
{$endif}
|
|
|
|
|
|
|
|
const
|
|
|
|
BundleResourcesDirectory = '/Contents/Resources/';
|
|
|
|
|
2010-09-21 06:33:18 +00:00
|
|
|
{ TChessConfig }
|
|
|
|
|
|
|
|
function TChessConfig.GetResourcesDir: string;
|
2011-04-07 06:35:58 +00:00
|
|
|
{$ifdef Darwin}
|
|
|
|
var
|
|
|
|
pathRef: CFURLRef;
|
|
|
|
pathCFStr: CFStringRef;
|
|
|
|
pathStr: shortstring;
|
|
|
|
{$endif}
|
2010-09-21 06:33:18 +00:00
|
|
|
begin
|
2011-04-07 06:35:58 +00:00
|
|
|
{$ifdef UNIX}
|
|
|
|
{$ifdef Darwin}
|
|
|
|
pathRef := CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
|
|
|
pathCFStr := CFURLCopyFileSystemPath(pathRef, kCFURLPOSIXPathStyle);
|
|
|
|
CFStringGetPascalString(pathCFStr, @pathStr, 255, CFStringGetSystemEncoding());
|
|
|
|
CFRelease(pathRef);
|
|
|
|
CFRelease(pathCFStr);
|
|
|
|
|
|
|
|
Result := pathStr + BundleResourcesDirectory;
|
|
|
|
{$else}
|
|
|
|
Result := '';
|
|
|
|
{$endif}
|
|
|
|
{$endif}
|
|
|
|
|
|
|
|
{$ifdef Windows}
|
|
|
|
Result := ExtractFilePath(Application.EXEName);
|
|
|
|
{$endif}
|
2010-09-21 06:33:18 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TChessConfig.GetCurrentSkinDir: string;
|
|
|
|
begin
|
|
|
|
Result := GetResourcesDir() + 'skins' + PathDelim + 'classic' + PathDelim;
|
|
|
|
end;
|
|
|
|
|
|
|
|
initialization
|
|
|
|
|
|
|
|
vChessConfig := TChessConfig.Create;
|
|
|
|
|
|
|
|
finalization
|
|
|
|
|
|
|
|
vChessConfig.Free;
|
|
|
|
|
|
|
|
end.
|
|
|
|
|