Changeset 11 for trunk/Forms


Ignore:
Timestamp:
Oct 4, 2019, 11:57:05 PM (5 years ago)
Author:
chronos
Message:
  • Added: Configurable speed of animations.
Location:
trunk/Forms
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.lfm

    r8 r11  
    2020      Caption = 'Game'
    2121      object MenuItemNew: TMenuItem
    22         Action = AGameNew
     22        Action = Core.AGameNew
     23      end
     24      object MenuItem1: TMenuItem
     25        Action = Core.ASettings
    2326      end
    2427      object MenuItemExit: TMenuItem
    25         Action = AExit
     28        Action = Core.AExit
    2629      end
    2730    end
     
    2932      Caption = 'Help'
    3033      object MenuItemAbout: TMenuItem
    31         Action = AAbout
     34        Action = Core.AAbout
    3235      end
    3336    end
    3437  end
    35   object ActionList1: TActionList
    36     left = 144
     38  object TimerDraw: TTimer
     39    Interval = 20
     40    OnTimer = TimerDrawTimer
     41    left = 138
    3742    top = 152
    38     object AGameNew: TAction
    39       Caption = 'New...'
    40       OnExecute = AGameNewExecute
    41     end
    42     object AExit: TAction
    43       Caption = 'Exit'
    44       OnExecute = AExitExecute
    45     end
    46     object AAbout: TAction
    47       Caption = 'About'
    48       OnExecute = AAboutExecute
    49     end
    5043  end
    5144end
  • trunk/Forms/UFormMain.lrj

    r8 r11  
    22{"hash":128377605,"name":"tformmain.caption","sourcebytes":[50,48,52,56,32,103,97,109,101],"value":"2048 game"},
    33{"hash":317493,"name":"tformmain.menuitemgame.caption","sourcebytes":[71,97,109,101],"value":"Game"},
    4 {"hash":322608,"name":"tformmain.menuitemhelp.caption","sourcebytes":[72,101,108,112],"value":"Help"},
    5 {"hash":88908046,"name":"tformmain.agamenew.caption","sourcebytes":[78,101,119,46,46,46],"value":"New..."},
    6 {"hash":315140,"name":"tformmain.aexit.caption","sourcebytes":[69,120,105,116],"value":"Exit"},
    7 {"hash":4691652,"name":"tformmain.aabout.caption","sourcebytes":[65,98,111,117,116],"value":"About"}
     4{"hash":322608,"name":"tformmain.menuitemhelp.caption","sourcebytes":[72,101,108,112],"value":"Help"}
    85]}
  • trunk/Forms/UFormMain.pas

    r10 r11  
    1414
    1515  TFormMain = class(TForm)
    16     AAbout: TAction;
    17     AExit: TAction;
    18     AGameNew: TAction;
    19     ActionList1: TActionList;
    2016    MainMenu1: TMainMenu;
     17    MenuItem1: TMenuItem;
    2118    MenuItemNew: TMenuItem;
    2219    MenuItemExit: TMenuItem;
     
    2421    MenuItemAbout: TMenuItem;
    2522    MenuItemGame: TMenuItem;
    26     procedure AAboutExecute(Sender: TObject);
    27     procedure AExitExecute(Sender: TObject);
    28     procedure AGameNewExecute(Sender: TObject);
     23    TimerDraw: TTimer;
    2924    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    3025    procedure FormCreate(Sender: TObject);
     
    3328    procedure FormPaint(Sender: TObject);
    3429    procedure FormShow(Sender: TObject);
     30    procedure TimerDrawTimer(Sender: TObject);
    3531  private
     32    RedrawPending: Boolean;
    3633  public
     34    procedure Redraw;
    3735  end;
    3836
     
    4543
    4644uses
    47   UCore, UFormNew, UFormAbout;
     45  UCore;
    4846
    4947{ TFormMain }
     
    5351  MovedCount: Integer;
    5452begin
    55   if Core.Game.Running then begin
     53  if Core.Game.Running and not Core.Game.Moving then begin
    5654    MovedCount := 0;
    5755    case Key of
     
    7270end;
    7371
    74 procedure TFormMain.AGameNewExecute(Sender: TObject);
    75 begin
    76   FormNew := TFormNew.Create(nil);
    77   try
    78     FormNew.Load(Core.Game);
    79     if FormNew.ShowModal = mrOk then begin
    80       FormNew.Save(Core.Game);
    81       Core.Game.New;
    82     end;
    83   finally
    84     FreeAndNil(FormNew);
    85   end;
    86 end;
    87 
    8872procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    8973begin
    9074  Core.PersistentForm1.Save(Self);
    91 end;
    92 
    93 procedure TFormMain.AExitExecute(Sender: TObject);
    94 begin
    95   Close;
    96 end;
    97 
    98 procedure TFormMain.AAboutExecute(Sender: TObject);
    99 begin
    100   FormAbout := TFormAbout.Create(nil);
    101   try
    102     FormAbout.ApplicationInfo := Core.ApplicationInfo1;
    103     FormAbout.ShowModal;
    104   finally
    105     FreeAndNil(FormAbout);
    106   end;
    10775end;
    10876
     
    12290end;
    12391
     92procedure TFormMain.TimerDrawTimer(Sender: TObject);
     93begin
     94  if RedrawPending then begin
     95    RedrawPending := False;
     96    Repaint;
     97  end;
     98end;
     99
     100procedure TFormMain.Redraw;
     101begin
     102  RedrawPending := True;
     103end;
     104
    124105end.
    125106
  • trunk/Forms/UFormSettings.lfm

    r8 r11  
    55  Width = 480
    66  Caption = 'Settings'
     7  ClientHeight = 360
     8  ClientWidth = 480
    79  DesignTimePPI = 144
     10  OnShow = FormShow
    811  LCLVersion = '2.0.2.0'
     12  object Label1: TLabel
     13    Left = 19
     14    Height = 26
     15    Top = 24
     16    Width = 150
     17    Caption = 'Animation speed:'
     18    ParentColor = False
     19  end
     20  object TrackBar1: TTrackBar
     21    Left = 208
     22    Height = 58
     23    Top = 16
     24    Width = 240
     25    Max = 100
     26    Position = 0
     27    Anchors = [akTop, akLeft, akRight]
     28    TabOrder = 0
     29  end
     30  object ButtonOk: TButton
     31    Left = 112
     32    Height = 38
     33    Top = 291
     34    Width = 113
     35    Anchors = [akLeft, akBottom]
     36    Caption = 'OK'
     37    OnClick = ButtonOkClick
     38    TabOrder = 1
     39  end
     40  object ButtonCancel: TButton
     41    Left = 256
     42    Height = 38
     43    Top = 288
     44    Width = 113
     45    Anchors = [akLeft, akBottom]
     46    Caption = 'Cancel'
     47    OnClick = ButtonCancelClick
     48    TabOrder = 2
     49  end
    950end
  • trunk/Forms/UFormSettings.lrj

    r8 r11  
    11{"version":1,"strings":[
    2 {"hash":213582195,"name":"tformsettings.caption","sourcebytes":[83,101,116,116,105,110,103,115],"value":"Settings"}
     2{"hash":213582195,"name":"tformsettings.caption","sourcebytes":[83,101,116,116,105,110,103,115],"value":"Settings"},
     3{"hash":69745274,"name":"tformsettings.label1.caption","sourcebytes":[65,110,105,109,97,116,105,111,110,32,115,112,101,101,100,58],"value":"Animation speed:"},
     4{"hash":1339,"name":"tformsettings.buttonok.caption","sourcebytes":[79,75],"value":"OK"},
     5{"hash":77089212,"name":"tformsettings.buttoncancel.caption","sourcebytes":[67,97,110,99,101,108],"value":"Cancel"}
    36]}
  • trunk/Forms/UFormSettings.pas

    r8 r11  
    66
    77uses
    8   Classes, SysUtils, Forms, Controls, Graphics, Dialogs;
     8  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls;
    99
    1010type
     11
     12  { TFormSettings }
     13
    1114  TFormSettings = class(TForm)
     15    ButtonOk: TButton;
     16    ButtonCancel: TButton;
     17    Label1: TLabel;
     18    TrackBar1: TTrackBar;
     19    procedure ButtonCancelClick(Sender: TObject);
     20    procedure ButtonOkClick(Sender: TObject);
     21    procedure FormShow(Sender: TObject);
    1222  private
    1323
     
    2333{$R *.lfm}
    2434
     35uses
     36  UCore;
     37
     38{ TFormSettings }
     39
     40procedure TFormSettings.ButtonCancelClick(Sender: TObject);
     41begin
     42  Close;
     43end;
     44
     45procedure TFormSettings.ButtonOkClick(Sender: TObject);
     46begin
     47  Core.Game.AnimationDuration := TrackBar1.Position;
     48  Close;
     49end;
     50
     51procedure TFormSettings.FormShow(Sender: TObject);
     52begin
     53  TrackBar1.Position := Core.Game.AnimationDuration;
     54end;
     55
    2556end.
    2657
Note: See TracChangeset for help on using the changeset viewer.