Ignore:
Timestamp:
Jun 21, 2024, 12:44:53 PM (5 months ago)
Author:
chronos
Message:
  • Modified: Remove U prefix from unit names.
  • Modified: Use TFormEx for all forms for code simplification.
File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Forms/FormNew.pas

    r316 r317  
    1 unit UFormNew;
     1unit FormNew;
    22
    33interface
     
    55uses
    66  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    7   ComCtrls, Spin, ExtCtrls, ActnList, ExtDlgs, Menus, UGame, UGeometry, UPlayer,
    8   UGameServer, UServerList, UMap, UGameSystem, UFormList;
     7  ComCtrls, Spin, ExtCtrls, ActnList, ExtDlgs, Menus, Game, Geometry, Player,
     8  GameServer, ServerList, Map, GameSystem, FormList, FormEx, FormChat;
    99
    1010type
     
    1212  { TFormNew }
    1313
    14   TFormNew = class(TForm)
     14  TFormNew = class(TFormEx)
    1515    ActionList1: TActionList;
    1616    AServerAdd: TAction;
     
    115115    procedure ComboBoxWinObjectiveChange(Sender: TObject);
    116116    procedure EditImageFileChange(Sender: TObject);
    117     procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    118117    procedure FormCreate(Sender: TObject);
    119118    procedure FormDestroy(Sender: TObject);
     
    143142    NewRandSeed: Cardinal;
    144143    FormPlayers: TFormList;
     144    FormChat: TFormChat;
    145145    procedure LoadGame(Game: TGame);
    146146    procedure SaveGame(Game: TGame);
     
    158158  end;
    159159
    160 var
    161   FormNew: TFormNew;
    162 
    163160
    164161implementation
     
    167164
    168165uses
    169   UFormChat, UCore, UFormServer, UClientGUI, UFormClient,
    170   UFormGameSystems, UMapType;
     166  Core, FormServer, ClientGUI, FormClient, FormGameSystems, MapType;
    171167
    172168resourcestring
     
    350346  ComboBoxGameSystem.Items.BeginUpdate;
    351347  try
    352     while ComboBoxGameSystem.Items.Count > Core.GameSystems.Count do
     348    while ComboBoxGameSystem.Items.Count > Core.Core.GameSystems.Count do
    353349      ComboBoxGameSystem.Items.Delete(ComboBoxGameSystem.Items.Count - 1);
    354     while ComboBoxGameSystem.Items.Count < Core.GameSystems.Count do
     350    while ComboBoxGameSystem.Items.Count < Core.Core.GameSystems.Count do
    355351      ComboBoxGameSystem.Items.Add('');
    356     for I := 0 to Core.GameSystems.Count - 1 do begin
    357       ComboBoxGameSystem.Items[I] := Core.GameSystems[I].GetName;
    358       ComboBoxGameSystem.Items.Objects[I] := Core.GameSystems[I];
     352    for I := 0 to Core.Core.GameSystems.Count - 1 do begin
     353      ComboBoxGameSystem.Items[I] := Core.Core.GameSystems[I].GetName;
     354      ComboBoxGameSystem.Items.Objects[I] := Core.Core.GameSystems[I];
    359355    end;
    360356    if Assigned(LastSystem) then
     
    457453    ItemIndex := LastIndex;
    458454  end;
    459   Core.CoolTranslator1.TranslateComponentRecursive(Self);
     455  Core.Core.Translator1.TranslateComponentRecursive(Self);
    460456end;
    461457
     
    500496  Randomize;
    501497  NewRandSeed := RandSeed;
    502   Core.PersistentForm.Load(Self);
    503   Core.ThemeManager1.UseTheme(Self);
    504498  ReloadView;
    505499  //Height := Trunc(1.5 * Height);
     
    583577end;
    584578
    585 procedure TFormNew.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    586 begin
    587   Core.PersistentForm.Save(Self);
    588 end;
    589 
    590579procedure TFormNew.AServerAddExecute(Sender: TObject);
    591580var
    592581  NewServerInfo: TServerInfo;
     582  FormServer: TFormServer;
    593583begin
    594584  FormServer := TFormServer.Create(nil);
    595   NewServerInfo := TServerInfo.Create;
    596   FormServer.ServerInfo := NewServerInfo;
    597   if FormServer.ShowModal = mrOK then begin
    598     ServerList.Items.Add(NewServerInfo);
    599     ReloadView;
    600   end else NewServerInfo.Free;
    601   FormServer.Free;
     585  try
     586    NewServerInfo := TServerInfo.Create;
     587    FormServer.ServerInfo := NewServerInfo;
     588    if FormServer.ShowModal = mrOK then begin
     589      ServerList.Items.Add(NewServerInfo);
     590      ReloadView;
     591    end else NewServerInfo.Free;
     592  finally
     593    FormServer.Free;
     594  end;
    602595end;
    603596
     
    605598var
    606599  ServerInfo: TServerInfo;
     600  FormServer: TFormServer;
    607601begin
    608602  FormServer := TFormServer.Create(nil);
    609   ServerInfo := TServerInfo(ListViewServers.Selected.Data);
    610   FormServer.ServerInfo := ServerInfo;
    611   if FormServer.ShowModal = mrOK then begin
    612     ReloadView;
    613   end;
    614   FormServer.Free;
     603  try
     604    ServerInfo := TServerInfo(ListViewServers.Selected.Data);
     605    FormServer.ServerInfo := ServerInfo;
     606    if FormServer.ShowModal = mrOK then begin
     607      ReloadView;
     608    end;
     609  finally
     610    FormServer.Free;
     611  end;
    615612end;
    616613
     
    629626
    630627procedure TFormNew.ButtonGameSystemsClick(Sender: TObject);
     628var
     629  FormGameSystems: TFormGameSystems;
    631630begin
    632631  FormGameSystems := TFormGameSystems.Create(nil);
    633632  try
    634     FormGameSystems.GameSystems := Core.GameSystems;
     633    FormGameSystems.GameSystems := Core.Core.GameSystems;
    635634    FormGameSystems.ShowModal;
    636635    ReloadGameSystemsMenu;
     
    683682    SpinEditServerPort.Value := LocalNetworkPort;
    684683  end;
    685   ServerList.Assign(Core.ServerList);
     684  ServerList.Assign(Core.Core.ServerList);
    686685  LoadGame(Server.Game);
    687686end;
     
    703702    end;
    704703  end;
    705   Core.ServerList.Assign(ServerList);
     704  Core.Core.ServerList.Assign(ServerList);
    706705  SaveGame(Server.Game);
    707706end;
Note: See TracChangeset for help on using the changeset viewer.