Changeset 270 for trunk


Ignore:
Timestamp:
Jan 28, 2019, 10:38:17 PM (6 years ago)
Author:
chronos
Message:
  • Modified: Keep randseed for randomly generated map preview inside New game form.
  • Modified: Resize map preview with form resize.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormNew.lfm

    r269 r270  
    518518          Top = 272
    519519          Width = 359
     520          Anchors = [akTop, akLeft, akRight]
     521          OnResize = Image1Resize
    520522        end
    521523        object Label15: TLabel
     
    523525          Height = 26
    524526          Top = 240
    525           Width = 147
    526           Caption = 'Random preview:'
    527           ParentColor = False
     527          Width = 71
     528          Caption = 'Preview:'
     529          ParentColor = False
     530        end
     531        object ButtonRandomize: TButton
     532          Left = 10
     533          Height = 38
     534          Top = 540
     535          Width = 153
     536          Caption = 'Randomize'
     537          OnClick = ButtonRandomizeClick
     538          TabOrder = 17
    528539        end
    529540      end
  • trunk/Forms/UFormNew.pas

    r269 r270  
    2525    Button2: TButton;
    2626    Button3: TButton;
     27    ButtonRandomize: TButton;
    2728    ButtonCancel: TButton;
    2829    ButtonImageBrowse: TButton;
     
    115116    procedure AServerRemoveExecute(Sender: TObject);
    116117    procedure ButtonImageBrowseClick(Sender: TObject);
     118    procedure ButtonRandomizeClick(Sender: TObject);
    117119    procedure CheckBoxBridgesChange(Sender: TObject);
    118120    procedure CheckBoxCityChange(Sender: TObject);
     
    128130    procedure FormDestroy(Sender: TObject);
    129131    procedure FormShow(Sender: TObject);
     132    procedure Image1Resize(Sender: TObject);
    130133    procedure ListViewPlayersCustomDrawSubItem(Sender: TCustomListView;
    131134      Item: TListItem; SubItem: Integer; State: TCustomDrawState;
     
    159162    GamePreview: TGame;
    160163    MapPreviewRedrawPending: Boolean;
     164    NewRandSeed: Cardinal;
    161165    procedure LoadGame(Game: TGame);
    162166    procedure SaveGame(Game: TGame);
     
    363367  Game.Players.Assign(Players);
    364368  with Game do begin
     369    StoredRandSeed := NewRandSeed;
    365370    SymetricMap := CheckBoxSymetricMap.Checked;
    366371    CyclicMap := CheckBoxCyclicMap.Checked;
     
    397402  Bitmap: TBitmap;
    398403begin
     404  Image1.Height := Round(Image1.Width * SpinEditMapSizeY.Value / SpinEditMapSizeX.Value);
    399405  GamePreview.GameSystem := Core.GameSystems.First;
    400406  SaveGame(GamePreview);
     
    508514procedure TFormNew.FormShow(Sender: TObject);
    509515begin
     516  Randomize;
     517  NewRandSeed := RandSeed;
    510518  Core.PersistentForm.Load(Self);
    511519  Core.ThemeManager1.UseTheme(Self);
     
    517525  TabSheetMode.Enabled := False;
    518526  {$ENDIF}
     527end;
     528
     529procedure TFormNew.Image1Resize(Sender: TObject);
     530begin
     531  MapPreviewRedraw;
    519532end;
    520533
     
    667680    EditImageFile.Text := OpenPictureDialog1.FileName;
    668681  end;
     682end;
     683
     684procedure TFormNew.ButtonRandomizeClick(Sender: TObject);
     685begin
     686  Randomize;
     687  NewRandSeed := RandSeed;
     688  MapPreviewRedraw;
    669689end;
    670690
  • trunk/Languages/xtactics.cs.po

    r269 r270  
    397397msgstr "Ok"
    398398
     399#: tformnew.buttonrandomize.caption
     400msgid "Randomize"
     401msgstr "Náhodně"
     402
    399403#: tformnew.caption
    400404msgctxt "tformnew.caption"
     
    459463
    460464#: tformnew.label15.caption
    461 msgid "Random preview:"
    462 msgstr "Náhodný náhled:"
     465msgid "Preview:"
     466msgstr "Náhled:"
    463467
    464468#: tformnew.label2.caption
  • trunk/Languages/xtactics.po

    r269 r270  
    384384msgstr ""
    385385
     386#: tformnew.buttonrandomize.caption
     387msgid "Randomize"
     388msgstr ""
     389
    386390#: tformnew.caption
    387391msgctxt "tformnew.caption"
     
    445449
    446450#: tformnew.label15.caption
    447 msgid "Random preview:"
     451msgid "Preview:"
    448452msgstr ""
    449453
  • trunk/UClientGUI.pas

    r269 r270  
    169169      Pen.Color := clBlack;
    170170      Pen.Style := psSolid;
    171       Pen.Width := 3;
     171      Pen.Width := Trunc(5 * View.Zoom);
    172172    end else begin
    173173      // Cannot set clear border as it will display shifted on gtk2
  • trunk/UGame.pas

    r268 r270  
    5353    procedure SetRunning(AValue: Boolean);
    5454    procedure BuildTerrain;
     55    procedure PlaceCities;
    5556    procedure SelectPlayerStartCell(Player: TPlayer);
    5657    procedure CalculatePlayersDistance;
     
    8283    BridgeEnabled: Boolean;
    8384    MaxPower: Integer;
     85    StoredRandSeed: Cardinal;
    8486    procedure PostConfig;
    8587    procedure Assign(Source: TGame);
     
    291293    if (VoidEnabled and (Random < VoidPercentage / 100)) or
    292294    (Map.IsOutsideShape(PosPx)) then Terrain := ttVoid
    293       else begin
    294         if CityEnabled and (Random < CityPercentage / 100) then Terrain := ttCity
    295           else Terrain := ttNormal;
    296       end;
     295      else Terrain := ttNormal;
    297296    if not Assigned(OneUnit) then
    298297      OneUnit := Units.AddNew(GameSystem.UnitKinds[0], Random(MaxNeutralUnits + 1));
    299298    Player := nil;
     299  end;
     300end;
     301
     302procedure TGame.PlaceCities;
     303var
     304  Cell: TCell;
     305begin
     306  for Cell in Map.Cells do
     307  with Cell do begin
     308    if (Terrain = ttNormal) and CityEnabled and (Random < CityPercentage / 100) then
     309      Terrain := ttCity;
    300310  end;
    301311end;
     
    418428procedure TGame.Assign(Source: TGame);
    419429begin
     430  StoredRandSeed := Source.StoredRandSeed;
    420431  DevelMode := Source.DevelMode;
    421432  Players.Assign(Source.Players);
     
    446457begin
    447458  with Config do begin
     459    SetValue(DOMString(Path + '/RandSeed'), Integer(StoredRandSeed));
    448460    SetValue(DOMString(Path + '/GridType'), Integer(MapType));
    449461    SetValue(DOMString(Path + '/MapImage'), DOMString(MapImageFileName));
     
    473485begin
    474486  with Config do begin
     487    StoredRandSeed := GetValue(DOMString(Path + '/RandSeed'), 0);
    475488    MapType := TMapType(GetValue(DOMString(Path + '/GridType'), Integer(mtHexagon)));
    476489    Map.Size := TPoint.Create(GetValue(DOMString(Path + '/MapSizeX'), 10),
     
    518531    RootNode := Doc.DocumentElement;
    519532    with RootNode do begin
     533      StoredRandSeed := ReadInteger(RootNode, 'RandSeed', 0);
    520534      MapType := TMapType(ReadInteger(RootNode, 'MapType', Integer(mtNone)));
    521535      SymetricMap := ReadBoolean(RootNode, 'SymetricMap', False);
     
    580594    AppendChild(RootNode);
    581595    with RootNode do begin
     596      WriteInteger(RootNode, 'RandSeed', Integer(StoredRandSeed));
    582597      WriteInteger(RootNode, 'MapType', Integer(MapType));
    583598      WriteBoolean(RootNode, 'SymetricMap', SymetricMap);
     
    825840begin
    826841  Clear;
     842  RandSeed := StoredRandSeed;
    827843  FileName := SNewGameFile;
    828844  TurnCounter := 1;
     
    832848  Map.MaxPower := MaxPower;
    833849  BuildTerrain;
     850  PlaceCities;
    834851  WinObjectiveMapPrepare;
    835852
Note: See TracChangeset for help on using the changeset viewer.