GIT
/
REPO
/
FRED-BOY
Projects
/
d2df-editor.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Main: Allow drop files
[d2df-editor.git]
/
src
/
editor
/
f_main.pas
diff --git
a/src/editor/f_main.pas
b/src/editor/f_main.pas
index 2b9ddee5a2a3f6a26c8311f6984b84d4655e3836..c5821c4fb5608f62e0321fdbe65fa418501d2e69 100644
(file)
--- 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 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);
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 OnIdle(Sender: TObject; var Done: Boolean);
public
procedure RefreshRecentMenu();
+ procedure OpenMapFile(FileName: String);
end;
const
end;
const
@@
-311,7
+313,7
@@
var
LayerEnabled: Array [LAYER_BACK..LAYER_TRIGGERS] of Boolean =
(True, True, True, True, True, True, True, True, True);
LayerEnabled: Array [LAYER_BACK..LAYER_TRIGGERS] of Boolean =
(True, True, True, True, True, True, True, True, True);
- PreviewMode: B
oolean = False
;
+ PreviewMode: B
yte = 0
;
gLanguage: String;
FormCaption: String;
gLanguage: String;
FormCaption: String;
@@
-435,6
+437,7
@@
var
MouseRDown: Boolean;
MouseLDownPos: Types.TPoint;
MouseRDownPos: Types.TPoint;
MouseRDown: Boolean;
MouseLDownPos: Types.TPoint;
MouseRDownPos: Types.TPoint;
+ WASDOffset: TPoint;
SelectFlag: Byte = SELECTFLAG_NONE;
MouseAction: Byte = MOUSEACTION_NONE;
SelectFlag: Byte = SELECTFLAG_NONE;
MouseAction: Byte = MOUSEACTION_NONE;
@@
-1996,6
+1999,7
@@
var
MapName: String;
idx: Integer;
begin
MapName: String;
idx: Integer;
begin
+ SelectMapForm.Caption := _lc[I_CAP_OPEN];
SelectMapForm.GetMaps(FileName);
if (FileName = OpenedWAD) and
SelectMapForm.GetMaps(FileName);
if (FileName = OpenedWAD) and
@@
-2772,7
+2776,7
@@
begin
end;
// Рисуем сетку:
end;
// Рисуем сетку:
- if DotEnable and (
not PreviewMode
) then
+ if DotEnable and (
PreviewMode = 0
) then
begin
if DotSize = 2 then
a := -1
begin
if DotSize = 2 then
a := -1
@@
-2789,7
+2793,7
@@
begin
// Превью текстуры:
if (lbTextureList.ItemIndex <> -1) and (cbPreview.Checked) and
// Превью текстуры:
if (lbTextureList.ItemIndex <> -1) and (cbPreview.Checked) and
- (not IsSpecialTextureSel()) and (
not PreviewMode
) then
+ (not IsSpecialTextureSel()) and (
PreviewMode = 0
) then
begin
if not g_GetTexture(SelectedTexture(), ID) then
g_GetTexture('NOTEXTURE', ID);
begin
if not g_GetTexture(SelectedTexture(), ID) then
g_GetTexture('NOTEXTURE', ID);
@@
-3981,8
+3985,10
@@
begin
if MouseAction = MOUSEACTION_MOVEOBJ then
begin
MoveSelectedObjects(ssShift in Shift, ssCtrl in Shift,
if MouseAction = MOUSEACTION_MOVEOBJ then
begin
MoveSelectedObjects(ssShift in Shift, ssCtrl in Shift,
- MousePos.X-LastMovePoint.X,
- MousePos.Y-LastMovePoint.Y);
+ MousePos.X-LastMovePoint.X+WASDOffset.X,
+ MousePos.Y-LastMovePoint.Y+WASDOffset.Y);
+ WASDOffset.X := 0;
+ WASDOffset.Y := 0;
end
else
// Меняем размер выделенного объекта:
end
else
// Меняем размер выделенного объекта:
@@
-3991,8
+3997,10
@@
begin
if (SelectedObjectCount = 1) and
(SelectedObjects[GetFirstSelected].Live) then
begin
if (SelectedObjectCount = 1) and
(SelectedObjects[GetFirstSelected].Live) then
begin
- dWidth := MousePos.X-LastMovePoint.X;
- dHeight := MousePos.Y-LastMovePoint.Y;
+ dWidth := MousePos.X-LastMovePoint.X+WASDOffset.X;
+ dHeight := MousePos.Y-LastMovePoint.Y+WASDOffset.Y;
+ WASDOffset.X := 0;
+ WASDOffset.Y := 0;
case ResizeType of
RESIZETYPE_VERTICAL: dWidth := 0;
case ResizeType of
RESIZETYPE_VERTICAL: dWidth := 0;
@@
-4105,6
+4113,15
@@
begin
slInvalidTextures.Free;
end;
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
procedure TMainForm.RenderPanelResize(Sender: TObject);
begin
if MainForm.Visible then
@@
-4202,17
+4219,34
@@
begin
if not (ssCtrl in Shift) then
begin
if not (ssCtrl in Shift) then
begin
+ // Быстрое превью карты:
+ if Key = Ord('E') then
+ begin
+ if PreviewMode = 0 then
+ PreviewMode := 2;
+ end;
+
// Вертикальный скролл карты:
with sbVertical do
begin
if Key = Ord('W') then
begin
// Вертикальный скролл карты:
with sbVertical do
begin
if Key = Ord('W') then
begin
+ if (MouseLDown or MouseRDown) and (Position >= DotStep) then
+ begin
+ Dec(WASDOffset.Y, DotStep);
+ RenderPanelMouseMove(Sender, Shift, LastMovePoint.X, LastMovePoint.Y);
+ end;
Position := IfThen(Position > DotStep, Position-DotStep, 0);
MapOffset.Y := -Round(Position/16) * 16;
end;
if Key = Ord('S') then
begin
Position := IfThen(Position > DotStep, Position-DotStep, 0);
MapOffset.Y := -Round(Position/16) * 16;
end;
if Key = Ord('S') then
begin
+ if (MouseLDown or MouseRDown) and (Position+DotStep <= Max) then
+ begin
+ Inc(WASDOffset.Y, DotStep);
+ RenderPanelMouseMove(Sender, Shift, LastMovePoint.X, LastMovePoint.Y);
+ end;
Position := IfThen(Position+DotStep < Max, Position+DotStep, Max);
MapOffset.Y := -Round(Position/16) * 16;
end;
Position := IfThen(Position+DotStep < Max, Position+DotStep, Max);
MapOffset.Y := -Round(Position/16) * 16;
end;
@@
-4223,12
+4257,22
@@
begin
begin
if Key = Ord('A') then
begin
begin
if Key = Ord('A') then
begin
+ if (MouseLDown or MouseRDown) and (Position >= DotStep) then
+ begin
+ Dec(WASDOffset.X, DotStep);
+ RenderPanelMouseMove(Sender, Shift, LastMovePoint.X, LastMovePoint.Y);
+ end;
Position := IfThen(Position > DotStep, Position-DotStep, 0);
MapOffset.X := -Round(Position/16) * 16;
end;
if Key = Ord('D') then
begin
Position := IfThen(Position > DotStep, Position-DotStep, 0);
MapOffset.X := -Round(Position/16) * 16;
end;
if Key = Ord('D') then
begin
+ if (MouseLDown or MouseRDown) and (Position+DotStep <= Max) then
+ begin
+ Inc(WASDOffset.X, DotStep);
+ RenderPanelMouseMove(Sender, Shift, LastMovePoint.X, LastMovePoint.Y);
+ end;
Position := IfThen(Position+DotStep < Max, Position+DotStep, Max);
MapOffset.X := -Round(Position/16) * 16;
end;
Position := IfThen(Position+DotStep < Max, Position+DotStep, Max);
MapOffset.X := -Round(Position/16) * 16;
end;
@@
-4332,6
+4376,7
@@
begin
if i > 0 then
begin
g_ProcessResourceStr(OpenedMap, @FileName, nil, nil);
if i > 0 then
begin
g_ProcessResourceStr(OpenedMap, @FileName, nil, nil);
+ SelectMapForm.Caption := _lc[I_CAP_SELECT];
SelectMapForm.GetMaps(FileName);
if SelectMapForm.ShowModal() = mrOK then
SelectMapForm.GetMaps(FileName);
if SelectMapForm.ShowModal() = mrOK then
@@
-5520,6
+5565,7
@@
begin
else if Key = _lc[I_PROP_TR_NEXT_MAP] then
begin // Выбор следующей карты:
g_ProcessResourceStr(OpenedMap, @FileName, nil, nil);
else if Key = _lc[I_PROP_TR_NEXT_MAP] then
begin // Выбор следующей карты:
g_ProcessResourceStr(OpenedMap, @FileName, nil, nil);
+ SelectMapForm.Caption := _lc[I_CAP_SELECT];
SelectMapForm.GetMaps(FileName);
if SelectMapForm.ShowModal() = mrOK then
SelectMapForm.GetMaps(FileName);
if SelectMapForm.ShowModal() = mrOK then
@@
-5806,31
+5852,35
@@
begin
if OpenDialog.Execute() then
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);
end;
procedure TMainForm.FormActivate(Sender: TObject);
@@
-5885,6
+5935,7
@@
begin
MapList := WAD.GetResourcesList('');
MapList := WAD.GetResourcesList('');
+ SelectMapForm.Caption := _lc[I_CAP_REMOVE];
SelectMapForm.lbMapList.Items.Clear();
if MapList <> nil then
SelectMapForm.lbMapList.Items.Clear();
if MapList <> nil then
@@
-6166,7
+6217,10
@@
end;
procedure TMainForm.miMapPreviewClick(Sender: TObject);
begin
procedure TMainForm.miMapPreviewClick(Sender: TObject);
begin
- if not PreviewMode then
+ if PreviewMode = 2 then
+ Exit;
+
+ if PreviewMode = 0 then
begin
Splitter2.Visible := False;
Splitter1.Visible := False;
begin
Splitter2.Visible := False;
Splitter1.Visible := False;
@@
-6189,8
+6243,8
@@
begin
sbVertical.Visible := True;
end;
sbVertical.Visible := True;
end;
- PreviewMode :=
not PreviewMode
;
- (Sender as TMenuItem).Checked := PreviewMode;
+ PreviewMode :=
PreviewMode xor 1
;
+ (Sender as TMenuItem).Checked := PreviewMode
> 0
;
FormResize(Self);
end;
FormResize(Self);
end;
@@
-6493,6
+6547,12
@@
begin
(Key = Ord('V')) then
FillProperty();
end;
(Key = Ord('V')) then
FillProperty();
end;
+// Быстрое превью карты:
+ if Key = Ord('E') then
+ begin
+ if PreviewMode = 2 then
+ PreviewMode := 0;
+ end;
end;
end.
end;
end.
DEADSOFTWARE 2012-2025