Changeset 2 for trunk


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 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk

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

    r1 r2  
    99      <ResourceType Value="res"/>
    1010      <UseXPManifest Value="True"/>
     11      <XPManifest>
     12        <DpiAware Value="True"/>
     13      </XPManifest>
    1114      <Icon Value="0"/>
    1215    </General>
     
    2730      </Item1>
    2831    </RequiredPackages>
    29     <Units Count="3">
     32    <Units Count="4">
    3033      <Unit0>
    3134        <Filename Value="Game2048.lpr"/>
     
    4346        <IsPartOfProject Value="True"/>
    4447      </Unit2>
     48      <Unit3>
     49        <Filename Value="UFormNew.pas"/>
     50        <IsPartOfProject Value="True"/>
     51        <ComponentName Value="FormNew"/>
     52        <ResourceBaseClass Value="Form"/>
     53      </Unit3>
    4554    </Units>
    4655  </ProjectOptions>
  • trunk/Game2048.lpr

    r1 r2  
    88  {$ENDIF}{$ENDIF}
    99  Interfaces, // this includes the LCL widgetset
    10   Forms, UFormMain, UGame
     10  Forms, UFormMain, UGame, UFormNew
    1111  { you can add units after this };
    1212
     
    1717  Application.Initialize;
    1818  Application.CreateForm(TFormMain, FormMain);
     19  Application.CreateForm(TFormNew, FormNew);
    1920  Application.Run;
    2021end.
  • trunk/UFormMain.lfm

    r1 r2  
    66  Caption = '2048 game'
    77  DesignTimePPI = 144
     8  Menu = MainMenu1
     9  OnCreate = FormCreate
     10  OnDestroy = FormDestroy
    811  OnKeyUp = FormKeyUp
    912  OnPaint = FormPaint
    1013  OnShow = FormShow
    1114  LCLVersion = '1.8.4.0'
     15  object MainMenu1: TMainMenu
     16    left = 325
     17    top = 152
     18    object MenuItemGame: TMenuItem
     19      Caption = 'Game'
     20      object MenuItem1: TMenuItem
     21        Action = AGameNew
     22      end
     23    end
     24  end
     25  object ActionList1: TActionList
     26    left = 144
     27    top = 155
     28    object AGameNew: TAction
     29      Caption = 'New...'
     30      OnExecute = AGameNewExecute
     31    end
     32  end
    1233end
  • 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.