Changeset 86


Ignore:
Timestamp:
Jun 7, 2024, 12:47:11 PM (7 months ago)
Author:
chronos
Message:
  • Modified: Remove U prefix from unit names.
  • Modified: Used TFormEx for all forms for code simplification.
  • Fixed: Fullscreen mode switching error.
Location:
trunk
Files:
3 edited
22 moved

Legend:

Unmodified
Added
Removed
  • trunk/Core.lfm

    r85 r86  
    21352135    end
    21362136  end
     2137  object ScaleDPI1: TScaleDPI
     2138    AutoDetect = False
     2139    Left = 120
     2140    Top = 400
     2141  end
    21372142end
  • trunk/Core.pas

    r85 r86  
    1 unit UCore;
    2 
    3 {$mode delphi}
     1unit Core;
    42
    53interface
     
    75uses
    86  Classes, SysUtils, Theme, PersistentForm, ApplicationInfo, Translator,
    9   RegistryEx, UGame, ActnList, Forms, Controls, Dialogs;
     7  RegistryEx, ScaleDPI, Game, ActnList, Forms, Controls, Dialogs;
    108
    119type
     
    2523    ApplicationInfo1: TApplicationInfo;
    2624    PersistentForm1: TPersistentForm;
     25    ScaleDPI1: TScaleDPI;
    2726    ThemeManager1: TThemeManager;
    2827    Translator1: TTranslator;
     
    6160
    6261uses
    63   UFormMain, UFormSettings, UFormNew, UFormHelp, UFormComputer, FormAbout,
    64   UFormHistory;
     62  FormMain, FormSettings, FormNew, FormHelp, FormComputer, FormAbout, FormEx,
     63  FormHistory;
    6564
    6665resourcestring
     
    6968  SWinCaption = 'Win';
    7069  SWinMessage = 'You reached %s and won! You can continue to play to get higher score.';
     70
     71procedure Translate;
     72begin
     73  Game.Translate;
     74end;
    7175
    7276{ TCore }
     
    9094  Game.OnGameOver := GameOver;
    9195  LoadConfig;
     96
     97  TFormEx.ScaleDPI := ScaleDPI1;
     98  TFormEx.Translator := Translator1;
     99  TFormEx.ThemeManager := ThemeManager1;
     100  TFormEx.PersistentForm := PersistentForm1;
    92101end;
    93102
    94103procedure TCore.ASettingsExecute(Sender: TObject);
     104var
     105  FormSettings: TFormSettings;
    95106begin
    96107  FormSettings := TFormSettings.Create(nil);
    97108  try
    98109    if FormSettings.ShowModal = mrOk then begin
    99       FormMain.Redraw;
    100       FormMain.UpdateInterface;
     110      FormMain.FormMain.Redraw;
     111      FormMain.FormMain.UpdateInterface;
    101112      UpdateInterface;
    102113    end;
     
    125136
    126137procedure TCore.AComputerExecute(Sender: TObject);
     138var
     139  FormComputer: TFormComputer;
    127140begin
    128141  FormComputer := TFormComputer.Create(nil);
     
    136149procedure TCore.AExitExecute(Sender: TObject);
    137150begin
    138   FormMain.Close;
     151  FormMain.FormMain.Close;
    139152end;
    140153
    141154procedure TCore.AHelpExecute(Sender: TObject);
     155var
     156  FormHelp: TFormHelp;
    142157begin
    143158  FormHelp := TFormHelp.Create(nil);
     
    150165
    151166procedure TCore.AHistoryExecute(Sender: TObject);
     167var
     168  FormHistory: TFormHistory;
    152169begin
    153170  FormHistory := TFormHistory.Create(nil);
     
    160177
    161178procedure TCore.ANewExecute(Sender: TObject);
     179var
     180  FormNew: TFormNew;
    162181begin
    163182  FormNew := TFormNew.Create(nil);
     
    168187      Game.New;
    169188      UpdateInterface;
    170       FormMain.UpdateInterface;
     189      FormMain.FormMain.UpdateInterface;
    171190    end;
    172191  finally
     
    183202procedure TCore.Translator1Translate(Sender: TObject);
    184203begin
    185   UGame.Translate;
     204  Translate;
    186205end;
    187206
     
    193212procedure TCore.GamePaint(Sender: TObject);
    194213begin
    195   if Assigned(FormMain) then FormMain.Redraw;
     214  if Assigned(FormMain.FormMain) then FormMain.FormMain.Redraw;
    196215end;
    197216
    198217procedure TCore.GameWin(Sender: TObject);
    199218begin
    200   TThread.Synchronize(FormMain.MoveThread, GameWinSync);
     219  TThread.Synchronize(FormMain.FormMain.MoveThread, GameWinSync);
    201220end;
    202221
     
    208227procedure TCore.GameOver(Sender: TObject);
    209228begin
    210   TThread.Synchronize(FormMain.MoveThread, GameOverSync);
     229  TThread.Synchronize(FormMain.FormMain.MoveThread, GameOverSync);
    211230end;
    212231
  • trunk/Forms/FormComputer.lfm

    r85 r86  
    1111  OnCreate = FormCreate
    1212  OnDestroy = FormDestroy
    13   OnShow = FormShow
    14   LCLVersion = '2.0.2.0'
     13  LCLVersion = '3.4.0.0'
    1514  object ButtonStart: TButton
    1615    Left = 40
     
    1918    Width = 113
    2019    Caption = 'Start'
     20    TabOrder = 0
    2121    OnClick = ButtonStartClick
    22     TabOrder = 0
    2322  end
    2423  object ButtonStop: TButton
     
    2928    Caption = 'Stop'
    3029    Enabled = False
     30    TabOrder = 1
    3131    OnClick = ButtonStopClick
    32     TabOrder = 1
    3332  end
    3433  object TrackBar1: TTrackBar
     
    4645    Height = 26
    4746    Top = 76
    48     Width = 127
     47    Width = 126
    4948    Caption = 'Delay per step:'
    5049    ParentColor = False
  • trunk/Forms/FormComputer.pas

    r85 r86  
    1 unit UFormComputer;
    2 
    3 {$mode delphi}
     1unit FormComputer;
    42
    53interface
     
    75uses
    86  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls,
    9   UGame, fgl;
     7  Game, Generics.Collections, Generics.Defaults, FormEx;
    108
    119type
     
    2321  end;
    2422
    25   TGameTries = class(TFPGObjectList<TGameTry>)
     23  TGameTries = class(TObjectList<TGameTry>)
     24  end;
     25
     26  { TGameTryComparer }
     27
     28  TGameTryComparer = class(TInterfacedObject, IComparer<TGameTry>)
     29    function Compare(constref Left, Right: TGameTry): Integer; overload;
    2630  end;
    2731
    2832  { TFormComputer }
    2933
    30   TFormComputer = class(TForm)
     34  TFormComputer = class(TFormEx)
    3135    ButtonStart: TButton;
    3236    ButtonStop: TButton;
     
    3842    procedure FormCreate(Sender: TObject);
    3943    procedure FormDestroy(Sender: TObject);
    40     procedure FormShow(Sender: TObject);
    4144  private
    4245    Stop: Boolean;
     
    4649    GameTries4: TGameTries;
    4750    procedure TryAllDirections(GameTries: TGameTries; GameTry: TGameTry);
    48   public
    49 
    50   end;
    51 
    52 var
    53   FormComputer: TFormComputer;
     51  end;
     52
    5453
    5554implementation
     
    5857
    5958uses
    60   UCore;
     59  Core;
    6160
    6261{ TGameTry }
     
    133132end;
    134133
     134{ TGameTryComparer }
     135
     136function TGameTryComparer.Compare(constref Left, Right: TGameTry): Integer;
     137var
     138  ScoreLeft: Double;
     139  ScoreRight: Double;
     140begin
     141  ScoreLeft := Left.GetFitness;
     142  ScoreRight := Right.GetFitness;
     143  if ScoreLeft > ScoreRight then Result := -1
     144  else if ScoreLeft < ScoreRight then Result := 1
     145  else Result := 0;
     146end;
     147
    135148{ TFormComputer }
    136149
     
    139152begin
    140153  ButtonStopClick(Self);
    141   Core.PersistentForm1.Save(Self);
    142154end;
    143155
     
    161173  J: Integer;
    162174  GameTries: TGameTries;
     175  GameTryComparer: TGameTryComparer;
    163176  Delay: Integer;
    164177begin
     
    166179  ButtonStop.Enabled := True;
    167180  Stop := False;
    168   with Core.Game do begin
     181  with Core.Core.Game do begin
    169182    while CanMove and not Stop do begin
    170183      NewTry := TGameTry.Create;
    171       NewTry.Game.Assign(Core.Game);
     184      NewTry.Game.Assign(Core.Core.Game);
    172185      GameTries1.Clear;
    173186      TryAllDirections(GameTries1, NewTry);
     
    184197
    185198      GameTries := GameTries4;
    186       GameTries.Sort(GameCompareScore);
     199      GameTryComparer := TGameTryComparer.Create;
     200      GameTries.Sort(GameTryComparer);
    187201      S := '';
    188202      for I := 0 to GameTries.Count - 1 do begin
     
    221235procedure TFormComputer.FormCreate(Sender: TObject);
    222236begin
    223   Core.Translator1.TranslateComponentRecursive(Self);
    224   Core.ThemeManager1.UseTheme(Self);
    225237  GameTries1 := TGameTries.Create;
    226238  GameTries2 := TGameTries.Create;
     
    235247  FreeAndNil(GameTries3);
    236248  FreeAndNil(GameTries4);
    237 end;
    238 
    239 procedure TFormComputer.FormShow(Sender: TObject);
    240 begin
    241   Core.PersistentForm1.Load(Self);
    242249end;
    243250
  • trunk/Forms/FormHelp.lfm

    r85 r86  
    88  ClientWidth = 480
    99  DesignTimePPI = 144
    10   OnClose = FormClose
    11   OnCreate = FormCreate
    1210  OnShow = FormShow
    13   LCLVersion = '2.0.2.0'
     11  LCLVersion = '3.4.0.0'
    1412  object Memo1: TMemo
    1513    Left = 8
  • trunk/Forms/FormHelp.pas

    r85 r86  
    1 unit UFormHelp;
    2 
    3 {$mode delphi}
     1unit FormHelp;
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
     6  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, FormEx;
    97
    108type
     
    1210  { TFormHelp }
    1311
    14   TFormHelp = class(TForm)
     12  TFormHelp = class(TFormEx)
    1513    Memo1: TMemo;
    16     procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    17     procedure FormCreate(Sender: TObject);
    1814    procedure FormShow(Sender: TObject);
    19   private
    20 
    21   public
    22 
    2315  end;
    2416
    25 var
    26   FormHelp: TFormHelp;
    2717
    2818implementation
     
    3121
    3222uses
    33   UCore;
     23  Core;
    3424
    3525resourcestring
     
    4232{ TFormHelp }
    4333
    44 procedure TFormHelp.FormCreate(Sender: TObject);
    45 begin
    46   Core.Translator1.TranslateComponentRecursive(Self);
    47   Core.ThemeManager1.UseTheme(Self);
    48 end;
    49 
    50 procedure TFormHelp.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    51 begin
    52   Core.PersistentForm1.Save(Self);
    53 end;
    54 
    5534procedure TFormHelp.FormShow(Sender: TObject);
    5635begin
    57   Core.PersistentForm1.Load(Self);
    5836  Memo1.Text := SParagraph1 + LineEnding +
    5937    SParagraph2 + LineEnding +
  • trunk/Forms/FormHistory.lfm

    r85 r86  
    88  ClientWidth = 480
    99  DesignTimePPI = 144
    10   OnClose = FormClose
    1110  OnCreate = FormCreate
    1211  OnDestroy = FormDestroy
    1312  OnShow = FormShow
    14   LCLVersion = '2.0.2.0'
     13  LCLVersion = '3.4.0.0'
    1514  object PaintBox1: TPaintBox
    1615    Left = 0
     
    4544    Interval = 50
    4645    OnTimer = Timer1Timer
    47     left = 108
    48     top = 123
     46    Left = 108
     47    Top = 123
    4948  end
    5049end
  • trunk/Forms/FormHistory.pas

    r85 r86  
    1 unit UFormHistory;
    2 
    3 {$mode delphi}
     1unit FormHistory;
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ComCtrls, UGame;
     6  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ComCtrls,
     7  Game, FormEx;
    98
    109type
     
    1211  { TFormHistory }
    1312
    14   TFormHistory = class(TForm)
     13  TFormHistory = class(TFormEx)
    1514    PaintBox1: TPaintBox;
    1615    Panel1: TPanel;
    1716    Timer1: TTimer;
    1817    TrackBar1: TTrackBar;
    19     procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    2018    procedure FormCreate(Sender: TObject);
    2119    procedure FormDestroy(Sender: TObject);
     
    3129  end;
    3230
    33 var
    34   FormHistory: TFormHistory;
    3531
    3632implementation
     
    3935
    4036uses
    41   UCore;
     37  Core;
    4238
    4339{ TFormHistory }
     
    4541procedure TFormHistory.FormShow(Sender: TObject);
    4642begin
    47   Core.PersistentForm1.Load(Self);
    48   TrackBar1.Max := Core.Game.History.Moves.Count;
    49   Game.Board.Size := Core.Game.Board.Size;
     43  TrackBar1.Max := Core.Core.Game.History.Moves.Count;
     44  Game.Board.Size := Core.Core.Game.Board.Size;
    5045  Redraw;
    5146end;
     
    5954begin
    6055  if RedrawPending then begin
    61     Core.Game.History.GetStep(Game, TrackBar1.Position);
     56    Core.Core.Game.History.GetStep(Game, TrackBar1.Position);
    6257    PaintBox1.Refresh;
    6358    RedrawPending := False;
     
    7772procedure TFormHistory.FormCreate(Sender: TObject);
    7873begin
    79   Core.Translator1.TranslateComponentRecursive(Self);
    80   Core.ThemeManager1.UseTheme(Self);
    8174  Game := TGame.Create;
    8275end;
     
    8780end;
    8881
    89 procedure TFormHistory.FormClose(Sender: TObject; var CloseAction: TCloseAction
    90   );
    91 begin
    92   Core.PersistentForm1.Save(Self);
    93 end;
    94 
    9582end.
    9683
  • trunk/Forms/FormMain.lfm

    r85 r86  
    1616  OnPaint = FormPaint
    1717  OnShow = FormShow
    18   LCLVersion = '2.0.10.0'
     18  LCLVersion = '3.4.0.0'
    1919  object MainMenu1: TMainMenu
    2020    Left = 328
  • trunk/Forms/FormMain.pas

    r85 r86  
    1 unit UFormMain;
    2 
    3 {$mode delphi}{$H+}
     1unit FormMain;
    42
    53interface
     
    75uses
    86  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus, Math,
    9   ActnList, ExtCtrls, StdCtrls, UGame, PersistentForm, ApplicationInfo,
    10   LCLType, Syncobjs, DateUtils;
     7  ActnList, ExtCtrls, StdCtrls, Game, PersistentForm, ApplicationInfo,
     8  LCLType, Syncobjs, DateUtils, FormEx;
    119
    1210type
     
    2220  { TFormMain }
    2321
    24   TFormMain = class(TForm)
     22  TFormMain = class(TFormEx)
    2523    MainMenu1: TMainMenu;
    2624    MenuItem1: TMenuItem;
     
    7270  FormMain: TFormMain;
    7371
     72
    7473implementation
    7574
     
    7776
    7877uses
    79   UCore;
     78  Core;
    8079
    8180{ TMoveThread }
     
    9897  KeyDown = 40;
    9998begin
    100   if Core.Game.Running then begin
     99  if Core.Core.Game.Running then begin
    101100    case Key of
    102101      KeyLeft: AddToMoveBuffer(drLeft);
     
    162161  TimeStart := Now;
    163162  {$ENDIF}
    164   Core.Game.Render(Canvas, Point(Width, Height - MainMenu1.Height));
     163  Core.Core.Game.Render(Canvas, Point(Width, Height - MainMenu1.Height));
    165164  {$IFDEF DEBUG}
    166165  DrawDuration := Now - TimeStart;
     
    170169procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    171170begin
    172   Core.PersistentForm1.Save(Self);
     171  Core.Core.PersistentForm1.Save(Self);
    173172end;
    174173
    175174procedure TFormMain.FormCreate(Sender: TObject);
    176175begin
    177   Core.Translator1.TranslateComponentRecursive(Self);
    178176  MoveBufferLock := TCriticalSection.Create;
    179177  MoveThread := TMoveThread.Create(True);
     
    192190procedure TFormMain.FormShow(Sender: TObject);
    193191begin
    194   Core.PersistentForm1.RegistryContext := Core.ApplicationInfo1.GetRegistryContext;
    195   Core.PersistentForm1.Load(Self);
    196   FullScreen := Core.PersistentForm1.FormFullScreen;
    197   Core.ThemeManager1.UseTheme(Self);
     192  FullScreen := Core.Core.PersistentForm1.FormFullScreen;
     193
    198194  UpdateInterface;
    199   if Core.Game.Board.GetEmptyTilesCount > Core.Game.Board.Size.X * Core.Game.Board.Size.Y -
     195  if Core.Core.Game.Board.GetEmptyTilesCount > Core.Core.Game.Board.Size.X * Core.Core.Game.Board.Size.Y -
    200196    InitialTileCount then
    201     Core.Game.New;
     197    Core.Core.Game.New;
    202198end;
    203199
     
    236232procedure TFormMain.ProcessMoveBuffer;
    237233begin
    238   if not Core.Game.Moving then begin
     234  if not Core.Core.Game.Moving then begin
    239235    MoveBufferLock.Acquire;
    240236    while Length(MoveBuffer) > 0 do begin
    241237      MoveBufferLock.Release;
    242       Core.Game.MoveAllAndUpdate(MoveBuffer[0], Core.Game.AnimationDuration > 0);
     238      Core.Core.Game.MoveAllAndUpdate(MoveBuffer[0], Core.Core.Game.AnimationDuration > 0);
    243239      MoveBufferLock.Acquire;
    244240      if Length(MoveBuffer) > 1 then
     
    254250begin
    255251  FullScreen := not FullScreen;
    256   Core.PersistentForm1.SetFullScreen(FormMain.FullScreen);
     252  Core.Core.PersistentForm1.SetFullScreen(FormMain.FullScreen);
    257253  UpdateInterface;
    258254end;
     
    269265begin
    270266  MenuItemFullScreen.Checked := FullScreen;
    271   MenuItemMovesHistory.Visible := Core.Game.RecordHistory;
     267  MenuItemMovesHistory.Visible := Core.Core.Game.RecordHistory;
    272268  ToolsVisible := False;
    273269  for I := 0 to MenuItemTools.Count - 1 do
  • trunk/Forms/FormNew.lfm

    r85 r86  
    88  ClientWidth = 501
    99  DesignTimePPI = 144
    10   OnClose = FormClose
    1110  OnCreate = FormCreate
    12   OnShow = FormShow
    13   LCLVersion = '2.0.10.0'
     11  LCLVersion = '3.4.0.0'
    1412  object Label1: TLabel
    1513    Left = 16
    16     Height = 24
     14    Height = 26
    1715    Top = 16
    1816    Width = 93
     
    8078  object Label2: TLabel
    8179    Left = 16
    82     Height = 24
     80    Height = 26
    8381    Top = 125
    8482    Width = 75
     
    8886  object ComboBoxSkin: TComboBox
    8987    Left = 173
    90     Height = 37
     88    Height = 38
    9189    Top = 120
    9290    Width = 262
  • trunk/Forms/FormNew.pas

    r85 r86  
    1 unit UFormNew;
    2 
    3 {$mode delphi}{$H+}
     1unit FormNew;
    42
    53interface
     
    75uses
    86  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   UGame;
     7  Game, FormEx;
    108
    119type
     
    1311  { TFormNew }
    1412
    15   TFormNew = class(TForm)
     13  TFormNew = class(TFormEx)
    1614    ButtonCancel: TButton;
    1715    ButtonOk: TButton;
     
    2220    Label1: TLabel;
    2321    Label2: TLabel;
    24     procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    2522    procedure FormCreate(Sender: TObject);
    26     procedure FormShow(Sender: TObject);
    27   private
    28 
    2923  public
    3024    procedure Load(Game: TGame);
     
    3226  end;
    3327
    34 var
    35   FormNew: TFormNew;
    3628
    3729implementation
     
    4032
    4133uses
    42   UCore;
     34  Core;
    4335
    4436{ TFormNew }
     
    4840  I: TTileSkin;
    4941begin
    50   Core.Translator1.TranslateComponentRecursive(Self);
    51   Core.ThemeManager1.UseTheme(Self);
    5242  ComboBoxSkin.Items.BeginUpdate;
    5343  try
     
    5848    ComboBoxSkin.Items.EndUpdate;
    5949  end;
    60 end;
    61 
    62 procedure TFormNew.FormShow(Sender: TObject);
    63 begin
    64   Core.PersistentForm1.Load(Self);
    65 end;
    66 
    67 procedure TFormNew.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    68 begin
    69   Core.PersistentForm1.Save(Self);
    7050end;
    7151
  • trunk/Forms/FormSettings.lfm

    r85 r86  
    88  ClientWidth = 480
    99  DesignTimePPI = 144
    10   OnClose = FormClose
    1110  OnCreate = FormCreate
    1211  OnShow = FormShow
    13   LCLVersion = '2.0.4.0'
     12  LCLVersion = '3.4.0.0'
    1413  object Label1: TLabel
    1514    Left = 19
    16     Height = 25
     15    Height = 26
    1716    Top = 24
    18     Width = 158
     17    Width = 170
    1918    Caption = 'Animation duration:'
    2019    ParentColor = False
     
    3736    Anchors = [akLeft, akBottom]
    3837    Caption = 'OK'
     38    TabOrder = 1
    3939    OnClick = ButtonOkClick
    40     TabOrder = 1
    4140  end
    4241  object ButtonCancel: TButton
     
    4746    Anchors = [akLeft, akBottom]
    4847    Caption = 'Cancel'
     48    TabOrder = 2
    4949    OnClick = ButtonCancelClick
    50     TabOrder = 2
    5150  end
    5251  object ComboBoxLanguage: TComboBox
    5352    Left = 208
    54     Height = 33
     53    Height = 42
    5554    Top = 86
    5655    Width = 230
    57     ItemHeight = 25
     56    ItemHeight = 0
    5857    Style = csDropDownList
    5958    TabOrder = 3
     
    6160  object Label2: TLabel
    6261    Left = 19
    63     Height = 25
     62    Height = 26
    6463    Top = 94
    65     Width = 81
     64    Width = 88
    6665    Caption = 'Language:'
    6766    ParentColor = False
     
    6968  object ComboBoxTheme: TComboBox
    7069    Left = 208
    71     Height = 33
     70    Height = 42
    7271    Top = 136
    7372    Width = 230
    74     ItemHeight = 25
     73    ItemHeight = 0
    7574    Style = csDropDownList
    7675    TabOrder = 4
     
    7877  object Label3: TLabel
    7978    Left = 19
    80     Height = 25
     79    Height = 26
    8180    Top = 144
    82     Width = 57
     81    Width = 63
    8382    Caption = 'Theme:'
    8483    ParentColor = False
  • trunk/Forms/FormSettings.pas

    r85 r86  
    1 unit UFormSettings;
    2 
    3 {$mode delphi}
     1unit FormSettings;
    42
    53interface
     
    75uses
    86  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls,
    9   Languages, Theme;
     7  Languages, Theme, FormEx;
    108
    119type
     
    1311  { TFormSettings }
    1412
    15   TFormSettings = class(TForm)
     13  TFormSettings = class(TFormEx)
    1614    ButtonOk: TButton;
    1715    ButtonCancel: TButton;
     
    2422    procedure ButtonCancelClick(Sender: TObject);
    2523    procedure ButtonOkClick(Sender: TObject);
    26     procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    2724    procedure FormCreate(Sender: TObject);
    2825    procedure FormShow(Sender: TObject);
    29   private
    30 
    31   public
    32 
    3326  end;
    34 
    35 var
    36   FormSettings: TFormSettings;
    3727
    3828
     
    4232
    4333uses
    44   UCore;
     34  Core;
    4535
    4636resourcestring
    4737  SLanguageChangeTitle = 'Language change';
    4838  SLanguageChangeMessage = 'Interface language was changed. It may require restart of application.';
    49 
    5039
    5140{ TFormSettings }
     
    5847procedure TFormSettings.ButtonOkClick(Sender: TObject);
    5948begin
    60   Core.Game.AnimationDuration := TrackBar1.Position;
     49  Core.Core.Game.AnimationDuration := TrackBar1.Position;
    6150  if ComboBoxLanguage.ItemIndex <> -1 then begin
    62     if (Core.Translator1.Language <> TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex])) then
     51    if (Core.Core.Translator1.Language <> TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex])) then
    6352      MessageDlg(SLanguageChangeTitle, SLanguageChangeMessage, mtInformation, [mbOk], 0);
    64     Core.Translator1.Language := TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex]);
     53    Core.Core.Translator1.Language := TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex]);
    6554  end;
    6655  if ComboBoxTheme.ItemIndex <> -1 then
    67     Core.ThemeManager1.Theme := TTheme(ComboBoxTheme.Items.Objects[ComboBoxTheme.ItemIndex]);
     56    Core.Core.ThemeManager1.Theme := TTheme(ComboBoxTheme.Items.Objects[ComboBoxTheme.ItemIndex]);
    6857  ModalResult := mrOk;
    69 end;
    70 
    71 procedure TFormSettings.FormClose(Sender: TObject; var CloseAction: TCloseAction
    72   );
    73 begin
    74   Core.PersistentForm1.Save(Self);
    7558end;
    7659
    7760procedure TFormSettings.FormCreate(Sender: TObject);
    7861begin
    79   Core.Translator1.TranslateComponentRecursive(Self);
    80   Core.Translator1.LanguageListToStrings(ComboBoxLanguage.Items);
    81   Core.ThemeManager1.UseTheme(Self);
    82   Core.ThemeManager1.Themes.LoadToStrings(ComboBoxTheme.Items);
     62  Core.Core.Translator1.LanguageListToStrings(ComboBoxLanguage.Items);
     63  Core.Core.ThemeManager1.Themes.LoadToStrings(ComboBoxTheme.Items);
    8364end;
    8465
    8566procedure TFormSettings.FormShow(Sender: TObject);
    8667begin
    87   Core.PersistentForm1.Load(Self);
    88   TrackBar1.Position := Core.Game.AnimationDuration;
    89   ComboBoxLanguage.ItemIndex := ComboBoxLanguage.Items.IndexOfObject(Core.Translator1.Language);
     68  TrackBar1.Position := Core.Core.Game.AnimationDuration;
     69  ComboBoxLanguage.ItemIndex := ComboBoxLanguage.Items.IndexOfObject(Core.Core.Translator1.Language);
    9070  if ComboBoxLanguage.ItemIndex = -1 then ComboBoxLanguage.ItemIndex := 0;
    91   ComboBoxTheme.ItemIndex := ComboBoxTheme.Items.IndexOfObject(Core.ThemeManager1.Theme);
     71  ComboBoxTheme.ItemIndex := ComboBoxTheme.Items.IndexOfObject(Core.Core.ThemeManager1.Theme);
    9272  if ComboBoxTheme.ItemIndex = -1 then ComboBoxTheme.ItemIndex := 0;
    9373end;
  • trunk/Game.pas

    r85 r86  
    1 unit UGame;
    2 
    3 {$mode delphi}{$H+}
     1unit Game;
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, Dialogs, fgl, Graphics, Types, Forms, Math, DateUtils,
     6  Classes, SysUtils, Dialogs, Generics.Collections, Graphics, Types, Forms, Math, DateUtils,
    97  Controls, RegistryEx;
    108
     
    2624  end;
    2725
    28   TTiles = class(TFPGObjectList<TTile>)
     26  TTiles = class(TObjectList<TTile>)
    2927  end;
    3028
     
    5048  { THistoryMoves }
    5149
    52   THistoryMoves = class(TFPGObjectList<THistoryMove>)
     50  THistoryMoves = class(TObjectList<THistoryMove>)
    5351    procedure SaveToRegistry(Reg: TRegistryEx; RegContext: TRegistryContext);
    5452    procedure LoadFromRegistry(Reg: TRegistryEx; RegContext: TRegistryContext);
     
    166164  end;
    167165
    168   TGames = class(TFPGObjectList<TGame>)
     166  TGames = class(TObjectList<TGame>)
    169167  end;
    170168
     
    196194
    197195uses
    198   UCore, MetaCanvas;
     196  Core, MetaCanvas;
    199197
    200198procedure Translate;
     
    627625  TopBarHeight := ScaleY(24, 96);
    628626  MetaCanvas.Brush.Style := bsSolid;
    629   MetaCanvas.Brush.Color := Core.ThemeManager1.Theme.ColorControl;
     627  MetaCanvas.Brush.Color := Core.Core.ThemeManager1.Theme.ColorControl;
    630628  MetaCanvas.FillRect(0, 0, MetaCanvas.Width, MetaCanvas.Height);
    631629
    632630  ValueStr := SScore + ': ' + IntToStr(Score);
    633631  MetaCanvas.Brush.Style := bsClear;
    634   MetaCanvas.Font.Color := Core.ThemeManager1.Theme.ColorControlText;
     632  MetaCanvas.Font.Color := Core.Core.ThemeManager1.Theme.ColorControlText;
    635633  MetaCanvas.Font.Height := Trunc(TopBarHeight * 0.7);
    636634  MetaCanvas.TextOut(ScaleY(16, 96), (TopBarHeight - MetaCanvas.TextHeight(ValueStr)) div 2, ValueStr);
    637635
    638636  ValueStr := STopScore + ': ' + IntToStr(TopScore);
    639   MetaCanvas.Font.Color := Core.ThemeManager1.Theme.ColorControlText;
     637  MetaCanvas.Font.Color := Core.Core.ThemeManager1.Theme.ColorControlText;
    640638  MetaCanvas.Font.Height := Trunc(TopBarHeight * 0.7);
    641639  MetaCanvas.TextOut(ScaleY(136, 96), (TopBarHeight - MetaCanvas.TextHeight(ValueStr)) div 2, ValueStr);
     
    12321230function TGame.GetTileColor(Value: Integer): TColor;
    12331231begin
    1234   if Core.ThemeManager1.Theme.Name = 'Dark' then begin
     1232  if Core.Core.ThemeManager1.Theme.Name = 'Dark' then begin
    12351233    case Value of
    12361234      0: Result := $222629;
  • trunk/Game2048.lpi

    r85 r86  
    9696      </Unit0>
    9797      <Unit1>
    98         <Filename Value="UGame.pas"/>
     98        <Filename Value="Game.pas"/>
    9999        <IsPartOfProject Value="True"/>
    100100      </Unit1>
    101101      <Unit2>
    102         <Filename Value="Forms/UFormMain.pas"/>
     102        <Filename Value="Forms/FormMain.pas"/>
    103103        <IsPartOfProject Value="True"/>
    104104        <ComponentName Value="FormMain"/>
     
    107107      </Unit2>
    108108      <Unit3>
    109         <Filename Value="Forms/UFormNew.pas"/>
     109        <Filename Value="Forms/FormNew.pas"/>
    110110        <IsPartOfProject Value="True"/>
    111111        <ComponentName Value="FormNew"/>
     
    114114      </Unit3>
    115115      <Unit4>
    116         <Filename Value="Forms/UFormSettings.pas"/>
     116        <Filename Value="Forms/FormSettings.pas"/>
    117117        <IsPartOfProject Value="True"/>
    118118        <ComponentName Value="FormSettings"/>
     
    121121      </Unit4>
    122122      <Unit5>
    123         <Filename Value="UCore.pas"/>
     123        <Filename Value="Core.pas"/>
    124124        <IsPartOfProject Value="True"/>
    125125        <ComponentName Value="Core"/>
     
    128128      </Unit5>
    129129      <Unit6>
    130         <Filename Value="Forms/UFormHelp.pas"/>
     130        <Filename Value="Forms/FormHelp.pas"/>
    131131        <IsPartOfProject Value="True"/>
    132132        <ComponentName Value="FormHelp"/>
     
    135135      </Unit6>
    136136      <Unit7>
    137         <Filename Value="Forms/UFormComputer.pas"/>
     137        <Filename Value="Forms/FormComputer.pas"/>
    138138        <IsPartOfProject Value="True"/>
    139139        <ComponentName Value="FormComputer"/>
     
    142142      </Unit7>
    143143      <Unit8>
    144         <Filename Value="Forms/UFormHistory.pas"/>
     144        <Filename Value="Forms/FormHistory.pas"/>
    145145        <IsPartOfProject Value="True"/>
    146146        <ComponentName Value="FormHistory"/>
  • trunk/Game2048.lpr

    r82 r86  
    88  {$ENDIF}
    99  Interfaces, SysUtils,// this includes the LCL widgetset
    10   Forms, UGame, Common, UFormMain, UCore
     10  Forms, Game, Common, FormMain, Core
    1111  { you can add units after this };
    1212
     
    2828  Application.Scaled := True;
    2929  Application.Initialize;
    30   Application.CreateForm(TCore, Core);
    31   Application.CreateForm(TFormMain, FormMain);
     30  Application.CreateForm(TCore, Core.Core);
     31  Application.CreateForm(TFormMain, FormMain.FormMain);
    3232  Application.Run;
    3333end.
  • trunk/Languages/Game2048.cs.po

    r85 r86  
    1212"X-Generator: Poedit 2.4.1\n"
    1313
     14#: core.sgameovercaption
     15#, fuzzy
     16msgctxt "core.sgameovercaption"
     17msgid "Lost"
     18msgstr "Prohra"
     19
     20#: core.sgameovermessage
     21#, fuzzy
     22msgctxt "core.sgameovermessage"
     23msgid "Game over!"
     24msgstr "Konec hry!"
     25
     26#: core.swincaption
     27#, fuzzy
     28msgctxt "core.swincaption"
     29msgid "Win"
     30msgstr "Vítězství"
     31
     32#: core.swinmessage
     33#, object-pascal-format, fuzzy
     34msgctxt "core.swinmessage"
     35msgid "You reached %s and won! You can continue to play to get higher score."
     36msgstr "Dosáhl jsi %s a vyhrál! Můžeš pokračovat ve hře k dosažení vyššího skóre."
     37
     38#: formhelp.scontrols
     39#, fuzzy
     40msgctxt "formhelp.scontrols"
     41msgid "Use arrow keys to slide blocks to one of board side."
     42msgstr "Použij klávesy šipek k posunutí bloků do jedné ze stran desky."
     43
     44#: formhelp.severyturn
     45#, fuzzy
     46msgctxt "formhelp.severyturn"
     47msgid "Every turn, a new tile will randomly appear in an empty spot on the board with a value of either 2 or 4."
     48msgstr "Každý tah se náhodně objeví nová dlaždice v prázdném místě desky s hodnotou 2 nebo 4."
     49
     50#: formhelp.sparagraph1
     51#, fuzzy
     52msgctxt "formhelp.sparagraph1"
     53msgid "2048 is a single-player block sliding puzzle game."
     54msgstr "2048 je jednouživatelská logická hra s posouváním bloků."
     55
     56#: formhelp.sparagraph2
     57#, fuzzy
     58msgctxt "formhelp.sparagraph2"
     59msgid "The game's objective is to slide numbered tiles on a grid to combine them to create a tile with the number 2048."
     60msgstr "Cílem hry je posouvat očíslované dlaždice na mřížce k jejich spojení a vytvoření dlaždice s číslem 2048."
     61
     62#: formhelp.sundo
     63#, fuzzy
     64msgctxt "formhelp.sundo"
     65msgid "You can undo one move back, if undo action is enabled."
     66msgstr "Můžete vrátit zpět jeden pohyb, pokud je akce vrátit zpět povolena."
     67
     68#: formsettings.slanguagechangemessage
     69#, fuzzy
     70msgctxt "formsettings.slanguagechangemessage"
     71msgid "Interface language was changed. It may require restart of application."
     72msgstr "Jazyk rozhraní byl změněn. To může vyžadovat restart aplikace."
     73
     74#: formsettings.slanguagechangetitle
     75#, fuzzy
     76msgctxt "formsettings.slanguagechangetitle"
     77msgid "Language change"
     78msgstr "Změna jazyka"
     79
     80#: game.sscore
     81#, fuzzy
     82msgctxt "game.sscore"
     83msgid "Score"
     84msgstr "Skóre"
     85
     86#: game.sskinalpha
     87#, fuzzy
     88msgctxt "game.sskinalpha"
     89msgid "Alpha"
     90msgstr "Písmena"
     91
     92#: game.sskinbinary
     93#, fuzzy
     94msgctxt "game.sskinbinary"
     95msgid "Binary"
     96msgstr "Binární"
     97
     98#: game.sskinlinear
     99#, fuzzy
     100msgctxt "game.sskinlinear"
     101msgid "Linear"
     102msgstr "Lineární"
     103
     104#: game.sskinpoweroftwo
     105#, fuzzy
     106msgctxt "game.sskinpoweroftwo"
     107msgid "Power of two"
     108msgstr "Mocnina dvou"
     109
     110#: game.sskinroman
     111#, fuzzy
     112msgctxt "game.sskinroman"
     113msgid "Roman"
     114msgstr "Římské číslice"
     115
     116#: game.stileshouldbeempty
     117#, fuzzy
     118msgctxt "game.stileshouldbeempty"
     119msgid "Tile should be empty"
     120msgstr "Dlaždice by měla být prázdná"
     121
     122#: game.stopscore
     123#, fuzzy
     124msgctxt "game.stopscore"
     125msgid "Top score"
     126msgstr "Nejvyšší skóre"
     127
    14128#: tcore.aabout.caption
    15129msgctxt "tcore.aabout.caption"
     
    165279msgstr "Téma:"
    166280
    167 #: ucore.sgameovercaption
    168 msgctxt "ucore.sgameovercaption"
    169 msgid "Lost"
    170 msgstr "Prohra"
    171 
    172 #: ucore.sgameovermessage
    173 msgctxt "ucore.sgameovermessage"
    174 msgid "Game over!"
    175 msgstr "Konec hry!"
    176 
    177 #: ucore.swincaption
    178 msgctxt "ucore.swincaption"
    179 msgid "Win"
    180 msgstr "Vítězství"
    181 
    182 #: ucore.swinmessage
    183 #, object-pascal-format
    184 msgctxt "ucore.swinmessage"
    185 msgid "You reached %s and won! You can continue to play to get higher score."
    186 msgstr "Dosáhl jsi %s a vyhrál! Můžeš pokračovat ve hře k dosažení vyššího skóre."
    187 
    188 #: uformhelp.scontrols
    189 msgid "Use arrow keys to slide blocks to one of board side."
    190 msgstr "Použij klávesy šipek k posunutí bloků do jedné ze stran desky."
    191 
    192 #: uformhelp.severyturn
    193 msgid "Every turn, a new tile will randomly appear in an empty spot on the board with a value of either 2 or 4."
    194 msgstr "Každý tah se náhodně objeví nová dlaždice v prázdném místě desky s hodnotou 2 nebo 4."
    195 
    196 #: uformhelp.sparagraph1
    197 msgid "2048 is a single-player block sliding puzzle game."
    198 msgstr "2048 je jednouživatelská logická hra s posouváním bloků."
    199 
    200 #: uformhelp.sparagraph2
    201 msgid "The game's objective is to slide numbered tiles on a grid to combine them to create a tile with the number 2048."
    202 msgstr "Cílem hry je posouvat očíslované dlaždice na mřížce k jejich spojení a vytvoření dlaždice s číslem 2048."
    203 
    204 #: uformhelp.sundo
    205 msgid "You can undo one move back, if undo action is enabled."
    206 msgstr "Můžete vrátit zpět jeden pohyb, pokud je akce vrátit zpět povolena."
    207 
    208 #: uformsettings.slanguagechangemessage
    209 msgid "Interface language was changed. It may require restart of application."
    210 msgstr "Jazyk rozhraní byl změněn. To může vyžadovat restart aplikace."
    211 
    212 #: uformsettings.slanguagechangetitle
    213 msgid "Language change"
    214 msgstr "Změna jazyka"
    215 
    216 #: ugame.sscore
    217 msgid "Score"
    218 msgstr "Skóre"
    219 
    220 #: ugame.sskinalpha
    221 msgid "Alpha"
    222 msgstr "Písmena"
    223 
    224 #: ugame.sskinbinary
    225 msgid "Binary"
    226 msgstr "Binární"
    227 
    228 #: ugame.sskinlinear
    229 msgid "Linear"
    230 msgstr "Lineární"
    231 
    232 #: ugame.sskinpoweroftwo
    233 msgid "Power of two"
    234 msgstr "Mocnina dvou"
    235 
    236 #: ugame.sskinroman
    237 msgid "Roman"
    238 msgstr "Římské číslice"
    239 
    240 #: ugame.stileshouldbeempty
    241 msgid "Tile should be empty"
    242 msgstr "Dlaždice by měla být prázdná"
    243 
    244 #: ugame.stopscore
    245 msgid "Top score"
    246 msgstr "Nejvyšší skóre"
    247 
Note: See TracChangeset for help on using the changeset viewer.