- Timestamp:
- Oct 26, 2022, 3:12:02 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BigMetro.lpi
r118 r121 161 161 <IsPartOfProject Value="True"/> 162 162 <ComponentName Value="Core"/> 163 <HasResources Value="True"/> 163 164 <ResourceBaseClass Value="DataModule"/> 164 165 </Unit14> -
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; -
trunk/Packages/Common/Languages/UDataFile.cs.po
r118 r121 19 19 msgid "Data file" 20 20 msgstr "Datový soubor" 21 -
trunk/Packages/Common/Languages/UTestCase.cs.po
r118 r121 23 23 msgid "Passed" 24 24 msgstr "Prošlo" 25 -
trunk/UEngine.pas
r119 r121 157 157 miFastTrain); 158 158 TMetroImprovementSet = set of TMetroImprovement; 159 TFullScrenChangeEvent = procedure (Sender: TObject; Active: Boolean) of object; 159 160 160 161 { TEngine } 161 162 162 TEngine = class 163 TEngine = class(TComponent) 163 164 private 164 165 FDarkMode: Boolean; 166 FFullScreen: Boolean; 165 167 FOnDarkModeChange: TNotifyEvent; 168 FOnExit: TNotifyEvent; 169 FOnFullScreenChange: TFullScrenChangeEvent; 166 170 FState: TGameState; 167 171 FTranslator: TTranslator; … … 219 223 UpdatedShape: TStationShape; Distance: Integer); 220 224 procedure SetDarkMode(AValue: Boolean); 225 procedure SetFullScreen(AValue: Boolean); 221 226 procedure SetState(AValue: TGameState); 222 227 procedure TrainsMovement; … … 304 309 procedure LoadFromRegistry; 305 310 procedure SaveToRegistry; 306 constructor Create ;311 constructor Create(AOwner: TComponent); override; 307 312 destructor Destroy; override; 308 313 procedure Tick; … … 313 318 published 314 319 property DarkMode: Boolean read FDarkMode write SetDarkMode; 320 property FullScreen: Boolean read FFullScreen write SetFullScreen; 315 321 property Translator: TTranslator read FTranslator write FTranslator; 316 322 property OnDarkModeChange: TNotifyEvent read FOnDarkModeChange 317 323 write FOnDarkModeChange; 324 property OnFullScreenChange: TFullScrenChangeEvent read FOnFullScreenChange 325 write FOnFullScreenChange; 326 property OnExit: TNotifyEvent read FOnExit write FOnExit; 318 327 end; 319 328 … … 349 358 350 359 uses 351 U FormMain, ULanguages;360 ULanguages; 352 361 353 362 resourcestring … … 1404 1413 end; 1405 1414 1415 procedure TEngine.SetFullScreen(AValue: Boolean); 1416 begin 1417 if FFullScreen = AValue then Exit; 1418 FFullScreen := AValue; 1419 if Assigned(FOnFullScreenChange) then 1420 FOnFullScreenChange(Self, FFullScreen); 1421 end; 1422 1406 1423 procedure TEngine.SetState(AValue: TGameState); 1407 1424 begin … … 1660 1677 procedure TEngine.MenuItemExit(Sender: TObject); 1661 1678 begin 1662 FormMain.Close;1679 if Assigned(FOnExit) then FOnExit(Self); 1663 1680 end; 1664 1681 … … 1739 1756 BackgroundColor := Colors.MenuItemBackground; 1740 1757 BackgroundSelectedColor := Colors.MenuItemBackgroundSelected; 1741 Checked := F ormMain.FullScreen;1758 Checked := FullScreen; 1742 1759 end; 1743 1760 with AddButton(SBack, MenuItemBack) do begin … … 1883 1900 procedure TEngine.FullScreenChanged(Sender: TObject); 1884 1901 begin 1885 FormMain.FullScreen := TMenuItemCheckBox(Sender).Checked; 1886 with TPersistentForm.Create(nil) do 1887 try 1888 Form := FormMain; 1889 SetFullScreen(FormMain.FullScreen); 1890 finally 1891 Free; 1892 end; 1902 FullScreen := TMenuItemCheckBox(Sender).Checked; 1893 1903 end; 1894 1904 … … 3362 3372 end; 3363 3373 3364 constructor TEngine.Create; 3365 begin 3374 constructor TEngine.Create(AOwner: TComponent); 3375 begin 3376 inherited; 3366 3377 ImprovementImageSize := ScaleX(64, 96); 3367 3378 IconSize := ScaleX(32, 96); -
trunk/UTestCases.pas
r118 r121 65 65 begin 66 66 inherited; 67 Engine := TEngine.Create ;67 Engine := TEngine.Create(nil); 68 68 end; 69 69
Note:
See TracChangeset
for help on using the changeset viewer.