- Added TLandscape.OnMapChanged to handle changes to map tiles
- Reenabled terrain, statics, nodraw and flat toggles - Fixed editing target list generation (in OnMouseUp) to only consider "normal" tiles, use their correct new order and the CanBeEdited attribute - Removed obsolete TfrmMain.CanBeModified
This commit is contained in:
parent
2ea8601402
commit
1f1f5ac7b4
|
@ -115,6 +115,7 @@ type
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TLandscapeChangeEvent = procedure of object;
|
TLandscapeChangeEvent = procedure of object;
|
||||||
|
TMapChangedEvent = procedure(AMapCell: TMapCell) of object;
|
||||||
TNewBlockEvent = procedure(ABlock: TBlock) of object;
|
TNewBlockEvent = procedure(ABlock: TBlock) of object;
|
||||||
TStaticChangedEvent = procedure(AStaticItem: TStaticItem) of object;
|
TStaticChangedEvent = procedure(AStaticItem: TStaticItem) of object;
|
||||||
TStaticFilter = function(AStatic: TStaticItem): Boolean of object;
|
TStaticFilter = function(AStatic: TStaticItem): Boolean of object;
|
||||||
|
@ -134,6 +135,7 @@ type
|
||||||
FCellHeight: Word;
|
FCellHeight: Word;
|
||||||
FBlockCache: TCacheManager;
|
FBlockCache: TCacheManager;
|
||||||
FOnChange: TLandscapeChangeEvent;
|
FOnChange: TLandscapeChangeEvent;
|
||||||
|
FOnMapChanged: TMapChangedEvent;
|
||||||
FOnNewBlock: TNewBlockEvent;
|
FOnNewBlock: TNewBlockEvent;
|
||||||
FOnStaticInserted: TStaticChangedEvent;
|
FOnStaticInserted: TStaticChangedEvent;
|
||||||
FOnStaticDeleted: TStaticChangedEvent;
|
FOnStaticDeleted: TStaticChangedEvent;
|
||||||
|
@ -165,6 +167,7 @@ type
|
||||||
property StaticList[X, Y: Word]: TList read GetStaticList;
|
property StaticList[X, Y: Word]: TList read GetStaticList;
|
||||||
property Normals[X, Y: Word]: TNormals read GetNormals;
|
property Normals[X, Y: Word]: TNormals read GetNormals;
|
||||||
property OnChange: TLandscapeChangeEvent read FOnChange write FOnChange;
|
property OnChange: TLandscapeChangeEvent read FOnChange write FOnChange;
|
||||||
|
property OnMapChanged: TMapChangedEvent read FOnMapChanged write FOnMapChanged;
|
||||||
property OnNewBlock: TNewBlockEvent read FOnNewBlock write FOnNewBlock;
|
property OnNewBlock: TNewBlockEvent read FOnNewBlock write FOnNewBlock;
|
||||||
property OnStaticInserted: TStaticChangedEvent read FOnStaticInserted
|
property OnStaticInserted: TStaticChangedEvent read FOnStaticInserted
|
||||||
write FOnStaticInserted;
|
write FOnStaticInserted;
|
||||||
|
@ -648,7 +651,7 @@ begin
|
||||||
begin
|
begin
|
||||||
cell.Altitude := ABuffer.ReadShortInt;
|
cell.Altitude := ABuffer.ReadShortInt;
|
||||||
cell.TileID := ABuffer.ReadWord;
|
cell.TileID := ABuffer.ReadWord;
|
||||||
if Assigned(FOnChange) then FOnChange;
|
if Assigned(FOnMapChanged) then FOnMapChanged(cell);
|
||||||
end;
|
end;
|
||||||
//TODO : update surrounding normals
|
//TODO : update surrounding normals
|
||||||
end;
|
end;
|
||||||
|
|
|
@ -946,6 +946,7 @@ object frmMain: TfrmMain
|
||||||
ParentShowHint = False
|
ParentShowHint = False
|
||||||
ShowHint = True
|
ShowHint = True
|
||||||
Style = tbsCheck
|
Style = tbsCheck
|
||||||
|
OnClick = tbTerrainClick
|
||||||
end
|
end
|
||||||
object tbStatics: TToolButton
|
object tbStatics: TToolButton
|
||||||
Left = 300
|
Left = 300
|
||||||
|
@ -957,6 +958,7 @@ object frmMain: TfrmMain
|
||||||
ParentShowHint = False
|
ParentShowHint = False
|
||||||
ShowHint = True
|
ShowHint = True
|
||||||
Style = tbsCheck
|
Style = tbsCheck
|
||||||
|
OnClick = tbStaticsClick
|
||||||
end
|
end
|
||||||
object tbSeparator4: TToolButton
|
object tbSeparator4: TToolButton
|
||||||
Left = 369
|
Left = 369
|
||||||
|
|
|
@ -34,7 +34,7 @@ uses
|
||||||
ComCtrls, OpenGLContext, GL, GLU, UGameResources, ULandscape, ExtCtrls,
|
ComCtrls, OpenGLContext, GL, GLU, UGameResources, ULandscape, ExtCtrls,
|
||||||
StdCtrls, Spin, UEnums, VirtualTrees, Buttons, UMulBlock, UWorldItem, math,
|
StdCtrls, Spin, UEnums, VirtualTrees, Buttons, UMulBlock, UWorldItem, math,
|
||||||
LCLIntf, UOverlayUI, UStatics, UEnhancedMemoryStream, ActnList,
|
LCLIntf, UOverlayUI, UStatics, UEnhancedMemoryStream, ActnList,
|
||||||
ImagingClasses, dateutils, UPlatformTypes, UVector;
|
ImagingClasses, dateutils, UPlatformTypes, UVector, UMap;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
@ -217,6 +217,8 @@ type
|
||||||
procedure tbFilterMouseMove(Sender: TObject; Shift: TShiftState; X,
|
procedure tbFilterMouseMove(Sender: TObject; Shift: TShiftState; X,
|
||||||
Y: Integer);
|
Y: Integer);
|
||||||
procedure tbRadarMapClick(Sender: TObject);
|
procedure tbRadarMapClick(Sender: TObject);
|
||||||
|
procedure tbStaticsClick(Sender: TObject);
|
||||||
|
procedure tbTerrainClick(Sender: TObject);
|
||||||
procedure tmGrabTileInfoTimer(Sender: TObject);
|
procedure tmGrabTileInfoTimer(Sender: TObject);
|
||||||
procedure tmMovementTimer(Sender: TObject);
|
procedure tmMovementTimer(Sender: TObject);
|
||||||
procedure tmTileHintTimer(Sender: TObject);
|
procedure tmTileHintTimer(Sender: TObject);
|
||||||
|
@ -288,7 +290,6 @@ type
|
||||||
FAccessChangedListeners: array of TAccessChangedListener;
|
FAccessChangedListeners: array of TAccessChangedListener;
|
||||||
{ Methods }
|
{ Methods }
|
||||||
procedure BuildTileList;
|
procedure BuildTileList;
|
||||||
function CanBeModified(ATile: TWorldItem): Boolean;
|
|
||||||
function ConfirmAction: Boolean;
|
function ConfirmAction: Boolean;
|
||||||
procedure GetDrawOffset(ARelativeX, ARelativeY: Integer; out DrawX,
|
procedure GetDrawOffset(ARelativeX, ARelativeY: Integer; out DrawX,
|
||||||
DrawY: Single); inline;
|
DrawY: Single); inline;
|
||||||
|
@ -316,6 +317,7 @@ type
|
||||||
{ Events }
|
{ Events }
|
||||||
procedure OnClientHandlingPacket(ABuffer: TEnhancedMemoryStream);
|
procedure OnClientHandlingPacket(ABuffer: TEnhancedMemoryStream);
|
||||||
procedure OnLandscapeChanged;
|
procedure OnLandscapeChanged;
|
||||||
|
procedure OnMapChanged(AMapCell: TMapCell);
|
||||||
procedure OnNewBlock(ABlock: TBlock);
|
procedure OnNewBlock(ABlock: TBlock);
|
||||||
procedure OnStaticDeleted(AStaticItem: TStaticItem);
|
procedure OnStaticDeleted(AStaticItem: TStaticItem);
|
||||||
procedure OnStaticElevated(AStaticItem: TStaticItem);
|
procedure OnStaticElevated(AStaticItem: TStaticItem);
|
||||||
|
@ -341,7 +343,7 @@ var
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
UdmNetwork, UMap, UArt, UTiledata, UHue, UAdminHandling, UPackets,
|
UdmNetwork, UArt, UTiledata, UHue, UAdminHandling, UPackets,
|
||||||
UfrmAccountControl, UGraphicHelper, ImagingComponents, UfrmDrawSettings,
|
UfrmAccountControl, UGraphicHelper, ImagingComponents, UfrmDrawSettings,
|
||||||
UfrmBoundaries, UfrmElevateSettings, UfrmConfirmation, UfrmMoveSettings,
|
UfrmBoundaries, UfrmElevateSettings, UfrmConfirmation, UfrmMoveSettings,
|
||||||
UfrmAbout, UPacketHandlers, UfrmHueSettings, UfrmRadar, UfrmLargeScaleCommand,
|
UfrmAbout, UPacketHandlers, UfrmHueSettings, UfrmRadar, UfrmLargeScaleCommand,
|
||||||
|
@ -590,7 +592,7 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end else if (SelectedTile <> targetTile) or CanBeModified(targetTile) then
|
end else if (SelectedTile <> targetTile) or targetTile.CanBeEdited then
|
||||||
begin
|
begin
|
||||||
if (not acMove.Checked) or (SelectedTile <> targetTile) or
|
if (not acMove.Checked) or (SelectedTile <> targetTile) or
|
||||||
(not frmMoveSettings.cbAsk.Checked) or ConfirmAction then
|
(not frmMoveSettings.cbAsk.Checked) or ConfirmAction then
|
||||||
|
@ -604,9 +606,12 @@ begin
|
||||||
blockInfo := nil;
|
blockInfo := nil;
|
||||||
while FScreenBuffer.Iterate(blockInfo) do
|
while FScreenBuffer.Iterate(blockInfo) do
|
||||||
begin
|
begin
|
||||||
if PtInRect(targetRect, Point(blockInfo^.Item.X, blockInfo^.Item.Y)) and
|
if (blockInfo^.State = ssNormal) and
|
||||||
CanBeModified(blockInfo^.Item) then
|
blockInfo^.Item.CanBeEdited and
|
||||||
targetTiles.Insert(0, blockInfo^.Item);
|
PtInRect(targetRect, Point(blockInfo^.Item.X, blockInfo^.Item.Y)) then
|
||||||
|
begin
|
||||||
|
targetTiles.Add(blockInfo^.Item);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -724,6 +729,7 @@ var
|
||||||
begin
|
begin
|
||||||
FLandscape := ResMan.Landscape;
|
FLandscape := ResMan.Landscape;
|
||||||
FLandscape.OnChange := @OnLandscapeChanged;
|
FLandscape.OnChange := @OnLandscapeChanged;
|
||||||
|
FLandscape.OnMapChanged := @OnMapChanged;
|
||||||
FLandscape.OnNewBlock := @OnNewBlock;
|
FLandscape.OnNewBlock := @OnNewBlock;
|
||||||
FLandscape.OnStaticDeleted := @OnStaticDeleted;
|
FLandscape.OnStaticDeleted := @OnStaticDeleted;
|
||||||
FLandscape.OnStaticElevated := @OnStaticElevated;
|
FLandscape.OnStaticElevated := @OnStaticElevated;
|
||||||
|
@ -931,6 +937,7 @@ end;
|
||||||
procedure TfrmMain.acFlatExecute(Sender: TObject);
|
procedure TfrmMain.acFlatExecute(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
acFlat.Checked := not acFlat.Checked;
|
acFlat.Checked := not acFlat.Checked;
|
||||||
|
RebuildScreenBuffer;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmMain.acHueExecute(Sender: TObject);
|
procedure TfrmMain.acHueExecute(Sender: TObject);
|
||||||
|
@ -958,6 +965,7 @@ end;
|
||||||
procedure TfrmMain.acNoDrawExecute(Sender: TObject);
|
procedure TfrmMain.acNoDrawExecute(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
acNoDraw.Checked := not acNoDraw.Checked;
|
acNoDraw.Checked := not acNoDraw.Checked;
|
||||||
|
RebuildScreenBuffer;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmMain.btnClearRandomClick(Sender: TObject);
|
procedure TfrmMain.btnClearRandomClick(Sender: TObject);
|
||||||
|
@ -1202,6 +1210,16 @@ begin
|
||||||
frmRadarMap.BringToFront;
|
frmRadarMap.BringToFront;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMain.tbStaticsClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
RebuildScreenBuffer;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMain.tbTerrainClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
RebuildScreenBuffer;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TfrmMain.tmGrabTileInfoTimer(Sender: TObject);
|
procedure TfrmMain.tmGrabTileInfoTimer(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
tmGrabTileInfo.Enabled := False;
|
tmGrabTileInfo.Enabled := False;
|
||||||
|
@ -1685,6 +1703,7 @@ begin
|
||||||
|
|
||||||
if item is TMapCell then
|
if item is TMapCell then
|
||||||
begin
|
begin
|
||||||
|
ABlockInfo^.HighRes := nil;
|
||||||
if not acFlat.Checked then
|
if not acFlat.Checked then
|
||||||
begin
|
begin
|
||||||
west := FLandscape.GetLandAlt(item.X, item.Y + 1, z);
|
west := FLandscape.GetLandAlt(item.X, item.Y + 1, z);
|
||||||
|
@ -2027,6 +2046,39 @@ begin
|
||||||
UpdateCurrentTile;
|
UpdateCurrentTile;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TfrmMain.OnMapChanged(AMapCell: TMapCell);
|
||||||
|
var
|
||||||
|
current, north, east, west: PBlockInfo;
|
||||||
|
cell: TMapCell;
|
||||||
|
begin
|
||||||
|
PrepareScreenBlock(FScreenBuffer.UpdateSortOrder(AMapCell));
|
||||||
|
FScreenBufferIndexed := False;
|
||||||
|
|
||||||
|
//Find surrounding cells
|
||||||
|
current := nil;
|
||||||
|
north := nil;
|
||||||
|
east := nil;
|
||||||
|
west := nil;
|
||||||
|
while ((north = nil) or (east = nil) or (west = nil)) and
|
||||||
|
FScreenBuffer.Iterate(current) do
|
||||||
|
begin
|
||||||
|
if current^.Item is TMapCell then
|
||||||
|
begin
|
||||||
|
cell := TMapCell(current^.Item);
|
||||||
|
if (cell.X = AMapCell.X - 1) and (cell.Y = AMapCell.Y - 1) then
|
||||||
|
north := current
|
||||||
|
else if (cell.X = AMapCell.X) and (cell.Y = AMapCell.Y - 1) then
|
||||||
|
east := current
|
||||||
|
else if (cell.X = AMapCell.X - 1) and (cell.Y = AMapCell.Y) then
|
||||||
|
west := current;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if north <> nil then PrepareScreenBlock(north);
|
||||||
|
if east <> nil then PrepareScreenBlock(east);
|
||||||
|
if west <> nil then PrepareScreenBlock(west);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TfrmMain.OnNewBlock(ABlock: TBlock);
|
procedure TfrmMain.OnNewBlock(ABlock: TBlock);
|
||||||
begin
|
begin
|
||||||
InvalidateScreenBuffer;
|
InvalidateScreenBuffer;
|
||||||
|
@ -2496,12 +2548,6 @@ begin
|
||||||
DrawY := (oglGamewindow.Height div 2) + (ARelativeX + ARelativeY) * 22;
|
DrawY := (oglGamewindow.Height div 2) + (ARelativeX + ARelativeY) * 22;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TfrmMain.CanBeModified(ATile: TWorldItem): Boolean;
|
|
||||||
begin
|
|
||||||
Result := (not (ATile is TVirtualTile)) and
|
|
||||||
dmNetwork.CanWrite(ATile.X, ATile.Y);
|
|
||||||
end;
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
{$I UfrmMain.lrs}
|
{$I UfrmMain.lrs}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue