Changeset 63
- Timestamp:
- Nov 26, 2020, 1:18:19 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMain.lfm
r62 r63 8 8 ClientWidth = 1276 9 9 DesignTimePPI = 144 10 OnActivate = FormActivate 11 OnClose = FormClose 10 12 OnCreate = FormCreate 11 13 OnDestroy = FormDestroy 12 14 OnKeyPress = FormKeyPress 15 OnKeyUp = FormKeyUp 13 16 OnShow = FormShow 14 17 LCLVersion = '2.0.10.0' 15 WindowState = wsMaximized16 18 object PaintBox1: TPaintBox 17 19 Left = 0 … … 57 59 Top = 460 58 60 end 61 object PersistentForm1: TPersistentForm 62 MinVisiblePart = 50 63 EntireVisible = False 64 Left = 488 65 Top = 536 66 end 59 67 end -
trunk/Forms/UFormMain.pas
r62 r63 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus, 9 ExtCtrls, UEngine, LCLType, types, UTranslator, UApplicationInfo, URegistry; 9 ExtCtrls, UEngine, LCLType, types, UTranslator, UApplicationInfo, URegistry, 10 UPersistentForm; 10 11 11 12 type … … 16 17 ApplicationInfo1: TApplicationInfo; 17 18 PaintBox1: TPaintBox; 19 PersistentForm1: TPersistentForm; 18 20 Timer1: TTimer; 19 21 Translator1: TTranslator; 22 procedure FormActivate(Sender: TObject); 23 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 20 24 procedure FormCreate(Sender: TObject); 21 25 procedure FormDestroy(Sender: TObject); 22 26 procedure FormKeyPress(Sender: TObject; var Key: char); 27 procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); 23 28 procedure FormShow(Sender: TObject); 24 29 procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; … … 36 41 procedure Timer1Timer(Sender: TObject); 37 42 private 43 Initialized: Boolean; 38 44 procedure LoadConfig; 39 45 procedure SaveConfig; 40 46 public 47 FullScreen: Boolean; 41 48 Engine: TEngine; 42 49 procedure EraseBackground(DC: HDC); override; … … 45 52 var 46 53 FormMain: TFormMain; 54 47 55 48 56 implementation … … 63 71 end; 64 72 73 procedure TFormMain.FormActivate(Sender: TObject); 74 begin 75 if not Initialized then begin 76 Initialized := True; 77 end; 78 end; 79 80 procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction); 81 begin 82 PersistentForm1.Save(Self); 83 end; 84 65 85 procedure TFormMain.FormDestroy(Sender: TObject); 66 86 begin … … 71 91 procedure TFormMain.FormKeyPress(Sender: TObject; var Key: char); 72 92 begin 73 if (Key = #32)then begin93 if Key = #32 then begin 74 94 if Engine.State = gsRunning then Engine.State := gsPaused 75 95 else if Engine.State = gsPaused then Engine.State := gsRunning; … … 77 97 end; 78 98 99 procedure TFormMain.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState 100 ); 101 const 102 KeyF11 = 122; 103 begin 104 if Key = KeyF11 then begin 105 FormMain.FullScreen := not FormMain.FullScreen; 106 FormMain.PersistentForm1.SetFullScreen(FormMain.FullScreen); 107 end; 108 end; 109 79 110 procedure TFormMain.FormShow(Sender: TObject); 80 111 begin 112 PersistentForm1.RegistryContext := ApplicationInfo1.GetRegistryContext; 113 PersistentForm1.Load(Self, False, True); 81 114 Randomize; 82 115 Engine.ImagePassenger.Picture.Assign(FormImages.ImagePassenger.Picture); -
trunk/Languages/BigMetro.cs.po
r62 r63 41 41 msgstr "Nulové přiblížení není povoleno" 42 42 43 #: umenu.sautomatic 44 msgid "Automatic" 45 msgstr "Automaticky" 46 43 47 #: umenu.sback 44 48 msgid "Back" … … 67 71 msgstr "Odejít" 68 72 73 #: umenu.sfullscreen 74 msgid "Full screen" 75 msgstr "Celá obrazovka" 76 69 77 #: umenu.slanguage 70 #, fuzzy71 #| msgid "Jazyk"72 78 msgid "Language" 73 79 msgstr "Jazyk" … … 82 88 msgid "Play" 83 89 msgstr "Hrát" 84 -
trunk/Languages/BigMetro.po
r62 r63 31 31 msgstr "" 32 32 33 #: umenu.sautomatic 34 msgid "Automatic" 35 msgstr "" 36 33 37 #: umenu.sback 34 38 msgid "Back" … … 57 61 msgstr "" 58 62 63 #: umenu.sfullscreen 64 msgid "Full screen" 65 msgstr "" 66 59 67 #: umenu.slanguage 60 68 msgid "Language" -
trunk/Packages/Common/UCommon.pas
r55 r63 8 8 {$ifdef Windows}Windows,{$endif} 9 9 {$ifdef Linux}baseunix,{$endif} 10 Classes, SysUtils, StrUtils, Dialogs, Process, LCLIntf, 10 Classes, SysUtils, StrUtils, Dialogs, Process, LCLIntf, LCLType, Forms, Controls, 11 11 FileUtil; //, ShFolder, ShellAPI; 12 12 -
trunk/Packages/Common/UPersistentForm.pas
r55 r63 3 3 {$mode delphi} 4 4 5 // Date: 20 15-04-185 // Date: 2020-11-26 6 6 7 7 interface … … 9 9 uses 10 10 Classes, SysUtils, Forms, URegistry, LCLIntf, Registry, Controls, ComCtrls, 11 ExtCtrls ;11 ExtCtrls, LCLType; 12 12 13 13 type … … 26 26 FormRestoredSize: TRect; 27 27 FormWindowState: TWindowState; 28 FormFullScreen: Boolean; 28 29 Form: TForm; 29 30 procedure LoadFromRegistry(RegistryContext: TRegistryContext); … … 31 32 function CheckEntireVisible(Rect: TRect): TRect; 32 33 function CheckPartVisible(Rect: TRect; Part: Integer): TRect; 33 procedure Load(Form: TForm; DefaultMaximized: Boolean = False); 34 procedure Load(Form: TForm; DefaultMaximized: Boolean = False; 35 DefaultFullScreen: Boolean = False); 34 36 procedure Save(Form: TForm); 35 37 constructor Create(AOwner: TComponent); override; 38 procedure SetFullScreen(State: Boolean); 36 39 property RegistryContext: TRegistryContext read FRegistryContext 37 40 write FRegistryContext; … … 43 46 procedure Register; 44 47 48 45 49 implementation 46 47 50 48 51 procedure Register; … … 169 172 + FormRestoredSize.Top; 170 173 // Other state 171 FormWindowState := TWindowState(ReadIntegerWithDefault('WindowState', Integer(wsNormal))); 174 FormWindowState := TWindowState(ReadIntegerWithDefault('WindowState', Integer(FormWindowState))); 175 FormFullScreen := ReadBoolWithDefault('FullScreen', FormFullScreen); 172 176 finally 173 177 Free; … … 193 197 // Other state 194 198 WriteInteger('WindowState', Integer(FormWindowState)); 199 WriteBool('FullScreen', FormFullScreen); 195 200 finally 196 201 Free; … … 250 255 end; 251 256 252 procedure TPersistentForm.Load(Form: TForm; DefaultMaximized: Boolean = False); 257 procedure TPersistentForm.Load(Form: TForm; DefaultMaximized: Boolean = False; 258 DefaultFullScreen: Boolean = False); 253 259 begin 254 260 Self.Form := Form; … … 258 264 FormRestoredSize := Bounds((Screen.Width - Form.Width) div 2, 259 265 (Screen.Height - Form.Height) div 2, Form.Width, Form.Height); 266 FormWindowState := Form.WindowState; 267 FormFullScreen := DefaultFullScreen; 260 268 261 269 LoadFromRegistry(RegistryContext); … … 277 285 Form.BoundsRect := FormNormalSize; 278 286 end; 287 if FormFullScreen then SetFullScreen(True); 279 288 LoadControl(Form); 280 289 end; … … 284 293 Self.Form := Form; 285 294 FormNormalSize := Bounds(Form.Left, Form.Top, Form.Width, Form.Height); 286 FormRestoredSize := Bounds(Form.RestoredLeft, Form.RestoredTop, Form.RestoredWidth, 287 Form.RestoredHeight); 295 if not FormFullScreen then 296 FormRestoredSize := Bounds(Form.RestoredLeft, Form.RestoredTop, Form.RestoredWidth, 297 Form.RestoredHeight); 288 298 FormWindowState := Form.WindowState; 289 299 SaveToRegistry(RegistryContext); … … 300 310 end; 301 311 312 procedure TPersistentForm.SetFullScreen(State: Boolean); 313 begin 314 if State then begin 315 FormFullScreen := True; 316 FormRestoredSize := Bounds(Form.RestoredLeft, Form.RestoredTop, Form.RestoredWidth, 317 Form.RestoredHeight); 318 ShowWindow(Form.Handle, SW_SHOWFULLSCREEN); 319 end else begin 320 FormFullScreen := False; 321 if Form.WindowState = wsNormal then begin 322 ShowWindow(Form.Handle, SW_SHOWNORMAL); 323 //Form.BoundsRect := FormRestoredSize; 324 end else if Form.WindowState = wsMaximized then ShowWindow(Form.Handle, SW_SHOWMAXIMIZED); 325 end; 326 end; 327 302 328 end. 303 329 -
trunk/UEngine.pas
r62 r63 301 301 procedure DarkModeChanged(Sender: TObject); 302 302 procedure LanguageChanged(Sender: TObject); 303 procedure FullScreenChanged(Sender: TObject); 303 304 procedure InitMenus; 304 305 public … … 1883 1884 NewLanguage: TLanguage; 1884 1885 begin 1885 NewLanguage := TLanguage(TMenuItemComboBox( MenuOptions.Items[0]).States.Objects[TMenuItemComboBox(MenuOptions.Items[0]).Index]);1886 NewLanguage := TLanguage(TMenuItemComboBox(Sender).States.Objects[TMenuItemComboBox(Sender).Index]); 1886 1887 if FormMain.Translator1.Language <> NewLanguage then begin 1887 1888 FormMain.Translator1.Language := NewLanguage; … … 1889 1890 InitMenus; 1890 1891 end; 1892 end; 1893 1894 procedure TEngine.FullScreenChanged(Sender: TObject); 1895 begin 1896 FormMain.FullScreen := TMenuItemCheckBox(Sender).Checked; 1897 FormMain.PersistentForm1.SetFullScreen(FormMain.FullScreen); 1891 1898 end; 1892 1899 … … 1908 1915 end; 1909 1916 AddCheckBox(SDarkMode, DarkModeChanged); 1917 with AddCheckBox(SFullScreen, FullScreenChanged) do begin 1918 Checked := FormMain.FullScreen; 1919 end; 1910 1920 AddButton(SBack, MenuItemBack); 1911 1921 end; -
trunk/UMenu.pas
r62 r63 85 85 SEnglish = 'English'; 86 86 SBack = 'Back'; 87 SAutomatic = 'Automatic'; 88 SFullScreen = 'Full screen'; 87 89 88 90 … … 133 135 134 136 procedure TMenuItemComboBox.Paint(Canvas: TCanvas; P: TPoint); 137 var 138 OutputText: string; 135 139 begin 136 140 if Selected then Canvas.Brush.Color := $e78C31 137 141 else Canvas.Brush.Color := $f7bC61; 138 Bounds := Classes.Bounds(P.X, P.Y, Canvas.TextWidth(States[Index]), Canvas.TextHeight(States[Index])); 139 Canvas.TextOut(P.X, P.Y, States[Index]); 142 OutputText := Text + ': ' + States[Index]; 143 Bounds := Classes.Bounds(P.X, P.Y, Canvas.TextWidth(OutputText), Canvas.TextHeight(OutputText)); 144 Canvas.TextOut(P.X, P.Y, OutputText); 140 145 end; 141 146 … … 159 164 if (Items[I] is TMenuItemButton) then begin 160 165 if Assigned(TMenuItemButton(Items[I]).FOnClick) then 161 TMenuItemButton(Items[I]).FOnClick( nil)166 TMenuItemButton(Items[I]).FOnClick(Items[I]); 162 167 end else 163 168 if (Items[I] is TMenuItemCheckBox) then begin 164 169 (Items[I] as TMenuItemCheckBox).Checked := not (Items[I] as TMenuItemCheckBox).Checked; 165 170 if Assigned((Items[I] as TMenuItemCheckBox).FOnChanged) then 166 (Items[I] as TMenuItemCheckBox).FOnChanged( nil);171 (Items[I] as TMenuItemCheckBox).FOnChanged(Items[I]); 167 172 end else 168 173 if (Items[I] is TMenuItemComboBox) then begin … … 170 175 (Items[I] as TMenuItemComboBox).States.Count; 171 176 if Assigned((Items[I] as TMenuItemComboBox).FOnChanged) then 172 (Items[I] as TMenuItemComboBox).FOnChanged( nil);177 (Items[I] as TMenuItemComboBox).FOnChanged(Items[I]); 173 178 end; 174 179 end;
Note:
See TracChangeset
for help on using the changeset viewer.