Changeset 11 for trunk/UCore.pas


Ignore:
Timestamp:
Oct 4, 2019, 11:57:05 PM (5 years ago)
Author:
chronos
Message:
  • Added: Configurable speed of animations.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r10 r11  
    77uses
    88  Classes, SysUtils, UTheme, UPersistentForm, UApplicationInfo, UTranslator,
    9   URegistry, UGame;
     9  URegistry, UGame, ActnList, Forms, Controls;
    1010
    1111type
     
    1414
    1515  TCore = class(TDataModule)
     16    AAbout: TAction;
     17    ASettings: TAction;
     18    ActionList1: TActionList;
     19    AExit: TAction;
     20    AGameNew: TAction;
    1621    ApplicationInfo1: TApplicationInfo;
    1722    PersistentForm1: TPersistentForm;
    1823    ThemeManager1: TThemeManager;
    1924    Translator1: TTranslator;
     25    procedure AAboutExecute(Sender: TObject);
     26    procedure AExitExecute(Sender: TObject);
     27    procedure AGameNewExecute(Sender: TObject);
     28    procedure ASettingsExecute(Sender: TObject);
    2029    procedure DataModuleCreate(Sender: TObject);
    2130    procedure DataModuleDestroy(Sender: TObject);
     
    3645
    3746uses
    38   UFormMain;
     47  UFormMain, UFormSettings, UFormAbout, UFormNew;
    3948
    4049{ TCore }
     
    4958end;
    5059
     60procedure TCore.ASettingsExecute(Sender: TObject);
     61begin
     62  FormSettings := TFormSettings.Create(nil);
     63  try
     64    FormSettings.ShowModal;
     65  finally
     66    FreeAndNil(FormSettings);
     67  end;
     68end;
     69
     70procedure TCore.AAboutExecute(Sender: TObject);
     71begin
     72  FormAbout := TFormAbout.Create(nil);
     73  try
     74    FormAbout.ApplicationInfo := Core.ApplicationInfo1;
     75    FormAbout.ShowModal;
     76  finally
     77    FreeAndNil(FormAbout);
     78  end;
     79end;
     80
     81procedure TCore.AExitExecute(Sender: TObject);
     82begin
     83  FormMain.Close;
     84end;
     85
     86procedure TCore.AGameNewExecute(Sender: TObject);
     87begin
     88  FormNew := TFormNew.Create(nil);
     89  try
     90    FormNew.Load(Core.Game);
     91    if FormNew.ShowModal = mrOk then begin
     92      FormNew.Save(Core.Game);
     93      Game.New;
     94    end;
     95  finally
     96    FreeAndNil(FormNew);
     97  end;
     98end;
     99
    51100procedure TCore.DataModuleDestroy(Sender: TObject);
    52101begin
     
    57106procedure TCore.GameChange(Sender: TObject);
    58107begin
    59   FormMain.Repaint;
     108  FormMain.Redraw;
    60109end;
    61110
     
    67116
    68117    Game.TopScore := ReadIntegerWithDefault('TopScore', 0);
     118    Game.Size := Point(ReadIntegerWithDefault('SizeX', 4), ReadIntegerWithDefault('SizeY', 4));
     119    Game.AnimationDuration := ReadIntegerWithDefault('AnimationDuration', 30);
    69120  finally
    70121    Free;
     
    79130
    80131    WriteInteger('TopScore', Game.TopScore);
     132    WriteInteger('SizeX', Game.Size.X);
     133    WriteInteger('SizeY', Game.Size.Y);
     134    WriteInteger('AnimationDuration', Game.AnimationDuration);
    81135  finally
    82136    Free;
Note: See TracChangeset for help on using the changeset viewer.