- Added more appropriate handling of the selection rectangle (no +1 and an own compare function)
This commit is contained in:
parent
e337c931ed
commit
2fdbc698ac
|
@ -287,6 +287,7 @@ type
|
||||||
FLastDraw: TDateTime;
|
FLastDraw: TDateTime;
|
||||||
FAccessChangedListeners: array of TAccessChangedListener;
|
FAccessChangedListeners: array of TAccessChangedListener;
|
||||||
FRepaintNeeded: Boolean;
|
FRepaintNeeded: Boolean;
|
||||||
|
FSelection: TRect;
|
||||||
{ Methods }
|
{ Methods }
|
||||||
procedure BuildTileList;
|
procedure BuildTileList;
|
||||||
function ConfirmAction: Boolean;
|
function ConfirmAction: Boolean;
|
||||||
|
@ -372,6 +373,14 @@ type
|
||||||
const
|
const
|
||||||
CScreenBufferValid = [sbsValid, sbsIndexed, sbsFiltered];
|
CScreenBufferValid = [sbsValid, sbsIndexed, sbsFiltered];
|
||||||
|
|
||||||
|
function IsInRect(const AX, AY: Integer; const ARect: TRect): Boolean; inline;
|
||||||
|
begin
|
||||||
|
Result := (AX >= ARect.Left) and
|
||||||
|
(AX <= ARect.Right) and
|
||||||
|
(AY >= ARect.Top) and
|
||||||
|
(AY <= ARect.Bottom);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TfrmMain }
|
{ TfrmMain }
|
||||||
|
|
||||||
procedure TfrmMain.mnuExitClick(Sender: TObject);
|
procedure TfrmMain.mnuExitClick(Sender: TObject);
|
||||||
|
@ -535,7 +544,7 @@ var
|
||||||
tileX, tileY: Word;
|
tileX, tileY: Word;
|
||||||
offsetX, offsetY: Integer;
|
offsetX, offsetY: Integer;
|
||||||
tile: TWorldItem;
|
tile: TWorldItem;
|
||||||
targetTiles: TList;
|
targetTiles: TWorldItemList;
|
||||||
targetTile: TWorldItem;
|
targetTile: TWorldItem;
|
||||||
begin
|
begin
|
||||||
if Button <> mbLeft then
|
if Button <> mbLeft then
|
||||||
|
@ -604,7 +613,7 @@ 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
|
||||||
begin
|
begin
|
||||||
targetTiles := TList.Create;
|
targetTiles := TWorldItemList.Create(False);
|
||||||
if SelectedTile = targetTile then
|
if SelectedTile = targetTile then
|
||||||
begin
|
begin
|
||||||
targetTiles.Add(targetTile)
|
targetTiles.Add(targetTile)
|
||||||
|
@ -615,7 +624,7 @@ begin
|
||||||
begin
|
begin
|
||||||
if (blockInfo^.State = ssNormal) and
|
if (blockInfo^.State = ssNormal) and
|
||||||
blockInfo^.Item.CanBeEdited and
|
blockInfo^.Item.CanBeEdited and
|
||||||
PtInRect(targetRect, Point(blockInfo^.Item.X, blockInfo^.Item.Y)) then
|
IsInRect(blockInfo^.Item.X, blockInfo^.Item.Y, targetRect) then
|
||||||
begin
|
begin
|
||||||
targetTiles.Add(blockInfo^.Item);
|
targetTiles.Add(blockInfo^.Item);
|
||||||
end;
|
end;
|
||||||
|
@ -628,7 +637,7 @@ begin
|
||||||
offsetY := frmMoveSettings.GetOffsetY;
|
offsetY := frmMoveSettings.GetOffsetY;
|
||||||
for i := 0 to targetTiles.Count - 1 do
|
for i := 0 to targetTiles.Count - 1 do
|
||||||
begin
|
begin
|
||||||
tile := TWorldItem(targetTiles.Items[i]);
|
tile := targetTiles.Items[i];
|
||||||
|
|
||||||
if tile is TStaticItem then
|
if tile is TStaticItem then
|
||||||
begin
|
begin
|
||||||
|
@ -641,7 +650,7 @@ begin
|
||||||
begin
|
begin
|
||||||
for i := 0 to targetTiles.Count - 1 do
|
for i := 0 to targetTiles.Count - 1 do
|
||||||
begin
|
begin
|
||||||
tile := TWorldItem(targetTiles.Items[i]);
|
tile := targetTiles.Items[i];
|
||||||
|
|
||||||
z := frmElevateSettings.seZ.Value;
|
z := frmElevateSettings.seZ.Value;
|
||||||
if frmElevateSettings.rbRaise.Checked then
|
if frmElevateSettings.rbRaise.Checked then
|
||||||
|
@ -664,7 +673,7 @@ begin
|
||||||
begin
|
begin
|
||||||
for i := 0 to targetTiles.Count - 1 do
|
for i := 0 to targetTiles.Count - 1 do
|
||||||
begin
|
begin
|
||||||
tile := TWorldItem(targetTiles.Items[i]);
|
tile := targetTiles.Items[i];
|
||||||
|
|
||||||
if tile is TStaticItem then
|
if tile is TStaticItem then
|
||||||
dmNetwork.Send(TDeleteStaticPacket.Create(TStaticItem(tile)));
|
dmNetwork.Send(TDeleteStaticPacket.Create(TStaticItem(tile)));
|
||||||
|
@ -673,7 +682,7 @@ begin
|
||||||
begin
|
begin
|
||||||
for i := 0 to targetTiles.Count - 1 do
|
for i := 0 to targetTiles.Count - 1 do
|
||||||
begin
|
begin
|
||||||
tile := TWorldItem(targetTiles.Items[i]);
|
tile := targetTiles.Items[i];
|
||||||
|
|
||||||
if (tile is TStaticItem) and
|
if (tile is TStaticItem) and
|
||||||
(TStaticItem(tile).Hue <> frmHueSettings.lbHue.ItemIndex) then
|
(TStaticItem(tile).Hue <> frmHueSettings.lbHue.ItemIndex) then
|
||||||
|
@ -2303,6 +2312,7 @@ var
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Logger.EnterMethod([lcClient, lcDebug], 'UpdateSelection');
|
Logger.EnterMethod([lcClient, lcDebug], 'UpdateSelection');
|
||||||
|
selectedRect := Rect(-1, -1, -1, -1);
|
||||||
if (CurrentTile <> nil) and (not acSelect.Checked) then
|
if (CurrentTile <> nil) and (not acSelect.Checked) then
|
||||||
begin
|
begin
|
||||||
blockInfo := nil;
|
blockInfo := nil;
|
||||||
|
@ -2313,8 +2323,8 @@ begin
|
||||||
Logger.Send([lcClient, lcDebug], 'SelectedRect', selectedRect);
|
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
|
||||||
SetHighlight(blockInfo, PtInRect(selectedRect,
|
SetHighlight(blockInfo, IsInRect(blockInfo^.Item.X, blockInfo^.Item.Y,
|
||||||
Point(blockInfo^.Item.X, blockInfo^.Item.Y)));
|
selectedRect));
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
Logger.Send([lcClient, lcDebug], 'Single Target');
|
Logger.Send([lcClient, lcDebug], 'Single Target');
|
||||||
|
@ -2323,6 +2333,7 @@ begin
|
||||||
SetHighlight(blockInfo, (blockInfo^.Item = CurrentTile));
|
SetHighlight(blockInfo, (blockInfo^.Item = CurrentTile));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
FSelection := selectedRect;
|
||||||
Logger.ExitMethod([lcClient, lcDebug], 'UpdateSelection');
|
Logger.ExitMethod([lcClient, lcDebug], 'UpdateSelection');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -2436,14 +2447,14 @@ begin
|
||||||
begin
|
begin
|
||||||
Result.Left := Min(CurrentTile.X, SelectedTile.X);
|
Result.Left := Min(CurrentTile.X, SelectedTile.X);
|
||||||
Result.Top := Min(CurrentTile.Y, SelectedTile.Y);
|
Result.Top := Min(CurrentTile.Y, SelectedTile.Y);
|
||||||
Result.Right := Max(CurrentTile.X, SelectedTile.X) + 1;
|
Result.Right := Max(CurrentTile.X, SelectedTile.X);
|
||||||
Result.Bottom := Max(CurrentTile.Y, SelectedTile.Y) + 1;
|
Result.Bottom := Max(CurrentTile.Y, SelectedTile.Y);
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
Result.Left := CurrentTile.X;
|
Result.Left := CurrentTile.X;
|
||||||
Result.Top := CurrentTile.Y;
|
Result.Top := CurrentTile.Y;
|
||||||
Result.Right := CurrentTile.X + 1;
|
Result.Right := CurrentTile.X;
|
||||||
Result.Bottom := CurrentTile.Y + 1;
|
Result.Bottom := CurrentTile.Y;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
Loading…
Reference in New Issue