Changeset 298 for trunk


Ignore:
Timestamp:
Jul 10, 2019, 5:35:15 PM (5 years ago)
Author:
chronos
Message:
  • Added: New item list type reference. Used in players for reference to selected nation.
  • Modified: New game players selection migrated to dynamic item/list forms.
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormItem.pas

    r296 r298  
    9191  J: Integer;
    9292  Control: TControl;
     93  ReferenceList: TItemList;
     94  ReferenceItem: TItem;
    9395begin
    9496  Fields := Item.GetFields;
     
    111113      end;
    112114    end
     115    else if DataType = dtReference then begin
     116      TComboBox(Control).Items.BeginUpdate;
     117      try
     118        TComboBox(Control).Items.Clear;
     119        ReferenceList := Item.GetReferenceList(Index);
     120        if Assigned(ReferenceList) then
     121          for J := 0 to ReferenceList.Count - 1 do
     122            TComboBox(Control).Items.AddObject(TItem(ReferenceList[J]).Name, ReferenceList[J]);
     123        ReferenceItem := TItem(Item.GetValueReference(Index));
     124        TComboBox(Control).ItemIndex := TComboBox(Control).Items.IndexOfObject(ReferenceItem);
     125      finally
     126        TComboBox(Control).Items.EndUpdate;
     127      end;
     128    end
    113129    else raise Exception.Create(Format(SUnsupportedDataType, [DataTypeStr[DataType]]));
    114130  end;
     
    131147    else if DataType = dtBoolean then Item.SetValueBoolean(Index, TCheckBox(Control).Checked)
    132148    else if DataType = dtEnumeration then Item.SetValueEnumeration(Index, TUndefinedEnum(TComboBox(Control).ItemIndex))
     149    else if DataType = dtReference then begin
     150      if TComboBox(Control).ItemIndex <> -1 then
     151        Item.SetValueReference(Index, TItem(TComboBox(Control).Items.Objects[TComboBox(Control).ItemIndex]))
     152        else Item.SetValueReference(Index, nil);
     153    end
    133154    else raise Exception.Create(Format(SUnsupportedDataType, [DataTypeStr[DataType]]));
    134155  end;
     
    173194      TComboBox(NewControl).Style := csDropDownList;
    174195    end else
     196    if DataType = dtReference then begin
     197      NewControl := TComboBox.Create(nil);
     198      NewControl.Width := 200;
     199      TComboBox(NewControl).Style := csDropDownList;
     200    end else
    175201    if DataType = dtBoolean then begin
    176202      NewControl := TCheckBox.Create(nil);
  • trunk/Forms/UFormList.lfm

    r295 r298  
    1111  OnCreate = FormCreate
    1212  OnShow = FormShow
    13   LCLVersion = '2.0.0.4'
     13  LCLVersion = '2.0.2.0'
    1414  object ListView1: TListView
    1515    Left = 0
  • trunk/Forms/UFormList.pas

    r290 r298  
    5151    procedure UpdateListViewColumns;
    5252  public
     53    MinItemCount: Integer;
     54    MaxItemCount: Integer;
    5355    procedure UpdateInterface;
    5456    procedure UpdateList;
     
    7072  SRemoveItems = 'Remove items';
    7173  SRemoveItemsQuery = 'Do you want to remove selected items?';
    72   SNewItem = 'New item';
     74  SNew = 'New';
    7375
    7476{ TFormList }
     
    8385      for I := ListView1.Items.Count - 1 downto 0 do
    8486        if ListView1.Items[I].Selected then begin
     87          if List.Count <= MinItemCount then Break;
    8588          ListView1.Items[I].Selected := False;
    8689          List.Remove(TItem(ListView1.Items[I].Data));
     
    99102  if Assigned(ListView1.Selected) then
    100103  with TItem(ListView1.Selected.Data) do begin
    101     TempEntry := List.GetItemClass.Create;
     104    TempEntry := List.CreateItem;
    102105    TempEntry.Assign(TItem(ListView1.Selected.Data));
    103106    FormItem := TFormItem.Create(Self);
     
    121124  FormItem: TFormItem;
    122125begin
    123   TempEntry := List.GetItemClass.Create;
     126  if (MaxItemCount <> -1) and (List.Count >= MaxItemCount) then Exit;
     127
     128  TempEntry := List.CreateItem;
    124129  FormItem := TFormItem.Create(Self);
    125130  try
    126     TempEntry.Name := SNewItem;
     131    TempEntry.Name := SNew + ' ' + LowerCase(List.GetItemClass.GetClassName);
    127132    FormItem.Item := TempEntry;
    128133    if FormItem.ShowModal = mrOk then begin
     
    143148  FormItem: TFormItem;
    144149begin
    145   TempEntry := List.GetItemClass.Create;
     150  if (MaxItemCount <> -1) and (List.Count >= MaxItemCount) then Exit;
     151
     152  TempEntry := List.CreateItem;
    146153  TempEntry.Assign(TItem(ListView1.Selected.Data));
    147154  FormItem := TFormItem.Create(Self);
     
    183190  for I := 0 to ToolBar1.ButtonCount - 1 do
    184191    ToolBar1.Buttons[I].Hint := ToolBar1.Buttons[I].Caption;
     192  MinItemCount := 0;
     193  MaxItemCount := -1;
    185194end;
    186195
     
    197206  var DefaultDraw: Boolean);
    198207var
     208  ItemFields: TItemFields;
    199209  ItemField: TItemField;
    200210begin
    201   ItemField := TItem(Item.Data).GetField(SubItem);
    202   if ItemField.DataType = dtColor then
    203   with ListView1.Canvas do begin
    204     Brush.Color := TItem(Item.Data).GetValueColor(ItemField.Index);
    205     Brush.Style := bsSolid;
    206     FillRect(Item.DisplayRectSubItem(1, drBounds));
    207   end;
    208   ItemField.Free;
     211  ItemFields := TItem(Item.Data).GetFields;
     212  try
     213    ItemField := ItemFields[SubItem];
     214    if ItemField.DataType = dtColor then
     215    with ListView1.Canvas do begin
     216      Brush.Color := TItem(Item.Data).GetValueColor(ItemField.Index);
     217      Brush.Style := bsSolid;
     218      FillRect(Item.DisplayRectSubItem(SubItem, drBounds));
     219    end;
     220  finally
     221    ItemFields.Free;
     222  end;
    209223end;
    210224
     
    272286procedure TFormList.UpdateInterface;
    273287begin
    274   ARemove.Enabled := Assigned(FList) and Assigned(ListView1.Selected);
     288  ARemove.Enabled := Assigned(FList) and Assigned(ListView1.Selected) and (List.Count > MinItemCount);
    275289  AModify.Enabled := Assigned(FList) and Assigned(ListView1.Selected);
    276   AAdd.Enabled := Assigned(FList);
     290  AAdd.Enabled := Assigned(FList) and ((MaxItemCount = -1) or ((MaxItemCount <> -1) and (List.Count < MaxItemCount)));
     291  AClone.Enabled := Assigned(FList) and ((MaxItemCount = -1) or ((MaxItemCount <> -1) and (List.Count < MaxItemCount)));
    277292  ASelectAll.Enabled := ListView1.Items.Count > 0;
    278293end;
  • trunk/Forms/UFormNew.pas

    r288 r298  
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    99  ComCtrls, Spin, ExtCtrls, ActnList, ExtDlgs, Menus, UGame, UGeometry, UPlayer,
    10   UGameServer, UServerList, UMap, UFormPlayers, UGameSystem;
     10  UGameServer, UServerList, UMap, UGameSystem, UFormList;
    1111
    1212type
     
    144144    MapPreviewRedrawPending: Boolean;
    145145    NewRandSeed: Cardinal;
    146     FormPlayers: TFormPlayers;
     146    FormPlayers: TFormList;
    147147    procedure LoadGame(Game: TGame);
    148148    procedure SaveGame(Game: TGame);
     
    385385  if Assigned(FServer) then begin
    386386    Load(FServer);
    387     FormPlayers.Players := FServer.Game.Players;
     387    FormPlayers.List := FServer.Game.Players;
    388388  end else begin
    389     FormPlayers.Players := nil;
     389    FormPlayers.List := nil;
    390390  end;
    391391end;
     
    402402  GamePreview.GeneratePlayers := False;
    403403  GamePreview.New;
    404   GamePreview.CurrentPlayer := GamePreview.Players.First;
     404  GamePreview.CurrentPlayer := TPlayer(GamePreview.Players.First);
    405405  Bitmap := Image1.Picture.Bitmap;
    406406  Bitmap.SetSize(Image1.Width, Image1.Height);
     
    534534  FormChat.Align := alClient;
    535535  FormChat.Show;
    536   FormPlayers := TFormPlayers.Create(nil);
     536  FormPlayers := TFormList.Create(nil);
    537537  FormPlayers.MinItemCount := MinPlayerCount;
    538538  FormPlayers.MaxItemCount := MaxPlayerCount;
  • trunk/Forms/UFormPlayer.lfm

    r295 r298  
    11object FormPlayer: TFormPlayer
    2   Left = 470
     2  Left = 1304
    33  Height = 338
    4   Top = 157
     4  Top = 318
    55  Width = 543
    66  Caption = 'Player'
     
    1414  OnShow = FormShow
    1515  Position = poMainFormCenter
    16   LCLVersion = '2.0.0.4'
     16  LCLVersion = '2.0.2.0'
    1717  object Label1: TLabel
    1818    Left = 20
  • trunk/Languages/xtactics.cs.po

    r297 r298  
    132132
    133133#: tformabout.labelcontent.caption
    134 #, fuzzy
    135134msgctxt "tformabout.labelcontent.caption"
    136135msgid "   "
     
    709708
    710709#: tformplayer.checkboxdefensive.caption
     710msgctxt "tformplayer.checkboxdefensive.caption"
    711711msgid "Defensive"
    712712msgstr "Obranný"
     
    11361136msgstr "Hlavní okno"
    11371137
    1138 #: uformlist.snewitem
    1139 msgid "New item"
    1140 msgstr "Nová položka"
     1138#: uformlist.snew
     1139msgctxt "uformlist.snew"
     1140msgid "New"
     1141msgstr "Nová"
    11411142
    11421143#: uformlist.sremoveitems
     
    12211222msgstr "Zůstat naživu určený počet tahů"
    12221223
    1223 #: uformplayer.sagrohigh
    1224 msgid "High"
    1225 msgstr "Vysoká"
    1226 
    1227 #: uformplayer.sagrolow
    1228 msgid "Low"
    1229 msgstr "Nízká"
    1230 
    1231 #: uformplayer.sagromedium
    1232 msgid "Medium"
    1233 msgstr "Střední"
    1234 
    1235 #: uformplayer.scomputer
    1236 msgctxt "uformplayer.scomputer"
    1237 msgid "Computer"
    1238 msgstr "Počítač"
    1239 
    1240 #: uformplayer.shuman
    1241 msgctxt "uformplayer.shuman"
    1242 msgid "Human"
    1243 msgstr "Člověk"
    1244 
    1245 #: uformplayers.sremoveitems
    1246 msgctxt "uformplayers.sremoveitems"
    1247 msgid "Remove items"
    1248 msgstr "Odstranit položky"
    1249 
    1250 #: uformplayers.sremoveitemsquery
    1251 msgctxt "uformplayers.sremoveitemsquery"
    1252 msgid "Do you want to remove selected items?"
    1253 msgstr "Opravdu chcete odstranit vybrané položky?"
    1254 
    12551224#: ugame.scomputer
    12561225msgctxt "ugame.scomputer"
     
    13691338msgstr "Národ"
    13701339
     1340#: uplayer.sagressivity
     1341msgid "Agressivity"
     1342msgstr "Agresivita"
     1343
    13711344#: uplayer.sattackerpowerpositive
    13721345msgctxt "uplayer.sattackerpowerpositive"
     
    13741347msgstr "Síla útočníka musí být větší než 0."
    13751348
     1349#: uplayer.scolor
     1350msgctxt "uplayer.scolor"
     1351msgid "Color"
     1352msgstr "Barva"
     1353
     1354#: uplayer.scomputer
     1355msgctxt "uplayer.scomputer"
     1356msgid "Computer"
     1357msgstr "Počítač"
     1358
    13761359#: uplayer.sdefenderpowerpositive
    13771360msgctxt "uplayer.sdefenderpowerpositive"
     
    13791362msgstr "Síla obránce musí být vyšší než nebo rovna nule."
    13801363
     1364#: uplayer.sdefensive
     1365msgctxt "uplayer.sdefensive"
     1366msgid "Defensive"
     1367msgstr "Obranný"
     1368
     1369#: uplayer.shigh
     1370msgctxt "uplayer.shigh"
     1371msgid "High"
     1372msgstr "Vysoká"
     1373
     1374#: uplayer.shuman
     1375msgctxt "uplayer.shuman"
     1376msgid "Human"
     1377msgstr "Člověk"
     1378
     1379#: uplayer.slow
     1380msgctxt "uplayer.slow"
     1381msgid "Low"
     1382msgstr "Nízká"
     1383
     1384#: uplayer.smedium
     1385msgctxt "uplayer.smedium"
     1386msgid "Medium"
     1387msgstr "Střední"
     1388
     1389#: uplayer.smode
     1390msgctxt "uplayer.smode"
     1391msgid "Mode"
     1392msgstr "Režim"
     1393
     1394#: uplayer.snation
     1395msgctxt "uplayer.snation"
     1396msgid "Nation"
     1397msgstr "Národ"
     1398
     1399#: uplayer.sstartunits
     1400msgctxt "uplayer.sstartunits"
     1401msgid "Start units"
     1402msgstr "Počátečních jednotek"
     1403
    13811404#: uplayer.sunfinishedbattle
    13821405msgctxt "uplayer.sunfinishedbattle"
     
    14131436msgid "View range"
    14141437msgstr "Dohled"
     1438
  • trunk/Languages/xtactics.po

    r297 r298  
    695695
    696696#: tformplayer.checkboxdefensive.caption
     697msgctxt "tformplayer.checkboxdefensive.caption"
    697698msgid "Defensive"
    698699msgstr ""
     
    11131114msgstr ""
    11141115
    1115 #: uformlist.snewitem
    1116 msgid "New item"
     1116#: uformlist.snew
     1117msgctxt "uformlist.snew"
     1118msgid "New"
    11171119msgstr ""
    11181120
     
    11981200msgstr ""
    11991201
    1200 #: uformplayer.sagrohigh
    1201 msgid "High"
    1202 msgstr ""
    1203 
    1204 #: uformplayer.sagrolow
    1205 msgid "Low"
    1206 msgstr ""
    1207 
    1208 #: uformplayer.sagromedium
    1209 msgid "Medium"
    1210 msgstr ""
    1211 
    1212 #: uformplayer.scomputer
    1213 msgctxt "uformplayer.scomputer"
    1214 msgid "Computer"
    1215 msgstr ""
    1216 
    1217 #: uformplayer.shuman
    1218 msgctxt "uformplayer.shuman"
    1219 msgid "Human"
    1220 msgstr ""
    1221 
    1222 #: uformplayers.sremoveitems
    1223 msgctxt "uformplayers.sremoveitems"
    1224 msgid "Remove items"
    1225 msgstr ""
    1226 
    1227 #: uformplayers.sremoveitemsquery
    1228 msgctxt "uformplayers.sremoveitemsquery"
    1229 msgid "Do you want to remove selected items?"
    1230 msgstr ""
    1231 
    12321202#: ugame.scomputer
    12331203msgctxt "ugame.scomputer"
     
    13401310msgstr ""
    13411311
     1312#: uplayer.sagressivity
     1313msgid "Agressivity"
     1314msgstr ""
     1315
    13421316#: uplayer.sattackerpowerpositive
    13431317msgid "Attacker power have to be higher then 0."
    13441318msgstr ""
    13451319
     1320#: uplayer.scolor
     1321msgctxt "uplayer.scolor"
     1322msgid "Color"
     1323msgstr ""
     1324
     1325#: uplayer.scomputer
     1326msgctxt "uplayer.scomputer"
     1327msgid "Computer"
     1328msgstr ""
     1329
    13461330#: uplayer.sdefenderpowerpositive
    13471331msgid "Defender power have to be higher then or equal to 0."
     1332msgstr ""
     1333
     1334#: uplayer.sdefensive
     1335msgctxt "uplayer.sdefensive"
     1336msgid "Defensive"
     1337msgstr ""
     1338
     1339#: uplayer.shigh
     1340msgctxt "uplayer.shigh"
     1341msgid "High"
     1342msgstr ""
     1343
     1344#: uplayer.shuman
     1345msgctxt "uplayer.shuman"
     1346msgid "Human"
     1347msgstr ""
     1348
     1349#: uplayer.slow
     1350msgctxt "uplayer.slow"
     1351msgid "Low"
     1352msgstr ""
     1353
     1354#: uplayer.smedium
     1355msgctxt "uplayer.smedium"
     1356msgid "Medium"
     1357msgstr ""
     1358
     1359#: uplayer.smode
     1360msgctxt "uplayer.smode"
     1361msgid "Mode"
     1362msgstr ""
     1363
     1364#: uplayer.snation
     1365msgctxt "uplayer.snation"
     1366msgid "Nation"
     1367msgstr ""
     1368
     1369#: uplayer.sstartunits
     1370msgctxt "uplayer.sstartunits"
     1371msgid "Start units"
    13481372msgstr ""
    13491373
  • trunk/UCore.pas

    r292 r298  
    531531procedure TCore.LoadGame(FileName: string);
    532532var
    533   Player: TPlayer;
     533  I: Integer;
    534534  NewClient: TClient;
    535535  ServerClient: TServerClient;
     536  Player: TPlayer;
    536537begin
    537538  GameLoaded := True;
     
    544545  LocalClients.Clear;
    545546  FormClient.Client := nil;
    546   for Player in Game.Players do
    547   with Player do
    548   if Mode = pmHuman then begin
    549     NewClient := LocalClients.New(Name);
    550     NewClient.ControlPlayer := Player;
    551     TClientGUI(NewClient).View.Clear;
    552     TClientGUI(NewClient).View.Zoom := 1;
    553     NewClient.LocalServer := Server;
    554     NewClient.ConnectType := ctLocal;
    555     NewClient.Active := True;
    556     if Assigned(NewClient.ControlPlayer.StartCell) then
    557       TClientGUI(NewClient).View.CenterPlayerCity(NewClient.ControlPlayer)
    558       else TClientGUI(NewClient).View.CenterMap;
    559   end else
    560   if Mode = pmComputer then begin
    561     NewClient := TComputer.Create;
    562     NewClient.Game := TGame(Game);
    563     NewClient.Name := Name;
    564     LocalClients.Add(NewClient);
    565     NewClient.ControlPlayer := Player;
    566     NewClient.LocalServer := Server;
    567     NewClient.ConnectType := ctLocal;
    568     NewClient.Active := True;
     547  for I := 0 to Game.Players.Count - 1 do begin
     548    Player := TPlayer(Game.Players[I]);
     549    with Player do
     550    if Mode = pmHuman then begin
     551      NewClient := LocalClients.New(Name);
     552      NewClient.ControlPlayer := Player;
     553      TClientGUI(NewClient).View.Clear;
     554      TClientGUI(NewClient).View.Zoom := 1;
     555      NewClient.LocalServer := Server;
     556      NewClient.ConnectType := ctLocal;
     557      NewClient.Active := True;
     558      if Assigned(NewClient.ControlPlayer.StartCell) then
     559        TClientGUI(NewClient).View.CenterPlayerCity(NewClient.ControlPlayer)
     560        else TClientGUI(NewClient).View.CenterMap;
     561    end else
     562    if Mode = pmComputer then begin
     563      NewClient := TComputer.Create;
     564      NewClient.Game := TGame(Game);
     565      NewClient.Name := Name;
     566      LocalClients.Add(NewClient);
     567      NewClient.ControlPlayer := Player;
     568      NewClient.LocalServer := Server;
     569      NewClient.ConnectType := ctLocal;
     570      NewClient.Active := True;
     571    end;
    569572  end;
    570573
     
    650653  NewClient: TClient;
    651654  Player: TPlayer;
     655  I: Integer;
    652656  ServerClient: TServerClient;
    653657begin
     
    659663  LocalClients.Clear;
    660664  FormClient.Client := nil;
    661   for Player in Game.Players do
    662   with Player do
    663   if Mode = pmHuman then begin
    664     NewClient := LocalClients.New(Name);
    665     NewClient.ControlPlayer := Player;
    666     TClientGUI(NewClient).View.Clear;
    667     TClientGUI(NewClient).View.Zoom := 1;
    668     NewClient.LocalServer := Server;
    669     NewClient.ConnectType := ctLocal;
    670     NewClient.Active := True;
    671     if Assigned(NewClient.ControlPlayer.StartCell) then
    672       TClientGUI(NewClient).View.CenterPlayerCity(NewClient.ControlPlayer)
    673       else TClientGUI(NewClient).View.CenterMap;
    674   end else
    675   if Mode = pmComputer then begin
    676     NewClient := TComputer.Create;
    677     NewClient.Game := TGame(Game);
    678     NewClient.Name := Name;
    679     LocalClients.Add(NewClient);
    680     NewClient.ControlPlayer := Player;
    681     NewClient.LocalServer := Server;
    682     NewClient.ConnectType := ctLocal;
    683     NewClient.Active := True;
     665  for I := 0 to Game.Players.Count - 1 do begin
     666    Player := TPlayer(Game.Players[I]);
     667    with Player do
     668    if Mode = pmHuman then begin
     669      NewClient := LocalClients.New(Name);
     670      NewClient.ControlPlayer := Player;
     671      TClientGUI(NewClient).View.Clear;
     672      TClientGUI(NewClient).View.Zoom := 1;
     673      NewClient.LocalServer := Server;
     674      NewClient.ConnectType := ctLocal;
     675      NewClient.Active := True;
     676      if Assigned(NewClient.ControlPlayer.StartCell) then
     677        TClientGUI(NewClient).View.CenterPlayerCity(NewClient.ControlPlayer)
     678        else TClientGUI(NewClient).View.CenterMap;
     679    end else
     680    if Mode = pmComputer then begin
     681      NewClient := TComputer.Create;
     682      NewClient.Game := TGame(Game);
     683      NewClient.Name := Name;
     684      LocalClients.Add(NewClient);
     685      NewClient.ControlPlayer := Player;
     686      NewClient.LocalServer := Server;
     687      NewClient.ConnectType := ctLocal;
     688      NewClient.Active := True;
     689    end;
    684690  end;
    685691
  • trunk/UGame.pas

    r294 r298  
    330330  if not GeneratePlayers then Exit;
    331331
    332   for Player in Players do begin
    333     Player.Reset;
    334     Player.StartCell := nil;
    335   end;
    336   I := 0;
    337   for Player in Players do
    338   with Player do begin
     332  for I := 0 to Players.Count - 1 do begin
     333    TPlayer(Players[I]).Reset;
     334    TPlayer(Players[I]).StartCell := nil;
     335  end;
     336  for I := 0 to Players.Count - 1 do
     337  with TPlayer(Players[I]) do begin
     338    Player := TPlayer(Players[I]);
    339339    PlayerMap.Update;
    340340    if (Map.Size.X > 0) and (Map.Size.Y > 0) then begin
     
    342342      if Assigned(Player.StartCell) then begin
    343343        if SymetricMap and (I = 1) then
    344           StartCell := Map.Cells[Map.Cells.Count - 1 - Map.Cells.IndexOf(Players[0].StartCell)];
     344          StartCell := Map.Cells[Map.Cells.Count - 1 - Map.Cells.IndexOf(TPlayer(Players[0]).StartCell)];
    345345
    346346        if CityEnabled then begin
     
    358358    InitUnitMoves;
    359359    PlayerMap.CheckVisibility;
    360     Inc(I);
    361360  end;
    362361end;
     
    411410  Player: TPlayer;
    412411  List: TCells;
    413 begin
    414   for Player in Players do
    415   if Assigned(Player.StartCell) then begin
    416     Player.StartCell.Weight := 1;
    417     Player.StartCell.Mark := True;
    418     List := TCells.Create;
    419     List.FreeObjects := False;
    420     List.Add(Player.StartCell);
    421     PropagatePlayerDistance(List);
    422     FreeAndNil(List);
     412  I: Integer;
     413begin
     414  for I := 0 to Players.Count - 1 do begin
     415    Player := TPlayer(Players[I]);
     416    if Assigned(Player.StartCell) then begin
     417      Player.StartCell.Weight := 1;
     418      Player.StartCell.Mark := True;
     419      List := TCells.Create;
     420      List.FreeObjects := False;
     421      List.Add(Player.StartCell);
     422      PropagatePlayerDistance(List);
     423      FreeAndNil(List);
     424    end;
    423425  end;
    424426end;
     
    568570    MaxNeutralUnits := GetValue(DOMString(Path + '/MaxNeutralUnits'), 5);
    569571    MaxPower := GetValue(DOMString(Path + '/MaxPower'), 99);
     572    GameSystemName := string(GetValue(DOMString(Path + '/GameSystemName'), DOMString('')));
    570573    Players.LoadConfig(Config, Path + '/Players');
    571     GameSystemName := string(GetValue(DOMString(Path + '/GameSystemName'), DOMString('')));
    572574  end;
    573575end;
     
    617619      if Assigned(NewNode) then
    618620        Players.LoadFromNode(NewNode);
    619       if Players.Count > 0 then CurrentPlayer := Players[0]
     621      if Players.Count > 0 then CurrentPlayer := TPlayer(Players[0])
    620622        else CurrentPlayer := nil;
    621623
     
    628630
    629631      for I := 0 to Players.Count - 1 do begin
    630         Players[I].PlayerMap.Update;
    631         Players[I].PlayerMap.CheckVisibility;
     632        TPlayer(Players[I]).PlayerMap.Update;
     633        TPlayer(Players[I]).PlayerMap.CheckVisibility;
    632634      end;
    633635      ComputePlayerStats;
     
    700702begin
    701703  for I := 0 to Players.Count - 1 do
    702   with Players[I] do begin
     704  with TPlayer(Players[I]) do begin
    703705    TotalUnits := 0;
    704706    TotalCells := 0;
     
    721723begin
    722724  for I := 0 to Players.Count - 1 do
    723   with Players[I] do begin
     725  with TPlayer(Players[I]) do begin
    724726    NewStat := TGameTurnStat.Create;
    725727    NewStat.DiscoveredCells := TotalDiscovered;
     
    770772      NewPlayerIndex := NewPlayerIndex mod AlivePlayers.Count;
    771773    end;
    772     CurrentPlayer := AlivePlayers[NewPlayerIndex];
     774    CurrentPlayer := TPlayer(AlivePlayers[NewPlayerIndex]);
    773775  finally
    774776    AlivePlayers.Free;
     
    895897  I: Integer;
    896898begin
    897   for I := 0 to Players.Count - 1 do Players[I].Clear;
     899  for I := 0 to Players.Count - 1 do TPlayer(Players[I]).Clear;
    898900  Map.Clear;
    899901end;
     
    922924
    923925  InitPlayers;
    924   if Players.Count > 0 then CurrentPlayer := Players[0]
     926  if Players.Count > 0 then CurrentPlayer := TPlayer(Players[0])
    925927    else CurrentPlayer := nil;
    926928
  • trunk/UItemList.pas

    r296 r298  
    99
    1010type
     11  TItemList = class;
    1112  TUndefinedEnum = (eeNone);
    1213
    1314  TDataType = (dtNone, dtString, dtBoolean, dtInteger, dtFloat, dtColor,
    14     dtTime, dtDate, dtDateTime, dtEnumeration);
     15    dtTime, dtDate, dtDateTime, dtEnumeration, dtReference);
    1516
    1617  { TItemField }
     
    5455    function GetValueBoolean(Index: Integer): Boolean;
    5556    function GetValueEnumeration(Index: Integer): TUndefinedEnum;
     57    function GetValueReference(Index: Integer): TItem;
    5658    function GetValueAsText(Index: Integer): string;
    5759    procedure SetValue(Index: Integer; var Value); virtual;
     
    6163    procedure SetValueBoolean(Index: Integer; Value: Boolean);
    6264    procedure SetValueEnumeration(Index: Integer; Value: TUndefinedEnum);
     65    procedure SetValueReference(Index: Integer; Value: TItem);
    6366    procedure Assign(Source: TItem); virtual;
    6467    procedure LoadFromNode(Node: TDOMNode); virtual;
     
    6669    class function GetClassSysName: string; virtual;
    6770    class function GetClassName: string; virtual;
     71    function GetReferenceList(Index: Integer): TItemList; virtual;
     72    constructor Create; virtual;
    6873  end;
    6974
     
    8186    function GetNewId: Integer;
    8287    procedure Assign(Source: TItemList); virtual;
    83     function AddItem(Name: string): TItem; virtual;
     88    function AddItem(Name: string = ''): TItem; virtual;
     89    function CreateItem(Name: string = ''): TItem; virtual;
    8490    procedure LoadFromNode(Node: TDOMNode); virtual;
    8591    procedure SaveToNode(Node: TDOMNode); virtual;
     
    8995const
    9096  DataTypeStr: array[TDataType] of string = ('None', 'String', 'Boolean',
    91     'Integer', 'Float', 'Color', 'Time', 'Date', 'DateTime', 'Enumeration');
     97    'Integer', 'Float', 'Color', 'Time', 'Date', 'DateTime', 'Enumeration',
     98    'Reference');
    9299
    93100resourcestring
     
    136143  while Count < Source.Count do AddItem('');
    137144  for I := 0 to Count - 1 do
    138     Items[I].Assign(Source.Items[I]);
     145    TItem(Items[I]).Assign(Source.Items[I]);
    139146end;
    140147
    141148function TItemList.AddItem(Name: string): TItem;
     149begin
     150  Result := CreateItem(Name);
     151  Result.Id := GetNewId;
     152  Add(Result);
     153end;
     154
     155function TItemList.CreateItem(Name: string): TItem;
    142156begin
    143157  Result := GetItemClass.Create;
    144158  Result.Name := Name;
    145   Result.Id := GetNewId;
    146   Add(Result);
    147159end;
    148160
     
    155167  Node2 := Node.FirstChild;
    156168  while Assigned(Node2) and (Node2.NodeName = UnicodeString(GetItemClass.GetClassSysName)) do begin
    157     NewItem := GetItemClass.Create;
     169    NewItem := CreateItem;
    158170    NewItem.LoadFromNode(Node2);
    159171    Add(NewItem);
     
    177189constructor TItemList.Create(FreeObjects: Boolean);
    178190begin
    179   inherited Create(FreeObjects);
     191  inherited;
    180192  NewId := 1;
    181193end;
     
    273285    SetValueEnumeration(Field.Index, Source.GetValueEnumeration(Field.Index));
    274286  end else
     287  if Field.DataType = dtReference then begin
     288    SetValueReference(Field.Index, Source.GetValueReference(Field.Index));
     289  end else
    275290    raise Exception.Create(Format(SUnsupportedDataType, [DataTypeStr[Field.DataType]]));
    276291end;
    277292
    278293procedure TItem.LoadValueFromNode(Node: TDOMNode; Field: TItemField);
     294var
     295  ReadId: Integer;
     296  ReferenceList: TItemList;
    279297begin
    280298  if Field.DataType = dtString then begin
     
    293311    SetValueEnumeration(Field.Index, TUndefinedEnum(ReadInteger(Node, Field.SysName, 0)));
    294312  end else
     313  if Field.DataType = dtReference then begin
     314    ReadId := ReadInteger(Node, Field.SysName, 0);
     315    ReferenceList := GetReferenceList(Field.Index);
     316    if (ReadId > 0) and Assigned(ReferenceList) then
     317      SetValueReference(Field.Index, TItem(ReferenceList.List[ReadId]));
     318  end else
    295319    raise Exception.Create(Format(SUnsupportedDataType, [DataTypeStr[Field.DataType]]));
    296320end;
    297321
    298322procedure TItem.SaveValueToNode(Node: TDOMNode; Field: TItemField);
     323var
     324  Item: TItem;
    299325begin
    300326  if Field.DataType = dtString then begin
     
    312338  if Field.DataType = dtEnumeration then begin
    313339    WriteInteger(Node, Field.SysName, Integer(GetValueEnumeration(Field.Index)));
     340  end else
     341  if Field.DataType = dtReference then begin
     342    Item := TItem(GetValueReference(Field.Index));
     343    if Assigned(Item) then WriteInteger(Node, Field.SysName, Item.Id)
     344      else WriteInteger(Node, Field.SysName, 0);
    314345  end else
    315346    raise Exception.Create(Format(SUnsupportedDataType, [DataTypeStr[Field.DataType]]));
     
    329360  Fields := GetFields;
    330361  try
    331     Result.Assign(Fields[Index]);
     362    Result.Assign(Fields.SearchByIndex(Index));
    332363  finally
    333364    Fields.Free;
     
    365396end;
    366397
     398function TItem.GetValueReference(Index: Integer): TItem;
     399begin
     400  GetValue(Index, Result);
     401end;
     402
    367403function TItem.GetValueAsText(Index: Integer): string;
    368404var
    369   Fields: TItemFields;
    370405  Field: TItemField;
    371 begin
    372   Fields := GetFields;
    373   Field := GetField(Fields.IndexOf(Fields.SearchByIndex(Index)));
    374   if Field.DataType = dtInteger then Result := IntToStr(GetValueInteger(Index))
    375   else if Field.DataType = dtString then Result := GetValueString(Index)
    376   else if Field.DataType = dtColor then Result := ''
    377   else if Field.DataType = dtEnumeration then Result := Field.EnumStates[Integer(GetValueEnumeration(Index))]
    378   else if Field.DataType = dtBoolean then begin
    379     if GetValueBoolean(Index) then Result := SYes else Result := SNo;
    380   end else
    381     raise Exception.Create(Format(SUnsupportedDataType, [DataTypeStr[Field.DataType]]));
    382   Field.Free;
    383   Fields.Free;
     406  Item: TItem;
     407begin
     408  Field := GetField(Index);
     409  try
     410    if Field.DataType = dtInteger then Result := IntToStr(GetValueInteger(Index))
     411    else if Field.DataType = dtString then Result := GetValueString(Index)
     412    else if Field.DataType = dtColor then Result := ''
     413    else if Field.DataType = dtEnumeration then Result := Field.EnumStates[Integer(GetValueEnumeration(Index))]
     414    else if Field.DataType = dtReference then begin
     415      Item := TItem(GetValueReference(Index));
     416      if Assigned(Item) then Result := Item.Name
     417        else Result := '';
     418    end else if Field.DataType = dtBoolean then begin
     419      if GetValueBoolean(Index) then Result := SYes else Result := SNo;
     420    end else
     421      raise Exception.Create(Format(SUnsupportedDataType, [DataTypeStr[Field.DataType]]));
     422  finally
     423    Field.Free;
     424  end;
    384425end;
    385426
     
    411452procedure TItem.SetValueEnumeration(Index: Integer;
    412453  Value: TUndefinedEnum);
     454begin
     455  SetValue(Index, Value);
     456end;
     457
     458procedure TItem.SetValueReference(Index: Integer; Value: TItem);
    413459begin
    414460  SetValue(Index, Value);
     
    474520end;
    475521
     522function TItem.GetReferenceList(Index: Integer): TItemList;
     523begin
     524  Result := nil;
     525end;
     526
     527constructor TItem.Create;
     528begin
     529end;
     530
    476531end.
    477532
  • trunk/UPlayer.pas

    r297 r298  
    122122    procedure GetValue(Index: Integer; out Value); override;
    123123    procedure SetValue(Index: Integer; var Value); override;
     124    function GetReferenceList(Index: Integer): TItemList; override;
    124125    class function GetClassSysName: string; override;
     126    class function GetClassName: string; override;
    125127    function IsAllowedMoveTarget(CellFrom, CellTo: TPlayerCell): Boolean;
    126128    procedure ReduceMovesPower;
     
    139141    procedure LoadFromNode(Node: TDOMNode); override;
    140142    procedure SaveToNode(Node: TDOMNode); override;
    141     constructor Create;
     143    constructor Create; override;
    142144    destructor Destroy; override;
    143145    procedure Assign(Source: TItem); override;
     
    153155  { TPlayers }
    154156
    155   TPlayers = class(TFPGObjectList<TPlayer>)
     157  TPlayers = class(TItemList)
    156158  public
    157159    Game: TObject; //TGame;
    158     NewId: Integer;
    159     function FindById(Id: Integer): TPlayer;
     160    class function GetItemClass: TItemClass; override;
    160161    procedure New(Name: string; Color: TColor; Mode: TPlayerMode);
    161     function GetNewId: Integer;
    162     procedure LoadFromNode(Node: TDOMNode);
    163     procedure SaveToNode(Node: TDOMNode);
    164     constructor Create(FreeObjects: Boolean = True);
     162    function CreateItem(Name: string = ''): TItem; override;
    165163    function GetFirstHuman: TPlayer;
    166     procedure Assign(Source: TPlayers);
    167164    procedure LoadConfig(Config: TXmlConfig; Path: string);
    168165    procedure SaveConfig(Config: TXmlConfig; Path: string);
     
    216213  SDefenderPowerPositive = 'Defender power have to be higher then or equal to 0.';
    217214  SUnfinishedBattle = 'Unfinished battle';
     215  SLow = 'Low';
     216  SMedium = 'Medium';
     217  SHigh = 'High';
     218  SHuman = 'Human';
     219  SComputer = 'Computer';
     220  SNation = 'Nation';
     221  SMode = 'Mode';
     222  SColor = 'Color';
     223  SAgressivity = 'Agressivity';
     224  SStartUnits = 'Start units';
     225  SDefensive = 'Defensive';
    218226
    219227function ComparePointer(const Item1, Item2: Integer): Integer;
     
    497505function TPlayers.GetAliveCount: Integer;
    498506var
    499   Player: TPlayer;
     507  I: Integer;
    500508begin
    501509  Result := 0;
    502   for Player in Self do
    503     if Player.IsAlive then Inc(Result);
     510  for I := 0 to Count - 1 do
     511    if TPlayer(Items[I]).IsAlive then Inc(Result);
    504512end;
    505513
    506514procedure TPlayers.GetAlivePlayers(Players: TPlayers);
    507515var
    508   Player: TPlayer;
     516  I: Integer;
    509517begin
    510518  Players.Clear;
    511   for Player in Self do
    512     if Player.IsAlive then Players.Add(Player);
    513 end;
    514 
    515 function TPlayers.FindById(Id: Integer): TPlayer;
     519  for I := 0 to Count - 1 do
     520    if TPlayer(Items[I]).IsAlive then Players.Add(TPlayer(Items[I]));
     521end;
     522
     523class function TPlayers.GetItemClass: TItemClass;
     524begin
     525  Result := TPlayer;
     526end;
     527
     528procedure TPlayers.New(Name: string; Color: TColor; Mode: TPlayerMode);
     529begin
     530  AddItem(Name);
     531  TPlayer(Last).Color := Color;
     532  TPlayer(Last).Mode := Mode;
     533  if Mode = pmComputer then
     534    TPlayer(Last).Agressivity := caMedium;
     535end;
     536
     537function TPlayers.CreateItem(Name: string): TItem;
     538begin
     539  Result := inherited;
     540  TPlayer(Result).Game := Game;
     541end;
     542
     543function TPlayers.GetFirstHuman: TPlayer;
    516544var
    517545  I: Integer;
    518546begin
    519547  I := 0;
    520   while (I < Count) and (Items[I].Id <> Id) do Inc(I);
    521   if I < Count then Result := Items[I]
     548  while (I < Count) and (TPlayer(Items[I]).Mode <> pmHuman) do Inc(I);
     549  if I < Count then Result := TPlayer(Items[I])
    522550    else Result := nil;
    523 end;
    524 
    525 procedure TPlayers.New(Name: string; Color: TColor; Mode: TPlayerMode);
    526 var
    527   NewPlayer: TPlayer;
    528 begin
    529   NewPlayer := TPlayer.Create;
    530   NewPlayer.Game := Game;
    531   NewPlayer.Name := Name;
    532   NewPlayer.Color := Color;
    533   NewPlayer.Mode := Mode;
    534   NewPlayer.Id := GetNewId;
    535   if Mode = pmComputer then
    536     NewPlayer.Agressivity := caMedium;
    537   Add(NewPlayer);
    538 end;
    539 
    540 function TPlayers.GetNewId: Integer;
    541 begin
    542   Result := NewId;
    543   Inc(NewId);
    544 end;
    545 
    546 procedure TPlayers.LoadFromNode(Node: TDOMNode);
    547 var
    548   Node2: TDOMNode;
    549   NewPlayer: TPlayer;
    550 begin
    551   Count := 0;
    552   Node2 := Node.FirstChild;
    553   while Assigned(Node2) and (Node2.NodeName = 'Player') do begin
    554     NewPlayer := TPlayer.Create;
    555     NewPlayer.Game := Game;
    556     NewPlayer.LoadFromNode(Node2);
    557     Add(NewPlayer);
    558     Node2 := Node2.NextSibling;
    559   end;
    560 end;
    561 
    562 procedure TPlayers.SaveToNode(Node: TDOMNode);
    563 var
    564   I: Integer;
    565   NewNode: TDOMNode;
    566 begin
    567   for I := 0 to Count - 1 do begin;
    568     NewNode := Node.OwnerDocument.CreateElement('Player');
    569     Node.AppendChild(NewNode);
    570     Items[I].SaveToNode(NewNode);
    571   end;
    572 end;
    573 
    574 constructor TPlayers.Create(FreeObjects: Boolean = True);
    575 begin
    576   inherited;
    577   NewId := 1;
    578 end;
    579 
    580 function TPlayers.GetFirstHuman: TPlayer;
    581 var
    582   I: Integer;
    583 begin
    584   I := 0;
    585   while (I < Count) and (Items[I].Mode <> pmHuman) do Inc(I);
    586   if I < Count then Result := Items[I]
    587     else Result := nil;
    588 end;
    589 
    590 procedure TPlayers.Assign(Source: TPlayers);
    591 var
    592   I: Integer;
    593 begin
    594   while Count > Source.Count do
    595     Delete(Count - 1);
    596   while Count < Source.Count do
    597     Add(TPlayer.Create);
    598   for I := 0 to Count - 1 do begin
    599     Items[I].Assign(Source[I]);
    600     Items[I].Game := Game;
    601   end;
    602   NewId := Source.NewId;
    603551end;
    604552
     
    615563      Count := NewCount;
    616564      for I := 0 to Count - 1 do begin
    617         Items[I] := TPlayer.Create;
    618         Items[I].Id := GetNewId;
    619         Items[I].Game := Game;
    620         Items[I].LoadConfig(Config, Path + '/Player' + IntToStr(I));
     565        Items[I] := CreateItem;
     566        TPlayer(Items[I]).LoadConfig(Config, Path + '/Player' + IntToStr(I));
    621567      end;
    622568    end;
     
    629575begin
    630576  for I := 0 to Count - 1 do
    631     Items[I].SaveConfig(Config, Path + '/Player' + IntToStr(I));
     577    TPlayer(Items[I]).SaveConfig(Config, Path + '/Player' + IntToStr(I));
    632578  with Config do begin
    633579    SetValue(DOMString(Path + '/Count'), Count);
     
    637583function TPlayers.GetAlivePlayers: TPlayerArray;
    638584var
    639   Player: TPlayer;
     585  I: Integer;
    640586begin
    641587  SetLength(Result, 0);
    642   for Player in Self do
    643     if Player.IsAlive then begin
     588  for I := 0 to Count - 1 do
     589    if TPlayer(Items[I]).IsAlive then begin
    644590      SetLength(Result, Length(Result) + 1);
    645       Result[Length(Result) - 1] := Player;
     591      Result[Length(Result) - 1] := TPlayer(Items[I]);
    646592    end;
    647593end;
     
    649595function TPlayers.GetAlivePlayersWithCities: TPlayerArray;
    650596var
    651   Player: TPlayer;
     597  I: Integer;
    652598begin
    653599  SetLength(Result, 0);
    654   for Player in Self do
    655     if Player.TotalCities > 0 then begin
     600  for I := 0 to Count - 1 do
     601    if TPlayer(Items[I]).TotalCities > 0 then begin
    656602      SetLength(Result, Length(Result) + 1);
    657       Result[Length(Result) - 1] := Player;
     603      Result[Length(Result) - 1] := TPlayer(Items[I]);
    658604    end;
    659605end;
     
    803749  NewNode: TDOMNode;
    804750begin
    805   Id := ReadInteger(Node, 'Id', 0);
    806   Name := ReadString(Node, 'Name', '');
    807   Color := ReadInteger(Node, 'Color', clSilver);
    808   Mode := TPlayerMode(ReadInteger(Node, 'Mode', Integer(pmHuman)));
     751  inherited;
    809752  StartCell := TGame(FGame).Map.Cells.FindById(ReadInteger(Node, 'StartCell', 0));
    810   StartUnits := ReadInteger(Node, 'StartUnits', 0);
    811   Agressivity := TComputerAgressivity(ReadInteger(Node, 'Agressivity', Integer(caMedium)));
    812   Defensive := ReadBoolean(Node, 'Defensive', False);
    813753
    814754  with Node do begin
     
    834774  NewNode: TDOMNode;
    835775begin
    836   WriteInteger(Node, 'Id', Id);
    837   WriteString(Node, 'Name', Name);
    838   WriteInteger(Node, 'Color', Color);
    839   WriteInteger(Node, 'Mode', Integer(Mode));
     776  inherited;
    840777  WriteInteger(Node, 'StartCell', StartCell.Id);
    841   WriteInteger(Node, 'StartUnits', StartUnits);
    842   WriteInteger(Node, 'Agressivity', Integer(Agressivity));
    843   WriteBoolean(Node, 'Defensive', Defensive);
    844778
    845779  with Node do begin
     
    862796constructor TPlayer.Create;
    863797begin
     798  inherited;
    864799  Units := TUnits.Create(False);
    865800  Moves := TUnitMoves.Create;
     
    879814  FreeAndNil(Moves);
    880815  FreeAndNil(Units);
    881   inherited Destroy;
     816  inherited;
    882817end;
    883818
    884819procedure TPlayer.Assign(Source: TItem);
    885820begin
    886   Id := Source.Id;
    887   Name := Source.Name;
    888   Color := TPlayer(Source).Color;
    889   Mode := TPlayer(Source).Mode;
    890   Game := TPlayer(Source).Game;
     821  inherited;
     822  //Game := TPlayer(Source).Game;
    891823  TotalCells := TPlayer(Source).TotalCells;
    892824  TotalUnits := TPlayer(Source).TotalUnits;
     
    894826  TotalDiscovered := TPlayer(Source).TotalDiscovered;
    895827  TotalWinObjectiveCells := TPlayer(Source).TotalWinObjectiveCells;
    896   StartUnits := TPlayer(Source).StartUnits;
    897828  StartCell := TPlayer(Source).StartCell;
    898   Agressivity := TPlayer(Source).Agressivity;
    899   Defensive := TPlayer(Source).Defensive;
    900   Nation := TPlayer(Source).Nation;
    901829end;
    902830
     
    12661194
    12671195class function TPlayer.GetFields: TItemFields;
     1196var
     1197  Field: TItemField;
    12681198begin
    12691199  Result := inherited;
    1270   Result.AddField(2, 'Color', 'Color', dtColor);
    1271   Result.AddField(3, 'Mode', 'Mode', dtInteger);
    1272   Result.AddField(4, 'StartUnits', 'StartUnits', dtInteger);
    1273   Result.AddField(5, 'Agressivity', 'Agressivity', dtInteger);
    1274   Result.AddField(6, 'Defensive', 'Defensive', dtBoolean);
     1200  Field := Result.AddField(2, 'Nation', SNation, dtReference);
     1201  Field := Result.AddField(3, 'Mode', SMode, dtEnumeration);
     1202  Field.EnumStates.Add(SHuman);
     1203  Field.EnumStates.Add(SComputer);
     1204  Result.AddField(4, 'Color', SColor, dtColor);
     1205  Field := Result.AddField(5, 'Agressivity', SAgressivity, dtEnumeration);
     1206  Field.EnumStates.Add(SLow);
     1207  Field.EnumStates.Add(SMedium);
     1208  Field.EnumStates.Add(SHigh);
     1209  Result.AddField(6, 'Defensive', SDefensive, dtBoolean);
     1210  Result.AddField(7, 'StartUnits', SStartUnits, dtInteger);
    12751211end;
    12761212
    12771213procedure TPlayer.GetValue(Index: Integer; out Value);
    12781214begin
    1279   inherited GetValue(Index, Value);
     1215  if Index = 1 then string(Value) := Name
     1216  else if Index = 2 then TNation(Value) := Nation
     1217  else if Index = 3 then TPlayerMode(Value) := Mode
     1218  else if Index = 4 then TColor(Value) := Color
     1219  else if Index = 5 then TComputerAgressivity(Value) := Agressivity
     1220  else if Index = 6 then Boolean(Value) := Defensive
     1221  else if Index = 7 then Integer(Value) := StartUnits
     1222  else inherited;
    12801223end;
    12811224
    12821225procedure TPlayer.SetValue(Index: Integer; var Value);
    12831226begin
    1284   inherited SetValue(Index, Value);
     1227  if Index = 1 then Name := string(Value)
     1228  else if Index = 2 then Nation := TNation(Value)
     1229  else if Index = 3 then Mode := TPlayerMode(Value)
     1230  else if Index = 4 then Color := TColor(Value)
     1231  else if Index = 5 then Agressivity := TComputerAgressivity(Value)
     1232  else if Index = 6 then Defensive := Boolean(Value)
     1233  else if Index = 7 then StartUnits := Integer(Value)
     1234  else inherited;
     1235end;
     1236
     1237function TPlayer.GetReferenceList(Index: Integer): TItemList;
     1238begin
     1239  if Index = 2 then Result := TGame(Game).GameSystem.Nations
     1240  else Result := nil;
    12851241end;
    12861242
     
    12881244begin
    12891245  Result := 'Player';
     1246end;
     1247
     1248class function TPlayer.GetClassName: string;
     1249begin
     1250  Result := SPlayer;
    12901251end;
    12911252
Note: See TracChangeset for help on using the changeset viewer.