- Realigned frmRegionControl

- Added coordinate grabbing to TfrmRegionControl
- Added hints to the grab buttons in frmLargeScaleCommand
This commit is contained in:
Andreas Schneider 2009-12-19 14:39:14 +01:00
parent 387d5fb28d
commit a9f278ae21
3 changed files with 1348 additions and 1193 deletions

View File

@ -1084,7 +1084,7 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = btnDeleteArea AnchorSideBottom.Control = btnDeleteArea
Left = 4 Left = 4
Height = 118 Height = 122
Top = 154 Top = 154
Width = 144 Width = 144
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
@ -1209,10 +1209,8 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand
Top = 280 Top = 280
Width = 22 Width = 22
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
BorderSpacing.Left = 4 BorderSpacing.Bottom = 4
BorderSpacing.Top = 8 BorderSpacing.Around = 4
BorderSpacing.Right = 4
BorderSpacing.Bottom = 8
Color = clBtnFace Color = clBtnFace
Glyph.Data = { Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100 36040000424D3604000000000000360000002800000010000000100000000100
@ -1394,6 +1392,7 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 34 Left = 34
Height = 22 Height = 22
Hint = 'Grab coordinates from the main window.'
Top = 360 Top = 360
Width = 22 Width = 22
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
@ -1438,6 +1437,8 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand
} }
NumGlyphs = 0 NumGlyphs = 0
OnClick = btnGrab1Click OnClick = btnGrab1Click
ShowHint = True
ParentShowHint = False
end end
object btnGrab2: TSpeedButton object btnGrab2: TSpeedButton
AnchorSideLeft.Control = seY2 AnchorSideLeft.Control = seY2
@ -1446,6 +1447,7 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 92 Left = 92
Height = 22 Height = 22
Hint = 'Grab coordinates from the main window.'
Top = 360 Top = 360
Width = 22 Width = 22
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
@ -1489,5 +1491,7 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand
} }
NumGlyphs = 0 NumGlyphs = 0
OnClick = btnGrab1Click OnClick = btnGrab1Click
ShowHint = True
ParentShowHint = False
end end
end end

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,7 @@
* CDDL HEADER END * CDDL HEADER END
* *
* *
* Portions Copyright 2008 Andreas Schneider * Portions Copyright 2009 Andreas Schneider
*) *)
unit UfrmRegionControl; unit UfrmRegionControl;
@ -32,7 +32,7 @@ interface
uses uses
Classes, SysUtils, math, LResources, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, math, LResources, Forms, Controls, Graphics, Dialogs,
VirtualTrees, ExtCtrls, ImagingComponents, StdCtrls, Buttons, Spin, LCLIntf, VirtualTrees, ExtCtrls, ImagingComponents, StdCtrls, Buttons, Spin, LCLIntf,
UEnhancedMemoryStream, Menus, URectList, UEnums; UEnhancedMemoryStream, Menus, URectList, UEnums, UWorldItem;
type type
TAreaMoveType = (amLeft, amTop, amRight, amBottom); TAreaMoveType = (amLeft, amTop, amRight, amBottom);
@ -54,32 +54,28 @@ type
btnAddArea: TSpeedButton; btnAddArea: TSpeedButton;
btnAddRegion: TSpeedButton; btnAddRegion: TSpeedButton;
btnClearArea: TSpeedButton; btnClearArea: TSpeedButton;
btnDeleteArea: TSpeedButton;
btnClose: TButton; btnClose: TButton;
btnDeleteArea: TSpeedButton;
btnDeleteRegion: TSpeedButton; btnDeleteRegion: TSpeedButton;
btnSave: TButton; btnSave: TButton;
Label1: TLabel; Label1: TLabel;
lblX: TLabel; lblX: TLabel;
lblY: TLabel; lblY: TLabel;
mnuAddRegion: TMenuItem; mnuAddRegion: TMenuItem;
mnuDeleteRegion: TMenuItem; mnuDeleteRegion: TMenuItem;
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
Panel5: TPanel;
pbArea: TPaintBox; pbArea: TPaintBox;
pnlAreaControls: TPanel;
pmRegions: TPopupMenu; pmRegions: TPopupMenu;
sbArea: TScrollBox; sbArea: TScrollBox;
seX1: TSpinEdit; seX1: TSpinEdit;
seX2: TSpinEdit; seX2: TSpinEdit;
seY1: TSpinEdit; seY1: TSpinEdit;
seY2: TSpinEdit; seY2: TSpinEdit;
btnGrab1: TSpeedButton;
btnGrab2: TSpeedButton;
spRegionsArea: TSplitter; spRegionsArea: TSplitter;
vstArea: TVirtualStringTree; vstArea: TVirtualStringTree;
vstRegions: TVirtualStringTree; vstRegions: TVirtualStringTree;
procedure btnGrab1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure mnuAddRegionClick(Sender: TObject); procedure mnuAddRegionClick(Sender: TObject);
procedure mnuDeleteRegionClick(Sender: TObject); procedure mnuDeleteRegionClick(Sender: TObject);
@ -93,8 +89,8 @@ type
procedure FormShow(Sender: TObject); procedure FormShow(Sender: TObject);
procedure pbAreaMouseDown(Sender: TObject; Button: TMouseButton; procedure pbAreaMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer); Shift: TShiftState; X, Y: Integer);
procedure pbAreaMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer procedure pbAreaMouseMove(Sender: TObject; Shift: TShiftState; X,
); Y: Integer);
procedure pbAreaPaint(Sender: TObject); procedure pbAreaPaint(Sender: TObject);
procedure seX1Change(Sender: TObject); procedure seX1Change(Sender: TObject);
procedure vstAreaChange(Sender: TBaseVirtualTree; Node: PVirtualNode); procedure vstAreaChange(Sender: TBaseVirtualTree; Node: PVirtualNode);
@ -112,12 +108,15 @@ type
FOnRegionModified: TRegionModifiedEvent; FOnRegionModified: TRegionModifiedEvent;
FOnRegionDeleted: TRegionDeletedEvent; FOnRegionDeleted: TRegionDeletedEvent;
FOnRegionList: TRegionListEvent; FOnRegionList: TRegionListEvent;
FSelectFirst: Boolean;
FOldWindowState: TWindowState;
function FindRegion(AName: string): PVirtualNode; function FindRegion(AName: string): PVirtualNode;
procedure CheckUnsaved; procedure CheckUnsaved;
procedure OnModifyRegionPacket(ABuffer: TEnhancedMemoryStream); procedure OnModifyRegionPacket(ABuffer: TEnhancedMemoryStream);
procedure OnDeleteRegionPacket(ABuffer: TEnhancedMemoryStream); procedure OnDeleteRegionPacket(ABuffer: TEnhancedMemoryStream);
procedure OnListRegionsPacket(ABuffer: TEnhancedMemoryStream); procedure OnListRegionsPacket(ABuffer: TEnhancedMemoryStream);
procedure OnAccessChanged(AAccessLevel: TAccessLevel); procedure OnAccessChanged(AAccessLevel: TAccessLevel);
procedure TileSelected(AWorldItem: TWorldItem);
public public
property OnRegionModified: TRegionModifiedEvent read FOnRegionModified write FOnRegionModified; property OnRegionModified: TRegionModifiedEvent read FOnRegionModified write FOnRegionModified;
property OnRegionDeleted: TRegionDeletedEvent read FOnRegionDeleted write FOnRegionDeleted; property OnRegionDeleted: TRegionDeletedEvent read FOnRegionDeleted write FOnRegionDeleted;
@ -221,9 +220,9 @@ end;
procedure TfrmRegionControl.FormDestroy(Sender: TObject); procedure TfrmRegionControl.FormDestroy(Sender: TObject);
begin begin
frmRadarMap.Dependencies.Remove(pbArea); frmRadarMap.Dependencies.Remove(pbArea);
if AdminPacketHandlers[$08] <> nil then FreeAndNil(AdminPacketHandlers[$08]); FreeAndNil(AdminPacketHandlers[$08]);
if AdminPacketHandlers[$09] <> nil then FreeAndNil(AdminPacketHandlers[$09]); FreeAndNil(AdminPacketHandlers[$09]);
if AdminPacketHandlers[$0A] <> nil then FreeAndNil(AdminPacketHandlers[$0A]); FreeAndNil(AdminPacketHandlers[$0A]);
end; end;
procedure TfrmRegionControl.FormShow(Sender: TObject); procedure TfrmRegionControl.FormShow(Sender: TObject);
@ -302,6 +301,15 @@ begin
CheckUnsaved; CheckUnsaved;
end; end;
procedure TfrmRegionControl.btnGrab1Click(Sender: TObject);
begin
FSelectFirst := (Sender = btnGrab1);
frmMain.RegisterSelectionListener(@TileSelected);
FOldWindowState := WindowState;
WindowState := wsMinimized;
frmMain.SwitchToSelection;
end;
procedure TfrmRegionControl.mnuDeleteRegionClick(Sender: TObject); procedure TfrmRegionControl.mnuDeleteRegionClick(Sender: TObject);
var var
regionNode: PVirtualNode; regionNode: PVirtualNode;
@ -481,6 +489,8 @@ begin
seX2.Enabled := selected; seX2.Enabled := selected;
seY1.Enabled := selected; seY1.Enabled := selected;
seY2.Enabled := selected; seY2.Enabled := selected;
btnGrab1.Enabled := selected;
btnGrab2.Enabled := selected;
if selected then if selected then
begin begin
areaInfo := Sender.GetNodeData(Node); areaInfo := Sender.GetNodeData(Node);
@ -708,6 +718,22 @@ begin
dmNetwork.Send(TRequestRegionListPacket.Create); dmNetwork.Send(TRequestRegionListPacket.Create);
end; end;
procedure TfrmRegionControl.TileSelected(AWorldItem: TWorldItem);
begin
if FSelectFirst then
begin
seX1.Value := AWorldItem.X;
seY1.Value := AWorldItem.Y;
end else
begin
seX2.Value := AWorldItem.X;
seY2.Value := AWorldItem.Y;
end;
frmMain.UnregisterSelectionListener(@TileSelected);
WindowState := FOldWindowState;
seX1Change(nil);
end;
initialization initialization
{$I UfrmRegionControl.lrs} {$I UfrmRegionControl.lrs}