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 OnDblClick = vstUoaDesignsDblClick
OnGetText = vstUoaDesignsGetText OnGetText = vstUoaDesignsGetText
end 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
end end
object tbMain: TToolBar object tbMain: TToolBar

View File

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