Place UOA design #4
@ -42,7 +42,8 @@ type
 | 
				
			|||||||
    constructor Create(AIdxFile, ABinFile: String);
 | 
					    constructor Create(AIdxFile, ABinFile: String);
 | 
				
			||||||
    destructor Destroy; override;
 | 
					    destructor Destroy; override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function LoadTiles(AHeader: TUoaDesignHeader; AOffsetX, AOffsetY: Word): TStaticItemList;
 | 
					    function LoadTiles(AHeader: TUoaDesignHeader; AOffsetX, AOffsetY: Word;
 | 
				
			||||||
 | 
					      AOffsetZ: ShortInt): TStaticItemList;
 | 
				
			||||||
  public
 | 
					  public
 | 
				
			||||||
    property Headers: TUoaDesignHeaders read FHeaders;
 | 
					    property Headers: TUoaDesignHeaders read FHeaders;
 | 
				
			||||||
  end;
 | 
					  end;
 | 
				
			||||||
@ -120,7 +121,7 @@ begin
 | 
				
			|||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function TUoaDesigns.LoadTiles(AHeader: TUoaDesignHeader; AOffsetX,
 | 
					function TUoaDesigns.LoadTiles(AHeader: TUoaDesignHeader; AOffsetX,
 | 
				
			||||||
  AOffsetY: Word): TStaticItemList;
 | 
					  AOffsetY: Word; AOffsetZ: ShortInt): TStaticItemList;
 | 
				
			||||||
var
 | 
					var
 | 
				
			||||||
  i: Integer;
 | 
					  i: Integer;
 | 
				
			||||||
  tile: TStaticItem;
 | 
					  tile: TStaticItem;
 | 
				
			||||||
@ -144,7 +145,7 @@ begin
 | 
				
			|||||||
    tile.TileID := ReadInt;
 | 
					    tile.TileID := ReadInt;
 | 
				
			||||||
    tile.X := AOffsetX + ReadInt;
 | 
					    tile.X := AOffsetX + ReadInt;
 | 
				
			||||||
    tile.Y := AOffsetY + ReadInt;
 | 
					    tile.Y := AOffsetY + ReadInt;
 | 
				
			||||||
    tile.Z := ReadInt;
 | 
					    tile.Z := AOffsetZ + ReadInt;
 | 
				
			||||||
    ReadInt; // TODO: Level??
 | 
					    ReadInt; // TODO: Level??
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if version = 1 then
 | 
					    if version = 1 then
 | 
				
			||||||
 | 
				
			|||||||
@ -133,7 +133,7 @@ object frmMain: TfrmMain
 | 
				
			|||||||
        AnchorSideLeft.Control = cbTerrain
 | 
					        AnchorSideLeft.Control = cbTerrain
 | 
				
			||||||
        AnchorSideLeft.Side = asrBottom
 | 
					        AnchorSideLeft.Side = asrBottom
 | 
				
			||||||
        AnchorSideTop.Control = cbTerrain
 | 
					        AnchorSideTop.Control = cbTerrain
 | 
				
			||||||
        Left = 114
 | 
					        Left = 109
 | 
				
			||||||
        Height = 26
 | 
					        Height = 26
 | 
				
			||||||
        Top = 12
 | 
					        Top = 12
 | 
				
			||||||
        Width = 47
 | 
					        Width = 47
 | 
				
			||||||
@ -152,9 +152,9 @@ object frmMain: TfrmMain
 | 
				
			|||||||
        AnchorSideRight.Side = asrBottom
 | 
					        AnchorSideRight.Side = asrBottom
 | 
				
			||||||
        AnchorSideBottom.Control = spTileList
 | 
					        AnchorSideBottom.Control = spTileList
 | 
				
			||||||
        Left = 6
 | 
					        Left = 6
 | 
				
			||||||
        Height = 313
 | 
					        Height = 319
 | 
				
			||||||
        Hint = '-'
 | 
					        Hint = '-'
 | 
				
			||||||
        Top = 74
 | 
					        Top = 68
 | 
				
			||||||
        Width = 328
 | 
					        Width = 328
 | 
				
			||||||
        Anchors = [akTop, akLeft, akRight, akBottom]
 | 
					        Anchors = [akTop, akLeft, akRight, akBottom]
 | 
				
			||||||
        BorderSpacing.Left = 6
 | 
					        BorderSpacing.Left = 6
 | 
				
			||||||
@ -217,7 +217,7 @@ object frmMain: TfrmMain
 | 
				
			|||||||
        Width = 340
 | 
					        Width = 340
 | 
				
			||||||
        Anchors = [akTop, akLeft, akRight, akBottom]
 | 
					        Anchors = [akTop, akLeft, akRight, akBottom]
 | 
				
			||||||
        Caption = 'Random pool'
 | 
					        Caption = 'Random pool'
 | 
				
			||||||
        ClientHeight = 234
 | 
					        ClientHeight = 237
 | 
				
			||||||
        ClientWidth = 338
 | 
					        ClientWidth = 338
 | 
				
			||||||
        TabOrder = 1
 | 
					        TabOrder = 1
 | 
				
			||||||
        object btnAddRandom: TSpeedButton
 | 
					        object btnAddRandom: TSpeedButton
 | 
				
			||||||
@ -375,7 +375,7 @@ object frmMain: TfrmMain
 | 
				
			|||||||
          Left = 256
 | 
					          Left = 256
 | 
				
			||||||
          Height = 35
 | 
					          Height = 35
 | 
				
			||||||
          Hint = 'Save Preset'
 | 
					          Hint = 'Save Preset'
 | 
				
			||||||
          Top = 186
 | 
					          Top = 189
 | 
				
			||||||
          Width = 35
 | 
					          Width = 35
 | 
				
			||||||
          Anchors = [akTop, akRight]
 | 
					          Anchors = [akTop, akRight]
 | 
				
			||||||
          BorderSpacing.Right = 6
 | 
					          BorderSpacing.Right = 6
 | 
				
			||||||
@ -427,7 +427,7 @@ object frmMain: TfrmMain
 | 
				
			|||||||
          Left = 297
 | 
					          Left = 297
 | 
				
			||||||
          Height = 35
 | 
					          Height = 35
 | 
				
			||||||
          Hint = 'Delete Preset'
 | 
					          Hint = 'Delete Preset'
 | 
				
			||||||
          Top = 186
 | 
					          Top = 189
 | 
				
			||||||
          Width = 35
 | 
					          Width = 35
 | 
				
			||||||
          Anchors = [akTop, akRight]
 | 
					          Anchors = [akTop, akRight]
 | 
				
			||||||
          BorderSpacing.Right = 6
 | 
					          BorderSpacing.Right = 6
 | 
				
			||||||
@ -482,7 +482,7 @@ object frmMain: TfrmMain
 | 
				
			|||||||
          AnchorSideBottom.Control = cbRandomPreset
 | 
					          AnchorSideBottom.Control = cbRandomPreset
 | 
				
			||||||
          Cursor = 63
 | 
					          Cursor = 63
 | 
				
			||||||
          Left = 6
 | 
					          Left = 6
 | 
				
			||||||
          Height = 143
 | 
					          Height = 146
 | 
				
			||||||
          Top = 37
 | 
					          Top = 37
 | 
				
			||||||
          Width = 326
 | 
					          Width = 326
 | 
				
			||||||
          Anchors = [akTop, akLeft, akRight, akBottom]
 | 
					          Anchors = [akTop, akLeft, akRight, akBottom]
 | 
				
			||||||
@ -532,7 +532,7 @@ object frmMain: TfrmMain
 | 
				
			|||||||
          AnchorSideBottom.Side = asrBottom
 | 
					          AnchorSideBottom.Side = asrBottom
 | 
				
			||||||
          Left = 6
 | 
					          Left = 6
 | 
				
			||||||
          Height = 42
 | 
					          Height = 42
 | 
				
			||||||
          Top = 186
 | 
					          Top = 189
 | 
				
			||||||
          Width = 244
 | 
					          Width = 244
 | 
				
			||||||
          Anchors = [akLeft, akRight, akBottom]
 | 
					          Anchors = [akLeft, akRight, akBottom]
 | 
				
			||||||
          BorderSpacing.Left = 6
 | 
					          BorderSpacing.Left = 6
 | 
				
			||||||
@ -585,10 +585,10 @@ object frmMain: TfrmMain
 | 
				
			|||||||
        AnchorSideTop.Side = asrBottom
 | 
					        AnchorSideTop.Side = asrBottom
 | 
				
			||||||
        AnchorSideRight.Control = tsTiles
 | 
					        AnchorSideRight.Control = tsTiles
 | 
				
			||||||
        AnchorSideRight.Side = asrBottom
 | 
					        AnchorSideRight.Side = asrBottom
 | 
				
			||||||
        Left = 114
 | 
					        Left = 109
 | 
				
			||||||
        Height = 38
 | 
					        Height = 38
 | 
				
			||||||
        Top = 38
 | 
					        Top = 38
 | 
				
			||||||
        Width = 201
 | 
					        Width = 206
 | 
				
			||||||
        Anchors = [akTop, akLeft, akRight]
 | 
					        Anchors = [akTop, akLeft, akRight]
 | 
				
			||||||
        BorderSpacing.Right = 25
 | 
					        BorderSpacing.Right = 25
 | 
				
			||||||
        OnEditingDone = edFilterEditingDone
 | 
					        OnEditingDone = edFilterEditingDone
 | 
				
			||||||
@ -600,9 +600,9 @@ object frmMain: TfrmMain
 | 
				
			|||||||
        AnchorSideTop.Control = cbTerrain
 | 
					        AnchorSideTop.Control = cbTerrain
 | 
				
			||||||
        AnchorSideTop.Side = asrBottom
 | 
					        AnchorSideTop.Side = asrBottom
 | 
				
			||||||
        Left = 8
 | 
					        Left = 8
 | 
				
			||||||
        Height = 28
 | 
					        Height = 25
 | 
				
			||||||
        Top = 40
 | 
					        Top = 37
 | 
				
			||||||
        Width = 79
 | 
					        Width = 74
 | 
				
			||||||
        Caption = 'Statics'
 | 
					        Caption = 'Statics'
 | 
				
			||||||
        Checked = True
 | 
					        Checked = True
 | 
				
			||||||
        OnChange = cbStaticsChange
 | 
					        OnChange = cbStaticsChange
 | 
				
			||||||
@ -613,9 +613,9 @@ object frmMain: TfrmMain
 | 
				
			|||||||
        AnchorSideLeft.Control = tsTiles
 | 
					        AnchorSideLeft.Control = tsTiles
 | 
				
			||||||
        AnchorSideTop.Control = tsTiles
 | 
					        AnchorSideTop.Control = tsTiles
 | 
				
			||||||
        Left = 6
 | 
					        Left = 6
 | 
				
			||||||
        Height = 28
 | 
					        Height = 25
 | 
				
			||||||
        Top = 12
 | 
					        Top = 12
 | 
				
			||||||
        Width = 83
 | 
					        Width = 78
 | 
				
			||||||
        BorderSpacing.Left = 6
 | 
					        BorderSpacing.Left = 6
 | 
				
			||||||
        BorderSpacing.Top = 12
 | 
					        BorderSpacing.Top = 12
 | 
				
			||||||
        Caption = 'Terrain'
 | 
					        Caption = 'Terrain'
 | 
				
			||||||
@ -824,7 +824,7 @@ object frmMain: TfrmMain
 | 
				
			|||||||
          item
 | 
					          item
 | 
				
			||||||
            Position = 1
 | 
					            Position = 1
 | 
				
			||||||
            Text = 'Name'
 | 
					            Text = 'Name'
 | 
				
			||||||
            Width = 208
 | 
					            Width = 206
 | 
				
			||||||
          end>
 | 
					          end>
 | 
				
			||||||
        Header.DefaultHeight = 26
 | 
					        Header.DefaultHeight = 26
 | 
				
			||||||
        Header.Height = 26
 | 
					        Header.Height = 26
 | 
				
			||||||
@ -874,6 +874,7 @@ object frmMain: TfrmMain
 | 
				
			|||||||
        TreeOptions.MiscOptions = [toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning]
 | 
					        TreeOptions.MiscOptions = [toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning]
 | 
				
			||||||
        TreeOptions.PaintOptions = [toShowButtons, toShowDropmark, toThemeAware, toUseBlendedImages]
 | 
					        TreeOptions.PaintOptions = [toShowButtons, toShowDropmark, toThemeAware, toUseBlendedImages]
 | 
				
			||||||
        TreeOptions.SelectionOptions = [toFullRowSelect]
 | 
					        TreeOptions.SelectionOptions = [toFullRowSelect]
 | 
				
			||||||
 | 
					        OnDblClick = vstUoaDesignsDblClick
 | 
				
			||||||
        OnGetText = vstUoaDesignsGetText
 | 
					        OnGetText = vstUoaDesignsGetText
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
				
			|||||||
@ -322,6 +322,7 @@ type
 | 
				
			|||||||
      Column: TColumnIndex; const NewText: String);
 | 
					      Column: TColumnIndex; const NewText: String);
 | 
				
			||||||
    procedure vstLocationsSaveNode(Sender: TBaseVirtualTree;
 | 
					    procedure vstLocationsSaveNode(Sender: TBaseVirtualTree;
 | 
				
			||||||
      Node: PVirtualNode; Stream: TStream);
 | 
					      Node: PVirtualNode; Stream: TStream);
 | 
				
			||||||
 | 
					    procedure vstUoaDesignsDblClick(Sender: TObject);
 | 
				
			||||||
    procedure vstUoaDesignsGetText(Sender: TBaseVirtualTree;
 | 
					    procedure vstUoaDesignsGetText(Sender: TBaseVirtualTree;
 | 
				
			||||||
      Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
 | 
					      Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
 | 
				
			||||||
      var CellText: String);
 | 
					      var CellText: String);
 | 
				
			||||||
@ -377,6 +378,7 @@ type
 | 
				
			|||||||
    procedure LoadRandomPresets;
 | 
					    procedure LoadRandomPresets;
 | 
				
			||||||
    procedure LoadUoaDesigns;
 | 
					    procedure LoadUoaDesigns;
 | 
				
			||||||
    procedure MoveBy(AOffsetX, AOffsetY: Integer); inline;
 | 
					    procedure MoveBy(AOffsetX, AOffsetY: Integer); inline;
 | 
				
			||||||
 | 
					    procedure PlaceUoaDesign(AWorldItem: TWorldItem);
 | 
				
			||||||
    procedure PrepareMapCell(AMapCell: TMapCell);
 | 
					    procedure PrepareMapCell(AMapCell: TMapCell);
 | 
				
			||||||
    procedure PrepareScreenBlock(ABlockInfo: PBlockInfo);
 | 
					    procedure PrepareScreenBlock(ABlockInfo: PBlockInfo);
 | 
				
			||||||
    procedure ProcessToolState;
 | 
					    procedure ProcessToolState;
 | 
				
			||||||
@ -1986,6 +1988,11 @@ begin
 | 
				
			|||||||
  Stream.Write(locationInfo^.Name[1], stringLength);
 | 
					  Stream.Write(locationInfo^.Name[1], stringLength);
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					procedure TfrmMain.vstUoaDesignsDblClick(Sender: TObject);
 | 
				
			||||||
 | 
					begin
 | 
				
			||||||
 | 
					  RegisterSelectionListener(@PlaceUoaDesign);
 | 
				
			||||||
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
procedure TfrmMain.vstUoaDesignsGetText(Sender: TBaseVirtualTree;
 | 
					procedure TfrmMain.vstUoaDesignsGetText(Sender: TBaseVirtualTree;
 | 
				
			||||||
  Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
 | 
					  Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
 | 
				
			||||||
  var CellText: String);
 | 
					  var CellText: String);
 | 
				
			||||||
@ -2060,7 +2067,8 @@ end;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
procedure TfrmMain.RegisterSelectionListener(AListener: TSelectionListener);
 | 
					procedure TfrmMain.RegisterSelectionListener(AListener: TSelectionListener);
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
  FSelectionListeners.Add(AListener);
 | 
					  if FSelectionListeners.IndexOf(AListener) = -1 then
 | 
				
			||||||
 | 
					    FSelectionListeners.Add(AListener);
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
procedure TfrmMain.UnregisterAccessChangedListener(
 | 
					procedure TfrmMain.UnregisterAccessChangedListener(
 | 
				
			||||||
@ -2273,6 +2281,33 @@ begin
 | 
				
			|||||||
  UpdateCurrentTile;
 | 
					  UpdateCurrentTile;
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					procedure TfrmMain.PlaceUoaDesign(AWorldItem: TWorldItem);
 | 
				
			||||||
 | 
					var
 | 
				
			||||||
 | 
					  selectedNode: PVirtualNode;
 | 
				
			||||||
 | 
					  header: TUoaDesignHeader;
 | 
				
			||||||
 | 
					  tiles: TStaticItemList;
 | 
				
			||||||
 | 
					  newTile: TStaticItem;
 | 
				
			||||||
 | 
					begin
 | 
				
			||||||
 | 
					  UnregisterSelectionListener(@PlaceUoaDesign);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  selectedNode := vstUoaDesigns.GetFirstSelected();
 | 
				
			||||||
 | 
					  if selectedNode = nil then
 | 
				
			||||||
 | 
					    Exit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  header := FUoaDesigns.Headers[selectedNode^.Index];
 | 
				
			||||||
 | 
					  tiles := FUoaDesigns.LoadTiles(header, AWorldItem.X, AWorldItem.Y, AWorldItem.Z);
 | 
				
			||||||
 | 
					  try
 | 
				
			||||||
 | 
					    FUndoList.Clear;
 | 
				
			||||||
 | 
					    for newTile in tiles do
 | 
				
			||||||
 | 
					    begin
 | 
				
			||||||
 | 
					      dmNetwork.Send(TInsertStaticPacket.Create(newTile));
 | 
				
			||||||
 | 
					      FUndoList.Add(TDeleteStaticPacket.Create(newTile));
 | 
				
			||||||
 | 
					    end;
 | 
				
			||||||
 | 
					  finally
 | 
				
			||||||
 | 
					    tiles.Free;
 | 
				
			||||||
 | 
					  end;
 | 
				
			||||||
 | 
					end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
procedure TfrmMain.PrepareMapCell(AMapCell: TMapCell);
 | 
					procedure TfrmMain.PrepareMapCell(AMapCell: TMapCell);
 | 
				
			||||||
var
 | 
					var
 | 
				
			||||||
  current, north, east, west: PBlockInfo;
 | 
					  current, north, east, west: PBlockInfo;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user