- Timestamp:
- Jun 7, 2024, 12:47:11 PM (3 months ago)
- Location:
- trunk
- Files:
-
- 3 edited
- 22 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Core.lfm
r85 r86 2135 2135 end 2136 2136 end 2137 object ScaleDPI1: TScaleDPI 2138 AutoDetect = False 2139 Left = 120 2140 Top = 400 2141 end 2137 2142 end -
trunk/Core.pas
r85 r86 1 unit UCore; 2 3 {$mode delphi} 1 unit Core; 4 2 5 3 interface … … 7 5 uses 8 6 Classes, SysUtils, Theme, PersistentForm, ApplicationInfo, Translator, 9 RegistryEx, UGame, ActnList, Forms, Controls, Dialogs;7 RegistryEx, ScaleDPI, Game, ActnList, Forms, Controls, Dialogs; 10 8 11 9 type … … 25 23 ApplicationInfo1: TApplicationInfo; 26 24 PersistentForm1: TPersistentForm; 25 ScaleDPI1: TScaleDPI; 27 26 ThemeManager1: TThemeManager; 28 27 Translator1: TTranslator; … … 61 60 62 61 uses 63 UFormMain, UFormSettings, UFormNew, UFormHelp, UFormComputer, FormAbout,64 UFormHistory;62 FormMain, FormSettings, FormNew, FormHelp, FormComputer, FormAbout, FormEx, 63 FormHistory; 65 64 66 65 resourcestring … … 69 68 SWinCaption = 'Win'; 70 69 SWinMessage = 'You reached %s and won! You can continue to play to get higher score.'; 70 71 procedure Translate; 72 begin 73 Game.Translate; 74 end; 71 75 72 76 { TCore } … … 90 94 Game.OnGameOver := GameOver; 91 95 LoadConfig; 96 97 TFormEx.ScaleDPI := ScaleDPI1; 98 TFormEx.Translator := Translator1; 99 TFormEx.ThemeManager := ThemeManager1; 100 TFormEx.PersistentForm := PersistentForm1; 92 101 end; 93 102 94 103 procedure TCore.ASettingsExecute(Sender: TObject); 104 var 105 FormSettings: TFormSettings; 95 106 begin 96 107 FormSettings := TFormSettings.Create(nil); 97 108 try 98 109 if FormSettings.ShowModal = mrOk then begin 99 FormMain. Redraw;100 FormMain. UpdateInterface;110 FormMain.FormMain.Redraw; 111 FormMain.FormMain.UpdateInterface; 101 112 UpdateInterface; 102 113 end; … … 125 136 126 137 procedure TCore.AComputerExecute(Sender: TObject); 138 var 139 FormComputer: TFormComputer; 127 140 begin 128 141 FormComputer := TFormComputer.Create(nil); … … 136 149 procedure TCore.AExitExecute(Sender: TObject); 137 150 begin 138 FormMain. Close;151 FormMain.FormMain.Close; 139 152 end; 140 153 141 154 procedure TCore.AHelpExecute(Sender: TObject); 155 var 156 FormHelp: TFormHelp; 142 157 begin 143 158 FormHelp := TFormHelp.Create(nil); … … 150 165 151 166 procedure TCore.AHistoryExecute(Sender: TObject); 167 var 168 FormHistory: TFormHistory; 152 169 begin 153 170 FormHistory := TFormHistory.Create(nil); … … 160 177 161 178 procedure TCore.ANewExecute(Sender: TObject); 179 var 180 FormNew: TFormNew; 162 181 begin 163 182 FormNew := TFormNew.Create(nil); … … 168 187 Game.New; 169 188 UpdateInterface; 170 FormMain. UpdateInterface;189 FormMain.FormMain.UpdateInterface; 171 190 end; 172 191 finally … … 183 202 procedure TCore.Translator1Translate(Sender: TObject); 184 203 begin 185 UGame.Translate;204 Translate; 186 205 end; 187 206 … … 193 212 procedure TCore.GamePaint(Sender: TObject); 194 213 begin 195 if Assigned(FormMain ) thenFormMain.Redraw;214 if Assigned(FormMain.FormMain) then FormMain.FormMain.Redraw; 196 215 end; 197 216 198 217 procedure TCore.GameWin(Sender: TObject); 199 218 begin 200 TThread.Synchronize(FormMain. MoveThread, GameWinSync);219 TThread.Synchronize(FormMain.FormMain.MoveThread, GameWinSync); 201 220 end; 202 221 … … 208 227 procedure TCore.GameOver(Sender: TObject); 209 228 begin 210 TThread.Synchronize(FormMain. MoveThread, GameOverSync);229 TThread.Synchronize(FormMain.FormMain.MoveThread, GameOverSync); 211 230 end; 212 231 -
trunk/Forms/FormComputer.lfm
r85 r86 11 11 OnCreate = FormCreate 12 12 OnDestroy = FormDestroy 13 OnShow = FormShow 14 LCLVersion = '2.0.2.0' 13 LCLVersion = '3.4.0.0' 15 14 object ButtonStart: TButton 16 15 Left = 40 … … 19 18 Width = 113 20 19 Caption = 'Start' 20 TabOrder = 0 21 21 OnClick = ButtonStartClick 22 TabOrder = 023 22 end 24 23 object ButtonStop: TButton … … 29 28 Caption = 'Stop' 30 29 Enabled = False 30 TabOrder = 1 31 31 OnClick = ButtonStopClick 32 TabOrder = 133 32 end 34 33 object TrackBar1: TTrackBar … … 46 45 Height = 26 47 46 Top = 76 48 Width = 12 747 Width = 126 49 48 Caption = 'Delay per step:' 50 49 ParentColor = False -
trunk/Forms/FormComputer.pas
r85 r86 1 unit UFormComputer; 2 3 {$mode delphi} 1 unit FormComputer; 4 2 5 3 interface … … 7 5 uses 8 6 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls, 9 UGame, fgl;7 Game, Generics.Collections, Generics.Defaults, FormEx; 10 8 11 9 type … … 23 21 end; 24 22 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; 26 30 end; 27 31 28 32 { TFormComputer } 29 33 30 TFormComputer = class(TForm )34 TFormComputer = class(TFormEx) 31 35 ButtonStart: TButton; 32 36 ButtonStop: TButton; … … 38 42 procedure FormCreate(Sender: TObject); 39 43 procedure FormDestroy(Sender: TObject); 40 procedure FormShow(Sender: TObject);41 44 private 42 45 Stop: Boolean; … … 46 49 GameTries4: TGameTries; 47 50 procedure TryAllDirections(GameTries: TGameTries; GameTry: TGameTry); 48 public 49 50 end; 51 52 var 53 FormComputer: TFormComputer; 51 end; 52 54 53 55 54 implementation … … 58 57 59 58 uses 60 UCore;59 Core; 61 60 62 61 { TGameTry } … … 133 132 end; 134 133 134 { TGameTryComparer } 135 136 function TGameTryComparer.Compare(constref Left, Right: TGameTry): Integer; 137 var 138 ScoreLeft: Double; 139 ScoreRight: Double; 140 begin 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; 146 end; 147 135 148 { TFormComputer } 136 149 … … 139 152 begin 140 153 ButtonStopClick(Self); 141 Core.PersistentForm1.Save(Self);142 154 end; 143 155 … … 161 173 J: Integer; 162 174 GameTries: TGameTries; 175 GameTryComparer: TGameTryComparer; 163 176 Delay: Integer; 164 177 begin … … 166 179 ButtonStop.Enabled := True; 167 180 Stop := False; 168 with Core. Game do begin181 with Core.Core.Game do begin 169 182 while CanMove and not Stop do begin 170 183 NewTry := TGameTry.Create; 171 NewTry.Game.Assign(Core. Game);184 NewTry.Game.Assign(Core.Core.Game); 172 185 GameTries1.Clear; 173 186 TryAllDirections(GameTries1, NewTry); … … 184 197 185 198 GameTries := GameTries4; 186 GameTries.Sort(GameCompareScore); 199 GameTryComparer := TGameTryComparer.Create; 200 GameTries.Sort(GameTryComparer); 187 201 S := ''; 188 202 for I := 0 to GameTries.Count - 1 do begin … … 221 235 procedure TFormComputer.FormCreate(Sender: TObject); 222 236 begin 223 Core.Translator1.TranslateComponentRecursive(Self);224 Core.ThemeManager1.UseTheme(Self);225 237 GameTries1 := TGameTries.Create; 226 238 GameTries2 := TGameTries.Create; … … 235 247 FreeAndNil(GameTries3); 236 248 FreeAndNil(GameTries4); 237 end;238 239 procedure TFormComputer.FormShow(Sender: TObject);240 begin241 Core.PersistentForm1.Load(Self);242 249 end; 243 250 -
trunk/Forms/FormHelp.lfm
r85 r86 8 8 ClientWidth = 480 9 9 DesignTimePPI = 144 10 OnClose = FormClose11 OnCreate = FormCreate12 10 OnShow = FormShow 13 LCLVersion = ' 2.0.2.0'11 LCLVersion = '3.4.0.0' 14 12 object Memo1: TMemo 15 13 Left = 8 -
trunk/Forms/FormHelp.pas
r85 r86 1 unit UFormHelp; 2 3 {$mode delphi} 1 unit FormHelp; 4 2 5 3 interface 6 4 7 5 uses 8 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls ;6 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, FormEx; 9 7 10 8 type … … 12 10 { TFormHelp } 13 11 14 TFormHelp = class(TForm )12 TFormHelp = class(TFormEx) 15 13 Memo1: TMemo; 16 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);17 procedure FormCreate(Sender: TObject);18 14 procedure FormShow(Sender: TObject); 19 private20 21 public22 23 15 end; 24 16 25 var26 FormHelp: TFormHelp;27 17 28 18 implementation … … 31 21 32 22 uses 33 UCore;23 Core; 34 24 35 25 resourcestring … … 42 32 { TFormHelp } 43 33 44 procedure TFormHelp.FormCreate(Sender: TObject);45 begin46 Core.Translator1.TranslateComponentRecursive(Self);47 Core.ThemeManager1.UseTheme(Self);48 end;49 50 procedure TFormHelp.FormClose(Sender: TObject; var CloseAction: TCloseAction);51 begin52 Core.PersistentForm1.Save(Self);53 end;54 55 34 procedure TFormHelp.FormShow(Sender: TObject); 56 35 begin 57 Core.PersistentForm1.Load(Self);58 36 Memo1.Text := SParagraph1 + LineEnding + 59 37 SParagraph2 + LineEnding + -
trunk/Forms/FormHistory.lfm
r85 r86 8 8 ClientWidth = 480 9 9 DesignTimePPI = 144 10 OnClose = FormClose11 10 OnCreate = FormCreate 12 11 OnDestroy = FormDestroy 13 12 OnShow = FormShow 14 LCLVersion = ' 2.0.2.0'13 LCLVersion = '3.4.0.0' 15 14 object PaintBox1: TPaintBox 16 15 Left = 0 … … 45 44 Interval = 50 46 45 OnTimer = Timer1Timer 47 left = 10848 top = 12346 Left = 108 47 Top = 123 49 48 end 50 49 end -
trunk/Forms/FormHistory.pas
r85 r86 1 unit UFormHistory; 2 3 {$mode delphi} 1 unit FormHistory; 4 2 5 3 interface 6 4 7 5 uses 8 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ComCtrls, UGame; 6 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ComCtrls, 7 Game, FormEx; 9 8 10 9 type … … 12 11 { TFormHistory } 13 12 14 TFormHistory = class(TForm )13 TFormHistory = class(TFormEx) 15 14 PaintBox1: TPaintBox; 16 15 Panel1: TPanel; 17 16 Timer1: TTimer; 18 17 TrackBar1: TTrackBar; 19 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);20 18 procedure FormCreate(Sender: TObject); 21 19 procedure FormDestroy(Sender: TObject); … … 31 29 end; 32 30 33 var34 FormHistory: TFormHistory;35 31 36 32 implementation … … 39 35 40 36 uses 41 UCore;37 Core; 42 38 43 39 { TFormHistory } … … 45 41 procedure TFormHistory.FormShow(Sender: TObject); 46 42 begin 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; 50 45 Redraw; 51 46 end; … … 59 54 begin 60 55 if RedrawPending then begin 61 Core. Game.History.GetStep(Game, TrackBar1.Position);56 Core.Core.Game.History.GetStep(Game, TrackBar1.Position); 62 57 PaintBox1.Refresh; 63 58 RedrawPending := False; … … 77 72 procedure TFormHistory.FormCreate(Sender: TObject); 78 73 begin 79 Core.Translator1.TranslateComponentRecursive(Self);80 Core.ThemeManager1.UseTheme(Self);81 74 Game := TGame.Create; 82 75 end; … … 87 80 end; 88 81 89 procedure TFormHistory.FormClose(Sender: TObject; var CloseAction: TCloseAction90 );91 begin92 Core.PersistentForm1.Save(Self);93 end;94 95 82 end. 96 83 -
trunk/Forms/FormMain.lfm
r85 r86 16 16 OnPaint = FormPaint 17 17 OnShow = FormShow 18 LCLVersion = ' 2.0.10.0'18 LCLVersion = '3.4.0.0' 19 19 object MainMenu1: TMainMenu 20 20 Left = 328 -
trunk/Forms/FormMain.pas
r85 r86 1 unit UFormMain; 2 3 {$mode delphi}{$H+} 1 unit FormMain; 4 2 5 3 interface … … 7 5 uses 8 6 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; 11 9 12 10 type … … 22 20 { TFormMain } 23 21 24 TFormMain = class(TForm )22 TFormMain = class(TFormEx) 25 23 MainMenu1: TMainMenu; 26 24 MenuItem1: TMenuItem; … … 72 70 FormMain: TFormMain; 73 71 72 74 73 implementation 75 74 … … 77 76 78 77 uses 79 UCore;78 Core; 80 79 81 80 { TMoveThread } … … 98 97 KeyDown = 40; 99 98 begin 100 if Core. Game.Running then begin99 if Core.Core.Game.Running then begin 101 100 case Key of 102 101 KeyLeft: AddToMoveBuffer(drLeft); … … 162 161 TimeStart := Now; 163 162 {$ENDIF} 164 Core. Game.Render(Canvas, Point(Width, Height - MainMenu1.Height));163 Core.Core.Game.Render(Canvas, Point(Width, Height - MainMenu1.Height)); 165 164 {$IFDEF DEBUG} 166 165 DrawDuration := Now - TimeStart; … … 170 169 procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction); 171 170 begin 172 Core. PersistentForm1.Save(Self);171 Core.Core.PersistentForm1.Save(Self); 173 172 end; 174 173 175 174 procedure TFormMain.FormCreate(Sender: TObject); 176 175 begin 177 Core.Translator1.TranslateComponentRecursive(Self);178 176 MoveBufferLock := TCriticalSection.Create; 179 177 MoveThread := TMoveThread.Create(True); … … 192 190 procedure TFormMain.FormShow(Sender: TObject); 193 191 begin 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 198 194 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 - 200 196 InitialTileCount then 201 Core. Game.New;197 Core.Core.Game.New; 202 198 end; 203 199 … … 236 232 procedure TFormMain.ProcessMoveBuffer; 237 233 begin 238 if not Core. Game.Moving then begin234 if not Core.Core.Game.Moving then begin 239 235 MoveBufferLock.Acquire; 240 236 while Length(MoveBuffer) > 0 do begin 241 237 MoveBufferLock.Release; 242 Core. Game.MoveAllAndUpdate(MoveBuffer[0],Core.Game.AnimationDuration > 0);238 Core.Core.Game.MoveAllAndUpdate(MoveBuffer[0], Core.Core.Game.AnimationDuration > 0); 243 239 MoveBufferLock.Acquire; 244 240 if Length(MoveBuffer) > 1 then … … 254 250 begin 255 251 FullScreen := not FullScreen; 256 Core. PersistentForm1.SetFullScreen(FormMain.FullScreen);252 Core.Core.PersistentForm1.SetFullScreen(FormMain.FullScreen); 257 253 UpdateInterface; 258 254 end; … … 269 265 begin 270 266 MenuItemFullScreen.Checked := FullScreen; 271 MenuItemMovesHistory.Visible := Core. Game.RecordHistory;267 MenuItemMovesHistory.Visible := Core.Core.Game.RecordHistory; 272 268 ToolsVisible := False; 273 269 for I := 0 to MenuItemTools.Count - 1 do -
trunk/Forms/FormNew.lfm
r85 r86 8 8 ClientWidth = 501 9 9 DesignTimePPI = 144 10 OnClose = FormClose11 10 OnCreate = FormCreate 12 OnShow = FormShow 13 LCLVersion = '2.0.10.0' 11 LCLVersion = '3.4.0.0' 14 12 object Label1: TLabel 15 13 Left = 16 16 Height = 2 414 Height = 26 17 15 Top = 16 18 16 Width = 93 … … 80 78 object Label2: TLabel 81 79 Left = 16 82 Height = 2 480 Height = 26 83 81 Top = 125 84 82 Width = 75 … … 88 86 object ComboBoxSkin: TComboBox 89 87 Left = 173 90 Height = 3 788 Height = 38 91 89 Top = 120 92 90 Width = 262 -
trunk/Forms/FormNew.pas
r85 r86 1 unit UFormNew; 2 3 {$mode delphi}{$H+} 1 unit FormNew; 4 2 5 3 interface … … 7 5 uses 8 6 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 UGame;7 Game, FormEx; 10 8 11 9 type … … 13 11 { TFormNew } 14 12 15 TFormNew = class(TForm )13 TFormNew = class(TFormEx) 16 14 ButtonCancel: TButton; 17 15 ButtonOk: TButton; … … 22 20 Label1: TLabel; 23 21 Label2: TLabel; 24 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);25 22 procedure FormCreate(Sender: TObject); 26 procedure FormShow(Sender: TObject);27 private28 29 23 public 30 24 procedure Load(Game: TGame); … … 32 26 end; 33 27 34 var35 FormNew: TFormNew;36 28 37 29 implementation … … 40 32 41 33 uses 42 UCore;34 Core; 43 35 44 36 { TFormNew } … … 48 40 I: TTileSkin; 49 41 begin 50 Core.Translator1.TranslateComponentRecursive(Self);51 Core.ThemeManager1.UseTheme(Self);52 42 ComboBoxSkin.Items.BeginUpdate; 53 43 try … … 58 48 ComboBoxSkin.Items.EndUpdate; 59 49 end; 60 end;61 62 procedure TFormNew.FormShow(Sender: TObject);63 begin64 Core.PersistentForm1.Load(Self);65 end;66 67 procedure TFormNew.FormClose(Sender: TObject; var CloseAction: TCloseAction);68 begin69 Core.PersistentForm1.Save(Self);70 50 end; 71 51 -
trunk/Forms/FormSettings.lfm
r85 r86 8 8 ClientWidth = 480 9 9 DesignTimePPI = 144 10 OnClose = FormClose11 10 OnCreate = FormCreate 12 11 OnShow = FormShow 13 LCLVersion = ' 2.0.4.0'12 LCLVersion = '3.4.0.0' 14 13 object Label1: TLabel 15 14 Left = 19 16 Height = 2 515 Height = 26 17 16 Top = 24 18 Width = 1 5817 Width = 170 19 18 Caption = 'Animation duration:' 20 19 ParentColor = False … … 37 36 Anchors = [akLeft, akBottom] 38 37 Caption = 'OK' 38 TabOrder = 1 39 39 OnClick = ButtonOkClick 40 TabOrder = 141 40 end 42 41 object ButtonCancel: TButton … … 47 46 Anchors = [akLeft, akBottom] 48 47 Caption = 'Cancel' 48 TabOrder = 2 49 49 OnClick = ButtonCancelClick 50 TabOrder = 251 50 end 52 51 object ComboBoxLanguage: TComboBox 53 52 Left = 208 54 Height = 3353 Height = 42 55 54 Top = 86 56 55 Width = 230 57 ItemHeight = 2556 ItemHeight = 0 58 57 Style = csDropDownList 59 58 TabOrder = 3 … … 61 60 object Label2: TLabel 62 61 Left = 19 63 Height = 2 562 Height = 26 64 63 Top = 94 65 Width = 8 164 Width = 88 66 65 Caption = 'Language:' 67 66 ParentColor = False … … 69 68 object ComboBoxTheme: TComboBox 70 69 Left = 208 71 Height = 3370 Height = 42 72 71 Top = 136 73 72 Width = 230 74 ItemHeight = 2573 ItemHeight = 0 75 74 Style = csDropDownList 76 75 TabOrder = 4 … … 78 77 object Label3: TLabel 79 78 Left = 19 80 Height = 2 579 Height = 26 81 80 Top = 144 82 Width = 5781 Width = 63 83 82 Caption = 'Theme:' 84 83 ParentColor = False -
trunk/Forms/FormSettings.pas
r85 r86 1 unit UFormSettings; 2 3 {$mode delphi} 1 unit FormSettings; 4 2 5 3 interface … … 7 5 uses 8 6 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls, 9 Languages, Theme ;7 Languages, Theme, FormEx; 10 8 11 9 type … … 13 11 { TFormSettings } 14 12 15 TFormSettings = class(TForm )13 TFormSettings = class(TFormEx) 16 14 ButtonOk: TButton; 17 15 ButtonCancel: TButton; … … 24 22 procedure ButtonCancelClick(Sender: TObject); 25 23 procedure ButtonOkClick(Sender: TObject); 26 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);27 24 procedure FormCreate(Sender: TObject); 28 25 procedure FormShow(Sender: TObject); 29 private30 31 public32 33 26 end; 34 35 var36 FormSettings: TFormSettings;37 27 38 28 … … 42 32 43 33 uses 44 UCore;34 Core; 45 35 46 36 resourcestring 47 37 SLanguageChangeTitle = 'Language change'; 48 38 SLanguageChangeMessage = 'Interface language was changed. It may require restart of application.'; 49 50 39 51 40 { TFormSettings } … … 58 47 procedure TFormSettings.ButtonOkClick(Sender: TObject); 59 48 begin 60 Core. Game.AnimationDuration := TrackBar1.Position;49 Core.Core.Game.AnimationDuration := TrackBar1.Position; 61 50 if ComboBoxLanguage.ItemIndex <> -1 then begin 62 if (Core. Translator1.Language <> TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex])) then51 if (Core.Core.Translator1.Language <> TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex])) then 63 52 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]); 65 54 end; 66 55 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]); 68 57 ModalResult := mrOk; 69 end;70 71 procedure TFormSettings.FormClose(Sender: TObject; var CloseAction: TCloseAction72 );73 begin74 Core.PersistentForm1.Save(Self);75 58 end; 76 59 77 60 procedure TFormSettings.FormCreate(Sender: TObject); 78 61 begin 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); 83 64 end; 84 65 85 66 procedure TFormSettings.FormShow(Sender: TObject); 86 67 begin 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); 90 70 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); 92 72 if ComboBoxTheme.ItemIndex = -1 then ComboBoxTheme.ItemIndex := 0; 93 73 end; -
trunk/Game.pas
r85 r86 1 unit UGame; 2 3 {$mode delphi}{$H+} 1 unit Game; 4 2 5 3 interface 6 4 7 5 uses 8 Classes, SysUtils, Dialogs, fgl, Graphics, Types, Forms, Math, DateUtils,6 Classes, SysUtils, Dialogs, Generics.Collections, Graphics, Types, Forms, Math, DateUtils, 9 7 Controls, RegistryEx; 10 8 … … 26 24 end; 27 25 28 TTiles = class(T FPGObjectList<TTile>)26 TTiles = class(TObjectList<TTile>) 29 27 end; 30 28 … … 50 48 { THistoryMoves } 51 49 52 THistoryMoves = class(T FPGObjectList<THistoryMove>)50 THistoryMoves = class(TObjectList<THistoryMove>) 53 51 procedure SaveToRegistry(Reg: TRegistryEx; RegContext: TRegistryContext); 54 52 procedure LoadFromRegistry(Reg: TRegistryEx; RegContext: TRegistryContext); … … 166 164 end; 167 165 168 TGames = class(T FPGObjectList<TGame>)166 TGames = class(TObjectList<TGame>) 169 167 end; 170 168 … … 196 194 197 195 uses 198 UCore, MetaCanvas;196 Core, MetaCanvas; 199 197 200 198 procedure Translate; … … 627 625 TopBarHeight := ScaleY(24, 96); 628 626 MetaCanvas.Brush.Style := bsSolid; 629 MetaCanvas.Brush.Color := Core. ThemeManager1.Theme.ColorControl;627 MetaCanvas.Brush.Color := Core.Core.ThemeManager1.Theme.ColorControl; 630 628 MetaCanvas.FillRect(0, 0, MetaCanvas.Width, MetaCanvas.Height); 631 629 632 630 ValueStr := SScore + ': ' + IntToStr(Score); 633 631 MetaCanvas.Brush.Style := bsClear; 634 MetaCanvas.Font.Color := Core. ThemeManager1.Theme.ColorControlText;632 MetaCanvas.Font.Color := Core.Core.ThemeManager1.Theme.ColorControlText; 635 633 MetaCanvas.Font.Height := Trunc(TopBarHeight * 0.7); 636 634 MetaCanvas.TextOut(ScaleY(16, 96), (TopBarHeight - MetaCanvas.TextHeight(ValueStr)) div 2, ValueStr); 637 635 638 636 ValueStr := STopScore + ': ' + IntToStr(TopScore); 639 MetaCanvas.Font.Color := Core. ThemeManager1.Theme.ColorControlText;637 MetaCanvas.Font.Color := Core.Core.ThemeManager1.Theme.ColorControlText; 640 638 MetaCanvas.Font.Height := Trunc(TopBarHeight * 0.7); 641 639 MetaCanvas.TextOut(ScaleY(136, 96), (TopBarHeight - MetaCanvas.TextHeight(ValueStr)) div 2, ValueStr); … … 1232 1230 function TGame.GetTileColor(Value: Integer): TColor; 1233 1231 begin 1234 if Core. ThemeManager1.Theme.Name = 'Dark' then begin1232 if Core.Core.ThemeManager1.Theme.Name = 'Dark' then begin 1235 1233 case Value of 1236 1234 0: Result := $222629; -
trunk/Game2048.lpi
r85 r86 96 96 </Unit0> 97 97 <Unit1> 98 <Filename Value=" UGame.pas"/>98 <Filename Value="Game.pas"/> 99 99 <IsPartOfProject Value="True"/> 100 100 </Unit1> 101 101 <Unit2> 102 <Filename Value="Forms/ UFormMain.pas"/>102 <Filename Value="Forms/FormMain.pas"/> 103 103 <IsPartOfProject Value="True"/> 104 104 <ComponentName Value="FormMain"/> … … 107 107 </Unit2> 108 108 <Unit3> 109 <Filename Value="Forms/ UFormNew.pas"/>109 <Filename Value="Forms/FormNew.pas"/> 110 110 <IsPartOfProject Value="True"/> 111 111 <ComponentName Value="FormNew"/> … … 114 114 </Unit3> 115 115 <Unit4> 116 <Filename Value="Forms/ UFormSettings.pas"/>116 <Filename Value="Forms/FormSettings.pas"/> 117 117 <IsPartOfProject Value="True"/> 118 118 <ComponentName Value="FormSettings"/> … … 121 121 </Unit4> 122 122 <Unit5> 123 <Filename Value=" UCore.pas"/>123 <Filename Value="Core.pas"/> 124 124 <IsPartOfProject Value="True"/> 125 125 <ComponentName Value="Core"/> … … 128 128 </Unit5> 129 129 <Unit6> 130 <Filename Value="Forms/ UFormHelp.pas"/>130 <Filename Value="Forms/FormHelp.pas"/> 131 131 <IsPartOfProject Value="True"/> 132 132 <ComponentName Value="FormHelp"/> … … 135 135 </Unit6> 136 136 <Unit7> 137 <Filename Value="Forms/ UFormComputer.pas"/>137 <Filename Value="Forms/FormComputer.pas"/> 138 138 <IsPartOfProject Value="True"/> 139 139 <ComponentName Value="FormComputer"/> … … 142 142 </Unit7> 143 143 <Unit8> 144 <Filename Value="Forms/ UFormHistory.pas"/>144 <Filename Value="Forms/FormHistory.pas"/> 145 145 <IsPartOfProject Value="True"/> 146 146 <ComponentName Value="FormHistory"/> -
trunk/Game2048.lpr
r82 r86 8 8 {$ENDIF} 9 9 Interfaces, SysUtils,// this includes the LCL widgetset 10 Forms, UGame, Common, UFormMain, UCore10 Forms, Game, Common, FormMain, Core 11 11 { you can add units after this }; 12 12 … … 28 28 Application.Scaled := True; 29 29 Application.Initialize; 30 Application.CreateForm(TCore, Core );31 Application.CreateForm(TFormMain, FormMain );30 Application.CreateForm(TCore, Core.Core); 31 Application.CreateForm(TFormMain, FormMain.FormMain); 32 32 Application.Run; 33 33 end. -
trunk/Languages/Game2048.cs.po
r85 r86 12 12 "X-Generator: Poedit 2.4.1\n" 13 13 14 #: core.sgameovercaption 15 #, fuzzy 16 msgctxt "core.sgameovercaption" 17 msgid "Lost" 18 msgstr "Prohra" 19 20 #: core.sgameovermessage 21 #, fuzzy 22 msgctxt "core.sgameovermessage" 23 msgid "Game over!" 24 msgstr "Konec hry!" 25 26 #: core.swincaption 27 #, fuzzy 28 msgctxt "core.swincaption" 29 msgid "Win" 30 msgstr "Vítězství" 31 32 #: core.swinmessage 33 #, object-pascal-format, fuzzy 34 msgctxt "core.swinmessage" 35 msgid "You reached %s and won! You can continue to play to get higher score." 36 msgstr "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 40 msgctxt "formhelp.scontrols" 41 msgid "Use arrow keys to slide blocks to one of board side." 42 msgstr "Použij klávesy šipek k posunutí bloků do jedné ze stran desky." 43 44 #: formhelp.severyturn 45 #, fuzzy 46 msgctxt "formhelp.severyturn" 47 msgid "Every turn, a new tile will randomly appear in an empty spot on the board with a value of either 2 or 4." 48 msgstr "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 52 msgctxt "formhelp.sparagraph1" 53 msgid "2048 is a single-player block sliding puzzle game." 54 msgstr "2048 je jednouživatelská logická hra s posouváním bloků." 55 56 #: formhelp.sparagraph2 57 #, fuzzy 58 msgctxt "formhelp.sparagraph2" 59 msgid "The game's objective is to slide numbered tiles on a grid to combine them to create a tile with the number 2048." 60 msgstr "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 64 msgctxt "formhelp.sundo" 65 msgid "You can undo one move back, if undo action is enabled." 66 msgstr "Můžete vrátit zpět jeden pohyb, pokud je akce vrátit zpět povolena." 67 68 #: formsettings.slanguagechangemessage 69 #, fuzzy 70 msgctxt "formsettings.slanguagechangemessage" 71 msgid "Interface language was changed. It may require restart of application." 72 msgstr "Jazyk rozhraní byl změněn. To může vyžadovat restart aplikace." 73 74 #: formsettings.slanguagechangetitle 75 #, fuzzy 76 msgctxt "formsettings.slanguagechangetitle" 77 msgid "Language change" 78 msgstr "Změna jazyka" 79 80 #: game.sscore 81 #, fuzzy 82 msgctxt "game.sscore" 83 msgid "Score" 84 msgstr "Skóre" 85 86 #: game.sskinalpha 87 #, fuzzy 88 msgctxt "game.sskinalpha" 89 msgid "Alpha" 90 msgstr "Písmena" 91 92 #: game.sskinbinary 93 #, fuzzy 94 msgctxt "game.sskinbinary" 95 msgid "Binary" 96 msgstr "Binární" 97 98 #: game.sskinlinear 99 #, fuzzy 100 msgctxt "game.sskinlinear" 101 msgid "Linear" 102 msgstr "Lineární" 103 104 #: game.sskinpoweroftwo 105 #, fuzzy 106 msgctxt "game.sskinpoweroftwo" 107 msgid "Power of two" 108 msgstr "Mocnina dvou" 109 110 #: game.sskinroman 111 #, fuzzy 112 msgctxt "game.sskinroman" 113 msgid "Roman" 114 msgstr "Římské číslice" 115 116 #: game.stileshouldbeempty 117 #, fuzzy 118 msgctxt "game.stileshouldbeempty" 119 msgid "Tile should be empty" 120 msgstr "Dlaždice by měla být prázdná" 121 122 #: game.stopscore 123 #, fuzzy 124 msgctxt "game.stopscore" 125 msgid "Top score" 126 msgstr "Nejvyšší skóre" 127 14 128 #: tcore.aabout.caption 15 129 msgctxt "tcore.aabout.caption" … … 165 279 msgstr "Téma:" 166 280 167 #: ucore.sgameovercaption168 msgctxt "ucore.sgameovercaption"169 msgid "Lost"170 msgstr "Prohra"171 172 #: ucore.sgameovermessage173 msgctxt "ucore.sgameovermessage"174 msgid "Game over!"175 msgstr "Konec hry!"176 177 #: ucore.swincaption178 msgctxt "ucore.swincaption"179 msgid "Win"180 msgstr "Vítězství"181 182 #: ucore.swinmessage183 #, object-pascal-format184 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.scontrols189 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.severyturn193 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.sparagraph1197 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.sparagraph2201 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.sundo205 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.slanguagechangemessage209 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.slanguagechangetitle213 msgid "Language change"214 msgstr "Změna jazyka"215 216 #: ugame.sscore217 msgid "Score"218 msgstr "Skóre"219 220 #: ugame.sskinalpha221 msgid "Alpha"222 msgstr "Písmena"223 224 #: ugame.sskinbinary225 msgid "Binary"226 msgstr "Binární"227 228 #: ugame.sskinlinear229 msgid "Linear"230 msgstr "Lineární"231 232 #: ugame.sskinpoweroftwo233 msgid "Power of two"234 msgstr "Mocnina dvou"235 236 #: ugame.sskinroman237 msgid "Roman"238 msgstr "Římské číslice"239 240 #: ugame.stileshouldbeempty241 msgid "Tile should be empty"242 msgstr "Dlaždice by měla být prázdná"243 244 #: ugame.stopscore245 msgid "Top score"246 msgstr "Nejvyšší skóre"247
Note:
See TracChangeset
for help on using the changeset viewer.