From 3ffe710c31add96d152f557e723df3c68c51eec8 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 21 Dec 2009 19:07:07 +0100 Subject: [PATCH] - Added "select offset" button/functionality to frmLargeScaleCommand (fixes #56) - Fixed frmFilter placement (fixes #57) --- Client/Tools/UfrmFilter.pas | 4 +- Client/UfrmLargeScaleCommand.lfm | 97 ++++++++++++++++++++++++++++---- Client/UfrmLargeScaleCommand.pas | 53 ++++++++++++++++- 3 files changed, 141 insertions(+), 13 deletions(-) diff --git a/Client/Tools/UfrmFilter.pas b/Client/Tools/UfrmFilter.pas index 65aa14a..bc4e92c 100644 --- a/Client/Tools/UfrmFilter.pas +++ b/Client/Tools/UfrmFilter.pas @@ -116,8 +116,8 @@ begin upperLeft := frmMain.pcLeft.ClientToScreen(Point(frmMain.pcLeft.Width, 0)); lowerLeft := frmMain.pcLeft.ClientToScreen(Point(frmMain.pcLeft.Width, frmMain.pcLeft.Height)); - Left := upperLeft.x - 4; - Top := upperLeft.y - 4; + Left := upperLeft.x - 8; + Top := upperLeft.y - 8; Height := lowerLeft.y - upperLeft.y; SetWindowParent(Handle, frmMain.Handle); diff --git a/Client/UfrmLargeScaleCommand.lfm b/Client/UfrmLargeScaleCommand.lfm index bccba11..0864105 100644 --- a/Client/UfrmLargeScaleCommand.lfm +++ b/Client/UfrmLargeScaleCommand.lfm @@ -28,20 +28,20 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand Top = 0 Width = 468 Anchors = [akTop, akLeft, akRight, akBottom] - PageIndex = 0 + PageIndex = 1 ShowTabs = False TabOrder = 0 object pgArea: TPage Caption = 'pgArea' ClientWidth = 462 - ClientHeight = 343 + ClientHeight = 316 object sbArea: TScrollBox Left = 0 - Height = 343 + Height = 316 Top = 0 Width = 462 Align = alClient - ClientHeight = 341 + ClientHeight = 314 ClientWidth = 460 TabOrder = 0 object pbArea: TPaintBox @@ -58,7 +58,7 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand object pgCopyMove: TPage Caption = 'Copy/Move' ClientWidth = 462 - ClientHeight = 316 + ClientHeight = 343 object rgCMAction: TRadioGroup AnchorSideLeft.Control = pgCopyMove AnchorSideTop.Control = pgCopyMove @@ -126,14 +126,15 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand AnchorSideLeft.Control = Label9 AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = gbCMOffset - AnchorSideRight.Control = gbCMOffset - AnchorSideRight.Side = asrBottom + AnchorSideRight.Control = btnGrabOffset Left = 27 Height = 19 Top = 8 - Width = 82 + Width = 62 Anchors = [akTop, akLeft, akRight] - BorderSpacing.Around = 8 + BorderSpacing.Top = 4 + BorderSpacing.Bottom = 4 + BorderSpacing.Around = 4 TabOrder = 0 end object seCMOffsetY: TSpinEdit @@ -145,10 +146,66 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand Left = 27 Height = 19 Top = 35 - Width = 82 + Width = 62 Anchors = [akTop, akLeft, akRight] + BorderSpacing.Bottom = 8 TabOrder = 1 end + object btnGrabOffset: TSpeedButton + AnchorSideTop.Control = gbCMOffset + AnchorSideTop.Side = asrCenter + AnchorSideRight.Control = gbCMOffset + AnchorSideRight.Side = asrBottom + Left = 93 + Height = 22 + Hint = 'Grab coordinates and calculate the offset in relation to the selected area.' + Top = 22 + Width = 22 + Anchors = [akTop, akRight] + BorderSpacing.Around = 4 + Color = clBtnFace + Enabled = False + Glyph.Data = { + 36040000424D3604000000000000360000002800000010000000100000000100 + 2000000000000004000064000000640000000000000000000000FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF007F7F7F067C7C + 7CE6787878CC75757581FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF008383835DAAAA + AAFFDBDBDBFF797979F275757506FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF0097979709FFFFFF00FFFFFF00FFFFFF00888888E7DBDB + DBFFB7B7B7FF7D7D7D80FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF009C9C9CC99898981EFFFFFF0090909050ADADADFFF2F2 + F2FF848484FD8181810FFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00A0A0A0FF9C9C9CE798989836949494DFD9D9D9FFC1C1 + C1FF898989A0FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00A4A4A4FFD7D7D7FF9D9D9DF8D0D0D0FFEEEEEEFF9191 + 91FE8D8D8D18FFFFFF00FFFFFF00818181097E7E7E09FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00A9A9A9FFF2F2F2FFE5E5E5FFE2E2E2FFE3E3E3FF9595 + 95F4919191CC8D8D8DF9898989FF86868693FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00ADADADFFEEEEEEFFE1E1E1FFDFDFDFFFE0E0E0FFE7E7 + E7FFE4E4E4FFBBBBBBFF8E8E8E93FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00B1B1B1FFF0F0F0FFE4E4E4FFE2E2E2FFE2E2E2FFE7E7 + E7FFC1C1C1FF96969690FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00B5B5B5FFF2F2F2FFE8E8E8FFE7E7E7FFEAEAEAFFC6C6 + C6FF9E9E9E8DFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00B9B9B9FFF4F4F4FFECECECFFEDEDEDFFCBCBCBFFA7A7 + A78AFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00BDBDBDFFF7F7F7FFEFEFEFFFD0D0D0FFAFAFAF8AFFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00C1C1C1FFF7F7F7FFD5D5D5FFB6B6B687FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00C4C4C4FFD9D9D9FFBEBEBE84FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00C8C8C8FFC5C5C581FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00CBCBCB7EFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00 + } + NumGlyphs = 0 + OnClick = btnGrabOffsetClick + ShowHint = True + ParentShowHint = False + end end object cbCMEraseTarget: TCheckBox AnchorSideLeft.Control = gbCMOffset @@ -1493,4 +1550,24 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand ShowHint = True ParentShowHint = False end + object pmSelectOffset: TPopupMenu + left = 421 + top = 82 + object mnuSelectTopLeft: TMenuItem + Caption = 'Select Top-Left Corner' + OnClick = mnuSelectTopLeftClick + end + object mnuSelectTopRight: TMenuItem + Caption = 'Select Top-Right Corner' + OnClick = mnuSelectTopLeftClick + end + object mnuSelectBottomLeft: TMenuItem + Caption = 'Select Bottom-Left Corner' + OnClick = mnuSelectTopLeftClick + end + object mnuSelectBottomRight: TMenuItem + Caption = 'Select Bottom-Right Corner' + OnClick = mnuSelectTopLeftClick + end + end end diff --git a/Client/UfrmLargeScaleCommand.pas b/Client/UfrmLargeScaleCommand.pas index 9eb675a..fe64221 100644 --- a/Client/UfrmLargeScaleCommand.pas +++ b/Client/UfrmLargeScaleCommand.pas @@ -32,7 +32,7 @@ interface uses Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Math, VirtualTrees, ExtCtrls, ImagingComponents, StdCtrls, Buttons, Spin, LCLIntf, - UPlatformTypes, UEnhancedMemoryStream, UWorldItem; + Menus, UPlatformTypes, UEnhancedMemoryStream, UWorldItem; type @@ -76,6 +76,10 @@ type lblInsertStaticsTiles: TLabel; lblX: TLabel; lblY: TLabel; + mnuSelectTopLeft: TMenuItem; + mnuSelectTopRight: TMenuItem; + mnuSelectBottomLeft: TMenuItem; + mnuSelectBottomRight: TMenuItem; nbActions: TNotebook; pgCopyMove: TPage; pgDeleteStatics: TPage; @@ -84,6 +88,7 @@ type pbArea: TPaintBox; pgArea: TPage; pgDrawTerrain: TPage; + pmSelectOffset: TPopupMenu; rgCMAction: TRadioGroup; rbPlaceStaticsOnTerrain: TRadioButton; rbPlaceStaticsOnTop: TRadioButton; @@ -106,12 +111,14 @@ type seY2: TSpinEdit; btnGrab1: TSpeedButton; btnGrab2: TSpeedButton; + btnGrabOffset: TSpeedButton; vdtTerrainTiles: TVirtualDrawTree; vdtInsertStaticsTiles: TVirtualDrawTree; vdtDeleteStaticsTiles: TVirtualDrawTree; vstActions: TVirtualStringTree; vstArea: TVirtualStringTree; procedure btnGrab1Click(Sender: TObject); + procedure btnGrabOffsetClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure btnAddAreaClick(Sender: TObject); procedure btnClearDStaticsTilesClick(Sender: TObject); @@ -124,6 +131,7 @@ type procedure btnExecuteClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); + procedure mnuSelectTopLeftClick(Sender: TObject); procedure pbAreaMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure pbAreaMouseMove(Sender: TObject; Shift: TShiftState; X, @@ -162,10 +170,12 @@ type FDelStaticsNode: PVirtualNode; FAddStaticsNode: PVirtualNode; FSelectFirst: Boolean; + FOffsetSelection: TObject; FOldWindowState: TWindowState; function AddNode(AActionID: Integer; ACaption: String): PVirtualNode; function FindNode(AActionID: Integer): PVirtualNode; procedure TileSelection(AWorldItem: TWorldItem); + procedure OffsetSelection(AWorldItem: TWorldItem); procedure SerializeTiles(ATileList: TVirtualDrawTree; AStream: TEnhancedMemoryStream); public @@ -231,6 +241,15 @@ begin frmRadarMap.Dependencies.Remove(pbArea); end; +procedure TfrmLargeScaleCommand.mnuSelectTopLeftClick(Sender: TObject); +begin + FOffsetSelection := Sender; + frmMain.RegisterSelectionListener(@OffsetSelection); + FOldWindowState := WindowState; + WindowState := wsMinimized; + frmMain.SwitchToSelection; +end; + procedure TfrmLargeScaleCommand.pbAreaMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var @@ -323,6 +342,11 @@ begin frmMain.SwitchToSelection; end; +procedure TfrmLargeScaleCommand.btnGrabOffsetClick(Sender: TObject); +begin + pmSelectOffset.PopUp; +end; + procedure TfrmLargeScaleCommand.btnClearDStaticsTilesClick(Sender: TObject); begin vdtDeleteStaticsTiles.Clear; @@ -638,6 +662,7 @@ begin seY2.Enabled := selected; btnGrab1.Enabled := selected; btnGrab2.Enabled := selected; + btnGrabOffset.Enabled := selected; if selected then begin nodeInfo := Sender.GetNodeData(Node); @@ -708,6 +733,32 @@ begin WindowState := FOldWindowState; end; +procedure TfrmLargeScaleCommand.OffsetSelection(AWorldItem: TWorldItem); +begin + if FOffsetSelection = mnuSelectTopLeft then + begin + seCMOffsetX.Value := AWorldItem.X - Min(seX1.Value, seX2.Value); + seCMOffsetY.Value := AWorldItem.Y - Min(seY1.Value, seY2.Value); + end else + if FOffsetSelection = mnuSelectTopRight then + begin + seCMOffsetX.Value := AWorldItem.X - Max(seX1.Value, seX2.Value); + seCMOffsetY.Value := AWorldItem.Y - Min(seY1.Value,seY2.Value); + end else + if FOffsetSelection = mnuSelectBottomLeft then + begin + seCMOffsetX.Value := AWorldItem.X - Min(seX1.Value, seX2.Value); + seCMOffsetY.Value := AWorldItem.Y - Max(seY1.Value, seY2.Value); + end else + if FOffsetSelection = mnuSelectBottomRight then + begin + seCMOffsetX.Value := AWorldItem.X - Max(seX1.Value, seX2.Value); + seCMOffsetY.Value := AWorldItem.Y - Max(seY1.Value, seY2.Value); + end; + frmMain.UnregisterSelectionListener(@OffsetSelection); + WindowState := FOldWindowState; +end; + procedure TfrmLargeScaleCommand.SerializeTiles(ATileList: TVirtualDrawTree; AStream: TEnhancedMemoryStream); var