Changeset 23 for trunk/Forms


Ignore:
Timestamp:
Sep 28, 2011, 8:34:06 PM (13 years ago)
Author:
george
Message:
  • Added: Introduced player pool for selection of players for new game.
  • Fixed: Deadlock on program exit during threads termination.
Location:
trunk/Forms
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UMainForm.lfm

    r21 r23  
    55  Width = 514
    66  Caption = 'Tunneler'
    7   ClientHeight = 389
     7  ClientHeight = 385
    88  ClientWidth = 514
    99  Menu = MainMenu1
     
    1818  object StatusBar1: TStatusBar
    1919    Left = 0
    20     Height = 17
    21     Top = 372
     20    Height = 21
     21    Top = 364
    2222    Width = 514
    2323    Panels = <   
     
    4747  object Image1: TImage
    4848    Left = 0
    49     Height = 372
     49    Height = 364
    5050    Top = 0
    5151    Width = 514
  • trunk/Forms/UMainForm.pas

    r22 r23  
    4343    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    4444    procedure FormCreate(Sender: TObject);
     45    procedure FormDestroy(Sender: TObject);
    4546    procedure FormDeactivate(Sender: TObject);
    46     procedure FormDestroy(Sender: TObject);
    4747    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    4848    procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
     
    6060  public
    6161    PersistentForm: TPersistentForm;
     62    Engine: TEngine;
    6263  end;
    6364
     
    8586    try
    8687      Engine.Lock.Acquire;
    87       StatusBar1.Panels[1].Text := IntToStr(TPlayer(Engine.Players[0]).Position.X) + ', ' +
    88         IntToStr(TPlayer(Engine.Players[0]).Position.Y) + ' ' +
    89         IntToStr(TPlayer(Engine.Players[0]).Direction);
     88      //StatusBar1.Panels[1].Text := IntToStr(TPlayer(Engine.Players[0]).Position.X) + ', ' +
     89      //  IntToStr(TPlayer(Engine.Players[0]).Position.Y) + ' ' +
     90      //  IntToStr(TPlayer(Engine.Players[0]).Direction);
    9091      StatusBar1.Panels[2].Text := FloatToStr(RoundTo(DrawDuration / OneMillisecond, -2));
    91       StatusBar1.Panels[3].Text := IntToStr(TPlayer(Engine.Players[0]).Bullets.Count);
     92      //StatusBar1.Panels[3].Text := IntToStr(TPlayer(Engine.Players[0]).Bullets.Count);
    9293    finally
    9394      Engine.Lock.Release;
     
    111112  Randomize;
    112113  DoubleBuffered := True;
     114  Engine := TEngine.Create;
    113115  Engine.Bitmap := Image1.Picture.Bitmap;
    114   with Engine do begin
    115     PlayerCount := 4;
    116     with TPlayer(Players[0]) do begin
    117       Name := 'Player 1';
    118       Keys.Left := 65;
    119       Keys.Down := 83;
    120       Keys.Right := 68;
    121       Keys.Up := 87;
    122       Keys.Shoot := 69;
    123     end;
    124     with TPlayer(Players[1]) do begin
    125       Name := 'Player 2';
    126       Keys.Left := 37;
    127       Keys.Down := 40;
    128       Keys.Right := 39;
    129       Keys.Up := 38;
    130       Keys.Shoot := 17;
    131     end;
    132     with TPlayer(Players[2]) do begin
    133       Name := 'Player 3';
    134       Keys.Left := 76;
    135       Keys.Down := 186;
    136       Keys.Right := 222;
    137       Keys.Up := 80;
    138       Keys.Shoot := 191;
    139     end;
    140     with TPlayer(Players[3]) do begin
    141       Name := 'Player 4';
    142       Keys.Left := 100;
    143       Keys.Down := 98;
    144       Keys.Right := 102;
    145       Keys.Up := 104;
    146       Keys.Shoot := 105;
    147     end;
    148   end;
    149116  Engine.NewGame;
    150117  Engine.Active := True;
     
    160127begin
    161128  PersistentForm.Free;
     129  Engine.Free;
    162130end;
    163131
  • trunk/Forms/UNewGameForm.lfm

    r22 r23  
    77  ClientHeight = 387
    88  ClientWidth = 560
    9   OnCreate = FormCreate
     9  OnShow = FormShow
    1010  LCLVersion = '0.9.31'
    1111  object ButtonStart: TButton
     
    3232  object Label1: TLabel
    3333    Left = 8
    34     Height = 14
     34    Height = 18
    3535    Top = 8
    36     Width = 44
     36    Width = 53
    3737    Caption = 'Players:'
    3838    ParentColor = False
  • trunk/Forms/UNewGameForm.pas

    r22 r23  
    1919    ListView1: TListView;
    2020    procedure ButtonStartClick(Sender: TObject);
    21     procedure FormCreate(Sender: TObject);
     21    procedure FormShow(Sender: TObject);
    2222    procedure ListView1Change(Sender: TObject; Item: TListItem;
    2323      Change: TItemChange);
     
    4040{ TNewGameForm }
    4141
    42 procedure TNewGameForm.FormCreate(Sender: TObject);
    43 var
    44   NewItem: TListItem;
    45   I: Integer;
    46 begin
    47   with ListView1 do try
    48     BeginUpdate;
    49     Clear;
    50     for I := 0 to Engine.Players.Count - 1 do
    51     with TPlayer(Engine.Players[I]) do begin
    52       NewItem := Items.Add;
    53       NewItem.Caption := Name;
    54       NewItem.SubItems.Add(IntToStr(Color));
    55       NewItem.SubItems.Add('');
    56       NewItem.Checked := Enabled;
    57       NewItem.Data := Pointer(Engine.Players[I]);
    58     end;
    59   finally
    60     EndUpdate;
    61   end;
    62 end;
    63 
    6442procedure TNewGameForm.ListView1Change(Sender: TObject; Item: TListItem;
    6543  Change: TItemChange);
     
    7452end;
    7553
     54procedure TNewGameForm.FormShow(Sender: TObject);
     55var
     56  NewItem: TListItem;
     57  I: Integer;
     58begin
     59  with ListView1 do try
     60    BeginUpdate;
     61    Clear;
     62    for I := 0 to Engine.PlayerPool.Count - 1 do
     63    with TPlayer(Engine.PlayerPool[I]) do begin
     64      NewItem := Items.Add;
     65      NewItem.Caption := Name;
     66      NewItem.SubItems.Add(IntToStr(Color));
     67      NewItem.SubItems.Add('');
     68      NewItem.Checked := Enabled;
     69      NewItem.Data := Pointer(Engine.PlayerPool[I]);
     70    end;
     71  finally
     72    EndUpdate;
     73  end;
     74end;
     75
    7676end.
    7777
Note: See TracChangeset for help on using the changeset viewer.