Changeset 401


Ignore:
Timestamp:
Jan 6, 2025, 11:12:12 AM (2 days ago)
Author:
chronos
Message:

Merged revision(s) 396-400 from trunk:

  • Fixed: Charts form chart was not drawn on the initial show.
  • Fixed: Run Randomize only once at startup.
  • Fixed: Store current state of RandSeed to game save.
  • Fixed: Load/store RandSeed as its Cardinal type instead of Integer.
  • Modified: Maximum number of player set to 12.
  • Fixed: Standard yellow color is too bright and not readable with white text. Used darker yellow instead.
  • Fixed: Integrity checks for id references loaded from game file.
  • Fixed: Wrong players and units id recalculation during game save causing bad references.
  • Modified: Set new created players as computer.
  • Fixed: Scale charts line width.
  • Fixed: Item form made bigger to avoid showing scrollbars.
  • Fixed: Item form string control made shorter.
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • tags/1.4.0

  • tags/1.4.0/Core.pas

    r394 r401  
    532532{$ENDIF}
    533533begin
     534  Randomize;
     535
    534536  BaseDir := ExcludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0)));
    535537  GameSystemsDir := CombinePaths(BaseDir, GameSystemsDirName);
  • tags/1.4.0/Forms/FormCharts.pas

    r394 r401  
    5555procedure TFormCharts.FormShow(Sender: TObject);
    5656begin
    57   Redraw;
    5857  Translate;
    5958  if (ComboBox1.ItemIndex = -1) and (ComboBox1.Items.Count > 0) then
    6059    ComboBox1.ItemIndex := 0;
    6160  Chart1.BackColor := ThemeManager.ActualTheme.ColorWindow;
     61  Redraw;
    6262end;
    6363
     
    7373    NewSeries := TLineSeries.Create(nil);
    7474    NewSeries.LinePen.Color := Color;
     75    NewSeries.LinePen.Width := Scale96ToScreen(1);
    7576    for X := 0 to TurnStats.Count - 1 do begin
    7677      if ComboBox1.ItemIndex = 0 then NewSeries.AddXY(X, TurnStats[X].OccupiedCells)
  • tags/1.4.0/Forms/FormNew.pas

    r394 r401  
    498498procedure TFormNew.FormShow(Sender: TObject);
    499499begin
    500   Randomize;
    501500  NewRandSeed := RandSeed;
    502501  ReloadView;
     
    659658procedure TFormNew.ButtonRandomizeClick(Sender: TObject);
    660659begin
    661   Randomize;
    662660  NewRandSeed := RandSeed;
    663661  MapPreviewRedraw;
  • tags/1.4.0/Game.pas

    r377 r401  
    1111  DefaultPlayerStartUnits = 5;
    1212  MinPlayerCount = 1;
    13   MaxPlayerCount = 8;
     13  MaxPlayerCount = 12;
    1414  GameFileExt = '.xtg';
    1515
     
    529529begin
    530530  with Config do begin
    531     SetValue(DOMString(Path + '/RandSeed'), Integer(StoredRandSeed));
     531    SetValue(DOMString(Path + '/RandSeed'), DOMString(IntToStr(StoredRandSeed)));
    532532    SetValue(DOMString(Path + '/GridType'), Integer(MapType));
    533533    SetValue(DOMString(Path + '/MapImage'), DOMString(MapImageFileName));
     
    558558var
    559559  Value: Integer;
     560  ValueInt64: Int64;
    560561begin
    561562  with Config do begin
    562     StoredRandSeed := GetValue(DOMString(Path + '/RandSeed'), 0);
    563     MapType := TMapType(GetValue(DOMString(Path + '/GridType'), Integer(mtHexagonVertical)));
    564     Map.Size := TPoint.Create(GetValue(DOMString(Path + '/MapSizeX'), 10),
    565       GetValue(DOMString(Path + '/MapSizeY'), 10));
     563    if TryStrToInt64(string(GetValue(DOMString(Path + '/RandSeed'), DOMString(IntToStr(StoredRandSeed)))), ValueInt64) then
     564      StoredRandSeed := ValueInt64;
     565    MapType := TMapType(GetValue(DOMString(Path + '/GridType'), Integer(MapType)));
     566    Map.Size := TPoint.Create(GetValue(DOMString(Path + '/MapSizeX'), Map.Size.X),
     567      GetValue(DOMString(Path + '/MapSizeY'), Map.Size.Y));
    566568    MapImageFileName := string(GetValue(DOMString(Path + '/MapImage'), DOMString(MapImageFileName)));
    567     SymetricMap := GetValue(DOMString(Path + '/SymetricMap'), False);
    568     CyclicMap := GetValue(DOMString(Path + '/CyclicMap'), False);
    569     FogOfWar := GetValue(DOMString(Path + '/FogOfWar'), False);
    570     VoidEnabled := GetValue(DOMString(Path + '/VoidEnabled'), True);
    571     VoidPercentage := GetValue(DOMString(Path + '/VoidPercentage'), 20);
    572     Value := GetValue(DOMString(Path + '/MapShape'), 0);
     569    SymetricMap := GetValue(DOMString(Path + '/SymetricMap'), SymetricMap);
     570    CyclicMap := GetValue(DOMString(Path + '/CyclicMap'), CyclicMap);
     571    FogOfWar := GetValue(DOMString(Path + '/FogOfWar'), FogOfWar);
     572    VoidEnabled := GetValue(DOMString(Path + '/VoidEnabled'), VoidEnabled);
     573    VoidPercentage := GetValue(DOMString(Path + '/VoidPercentage'), VoidPercentage);
     574    Value := GetValue(DOMString(Path + '/MapShape'), Integer(Map.Shape));
    573575    if (Value >= Integer(Low(TMapShape))) and (Value <= Integer(High(TMapShape))) then
    574576      Map.Shape := TMapShape(Value) else Map.Shape := Low(TMapShape);
    575     CityEnabled := GetValue(DOMString(Path + '/CityEnabled'), False);
    576     CityPercentage := GetValue(DOMString(Path + '/CityPercentage'), 10);
    577     BridgeEnabled := GetValue(DOMString(Path + '/BridgeEnabled'), True);
    578     Value := GetValue(DOMString(Path + '/GrowAmount'), Integer(gaBySquareRoot));
     577    CityEnabled := GetValue(DOMString(Path + '/CityEnabled'), CityEnabled);
     578    CityPercentage := GetValue(DOMString(Path + '/CityPercentage'), CityPercentage);
     579    BridgeEnabled := GetValue(DOMString(Path + '/BridgeEnabled'), BridgeEnabled);
     580    Value := GetValue(DOMString(Path + '/GrowAmount'), Integer(GrowAmount));
    579581    if (Value >= Integer(Low(TGrowAmount))) and (Value <= Integer(High(TGrowAmount))) then
    580582      GrowAmount := TGrowAmount(Value) else GrowAmount := Low(TGrowAmount);
    581     Value := GetValue(DOMString(Path + '/GrowCells'), Integer(gcPlayerAll));
     583    Value := GetValue(DOMString(Path + '/GrowCells'), Integer(GrowCells));
    582584    if (Value >= Integer(Low(TGrowCells))) and (Value <= Integer(High(TGrowCells))) then
    583585      GrowCells := TGrowCells(Value) else GrowCells := Low(TGrowCells);
    584     Value := GetValue(DOMString(Path + '/WinObjective'), Integer(woDefeatAllOponents));
     586    Value := GetValue(DOMString(Path + '/WinObjective'), Integer(WinObjective));
    585587    if (Value >= Integer(Low(TWinObjective))) and (Value <= Integer(High(TWinObjective))) then
    586588      WinObjective := TWinObjective(Value) else WinObjective := Low(TWinObjective);
    587     StayAliveForDefinedTurns := GetValue(DOMString(Path + '/StayAliveForDefinedTurns'), 20);
    588     SpecialCaptureCellCount := GetValue(DOMString(Path + '/SpecialCaptureCellCount'), 1);
    589     MaxNeutralUnits := GetValue(DOMString(Path + '/MaxNeutralUnits'), 5);
    590     MaxPower := GetValue(DOMString(Path + '/MaxPower'), 99);
     589    StayAliveForDefinedTurns := GetValue(DOMString(Path + '/StayAliveForDefinedTurns'), StayAliveForDefinedTurns);
     590    SpecialCaptureCellCount := GetValue(DOMString(Path + '/SpecialCaptureCellCount'), SpecialCaptureCellCount);
     591    MaxNeutralUnits := GetValue(DOMString(Path + '/MaxNeutralUnits'), MaxNeutralUnits);
     592    MaxPower := GetValue(DOMString(Path + '/MaxPower'), MaxPower);
    591593    Players.LoadConfig(Config, Path + '/Players');
    592594  end;
     
    608610    RootNode := Doc.DocumentElement;
    609611    with RootNode do begin
    610       StoredRandSeed := ReadInteger(RootNode, 'RandSeed', 0);
     612      StoredRandSeed := ReadInt64(RootNode, 'RandSeed', 0);
    611613      MapType := TMapType(ReadInteger(RootNode, 'MapType', Integer(mtNone)));
    612614      SymetricMap := ReadBoolean(RootNode, 'SymetricMap', False);
     
    672674    AppendChild(RootNode);
    673675    with RootNode do begin
    674       WriteInteger(RootNode, 'RandSeed', Integer(StoredRandSeed));
     676      StoredRandSeed := RandSeed;
     677      WriteInt64(RootNode, 'RandSeed', StoredRandSeed);
    675678      WriteInteger(RootNode, 'MapType', Integer(MapType));
    676679      WriteBoolean(RootNode, 'SymetricMap', SymetricMap);
     
    691694      WriteBoolean(RootNode, 'Running', Running);
    692695      WriteInteger(RootNode, 'CurrentPlayer', CurrentPlayer.Id);
     696
     697      Units.RecalculateItemsId;
     698      Players.RecalculateItemsId;
    693699
    694700      NewNode := OwnerDocument.CreateElement('GameSystem');
     
    910916
    911917  GeneratePlayers := True;
     918  StoredRandSeed := RandSeed;
    912919  MapImageFileName := '';
    913   Randomize;
    914   StoredRandSeed := RandSeed;
    915   InitDefaultPlayers;
    916 
     920  MapType := mtHexagonVertical;
     921  Map.Size := TPoint.Create(10, 10);
     922
     923  CityPercentage := 20;
    917924  VoidEnabled := True;
    918925  VoidPercentage := 20;
    919926  MaxPower := DefaultMaxPower;
    920927  MaxNeutralUnits := Min(4, MaxPower);
    921 
    922   Map.Size := TPoint.Create(3, 3);
     928  BridgeEnabled := True;
     929  MaxNeutralUnits := 5;
     930  MaxPower := 99;
     931  SpecialCaptureCellCount := 1;
     932  StayAliveForDefinedTurns := 20;
     933  WinObjective := woDefeatAllOponents;
     934  GrowCells := gcPlayerAll;
     935  GrowAmount := gaBySquareRoot;
     936
     937  InitDefaultPlayers;
    923938end;
    924939
  • tags/1.4.0/Install/flatpak/net.zdechov.app.xTactics.yml

    r395 r401  
    2727      - type: svn
    2828        url: https://svn.zdechov.net/xtactics/tags/1.4.0
    29         revision: r395
     29        revision: r401
    3030    buildsystem: simple
    3131    build-commands:
  • tags/1.4.0/Map.pas

    r376 r401  
    10581058  Cell: TCell;
    10591059begin
    1060   Player := TGame(Map.Game).Players.FindById(PlayerId);
    1061   OneUnit := TGame(Map.Game).Units.FindById(OneUnitId);
     1060  if PlayerId <> 0 then begin
     1061    Player := TGame(Map.Game).Players.FindById(PlayerId);
     1062    if not Assigned(Player) then
     1063      raise Exception.Create('Referenced player id ' + IntToStr(PlayerId) + ' not found.');
     1064  end else Player := nil;
     1065
     1066  if OneUnitId <> 0 then begin
     1067    OneUnit := TGame(Map.Game).Units.FindById(OneUnitId);
     1068    if not Assigned(OneUnit) then
     1069      raise Exception.Create('Referenced unit id ' + IntToStr(OneUnitId) + ' not found.');
     1070  end else OneUnit := nil;
    10621071
    10631072  Neighbors.Count := Length(NeighborsId);
  • tags/1.4.0/Packages/Common/Forms/FormItem.lfm

    r365 r401  
    11object FormItem: TFormItem
    2   Left = 1040
    3   Height = 397
    4   Top = 540
    5   Width = 469
     2  Left = 441
     3  Height = 446
     4  Top = 395
     5  Width = 577
    66  Caption = 'Item'
    7   ClientHeight = 397
    8   ClientWidth = 469
     7  ClientHeight = 446
     8  ClientWidth = 577
    99  DesignTimePPI = 144
    1010  OnCreate = FormCreate
     
    1212  LCLVersion = '3.6.0.0'
    1313  object ButtonOk: TButton
    14     Left = 224
     14    Left = 332
    1515    Height = 38
    16     Top = 353
     16    Top = 402
    1717    Width = 113
    1818    Anchors = [akRight, akBottom]
     
    2424  end
    2525  object ButtonCancel: TButton
    26     Left = 348
     26    Left = 456
    2727    Height = 38
    28     Top = 353
     28    Top = 402
    2929    Width = 113
    3030    Anchors = [akRight, akBottom]
     
    3636  object ScrollBox1: TScrollBox
    3737    Left = 8
    38     Height = 334
     38    Height = 383
    3939    Top = 8
    40     Width = 453
     40    Width = 561
    4141    HorzScrollBar.Page = 1
    4242    VertScrollBar.Page = 1
  • tags/1.4.0/Packages/Common/Forms/FormItem.pas

    r355 r401  
    176176    if DataType = dtString then begin
    177177      NewControl := TEdit.Create(nil);
    178       NewControl.Width := Scale96ToScreen(300);
     178      NewControl.Width := Scale96ToScreen(200);
    179179    end else
    180180    if DataType = dtColor then begin
  • tags/1.4.0/Packages/Common/ItemList.pas

    r394 r401  
    133133    FBaseItemList: TBaseItemList;
    134134    procedure RecalculateNewId(Reset: Boolean);
    135     procedure RecalculateItemsId;
    136135    function BaseGetItem(Index: SizeInt): TItem;
    137136    procedure BaseSetItem(Index: SizeInt; AValue: TItem);
     
    145144  public
    146145    NewId: Integer;
     146    procedure RecalculateItemsId;
    147147    function CreateItem(Name: string = ''): T; virtual;
    148148    function IncrementName(Name: string): string;
     
    265265  NewNode2: TDOMNode;
    266266begin
    267   RecalculateItemsId;
    268267  for I := 0 to Count - 1 do
    269268  with TItem(Items[I]) do begin
  • tags/1.4.0/Player.pas

    r394 r401  
    209209
    210210const
    211   PlayerColors: array[0..11] of TColor = (clBlue, clRed, clGreen, clYellow,
     211  clDarkYellow = $00C0C0;
     212  PlayerColors: array[0..11] of TColor = (clBlue, clRed, clGreen, clDarkYellow,
    212213    clFuchsia, clAqua, clOlive, clMaroon, clNavy, clPurple, clTeal, clGray);
    213214
     
    557558  Result := inherited;
    558559  Result.Game := Game;
     560  Result.Mode := pmComputer;
     561  Result.Agressivity := caMedium;
    559562  Result.Color := GetUnusedColor;
    560563end;
  • tags/1.4.0/Release notes.txt

    r394 r401  
    22==========================
    33
    4 * Added: Application icon with 256x256 resolution.
     4* Added: Added vector logo and generated raster logo with resolution 256x256.
    55* Added: Close button on more forms for better touch screen devices support.
    66* Added: Game systems action in Tools menu.
     
    2525* Modified: Do not paint new game preview bellow form height.
    2626* Modified: Automatically save running game on application exit and reopen it on next start.
    27 * Modified: Automatic map zoom on new game.
    2827* Modified: Show icons in shortcuts window.
    2928* Modified: Improved dark theme support on Windows.
     
    3130* Modified: Allow to set nation in player settings.
    3231* Modified: Allow to have only one player in the game.
     32* Modified: Set new created players as computer.
     33* Modified: Maximum number of player set to 12.
     34* Modified: Do not zoom all on new game start and game load from file.
     35* Modified: Allow to resize new game, settings and game system forms to be smaller with scroll box area.
     36* Modified: Use new higher resolution application image in about dialog.
    3337* Fixed: Initialization of preset World image map.
    3438* Fixed: Map image was not always loaded and applied.
     
    5256* Fixed: Selection of unit moves.
    5357* Fixed: Full screen mode under Windows and Linux.
     58* Fixed: Scale charts line width.
     59* Fixed: Item form made bigger to avoid showing scrollbars.
     60* Fixed: Item form string control made shorter.
     61* Fixed: Wrong players and units id recalculation during game save causing bad references.
     62* Fixed: Integrity checks for id references loaded from game file.
     63* Fixed: Run Randomize only once at startup.
     64* Fixed: Store current state of RandSeed to game save.
     65* Fixed: Load/store RandSeed as its Cardinal type instead of Integer.
     66* Fixed: Charts form chart was not drawn on the initial show.
     67* Fixed: Themed background in New game form rules win conditions.
     68* Fixed: Apply theme to chart background.
     69* Fixed: Add new players with different colors.
    5470
    5571Version 1.3.0 (2018-09-22)
  • tags/1.4.0/Units.pas

    r376 r401  
    114114  NewNode2: TDOMNode;
    115115begin
    116   RecalculateItemsId;
    117116  for I := 0 to Count - 1 do
    118117  with Items[I] do begin
     
    188187procedure TUnit.FixRefId;
    189188begin
    190   Player := TGame(Game).Players.FindById(PlayerId);
    191   Kind := TGame(Game).GameSystem.UnitKinds.FindById(KindId);
     189  if PlayerId <> 0 then begin
     190    Player := TGame(Game).Players.FindById(PlayerId);
     191    if not Assigned(Player) then
     192      raise Exception.Create('Referenced player id ' + IntToStr(PlayerId) + ' not found.');
     193  end else Player := nil;
     194
     195  if KindId <> 0 then begin
     196    Kind := TGame(Game).GameSystem.UnitKinds.FindById(KindId);
     197    if not Assigned(Kind) then
     198      raise Exception.Create('Referenced unit kind id ' + IntToStr(KindId) + ' not found.');
     199  end else Kind := nil;
    192200end;
    193201
  • trunk/Forms/FormCharts.lfm

    r364 r401  
    4141  object ComboBox1: TComboBox
    4242    Left = 29
    43     Height = 38
     43    Height = 33
    4444    Top = 10
    4545    Width = 470
    46     ItemHeight = 0
     46    ItemHeight = 25
    4747    ItemIndex = 0
    4848    Items.Strings = (
  • trunk/Install/flatpak/net.zdechov.app.xTactics.yml

    r395 r401  
    2727      - type: svn
    2828        url: https://svn.zdechov.net/xtactics/trunk
    29         revision: r395
     29        revision: r401
    3030    buildsystem: simple
    3131    build-commands:
  • trunk/Languages/xtactics.cs.po

    r362 r401  
    12571257msgid "View range"
    12581258msgstr "Dohled"
     1259
  • trunk/Release notes.txt

    r389 r401  
    22==========================
    33
    4 * Added: Application icon with 256x256 resolution.
     4* Added: Added vector logo and generated raster logo with resolution 256x256.
    55* Added: Close button on more forms for better touch screen devices support.
    66* Added: Game systems action in Tools menu.
     
    2525* Modified: Do not paint new game preview bellow form height.
    2626* Modified: Automatically save running game on application exit and reopen it on next start.
    27 * Modified: Automatic map zoom on new game.
    2827* Modified: Show icons in shortcuts window.
    2928* Modified: Improved dark theme support on Windows.
     
    3130* Modified: Allow to set nation in player settings.
    3231* Modified: Allow to have only one player in the game.
     32* Modified: Set new created players as computer.
     33* Modified: Maximum number of player set to 12.
     34* Modified: Do not zoom all on new game start and game load from file.
     35* Modified: Allow to resize new game, settings and game system forms to be smaller with scroll box area.
     36* Modified: Use new higher resolution application image in about dialog.
    3337* Fixed: Initialization of preset World image map.
    3438* Fixed: Map image was not always loaded and applied.
     
    5256* Fixed: Selection of unit moves.
    5357* Fixed: Full screen mode under Windows and Linux.
     58* Fixed: Scale charts line width.
     59* Fixed: Item form made bigger to avoid showing scrollbars.
     60* Fixed: Item form string control made shorter.
     61* Fixed: Wrong players and units id recalculation during game save causing bad references.
     62* Fixed: Integrity checks for id references loaded from game file.
     63* Fixed: Run Randomize only once at startup.
     64* Fixed: Store current state of RandSeed to game save.
     65* Fixed: Load/store RandSeed as its Cardinal type instead of Integer.
     66* Fixed: Charts form chart was not drawn on the initial show.
     67* Fixed: Themed background in New game form rules win conditions.
     68* Fixed: Apply theme to chart background.
     69* Fixed: Add new players with different colors.
    5470
    5571Version 1.3.0 (2018-09-22)
Note: See TracChangeset for help on using the changeset viewer.