Changeset 121 for trunk/Forms
- Timestamp:
- Oct 26, 2022, 3:12:02 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMain.pas
r118 r121 38 38 private 39 39 Initialized: Boolean; 40 procedure FullScreenChangeExecute(Sender: TObject; Active: Boolean); 41 procedure ExitExecute(Sender: TObject); 40 42 procedure LoadConfig; 41 43 procedure SaveConfig; 42 44 procedure LoadGraphicAssets; 43 procedure DarkModeChange (Sender: TObject);45 procedure DarkModeChangeExecute(Sender: TObject); 44 46 procedure CopyImage(DestBmp: TBitmap; SourceBmp: TBitmap; Grayed: Boolean = False); 45 47 public 46 FullScreen: Boolean;47 48 Engine: TEngine; 48 49 procedure EraseBackground(DC: HDC); override; … … 81 82 {$ENDIF} 82 83 83 Engine := TEngine.Create ;84 Engine := TEngine.Create(nil); 84 85 Engine.RegistryContext := ApplicationInfo1.GetRegistryContext; 85 86 Engine.Translator := Core.Translator1; 87 Engine.OnFullScreenChange := FullScreenChangeExecute; 88 Engine.OnExit := ExitExecute; 86 89 LoadConfig; 87 90 // Load cities after language core is loaded to have city names translated … … 92 95 end; 93 96 94 procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);95 begin96 Core.PersistentForm1.Save(Self);97 end;98 99 97 procedure TFormMain.FormDestroy(Sender: TObject); 100 98 begin 101 99 SaveConfig; 102 100 FreeAndNil(Engine); 101 end; 102 103 procedure TFormMain.FormShow(Sender: TObject); 104 begin 105 if not Initialized then begin 106 Initialized := True; 107 Core.PersistentForm1.RegistryContext := ApplicationInfo1.GetRegistryContext; 108 Core.PersistentForm1.Load(Self, False, True); 109 Engine.FullScreen := Core.PersistentForm1.FormFullScreen; 110 Engine.InitMenus; 111 Engine.OnDarkModeChange := DarkModeChangeExecute; 112 Engine.Map.Size := Point(PaintBox1.Width, PaintBox1.Height); 113 Engine.View.DestRect := Rect(0, 0, PaintBox1.Width, PaintBox1.Height); 114 Engine.MainMenu; 115 LoadGraphicAssets; 116 end; 117 end; 118 119 procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction); 120 begin 121 Core.PersistentForm1.Save(Self); 103 122 end; 104 123 … … 120 139 begin 121 140 if Key = KeyF11 then begin 122 FullScreen := not FullScreen; 123 Core.PersistentForm1.SetFullScreen(FormMain.FullScreen); 141 Engine.FullScreen := not Engine.FullScreen; 124 142 end else 125 143 {$IFDEF DEBUG} … … 141 159 end; 142 160 143 procedure TFormMain.FormShow(Sender: TObject);144 begin145 if not Initialized then begin146 Initialized := True;147 Core.PersistentForm1.RegistryContext := ApplicationInfo1.GetRegistryContext;148 Core.PersistentForm1.Load(Self, False, True);149 FullScreen := Core.PersistentForm1.FormFullScreen;150 Engine.InitMenus;151 Engine.OnDarkModeChange := DarkModeChange;152 Engine.Map.Size := Point(PaintBox1.Width, PaintBox1.Height);153 Engine.View.DestRect := Rect(0, 0, PaintBox1.Width, PaintBox1.Height);154 Engine.MainMenu;155 LoadGraphicAssets;156 end;157 end;158 159 161 procedure TFormMain.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; 160 162 Shift: TShiftState; X, Y: Integer); … … 214 216 FormatSettings.ShortDayNames[6] := SFridayShort; 215 217 FormatSettings.ShortDayNames[7] := SSaturdayShort; 218 end; 219 220 procedure TFormMain.FullScreenChangeExecute(Sender: TObject; Active: Boolean); 221 begin 222 Core.PersistentForm1.SetFullScreen(Active); 223 end; 224 225 procedure TFormMain.ExitExecute(Sender: TObject); 226 begin 227 Close; 216 228 end; 217 229 … … 306 318 end; 307 319 308 procedure TFormMain.DarkModeChange (Sender: TObject);320 procedure TFormMain.DarkModeChangeExecute(Sender: TObject); 309 321 begin 310 322 LoadGraphicAssets;
Note:
See TracChangeset
for help on using the changeset viewer.