Changeset 211 for trunk


Ignore:
Timestamp:
May 23, 2018, 8:53:58 PM (7 years ago)
Author:
chronos
Message:
  • Modified: Each client form is redrawn by itself, not by Core.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormClient.lfm

    r206 r211  
    77  ClientHeight = 621
    88  ClientWidth = 775
    9   DesignTimePPI = 120
     9  DesignTimePPI = 144
    1010  OnClose = FormClose
    1111  OnCreate = FormCreate
     
    1717  object StatusBar1: TStatusBar
    1818    Left = 0
    19     Height = 28
    20     Top = 593
     19    Height = 30
     20    Top = 591
    2121    Width = 775
    2222    Panels = <   
     
    3434  object ToolBar1: TToolBar
    3535    Left = 0
    36     Height = 593
     36    Height = 591
    3737    Top = 0
    3838    Width = 32
     
    7575  object PaintBox1: TPaintBox
    7676    Left = 32
    77     Height = 593
     77    Height = 591
    7878    Top = 0
    7979    Width = 743
  • trunk/Forms/UFormClient.pas

    r207 r211  
    7979    procedure SetClient(AValue: TClient);
    8080    procedure DoClientChange(Sender: TObject);
     81    procedure DoGameEnd(Sender: TObject);
    8182    procedure DoTurnStart(Sender: TObject);
    8283    procedure DoMove(CellFrom, CellTo: TCell; var CountOnce,
     
    231232    FClient.OnTurnStart := DoTurnStart;
    232233    FClient.OnDestroy := DoClientDestroy;
     234    FClient.OnGameEnd := DoGameEnd;
    233235    FClient.View.DestRect := TRect.CreateBounds(TPoint.Create(0, 0), TPoint.Create(PaintBox1.Width, PaintBox1.Height));
    234236  end;
     
    237239
    238240procedure TFormClient.DoClientChange(Sender: TObject);
     241begin
     242  Redraw;
     243end;
     244
     245procedure TFormClient.DoGameEnd(Sender: TObject);
    239246begin
    240247  Redraw;
     
    245252  TurnActive := True;
    246253  Synchronize(UpdateInterface);
     254  Synchronize(Redraw);
    247255end;
    248256
  • trunk/UCore.lfm

    r207 r211  
    33  OnDestroy = DataModuleDestroy
    44  OldCreateOrder = False
    5   Height = 676
    6   HorizontalOffset = 262
    7   VerticalOffset = 203
    8   Width = 1048
    9   PPI = 120
     5  Height = 811
     6  HorizontalOffset = 314
     7  VerticalOffset = 244
     8  Width = 1258
     9  PPI = 144
    1010  object ActionListMain: TActionList
    1111    Images = ImageListSmall
    12     left = 114
    13     top = 50
     12    left = 137
     13    top = 60
    1414    object AExit: TAction
    1515      Caption = 'Exit'
     
    101101  end
    102102  object ImageListSmall: TImageList
    103     left = 655
    104     top = 350
     103    left = 786
     104    top = 420
    105105    Bitmap = {
    106106      4C690C00000010000000100000000000000000000000E3AA4BD6E5B35EFFE3B1
     
    494494    POFilesFolder = 'Languages'
    495495    OnTranslate = CoolTranslator1Translate
    496     left = 114
    497     top = 363
     496    left = 137
     497    top = 436
    498498  end
    499499  object ImageListLarge: TImageList
    500500    Height = 32
    501501    Width = 32
    502     left = 655
    503     top = 238
     502    left = 786
     503    top = 286
    504504    Bitmap = {
    505505      4C690C0000002000000020000000000000000000000000000000E2AA4B36E2A9
     
    20462046    RootName = 'CONFIG'
    20472047    ReadOnly = False
    2048     left = 114
    2049     top = 463
     2048    left = 137
     2049    top = 556
    20502050  end
    20512051  object OpenDialog1: TOpenDialog
    20522052    DefaultExt = '.xtmap'
    2053     left = 938
    2054     top = 243
     2053    left = 1126
     2054    top = 292
    20552055  end
    20562056  object SaveDialog1: TSaveDialog
    20572057    DefaultExt = '.xtmap'
    2058     left = 938
    2059     top = 138
     2058    left = 1126
     2059    top = 166
    20602060  end
    20612061  object ApplicationInfo: TApplicationInfo
     
    20742074    RegistryRoot = rrKeyCurrentUser
    20752075    License = 'CC0'
    2076     left = 114
    2077     top = 150
     2076    left = 137
     2077    top = 180
    20782078  end
    20792079  object PersistentForm: TPersistentForm
    20802080    MinVisiblePart = 50
    20812081    EntireVisible = False
    2082     left = 650
    2083     top = 500
     2082    left = 780
     2083    top = 600
    20842084  end
    20852085  object ScaleDPI1: TScaleDPI
    20862086    AutoDetect = False
    2087     left = 113
    2088     top = 563
     2087    left = 136
     2088    top = 676
    20892089  end
    20902090  object LastOpenedList1: TLastOpenedList
    20912091    MaxCount = 10
    20922092    OnChange = LastOpenedList1Change
    2093     left = 114
    2094     top = 250
     2093    left = 137
     2094    top = 300
    20952095  end
    20962096end
  • trunk/UCore.pas

    r207 r211  
    7070    procedure LoadRecentExecute(Sender: TObject);
    7171    procedure StartNewGame;
     72    procedure LoadGame(FileName: string);
    7273    procedure DoPlayerChange(Sender: TObject);
    7374    procedure DoMoveUpdated(UnitMove: TUnitMove);
     
    7879    procedure CommandLineParams;
    7980    procedure SelectClient;
    80     procedure LoadGame(FileName: string);
    81     procedure RedrawClients;
    8281    procedure UpdateOtherForms;
    8382    procedure FormClientActions;
     
    139138  I: Integer;
    140139begin
    141   RedrawClients;
     140  Server.GameEnd;
    142141  if Assigned(Player) then
    143142    ShowMessage(Format(SPlayerWins, [Player.Name]))
     
    276275  if MessageDlg(SEndGame, SEndGameQuestion, mtConfirmation, mbYesNo, 0) = mrYes then begin
    277276    Game.Running := False;
    278     RedrawClients;
     277    Server.GameEnd;
    279278    UpdateActions;
    280279  end;
     
    489488      TPoint.Create(FormClient.PaintBox1.Width, FormClient.PaintBox1.Height));
    490489  FormClient.AZoomAll.Execute;
    491   RedrawClients;
    492490  UpdateOtherForms;
    493491  UpdateActions;
     
    495493  if Assigned(ServerClient) then ServerClient.TurnStart
    496494    else raise Exception.Create(SMissingServerClientForPlayer);
    497 end;
    498 
    499 procedure TCore.RedrawClients;
    500 var
    501   Form: TFormClient;
    502 begin
    503   for Form in FormClients do
    504     Form.Redraw;
    505   FormClient.Redraw;
    506495end;
    507496
     
    579568  if Game.Players.GetAliveCount = Game.Players.Count then Game.Running := True
    580569    else ShowMessage(Format(SPlayersNotInitialized, [Game.Players.Count, Game.Players.GetAliveCount]));
    581   FormClient.AZoomAll.Execute;
    582   RedrawClients;
    583570  UpdateOtherForms;
    584571  UpdateActions;
     
    594581begin
    595582  if Assigned(Game.CurrentPlayer) then begin
    596     PlayerClient := LocalClients.SearchPlayer(Game.CurrentPlayer);
    597     if Assigned(PlayerClient) then FormClient.Client := PlayerClient;
     583    if Game.CurrentPlayer.Mode = pmHuman then begin
     584      PlayerClient := LocalClients.SearchPlayer(Game.CurrentPlayer);
     585      if Assigned(PlayerClient) then FormClient.Client := PlayerClient;
     586    end;
    598587
    599588    ServerClient := Server.Clients.SearchByPlayer(Game.CurrentPlayer);
  • trunk/UGame.pas

    r210 r211  
    31763176  // Select new player from alive players
    31773177  AlivePlayers := TPlayers.Create(False);
    3178   Players.GetAlivePlayers(AlivePlayers);
    3179   NewPlayerIndex := AlivePlayers.IndexOf(CurrentPlayer) + 1;
    3180   if NewPlayerIndex >= AlivePlayers.Count then begin
    3181     // Start of turn
    3182     Inc(TurnCounter);
    3183     RecordTurnStats;
    3184     if Assigned(FOnNewTurn) then
    3185       FOnNewTurn(Self);
    3186     NewPlayerIndex := NewPlayerIndex mod AlivePlayers.Count;
    3187   end;
    3188   CurrentPlayer := AlivePlayers[NewPlayerIndex];
     3178  try
     3179    Players.GetAlivePlayers(AlivePlayers);
     3180    NewPlayerIndex := AlivePlayers.IndexOf(CurrentPlayer) + 1;
     3181    if NewPlayerIndex >= AlivePlayers.Count then begin
     3182      // Start of turn
     3183      Inc(TurnCounter);
     3184      RecordTurnStats;
     3185      if Assigned(FOnNewTurn) then
     3186        FOnNewTurn(Self);
     3187      NewPlayerIndex := NewPlayerIndex mod AlivePlayers.Count;
     3188    end;
     3189    CurrentPlayer := AlivePlayers[NewPlayerIndex];
     3190  finally
     3191    AlivePlayers.Free;
     3192  end;
    31893193
    31903194  if Assigned(FOnPlayerChange) then
  • trunk/UGameClient.pas

    r205 r211  
    2121    FOnChange: TNotifyEvent;
    2222    FOnDestroy: TNotifyEvent;
     23    FOnGameEnd: TNotifyEvent;
    2324    FOnReceive: TCommandEvent;
    2425    FOnMove: TMoveEvent;
     
    3536    procedure ReceiveCmd(Command: TCommand; DataOut, DataIn: TStream); virtual;
    3637    procedure DoTurnStart(Sender: TObject); virtual;
     38    procedure DoGameEnd(Sender: TObject);
    3739  public
    3840    Name: string;
     
    5456    property OnChange: TNotifyEvent read FOnChange write FOnChange;
    5557    property OnTurnStart: TNotifyEvent read FOnTurnStart write FOnTurnStart;
     58    property OnGameEnd: TNotifyEvent read FOnGameEnd write FOnGameEnd;
    5659    property Active: Boolean read FActive write SetActive;
    5760  end;
     
    134137  if Assigned(FOnTurnStart) then
    135138    FOnTurnStart(Self);
     139end;
     140
     141procedure TClient.DoGameEnd(Sender: TObject);
     142begin
     143  if Assigned(FOnGameEnd) then
     144    FOnGameEnd(Self);
    136145end;
    137146
     
    191200  Protocol := TGameProtocolClient.Create;
    192201  Protocol.OnTurnStart := DoTurnStart;
     202  Protocol.OnGameEnd := DoGameEnd;
    193203end;
    194204
  • trunk/UGameServer.pas

    r203 r211  
    2525    procedure SendCmd(Command: TCommand; DataOut, DataIn: TStream);
    2626    procedure TurnStart;
     27    procedure GameEnd;
    2728    property OnReceiveCmd: TCommandEvent read FOnReceiveCmd write
    2829      FOnReceiveCmd;
     
    6061    procedure SaveConfig(Config: TXmlConfig; Path: string);
    6162    procedure InitClients;
     63    procedure GameEnd;
    6264    procedure Clear;
    6365    constructor Create;
     
    100102begin
    101103  Protocol.TurnStart;
     104end;
     105
     106procedure TServerClient.GameEnd;
     107begin
     108  Protocol.GameEnd;
    102109end;
    103110
     
    234241end;
    235242
     243procedure TServer.GameEnd;
     244var
     245  I: Integer;
     246begin
     247  for I := 0 to Clients.Count - 1 do
     248    Clients[I].GameEnd;
     249end;
     250
    236251procedure TServer.Clear;
    237252begin
Note: See TracChangeset for help on using the changeset viewer.