Finish placement as per preview

This commit is contained in:
Andreas Schneider 2022-07-20 19:23:31 +02:00
parent 1753c38eea
commit 54e7209c8d
2 changed files with 56 additions and 14 deletions

View File

@ -877,6 +877,20 @@ object frmMain: TfrmMain
OnDblClick = vstUoaDesignsDblClick
OnGetText = vstUoaDesignsGetText
end
object btnCancelUOAPlacement: TButton
AnchorSideLeft.Control = vstUoaDesigns
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = vstUoaDesigns
AnchorSideTop.Side = asrCenter
Left = 103
Height = 47
Top = 305
Width = 134
Caption = 'Cancel'
OnClick = btnCancelUOAPlacementClick
TabOrder = 1
Visible = False
end
end
end
object tbMain: TToolBar

View File

@ -88,6 +88,7 @@ type
btnGoTo: TButton;
btnRandomPresetDelete: TSpeedButton;
btnRandomPresetSave: TSpeedButton;
btnCancelUOAPlacement: TButton;
cbRandomPreset: TComboBox;
cbStatics: TCheckBox;
cbTerrain: TCheckBox;
@ -219,6 +220,7 @@ type
var CanShow: Boolean; var HintInfo: THintInfo);
procedure btnAddLocationClick(Sender: TObject);
procedure btnAddRandomClick(Sender: TObject);
procedure btnCancelUOAPlacementClick(Sender: TObject);
procedure btnClearLocationsClick(Sender: TObject);
procedure btnClearRandomClick(Sender: TObject);
procedure btnDeleteLocationClick(Sender: TObject);
@ -1157,6 +1159,11 @@ begin
vdtRandom.EndUpdate;
end;
procedure TfrmMain.btnCancelUOAPlacementClick(Sender: TObject);
begin
PlaceUoaDesign(nil);
end;
procedure TfrmMain.btnClearLocationsClick(Sender: TObject);
begin
if MessageDlg('Are you sure you want to delete all saved locations?',
@ -2014,6 +2021,9 @@ begin
RegisterSelectionListener(@PlaceUoaDesign);
RegisterHoverListener(@PreviewUoaDesign);
vstUoaDesigns.Enabled := False;
btnCancelUOAPlacement.Visible := True;
end;
procedure TfrmMain.vstUoaDesignsGetText(Sender: TBaseVirtualTree;
@ -2319,29 +2329,47 @@ procedure TfrmMain.PlaceUoaDesign(AWorldItem: TWorldItem);
var
selectedNode: PVirtualNode;
header: TUoaDesignHeader;
tiles: TStaticItemList;
newTile: TStaticItem;
item: TWorldItem;
i: Integer;
begin
UnregisterSelectionListener(@PlaceUoaDesign);
UnregisterHoverListener(@PreviewUoaDesign);
FreeAndNil(FCurrentUoaDesign);
FCurrentUoaDesignAnchor := nil;
vstUoaDesigns.Enabled := True;
btnCancelUOAPlacement.Visible := False;
selectedNode := vstUoaDesigns.GetFirstSelected();
if selectedNode = nil then
Exit;
vstUoaDesigns.ClearSelection;
{header := FUoaDesigns.Headers[selectedNode^.Index];
tiles := FUoaDesigns.LoadTiles(header, AWorldItem.X, AWorldItem.Y, AWorldItem.Z);
try
FUndoList.Clear;
for newTile in tiles do
if AWorldItem = nil then
begin
dmNetwork.Send(TInsertStaticPacket.Create(newTile));
FUndoList.Add(TDeleteStaticPacket.Create(newTile));
for i := FVirtualTiles.Count - 1 downto 0 do
begin
if FVirtualTiles[i] is TGhostTile then
begin
FScreenBuffer.Delete(FVirtualTiles[i]);
FVirtualTiles.Delete(i);
end;
finally
tiles.Free;
end;}
end;
Exit;
end;
FUndoList.Clear;
for i := FVirtualTiles.Count - 1 downto 0 do
begin
item := FVirtualTiles[i];
if item is TGhostTile then
begin
dmNetwork.Send(TInsertStaticPacket.Create(TGhostTile(item)));
FUndoList.Add(TDeleteStaticPacket.Create(TGhostTile(item)));
FVirtualTiles.Delete(i);
FScreenBuffer.Delete(item);
end;
end;
vstUoaDesigns.ClearSelection;
end;
procedure TfrmMain.PrepareMapCell(AMapCell: TMapCell);