Changeset 289


Ignore:
Timestamp:
Mar 24, 2019, 11:15:07 PM (6 years ago)
Author:
chronos
Message:
  • Added: Allow to add building kinds to game system.
Location:
trunk
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormGameSystem.lfm

    r283 r289  
    1212  OnDestroy = FormDestroy
    1313  OnShow = FormShow
    14   LCLVersion = '1.8.4.0'
     14  LCLVersion = '2.0.0.4'
    1515  object ButtonSave: TButton
    1616    Left = 160
     
    5858    Top = 16
    5959    Width = 744
    60     ActivePage = TabSheetNations
     60    ActivePage = TabSheetBuildings
    6161    Anchors = [akTop, akLeft, akRight, akBottom]
    62     TabIndex = 2
     62    TabIndex = 3
    6363    TabOrder = 4
    6464    object TabSheetGeneral: TTabSheet
     
    9797      Caption = 'Nations'
    9898    end
     99    object TabSheetBuildings: TTabSheet
     100      Caption = 'Buildings'
     101    end
    99102  end
    100103  object OpenDialog1: TOpenDialog
  • trunk/Forms/UFormGameSystem.pas

    r284 r289  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   ComCtrls, UGameSystem, UFormUnitKinds, UFormNations;
     9  ComCtrls, UGameSystem, UFormUnitKinds, UFormNations, UFormBuildingKinds;
    1010
    1111type
     
    2424    PageControl1: TPageControl;
    2525    SaveDialog1: TSaveDialog;
     26    TabSheetBuildings: TTabSheet;
    2627    TabSheetNations: TTabSheet;
    2728    TabSheetGeneral: TTabSheet;
     
    3738    FormUnitKinds: TFormUnitKinds;
    3839    FormNations: TFormNations;
     40    FormBuildingKinds: TFormBuildingKinds;
    3941    procedure SetGameSystem(AValue: TGameSystem);
    4042  public
     
    100102  FormNations.Align := alClient;
    101103  FormNations.Visible := True;
     104  FormBuildingKinds := TFormBuildingKinds.Create(nil);
     105  FormBuildingKinds.ManualDock(TabSheetBuildings, nil, alClient);
     106  FormBuildingKinds.Align := alClient;
     107  FormBuildingKinds.Visible := True;
    102108end;
    103109
     
    107113  FreeAndNil(FormNations);
    108114  FreeAndNil(FormUnitKinds);
     115  FreeAndNil(FormBuildingKinds);
    109116end;
    110117
     
    120127    FormUnitKinds.UnitKinds := nil;
    121128    FormNations.Nations := nil;
     129    FormBuildingKinds.BuildingKinds := nil;
    122130  end;
    123131  FGameSystem := AValue;
     
    125133    FormUnitKinds.UnitKinds := GameSystem.UnitKinds;
    126134    FormNations.Nations := GameSystem.Nations;
     135    FormBuildingKinds.BuildingKinds := GameSystem.BuildingKinds;
    127136  end;
    128137end;
     
    138147  FormUnitKinds.UpdateList;
    139148  FormUnitKinds.UpdateInterface;
     149  FormBuildingKinds.UpdateList;
     150  FormBuildingKinds.UpdateInterface;
    140151  Caption := ExtractFileName(Self.GameSystem.FileName) + ' - ' + SGameSystem;
    141152end;
  • trunk/Languages/xtactics.cs.po

    r288 r289  
    113113msgstr "Přepnout Skrytou mapu"
    114114
     115#: tformbuildingkind.buttoncancel.caption
     116#, fuzzy
     117msgctxt "tformbuildingkind.buttoncancel.caption"
     118msgid "Cancel"
     119msgstr "Zrušit"
     120
     121#: tformbuildingkind.buttonok.caption
     122#, fuzzy
     123msgctxt "tformbuildingkind.buttonok.caption"
     124msgid "OK"
     125msgstr "OK"
     126
     127#: tformbuildingkind.caption
     128msgid "Building kind"
     129msgstr ""
     130
     131#: tformbuildingkind.labelname.caption
     132#, fuzzy
     133msgctxt "tformbuildingkind.labelname.caption"
     134msgid "Name:"
     135msgstr "Jméno:"
     136
     137#: tformbuildingkinds.aadd.caption
     138#, fuzzy
     139msgctxt "tformbuildingkinds.aadd.caption"
     140msgid "Add"
     141msgstr "Přidat"
     142
     143#: tformbuildingkinds.aclone.caption
     144#, fuzzy
     145msgctxt "tformbuildingkinds.aclone.caption"
     146msgid "Clone"
     147msgstr "Klonovat"
     148
     149#: tformbuildingkinds.amodify.caption
     150#, fuzzy
     151msgctxt "tformbuildingkinds.amodify.caption"
     152msgid "Modify"
     153msgstr "Upravit"
     154
     155#: tformbuildingkinds.aremove.caption
     156#, fuzzy
     157msgctxt "tformbuildingkinds.aremove.caption"
     158msgid "Remove"
     159msgstr "Odstranit"
     160
     161#: tformbuildingkinds.aselectall.caption
     162#, fuzzy
     163msgctxt "tformbuildingkinds.aselectall.caption"
     164msgid "Select all"
     165msgstr "Vybrat vše"
     166
     167#: tformbuildingkinds.caption
     168msgid "Building kinds"
     169msgstr ""
     170
     171#: tformbuildingkinds.listview1.columns[0].caption
     172#, fuzzy
     173msgctxt "tformbuildingkinds.listview1.columns[0].caption"
     174msgid "Name"
     175msgstr "Jméno"
     176
    115177#: tformcharts.caption
    116178msgctxt "tformcharts.caption"
     
    218280msgid "Units can split or merge"
    219281msgstr "Dělení nebo slučování jednotek"
     282
     283#: tformgamesystem.tabsheetbuildings.caption
     284msgid "Buildings"
     285msgstr ""
    220286
    221287#: tformgamesystem.tabsheetgeneral.caption
     
    9501016msgstr "Jméno"
    9511017
     1018#: ubuilding.sbuilding
     1019msgid "Building"
     1020msgstr ""
     1021
    9521022#: uclientgui.swrongarrowangle
    9531023msgid "Wrong arrow angle %s"
     
    10071077msgid "Version"
    10081078msgstr "Verze"
     1079
     1080#: uformbuildingkinds.snewbuildingkind
     1081msgid "New building kind"
     1082msgstr ""
     1083
     1084#: uformbuildingkinds.sremoveitems
     1085#, fuzzy
     1086msgctxt "uformbuildingkinds.sremoveitems"
     1087msgid "Remove items"
     1088msgstr "Odstranit položky"
     1089
     1090#: uformbuildingkinds.sremoveitemsquery
     1091#, fuzzy
     1092msgctxt "uformbuildingkinds.sremoveitemsquery"
     1093msgid "Do you want to remove selected items?"
     1094msgstr "Opravdu chcete odstranit vybrané položky?"
    10091095
    10101096#: uformcharts.scitiescount
     
    13241410msgid "Unfinished battle"
    13251411msgstr "Neukončená bitva"
     1412
  • trunk/Languages/xtactics.po

    r288 r289  
    103103msgstr ""
    104104
     105#: tformbuildingkind.buttoncancel.caption
     106msgctxt "tformbuildingkind.buttoncancel.caption"
     107msgid "Cancel"
     108msgstr ""
     109
     110#: tformbuildingkind.buttonok.caption
     111msgctxt "tformbuildingkind.buttonok.caption"
     112msgid "OK"
     113msgstr ""
     114
     115#: tformbuildingkind.caption
     116msgid "Building kind"
     117msgstr ""
     118
     119#: tformbuildingkind.labelname.caption
     120msgctxt "tformbuildingkind.labelname.caption"
     121msgid "Name:"
     122msgstr ""
     123
     124#: tformbuildingkinds.aadd.caption
     125msgctxt "tformbuildingkinds.aadd.caption"
     126msgid "Add"
     127msgstr ""
     128
     129#: tformbuildingkinds.aclone.caption
     130msgctxt "tformbuildingkinds.aclone.caption"
     131msgid "Clone"
     132msgstr ""
     133
     134#: tformbuildingkinds.amodify.caption
     135msgctxt "tformbuildingkinds.amodify.caption"
     136msgid "Modify"
     137msgstr ""
     138
     139#: tformbuildingkinds.aremove.caption
     140msgctxt "tformbuildingkinds.aremove.caption"
     141msgid "Remove"
     142msgstr ""
     143
     144#: tformbuildingkinds.aselectall.caption
     145msgctxt "tformbuildingkinds.aselectall.caption"
     146msgid "Select all"
     147msgstr ""
     148
     149#: tformbuildingkinds.caption
     150msgid "Building kinds"
     151msgstr ""
     152
     153#: tformbuildingkinds.listview1.columns[0].caption
     154msgctxt "tformbuildingkinds.listview1.columns[0].caption"
     155msgid "Name"
     156msgstr ""
     157
    105158#: tformcharts.caption
    106159msgctxt "tformcharts.caption"
     
    209262msgstr ""
    210263
     264#: tformgamesystem.tabsheetbuildings.caption
     265msgid "Buildings"
     266msgstr ""
     267
    211268#: tformgamesystem.tabsheetgeneral.caption
    212269msgctxt "tformgamesystem.tabsheetgeneral.caption"
     
    936993msgstr ""
    937994
     995#: ubuilding.sbuilding
     996msgid "Building"
     997msgstr ""
     998
    938999#: uclientgui.swrongarrowangle
    9391000msgid "Wrong arrow angle %s"
     
    9921053#: uformabout.sversion
    9931054msgid "Version"
     1055msgstr ""
     1056
     1057#: uformbuildingkinds.snewbuildingkind
     1058msgid "New building kind"
     1059msgstr ""
     1060
     1061#: uformbuildingkinds.sremoveitems
     1062msgctxt "uformbuildingkinds.sremoveitems"
     1063msgid "Remove items"
     1064msgstr ""
     1065
     1066#: uformbuildingkinds.sremoveitemsquery
     1067msgctxt "uformbuildingkinds.sremoveitemsquery"
     1068msgid "Do you want to remove selected items?"
    9941069msgstr ""
    9951070
  • trunk/UBuilding.pas

    r265 r289  
    99
    1010type
     11
     12  { TBuildingKind }
     13
    1114  TBuildingKind = class
    1215    Id: Integer;
    1316    Name: string;
    1417    Cost: Integer;
     18    procedure Assign(Source: TBuildingKind);
     19    procedure LoadFromNode(Node: TDOMNode);
     20    procedure SaveToNode(Node: TDOMNode);
    1521  end;
    1622
     
    1925  TBuildingKinds = class(TFPGObjectList<TBuildingKind>)
    2026    function AddNew(Name: string): TBuildingKind;
     27    procedure LoadFromNode(Node: TDOMNode);
     28    procedure SaveToNode(Node: TDOMNode);
     29    procedure Assign(Source: TBuildingKinds);
    2130  end;
    2231
     
    2534  end;
    2635
     36resourcestring
     37  SBuilding = 'Building';
     38
    2739
    2840implementation
     41
     42{ TBuildingKind }
     43
     44procedure TBuildingKind.Assign(Source: TBuildingKind);
     45begin
     46  Name := Source.Name;
     47  Cost := Source.Cost;
     48end;
     49
     50procedure TBuildingKind.LoadFromNode(Node: TDOMNode);
     51begin
     52  Id := ReadInteger(Node, 'Id', 0);
     53  Name := ReadString(Node, 'Name', '');
     54  Cost := ReadInteger(Node, 'Cost', 0);
     55end;
     56
     57procedure TBuildingKind.SaveToNode(Node: TDOMNode);
     58begin
     59  WriteInteger(Node, 'Id', Id);
     60  WriteString(Node, 'Name', Name);
     61  WriteInteger(Node, 'Cost', Cost);
     62end;
    2963
    3064{ TBuildingKinds }
     
    3771end;
    3872
     73procedure TBuildingKinds.LoadFromNode(Node: TDOMNode);
     74var
     75  Node2: TDOMNode;
     76  NewItem: TBuildingKind;
     77begin
     78  Count := 0;
     79  Node2 := Node.FirstChild;
     80  while Assigned(Node2) and (Node2.NodeName = 'BuildingKind') do begin
     81    NewItem := TBuildingKind.Create;
     82    NewItem.LoadFromNode(Node2);
     83    Add(NewItem);
     84    Node2 := Node2.NextSibling;
     85  end;
     86end;
     87
     88procedure TBuildingKinds.SaveToNode(Node: TDOMNode);
     89var
     90  I: Integer;
     91  NewNode2: TDOMNode;
     92begin
     93  for I := 0 to Count - 1 do
     94  with Items[I] do begin
     95    NewNode2 := Node.OwnerDocument.CreateElement('BuildingKind');
     96    Node.AppendChild(NewNode2);
     97    SaveToNode(NewNode2);
     98  end;
     99end;
     100
     101procedure TBuildingKinds.Assign(Source: TBuildingKinds);
     102var
     103  I: Integer;
     104begin
     105  while Count > Source.Count do Delete(Count - 1);
     106  while Count < Source.Count do AddNew('');
     107  for I := 0 to Count - 1 do
     108    Items[I].Assign(Source.Items[I]);
     109end;
     110
    39111end.
    40112
  • trunk/UGameSystem.pas

    r284 r289  
    77uses
    88  Classes, SysUtils, fgl, UUnit, DOM, XMLRead, XMLWrite, UXMLUtils, XMLConf,
    9   FileUtil, UMapType, UNation;
     9  FileUtil, UMapType, UNation, UBuilding;
    1010
    1111type
     
    2323    PreferedMapType: TMapType;
    2424    Nations: TNations;
     25    BuildingKinds: TBuildingKinds;
    2526    constructor Create;
    2627    destructor Destroy; override;
     
    7980begin
    8081  UnitKinds := TUnitKinds.Create;
     82  BuildingKinds := TBuildingKinds.Create;
    8183  Nations := TNations.Create;
    8284end;
     
    8587begin
    8688  Nations.Free;
     89  BuildingKinds.Free;
    8790  UnitKinds.Free;
    8891  inherited Destroy;
     
    9295begin
    9396  UnitKinds.Clear;
     97  BuildingKinds.Clear;
    9498  Nations.Clear;
    9599end;
     
    109113  PreferedMapType := Source.PreferedMapType;
    110114  UnitKinds.Assign(Source.UnitKinds);
     115  BuildingKinds.Assign(Source.BuildingKinds);
    111116  Nations.Assign(Source.Nations);
    112117end;
     
    124129  if Assigned(NewNode) then
    125130    UnitKinds.LoadFromNode(NewNode);
     131  NewNode := Node.FindNode('BuildingKinds');
     132  if Assigned(NewNode) then
     133    BuildingKinds.LoadFromNode(NewNode);
    126134  NewNode := Node.FindNode('Nations');
    127135  if Assigned(NewNode) then
     
    141149  Node.AppendChild(NewNode);
    142150  UnitKinds.SaveToNode(NewNode);
     151  NewNode := Node.OwnerDocument.CreateElement('BuildingKinds');
     152  Node.AppendChild(NewNode);
     153  BuildingKinds.SaveToNode(NewNode);
    143154  NewNode := Node.OwnerDocument.CreateElement('Nations');
    144155  Node.AppendChild(NewNode);
  • trunk/xtactics.lpi

    r287 r289  
    110110      </Item7>
    111111    </RequiredPackages>
    112     <Units Count="46">
     112    <Units Count="48">
    113113      <Unit0>
    114114        <Filename Value="xtactics.lpr"/>
     
    361361        <ResourceBaseClass Value="Form"/>
    362362      </Unit45>
     363      <Unit46>
     364        <Filename Value="Forms/UFormBuildingKind.pas"/>
     365        <IsPartOfProject Value="True"/>
     366        <ComponentName Value="FormBuildingKind"/>
     367        <HasResources Value="True"/>
     368        <ResourceBaseClass Value="Form"/>
     369      </Unit46>
     370      <Unit47>
     371        <Filename Value="Forms/UFormBuildingKinds.pas"/>
     372        <IsPartOfProject Value="True"/>
     373        <ComponentName Value="FormBuildingKinds"/>
     374        <HasResources Value="True"/>
     375        <ResourceBaseClass Value="Form"/>
     376      </Unit47>
    363377    </Units>
    364378  </ProjectOptions>
Note: See TracChangeset for help on using the changeset viewer.