Changeset 284


Ignore:
Timestamp:
Mar 10, 2019, 6:19:51 PM (6 years ago)
Author:
chronos
Message:
  • Modified: TNation and TNations classes now uses generic TItem and TItemList classes.
  • Added: Translation files for LCL.
Location:
trunk
Files:
3 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormGameSystem.pas

    r283 r284  
    138138  FormUnitKinds.UpdateList;
    139139  FormUnitKinds.UpdateInterface;
     140  Caption := ExtractFileName(Self.GameSystem.FileName) + ' - ' + SGameSystem;
    140141end;
    141142
  • trunk/Forms/UFormNation.pas

    r283 r284  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   Spin, ColorBox, UNation;
     9  ColorBox, UNation;
    1010
    1111type
     
    3030  FormNation: TFormNation;
    3131
     32
    3233implementation
    3334
     
    4041  EditName.Text := Nation.Name;
    4142  ColorBoxColor.Selected := Nation.Color;
     43  Caption := Nation.Name + ' - ' + SNation;
    4244end;
    4345
  • trunk/Forms/UFormNations.lfm

    r283 r284  
    9595      Caption = 'Clone'
    9696      ImageIndex = 17
     97      OnExecute = ACloneExecute
    9798    end
    9899    object ASelectAll: TAction
  • trunk/Forms/UFormNations.pas

    r283 r284  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
    9   ActnList, Menus, UGameSystem, UNation;
     9  ActnList, Menus, UNation;
    1010
    1111type
     
    3333    ToolButton4: TToolButton;
    3434    procedure AAddExecute(Sender: TObject);
     35    procedure ACloneExecute(Sender: TObject);
    3536    procedure AModifyExecute(Sender: TObject);
    3637    procedure ARemoveExecute(Sender: TObject);
     
    137138end;
    138139
     140procedure TFormNations.ACloneExecute(Sender: TObject);
     141var
     142  TempEntry: TNation;
     143begin
     144  if Assigned(ListView1.Selected) then
     145  with TNation(ListView1.Selected.Data) do begin
     146    TempEntry := TNation.Create;
     147    TempEntry.Assign(TNation(ListView1.Selected.Data));
     148    FormNation := TFormNation.Create(Self);
     149    try
     150      TempEntry.Name := Nations.GetNextAvailableName(TempEntry.Name);
     151      FormNation.Load(TempEntry);
     152      if FormNation.ShowModal = mrOk then begin
     153        FormNation.Save(TempEntry);
     154        Nations.Add(TempEntry);
     155        TempEntry := nil;
     156        UpdateList;
     157        UpdateInterface;
     158      end;
     159    finally
     160      FreeAndNil(FormNation);
     161    end;
     162    TempEntry.Free;
     163  end;
     164end;
     165
    139166procedure TFormNations.ASelectAllExecute(Sender: TObject);
    140167var
  • trunk/Forms/UFormPlayers.pas

    r282 r284  
    6969
    7070uses
    71   UCore, UFormPlayer, UGame;
     71  UCore, UFormPlayer, UGame, UNation;
    7272
    7373resourcestring
     
    131131    TempEntry.Id := Players.GetNewId;
    132132    TempEntry.Name := SPlayer + ' ' + IntToStr(TempEntry.Id);
    133     TempEntry.Nation := Core.Game.GameSystem.Nations.First;
     133    TempEntry.Nation := TNation(Core.Game.GameSystem.Nations.First);
    134134    TempEntry.Color := TempEntry.Nation.Color;
    135135    TempEntry.Mode := pmComputer;
    136136    TempEntry.Agressivity := caMedium;
     137    TempEntry.Game := Players.Game;
    137138    FormPlayer.LoadData(TempEntry);
    138139    if FormPlayer.ShowModal = mrOk then begin
  • trunk/Forms/UFormUnitKinds.pas

    r277 r284  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
    9   ActnList, Menus, UGameSystem, UUnit;
     9  ActnList, Menus, UUnit;
    1010
    1111type
  • trunk/Languages/xtactics.cs.po

    r283 r284  
    227227
    228228#: tformgamesystem.caption
     229msgctxt "tformgamesystem.caption"
    229230msgid "Game system"
    230231msgstr "Herní systém"
     
    13531354msgstr "Chybný formát souboru"
    13541355
     1356#: ugamesystem.sgamesystem
     1357#, fuzzy
     1358msgctxt "ugamesystem.sgamesystem"
     1359msgid "Game system"
     1360msgstr "Herní systém"
     1361
    13551362#: ugamesystem.swrongfileformat
    13561363msgctxt "ugamesystem.swrongfileformat"
     
    13961403msgstr "Trojúhelníková"
    13971404
     1405#: unation.snation
     1406#, fuzzy
     1407#| msgid "Start units"
     1408msgctxt "unation.snation"
     1409msgid "Nation"
     1410msgstr "Počátečních jednotek"
     1411
    13981412#: uplayer.sattackerpowerpositive
    13991413msgctxt "uplayer.sattackerpowerpositive"
     
    14261440msgid "64-bit UInt read overflow."
    14271441msgstr "Přetečení při čtení 64-bit UInt"
     1442
  • trunk/Languages/xtactics.po

    r283 r284  
    217217
    218218#: tformgamesystem.caption
     219msgctxt "tformgamesystem.caption"
    219220msgid "Game system"
    220221msgstr ""
     
    13131314msgstr ""
    13141315
     1316#: ugamesystem.sgamesystem
     1317msgctxt "ugamesystem.sgamesystem"
     1318msgid "Game system"
     1319msgstr ""
     1320
    13151321#: ugamesystem.swrongfileformat
    13161322msgctxt "ugamesystem.swrongfileformat"
     
    13501356msgstr ""
    13511357
     1358#: unation.snation
     1359msgctxt "unation.snation"
     1360msgid "Nation"
     1361msgstr ""
     1362
    13521363#: uplayer.sattackerpowerpositive
    13531364msgid "Attacker power have to be higher then 0."
  • trunk/UCore.pas

    r282 r284  
    129129uses
    130130  UFormMain, UFormNew, UFormSettings, UFormAbout, UClientAI, UFormKeyShortcuts,
    131   UFormHelp, UFormCharts, UFormUnitMoves, UFormPlayersStats, UClientGUI, UMapType;
     131  UFormHelp, UFormCharts, UFormUnitMoves, UFormPlayersStats, UClientGUI, UMapType,
     132  UNation;
    132133
    133134const
     
    521522    PreferedMapType := mtNone;
    522523    MaxPlayerCount := 3;
    523     with Nations.AddNew('Nation 1') do begin
     524    with TNation(Nations.AddItem('Nation 1')) do begin
    524525      Color := clBlue;
    525526    end;
    526     with Nations.AddNew('Nation 2') do begin
     527    with TNation(Nations.AddItem('Nation 2')) do begin
    527528      Color := clRed;
    528529    end;
    529     with Nations.AddNew('Nation 3') do begin
     530    with TNation(Nations.AddItem('Nation 3')) do begin
    530531      Color := clGreen;
    531532    end;
    532     with Nations.AddNew('Nation 4') do begin
     533    with TNation(Nations.AddItem('Nation 4')) do begin
    533534      Color := clOrange;
    534535    end;
    535     with Nations.AddNew('Nation 5') do begin
     536    with TNation(Nations.AddItem('Nation 5')) do begin
    536537      Color := clPurple;
    537538    end;
    538     with Nations.AddNew('Nation 6') do begin
     539    with TNation(Nations.AddItem('Nation 6')) do begin
    539540      Color := clMaroon;
    540541    end;
    541     with Nations.AddNew('Nation 7') do begin
     542    with TNation(Nations.AddItem('Nation 7')) do begin
    542543      Color := clAqua;
    543544    end;
    544     with Nations.AddNew('Nation 8') do begin
     545    with TNation(Nations.AddItem('Nation 8')) do begin
    545546      Color := clFuchsia;
    546547    end;
     
    555556    UnitsMoveImmediately := False;
    556557    MaxPlayerCount := 8;
    557     with Nations.AddNew('Nation 1') do begin
     558    with TNation(Nations.AddItem('Nation 1')) do begin
    558559      Color := clBlue;
    559560    end;
    560     with Nations.AddNew('Nation 2') do begin
     561    with TNation(Nations.AddItem('Nation 2')) do begin
    561562      Color := clRed;
    562563    end;
    563     with Nations.AddNew('Nation 3') do begin
     564    with TNation(Nations.AddItem('Nation 3')) do begin
    564565      Color := clGreen;
    565566    end;
    566     with Nations.AddNew('Nation 4') do begin
     567    with TNation(Nations.AddItem('Nation 4')) do begin
    567568      Color := clOrange;
    568569    end;
    569     with Nations.AddNew('Nation 5') do begin
     570    with TNation(Nations.AddItem('Nation 5')) do begin
    570571      Color := clPurple;
    571572    end;
    572     with Nations.AddNew('Nation 6') do begin
     573    with TNation(Nations.AddItem('Nation 6')) do begin
    573574      Color := clMaroon;
    574575    end;
    575     with Nations.AddNew('Nation 7') do begin
     576    with TNation(Nations.AddItem('Nation 7')) do begin
    576577      Color := clAqua;
    577578    end;
    578     with Nations.AddNew('Nation 8') do begin
     579    with TNation(Nations.AddItem('Nation 8')) do begin
    579580      Color := clFuchsia;
    580581    end;
     
    589590    UnitsMoveImmediately := True;
    590591    MaxPlayerCount := 3;
    591     with Nations.AddNew('Americans') do begin
     592    with TNation(Nations.AddItem('Americans')) do begin
    592593      Color := clFuchsia;
    593594    end;
     
    676677    UnitsMoveImmediately := True;
    677678    MaxPlayerCount := 3;
    678     with Nations.AddNew('Attreides') do begin
     679    with TNation(Nations.AddItem('Attreides')) do begin
    679680      Color := clBlue;
    680681    end;
    681     with Nations.AddNew('Harkonen') do begin
     682    with TNation(Nations.AddItem('Harkonen')) do begin
    682683      Color := clRed;
    683684    end;
    684     with Nations.AddNew('Ordos') do begin
     685    with TNation(Nations.AddItem('Ordos')) do begin
    685686      Color := clGreen;
    686687    end;
    687     with Nations.AddNew('Fremens') do begin
     688    with TNation(Nations.AddItem('Fremens')) do begin
    688689      Color := clBrown;
    689690    end;
    690     with Nations.AddNew('Sardaukers') do begin
     691    with TNation(Nations.AddItem('Sardaukers')) do begin
    691692      Color := clPurple;
    692693    end;
    693     with Nations.AddNew('Merceneries') do begin
     694    with TNation(Nations.AddItem('Merceneries')) do begin
    694695      Color := clOrange;
    695696    end;
     
    734735    UnitsMoveImmediately := True;
    735736    MaxPlayerCount := 2;
    736     with Nations.AddNew('Germany') do begin
     737    with TNation(Nations.AddItem('Germany')) do begin
    737738      Color := clBlue;
    738739    end;
    739     with Nations.AddNew('Russia') do begin
     740    with TNation(Nations.AddItem('Russia')) do begin
    740741      Color := clRed;
    741742    end;
    742     with Nations.AddNew('Alliance') do begin
     743    with TNation(Nations.AddItem('Alliance')) do begin
    743744      Color := clGreen;
    744745    end;
  • trunk/UGameSystem.pas

    r282 r284  
    4646  GameSystemExt = '.xts';
    4747
     48resourcestring
     49  SGameSystem = 'Game system';
     50
    4851
    4952implementation
  • trunk/UNation.pas

    r283 r284  
    66
    77uses
    8   Classes, SysUtils, fgl, DOM, UXMLUtils, Graphics;
     8  Classes, SysUtils, fgl, DOM, UXMLUtils, Graphics, UItemList;
    99
    1010type
     
    1212  { TNation }
    1313
    14   TNation = class
    15     Id: Integer;
    16     Name: string;
     14  TNation = class(TItem)
    1715    Color: TColor;
    18     procedure Assign(Source: TNation);
    19     procedure LoadFromNode(Node: TDOMNode);
    20     procedure SaveToNode(Node: TDOMNode);
     16    function GetFields: TItemFields; override;
     17    procedure GetValue(Index: Integer; out Value); override;
     18    procedure SetValue(Index: Integer; var Value); override;
     19    procedure Assign(Source: TItem); override;
     20    procedure LoadFromNode(Node: TDOMNode); override;
     21    procedure SaveToNode(Node: TDOMNode); override;
    2122  end;
    2223
    2324  { TNations }
    2425
    25   TNations = class(TFPGObjectList<TNation>)
    26     NewId: Integer;
    27     function FindById(Id: Integer): TNation;
    28     function GetNewId: Integer;
    29     function AddNew(Name: string): TNation;
     26  TNations = class(TItemList)
     27    function GetItemClass: TItemClass; override;
    3028    procedure LoadFromNode(Node: TDOMNode);
    3129    procedure SaveToNode(Node: TDOMNode);
    3230    constructor Create(FreeObjects: Boolean = True);
    33     procedure Assign(Source: TNations);
    3431  end;
     32
     33resourcestring
     34  SNation = 'Nation';
     35
    3536
    3637implementation
    3738
     39uses
     40  UCommon;
     41
    3842{ TNation }
    3943
    40 procedure TNation.Assign(Source: TNation);
     44function TNation.GetFields: TItemFields;
    4145begin
    42   Id := Source.Id;
    43   Name := Source.Name;
    44   Color := Source.Color;
     46  inherited;
     47  Result.AddField('Name');
     48  Result.AddField('Color');
     49end;
     50
     51procedure TNation.GetValue(Index: Integer; out Value);
     52begin
     53  if Index = 0 then string(Value) := Name
     54  else if Index = 1 then TColor(Value) := Color
     55  else raise Exception.Create('Unsupported value index ' + IntToStr(Index));
     56end;
     57
     58procedure TNation.SetValue(Index: Integer; var Value);
     59begin
     60  if Index = 0 then Name := string(Value)
     61  else if Index = 1 then Color := TColor(Value)
     62  else raise Exception.Create('Unsupported value index ' + IntToStr(Index));
     63end;
     64
     65procedure TNation.Assign(Source: TItem);
     66begin
     67  inherited;
     68  Color := TNation(Source).Color;
    4569end;
    4670
    4771procedure TNation.LoadFromNode(Node: TDOMNode);
    4872begin
    49   Id := ReadInteger(Node, 'Id', 0);
    50   Name := ReadString(Node, 'Name', '');
     73  inherited;
    5174  Color := ReadInteger(Node, 'Color', 0);
    5275end;
     
    5477procedure TNation.SaveToNode(Node: TDOMNode);
    5578begin
    56   WriteInteger(Node, 'Id', Id);
    57   WriteString(Node, 'Name', Name);
     79  inherited;
    5880  WriteInteger(Node, 'Color', Color);
    5981end;
     
    6183{ TNations }
    6284
    63 function TNations.FindById(Id: Integer): TNation;
    64 var
    65   I: Integer;
     85function TNations.GetItemClass: TItemClass;
    6686begin
    67   I := 0;
    68   while (I < Count) and (Items[I].Id <> Id) do Inc(I);
    69   if I < Count then Result := Items[I]
    70     else Result := nil;
    71 end;
    72 
    73 function TNations.GetNewId: Integer;
    74 begin
    75   Result := NewId;
    76   Inc(NewId);
    77 end;
    78 
    79 function TNations.AddNew(Name: string): TNation;
    80 begin
    81   Result := TNation.Create;
    82   Result.Name := Name;
    83   Result.Id := GetNewId;
    84   Add(Result);
     87  Result := TNation;
    8588end;
    8689
     
    116119begin
    117120  inherited;
    118   NewId := 1;
    119 end;
    120 
    121 procedure TNations.Assign(Source: TNations);
    122 var
    123   I: Integer;
    124 begin
    125   while Count > Source.Count do Delete(Count - 1);
    126   while Count < Source.Count do AddNew('');
    127   for I := 0 to Count - 1 do
    128     Items[I].Assign(Source.Items[I]);
    129121end;
    130122
  • trunk/UPlayer.pas

    r282 r284  
    908908    Defensive := GetValue(DOMString(Path + '/Defensive'), False);
    909909    Agressivity := TComputerAgressivity(GetValue(DOMString(Path + '/Agressivity'), 0));
    910     Nation := TGame(Game).GameSystem.Nations.FindById(GetValue(DOMString(Path + '/Nation'), 0));
     910    Nation := TNation(TGame(Game).GameSystem.Nations.FindById(GetValue(DOMString(Path + '/Nation'), 0)));
    911911  end;
    912912end;
  • trunk/xtactics.lpi

    r283 r284  
    109109      </Item7>
    110110    </RequiredPackages>
    111     <Units Count="45">
     111    <Units Count="46">
    112112      <Unit0>
    113113        <Filename Value="xtactics.lpr"/>
     
    339339      </Unit41>
    340340      <Unit42>
    341         <Filename Value="Forms/UFormAbout.lfm"/>
     341        <Filename Value="UItemList.pas"/>
    342342        <IsPartOfProject Value="True"/>
    343343      </Unit42>
    344344      <Unit43>
    345         <Filename Value="Forms/UFormNation.pas"/>
    346         <IsPartOfProject Value="True"/>
    347         <ComponentName Value="FormNation"/>
    348         <HasResources Value="True"/>
    349         <ResourceBaseClass Value="Form"/>
     345        <Filename Value="Forms/UFormAbout.lfm"/>
     346        <IsPartOfProject Value="True"/>
    350347      </Unit43>
    351348      <Unit44>
     349        <Filename Value="Forms/UFormNation.pas"/>
     350        <IsPartOfProject Value="True"/>
     351        <ComponentName Value="FormNation"/>
     352        <HasResources Value="True"/>
     353        <ResourceBaseClass Value="Form"/>
     354      </Unit44>
     355      <Unit45>
    352356        <Filename Value="Forms/UFormNations.pas"/>
    353357        <IsPartOfProject Value="True"/>
     
    355359        <HasResources Value="True"/>
    356360        <ResourceBaseClass Value="Form"/>
    357       </Unit44>
     361      </Unit45>
    358362    </Units>
    359363  </ProjectOptions>
Note: See TracChangeset for help on using the changeset viewer.