Changeset 2 for trunk/UFormMain.pas


Ignore:
Timestamp:
Dec 6, 2018, 10:58:45 PM (6 years ago)
Author:
chronos
Message:
  • Added: New game dialog with setting of game board size.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore set to
      Game2048
      Game2048.lps
      lib
  • trunk/UFormMain.pas

    r1 r2  
    66
    77uses
    8   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, UGame;
     8  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
     9  ActnList, UGame;
    910
    1011type
     
    1314
    1415  TFormMain = class(TForm)
     16    AGameNew: TAction;
     17    ActionList1: TActionList;
     18    MainMenu1: TMainMenu;
     19    MenuItem1: TMenuItem;
     20    MenuItemGame: TMenuItem;
     21    procedure AGameNewExecute(Sender: TObject);
     22    procedure FormCreate(Sender: TObject);
     23    procedure FormDestroy(Sender: TObject);
    1524    procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
    1625    procedure FormPaint(Sender: TObject);
     
    2938
    3039{$R *.lfm}
     40
     41uses
     42  UFormNew;
    3143
    3244{ TFormMain }
     
    5062end;
    5163
     64procedure TFormMain.AGameNewExecute(Sender: TObject);
     65begin
     66  FormNew.Load(Game);
     67  if FormNew.ShowModal = mrOk then begin
     68    FormNew.Save(Game);
     69    Game.New;
     70  end;
     71end;
     72
     73procedure TFormMain.FormCreate(Sender: TObject);
     74begin
     75  Randomize;
     76  Game := TGame.Create;
     77  Game.Size := Point(4, 4);
     78  Game.OnChange := GameChange;
     79end;
     80
     81procedure TFormMain.FormDestroy(Sender: TObject);
     82begin
     83  Game.Free;
     84end;
     85
    5286procedure TFormMain.FormPaint(Sender: TObject);
    5387begin
     
    5791procedure TFormMain.FormShow(Sender: TObject);
    5892begin
    59   Randomize;
    60   Game := TGame.Create;
    61   Game.Size := Point(3, 3);
    62   Game.OnChange := GameChange;
    6393  Game.New;
    64 
    6594  {
    6695  Game.Cells[0, 0].Value := 1;
Note: See TracChangeset for help on using the changeset viewer.