summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6e9e0d2)
raw | patch | inline | side by side (parent: 6e9e0d2)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 25 Oct 2019 11:08:16 +0000 (14:08 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 25 Oct 2019 11:08:16 +0000 (14:08 +0300) |
src/game/g_main.pas | patch | blob | history | |
src/shared/a_modes.inc | patch | blob | history |
diff --git a/src/game/g_main.pas b/src/game/g_main.pas
index ee0d96eb590390aa86bbd215c864b6a33f251fab..165a116c0446e72a44817b3abc61e9e116174fa9 100644 (file)
--- a/src/game/g_main.pas
+++ b/src/game/g_main.pas
{$IFDEF LINUX}
BaseUnix,
{$ENDIF}
+{$IFDEF DARWIN}
+ MacOSAll, CocoaAll,
+{$ENDIF}
{$IFDEF USE_SDL2}
SDL2,
{$ENDIF}
e_LogWriteln(' ' + dir);
end;
+{$IFDEF DARWIN}
+ function NSStringToAnsiString (s: NSString): AnsiString;
+ var i: Integer;
+ begin
+ result := '';
+ for i := 0 to s.length - 1 do
+ result := result + AnsiChar(s.characterAtIndex(i));
+ end;
+
+ function GetBundlePath (): AnsiString;
+ var pathRef: CFURLRef; pathCFStr: CFStringRef; pathStr: ShortString;
+ begin
+ pathRef := CFBundleCopyBundleURL(CFBundleGetMainBundle());
+ pathCFStr := CFURLCopyFileSystemPath(pathRef, kCFURLPOSIXPathStyle);
+ CFStringGetPascalString(pathCFStr, @pathStr, 255, CFStringGetSystemEncoding());
+ CFRelease(pathRef);
+ CFRelease(pathCFStr);
+ Result := pathStr;
+ end;
+{$ENDIF}
+
procedure InitPath;
var i: Integer; rwdir, rodir: AnsiString; rwdirs, rodirs: SSArray;
//first: Boolean = true;
end;
function GetDefaultRODirs (): SSArray;
- {$IFDEF UNIX}
+ {$IF DEFINED(UNIX) AND NOT DEFINED(DARWIN) AND NOT DEFINED(ANDROID)}
var home: AnsiString;
{$ENDIF}
+ {$IFDEF WINDOWS}
+ var appdata: AnsiString;
+ {$ENDIF}
+ {$IFDEF DARWIN}
+ var bundle, s: AnsiString; dirArr: NSArray; i: Integer;
+ {$ENDIF}
begin
+ result := nil;
if forceCurrentDir = false then
begin
{$IFDEF USE_SDL2}
AddDir(result, SDL_GetBasePath());
AddDir(result, SDL_GetPrefPath('', 'doom2df'));
{$ENDIF}
- {$IFDEF UNIX}
+ {$IFDEF WINDOWS}
+ appdata := GetEnvironmentVariable('APPDATA') + '\doom2df';
+ if appdata <> '' then
+ AddDir(result, appdata);
+ {$ENDIF}
+ {$IF DEFINED(UNIX) AND NOT DEFINED(DARWIN) AND NOT DEFINED(ANDROID)}
AddDir(result, '/usr/share/doom2df');
AddDir(result, '/usr/local/share/doom2df');
home := GetEnvironmentVariable('HOME');
if home <> '' then
AddDir(result, e_CatPath(home, '.doom2df'));
{$ENDIF}
+ {$IFDEF DARWIN}
+ bundle := GetBundlePath();
+ if bundle <> '' then
+ AddDir(result, e_CatPath(bundle, 'Contents/Resources'));
+ dirArr := NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, true);
+ for i := 0 to dirArr.count - 1 do
+ begin
+ s := NSStringToAnsiString(dirArr.objectAtIndex(i));
+ AddDir(result, e_CatPath(s, 'Doom 2D Forever'))
+ end;
+ {$ENDIF}
{$IF DEFINED(ANDROID) AND DEFINED(USE_SDL2)}
AddDir(result, SDL_AndroidGetInternalStoragePath());
if SDL_AndroidGetExternalStorageState() <> 0 then
AddDir(result, SDL_AndroidGetExternalStoragePath());
{$ENDIF}
end;
- AddDir(result, '.');
+ {$IFNDEF ANDROID}
+ {$IFDEF DARWIN}
+ if ExtractFileExt(bundle) <> '.app' then
+ AddDir(result, '');
+ {$ELSE}
+ AddDir(result, '');
+ {$ENDIF}
+ {$ENDIF}
end;
function GetDefaultRWDirs (): SSArray;
- {$IFDEF UNIX}
+ {$IF DEFINED(UNIX) AND NOT DEFINED(DARWIN) AND NOT DEFINED(ANDROID)}
var home: AnsiString;
{$ENDIF}
+ {$IFDEF WINDOWS}
+ var appdata: AnsiString;
+ {$ENDIF}
+ {$IFDEF DARWIN}
+ var bundle, s: AnsiString; dirArr: NSArray; i: Integer;
+ {$ENDIF}
begin
+ result := nil;
if forceCurrentDir = false then
begin
- {$IF DEFINED(USE_SDL2)}
+ {$IFDEF USE_SDL2}
AddDir(result, SDL_GetPrefPath('', 'doom2df'));
{$ENDIF}
- {$IFDEF UNIX}
+ {$IFDEF WINDOWS}
+ appdata := GetEnvironmentVariable('APPDATA') + '\doom2df';
+ if appdata <> '' then
+ AddDir(result, appdata);
+ {$ENDIF}
+ {$IF DEFINED(UNIX) AND NOT DEFINED(DARWIN) AND NOT DEFINED(ANDROID)}
home := GetEnvironmentVariable('HOME');
if home <> '' then
AddDir(result, e_CatPath(home, '.doom2df'));
{$ENDIF}
+ {$IFDEF DARWIN}
+ dirArr := NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, true);
+ for i := 0 to dirArr.count - 1 do
+ begin
+ s := NSStringToAnsiString(dirArr.objectAtIndex(i));
+ AddDir(result, e_CatPath(s, 'Doom 2D Forever'))
+ end;
+ {$ENDIF}
{$IF DEFINED(ANDROID) AND DEFINED(USE_SDL2)}
if SDL_AndroidGetExternalStorageState() <> 0 then
AddDir(result, SDL_AndroidGetExternalStoragePath());
{$ENDIF}
end;
- AddDir(result, '.');
+ {$IFNDEF ANDROID}
+ {$IFDEF DARWIN}
+ bundle := GetBundlePath();
+ if ExtractFileExt(bundle) <> '.app' then
+ if bundle = '' then
+ AddDir(result, '');
+ {$ELSE}
+ AddDir(result, '');
+ {$ENDIF}
+ {$ENDIF}
end;
begin
diff --git a/src/shared/a_modes.inc b/src/shared/a_modes.inc
index 68a06725be44bc6a09c866a23cc415a39205b2d6..9b5d9390f1fadf14f156622520bde230fc91a334 100644 (file)
--- a/src/shared/a_modes.inc
+++ b/src/shared/a_modes.inc
{$MODESWITCH TYPEHELPERS+} // Allow the use of type helpers.
{$MODESWITCH UNICODESTRINGS-}
+{$IFDEF DARWIN}
+ {$MODESWITCH OBJECTIVEC1}
+{$ENDIF}
{$ASSERTIONS ON}
{$BITPACKING OFF}