Changeset 270 for trunk/Forms


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/Forms
Files:
2 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
Note: See TracChangeset for help on using the changeset viewer.