Changeset 191 for trunk/UCore.pas


Ignore:
Timestamp:
May 1, 2018, 10:16:08 AM (7 years ago)
Author:
chronos
Message:
  • Fixed: Clients initialization if game is loaded from file.
  • Fixed: Removed compilation warnings.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r185 r191  
    155155procedure TCore.LoadConfig;
    156156begin
    157   RegistryContext := RegContext(HKEY_CURRENT_USER, DefaultRegKey);
     157  RegistryContext := TRegistryContext.Create(HKEY_CURRENT_USER, DefaultRegKey);
    158158  PersistentForm.RegistryContext := RegistryContext;
    159159  XMLConfig1.Filename := GetAppConfigDir(False) + 'Config.xml';
     
    415415
    416416procedure TCore.LoadGame(FileName: string);
     417var
     418  Player: TPlayer;
     419  NewClient: TClient;
    417420begin
    418421  Game.LoadFromFile(FileName);
    419   Server.InitClients;
    420   SelectClient;
    421   LastOpenedList1.AddItem(FileName);
    422   with FormClient.Client do
    423     View.DestRect := TRect.CreateBounds(TPoint.Create(0, 0),
    424       TPoint.Create(FormClient.PaintBox1.Width, FormClient.PaintBox1.Height));
    425   FormClient.AZoomAll.Execute;
    426   RedrawClients;
    427   UpdateOtherForms;
    428 end;
    429 
    430 procedure TCore.RedrawClients;
    431 var
    432   Form: TFormClient;
    433 begin
    434   for Form in FormClients do
    435     Form.Redraw;
    436   FormClient.Redraw;
    437 end;
    438 
    439 procedure TCore.UpdateOtherForms;
    440 begin
    441   if Assigned(FormCharts) and FormCharts.Visible then FormCharts.Redraw;
    442   if Assigned(FormUnitMoves) and FormUnitMoves.Visible then FormUnitMoves.ReloadList;
    443   if Assigned(FormPlayersStats) and FormPlayersStats.Visible then FormPlayersStats.ReloadList;
    444 end;
    445 
    446 procedure TCore.Spectate(Player: TPlayer);
    447 var
    448   Form: TFormClient;
    449 begin
    450   Form := TFormClient.Create(nil);
    451   Form.Client := Clients.New(SSpectator);
    452   //Form.Client.Form := Form;
    453   //Form.Client.ControlPlayer := Player;
    454   Form.AZoomAll.Execute;
    455   Form.Show;
    456   FormClients.Add(Form);
    457 end;
    458 
    459 procedure TCore.StartNewGame;
    460 var
    461   NewClient: TClient;
    462   Player: TPlayer;
    463 begin
    464   Game.New;
    465422  Server.InitClients;
    466423
     
    478435  end;
    479436
     437  SelectClient;
     438  LastOpenedList1.AddItem(FileName);
     439  with FormClient.Client do
     440    View.DestRect := TRect.CreateBounds(TPoint.Create(0, 0),
     441      TPoint.Create(FormClient.PaintBox1.Width, FormClient.PaintBox1.Height));
     442  FormClient.AZoomAll.Execute;
     443  RedrawClients;
     444  UpdateOtherForms;
     445end;
     446
     447procedure TCore.RedrawClients;
     448var
     449  Form: TFormClient;
     450begin
     451  for Form in FormClients do
     452    Form.Redraw;
     453  FormClient.Redraw;
     454end;
     455
     456procedure TCore.UpdateOtherForms;
     457begin
     458  if Assigned(FormCharts) and FormCharts.Visible then FormCharts.Redraw;
     459  if Assigned(FormUnitMoves) and FormUnitMoves.Visible then FormUnitMoves.ReloadList;
     460  if Assigned(FormPlayersStats) and FormPlayersStats.Visible then FormPlayersStats.ReloadList;
     461end;
     462
     463procedure TCore.Spectate(Player: TPlayer);
     464var
     465  Form: TFormClient;
     466begin
     467  Form := TFormClient.Create(nil);
     468  Form.Client := Clients.New(SSpectator);
     469  //Form.Client.Form := Form;
     470  //Form.Client.ControlPlayer := Player;
     471  Form.AZoomAll.Execute;
     472  Form.Show;
     473  FormClients.Add(Form);
     474end;
     475
     476procedure TCore.StartNewGame;
     477var
     478  NewClient: TClient;
     479  Player: TPlayer;
     480begin
     481  Game.New;
     482  Server.InitClients;
     483
     484  // Create local clients for human players
     485  for Player in Game.Players do
     486  with Player do
     487  if Mode = pmHuman then begin
     488    NewClient := Clients.New(Name);
     489    NewClient.ControlPlayer := Player;
     490    NewClient.View.Clear;
     491    NewClient.View.Zoom := 1;
     492    if Assigned(NewClient.ControlPlayer.StartCell) then
     493      NewClient.View.CenterPlayerCity(NewClient.ControlPlayer)
     494      else NewClient.View.CenterMap;
     495  end;
     496
    480497  Game.DevelMode := DevelMode;
    481498  SelectClient;
Note: See TracChangeset for help on using the changeset viewer.