Changeset 86 for trunk/Forms
- Timestamp:
- Jun 7, 2024, 12:47:11 PM (5 months ago)
- Location:
- trunk/Forms
- Files:
-
- 18 moved
Legend:
- Unmodified
- Added
- Removed
-
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;
Note:
See TracChangeset
for help on using the changeset viewer.