diff --git a/Client/CentrED.lpi b/Client/CentrED.lpi index 02c97c4..ca7ca5c 100644 --- a/Client/CentrED.lpi +++ b/Client/CentrED.lpi @@ -40,7 +40,7 @@ - + @@ -164,6 +164,7 @@ + @@ -218,6 +219,16 @@ + + + + + + + + + + diff --git a/Client/CentrED.lpr b/Client/CentrED.lpr index 21b295f..3def0b4 100644 --- a/Client/CentrED.lpr +++ b/Client/CentrED.lpr @@ -38,7 +38,8 @@ uses UfrmElevateSettings, UOverlayUI, UResourceManager, UfrmConfirmation, UfrmMoveSettings, UfrmAbout, UfrmHueSettings, UfrmRadar, UfrmLargeScaleCommand, UfrmVirtualLayer, UfrmFilter, UfrmTileInfo, - UGUIPlatformUtils, UPlatformTypes, UfrmRegionControl; + UGUIPlatformUtils, UPlatformTypes, UfrmRegionControl, UPackets, + UPacketHandlers; {$IFDEF Windows} {$R *.res} diff --git a/Client/Tools/UfrmFilter.lfm b/Client/Tools/UfrmFilter.lfm index 0c5dee7..92fbce8 100644 --- a/Client/Tools/UfrmFilter.lfm +++ b/Client/Tools/UfrmFilter.lfm @@ -11,6 +11,7 @@ object frmFilter: TfrmFilter ClientWidth = 236 Font.Height = -11 OnCreate = FormCreate + OnDestroy = FormDestroy OnShow = FormShow LCLVersion = '0.9.25' object rgFilterType: TRadioGroup @@ -56,7 +57,7 @@ object frmFilter: TfrmFilter object Label1: TLabel Left = 4 Height = 28 - Top = 29 + Top = 28 Width = 216 Align = alTop BorderSpacing.Around = 4 @@ -69,15 +70,14 @@ object frmFilter: TfrmFilter Tag = 1 Cursor = 63 Left = 4 - Height = 151 - Top = 61 + Height = 152 + Top = 60 Width = 216 Align = alClient BorderSpacing.Around = 4 BorderStyle = bsSingle DefaultNodeHeight = 44 DragType = dtVCL - Header.Font.Height = -11 Header.Options = [hoColumnResize, hoDrag, hoVisible] Header.ParentFont = True Header.Style = hsFlatButtons @@ -214,7 +214,7 @@ object frmFilter: TfrmFilter end object cbTileFilter: TCheckBox Left = 4 - Height = 21 + Height = 20 Top = 4 Width = 216 Align = alTop @@ -240,7 +240,7 @@ object frmFilter: TfrmFilter TabOrder = 2 object cbHueFilter: TCheckBox Left = 4 - Height = 21 + Height = 20 Top = 4 Width = 216 Align = alTop @@ -252,14 +252,13 @@ object frmFilter: TfrmFilter object vdtHues: TVirtualDrawTree Cursor = 63 Left = 4 - Height = 118 - Top = 29 + Height = 119 + Top = 28 Width = 216 Align = alClient BorderSpacing.Around = 4 BorderStyle = bsSingle Header.AutoSizeIndex = 2 - Header.Font.Height = -11 Header.Options = [hoAutoResize, hoColumnResize, hoDrag, hoVisible] Header.ParentFont = True Header.Style = hsFlatButtons diff --git a/Client/Tools/UfrmFilter.pas b/Client/Tools/UfrmFilter.pas index 788daa2..9c59904 100644 --- a/Client/Tools/UfrmFilter.pas +++ b/Client/Tools/UfrmFilter.pas @@ -61,6 +61,7 @@ type procedure btnClearClick(Sender: TObject); procedure btnDeleteClick(Sender: TObject); procedure FormCreate(Sender: TObject); + procedure FormDestroy(Sender: TObject); procedure FormShow(Sender: TObject); procedure mnuUncheckHuesClick(Sender: TObject); procedure mnuCheckHuesClick(Sender: TObject); @@ -308,6 +309,11 @@ begin //FCheckedHues.Bits[0] := True; end; +procedure TfrmFilter.FormDestroy(Sender: TObject); +begin + if FCheckedHues <> nil then FreeAndNil(FCheckedHues); +end; + procedure TfrmFilter.btnDeleteClick(Sender: TObject); begin vdtFilter.DeleteSelectedNodes; diff --git a/Client/UfrmAccountControl.lfm b/Client/UfrmAccountControl.lfm index df38592..2fb7491 100644 --- a/Client/UfrmAccountControl.lfm +++ b/Client/UfrmAccountControl.lfm @@ -77,7 +77,6 @@ object frmAccountControl: TfrmAccountControl Width = 369 Align = alClient Header.AutoSizeIndex = 1 - Header.Font.Height = -11 Header.Options = [hoColumnResize, hoDrag, hoVisible] Header.ParentFont = True Header.Style = hsPlates @@ -89,6 +88,7 @@ object frmAccountControl: TfrmAccountControl TreeOptions.PaintOptions = [toShowButtons, toShowDropmark, toThemeAware, toUseBlendedImages] TreeOptions.SelectionOptions = [toFullRowSelect] OnDblClick = vstAccountsDblClick + OnFreeNode = vstAccountsFreeNode OnGetText = vstAccountsGetText OnGetImageIndex = vstAccountsGetImageIndex Columns = < diff --git a/Client/UfrmAccountControl.pas b/Client/UfrmAccountControl.pas index 9a2434b..c4da68b 100644 --- a/Client/UfrmAccountControl.pas +++ b/Client/UfrmAccountControl.pas @@ -56,6 +56,7 @@ type procedure tbDeleteUserClick(Sender: TObject); procedure tbRefreshClick(Sender: TObject); procedure vstAccountsDblClick(Sender: TObject); + procedure vstAccountsFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode); procedure vstAccountsGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex; var Ghosted: Boolean; var ImageIndex: Integer); @@ -83,6 +84,7 @@ type TAccountInfo = record Username: string; AccessLevel: TAccessLevel; + Regions: TStringList; end; { TModifyUserPacket } @@ -226,6 +228,16 @@ begin tbEditUserClick(Sender); end; +procedure TfrmAccountControl.vstAccountsFreeNode(Sender: TBaseVirtualTree; + Node: PVirtualNode); +var + accountInfo: PAccountInfo; +begin + accountInfo := vstAccounts.GetNodeData(Node); + accountInfo^.Username := ''; + if accountInfo^.Regions <> nil then FreeAndNil(accountInfo^.Regions); +end; + procedure TfrmAccountControl.vstAccountsGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex; var Ghosted: Boolean; var ImageIndex: Integer); @@ -265,6 +277,7 @@ var modifyStatus: TModifyUserStatus; username: string; accountInfo: PAccountInfo; + i, regions: Integer; begin modifyStatus := TModifyUserStatus(ABuffer.ReadByte); username := ABuffer.ReadStringNull; @@ -275,6 +288,11 @@ begin accountInfo := vstAccounts.GetNodeData(node); accountInfo^.Username := username; accountInfo^.AccessLevel := TAccessLevel(ABuffer.ReadByte); + accountInfo^.Regions := TStringList.Create; + regions := ABuffer.ReadByte; + for i := 0 to regions - 1 do + accountInfo^.Regions.Add(ABuffer.ReadStringNull); + Messagedlg('Success', Format('The user "%s" has been added.', [username]), mtInformation, [mbOK], 0); end; @@ -285,6 +303,11 @@ begin begin accountInfo := vstAccounts.GetNodeData(node); accountInfo^.AccessLevel := TAccessLevel(ABuffer.ReadByte); + accountInfo^.Regions.Clear; + regions := ABuffer.ReadByte; + for i := 0 to regions - 1 do + accountInfo^.Regions.Add(ABuffer.ReadStringNull); + Messagedlg('Success', Format('The user "%s" has been modified.', [username]), mtInformation, [mbOK], 0); end; @@ -325,7 +348,7 @@ procedure TfrmAccountControl.OnListUsersPacket(ABuffer: TEnhancedMemoryStream); var node: PVirtualNode; accountInfo: PAccountInfo; - i, count: Word; + i, j, count, regions: Word; begin vstAccounts.BeginUpdate; vstAccounts.Clear; @@ -336,6 +359,10 @@ begin accountInfo := vstAccounts.GetNodeData(node); accountInfo^.Username := ABuffer.ReadStringNull; accountInfo^.AccessLevel := TAccessLevel(ABuffer.ReadByte); + accountInfo^.Regions := TStringList.Create; + regions := ABuffer.ReadByte; + for j := 0 to regions - 1 do + accountInfo^.Regions.Add(ABuffer.ReadStringNull); end; vstAccounts.EndUpdate; end; diff --git a/Client/UfrmEditAccount.lfm b/Client/UfrmEditAccount.lfm index 6a5e54d..eaef55f 100644 --- a/Client/UfrmEditAccount.lfm +++ b/Client/UfrmEditAccount.lfm @@ -1,115 +1,180 @@ object frmEditAccount: TfrmEditAccount Left = 290 - Height = 186 + Height = 214 Top = 171 - Width = 266 - ActiveControl = edUsername + Width = 261 + ActiveControl = PageControl1 BorderIcons = [biSystemMenu] BorderStyle = bsDialog Caption = 'Edit Account' - ClientHeight = 186 - ClientWidth = 266 + ClientHeight = 214 + ClientWidth = 261 Font.Height = -11 Position = poOwnerFormCenter LCLVersion = '0.9.25' - object lblPasswordHint: TLabel - Left = 96 - Height = 28 - Top = 72 - Width = 160 - AutoSize = False - Caption = 'Leave empty to leave the password unchanged.' - Enabled = False - ParentColor = False - ParentFont = True - WordWrap = True - end - object lblUsername: TLabel - Left = 16 - Height = 14 - Top = 20 - Width = 58 - Caption = 'Username:' - ParentColor = False - ParentFont = True - end - object lblPassword: TLabel - Left = 16 - Height = 14 - Top = 52 - Width = 54 - Caption = 'Password:' - ParentColor = False - ParentFont = True - end - object lblAccessLevel: TLabel - Left = 16 - Height = 14 - Top = 116 - Width = 63 - Caption = 'Accesslevel:' - ParentColor = False - ParentFont = True - end - object btnOK: TButton - Left = 93 - Height = 25 - Top = 152 - Width = 75 - BorderSpacing.InnerBorder = 4 - Caption = 'OK' - Default = True - ModalResult = 1 + object PageControl1: TPageControl + Height = 173 + Width = 261 + ActivePage = tsGeneral + Align = alClient ParentFont = True + TabIndex = 0 TabOrder = 0 + object tsGeneral: TTabSheet + Caption = 'General' + ClientHeight = 142 + ClientWidth = 257 + ParentFont = True + object lblPasswordHint: TLabel + Left = 86 + Height = 28 + Top = 64 + Width = 160 + AutoSize = False + Caption = 'Leave empty to leave the password unchanged.' + Enabled = False + ParentColor = False + ParentFont = True + WordWrap = True + end + object lblUsername: TLabel + Left = 6 + Height = 13 + Top = 12 + Width = 64 + Caption = 'Username:' + ParentColor = False + ParentFont = True + end + object lblPassword: TLabel + Left = 6 + Height = 13 + Top = 44 + Width = 61 + Caption = 'Password:' + ParentColor = False + ParentFont = True + end + object lblAccessLevel: TLabel + Left = 6 + Height = 13 + Top = 108 + Width = 71 + Caption = 'Accesslevel:' + ParentColor = False + ParentFont = True + end + object edUsername: TEdit + Left = 86 + Height = 23 + Top = 8 + Width = 160 + Color = clBtnFace + ParentFont = True + ReadOnly = True + TabOrder = 0 + end + object edPassword: TEdit + Left = 86 + Height = 23 + Top = 40 + Width = 160 + EchoMode = emPassword + ParentFont = True + PasswordChar = '*' + TabOrder = 1 + end + object cbAccessLevel: TComboBox + Left = 86 + Height = 23 + Top = 104 + Width = 160 + AutoCompleteText = [cbactEndOfLineComplete, cbactSearchAscending] + Items.Strings = ( + 'None' + 'Viewer' + 'Normal' + 'Administrator' + ) + MaxLength = 0 + ParentFont = True + Style = csDropDownList + TabOrder = 2 + end + end + object tsRegions: TTabSheet + Caption = 'Regions' + ClientHeight = 142 + ClientWidth = 257 + ParentFont = True + object Label1: TLabel + Left = 8 + Height = 13 + Top = 8 + Width = 241 + Align = alTop + BorderSpacing.Left = 8 + BorderSpacing.Top = 8 + BorderSpacing.Right = 8 + BorderSpacing.Bottom = 4 + Caption = 'Allowed Regions:' + ParentColor = False + ParentFont = True + end + object CheckListBox1: TCheckListBox + Left = 8 + Height = 109 + Top = 25 + Width = 241 + Align = alClient + BorderSpacing.Left = 8 + BorderSpacing.Top = 4 + BorderSpacing.Right = 8 + BorderSpacing.Bottom = 8 + ItemHeight = 10 + ParentFont = True + TabOrder = 0 + TopIndex = -1 + end + end end - object btnCancel: TButton - Left = 181 + object Panel1: TPanel + Left = 8 Height = 25 - Top = 152 - Width = 75 - BorderSpacing.InnerBorder = 4 - Cancel = True - Caption = 'Cancel' - ModalResult = 2 + Top = 181 + Width = 245 + Align = alBottom + BorderSpacing.Around = 8 + BevelOuter = bvNone + ClientHeight = 25 + ClientWidth = 245 ParentFont = True TabOrder = 1 - end - object edUsername: TEdit - Left = 96 - Height = 23 - Top = 16 - Width = 160 - Color = clBtnFace - ParentFont = True - ReadOnly = True - TabOrder = 2 - end - object edPassword: TEdit - Left = 96 - Height = 23 - Top = 48 - Width = 160 - EchoMode = emPassword - ParentFont = True - PasswordChar = '*' - TabOrder = 3 - end - object cbAccessLevel: TComboBox - Left = 96 - Height = 29 - Top = 112 - Width = 160 - AutoCompleteText = [cbactEndOfLineComplete, cbactSearchAscending] - Items.Strings = ( - 'None' - 'Viewer' - 'Normal' - 'Administrator' - ) - MaxLength = 0 - ParentFont = True - Style = csDropDownList - TabOrder = 4 + object btnCancel: TButton + Left = 170 + Height = 25 + Width = 75 + Align = alRight + BorderSpacing.Left = 4 + BorderSpacing.InnerBorder = 4 + Cancel = True + Caption = 'Cancel' + ModalResult = 2 + ParentFont = True + TabOrder = 0 + end + object btnOK: TButton + Left = 91 + Height = 25 + Width = 75 + Align = alRight + BorderSpacing.Right = 4 + BorderSpacing.InnerBorder = 4 + Caption = 'OK' + Default = True + ModalResult = 1 + ParentFont = True + TabOrder = 1 + end end end diff --git a/Client/UfrmEditAccount.pas b/Client/UfrmEditAccount.pas index 97aa953..08ac44c 100644 --- a/Client/UfrmEditAccount.pas +++ b/Client/UfrmEditAccount.pas @@ -31,22 +31,28 @@ interface uses Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls, - UEnums; + UEnums, ComCtrls, ExtCtrls, CheckLst; type { TfrmEditAccount } - TfrmEditAccount = class(TForm) - btnOK: TButton; - btnCancel: TButton; - cbAccessLevel: TComboBox; - edUsername: TEdit; - edPassword: TEdit; - lblUsername: TLabel; - lblPassword: TLabel; - lblAccessLevel: TLabel; - lblPasswordHint: TLabel; + TfrmEditAccount = class(TForm) + btnCancel: TButton; + btnOK: TButton; + cbAccessLevel: TComboBox; + CheckListBox1: TCheckListBox; + edPassword: TEdit; + edUsername: TEdit; + Label1: TLabel; + lblAccessLevel: TLabel; + lblPassword: TLabel; + lblPasswordHint: TLabel; + lblUsername: TLabel; + PageControl1: TPageControl; + Panel1: TPanel; + tsGeneral: TTabSheet; + tsRegions: TTabSheet; public function GetAccessLevel: TAccessLevel; procedure SetAccessLevel(AAccessLevel: TAccessLevel); diff --git a/Client/UfrmLargeScaleCommand.lfm b/Client/UfrmLargeScaleCommand.lfm index 84d93c6..482b28b 100644 --- a/Client/UfrmLargeScaleCommand.lfm +++ b/Client/UfrmLargeScaleCommand.lfm @@ -1,11 +1,11 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand Left = 290 - Height = 390 + Height = 397 Top = 171 Width = 620 - ActiveControl = vstActions + ActiveControl = vdtDeleteStaticsTiles Caption = 'Large Scale Commands' - ClientHeight = 390 + ClientHeight = 397 ClientWidth = 620 Constraints.MinHeight = 390 Constraints.MinWidth = 620 @@ -18,21 +18,21 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand LCLVersion = '0.9.25' object nbActions: TNotebook Left = 152 - Height = 360 + Height = 364 Width = 468 Align = alClient - PageIndex = 5 + PageIndex = 4 ParentFont = True ShowTabs = False TabOrder = 0 object pgArea: TPage Caption = 'pgArea' - ClientWidth = 464 - ClientHeight = 356 + ClientWidth = 468 + ClientHeight = 360 ParentFont = True object sbArea: TScrollBox - Height = 356 - Width = 464 + Height = 360 + Width = 468 Align = alClient TabOrder = 0 object pbArea: TPaintBox @@ -46,8 +46,8 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand end object pgCopyMove: TPage Caption = 'Copy/Move' - ClientWidth = 464 - ClientHeight = 356 + ClientWidth = 468 + ClientHeight = 360 ParentFont = True object rgCMAction: TRadioGroup Left = 12 @@ -64,8 +64,8 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 2 - ClientHeight = 23 - ClientWidth = 180 + ClientHeight = 40 + ClientWidth = 184 Columns = 2 ItemIndex = 0 Items.Strings = ( @@ -132,8 +132,8 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand end object pgModifyAltitude: TPage Caption = 'Modify altitude' - ClientWidth = 464 - ClientHeight = 356 + ClientWidth = 468 + ClientHeight = 360 ParentFont = True object Label2: TLabel Left = 28 @@ -218,18 +218,18 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand end object pgDrawTerrain: TPage Caption = 'Draw Terrain' - ClientWidth = 464 - ClientHeight = 356 + ClientWidth = 468 + ClientHeight = 360 ParentFont = True object gbDrawTerrainTiles: TGroupBox Left = 8 - Height = 340 + Height = 344 Top = 8 Width = 225 Align = alLeft BorderSpacing.Around = 8 Caption = 'Tiles' - ClientHeight = 323 + ClientHeight = 328 ClientWidth = 221 ParentFont = True TabOrder = 0 @@ -250,7 +250,7 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand Tag = 1 Cursor = 63 Left = 4 - Height = 231 + Height = 236 Top = 62 Width = 213 Align = alClient @@ -260,7 +260,6 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand DefaultNodeHeight = 44 DragMode = dmAutomatic DragType = dtVCL - Header.Font.Height = -11 Header.Options = [hoColumnResize, hoDrag, hoVisible] Header.ParentFont = True Header.Style = hsFlatButtons @@ -289,7 +288,7 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand end object pnlDrawTerrainTilesControls: TPanel Height = 26 - Top = 297 + Top = 302 Width = 221 Align = alBottom BevelOuter = bvNone @@ -399,23 +398,23 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand object pgDeleteStatics: TPage Caption = 'Delete statics' ClientWidth = 464 - ClientHeight = 356 + ClientHeight = 360 ParentFont = True object gbDeleteStaticsTiles: TGroupBox Left = 8 - Height = 340 + Height = 344 Top = 8 Width = 225 Align = alLeft BorderSpacing.Around = 8 Caption = 'Tiles' - ClientHeight = 323 + ClientHeight = 327 ClientWidth = 221 ParentFont = True TabOrder = 0 object lblDeleteStaticsTilesDesc: TLabel Left = 4 - Height = 64 + Height = 73 Width = 213 Align = alTop BorderSpacing.Left = 4 @@ -423,13 +422,15 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand BorderSpacing.Bottom = 4 Caption = 'Drag statics tiles from the main window and drop them on the list. Only statics matching these tiles will be deleted. If the list is empty, every static will be deleted.' ParentColor = False + ParentFont = True WordWrap = True end object vdtDeleteStaticsTiles: TVirtualDrawTree Tag = 1 + Cursor = 63 Left = 4 - Height = 225 - Top = 68 + Height = 220 + Top = 77 Width = 213 Align = alClient BorderSpacing.Left = 4 @@ -438,7 +439,6 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand DefaultNodeHeight = 44 DragMode = dmAutomatic DragType = dtVCL - Header.Font.Height = -11 Header.Options = [hoColumnResize, hoDrag, hoVisible] Header.ParentFont = True Header.Style = hsFlatButtons @@ -467,7 +467,7 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand end object pnlDrawTerrainTilesControls2: TPanel Height = 26 - Top = 297 + Top = 301 Width = 221 Align = alBottom BevelOuter = bvNone @@ -632,17 +632,17 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand object pgInsertStatics: TPage Caption = 'Insert statics' ClientWidth = 464 - ClientHeight = 356 + ClientHeight = 360 ParentFont = True object gbInserStaticsTiles: TGroupBox Left = 8 - Height = 340 + Height = 344 Top = 8 Width = 225 Align = alLeft BorderSpacing.Around = 8 Caption = 'Tiles' - ClientHeight = 323 + ClientHeight = 327 ClientWidth = 221 ParentFont = True TabOrder = 0 @@ -662,7 +662,7 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand object vdtInsertStaticsTiles: TVirtualDrawTree Tag = 1 Left = 4 - Height = 231 + Height = 235 Top = 62 Width = 213 Align = alClient @@ -672,7 +672,6 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand DefaultNodeHeight = 44 DragMode = dmAutomatic DragType = dtVCL - Header.Font.Height = -11 Header.Options = [hoColumnResize, hoDrag, hoVisible] Header.ParentFont = True Header.Style = hsFlatButtons @@ -701,7 +700,7 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand end object pnlDrawTerrainTilesControls1: TPanel Height = 26 - Top = 297 + Top = 301 Width = 221 Align = alBottom BevelOuter = bvNone @@ -900,11 +899,11 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand end end object pnlLeft: TPanel - Height = 360 + Height = 364 Width = 152 Align = alLeft BevelOuter = bvNone - ClientHeight = 360 + ClientHeight = 364 ClientWidth = 152 ParentFont = True TabOrder = 1 @@ -924,7 +923,6 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand Height = 136 Width = 152 Align = alTop - Header.Font.Height = -11 Header.Options = [hoAutoResize, hoVisible] Header.ParentFont = True Header.Style = hsFlatButtons @@ -945,7 +943,7 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand object pnlAreaControls: TPanel Left = 4 Height = 82 - Top = 274 + Top = 278 Width = 144 Align = alBottom BorderSpacing.Around = 4 @@ -1161,7 +1159,7 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand end object vstArea: TVirtualStringTree Left = 4 - Height = 121 + Height = 125 Top = 149 Width = 144 Align = alClient @@ -1180,22 +1178,23 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand end end object pnlControls: TPanel - Height = 30 - Top = 360 - Width = 620 + Left = 4 + Height = 25 + Top = 368 + Width = 612 Align = alBottom + BorderSpacing.Around = 4 BevelOuter = bvNone - ClientHeight = 30 - ClientWidth = 620 + ClientHeight = 25 + ClientWidth = 612 ParentFont = True TabOrder = 2 object btnExecute: TButton - Left = 484 - Height = 22 - Top = 4 + Left = 480 + Height = 25 Width = 64 Align = alRight - BorderSpacing.Around = 4 + BorderSpacing.Right = 4 BorderSpacing.InnerBorder = 4 Caption = 'Execute' OnClick = btnExecuteClick @@ -1203,12 +1202,11 @@ object frmLargeScaleCommand: TfrmLargeScaleCommand TabOrder = 0 end object btnClose: TButton - Left = 552 - Height = 22 - Top = 4 + Left = 548 + Height = 25 Width = 64 Align = alRight - BorderSpacing.Around = 4 + BorderSpacing.Left = 4 BorderSpacing.InnerBorder = 4 Caption = 'Close' OnClick = btnCloseClick diff --git a/Client/UfrmLargeScaleCommand.pas b/Client/UfrmLargeScaleCommand.pas index bd81305..d50b5a4 100644 --- a/Client/UfrmLargeScaleCommand.pas +++ b/Client/UfrmLargeScaleCommand.pas @@ -21,7 +21,7 @@ * CDDL HEADER END * * - * Portions Copyright 2007 Andreas Schneider + * Portions Copyright 2008 Andreas Schneider *) unit UfrmLargeScaleCommand; @@ -163,7 +163,7 @@ type AStream: TEnhancedMemoryStream); public { public declarations } - end; + end; var frmLargeScaleCommand: TfrmLargeScaleCommand; @@ -197,25 +197,25 @@ begin AddNode(3, 'Delete statics'); AddNode(4, 'Insert statics'); vstActions.Selected[vstActions.GetFirst] := True; - + vstArea.NodeDataSize := SizeOf(TRect); - + pbArea.Width := frmRadarMap.Radar.Width; pbArea.Height := frmRadarMap.Radar.Height; seX1.MaxValue := ResMan.Landscape.CellWidth; seX2.MaxValue := ResMan.Landscape.CellWidth; seY1.MaxValue := ResMan.Landscape.CellHeight; seY2.MaxValue := ResMan.Landscape.CellHeight; - + vdtTerrainTiles.NodeDataSize := SizeOf(TTileInfo); vdtInsertStaticsTiles.NodeDataSize := SizeOf(TTileInfo); vdtDeleteStaticsTiles.NodeDataSize := SizeOf(TTileInfo); - + seCMOffsetX.MinValue := -ResMan.Landscape.CellWidth; seCMOffsetX.MaxValue := ResMan.Landscape.CellWidth; seCMOffsetY.MinValue := -ResMan.Landscape.CellHeight; seCMOffsetY.MaxValue := ResMan.Landscape.CellHeight; - + frmRadarMap.Dependencies.Add(pbArea); end; @@ -385,7 +385,7 @@ begin stream.WriteBoolean(cbCMEraseTarget.Checked); end else stream.WriteBoolean(False); - + //Modify altitude node := FindNode(1); if vstActions.CheckState[node] = csCheckedNormal then @@ -403,7 +403,7 @@ begin end; end else stream.WriteBoolean(False); - + //Draw terrain node := FindNode(2); if vstActions.CheckState[node] = csCheckedNormal then @@ -412,7 +412,7 @@ begin SerializeTiles(vdtTerrainTiles, stream); end else stream.WriteBoolean(False); - + //Delete statics node := FindNode(3); if vstActions.CheckState[node] = csCheckedNormal then @@ -423,7 +423,7 @@ begin stream.WriteShortInt(Max(seDeleteStaticsZ1.Value, seDeleteStaticsZ2.Value)); end else stream.WriteBoolean(False); - + //Insert statics node := FindNode(4); if vstActions.CheckState[node] = csCheckedNormal then @@ -441,7 +441,7 @@ begin stream.WriteByte(2); end else stream.WriteBoolean(False); - + dmNetwork.Send(TCompressedPacket.Create(packet)); Close; end; diff --git a/Client/UfrmLogin.lfm b/Client/UfrmLogin.lfm index f4c9390..78115d3 100644 --- a/Client/UfrmLogin.lfm +++ b/Client/UfrmLogin.lfm @@ -16,8 +16,8 @@ object frmLogin: TfrmLogin ShowInTaskBar = stAlways LCLVersion = '0.9.25' object lblCopyright: TLabel - Height = 23 - Top = 242 + Height = 24 + Top = 241 Width = 489 Align = alBottom Alignment = taCenter @@ -427,7 +427,6 @@ object frmLogin: TfrmLogin NumGlyphs = 1 ParentColor = False ParentFont = True - ReadOnly = True TabOrder = 0 end end diff --git a/Client/UfrmMain.lfm b/Client/UfrmMain.lfm index 7974867..2e79066 100644 --- a/Client/UfrmMain.lfm +++ b/Client/UfrmMain.lfm @@ -3,9 +3,9 @@ object frmMain: TfrmMain Height = 603 Top = 144 Width = 766 - ActiveControl = cbTerrain + ActiveControl = pcLeft Caption = 'UO CentrED' - ClientHeight = 578 + ClientHeight = 574 ClientWidth = 766 Constraints.MinHeight = 603 Constraints.MinWidth = 766 @@ -21,7 +21,7 @@ object frmMain: TfrmMain WindowState = wsMaximized object pnlBottom: TPanel Height = 31 - Top = 547 + Top = 543 Width = 766 Align = alBottom BevelOuter = bvNone @@ -31,25 +31,25 @@ object frmMain: TfrmMain TabOrder = 0 object lblX: TLabel Left = 11 - Height = 14 + Height = 13 Top = 7 - Width = 11 + Width = 12 Caption = 'X:' ParentColor = False ParentFont = True end object lblY: TLabel Left = 88 - Height = 14 + Height = 13 Top = 7 - Width = 10 + Width = 12 Caption = 'Y:' ParentColor = False ParentFont = True end object lblTileInfo: TLabel Left = 240 - Height = 14 + Height = 13 Top = 7 Width = 4 Caption = ' ' @@ -57,9 +57,9 @@ object frmMain: TfrmMain ParentFont = True end object lblTip: TLabel - Left = 528 + Left = 519 Height = 31 - Width = 230 + Width = 239 Align = alRight Alignment = taRightJustify BorderSpacing.Right = 8 @@ -69,14 +69,15 @@ object frmMain: TfrmMain ParentFont = True end object lblTipC: TLabel - Left = 505 + Left = 490 Height = 31 - Width = 23 + Width = 29 Align = alRight Caption = 'Tip: ' + Font.Height = -11 + Font.Style = [fsBold] Layout = tlCenter ParentColor = False - ParentFont = True end object edX: TSpinEdit Left = 24 @@ -109,7 +110,7 @@ object frmMain: TfrmMain end end object pcLeft: TPageControl - Height = 523 + Height = 519 Top = 24 Width = 224 ActivePage = tsTiles @@ -119,7 +120,7 @@ object frmMain: TfrmMain TabOrder = 1 object tsTiles: TTabSheet Caption = 'Tiles' - ClientHeight = 494 + ClientHeight = 488 ClientWidth = 220 ParentFont = True object pnlTileListSettings: TPanel @@ -133,18 +134,18 @@ object frmMain: TfrmMain TabOrder = 0 object lblFilter: TLabel Left = 84 - Height = 14 + Height = 13 Top = 8 - Width = 30 + Width = 33 Caption = 'Filter:' ParentColor = False ParentFont = True end object cbTerrain: TCheckBox Left = 4 - Height = 21 + Height = 20 Top = 8 - Width = 64 + Width = 66 Caption = 'Terrain' Checked = True OnChange = cbTerrainChange @@ -154,9 +155,9 @@ object frmMain: TfrmMain end object cbStatics: TCheckBox Left = 4 - Height = 21 + Height = 20 Top = 32 - Width = 63 + Width = 64 Caption = 'Statics' Checked = True OnChange = cbStaticsChange @@ -176,7 +177,7 @@ object frmMain: TfrmMain end object vdtTiles: TVirtualDrawTree Tag = 1 - Height = 240 + Height = 234 Top = 56 Width = 220 Align = alClient @@ -184,7 +185,6 @@ object frmMain: TfrmMain DragMode = dmAutomatic DragType = dtVCL Header.AutoSizeIndex = 2 - Header.Font.Height = -11 Header.MainColumn = 2 Header.Options = [hoVisible] Header.ParentFont = True @@ -221,24 +221,23 @@ object frmMain: TfrmMain end object gbRandom: TGroupBox Height = 193 - Top = 301 + Top = 295 Width = 220 Align = alBottom Caption = 'Random pool' - ClientHeight = 178 + ClientHeight = 176 ClientWidth = 216 ParentFont = True TabOrder = 2 object vdtRandom: TVirtualDrawTree Tag = 1 Cursor = 63 - Height = 126 + Height = 124 Top = 22 Width = 216 Align = alClient DefaultNodeHeight = 44 DragType = dtVCL - Header.Font.Height = -11 Header.Options = [hoColumnResize, hoDrag, hoVisible] Header.ParentFont = True Header.Style = hsFlatButtons @@ -421,7 +420,7 @@ object frmMain: TfrmMain object pnlRandomPreset: TPanel Left = 4 Height = 22 - Top = 152 + Top = 150 Width = 208 Align = alBottom BorderSpacing.Around = 4 @@ -541,7 +540,7 @@ object frmMain: TfrmMain object spTileList: TSplitter Cursor = crVSplit Height = 5 - Top = 296 + Top = 290 Width = 220 Align = alBottom ResizeAnchor = akBottom @@ -564,12 +563,12 @@ object frmMain: TfrmMain end object tsClients: TTabSheet Caption = 'Clients' - ClientHeight = 494 - ClientWidth = 220 + ClientHeight = 519 + ClientWidth = 224 ParentFont = True object lbClients: TListBox - Height = 494 - Width = 220 + Height = 519 + Width = 224 Align = alClient OnDblClick = mnuGoToClientClick ParentFont = True @@ -581,20 +580,19 @@ object frmMain: TfrmMain end object tsLocations: TTabSheet Caption = 'Locations' - ClientHeight = 494 - ClientWidth = 220 + ClientHeight = 519 + ClientWidth = 224 ParentFont = True object vstLocations: TVirtualStringTree Cursor = 63 Left = 4 - Height = 458 + Height = 483 Top = 4 - Width = 212 + Width = 216 Align = alClient BorderSpacing.Around = 4 BorderStyle = bsSingle Header.AutoSizeIndex = 1 - Header.Font.Height = -11 Header.Options = [hoAutoResize, hoColumnResize, hoDrag, hoVisible] Header.ParentFont = True Header.Style = hsFlatButtons @@ -604,6 +602,7 @@ object frmMain: TfrmMain TreeOptions.PaintOptions = [toShowButtons, toShowDropmark, toThemeAware, toUseBlendedImages] TreeOptions.SelectionOptions = [toFullRowSelect] OnDblClick = vstLocationsDblClick + OnFreeNode = vstLocationsFreeNode OnGetText = vstLocationsGetText OnLoadNode = vstLocationsLoadNode OnNewText = vstLocationsNewText @@ -615,20 +614,20 @@ object frmMain: TfrmMain end item Position = 1 - Width = 133 + Width = 141 WideText = 'Name' end> end object pnlLocationControls: TPanel Left = 4 Height = 24 - Top = 466 - Width = 212 + Top = 491 + Width = 216 Align = alBottom BorderSpacing.Around = 4 BevelOuter = bvNone ClientHeight = 24 - ClientWidth = 212 + ClientWidth = 216 ParentFont = True TabOrder = 1 object btnClearLocations: TSpeedButton @@ -952,17 +951,17 @@ object frmMain: TfrmMain end object pnlMain: TPanel Left = 224 - Height = 523 + Height = 519 Top = 24 Width = 542 Align = alClient BevelOuter = bvNone - ClientHeight = 523 + ClientHeight = 519 ClientWidth = 542 ParentFont = True TabOrder = 3 object oglGameWindow: TOpenGLControl - Height = 372 + Height = 368 Width = 542 Align = alClient OnDblClick = oglGameWindowDblClick @@ -976,7 +975,7 @@ object frmMain: TfrmMain end object pnlChatHeader: TPanel Height = 24 - Top = 372 + Top = 368 Width = 542 Align = alBottom BevelInner = bvRaised @@ -1004,7 +1003,7 @@ object frmMain: TfrmMain end object pnlChat: TPanel Height = 122 - Top = 401 + Top = 397 Width = 542 Align = alBottom BevelOuter = bvNone @@ -1014,11 +1013,11 @@ object frmMain: TfrmMain TabOrder = 1 Visible = False object vstChat: TVirtualStringTree + Cursor = 63 Height = 99 Width = 542 Align = alClient Header.AutoSizeIndex = 2 - Header.Font.Height = -11 Header.MainColumn = 2 Header.Options = [hoAutoResize, hoColumnResize, hoDrag, hoVisible] Header.ParentFont = True @@ -1060,7 +1059,7 @@ object frmMain: TfrmMain object spChat: TSplitter Cursor = crVSplit Height = 5 - Top = 396 + Top = 392 Width = 542 Align = alBottom AutoSnap = False @@ -1252,6 +1251,10 @@ object frmMain: TfrmMain ImageIndex = 3 OnClick = mnuAccountControlClick end + object mnuRegionControl: TMenuItem + Caption = '&Region Management' + OnClick = mnuRegionControlClick + end object mnuLargeScaleCommands: TMenuItem Caption = 'Large Scale Commands' Bitmap.Data = { diff --git a/Client/UfrmMain.pas b/Client/UfrmMain.pas index 9ef4a22..829becb 100644 --- a/Client/UfrmMain.pas +++ b/Client/UfrmMain.pas @@ -252,6 +252,8 @@ type const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType); procedure vstLocationsDblClick(Sender: TObject); + procedure vstLocationsFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode + ); procedure vstLocationsGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString); procedure vstLocationsLoadNode(Sender: TBaseVirtualTree; @@ -1406,6 +1408,15 @@ begin end; end; +procedure TfrmMain.vstLocationsFreeNode(Sender: TBaseVirtualTree; + Node: PVirtualNode); +var + locationInfo: PLocationInfo; +begin + locationInfo := Sender.GetNodeData(Node); + locationInfo^.Name := ''; +end; + procedure TfrmMain.vstLocationsGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString); diff --git a/Client/UfrmRegionControl.lfm b/Client/UfrmRegionControl.lfm index 3a25512..835fdf5 100644 --- a/Client/UfrmRegionControl.lfm +++ b/Client/UfrmRegionControl.lfm @@ -1,11 +1,11 @@ object frmRegionControl: TfrmRegionControl - Left = 367 - Height = 390 - Top = 268 + Left = 247 + Height = 392 + Top = 139 Width = 620 - ActiveControl = vstGroups + ActiveControl = vstRegions Caption = 'Region Control' - ClientHeight = 390 + ClientHeight = 392 ClientWidth = 620 Font.Height = -11 OnCreate = FormCreate @@ -14,11 +14,11 @@ object frmRegionControl: TfrmRegionControl Position = poOwnerFormCenter LCLVersion = '0.9.25' object Panel1: TPanel - Height = 360 + Height = 359 Width = 160 - Anchors = [akTop, akLeft, akBottom] + Align = alLeft Caption = 'Panel1' - ClientHeight = 360 + ClientHeight = 359 ClientWidth = 160 ParentFont = True TabOrder = 0 @@ -37,7 +37,7 @@ object frmRegionControl: TfrmRegionControl object pnlAreaControls: TPanel Left = 5 Height = 82 - Top = 273 + Top = 272 Width = 150 Align = alBottom BorderSpacing.Around = 4 @@ -72,6 +72,7 @@ object frmRegionControl: TfrmRegionControl Hint = 'Add area' Width = 23 Color = clBtnFace + Enabled = False Glyph.Data = { 36040000424D3604000000000000360000002800000010000000100000000100 2000000000000004000064000000640000000000000000000000000000000000 @@ -119,6 +120,7 @@ object frmRegionControl: TfrmRegionControl Hint = 'Delete area' Width = 23 Color = clBtnFace + Enabled = False Glyph.Data = { 36040000424D3604000000000000360000002800000010000000100000000100 2000000000000004000064000000640000000000000000000000000000000000 @@ -166,6 +168,7 @@ object frmRegionControl: TfrmRegionControl Hint = 'Delete all areas' Width = 23 Color = clBtnFace + Enabled = False Glyph.Data = { 36040000424D3604000000000000360000002800000010000000100000000100 2000000000000004000064000000640000000000000000000000000000000000 @@ -250,7 +253,7 @@ object frmRegionControl: TfrmRegionControl end object vstArea: TVirtualStringTree Left = 5 - Height = 119 + Height = 118 Top = 150 Width = 150 Align = alClient @@ -268,46 +271,46 @@ object frmRegionControl: TfrmRegionControl OnGetText = vstAreaGetText Columns = <> end - object vstGroups: TVirtualStringTree + object vstRegions: TVirtualStringTree Left = 1 Height = 136 Top = 1 Width = 158 Align = alTop - Header.Font.Height = -11 Header.Options = [hoAutoResize, hoVisible] Header.ParentFont = True Header.Style = hsFlatButtons ParentFont = True - PopupMenu = pmGroup + PopupMenu = pmRegions TabOrder = 2 TreeOptions.MiscOptions = [toCheckSupport, toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning] TreeOptions.PaintOptions = [toShowButtons, toShowDropmark, toThemeAware, toUseBlendedImages] TreeOptions.SelectionOptions = [toFullRowSelect] - OnChange = vstGroupsChange - OnEditing = vstGroupsOnEditing - OnGetText = vstGroupsGetText - OnNewText = vstGroupsNewText + OnChange = vstRegionsChange + OnEditing = vstRegionsOnEditing + OnFreeNode = vstRegionsFreeNode + OnGetText = vstRegionsGetText + OnNewText = vstRegionsNewText Columns = < item Width = 158 - WideText = 'Groups' + WideText = 'Regions' end> end end object Panel2: TPanel Left = 160 - Height = 361 + Height = 359 Width = 460 - Anchors = [akTop, akLeft, akRight, akBottom] + Align = alClient Caption = 'Panel2' - ClientHeight = 361 + ClientHeight = 359 ClientWidth = 460 ParentFont = True TabOrder = 1 object sbArea: TScrollBox Left = 1 - Height = 359 + Height = 357 Top = 1 Width = 458 Align = alClient @@ -323,20 +326,24 @@ object frmRegionControl: TfrmRegionControl end end object Panel3: TPanel - Height = 30 - Top = 360 - Width = 620 - Anchors = [akLeft, akRight, akBottom] - ClientHeight = 30 - ClientWidth = 620 + Left = 4 + Height = 25 + Top = 363 + Width = 612 + Align = alBottom + BorderSpacing.Around = 4 + BevelOuter = bvNone + ClientHeight = 25 + ClientWidth = 612 ParentFont = True TabOrder = 2 object btnExit: TButton - Left = 551 - Height = 22 - Top = 4 + Left = 548 + Height = 25 Width = 64 + Align = alRight Anchors = [akTop, akRight] + BorderSpacing.Left = 4 Caption = 'Exit' OnClick = btnCloseClick ParentFont = True @@ -344,10 +351,11 @@ object frmRegionControl: TfrmRegionControl end object btnSave: TButton Left = 480 - Height = 22 - Top = 4 + Height = 25 Width = 64 + Align = alRight Anchors = [akTop, akRight] + BorderSpacing.Right = 4 Caption = 'Save' Enabled = False OnClick = btnSaveClick @@ -355,14 +363,14 @@ object frmRegionControl: TfrmRegionControl TabOrder = 1 end end - object pmGroup: TPopupMenu + object pmRegions: TPopupMenu left = 48 top = 43 - object mnuAddGroup: TMenuItem + object mnuAddRegion: TMenuItem Caption = 'Add' OnClick = acAddGroup end - object mnuRemoveGroup: TMenuItem + object mnuRemoveRegion: TMenuItem Caption = 'Remove' OnClick = accRemoveGroup end diff --git a/Client/UfrmRegionControl.pas b/Client/UfrmRegionControl.pas index 8e4243b..579cbd9 100644 --- a/Client/UfrmRegionControl.pas +++ b/Client/UfrmRegionControl.pas @@ -32,8 +32,7 @@ interface uses Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, CheckLst, VirtualTrees, ExtCtrls, ImagingComponents, StdCtrls, Buttons, Spin, LCLIntf, - math, UPlatformTypes, UEnhancedMemoryStream, Menus,contnrs, UInterfaces, - URectList; + math, UPlatformTypes, UEnhancedMemoryStream, Menus, contnrs, URectList; type TAreaMoveType = (amLeft, amTop, amRight, amBottom); @@ -50,20 +49,20 @@ type Label1: TLabel; lblX: TLabel; lblY: TLabel; - mnuAddGroup: TMenuItem; - mnuRemoveGroup: TMenuItem; + mnuAddRegion: TMenuItem; + mnuRemoveRegion: TMenuItem; Panel1: TPanel; Panel2: TPanel; Panel3: TPanel; pbArea: TPaintBox; pnlAreaControls: TPanel; - pmGroup: TPopupMenu; + pmRegions: TPopupMenu; sbArea: TScrollBox; seX1: TSpinEdit; seX2: TSpinEdit; seY1: TSpinEdit; seY2: TSpinEdit; - vstGroups: TVirtualStringTree; + vstRegions: TVirtualStringTree; vstArea: TVirtualStringTree; procedure acAddGroup(Sender: TObject); procedure accRemoveGroup(Sender: TObject); @@ -84,12 +83,13 @@ type procedure vstAreaChange(Sender: TBaseVirtualTree; Node: PVirtualNode); procedure vstAreaGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString); - procedure vstGroupsChange(Sender: TBaseVirtualTree; Node: PVirtualNode); - procedure vstGroupsGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; + procedure vstRegionsChange(Sender: TBaseVirtualTree; Node: PVirtualNode); + procedure vstRegionsFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode); + procedure vstRegionsGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString); - procedure vstGroupsNewText(Sender: TBaseVirtualTree; Node: PVirtualNode; + procedure vstRegionsNewText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; const NewText: WideString); - procedure vstGroupsOnEditing(Sender: TBaseVirtualTree; Node: PVirtualNode; + procedure vstRegionsOnEditing(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; var Allowed: Boolean); protected FLastX: Integer; @@ -142,13 +142,13 @@ var node: PVirtualNode; regionInfo: PRegionInfo; begin - vstGroups.BeginUpdate; - vstGroups.Clear; + vstRegions.BeginUpdate; + vstRegions.Clear; regionCount := ABuffer.ReadByte; for i := 0 to regionCount - 1 do begin - node := vstGroups.AddChild(nil); - regionInfo := vstGroups.GetNodeData(node); + node := vstRegions.AddChild(nil); + regionInfo := vstRegions.GetNodeData(node); regionInfo^.Name := ABuffer.ReadStringNull; regionInfo^.Areas := TRectList.Create; areaCount := ABuffer.ReadByte; @@ -161,7 +161,7 @@ begin regionInfo^.Areas.Add(x1, y1, x2, y2); end; end; - vstGroups.EndUpdate; + vstRegions.EndUpdate; end; @@ -175,11 +175,11 @@ begin seY2.MaxValue := ResMan.Landscape.CellHeight; vstArea.NodeDataSize := SizeOf(TRect); - vstGroups.NodeDataSize := SizeOf(TRegionInfo); + vstRegions.NodeDataSize := SizeOf(TRegionInfo); frmRadarMap.Dependencies.Add(pbArea); - AdminPacketHandlers[$09] := TPacketHandler.Create(0, @OnListRegionsPacket); + AdminPacketHandlers[$0A] := TPacketHandler.Create(0, @OnListRegionsPacket); end; procedure TfrmRegionControl.btnDeleteAreaClick(Sender: TObject); @@ -187,11 +187,11 @@ var infoGroup: PRegionInfo; i: Integer; begin - if vstGroups.GetFirstSelected <> nil then + if vstRegions.GetFirstSelected <> nil then begin - infoGroup := vstGroups.GetNodeData(vstGroups.GetFirstSelected); + infoGroup := vstRegions.GetNodeData(vstRegions.GetFirstSelected); infoGroup^.Areas.Delete(vstArea.AbsoluteIndex(vstArea.GetFirstSelected)); - vstGroupsChange(vstGroups, vstGroups.GetFirstSelected); + vstRegionsChange(vstRegions, vstRegions.GetFirstSelected); end; end; @@ -209,15 +209,15 @@ begin stream.Position := stream.Size; stream.WriteByte($09); - groupCount := Min(vstGroups.RootNodeCount, 255); + groupCount := Min(vstRegions.RootNodeCount, 255); stream.WriteByte(groupCount); if groupCount = 0 then Exit; i := 0; - node := vstGroups.GetFirst; + node := vstRegions.GetFirst; while (node <> nil) and (i < groupCount) do begin - groupInfo := vstGroups.GetNodeData(node); + groupInfo := vstRegions.GetNodeData(node); stream.WriteStringNull(groupInfo^.Name); areaCount:=Min(groupInfo^.Areas.Count,255); stream.WriteByte(areaCount); @@ -229,7 +229,7 @@ begin stream.WriteWord(Max(Left, Right)); stream.WriteWord(Max(Top, Bottom)); end; - node := vstGroups.GetNext(node); + node := vstRegions.GetNext(node); Inc(i); end; dmNetwork.Send(TCompressedPacket.Create(packet)); @@ -241,48 +241,53 @@ var node : PVirtualNode; infoGroup : PRegionInfo; begin - node := vstGroups.AddChild(nil); - infoGroup := vstGroups.GetNodeData(node); + node := vstRegions.AddChild(nil); + infoGroup := vstRegions.GetNodeData(node); infoGroup^.Name := 'Unnamed'; infoGroup^.Areas := TRectList.Create; end; procedure TfrmRegionControl.accRemoveGroup(Sender: TObject); begin - vstGroups.DeleteSelectedNodes; - vstGroupsChange(vstGroups, nil); + vstRegions.DeleteSelectedNodes; + vstRegionsChange(vstRegions, nil); end; procedure TfrmRegionControl.btnAddAreaClick(Sender: TObject); var - node: PVirtualNode; - nodeInfo: ^TRect; - infoGroup : PRegionInfo; + node, selected: PVirtualNode; + areaInfo: ^TRect; + regionInfo: PRegionInfo; begin - infoGroup:=vstGroups.GetNodeData(vstGroups.GetFirstSelected); - node := vstArea.AddChild(nil); - nodeInfo := vstArea.GetNodeData(node); - nodeInfo^.Left := 0; - nodeInfo^.Top := 0; - nodeInfo^.Right := 0; - nodeInfo^.Bottom := 0; - infoGroup^.Areas.Add(0, 0, 0, 0); - vstArea.ClearSelection; - vstArea.Selected[node] := True; - vstArea.FocusedNode := node; + selected := vstRegions.GetFirstSelected; + if selected <> nil then + begin + regionInfo := vstRegions.GetNodeData(selected); + node := vstArea.AddChild(nil); + areaInfo := vstArea.GetNodeData(node); + areaInfo^.Left := 0; + areaInfo^.Top := 0; + areaInfo^.Right := 0; + areaInfo^.Bottom := 0; + regionInfo^.Areas.Add(0, 0, 0, 0); + vstArea.ClearSelection; + vstArea.Selected[node] := True; + vstArea.FocusedNode := node; + end; end; procedure TfrmRegionControl.btnClearAreaClick(Sender: TObject); var - infoGroup: PRegionInfo; - infoArea : TRect; + regionNode: PVirtualNode; + regionInfo: PRegionInfo; i: Integer; begin - if vstGroups.GetFirstSelected <> nil then + regionNode := vstRegions.GetFirstSelected; + if regionNode <> nil then begin - infoGroup := vstGroups.GetNodeData(vstGroups.GetFirstSelected); - infoGroup^.Areas.Clear; - vstGroupsChange(vstGroups, vstGroups.GetFirstSelected); + regionInfo := vstRegions.GetNodeData(regionNode); + regionInfo^.Areas.Clear; + vstRegionsChange(vstRegions, vstRegions.GetFirstSelected); end; end; @@ -294,7 +299,7 @@ end; procedure TfrmRegionControl.FormDestroy(Sender: TObject); begin frmRadarMap.Dependencies.Remove(pbArea); - if AdminPacketHandlers[$09] <> nil then FreeAndNil(AdminPacketHandlers[$09]); + if AdminPacketHandlers[$0A] <> nil then FreeAndNil(AdminPacketHandlers[$0A]); end; procedure TfrmRegionControl.FormShow(Sender: TObject); @@ -306,50 +311,50 @@ end; procedure TfrmRegionControl.pbAreaMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var - node, match: PVirtualNode; - nodeInfo: ^TRect; + areaNode, regionNode, match: PVirtualNode; + areaInfo: ^TRect; p: TPoint; i: Integer; - infoArea: TRect; - infoGroup: PRegionInfo; + regionInfo: PRegionInfo; begin FAreaMove := []; p := Point(X * 8, Y * 8); match := nil; - node := vstArea.GetFirst; - while node <> nil do + areaNode := vstArea.GetFirst; + while areaNode <> nil do //find the last matching area begin - nodeInfo := vstArea.GetNodeData(node); - if PtInRect(nodeInfo^, p) then - match := node; - node := vstArea.GetNext(node); + areaInfo := vstArea.GetNodeData(areaNode); + if PtInRect(areaInfo^, p) then + match := areaNode; + areaNode := vstArea.GetNext(areaNode); end; if match <> nil then begin - nodeInfo := vstArea.GetNodeData(match); - if p.x - nodeInfo^.Left <= 64 then Include(FAreaMove, amLeft); - if p.y - nodeInfo^.Top <= 64 then Include(FAreaMove, amTop); - if nodeInfo^.Right - p.x <= 64 then Include(FAreaMove, amRight); - if nodeInfo^.Bottom - p.y <= 64 then Include(FAreaMove, amBottom); + areaInfo := vstArea.GetNodeData(match); + if p.x - areaInfo^.Left <= 64 then Include(FAreaMove, amLeft); + if p.y - areaInfo^.Top <= 64 then Include(FAreaMove, amTop); + if areaInfo^.Right - p.x <= 64 then Include(FAreaMove, amRight); + if areaInfo^.Bottom - p.y <= 64 then Include(FAreaMove, amBottom); if FAreaMove = [] then FAreaMove := [amLeft, amTop, amRight, amBottom]; end else begin - if vstGroups.GetFirstSelected <> nil then - begin - infoGroup:=vstGroups.GetNodeData(vstGroups.GetFirstSelected); - match := vstArea.AddChild(nil); - nodeInfo:=vstArea.GetNodeData(match); - nodeInfo^.Left := p.x; - nodeInfo^.Top := p.y; - nodeInfo^.Right := p.x; - nodeInfo^.Bottom := p.y; - infoGroup^.Areas.Add(p.x, p.y, p.x, p.y); + regionNode := vstRegions.GetFirstSelected; + if regionNode <> nil then + begin + regionInfo := vstRegions.GetNodeData(regionNode); + match := vstArea.AddChild(nil); + areaInfo := vstArea.GetNodeData(match); + areaInfo^.Left := p.x; + areaInfo^.Top := p.y; + areaInfo^.Right := p.x; + areaInfo^.Bottom := p.y; + regionInfo^.Areas.Add(p.x, p.y, p.x, p.y); - pbArea.Repaint; + pbArea.Repaint; - FAreaMove := [amRight, amBottom]; - end; + FAreaMove := [amRight, amBottom]; + end; end; vstArea.ClearSelection; vstArea.Selected[match] := True; @@ -380,7 +385,7 @@ procedure TfrmRegionControl.pbAreaPaint(Sender: TObject); var i: Integer; node: PVirtualNode; - nodeInfo: ^TRect; + areaInfo: ^TRect; begin DisplayImage(pbArea.Canvas, 0, 0, frmRadarMap.Radar); pbArea.Canvas.Pen.Color := clRed; @@ -398,9 +403,9 @@ begin pbArea.Canvas.Pen.Width := 1; pbArea.Canvas.Pen.Style := psDot; end; - nodeInfo := vstArea.GetNodeData(node); - pbArea.Canvas.Rectangle(nodeInfo^.Left div 8, nodeInfo^.Top div 8, - nodeInfo^.Right div 8 + 1, nodeInfo^.Bottom div 8 + 1); + areaInfo := vstArea.GetNodeData(node); + pbArea.Canvas.Rectangle(areaInfo^.Left div 8, areaInfo^.Top div 8, + areaInfo^.Right div 8 + 1, areaInfo^.Bottom div 8 + 1); node := vstArea.GetNext(node); end; end; @@ -408,19 +413,19 @@ end; procedure TfrmRegionControl.seX1Change(Sender: TObject); var node: PVirtualNode; - nodeInfo: ^TRect; - infoGroup: PRegionInfo; + areaInfo: ^TRect; + regionInfo: PRegionInfo; begin node := vstArea.GetFirstSelected; if node <> nil then begin - nodeInfo := vstArea.GetNodeData(node); - nodeInfo^.Left := seX1.Value; - nodeInfo^.Right := seX2.Value; - nodeInfo^.Top := seY1.Value; - nodeInfo^.Bottom := seY2.Value; - infoGroup:= vstGroups.GetNodeData(vstGroups.GetFirstSelected); - infoGroup^.Areas.Rects[vstArea.AbsoluteIndex(node)] := nodeinfo^; + areaInfo := vstArea.GetNodeData(node); + areaInfo^.Left := seX1.Value; + areaInfo^.Right := seX2.Value; + areaInfo^.Top := seY1.Value; + areaInfo^.Bottom := seY2.Value; + regionInfo:= vstRegions.GetNodeData(vstRegions.GetFirstSelected); + regionInfo^.Areas.Rects[vstArea.AbsoluteIndex(node)] := areaInfo^; vstArea.InvalidateNode(node); pbArea.Repaint; end; @@ -429,7 +434,7 @@ end; procedure TfrmRegionControl.vstAreaChange(Sender: TBaseVirtualTree; Node: PVirtualNode); var - nodeInfo: ^TRect; + areaInfo: ^TRect; selected: Boolean; begin selected := (Node <> nil) and Sender.Selected[Node]; @@ -442,82 +447,92 @@ begin seY2.Enabled := selected; if selected then begin - nodeInfo := Sender.GetNodeData(Node); - seX1.Value := nodeInfo^.Left; - seX2.Value := nodeInfo^.Right; - seY1.Value := nodeInfo^.Top; - seY2.Value := nodeInfo^.Bottom; + areaInfo := Sender.GetNodeData(Node); + seX1.Value := areaInfo^.Left; + seX2.Value := areaInfo^.Right; + seY1.Value := areaInfo^.Top; + seY2.Value := areaInfo^.Bottom; end; + pbArea.Repaint; end; procedure TfrmRegionControl.vstAreaGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString); var - nodeInfo: ^TRect; + areaInfo: ^TRect; begin - nodeInfo := Sender.GetNodeData(Node); - CellText := Format('(%d, %d), (%d, %d)', [nodeInfo^.Left, nodeInfo^.Top, - nodeInfo^.Right, nodeInfo^.Bottom]); + areaInfo := Sender.GetNodeData(Node); + CellText := Format('(%d, %d), (%d, %d)', [areaInfo^.Left, areaInfo^.Top, + areaInfo^.Right, areaInfo^.Bottom]); end; -procedure TfrmRegionControl.vstGroupsChange(Sender: TBaseVirtualTree; +procedure TfrmRegionControl.vstRegionsChange(Sender: TBaseVirtualTree; Node: PVirtualNode); var i: Integer; - nodeArea: PVirtualNode; - infoGroup: PRegionInfo; - infoArea: ^TRect; - Area: ^TRect; + areaNode: PVirtualNode; + regionInfo: PRegionInfo; + areaInfo: ^TRect; begin vstArea.BeginUpdate; vstArea.Clear; if Node <> nil then - begin {TODO : code style!!!!} - infoGroup:=Sender.GetNodeData(Node); - for i:=0 to infoGroup^.Areas.Count-1 do + begin + regionInfo := Sender.GetNodeData(Node); + for i := 0 to regionInfo^.Areas.Count - 1 do begin - nodeArea := vstArea.AddChild(nil); - infoArea := vstArea.GetNodeData(nodeArea); - Area := infoGroup^.Areas[i]; - infoArea^.Left := Area^.Left; - infoArea^.Top := Area^.Top; - infoArea^.Right := Area^.Right; - infoArea^.Bottom := Area^.Bottom; + areaNode := vstArea.AddChild(nil); + areaInfo := vstArea.GetNodeData(areaNode); + with regionInfo^.Areas.Rects[i] do + begin + areaInfo^.Left := Left; + areaInfo^.Top := Top; + areaInfo^.Right := Right; + areaInfo^.Bottom := Bottom; + end; end; end; vstArea.EndUpdate; pbArea.Repaint; end; -procedure TfrmRegionControl.vstGroupsGetText(Sender: TBaseVirtualTree; +procedure TfrmRegionControl.vstRegionsFreeNode(Sender: TBaseVirtualTree; + Node: PVirtualNode); +var + regionInfo: PRegionInfo; +begin + regionInfo := Sender.GetNodeData(Node); + if regionInfo^.Areas <> nil then FreeAndNil(regionInfo^.Areas); +end; + +procedure TfrmRegionControl.vstRegionsGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString); var - nodeInfo: PRegionInfo; + regionInfo: PRegionInfo; begin - nodeInfo := Sender.GetNodeData(Node); - CellText := nodeInfo^.Name; + regionInfo := Sender.GetNodeData(Node); + CellText := regionInfo^.Name; end; -procedure TfrmRegionControl.vstGroupsNewText(Sender: TBaseVirtualTree; +procedure TfrmRegionControl.vstRegionsNewText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; const NewText: WideString); var - nodeInfo: PRegionInfo; + regionInfo: PRegionInfo; begin if (Node <> nil) then begin - nodeInfo := Sender.GetNodeData(Node); - nodeInfo^.Name := NewText; + regionInfo := Sender.GetNodeData(Node); + regionInfo^.Name := NewText; end; end; -procedure TfrmRegionControl.vstGroupsOnEditing(Sender: TBaseVirtualTree; +procedure TfrmRegionControl.vstRegionsOnEditing(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; var Allowed: Boolean); begin Allowed := True; end; - initialization {$I UfrmRegionControl.lrs} diff --git a/Server/UAccount.pas b/Server/UAccount.pas index 29a37c4..c4c60fe 100644 --- a/Server/UAccount.pas +++ b/Server/UAccount.pas @@ -32,7 +32,7 @@ interface uses Classes, SysUtils, md5, contnrs, math, DOM, UXmlHelper, UInterfaces, UEnums, URegions; - + type { TAccount } @@ -41,6 +41,7 @@ type constructor Create(AOwner: IInvalidate; AName, APasswordHash: string; AAccessLevel: TAccessLevel; ARegions: TStringList); constructor Deserialize(AOwner: IInvalidate; AElement: TDOMElement); + destructor Destroy; override; procedure Serialize(AElement: TDOMElement); protected FOwner: IInvalidate; @@ -60,7 +61,7 @@ type property Regions: TStringList read FRegions; procedure Invalidate; end; - + { TAccountList } TAccountList = class(TObjectList, ISerializable, IInvalidate) @@ -113,7 +114,7 @@ begin FLastPos := Point(0, 0); TXmlHelper.ReadCoords(AElement, 'LastPos', FLastPos.X, FLastPos.Y); FRegions := TStringList.Create; - + xmlElement := TDOMElement(AElement.FindNode('Regions')); if xmlElement <> nil then begin @@ -131,6 +132,12 @@ begin end; end; +destructor TAccount.Destroy; +begin + if FRegions <> nil then FreeAndNil(FRegions); + inherited Destroy; +end; + procedure TAccount.SetAccessLevel(const AValue: TAccessLevel); begin FAccessLevel := AValue; @@ -157,8 +164,8 @@ end; procedure TAccount.Serialize(AElement: TDOMElement); var - i : Integer; - child : TDOMElement; + i: Integer; + child: TDOMElement; begin TXmlHelper.WriteString(AElement, 'Name', FName); TXmlHelper.WriteString(AElement, 'PasswordHash', FPasswordHash); diff --git a/Server/UAdminHandling.pas b/Server/UAdminHandling.pas index f77c975..f194acc 100644 --- a/Server/UAdminHandling.pas +++ b/Server/UAdminHandling.pas @@ -32,7 +32,7 @@ interface uses Classes, SysUtils, math, UPacket, UPacketHandlers, UConfig, UAccount, UNetState, UEnhancedMemoryStream, UEnums, URegions; - + type { TModifyUserResponsePacket } @@ -40,13 +40,13 @@ type TModifyUserResponsePacket = class(TPacket) constructor Create(AStatus: TModifyUserStatus; AAccount: TAccount); end; - + { TDeleteUserResponsePacket } TDeleteUserResponsePacket = class(TPacket) constructor Create(AStatus: TDeleteUserStatus; AUsername: string); end; - + { TUserListPacket } TUserListPacket = class(TPacket) @@ -64,13 +64,13 @@ type TDeleteRegionResponsePacket = class(TPacket) constructor Create(AStatus: TDeleteRegionStatus; ARegionName: string); end; - + { TUserRegionsPacket } TRegionListPacket = class(TPacket) constructor Create; end; - + procedure OnAdminHandlerPacket(ABuffer: TEnhancedMemoryStream; ANetState: TNetState); procedure OnFlushPacket(ABuffer: TEnhancedMemoryStream; ANetState: TNetState); procedure OnQuitPacket(ABuffer: TEnhancedMemoryStream; ANetState: TNetState); @@ -302,10 +302,8 @@ begin begin FStream.WriteByte(Byte(AAccount.AccessLevel)); FStream.WriteByte(AAccount.Regions.Count); - if AAccount.Regions.Count > 0 then begin - for i := 0 to AAccount.Regions.Count - 1 do - FStream.WriteStringNull(AAccount.Regions[i]); - end; + for i := 0 to AAccount.Regions.Count - 1 do + FStream.WriteStringNull(AAccount.Regions[i]); end; {TODO : check for client side modifications!} end; @@ -339,9 +337,6 @@ begin for j := 0 to account.Regions.Count - 1 do FStream.WriteStringNull(account.Regions[j]); end; - FStream.WriteWord(Config.Regions.Count); - for i := 0 to Config.Regions.Count - 1 do - FStream.WriteStringNull(TRegion(Config.Regions.Items[i]).Name); end; { TModifyRegionResponsePacket } @@ -389,7 +384,7 @@ var region: TRegion; begin inherited Create($03, 0); - FStream.WriteByte($08); + FStream.WriteByte($0A); FStream.WriteByte(Config.Regions.Count); for i := 0 to Config.Regions.Count - 1 do begin