Changeset 282


Ignore:
Timestamp:
Mar 10, 2019, 4:48:41 PM (6 years ago)
Author:
chronos
Message:
  • Modified: Allow to set nation in player settings.
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormNew.lfm

    r281 r282  
    258258        object ComboBoxGridType: TComboBox
    259259          Left = 146
    260           Height = 38
     260          Height = 42
    261261          Top = 104
    262262          Width = 304
     
    275275        object ComboBoxMapShape: TComboBox
    276276          Left = 146
    277           Height = 38
     277          Height = 42
    278278          Top = 144
    279279          Width = 304
  • trunk/Forms/UFormNew.pas

    r281 r282  
    514514  FormChat.Show;
    515515  Players := TPlayers.Create;
     516  Players.Game := GamePreview;
    516517  FormPlayers := TFormPlayers.Create(nil);
    517518  FormPlayers.MinItemCount := MinPlayerCount;
  • trunk/Forms/UFormPlayer.lfm

    r279 r282  
    11object FormPlayer: TFormPlayer
    22  Left = 470
    3   Height = 344
    4   Top = 219
    5   Width = 522
     3  Height = 406
     4  Top = 157
     5  Width = 652
    66  Caption = 'Player'
    7   ClientHeight = 344
    8   ClientWidth = 522
     7  ClientHeight = 406
     8  ClientWidth = 652
    99  Constraints.MinHeight = 344
    1010  Constraints.MinWidth = 522
     
    2727    Height = 43
    2828    Top = 27
    29     Width = 339
     29    Width = 469
    3030    Anchors = [akTop, akLeft, akRight]
    3131    TabOrder = 0
    3232  end
    3333  object ButtonCancel: TButton
    34     Left = 278
     34    Left = 274
    3535    Height = 25
    36     Top = 307
     36    Top = 366
    3737    Width = 75
    3838    Anchors = [akRight, akBottom]
     
    4242  end
    4343  object ButtonOk: TButton
    44     Left = 403
     44    Left = 394
    4545    Height = 25
    46     Top = 307
     46    Top = 369
    4747    Width = 75
    4848    Anchors = [akRight, akBottom]
     
    5555    Left = 168
    5656    Height = 38
    57     Top = 72
    58     Width = 339
     57    Top = 124
     58    Width = 469
    5959    Anchors = [akTop, akLeft, akRight]
    6060    ItemHeight = 0
     
    7272    Left = 24
    7373    Height = 26
    74     Top = 72
     74    Top = 128
    7575    Width = 53
    7676    Caption = 'Mode:'
     
    8080    Left = 24
    8181    Height = 26
    82     Top = 128
     82    Top = 176
    8383    Width = 50
    8484    Caption = 'Color:'
     
    8888    Left = 168
    8989    Height = 42
    90     Top = 120
    91     Width = 339
     90    Top = 168
     91    Width = 469
    9292    Style = [cbStandardColors, cbExtendedColors, cbCustomColor, cbPrettyNames]
    9393    Anchors = [akTop, akLeft, akRight]
     
    9898    Left = 24
    9999    Height = 26
    100     Top = 168
     100    Top = 216
    101101    Width = 98
    102102    Caption = 'Agressivity:'
     
    105105  object ComboBoxAgressivity: TComboBox
    106106    Left = 168
    107     Height = 42
    108     Top = 168
    109     Width = 339
     107    Height = 38
     108    Top = 216
     109    Width = 469
    110110    Anchors = [akTop, akLeft, akRight]
    111111    ItemHeight = 0
     
    122122    Left = 24
    123123    Height = 30
    124     Top = 208
     124    Top = 256
    125125    Width = 109
    126126    Caption = 'Defensive'
     
    130130    Left = 24
    131131    Height = 26
    132     Top = 248
     132    Top = 296
    133133    Width = 94
    134134    Caption = 'Start units:'
     
    138138    Left = 224
    139139    Height = 43
    140     Top = 240
     140    Top = 288
    141141    Width = 112
    142142    MaxValue = 99
    143143    TabOrder = 7
    144144  end
     145  object ComboBoxNation: TComboBox
     146    Left = 168
     147    Height = 42
     148    Top = 76
     149    Width = 469
     150    Anchors = [akTop, akLeft, akRight]
     151    ItemHeight = 0
     152    OnChange = ComboBoxModeChange
     153    Style = csDropDownList
     154    TabOrder = 8
     155  end
     156  object Label6: TLabel
     157    Left = 24
     158    Height = 26
     159    Top = 80
     160    Width = 63
     161    Caption = 'Nation:'
     162    ParentColor = False
     163  end
    145164end
  • trunk/Forms/UFormPlayer.pas

    r279 r282  
    2020    ComboBoxMode: TComboBox;
    2121    ComboBoxAgressivity: TComboBox;
     22    ComboBoxNation: TComboBox;
    2223    EditName: TEdit;
    2324    Label1: TLabel;
     
    2627    Label4: TLabel;
    2728    Label5: TLabel;
     29    Label6: TLabel;
    2830    SpinEditStartUnits: TSpinEdit;
    2931    procedure ComboBoxModeChange(Sender: TObject);
     
    4850
    4951uses
    50   UCore;
     52  UCore, UNation;
    5153
    5254resourcestring
     
    111113
    112114procedure TFormPlayer.LoadData(Player: TPlayer);
     115var
     116  I: Integer;
    113117begin
     118  while ComboBoxNation.Items.Count > TGame(Player.Game).GameSystem.Nations.Count do
     119    ComboBoxNation.Items.Delete(ComboBoxNation.Items.Count - 1);
     120  while ComboBoxNation.Items.Count < TGame(Player.Game).GameSystem.Nations.Count do
     121    ComboBoxNation.Items.Add('');
     122  for I := 0 to TGame(Player.Game).GameSystem.Nations.Count - 1 do begin
     123    ComboBoxNation.Items[I] := TGame(Player.Game).GameSystem.Nations[I].Name;
     124    ComboBoxNation.Items.Objects[I] := TGame(Player.Game).GameSystem.Nations[I];
     125  end;
     126
     127  ComboBoxNation.ItemIndex := ComboBoxNation.Items.IndexOfObject(Player.Nation);
     128  if (ComboBoxNation.ItemIndex = -1) and (ComboBoxNation.Items.Count > 0) then
     129    ComboBoxNation.ItemIndex := 0;
     130
    114131  EditName.Text := Player.Name;
    115132  ComboBoxMode.ItemIndex := Integer(Player.Mode);
     
    123140procedure TFormPlayer.SaveData(Player: TPlayer);
    124141begin
     142  Player.Nation := TNation(ComboBoxNation.Items.Objects[ComboBoxNation.ItemIndex]);
    125143  Player.Name := EditName.Text;
    126144  Player.Mode := TPlayerMode(ComboBoxMode.ItemIndex);
  • trunk/Forms/UFormPlayers.lfm

    r279 r282  
    11object FormPlayers: TFormPlayers
    2   Left = 779
    3   Height = 360
    4   Top = 236
    5   Width = 480
     2  Left = 566
     3  Height = 354
     4  Top = 293
     5  Width = 682
    66  Caption = 'Players'
    7   ClientHeight = 360
    8   ClientWidth = 480
     7  ClientHeight = 354
     8  ClientWidth = 682
    99  DesignTimePPI = 144
    1010  OnClose = FormClose
     
    1515  object ListView1: TListView
    1616    Left = 0
    17     Height = 321
     17    Height = 315
    1818    Top = 0
    19     Width = 480
     19    Width = 682
    2020    Align = alClient
    2121    Columns = <   
     
    3030      item
    3131        Caption = 'Color'
     32        Width = 80
     33      end   
     34      item
     35        Caption = 'Nation'
    3236        Width = 100
    3337      end   
    3438      item
    3539        Caption = 'Start units'
    36         Width = 65
     40        Width = 187
    3741      end>
    3842    MultiSelect = True
     
    5357    Left = 0
    5458    Height = 39
    55     Top = 321
    56     Width = 480
     59    Top = 315
     60    Width = 682
    5761    Align = alBottom
    5862    Images = Core.ImageListSmall
  • trunk/Forms/UFormPlayers.pas

    r279 r282  
    131131    TempEntry.Id := Players.GetNewId;
    132132    TempEntry.Name := SPlayer + ' ' + IntToStr(TempEntry.Id);
    133     TempEntry.Color := PlayerColors[Players.Count];
     133    TempEntry.Nation := Core.Game.GameSystem.Nations.First;
     134    TempEntry.Color := TempEntry.Nation.Color;
    134135    TempEntry.Mode := pmComputer;
    135136    TempEntry.Agressivity := caMedium;
     
    204205    Item.SubItems.Add(PlayerModeText[Mode]);
    205206    Item.SubItems.Add(''); // Do not show color text
     207    if Assigned(Nation) then Item.SubItems.Add(Nation.Name)
     208      else Item.SubItems.Add('');
    206209    Item.SubItems.Add(IntToStr(StartUnits));
    207210  end;
  • trunk/Languages/xtactics.cs.po

    r281 r282  
    678678msgstr "Počátečních jednotek:"
    679679
     680#: tformplayer.label6.caption
     681msgid "Nation:"
     682msgstr ""
     683
    680684#: tformplayers.aadd.caption
    681685msgctxt "tformplayers.aadd.caption"
     
    724728
    725729#: tformplayers.listview1.columns[3].caption
     730#, fuzzy
     731#| msgid "Start units"
    726732msgctxt "tformplayers.listview1.columns[3].caption"
     733msgid "Nation"
     734msgstr "Počátečních jednotek"
     735
     736#: tformplayers.listview1.columns[4].caption
     737#, fuzzy
     738#| msgid "Start units"
     739msgctxt "tformplayers.listview1.columns[4].caption"
    727740msgid "Start units"
    728741msgstr "Počátečních jednotek"
     
    13101323msgid "64-bit UInt read overflow."
    13111324msgstr "Přetečení při čtení 64-bit UInt"
     1325
  • trunk/Languages/xtactics.po

    r281 r282  
    665665msgstr ""
    666666
     667#: tformplayer.label6.caption
     668msgid "Nation:"
     669msgstr ""
     670
    667671#: tformplayers.aadd.caption
    668672msgctxt "tformplayers.aadd.caption"
     
    709713
    710714#: tformplayers.listview1.columns[3].caption
     715msgctxt "tformplayers.listview1.columns[3].caption"
     716msgid "Nation"
     717msgstr ""
     718
     719#: tformplayers.listview1.columns[4].caption
     720msgctxt "tformplayers.listview1.columns[4].caption"
    711721msgid "Start units"
    712722msgstr ""
  • trunk/UCore.pas

    r281 r282  
    99  UGame, UApplicationInfo, UPersistentForm, UScaleDPI, UCoolTranslator,
    1010  URegistry, ULastOpenedList, UTheme, Registry, Menus, UFormClient, UPlayer,
    11   UGameServer, UGameClient, fgl, UServerList, UGameSystem, UUnit;
     11  UGameServer, UGameClient, fgl, UServerList, UGameSystem, UUnit, Graphics;
    1212
    1313type
     
    118118  Core: TCore;
    119119
     120const
     121  clOrange = $009Aff;
     122  clBrown = $a52A2A;
     123
    120124
    121125implementation
     
    517521    PreferedMapType := mtNone;
    518522    MaxPlayerCount := 3;
     523    with Nations.AddNew('Nation 1') do begin
     524      Color := clBlue;
     525    end;
     526    with Nations.AddNew('Nation 2') do begin
     527      Color := clRed;
     528    end;
     529    with Nations.AddNew('Nation 3') do begin
     530      Color := clGreen;
     531    end;
     532    with Nations.AddNew('Nation 4') do begin
     533      Color := clOrange;
     534    end;
     535    with Nations.AddNew('Nation 5') do begin
     536      Color := clPurple;
     537    end;
     538    with Nations.AddNew('Nation 6') do begin
     539      Color := clMaroon;
     540    end;
     541    with Nations.AddNew('Nation 7') do begin
     542      Color := clAqua;
     543    end;
     544    with Nations.AddNew('Nation 8') do begin
     545      Color := clFuchsia;
     546    end;
    519547    with UnitKinds.AddNew('Unit') do begin
    520548      Moves := 1;
     
    525553  with GameSystems.AddNew('HexWars') do begin
    526554    PreferedMapType := mtHexagonVertical;
    527     MaxPlayerCount := 3;
     555    UnitsMoveImmediately := False;
     556    MaxPlayerCount := 8;
     557    with Nations.AddNew('Nation 1') do begin
     558      Color := clBlue;
     559    end;
     560    with Nations.AddNew('Nation 2') do begin
     561      Color := clRed;
     562    end;
     563    with Nations.AddNew('Nation 3') do begin
     564      Color := clGreen;
     565    end;
     566    with Nations.AddNew('Nation 4') do begin
     567      Color := clOrange;
     568    end;
     569    with Nations.AddNew('Nation 5') do begin
     570      Color := clPurple;
     571    end;
     572    with Nations.AddNew('Nation 6') do begin
     573      Color := clMaroon;
     574    end;
     575    with Nations.AddNew('Nation 7') do begin
     576      Color := clAqua;
     577    end;
     578    with Nations.AddNew('Nation 8') do begin
     579      Color := clFuchsia;
     580    end;
    528581    with UnitKinds.AddNew('Unit') do begin
    529582      Moves := 1;
     
    534587  with GameSystems.AddNew('Civilization I') do begin
    535588    PreferedMapType := mtSquare;
     589    UnitsMoveImmediately := True;
     590    MaxPlayerCount := 3;
     591    with Nations.AddNew('Americans') do begin
     592      Color := clFuchsia;
     593    end;
     594    with UnitKinds.AddNew('Scout') do begin
     595      Moves := 1;
     596      Power := 1;
     597    end;
     598    with UnitKinds.AddNew('Settler') do begin
     599      Moves := 1;
     600      Power := 1;
     601    end;
     602  end;
     603
     604  with GameSystems.AddNew('Civilization II') do begin
     605    PreferedMapType := mtIsometric;
     606    UnitsMoveImmediately := True;
    536607    MaxPlayerCount := 3;
    537608    with UnitKinds.AddNew('Scout') do begin
     
    545616  end;
    546617
    547   with GameSystems.AddNew('Civilization II') do begin
     618  with GameSystems.AddNew('Civilization III') do begin
    548619    PreferedMapType := mtIsometric;
     620    UnitsMoveImmediately := True;
    549621    MaxPlayerCount := 3;
    550622    with UnitKinds.AddNew('Scout') do begin
     
    558630  end;
    559631
    560   with GameSystems.AddNew('Civilization III') do begin
     632  with GameSystems.AddNew('Civilization IV') do begin
    561633    PreferedMapType := mtIsometric;
     634    UnitsMoveImmediately := True;
    562635    MaxPlayerCount := 3;
    563636    with UnitKinds.AddNew('Scout') do begin
     
    571644  end;
    572645
    573   with GameSystems.AddNew('Civilization IV') do begin
    574     PreferedMapType := mtIsometric;
     646  with GameSystems.AddNew('Civilization V') do begin
     647    PreferedMapType := mtHexagonHorizontal;
     648    UnitsMoveImmediately := True;
    575649    MaxPlayerCount := 3;
    576650    with UnitKinds.AddNew('Scout') do begin
     
    584658  end;
    585659
    586   with GameSystems.AddNew('Civilization V') do begin
     660  with GameSystems.AddNew('Civilization VI') do begin
    587661    PreferedMapType := mtHexagonHorizontal;
     662    UnitsMoveImmediately := True;
    588663    MaxPlayerCount := 3;
    589664    with UnitKinds.AddNew('Scout') do begin
     
    597672  end;
    598673
    599   with GameSystems.AddNew('Civilization VI') do begin
    600     PreferedMapType := mtHexagonHorizontal;
    601     MaxPlayerCount := 3;
    602     with UnitKinds.AddNew('Scout') do begin
    603       Moves := 1;
    604       Power := 1;
    605     end;
    606     with UnitKinds.AddNew('Settler') do begin
    607       Moves := 1;
    608       Power := 1;
    609     end;
    610   end;
    611 
    612674  with GameSystems.AddNew('Dune 2') do begin
    613675    PreferedMapType := mtSquare;
     676    UnitsMoveImmediately := True;
    614677    MaxPlayerCount := 3;
     678    with Nations.AddNew('Attreides') do begin
     679      Color := clBlue;
     680    end;
     681    with Nations.AddNew('Harkonen') do begin
     682      Color := clRed;
     683    end;
     684    with Nations.AddNew('Ordos') do begin
     685      Color := clGreen;
     686    end;
     687    with Nations.AddNew('Fremens') do begin
     688      Color := clBrown;
     689    end;
     690    with Nations.AddNew('Sardaukers') do begin
     691      Color := clPurple;
     692    end;
     693    with Nations.AddNew('Merceneries') do begin
     694      Color := clOrange;
     695    end;
    615696    with UnitKinds.AddNew('Light Infantry') do begin
    616697      Moves := 1;
     
    629710  with GameSystems.AddNew('Battle Isle 2') do begin
    630711    PreferedMapType := mtHexagonHorizontal;
     712    UnitsMoveImmediately := True;
    631713    MaxPlayerCount := 8;
    632714    with UnitKinds.AddNew('Demon 132') do begin
     
    650732  with GameSystems.AddNew('Panzer General') do begin
    651733    PreferedMapType := mtHexagonHorizontal;
     734    UnitsMoveImmediately := True;
    652735    MaxPlayerCount := 2;
     736    with Nations.AddNew('Germany') do begin
     737      Color := clBlue;
     738    end;
     739    with Nations.AddNew('Russia') do begin
     740      Color := clRed;
     741    end;
     742    with Nations.AddNew('Alliance') do begin
     743      Color := clGreen;
     744    end;
    653745    with UnitKinds.AddNew('Rifle Team') do begin
    654746      Moves := 1;
  • trunk/UGame.pas

    r281 r282  
    118118
    119119const
    120   clOrange = $009Aff;
    121   PlayerColors: array[0..7] of TColor = (clBlue, clRed, clGreen, clOrange,
    122     clPurple, clMaroon, clAqua, clFuchsia);
    123120  ComputerAggroProbability: array[TComputerAgressivity] of Single = (0.9, 0.7, 0.5);
    124121
  • trunk/UGameSystem.pas

    r281 r282  
    77uses
    88  Classes, SysUtils, fgl, UUnit, DOM, XMLRead, XMLWrite, UXMLUtils, XMLConf,
    9   FileUtil, UMapType;
     9  FileUtil, UMapType, UNation;
    1010
    1111type
     
    2222    UnitsMoveImmediately: Boolean;
    2323    PreferedMapType: TMapType;
     24    Nations: TNations;
    2425    constructor Create;
    2526    destructor Destroy; override;
     
    7576begin
    7677  UnitKinds := TUnitKinds.Create;
     78  Nations := TNations.Create;
    7779end;
    7880
    7981destructor TGameSystem.Destroy;
    8082begin
     83  Nations.Free;
    8184  UnitKinds.Free;
    8285  inherited Destroy;
     
    8689begin
    8790  UnitKinds.Clear;
     91  Nations.Clear;
    8892end;
    8993
     
    102106  PreferedMapType := Source.PreferedMapType;
    103107  UnitKinds.Assign(Source.UnitKinds);
     108  Nations.Assign(Source.Nations);
    104109end;
    105110
     
    116121  if Assigned(NewNode) then
    117122    UnitKinds.LoadFromNode(NewNode);
     123  NewNode := Node.FindNode('Nations');
     124  if Assigned(NewNode) then
     125    Nations.LoadFromNode(NewNode);
    118126end;
    119127
     
    130138  Node.AppendChild(NewNode);
    131139  UnitKinds.SaveToNode(NewNode);
     140  NewNode := Node.OwnerDocument.CreateElement('Nations');
     141  Node.AppendChild(NewNode);
     142  Nations.SaveToNode(NewNode);
    132143end;
    133144
  • trunk/UPlayer.pas

    r274 r282  
    77uses
    88  Classes, SysUtils, Graphics, UMap, DOM, fgl, XMLConf, UXMLUtils, Math,
    9   UGeometry, UUnit;
     9  UGeometry, UUnit, UNation;
    1010
    1111type
     
    120120    Moves: TUnitMoves;
    121121    Units: TUnits;
     122    Nation: TNation;
    122123    function IsAllowedMoveTarget(CellFrom, CellTo: TPlayerCell): Boolean;
    123124    procedure ReduceMovesPower;
     
    895896  Agressivity := Source.Agressivity;
    896897  Defensive := Source.Defensive;
     898  Nation := Source.Nation;
    897899end;
    898900
     
    906908    Defensive := GetValue(DOMString(Path + '/Defensive'), False);
    907909    Agressivity := TComputerAgressivity(GetValue(DOMString(Path + '/Agressivity'), 0));
     910    Nation := TGame(Game).GameSystem.Nations.FindById(GetValue(DOMString(Path + '/Nation'), 0));
    908911  end;
    909912end;
     
    918921    SetValue(DOMString(Path + '/Defensive'), Defensive);
    919922    SetValue(DOMString(Path + '/Agressivity'), Integer(Agressivity));
     923    if Assigned(Nation) then
     924      SetValue(DOMString(Path + '/Nation'), Nation.Id)
     925      else SetValue(DOMString(Path + '/Nation'), 0)
    920926  end;
    921927end;
  • trunk/xtactics.lpi

    r279 r282  
    109109      </Item7>
    110110    </RequiredPackages>
    111     <Units Count="41">
     111    <Units Count="42">
    112112      <Unit0>
    113113        <Filename Value="xtactics.lpr"/>
     
    334334        <ResourceBaseClass Value="Form"/>
    335335      </Unit40>
     336      <Unit41>
     337        <Filename Value="UNation.pas"/>
     338        <IsPartOfProject Value="True"/>
     339      </Unit41>
    336340    </Units>
    337341  </ProjectOptions>
Note: See TracChangeset for help on using the changeset viewer.