Changeset 334 for trunk


Ignore:
Timestamp:
Aug 27, 2024, 4:39:09 PM (3 months ago)
Author:
chronos
Message:
  • Fixed: Recalculate list NewId if necessary.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ClientGUI.pas

    r330 r334  
    365365            end;
    366366          if Assigned(SelectedCell) and (SelectedCell = Cell) then
    367               Brush.Color := clGreen
     367            Brush.Color := clGreen
    368368            else if Assigned(SelectedCell) and ControlPlayer.IsAllowedMoveTarget(SelectedCell, Cell) then
    369369              Brush.Color := clPurple
  • trunk/ItemList.pas

    r326 r334  
    44
    55uses
    6   Classes, SysUtils, Generics.Collections, DOM, XML, Common, Graphics;
     6  Classes, SysUtils, Generics.Collections, DOM, XML, Common, Graphics, Math;
    77
    88type
     
    7777
    7878  TItemList = class(TObjectList<TItem>)
     79  private
     80    procedure RecalculateNewId(Reset: Boolean);
     81  public
    7982    NewId: Integer;
    8083    class function GetItemClass: TItemClass; virtual;
     
    144147  for I := 0 to Count - 1 do
    145148    TItem(Items[I]).Assign(Source.Items[I]);
     149  RecalculateNewId(True);
    146150end;
    147151
     
    172176    Node2 := Node2.NextSibling;
    173177  end;
     178  RecalculateNewId(True);
    174179end;
    175180
     
    191196  inherited;
    192197  NewId := 1;
     198end;
     199
     200procedure TItemList.RecalculateNewId(Reset: Boolean);
     201var
     202  I: Integer;
     203begin
     204  NewId := 1;
     205  for I := 0 to Count - 1 do
     206  with TItem(Items[I]) do begin
     207    NewId := Max(NewId, Id + 1);
     208  end;
    193209end;
    194210
Note: See TracChangeset for help on using the changeset viewer.