Ignore:
Timestamp:
Apr 19, 2019, 11:25:56 AM (6 years ago)
Author:
chronos
Message:
  • Fixed: Configurable player tank colors in New game dialog.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UNewGameForm.pas

    r41 r43  
    1717    ButtonCancel: TButton;
    1818    ColorButton1: TColorButton;
     19    ColorButton2: TColorButton;
    1920    EditUp: TEdit;
    2021    EditDown: TEdit;
     
    3233    Label7: TLabel;
    3334    Label8: TLabel;
     35    Label9: TLabel;
    3436    ListView1: TListView;
    3537    procedure ColorButton1ColorChanged(Sender: TObject);
     38    procedure ColorButton2ColorChanged(Sender: TObject);
    3639    procedure EditDownChange(Sender: TObject);
    3740    procedure EditDownKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState
     
    5457    procedure ListView1Change(Sender: TObject; Item: TListItem;
    5558      Change: TItemChange);
     59    procedure ListView1CustomDrawSubItem(Sender: TCustomListView;
     60      Item: TListItem; SubItem: Integer; State: TCustomDrawState;
     61      var DefaultDraw: Boolean);
    5662    procedure ListView1Data(Sender: TObject; Item: TListItem);
    5763    procedure ListView1SelectItem(Sender: TObject; Item: TListItem;
     
    6167    procedure ReloadList;
    6268  public
     69    procedure UpdateInterface;
    6370    procedure LoadData(Engine: TEngine);
    6471    procedure SaveData(Engine: TEngine);
     
    7380{$R *.lfm}
    7481
     82uses
     83  UMainForm;
     84
    7585{ TNewGameForm }
    7686
     
    8090  if Change = ctState then
    8191    TPlayer(Item.Data).Enabled := Item.Checked;
     92end;
     93
     94procedure TNewGameForm.ListView1CustomDrawSubItem(Sender: TCustomListView;
     95  Item: TListItem; SubItem: Integer; State: TCustomDrawState;
     96  var DefaultDraw: Boolean);
     97begin
     98  if SubItem = 1 then
     99  with ListView1.Canvas do begin
     100    Brush.Color := TPlayer(Item.Data).Color1;
     101    Brush.Style := bsSolid;
     102    FillRect(Item.DisplayRectSubItem(1, drBounds));
     103  end;
    82104end;
    83105
     
    87109  with TPlayer(Players[Item.Index]) do begin
    88110    Item.Caption := Name;
    89     Item.SubItems.Add(IntToHex(Color, 6));
     111    Item.SubItems.Add('');
    90112    Item.SubItems.Add('');
    91113    Item.Checked := Enabled;
     
    100122  with TPlayer(Item.Data) do begin
    101123    EditName.Text := Name;
    102     ColorButton1.ButtonColor := Color;
     124    ColorButton1.ButtonColor := Color1;
     125    ColorButton2.ButtonColor := Color2;
    103126    EditDown.Text := IntToStr(Keys.Down);
    104127    EditUp.Text := IntToStr(Keys.Up);
     
    107130    EditShoot.Text := IntToStr(Keys.Shoot);
    108131  end;
     132  UpdateInterface;
    109133end;
    110134
     
    115139end;
    116140
     141procedure TNewGameForm.UpdateInterface;
     142begin
     143  EditUp.Enabled := Assigned(ListView1.Selected);
     144  EditDown.Enabled := Assigned(ListView1.Selected);
     145  EditLeft.Enabled := Assigned(ListView1.Selected);
     146  EditRight.Enabled := Assigned(ListView1.Selected);
     147  EditShoot.Enabled := Assigned(ListView1.Selected);
     148  EditName.Enabled := Assigned(ListView1.Selected);
     149  ColorButton1.Enabled := Assigned(ListView1.Selected);
     150  ColorButton2.Enabled := Assigned(ListView1.Selected);
     151end;
     152
    117153procedure TNewGameForm.LoadData(Engine: TEngine);
    118154begin
     
    129165  if Assigned(ListView1.Selected) then
    130166  with TPlayer(ListView1.Selected.Data) do begin
    131     Color := ColorButton1.ButtonColor;
     167    Color1 := ColorButton1.ButtonColor;
     168    ReloadList;
     169  end;
     170end;
     171
     172procedure TNewGameForm.ColorButton2ColorChanged(Sender: TObject);
     173begin
     174  if Assigned(ListView1.Selected) then
     175  with TPlayer(ListView1.Selected.Data) do begin
     176    Color2 := ColorButton2.ButtonColor;
    132177    ReloadList;
    133178  end;
     
    230275procedure TNewGameForm.FormCreate(Sender: TObject);
    231276begin
    232   Players := TPlayers.Create
     277  MainForm.CoolTranslator1.TranslateComponentRecursive(Self);
     278  Players := TPlayers.Create;
    233279end;
    234280
     
    241287begin
    242288  ReloadList;
     289  UpdateInterface;
    243290end;
    244291
Note: See TracChangeset for help on using the changeset viewer.