From: binarymaster Date: Fri, 29 Sep 2017 20:17:35 +0000 (+0300) Subject: Main: Allow drop files X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=ea332be65eaf98a52891ec2bd691b0ce27c9d316;p=d2df-editor.git Main: Allow drop files http://doom2d.org/forum/viewtopic.php?f=12&t=1588 --- diff --git a/src/editor/f_main.lfm b/src/editor/f_main.lfm index ade3a7f..0a7bf85 100644 --- a/src/editor/f_main.lfm +++ b/src/editor/f_main.lfm @@ -3,6 +3,7 @@ object MainForm: TMainForm Height = 480 Top = 255 Width = 672 + AllowDropFiles = True Caption = '2' ClientHeight = 460 ClientWidth = 672 @@ -18,6 +19,7 @@ object MainForm: TMainForm OnCloseQuery = FormCloseQuery OnCreate = FormCreate OnDestroy = FormDestroy + OnDropFiles = FormDropFiles OnKeyDown = FormKeyDown OnKeyUp = FormKeyUp OnResize = FormResize diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas index 63f31f4..c5821c4 100644 --- a/src/editor/f_main.pas +++ b/src/editor/f_main.pas @@ -204,6 +204,7 @@ type procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); + procedure FormDropFiles(Sender: TObject; const FileNames: array of String); procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure FormResize(Sender: TObject); procedure lbTextureListClick(Sender: TObject); @@ -262,6 +263,7 @@ type procedure OnIdle(Sender: TObject; var Done: Boolean); public procedure RefreshRecentMenu(); + procedure OpenMapFile(FileName: String); end; const @@ -4111,6 +4113,15 @@ begin slInvalidTextures.Free; end; +procedure TMainForm.FormDropFiles(Sender: TObject; + const FileNames: array of String); +begin + if Length(FileNames) <> 1 then + Exit; + + OpenMapFile(FileNames[0]); +end; + procedure TMainForm.RenderPanelResize(Sender: TObject); begin if MainForm.Visible then @@ -5841,31 +5852,35 @@ begin if OpenDialog.Execute() then begin - if (Pos('.ini', LowerCase(ExtractFileName(OpenDialog.FileName))) > 0) then - begin // INI карты: - FullClear(); + OpenMapFile(OpenDialog.FileName); + OpenDialog.InitialDir := ExtractFileDir(OpenDialog.FileName); + end; +end; - pLoadProgress.Left := (RenderPanel.Width div 2)-(pLoadProgress.Width div 2); - pLoadProgress.Top := (RenderPanel.Height div 2)-(pLoadProgress.Height div 2); - pLoadProgress.Show(); +procedure TMainForm.OpenMapFile(FileName: String); +begin + if (Pos('.ini', LowerCase(ExtractFileName(FileName))) > 0) then + begin // INI карты: + FullClear(); - OpenedMap := ''; - OpenedWAD := ''; + pLoadProgress.Left := (RenderPanel.Width div 2)-(pLoadProgress.Width div 2); + pLoadProgress.Top := (RenderPanel.Height div 2)-(pLoadProgress.Height div 2); + pLoadProgress.Show(); - LoadMapOld(OpenDialog.FileName); + OpenedMap := ''; + OpenedWAD := ''; - MainForm.Caption := Format('%s - %s', [FormCaption, ExtractFileName(OpenDialog.FileName)]); + LoadMapOld(FileName); - pLoadProgress.Hide(); - MainForm.FormResize(Self); - end - else // Карты из WAD: - begin - OpenMap(OpenDialog.FileName, ''); - end; + MainForm.Caption := Format('%s - %s', [FormCaption, ExtractFileName(FileName)]); - OpenDialog.InitialDir := ExtractFileDir(OpenDialog.FileName); - end; + pLoadProgress.Hide(); + MainForm.FormResize(Self); + end + else // Карты из WAD: + begin + OpenMap(FileName, ''); + end; end; procedure TMainForm.FormActivate(Sender: TObject);