DEADSOFTWARE

Main: Use TProcessUTF8 to start the test
[d2df-editor.git] / src / editor / f_main.pas
index 8fd1fa3372b6a4e87fe52580603a0f3a82def031..99820355f52210d9bc9db7cdf758a2ec5a50502b 100644 (file)
@@ -8,7 +8,7 @@ uses
   LCLIntf, LCLType, LMessages, SysUtils, Variants, Classes, Graphics,
   Controls, Forms, Dialogs, ImgList, StdCtrls, Buttons,
   ComCtrls, ValEdit, Types, ToolWin, Menus, ExtCtrls,
   LCLIntf, LCLType, LMessages, SysUtils, Variants, Classes, Graphics,
   Controls, Forms, Dialogs, ImgList, StdCtrls, Buttons,
   ComCtrls, ValEdit, Types, ToolWin, Menus, ExtCtrls,
-  CheckLst, Grids, OpenGLContext, utils;
+  CheckLst, Grids, OpenGLContext, utils, UTF8Process;
 
 type
 
 
 type
 
@@ -1795,6 +1795,7 @@ procedure FullClear();
 begin
   RemoveSelectFromObjects();
   ClearMap();
 begin
   RemoveSelectFromObjects();
   ClearMap();
+  LoadSky(gMapInfo.SkyName);
   UndoBuffer := nil;
   slInvalidTextures.Clear();
   MapCheckForm.lbErrorList.Clear();
   UndoBuffer := nil;
   slInvalidTextures.Clear();
   MapCheckForm.lbErrorList.Clear();
@@ -4032,10 +4033,20 @@ var
 begin
   config := TConfig.CreateFile(EditorDir+'Editor.cfg');
 
 begin
   config := TConfig.CreateFile(EditorDir+'Editor.cfg');
 
-  config.WriteInt('Editor', 'XPos', Left);
-  config.WriteInt('Editor', 'YPos', Top);
-  config.WriteInt('Editor', 'Width', Width);
-  config.WriteInt('Editor', 'Height', Height);
+  if WindowState <> wsMaximized then
+  begin
+    config.WriteInt('Editor', 'XPos', Left);
+    config.WriteInt('Editor', 'YPos', Top);
+    config.WriteInt('Editor', 'Width', Width);
+    config.WriteInt('Editor', 'Height', Height);
+  end
+  else
+  begin
+    config.WriteInt('Editor', 'XPos', RestoredLeft);
+    config.WriteInt('Editor', 'YPos', RestoredTop);
+    config.WriteInt('Editor', 'Width', RestoredWidth);
+    config.WriteInt('Editor', 'Height', RestoredHeight);
+  end;
   config.WriteBool('Editor', 'Maximize', WindowState = wsMaximized);
   config.WriteBool('Editor', 'Minimap', ShowMap);
   config.WriteInt('Editor', 'PanelProps', PanelProps.ClientWidth);
   config.WriteBool('Editor', 'Maximize', WindowState = wsMaximized);
   config.WriteBool('Editor', 'Minimap', ShowMap);
   config.WriteInt('Editor', 'PanelProps', PanelProps.ClientWidth);
@@ -6107,6 +6118,8 @@ begin
 
   PreviewMode := not PreviewMode;
   (Sender as TMenuItem).Checked := PreviewMode;
 
   PreviewMode := not PreviewMode;
   (Sender as TMenuItem).Checked := PreviewMode;
+
+  FormResize(Self);
 end;
 
 procedure TMainForm.miLayer1Click(Sender: TObject);
 end;
 
 procedure TMainForm.miLayer1Click(Sender: TObject);
@@ -6242,7 +6255,8 @@ var
   cmd, mapWAD, mapToRun: String;
   opt: LongWord;
   time: Integer;
   cmd, mapWAD, mapToRun: String;
   opt: LongWord;
   time: Integer;
-  lpMsgBuf: PChar;
+  proc: TProcessUTF8;
+  res: Boolean;
 begin
   // Сохраняем временную карту:
   time := 0;
 begin
   // Сохраняем временную карту:
   time := 0;
@@ -6282,13 +6296,27 @@ begin
   cmd := cmd + ' --tempdelete';
 
 // Запускаем:
   cmd := cmd + ' --tempdelete';
 
 // Запускаем:
-  Application.Minimize();
-  if ExecuteProcess(TestD2dExe, cmd) < 0 then
+  proc := TProcessUTF8.Create(nil);
+  proc.Executable := TestD2dExe;
+  proc.Parameters.Add(cmd);
+  res := True;
+  try
+    proc.Execute();
+  except
+    res := False;
+  end;
+  if res then
+  begin
+    Application.Minimize();
+    proc.WaitOnExit();
+  end;
+  if (not res) or (proc.ExitCode < 0) then
   begin
     MessageBox(0, 'FIXME',
                PChar(_lc[I_MSG_EXEC_ERROR]),
                MB_OK or MB_ICONERROR);
   end;
   begin
     MessageBox(0, 'FIXME',
                PChar(_lc[I_MSG_EXEC_ERROR]),
                MB_OK or MB_ICONERROR);
   end;
+  proc.Free();
 
   SysUtils.DeleteFile(mapWAD);
   Application.Restore();
 
   SysUtils.DeleteFile(mapWAD);
   Application.Restore();