X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Feditor%2Ff_main.pas;h=070939d11262449427ddd618720d851addd242b1;hb=797ba76501e5360f4d02d6aade613dc529a24213;hp=8158c03344f380660a7de069841ce8357aedb984;hpb=04aa8dddb3c22e6b48c1de5328e5c85514b89970;p=d2df-editor.git diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas index 8158c03..070939d 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 @@ -293,6 +295,7 @@ var DrawPanelSize: Boolean; BackColor: TColor; PreviewColor: TColor; + UseCheckerboard: Boolean; Scale: Byte; RecentCount: Integer; RecentFiles: TStringList; @@ -435,6 +438,7 @@ var MouseRDown: Boolean; MouseLDownPos: Types.TPoint; MouseRDownPos: Types.TPoint; + WASDOffset: TPoint; SelectFlag: Byte = SELECTFLAG_NONE; MouseAction: Byte = MOUSEACTION_NONE; @@ -2652,6 +2656,7 @@ begin DrawPanelSize := config.ReadBool('Editor', 'DrawPanelSize', True); BackColor := config.ReadInt('Editor', 'BackColor', $7F6040); PreviewColor := config.ReadInt('Editor', 'PreviewColor', $00FF00); + UseCheckerboard := config.ReadBool('Editor', 'UseCheckerboard', True); gColorEdge := config.ReadInt('Editor', 'EdgeColor', COLOR_EDGE); gAlphaEdge := config.ReadInt('Editor', 'EdgeAlpha', ALPHA_EDGE); if gAlphaEdge = 255 then @@ -2795,8 +2800,14 @@ begin if not g_GetTexture(SelectedTexture(), ID) then g_GetTexture('NOTEXTURE', ID); g_GetTextureSizeByID(ID, Width, Height); - if g_GetTexture('PREVIEW', PID) then - e_DrawFill(PID, RenderPanel.Width-Width, RenderPanel.Height-Height, Width div 16 + 1, Height div 16 + 1, 0, True, False); + if UseCheckerboard then + begin + if g_GetTexture('PREVIEW', PID) then + e_DrawFill(PID, RenderPanel.Width-Width, RenderPanel.Height-Height, Width div 16 + 1, Height div 16 + 1, 0, True, False); + end else + e_DrawFillQuad(RenderPanel.Width-Width-2, RenderPanel.Height-Height-2, + RenderPanel.Width-1, RenderPanel.Height-1, + GetRValue(PreviewColor), GetGValue(PreviewColor), GetBValue(PreviewColor), 0); e_Draw(ID, RenderPanel.Width-Width, RenderPanel.Height-Height, 0, True, False); end; @@ -3982,8 +3993,10 @@ begin 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 // Меняем размер выделенного объекта: @@ -3992,8 +4005,10 @@ 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; @@ -4106,6 +4121,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 @@ -4215,12 +4239,22 @@ begin 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 + 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; @@ -4231,12 +4265,22 @@ 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 + 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; @@ -5816,31 +5860,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);