Changeset 183 for trunk/Forms


Ignore:
Timestamp:
Feb 9, 2018, 10:33:18 AM (7 years ago)
Author:
chronos
Message:
  • Modified: Units move handling was moved from Core to FormClient as it is game client related functionality.
Location:
trunk/Forms
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormClient.pas

    r180 r183  
    7676    procedure SetClient(AValue: TClient);
    7777    procedure DoClientChange(Sender: TObject);
     78    procedure DoOnMove(CellFrom, CellTo: TCell; var CountOnce,
     79      CountRepeat: Integer; Update: Boolean; var Confirm: Boolean);
    7880  public
    7981    property Client: TClient read FClient write SetClient;
     
    9092
    9193uses
    92   UCore;
     94  UCore, UFormMove;
    9395
    9496resourcestring
     
    98100
    99101{ TFormClient }
     102
     103procedure TFormClient.DoOnMove(CellFrom, CellTo: TCell; var CountOnce,
     104  CountRepeat: Integer; Update: Boolean; var Confirm: Boolean);
     105var
     106  I: Integer;
     107  FormMove: TFormMove;
     108begin
     109  FormMove := TFormMove.Create(nil);
     110  try
     111    if Update then FormMove.SpinEditOnce.MaxValue := CellFrom.GetAvialPower + CountOnce
     112      else FormMove.SpinEditOnce.MaxValue := CellFrom.GetAvialPower;
     113    FormMove.SpinEditOnce.Value := CountOnce;
     114    FormMove.TrackBarOnce.Max := FormMove.SpinEditOnce.MaxValue;
     115    FormMove.TrackBarOnce.Position := FormMove.SpinEditOnce.Value;
     116    FormMove.SpinEditRepeat.MaxValue := Client.Game.Map.MaxPower;
     117    FormMove.SpinEditRepeat.Value := CountRepeat;
     118    FormMove.TrackBarRepeat.Max := FormMove.SpinEditRepeat.MaxValue;
     119    FormMove.TrackBarRepeat.Position := FormMove.SpinEditRepeat.Value;
     120    FormMove.DefendCount := CellTo.Power;
     121    // Attack count from other surrounding cells without current move if already exists
     122    FormMove.AttackCount := 0;
     123    for I := 0 to CellTo.MovesTo.Count - 1 do
     124    if TUnitMove(CellTo.MovesTo[I]).CellFrom <> CellFrom then
     125      FormMove.AttackCount := FormMove.AttackCount + TUnitMove(CellTo.MovesTo[I]).CountOnce;
     126    FormMove.ShowWinProbability := CellTo.Player <> CellFrom.Player;
     127
     128    if FormMove.ShowModal = mrOk then begin
     129      CountOnce := FormMove.SpinEditOnce.Value;
     130      CountRepeat := FormMove.SpinEditRepeat.Value;
     131      Confirm := True;
     132    end else Confirm := False;
     133  finally
     134    FormMove.Free;
     135  end;
     136end;
    100137
    101138procedure TFormClient.PaintBox1Paint(Sender: TObject);
     
    165202begin
    166203  if FClient = AValue then Exit;
     204  if Assigned(FClient) then FClient.Form := nil;
    167205  FClient := AValue;
    168   if Assigned(FClient) then
     206  if Assigned(FClient) then begin
     207    FClient.Form := Self;
    169208    FClient.OnChange := DoClientChange;
     209    FClient.OnMove := DoOnMove;
     210  end;
    170211  Redraw;
    171212end;
     
    298339procedure TFormClient.FormDestroy(Sender: TObject);
    299340begin
     341  Client := nil;
    300342  TempBitmap.Free;
    301343end;
  • trunk/Forms/UFormNew.pas

    r179 r183  
    319319procedure TFormNew.APlayerModifyExecute(Sender: TObject);
    320320begin
    321   if Assigned(ListViewPlayers.Selected) then begin
    322     FormPlayer.Load(TPlayer(ListViewPlayers.Selected.Data));
    323     if FormPlayer.ShowModal = mrOk then begin
    324       FormPlayer.Save(TPlayer(ListViewPlayers.Selected.Data));
    325       ReloadView;
     321  FormPlayer := TFormPlayer.Create(nil);
     322  try
     323    if Assigned(ListViewPlayers.Selected) then begin
     324      FormPlayer.Load(TPlayer(ListViewPlayers.Selected.Data));
     325       if FormPlayer.ShowModal = mrOk then begin
     326         FormPlayer.Save(TPlayer(ListViewPlayers.Selected.Data));
     327         ReloadView;
     328      end;
    326329    end;
     330  finally
     331    FormPlayer.Free;
    327332  end;
    328333end;
  • trunk/Forms/UFormPlayer.lfm

    r134 r183  
    99  Constraints.MinHeight = 344
    1010  Constraints.MinWidth = 522
     11  DesignTimePPI = 120
     12  OnClose = FormClose
    1113  OnShow = FormShow
    1214  Position = poMainFormCenter
    13   LCLVersion = '1.6.4.0'
     15  LCLVersion = '1.8.0.6'
    1416  object Label1: TLabel
    1517    Left = 24
    16     Height = 24
     18    Height = 20
    1719    Top = 27
    18     Width = 56
     20    Width = 43
    1921    Caption = 'Name:'
    2022    ParentColor = False
     
    2224  object EditName: TEdit
    2325    Left = 168
    24     Height = 34
     26    Height = 28
    2527    Top = 27
    2628    Width = 339
     
    5153  object ComboBoxMode: TComboBox
    5254    Left = 168
    53     Height = 34
     55    Height = 28
    5456    Top = 72
    5557    Width = 339
    5658    Anchors = [akTop, akLeft, akRight]
    57     ItemHeight = 0
     59    ItemHeight = 20
    5860    ItemIndex = 0
    5961    Items.Strings = (
     
    6870  object Label2: TLabel
    6971    Left = 24
    70     Height = 24
     72    Height = 20
    7173    Top = 72
    72     Width = 53
     74    Width = 42
    7375    Caption = 'Mode:'
    7476    ParentColor = False
     
    7678  object Label3: TLabel
    7779    Left = 24
    78     Height = 24
     80    Height = 20
    7981    Top = 128
    80     Width = 50
     82    Width = 39
    8183    Caption = 'Color:'
    8284    ParentColor = False
     
    8486  object ColorBox1: TColorBox
    8587    Left = 168
    86     Height = 38
     88    Height = 26
    8789    Top = 120
    8890    Width = 339
     
    9496  object Label4: TLabel
    9597    Left = 24
    96     Height = 24
     98    Height = 20
    9799    Top = 168
    98     Width = 98
     100    Width = 74
    99101    Caption = 'Agressivity:'
    100102    ParentColor = False
     
    102104  object ComboBoxAgressivity: TComboBox
    103105    Left = 168
    104     Height = 34
     106    Height = 28
    105107    Top = 168
    106108    Width = 339
    107109    Anchors = [akTop, akLeft, akRight]
    108     ItemHeight = 0
     110    ItemHeight = 20
    109111    Items.Strings = (
    110112      'Low'
     
    118120  object CheckBoxDefensive: TCheckBox
    119121    Left = 24
    120     Height = 28
     122    Height = 24
    121123    Top = 208
    122     Width = 107
     124    Width = 89
    123125    Caption = 'Defensive'
    124126    TabOrder = 6
     
    126128  object Label5: TLabel
    127129    Left = 24
    128     Height = 24
     130    Height = 20
    129131    Top = 248
    130     Width = 94
     132    Width = 69
    131133    Caption = 'Start units:'
    132134    ParentColor = False
     
    134136  object SpinEditStartUnits: TSpinEdit
    135137    Left = 224
    136     Height = 34
     138    Height = 28
    137139    Top = 240
    138140    Width = 112
  • trunk/Forms/UFormPlayer.pas

    r134 r183  
    2828    SpinEditStartUnits: TSpinEdit;
    2929    procedure ComboBoxModeChange(Sender: TObject);
     30    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    3031    procedure FormShow(Sender: TObject);
    3132  private
     
    4546{$R *.lfm}
    4647
     48uses
     49  UCore;
     50
    4751resourcestring
    4852  SHuman = 'Human';
     
    5963end;
    6064
     65procedure TFormPlayer.FormClose(Sender: TObject; var CloseAction: TCloseAction);
     66begin
     67  Core.PersistentForm.Save(Self);
     68end;
     69
    6170procedure TFormPlayer.FormShow(Sender: TObject);
    6271begin
     72  Core.PersistentForm.Load(Self);
     73  Translate;
    6374  UpdateInterface;
    6475end;
     
    6879  LastIndex: Integer;
    6980begin
     81  Core.CoolTranslator1.TranslateComponentRecursive(Self);
    7082  with ComboBoxMode do begin
    7183    LastIndex := ItemIndex;
Note: See TracChangeset for help on using the changeset viewer.