Ignore:
Timestamp:
Oct 4, 2014, 11:33:16 PM (10 years ago)
Author:
chronos
Message:
  • Added: New game option "Map shape" which can use image in file as base for map generation. Black color is used as void.
  • Modified: New game dialog restructured to separate player, map and rules settings.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormNew.pas

    r74 r75  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   ComCtrls, Spin, ExtCtrls, ActnList, UGame;
     9  ComCtrls, Spin, ExtCtrls, ActnList, ExtDlgs, Menus, UGame;
    1010
    1111type
     
    1818    APlayerModify: TAction;
    1919    ActionList1: TActionList;
     20    ButtonImageBrowse: TButton;
    2021    ButtonCancel: TButton;
    2122    ButtonOk: TButton;
     
    2324    ButtonPlayerModify: TButton;
    2425    ButtonPlayerRemove: TButton;
     26    CheckBoxCity: TCheckBox;
    2527    CheckBoxSymetricMap: TCheckBox;
    26     CheckBoxCity: TCheckBox;
    2728    CheckBoxVoid: TCheckBox;
    2829    ComboBoxGridType: TComboBox;
     30    ComboBoxMapShape: TComboBox;
    2931    ComboBoxWinObjective: TComboBox;
     32    EditImageFile: TEdit;
    3033    Label1: TLabel;
    3134    Label2: TLabel;
     
    3538    Label6: TLabel;
    3639    Label7: TLabel;
     40    Label8: TLabel;
     41    Label9: TLabel;
    3742    ListView1: TListView;
    38     Panel1: TPanel;
    39     Panel2: TPanel;
     43    MenuItem1: TMenuItem;
     44    MenuItem2: TMenuItem;
     45    MenuItem3: TMenuItem;
     46    OpenPictureDialog1: TOpenPictureDialog;
     47    PageControl1: TPageControl;
     48    PopupMenu1: TPopupMenu;
    4049    RadioGroupGrowAmount: TRadioGroup;
    4150    RadioGroupGrowCells: TRadioGroup;
     
    4655    SpinEditVoidPercent: TSpinEdit;
    4756    Splitter1: TSplitter;
     57    TabSheet1: TTabSheet;
     58    TabSheet2: TTabSheet;
     59    TabSheet3: TTabSheet;
    4860    TrackBarSizeX: TTrackBar;
    4961    TrackBarSizeY: TTrackBar;
     
    5163    procedure APlayerModifyExecute(Sender: TObject);
    5264    procedure APlayerRemoveExecute(Sender: TObject);
     65    procedure ButtonImageBrowseClick(Sender: TObject);
    5366    procedure CheckBoxCityChange(Sender: TObject);
    5467    procedure CheckBoxVoidChange(Sender: TObject);
     68    procedure ComboBoxMapShapeChange(Sender: TObject);
    5569    procedure FormCreate(Sender: TObject);
    5670    procedure FormDestroy(Sender: TObject);
     
    103117  SGrowAmountByOne = 'By one';
    104118  SGrowAmountBySquareRoot = 'By square root';
    105 
     119  SRectangular = 'Rectangular';
     120  SFromImageFile = 'From image file';
    106121
    107122{ TFormNew }
     
    185200    ItemIndex := LastIndex;
    186201  end;
     202  with ComboBoxMapShape do begin
     203    LastIndex := ItemIndex;
     204    Clear;
     205    Items.Add(SRectangular);
     206    Items.Add(SFromImageFile);
     207    ItemIndex := LastIndex;
     208  end;
    187209  with RadioGroupGrowCells do begin
    188210    LastIndex := ItemIndex;
     
    209231  ButtonPlayerAdd.Enabled := Players.Count < MaxPlayerCount;
    210232  APlayerModify.Enabled := Assigned(ListView1.Selected);
     233  EditImageFile.Enabled := ComboBoxMapShape.ItemIndex = Integer(msImage);
     234  ButtonImageBrowse.Enabled := ComboBoxMapShape.ItemIndex = Integer(msImage);
    211235  Translate;
    212236end;
     
    242266begin
    243267  SpinEditVoidPercent.Enabled := CheckBoxVoid.Checked;
     268end;
     269
     270procedure TFormNew.ComboBoxMapShapeChange(Sender: TObject);
     271begin
     272  ReloadView;
    244273end;
    245274
     
    260289    Players.Remove(ListView1.Selected.Data);
    261290    ReloadView;
     291  end;
     292end;
     293
     294procedure TFormNew.ButtonImageBrowseClick(Sender: TObject);
     295begin
     296  OpenPictureDialog1.FileName := EditImageFile.Text;
     297  if OpenPictureDialog1.Execute then begin
     298    EditImageFile.Text := OpenPictureDialog1.FileName;
    262299  end;
    263300end;
     
    309346  ComboBoxWinObjective.ItemIndex := Integer(Game.WinObjective);
    310347  SpinEditNeutralUnits.Value := Game.MaxNeutralUnits;
     348  ComboBoxMapShape.ItemIndex := Integer(Game.Map.Shape);
     349  EditImageFile.Text := Game.MapImageFileName;
    311350end;
    312351
     
    334373  Game.WinObjective := TWinObjective(ComboBoxWinObjective.ItemIndex);
    335374  Game.MaxNeutralUnits := SpinEditNeutralUnits.Value;
     375  Game.Map.Shape := TMapShape(ComboBoxMapShape.ItemIndex);
     376  Game.MapImageFileName := EditImageFile.Text;
    336377end;
    337378
Note: See TracChangeset for help on using the changeset viewer.