unit UNation;

{$mode delphi}

interface

uses
  Classes, SysUtils, Graphics, UItemList;

type

  { TNation }

  TNation = class(TItem)
    Color: TColor;
    class function GetFields: TItemFields; override;
    procedure GetValue(Index: Integer; out Value); override;
    procedure SetValue(Index: Integer; var Value); override;
    class function GetClassSysName: string; override;
    class function GetClassName: string; override;
  end;

  { TNations }

  TNations = class(TItemList)
    class function GetItemClass: TItemClass; override;
  end;

resourcestring
  SNation = 'Nation';
  SColor = 'Color';


implementation

uses
  UCommon;

{ TNation }

class function TNation.GetFields: TItemFields;
begin
  Result := inherited;
  Result.AddField(2, 'Color', SColor, dtColor);
end;

procedure TNation.GetValue(Index: Integer; out Value);
begin
  if Index = 1 then string(Value) := Name
  else if Index = 2 then TColor(Value) := Color
  else inherited;
end;

procedure TNation.SetValue(Index: Integer; var Value);
begin
  if Index = 1 then Name := string(Value)
  else if Index = 2 then Color := TColor(Value)
  else inherited;
end;

class function TNation.GetClassSysName: string;
begin
  Result := 'Nation';
end;

class function TNation.GetClassName: string;
begin
  Result := SNation;
end;

{ TNations }

class function TNations.GetItemClass: TItemClass;
begin
  Result := TNation;
end;

end.

