- Changed handling of CurrentTile and SelectedTile to avoid unnecessary invalidations
This commit is contained in:
parent
94d77d4a00
commit
6c9a474003
|
@ -492,7 +492,6 @@ begin
|
||||||
(frmMoveSettings.Visible and (fsModal in frmMoveSettings.FormState))
|
(frmMoveSettings.Visible and (fsModal in frmMoveSettings.FormState))
|
||||||
) then //during confirmation the mouse would leave ...
|
) then //during confirmation the mouse would leave ...
|
||||||
begin
|
begin
|
||||||
lblTileInfo.Caption := '';
|
|
||||||
CurrentTile := nil;
|
CurrentTile := nil;
|
||||||
FOverlayUI.Visible := False;
|
FOverlayUI.Visible := False;
|
||||||
end;
|
end;
|
||||||
|
@ -520,9 +519,6 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
lblTileInfo.Caption := '';
|
|
||||||
CurrentTile := nil;
|
|
||||||
|
|
||||||
UpdateCurrentTile(X, Y);
|
UpdateCurrentTile(X, Y);
|
||||||
|
|
||||||
FRepaintNeeded := True;
|
FRepaintNeeded := True;
|
||||||
|
@ -1620,17 +1616,49 @@ end;
|
||||||
|
|
||||||
procedure TfrmMain.SetCurrentTile(const AValue: TWorldItem);
|
procedure TfrmMain.SetCurrentTile(const AValue: TWorldItem);
|
||||||
begin
|
begin
|
||||||
|
if AValue = FSelectedTile then
|
||||||
|
Exit;
|
||||||
|
|
||||||
if FCurrentTile <> nil then
|
if FCurrentTile <> nil then
|
||||||
FCurrentTile.OnDestroy.UnregisterEvent(@OnTileRemoved);
|
FCurrentTile.OnDestroy.UnregisterEvent(@OnTileRemoved);
|
||||||
FCurrentTile := AValue;
|
FCurrentTile := AValue;
|
||||||
if FCurrentTile <> nil then
|
|
||||||
|
if FCurrentTile = nil then
|
||||||
|
begin
|
||||||
|
lblTileInfo.Caption := '';
|
||||||
|
end else
|
||||||
|
begin
|
||||||
FCurrentTile.OnDestroy.RegisterEvent(@OnTileRemoved);
|
FCurrentTile.OnDestroy.RegisterEvent(@OnTileRemoved);
|
||||||
|
if FCurrentTile is TVirtualTile then
|
||||||
|
lblTileInfo.Caption := Format('Virtual Layer: X: %d, Y: %d, Z: %d', [FCurrentTile.X, FCurrentTile.Y, FCurrentTile.Z])
|
||||||
|
else if FCurrentTile is TMapCell then
|
||||||
|
lblTileInfo.Caption := Format('Terrain TileID: $%x, X: %d, Y: %d, Z: %d', [FCurrentTile.TileID, FCurrentTile.X, FCurrentTile.Y, FCurrentTile.Z])
|
||||||
|
else if FCurrentTile is TStaticItem then
|
||||||
|
lblTileInfo.Caption := Format('Static TileID: $%x, X: %d, Y: %d, Z: %d, Hue: $%x', [FCurrentTile.TileID, FCurrentTile.X, FCurrentTile.Y, FCurrentTile.Z, TStaticItem(FCurrentTile).Hue]);
|
||||||
|
|
||||||
|
if (acDraw.Checked) and (SelectedTile = nil) then
|
||||||
|
begin
|
||||||
|
if FGhostTile <> nil then
|
||||||
|
begin
|
||||||
|
if (FGhostTile is TStaticItem) and (not frmDrawSettings.cbForceAltitude.Checked) then
|
||||||
|
begin
|
||||||
|
FGhostTile.Z := CurrentTile.Z;
|
||||||
|
if FCurrentTile is TStaticItem then
|
||||||
|
FGhostTile.Z := FGhostTile.Z + ResMan.Tiledata.StaticTiles[FCurrentTile.TileID].Height;
|
||||||
|
end else
|
||||||
|
FGhostTile.Z := frmDrawSettings.seForceAltitude.Value;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
UpdateSelection;
|
UpdateSelection;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmMain.SetSelectedTile(const AValue: TWorldItem);
|
procedure TfrmMain.SetSelectedTile(const AValue: TWorldItem);
|
||||||
begin
|
begin
|
||||||
|
if AValue = FSelectedTile then
|
||||||
|
Exit;
|
||||||
|
|
||||||
if FSelectedTile <> nil then
|
if FSelectedTile <> nil then
|
||||||
FSelectedTile.OnDestroy.UnregisterEvent(@OnTileRemoved);
|
FSelectedTile.OnDestroy.UnregisterEvent(@OnTileRemoved);
|
||||||
FSelectedTile := AValue;
|
FSelectedTile := AValue;
|
||||||
|
@ -2211,12 +2239,20 @@ var
|
||||||
node: PVirtualNode;
|
node: PVirtualNode;
|
||||||
tileInfo: PTileInfo;
|
tileInfo: PTileInfo;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
blockInfo: PBlockInfo;
|
||||||
begin
|
begin
|
||||||
if acSelect.Checked then
|
if acSelect.Checked then
|
||||||
begin
|
begin
|
||||||
//lblTip.Caption := 'Right click shows a menu with all the tools.';
|
//lblTip.Caption := 'Right click shows a menu with all the tools.';
|
||||||
lblTip.Caption := 'Press and hold the left mouse button to show a list with actions (eg. grab hue).';
|
lblTip.Caption := 'Press and hold the left mouse button to show a list with actions (eg. grab hue).';
|
||||||
oglGameWindow.Cursor := crDefault;
|
oglGameWindow.Cursor := crDefault;
|
||||||
|
|
||||||
|
//no highlighted tiles in "selection" mode
|
||||||
|
Logger.Send([lcClient, lcDebug], 'Disable highlighting');
|
||||||
|
blockInfo := nil;
|
||||||
|
while FScreenBuffer.Iterate(blockInfo) do
|
||||||
|
if blockInfo^.State = ssNormal then
|
||||||
|
blockInfo^.Highlighted := False;
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
lblTip.Caption := 'Press and hold the left mouse button to target an area.';
|
lblTip.Caption := 'Press and hold the left mouse button to target an area.';
|
||||||
|
@ -2369,34 +2405,18 @@ var
|
||||||
info: PBlockInfo;
|
info: PBlockInfo;
|
||||||
begin
|
begin
|
||||||
FOverlayUI.ActiveArrow := FOverlayUI.HitTest(AX, AY);
|
FOverlayUI.ActiveArrow := FOverlayUI.HitTest(AX, AY);
|
||||||
if FOverlayUI.ActiveArrow > -1 then Exit;
|
if FOverlayUI.ActiveArrow > -1 then
|
||||||
|
begin
|
||||||
|
CurrentTile := nil;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
info := FScreenBuffer.Find(Point(AX, AY));
|
info := FScreenBuffer.Find(Point(AX, AY));
|
||||||
if info <> nil then
|
if info <> nil then
|
||||||
begin
|
begin
|
||||||
CurrentTile := info^.Item;
|
CurrentTile := info^.Item;
|
||||||
|
|
||||||
if CurrentTile is TVirtualTile then
|
|
||||||
lblTileInfo.Caption := Format('Virtual Layer: X: %d, Y: %d, Z: %d', [CurrentTile.X, CurrentTile.Y, CurrentTile.Z])
|
|
||||||
else if CurrentTile is TMapCell then
|
|
||||||
lblTileInfo.Caption := Format('Terrain TileID: $%x, X: %d, Y: %d, Z: %d', [CurrentTile.TileID, CurrentTile.X, CurrentTile.Y, CurrentTile.Z])
|
|
||||||
else
|
|
||||||
lblTileInfo.Caption := Format('Static TileID: $%x, X: %d, Y: %d, Z: %d, Hue: $%x', [CurrentTile.TileID, CurrentTile.X, CurrentTile.Y, CurrentTile.Z, TStaticItem(CurrentTile).Hue]);
|
|
||||||
|
|
||||||
if (acDraw.Checked) and (SelectedTile = nil) then
|
|
||||||
begin
|
|
||||||
if FGhostTile <> nil then
|
|
||||||
begin
|
|
||||||
if (FGhostTile is TStaticItem) and (not frmDrawSettings.cbForceAltitude.Checked) then
|
|
||||||
begin
|
|
||||||
FGhostTile.Z := CurrentTile.Z;
|
|
||||||
if CurrentTile is TStaticItem then
|
|
||||||
FGhostTile.Z := FGhostTile.Z + ResMan.Tiledata.StaticTiles[CurrentTile.TileID].Height;
|
|
||||||
end else
|
end else
|
||||||
FGhostTile.Z := frmDrawSettings.seForceAltitude.Value;
|
CurrentTile := nil;
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmMain.UpdateFilter;
|
procedure TfrmMain.UpdateFilter;
|
||||||
|
@ -2429,32 +2449,27 @@ var
|
||||||
selectedRect: TRect;
|
selectedRect: TRect;
|
||||||
blockInfo: PBlockInfo;
|
blockInfo: PBlockInfo;
|
||||||
begin
|
begin
|
||||||
if acSelect.Checked then
|
Logger.EnterMethod([lcClient, lcDebug], 'UpdateSelection');
|
||||||
begin
|
if (CurrentTile <> nil) and (not acSelect.Checked) then
|
||||||
//no highlighted tiles in "selection" mode
|
|
||||||
blockInfo := nil;
|
|
||||||
while FScreenBuffer.Iterate(blockInfo) do
|
|
||||||
if blockInfo^.State = ssNormal then
|
|
||||||
blockInfo^.Highlighted := False;
|
|
||||||
Exit;
|
|
||||||
end;
|
|
||||||
|
|
||||||
if CurrentTile <> nil then
|
|
||||||
begin
|
begin
|
||||||
blockInfo := nil;
|
blockInfo := nil;
|
||||||
if (SelectedTile <> nil) and (CurrentTile <> SelectedTile) then
|
if (SelectedTile <> nil) and (CurrentTile <> SelectedTile) then
|
||||||
begin
|
begin
|
||||||
|
Logger.Send([lcClient, lcDebug], 'Multiple Targets');
|
||||||
selectedRect := GetSelectedRect;
|
selectedRect := GetSelectedRect;
|
||||||
|
Logger.Send([lcClient, lcDebug], 'SelectedRect', selectedRect);
|
||||||
while FScreenBuffer.Iterate(blockInfo) do
|
while FScreenBuffer.Iterate(blockInfo) do
|
||||||
if blockInfo^.State = ssNormal then
|
if blockInfo^.State = ssNormal then
|
||||||
blockInfo^.Highlighted := PtInRect(selectedRect, Point(blockInfo^.Item.X, blockInfo^.Item.Y));
|
blockInfo^.Highlighted := PtInRect(selectedRect, Point(blockInfo^.Item.X, blockInfo^.Item.Y));
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
|
Logger.Send([lcClient, lcDebug], 'Single Target');
|
||||||
while FScreenBuffer.Iterate(blockInfo) do
|
while FScreenBuffer.Iterate(blockInfo) do
|
||||||
if blockInfo^.State = ssNormal then
|
if blockInfo^.State = ssNormal then
|
||||||
blockInfo^.Highlighted := (blockInfo^.Item = CurrentTile);
|
blockInfo^.Highlighted := (blockInfo^.Item = CurrentTile);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Logger.ExitMethod([lcClient, lcDebug], 'UpdateSelection');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmMain.OnTileRemoved(ATile: TMulBlock);
|
procedure TfrmMain.OnTileRemoved(ATile: TMulBlock);
|
||||||
|
|
Loading…
Reference in New Issue