unit untTextItem;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
  FMX.Layouts, FMX.Controls.Presentation, FMX.StdCtrls, FMX.Edit, FMX.Effects, FMX.Filter.Effects,
  FMX.ListBox, FMX.Objects, untCard, untConstant;

type
  TTextItem = class(TListBoxItem)
  private
    FOptionId: Int64;
    FLbl: TText;
    function GetOptionText: string;
    procedure SetOptionText(const Value: string);
  public
    constructor Create(AOwner: TComponent); override;
    constructor Create(AOwner: TComponent; AOptionText: string); overload;
    constructor Create(AOwner: TComponent; AOptionText: string; AOptionId: Int64); overload;
    destructor Destroy; override;
  published
    property OptionText: string read GetOptionText write SetOptionText;
    property OptionId: Int64 read FOptionId write FOptionId;
  end;

  TCardPositionItem = class(TTextItem)
  public
    constructor Create(AOwner: TComponent; APosition: Integer);
  end;

  TCardOwnerPlayerItem = class(TTextItem)
  public
    constructor Create(AOwner: TComponent; APlayer: Integer);
  end;

implementation

{ TTextItem }

constructor TTextItem.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Self.Parent := TFmxObject(AOwner);
  Self.Height:= 28;
  self.Width:= 250;
  self.Text := '';
  FLbl := TText.Create(Self);
  FLbl.Parent := Self;
  FLbl.Align:= TAlignLayout.Client;
  FLbl.HitTest:= False;
  FLbl.TextSettings.Font.Family := 'Microsoft Yahei';
  FLbl.TextSettings.FontColor := TAlphaColors.White;
  FLbl.HorzTextAlign:= TTextAlign.Center;
  FLbl.VertTextAlign:= TTextAlign.Center;
end;

constructor TTextItem.Create(AOwner: TComponent; AOptionText: string);
begin
  inherited Create(AOwner);
  Self.Parent := TFmxObject(AOwner);
  Self.Height:= 28;
  self.Width:= 250;
  FLbl := TText.Create(Self);
  FLbl.Parent := Self;
  FLbl.Align:= TAlignLayout.Client;
  FLbl.HitTest:= False;
  FLbl.TextSettings.Font.Family := 'Microsoft Yahei';
  FLbl.TextSettings.FontColor := TAlphaColors.White;
  FLbl.HorzTextAlign:= TTextAlign.Center;
  FLbl.VertTextAlign:= TTextAlign.Center;
  FLbl.Text := AOptionText;
end;

constructor TTextItem.Create(AOwner: TComponent; AOptionText: string; AOptionId: Int64);
begin
   inherited Create(AOwner);
  Self.Parent := TFmxObject(AOwner);
  Self.Height:= 28;
  self.Width:= 250;
  FLbl := TText.Create(Self);
  FLbl.Parent := Self;
  FLbl.Align:= TAlignLayout.Client;
  FLbl.HitTest:= False;
  FLbl.TextSettings.Font.Family := 'Microsoft Yahei';
  FLbl.TextSettings.FontColor := TAlphaColors.White;
  FLbl.HorzTextAlign:= TTextAlign.Center;
  FLbl.VertTextAlign:= TTextAlign.Center;
  FLbl.Text := AOptionText;
  FOptionId := AOptionId;
end;

destructor TTextItem.Destroy;
begin
  FLbl.Free;
  inherited;
end;

function TTextItem.GetOptionText: string;
begin
  Exit(FLbl.Text);
end;

procedure TTextItem.SetOptionText(const Value: string);
begin
  FLbl.Text := Value;
end;

{ TCardPositionItem }

constructor TCardPositionItem.Create(AOwner: TComponent;
  APosition: Integer);
begin
  inherited Create(AOwner);
  case APosition of
  0: FLbl.Text:= '正面攻击';
  1: FLbl.Text:= '正面防御';
  2: FLbl.Text:= '反面防御';
  3: FLbl.Text:= '正面';
  4: FLbl.Text:= '反面';
  end;
end;

{ TCardOwnerPlayerItem }

constructor TCardOwnerPlayerItem.Create(AOwner: TComponent;
  APlayer: Integer);
begin
  inherited Create(AOwner);
  case APlayer of
  0:
    begin
      FLbl.Text:= '自己';
      FLbl.TextSettings.FontColor:= COLOR_SELF;
    end;
  1:
    begin
      FLbl.Text:= '对手';
      FLbl.TextSettings.FontColor:= COLOR_OPPONENT;
    end;
  end;
end;

end.
