Changeset 231 for trunk/UCore.pas


Ignore:
Timestamp:
Sep 19, 2018, 2:05:52 PM (6 years ago)
Author:
chronos
Message:
  • Modified: UGame unit was split to UPlayer, UMap and UClientGUI units to have better logical separation of game classes.
  • Modified: Drawing methods moved from TMap and TPlayerMap to TClientGUI. Generic TClient class and TComputer classes don't need have any drawing support.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r227 r231  
    88  Classes, SysUtils, XMLConf, FileUtil, ActnList, Controls, Dialogs, Forms,
    99  UGame, UApplicationInfo, UPersistentForm, UScaleDPI, UCoolTranslator,
    10   URegistry, ULastOpenedList, Registry, Menus, UFormClient,
     10  URegistry, ULastOpenedList, Registry, Menus, UFormClient, UPlayer,
    1111  UGameServer, UGameClient, fgl, UServerList;
    1212
     
    115115uses
    116116  UFormMain, UFormNew, UFormSettings, UFormAbout, UClientAI, UFormKeyShortcuts,
    117   UFormHelp, UFormCharts, UFormUnitMoves, UFormPlayersStats;
     117  UFormHelp, UFormCharts, UFormUnitMoves, UFormPlayersStats, UClientGUI;
    118118
    119119const
     
    248248begin
    249249  FirstHuman := Game.Players.GetFirstHuman;
    250   if Assigned(FirstHuman) then FormClient.Client := LocalClients.SearchPlayer(FirstHuman)
    251     else FormClient.Client := TClient(LocalClients.First);
     250  if Assigned(FirstHuman) then FormClient.Client := TClientGUI(LocalClients.SearchPlayer(FirstHuman))
     251    else begin
     252      FormClient.Client := TClientGUI(LocalClients.New(SSpectator));
     253      FormClient.Client.LocalServer := Server;
     254      FormClient.Client.ConnectType := ctLocal;
     255      FormClient.Client.Active := True;
     256      FormClient.AZoomAll.Execute;
     257    end;
    252258end;
    253259
     
    469475    NewClient := LocalClients.New(Name);
    470476    NewClient.ControlPlayer := Player;
    471     NewClient.View.Clear;
    472     NewClient.View.Zoom := 1;
     477    TClientGUI(NewClient).View.Clear;
     478    TClientGUI(NewClient).View.Zoom := 1;
    473479    NewClient.LocalServer := Server;
    474480    NewClient.ConnectType := ctLocal;
    475481    NewClient.Active := True;
    476482    if Assigned(NewClient.ControlPlayer.StartCell) then
    477       NewClient.View.CenterPlayerCity(NewClient.ControlPlayer)
    478       else NewClient.View.CenterMap;
     483      TClientGUI(NewClient).View.CenterPlayerCity(NewClient.ControlPlayer)
     484      else TClientGUI(NewClient).View.CenterMap;
    479485  end else
    480486  if Mode = pmComputer then begin
    481487    NewClient := TComputer.Create;
    482     NewClient.Game := Game;
     488    NewClient.Game := TGame(Game);
    483489    NewClient.Name := Name;
    484490    LocalClients.Add(NewClient);
     
    537543begin
    538544  Form := TFormClient.Create(nil);
    539   Form.Client := LocalClients.New(SSpectator);
     545  Form.Client := TClientGUI(LocalClients.New(SSpectator));
    540546  Form.Client.LocalServer := Server;
    541547  Form.Client.ConnectType := ctLocal;
     
    566572    NewClient := LocalClients.New(Name);
    567573    NewClient.ControlPlayer := Player;
    568     NewClient.View.Clear;
    569     NewClient.View.Zoom := 1;
     574    TClientGUI(NewClient).View.Clear;
     575    TClientGUI(NewClient).View.Zoom := 1;
    570576    NewClient.LocalServer := Server;
    571577    NewClient.ConnectType := ctLocal;
    572578    NewClient.Active := True;
    573579    if Assigned(NewClient.ControlPlayer.StartCell) then
    574       NewClient.View.CenterPlayerCity(NewClient.ControlPlayer)
    575       else NewClient.View.CenterMap;
     580      TClientGUI(NewClient).View.CenterPlayerCity(NewClient.ControlPlayer)
     581      else TClientGUI(NewClient).View.CenterMap;
    576582  end else
    577583  if Mode = pmComputer then begin
    578584    NewClient := TComputer.Create;
    579     NewClient.Game := Game;
     585    NewClient.Game := TGame(Game);
    580586    NewClient.Name := Name;
    581587    LocalClients.Add(NewClient);
     
    607613    if Game.CurrentPlayer.Mode = pmHuman then begin
    608614      PlayerClient := LocalClients.SearchPlayer(Game.CurrentPlayer);
    609       if Assigned(PlayerClient) then FormClient.Client := PlayerClient;
     615      if Assigned(PlayerClient) then FormClient.Client := TClientGUI(PlayerClient);
    610616    end;
    611617
Note: See TracChangeset for help on using the changeset viewer.