Changeset 213 for trunk/Forms


Ignore:
Timestamp:
May 24, 2018, 9:25:17 PM (7 years ago)
Author:
chronos
Message:
  • Added: Button with action to surrender the game.
  • Fixed: Added framing comm component for correct separation of network messages.
  • Added: New game protocol command NextPlayer. GUI client will redraw map on this event to see how other players/AI fight each other.
Location:
trunk/Forms
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormClient.lfm

    r211 r213  
    5252    object ToolButton6: TToolButton
    5353      Left = 1
    54       Top = 39
     54      Top = 71
    5555      Action = AZoomIn
    5656    end
    5757    object ToolButton7: TToolButton
    5858      Left = 1
    59       Top = 71
     59      Top = 103
    6060      Action = AZoomOut
    6161    end
    6262    object ToolButton8: TToolButton
    6363      Left = 1
    64       Top = 103
     64      Top = 135
    6565      Action = AZoomAll
    6666    end
    6767    object ToolButton9: TToolButton
    6868      Left = 1
    69       Top = 34
     69      Top = 66
    7070      Width = 32
    7171      AutoSize = True
    7272      Style = tbsDivider
     73    end
     74    object ToolButton1: TToolButton
     75      Left = 1
     76      Top = 34
     77      Action = ASurrender
    7378    end
    7479  end
     
    134139      ShortCut = 16468
    135140    end
     141    object ASurrender: TAction
     142      Caption = 'Surrender'
     143      ImageIndex = 4
     144      OnExecute = ASurrenderExecute
     145    end
    136146  end
    137147  object PopupMenuToolbar: TPopupMenu
  • trunk/Forms/UFormClient.pas

    r211 r213  
    1919
    2020  TFormClient = class(TForm)
     21    ASurrender: TAction;
    2122    AGameEndTurn: TAction;
    2223    AStatusBarVisible: TAction;
     
    3334    Timer1: TTimer;
    3435    ToolBar1: TToolBar;
     36    ToolButton1: TToolButton;
    3537    ToolButton2: TToolButton;
    3638    ToolButton6: TToolButton;
     
    4042    procedure AGameEndTurnExecute(Sender: TObject);
    4143    procedure AStatusBarVisibleExecute(Sender: TObject);
     44    procedure ASurrenderExecute(Sender: TObject);
    4245    procedure AToolBarBigIconsExecute(Sender: TObject);
    4346    procedure AToolBarVisibleExecute(Sender: TObject);
     
    8083    procedure DoClientChange(Sender: TObject);
    8184    procedure DoGameEnd(Sender: TObject);
     85    procedure DoNextPlayer(Sender: TObject);
    8286    procedure DoTurnStart(Sender: TObject);
    8387    procedure DoMove(CellFrom, CellTo: TCell; var CountOnce,
     
    103107resourcestring
    104108  STurn = 'turn';
     109  SSurrender = 'Surrender';
     110  SSurrenderQuestion = 'Do you want to surrender current game?';
    105111
    106112{$R *.lfm}
     
    233239    FClient.OnDestroy := DoClientDestroy;
    234240    FClient.OnGameEnd := DoGameEnd;
     241    FClient.OnNextPlayer := DoNextPlayer;
    235242    FClient.View.DestRect := TRect.CreateBounds(TPoint.Create(0, 0), TPoint.Create(PaintBox1.Width, PaintBox1.Height));
    236243  end;
     
    248255end;
    249256
     257procedure TFormClient.DoNextPlayer(Sender: TObject);
     258begin
     259  Redraw;
     260end;
     261
    250262procedure TFormClient.DoTurnStart(Sender: TObject);
    251263begin
    252264  TurnActive := True;
    253   Synchronize(UpdateInterface);
    254   Synchronize(Redraw);
     265  UpdateInterface;
     266  Redraw;
    255267end;
    256268
     
    290302  ToolBar1.Visible := AToolBarVisible.Checked;
    291303  StatusBar1.Visible := AStatusBarVisible.Checked;
    292   AGameEndTurn.Enabled := TurnActive;
     304  AGameEndTurn.Enabled := Assigned(Client.ControlPlayer) and
     305    Client.ControlPlayer.IsAlive and TurnActive;
     306  ASurrender.Enabled := Assigned(Client.ControlPlayer) and
     307    Client.ControlPlayer.IsAlive;
    293308end;
    294309
     
    339354  AStatusBarVisible.Checked := not AStatusBarVisible.Checked;
    340355  UpdateInterface;
     356end;
     357
     358procedure TFormClient.ASurrenderExecute(Sender: TObject);
     359begin
     360  if MessageDlg(SSurrender, SSurrenderQuestion, mtConfirmation, mbYesNo, 0) =
     361    mrYes then begin
     362      Client.Protocol.Surrender;
     363      UpdateInterface;
     364    end;
    341365end;
    342366
Note: See TracChangeset for help on using the changeset viewer.