summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d577822)
raw | patch | inline | side by side (parent: d577822)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Tue, 23 May 2023 15:54:07 +0000 (18:54 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Tue, 23 May 2023 15:54:07 +0000 (18:54 +0300) |
diff --git a/src/editor/Editor.lpr b/src/editor/Editor.lpr
index 18f997c7c142c491e02c5f14ab87c1796c0abeba..2e5585344aa4627e340de55019560340902728e5 100644 (file)
--- a/src/editor/Editor.lpr
+++ b/src/editor/Editor.lpr
{$INCLUDE ../shared/a_modes.inc}
uses
+ {$IFDEF DARWIN}
+ MacOSAll, CocoaAll,
+ {$ENDIF}
Forms, Interfaces, Dialogs,
GL, GLExt, SysUtils,
e_graphics in '../engine/e_graphics.pas',
LogFileName: AnsiString = '';
ParamFileIndex: Integer = 1;
+{$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 THandlerObject.ExceptionHandler (Sender: TObject; e: Exception);
begin
e_WriteStackTrace(e.message);
StartMap := ParamStr(i);
end;
- procedure InitLogs;
+ procedure InitPathes;
+ {$IFDEF DARWIN}
+ var BundlePath, DFPath, DocPath: AnsiString; ns: NSString;
+ var ApplicationSupportDirs, DocumentDirs: NSArray;
+ var count: Integer;
+ {$ELSE}
+ var EditorDir: AnsiString;
+ {$ENDIF}
begin
- if LogFileName = '' then
- LogFileName := 'Editor.log';
+ {$IFDEF DARWIN}
+ BundlePath := GetBundlePath();
+ ApplicationSupportDirs := NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, true);
+ count := ApplicationSupportDirs.count;
+ ns := ApplicationSupportDirs.objectAtIndex(count - 1);
+ DFPath := NSStringToAnsiString(ns) + DirectorySeparator + 'Doom 2D Forever';
+ DocumentDirs := NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true);
+ count := DocumentDirs.count;
+ ns := DocumentDirs.objectAtIndex(count - 1);
+ DocPath := NSStringToAnsiString(ns) + DirectorySeparator + 'Doom 2D Forever';
+ GameExeFile := 'Doom 2D Forever.app';
+ CfgFileName := DFPath + DirectorySeparator + 'Editor.cfg';
+ LogFileName := DFPath + DirectorySeparator + 'Editor.log';
+ MapsDir := DocPath + DirectorySeparator + 'Maps';
+ WadsDir := BundlePath + DirectorySeparator + 'Contents' + DirectorySeparator + 'Resources' + DirectorySeparator + 'wads';
+ GameWad := BundlePath + DirectorySeparator + 'Contents' + DirectorySeparator + 'Resources' + DirectorySeparator + 'data' + DirectorySeparator + 'game.wad';
+ EditorWad := BundlePath + DirectorySeparator + 'Contents' + DirectorySeparator + 'Resources' + DirectorySeparator + 'data' + DirectorySeparator + 'editor.wad';
+ {$ELSE}
+ EditorDir := ExtractFilePath(Application.ExeName);
+ {$IFDEF WINDOWS}
+ GameExeFile := 'Doom2DF.exe';
+ {$ELSE}
+ GameExeFile := 'Doom2DF';
+ {$ENDIF}
+ CfgFileName := EditorDir + DirectorySeparator + 'Editor.cfg';
+ LogFileName := EditorDir + DirectorySeparator + 'Editor.log';
+ MapsDir := EditorDir + DirectorySeparator + 'maps';
+ WadsDir := EditorDir + DirectorySeparator + 'wads';
+ GameWad := EditorDir + DirectorySeparator + 'data' + DirectorySeparator + 'game.wad';
+ EditorWad := EditorDir + DirectorySeparator + 'data' + DirectorySeparator + 'editor.wad';
+ {$ENDIF}
+ ForceDirectories(MapsDir);
+ ForceDirectories(WadsDir);
+ end;
- if LogFileName <> '' then
- e_InitLog(LogFileName, WM_NEWFILE);
+ procedure InitLogs;
+ begin
+ e_InitLog(LogFileName, WM_NEWFILE);
{$IF DECLARED(UseHeapTrace)}
(* http://wiki.freepascal.org/heaptrc *)
//SetHeapTraceOutput('EditorLeaks.log');
//HaltOnError := False;
{$ENDIF}
+
+ e_WriteLog('Used file pathes:', MSG_NOTIFY);
+ e_WriteLog(' GameExeFile = ' + GameExeFile, MSG_NOTIFY);
+ e_WriteLog(' CfgFileName = ' + CfgFileName, MSG_NOTIFY);
+ e_WriteLog(' LogFileName = ' + LogFileName, MSG_NOTIFY);
+ e_WriteLog(' MapsDir = ' + MapsDir, MSG_NOTIFY);
+ e_WriteLog(' WadsDir = ' + WadsDir, MSG_NOTIFY);
+ e_WriteLog(' GameWad = ' + GameWad, MSG_NOTIFY);
+ e_WriteLog(' EditorWad = ' + EditorWad, MSG_NOTIFY);
end;
begin
Application.AddOnExceptionHandler(THandlerObject.ExceptionHandler, True);
Application.Initialize();
- EditorDir := ExtractFilePath(Application.ExeName);
- CfgFileName := EditorDir + DirectorySeparator + 'Editor.cfg';
- GameWad := EditorDir + DirectorySeparator + 'data' + DirectorySeparator + 'game.wad';
- EditorWad := EditorDir + DirectorySeparator + 'data' + DirectorySeparator + 'editor.wad';
- WadsDir := EditorDir + DirectorySeparator + 'wads';
-
+ InitPathes;
CheckParamOptions;
InitLogs;
diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas
index e3c6288d2419f49a2b6d2f38fca31b5e1eec0da4..8fd661aa8cee44eea859fc0430053546421e87c1 100644 (file)
--- a/src/editor/f_main.pas
+++ b/src/editor/f_main.pas
if aWAD = _lc[I_WAD_SPECIAL_MAP] then
begin // Файл карты
g_ProcessResourceStr(OpenedMap, @fn, nil, nil);
- //FileName := EditorDir+'maps\'+ExtractFileName(fn);
FileName := fn;
ResourceName := ':'+SectionName+'\'+aTex;
end
DotSize := 2
else
DotSize := 1;
- OpenDialog.InitialDir := config.ReadStr('Editor', 'LastOpenDir', EditorDir);
- SaveDialog.InitialDir := config.ReadStr('Editor', 'LastSaveDir', EditorDir);
+ OpenDialog.InitialDir := config.ReadStr('Editor', 'LastOpenDir', MapsDir);
+ SaveDialog.InitialDir := config.ReadStr('Editor', 'LastSaveDir', MapsDir);
s := config.ReadStr('Editor', 'Language', '');
gLanguage := s;
index f22f5fd38cae93ac41bcc9faff9502d574e9f089..de82a635dafb035b7f79f62600983c1367d77a67 100644 (file)
--- a/src/editor/f_maptest.pas
+++ b/src/editor/f_maptest.pas
TestOptionsWeaponStay := config.ReadBool('TestRun', 'WeaponStay', False);
TestOptionsMonstersDM := config.ReadBool('TestRun', 'MonstersDM', False);
TestMapOnce := config.ReadBool('TestRun', 'MapOnce', False);
- TestD2dExe := config.ReadStr('TestRun', 'Exe', EditorDir+'Doom2DF.exe');
+ TestD2dExe := config.ReadStr('TestRun', 'Exe', GameExeFile);
TestD2DArgs := config.ReadStr('TestRun', 'Args', '');
config.Free();
index 1fce2c21b9f7678dc42dd4b8ad5e8f01bf421848..1259898100b2b25ed7494d22d3de04abb17f79b8 100644 (file)
--- a/src/editor/f_packmap.pas
+++ b/src/editor/f_packmap.pas
procedure TPackMapForm.FormCreate(Sender: TObject);
begin
- SaveDialog.InitialDir := EditorDir;
+ SaveDialog.InitialDir := MapsDir;
end;
end.
diff --git a/src/shared/a_modes.inc b/src/shared/a_modes.inc
index 9e5299743a421f783ebefa5f6ab5291d536fe3fe..05afc88baeddc07d83ea0dd2645973a710d35ce3 100644 (file)
--- a/src/shared/a_modes.inc
+++ b/src/shared/a_modes.inc
{$DEFINE NOSOUND}
{$ENDIF}
+{$IFDEF DARWIN}
+ {$MODESWITCH OBJECTIVEC1}
+{$ENDIF}