Changeset 118
- Timestamp:
- Oct 23, 2022, 10:55:55 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 11 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BigMetro.lpi
r117 r118 89 89 </Item2> 90 90 </RequiredPackages> 91 <Units Count="1 2">91 <Units Count="16"> 92 92 <Unit0> 93 93 <Filename Value="BigMetro.lpr"/> … … 144 144 <IsPartOfProject Value="True"/> 145 145 </Unit11> 146 <Unit12> 147 <Filename Value="Forms/UFormTestCase.pas"/> 148 <IsPartOfProject Value="True"/> 149 <ComponentName Value="FormTestCase"/> 150 <ResourceBaseClass Value="Form"/> 151 </Unit12> 152 <Unit13> 153 <Filename Value="Forms/UFormTest.pas"/> 154 <IsPartOfProject Value="True"/> 155 <ComponentName Value="FormTest"/> 156 <HasResources Value="True"/> 157 <ResourceBaseClass Value="Form"/> 158 </Unit13> 159 <Unit14> 160 <Filename Value="UCore.pas"/> 161 <IsPartOfProject Value="True"/> 162 <ComponentName Value="Core"/> 163 <ResourceBaseClass Value="DataModule"/> 164 </Unit14> 165 <Unit15> 166 <Filename Value="UTestCases.pas"/> 167 <IsPartOfProject Value="True"/> 168 </Unit15> 146 169 </Units> 147 170 </ProjectOptions> -
trunk/BigMetro.lpr
r93 r118 8 8 {$ENDIF} 9 9 Interfaces, // this includes the LCL widgetset 10 Forms, SysUtils, UFormMain, UFormImages, Common, UMenu, UControls, 11 UMetroPassenger, UColors, UView, URiver, UCity; 10 Forms, SysUtils, UFormMain, UFormImages, UFormTestCase, UFormTest, Common, 11 UMenu, UControls, UMetroPassenger, UColors, UView, URiver, UCity, UCore, 12 UTestCases; 12 13 13 14 {$R *.res} … … 28 29 Application.Scaled:=True; 29 30 Application.Initialize; 31 Application.CreateForm(TCore, Core); 30 32 Application.CreateForm(TFormMain, FormMain); 31 33 Application.CreateForm(TFormImages, FormImages); -
trunk/Forms/UFormMain.lfm
r112 r118 37 37 Top = 21 38 38 end 39 object Translator1: TTranslator40 POFilesFolder = 'Languages'41 OnTranslate = Translator1Translate42 Left = 49643 Top = 35844 end45 39 object ApplicationInfo1: TApplicationInfo 46 40 Identification = 1 … … 61 55 Top = 460 62 56 end 63 object PersistentForm1: TPersistentForm64 MinVisiblePart = 5065 EntireVisible = False66 Left = 48867 Top = 53668 end69 57 end -
trunk/Forms/UFormMain.pas
r100 r118 15 15 ApplicationInfo1: TApplicationInfo; 16 16 PaintBox1: TPaintBox; 17 PersistentForm1: TPersistentForm;18 17 Timer1: TTimer; 19 Translator1: TTranslator;20 18 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 21 19 procedure FormCreate(Sender: TObject); … … 60 58 61 59 uses 62 UFormImages, UPixelPointer ;60 UFormImages, UPixelPointer, UCore, UFormTest, UTestCases; 63 61 64 62 resourcestring … … 79 77 {$IFDEF UNIX} 80 78 // If installed in UNIX system then use installation directory for po files 81 if not DirectoryExists( Translator1.POFilesFolder) and DirectoryExists(UnixLanguagesDir) then82 Translator1.POFilesFolder := UnixLanguagesDir;79 if not DirectoryExists(Core.Translator1.POFilesFolder) and DirectoryExists(UnixLanguagesDir) then 80 Core.Translator1.POFilesFolder := UnixLanguagesDir; 83 81 {$ENDIF} 84 82 85 83 Engine := TEngine.Create; 86 84 Engine.RegistryContext := ApplicationInfo1.GetRegistryContext; 85 Engine.Translator := Core.Translator1; 87 86 LoadConfig; 88 87 // Load cities after language core is loaded to have city names translated … … 95 94 procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction); 96 95 begin 97 PersistentForm1.Save(Self);96 Core.PersistentForm1.Save(Self); 98 97 end; 99 98 … … 116 115 const 117 116 KeyF11 = 122; 117 {$IFDEF DEBUG} 118 KeyF12 = 123; 119 {$ENDIF} 118 120 begin 119 121 if Key = KeyF11 then begin 120 122 FullScreen := not FullScreen; 121 PersistentForm1.SetFullScreen(FormMain.FullScreen);123 Core.PersistentForm1.SetFullScreen(FormMain.FullScreen); 122 124 end else 125 {$IFDEF DEBUG} 126 if Key = KeyF12 then begin 127 FormTest := TFormTest.Create(nil); 128 try 129 FormTest.TestCases := InitTestCases; 130 try 131 FormTest.ShowModal; 132 finally 133 FormTest.TestCases.Free; 134 end; 135 finally 136 FormTest.Free; 137 end; 138 end else 139 {$ENDIF} 123 140 Engine.KeyUp(Key); 124 141 end; … … 128 145 if not Initialized then begin 129 146 Initialized := True; 130 PersistentForm1.RegistryContext := ApplicationInfo1.GetRegistryContext;131 PersistentForm1.Load(Self, False, True);132 FullScreen := PersistentForm1.FormFullScreen;147 Core.PersistentForm1.RegistryContext := ApplicationInfo1.GetRegistryContext; 148 Core.PersistentForm1.Load(Self, False, True); 149 FullScreen := Core.PersistentForm1.FormFullScreen; 133 150 Engine.InitMenus; 134 151 Engine.OnDarkModeChange := DarkModeChange; … … 214 231 if ValueExists('LanguageCode') then begin 215 232 LangCode := ReadStringWithDefault('LanguageCode', ''); 216 Translator1.Language :=Translator1.Languages.SearchByCode(LangCode);217 end else Translator1.Language :=Translator1.Languages.SearchByCode('');233 Core.Translator1.Language := Core.Translator1.Languages.SearchByCode(LangCode); 234 end else Core.Translator1.Language := Core.Translator1.Languages.SearchByCode(''); 218 235 Engine.LoadFromRegistry; 219 236 finally … … 228 245 CurrentContext := ApplicationInfo1.GetRegistryContext; 229 246 230 if Assigned( Translator1.Language) and (Translator1.Language.Code <> '') then231 WriteString('LanguageCode', Translator1.Language.Code)247 if Assigned(Core.Translator1.Language) and (Core.Translator1.Language.Code <> '') then 248 WriteString('LanguageCode', Core.Translator1.Language.Code) 232 249 else DeleteValue('LanguageCode'); 233 250 Engine.SaveToRegistry; -
trunk/Languages/BigMetro.cs.po
r117 r118 25 25 msgstr "Big Metro" 26 26 27 #: tformtest.arun.caption 28 msgctxt "tformtest.arun.caption" 29 msgid "Run" 30 msgstr "Spustit" 31 32 #: tformtest.ashow.caption 33 msgid "Show" 34 msgstr "Ukázat" 35 36 #: tformtest.buttonrun.caption 37 msgctxt "tformtest.buttonrun.caption" 38 msgid "Run" 39 msgstr "Spustit" 40 41 #: tformtest.caption 42 msgid "Test" 43 msgstr "Test" 44 45 #: tformtest.labelresult.caption 46 msgid " " 47 msgstr " " 48 49 #: tformtest.listviewtestcases.columns[0].caption 50 msgid "Name" 51 msgstr "Jméno" 52 53 #: tformtest.listviewtestcases.columns[1].caption 54 msgid "Result" 55 msgstr "Výsledek" 56 57 #: tformtestcase.caption 58 msgid "Test case" 59 msgstr "Testový případ" 60 27 61 #: uengine.sautomatic 28 62 msgctxt "uengine.sautomatic" … … 265 299 msgid "Zero zoom not allowed" 266 300 msgstr "Nulové přiblížení není povoleno" 267 -
trunk/Languages/BigMetro.de.po
r117 r118 25 25 msgstr "Big Metro" 26 26 27 #: tformtest.arun.caption 28 msgctxt "tformtest.arun.caption" 29 msgid "Run" 30 msgstr "" 31 32 #: tformtest.ashow.caption 33 msgid "Show" 34 msgstr "" 35 36 #: tformtest.buttonrun.caption 37 msgctxt "tformtest.buttonrun.caption" 38 msgid "Run" 39 msgstr "" 40 41 #: tformtest.caption 42 msgid "Test" 43 msgstr "" 44 45 #: tformtest.labelresult.caption 46 msgid " " 47 msgstr "" 48 49 #: tformtest.listviewtestcases.columns[0].caption 50 msgid "Name" 51 msgstr "" 52 53 #: tformtest.listviewtestcases.columns[1].caption 54 msgid "Result" 55 msgstr "" 56 57 #: tformtestcase.caption 58 msgid "Test case" 59 msgstr "" 60 27 61 #: uengine.sautomatic 28 62 msgctxt "uengine.sautomatic" -
trunk/Languages/BigMetro.fr.po
r117 r118 25 25 msgstr "Big Metro" 26 26 27 #: tformtest.arun.caption 28 msgctxt "tformtest.arun.caption" 29 msgid "Run" 30 msgstr "" 31 32 #: tformtest.ashow.caption 33 msgid "Show" 34 msgstr "" 35 36 #: tformtest.buttonrun.caption 37 msgctxt "tformtest.buttonrun.caption" 38 msgid "Run" 39 msgstr "" 40 41 #: tformtest.caption 42 msgid "Test" 43 msgstr "" 44 45 #: tformtest.labelresult.caption 46 msgid " " 47 msgstr "" 48 49 #: tformtest.listviewtestcases.columns[0].caption 50 msgid "Name" 51 msgstr "" 52 53 #: tformtest.listviewtestcases.columns[1].caption 54 msgid "Result" 55 msgstr "" 56 57 #: tformtestcase.caption 58 msgid "Test case" 59 msgstr "" 60 27 61 #: uengine.sautomatic 28 62 msgctxt "uengine.sautomatic" -
trunk/Languages/BigMetro.pot
r117 r118 15 15 msgstr "" 16 16 17 #: tformtest.arun.caption 18 msgctxt "tformtest.arun.caption" 19 msgid "Run" 20 msgstr "" 21 22 #: tformtest.ashow.caption 23 msgid "Show" 24 msgstr "" 25 26 #: tformtest.buttonrun.caption 27 msgctxt "tformtest.buttonrun.caption" 28 msgid "Run" 29 msgstr "" 30 31 #: tformtest.caption 32 msgid "Test" 33 msgstr "" 34 35 #: tformtest.labelresult.caption 36 msgid " " 37 msgstr "" 38 39 #: tformtest.listviewtestcases.columns[0].caption 40 msgid "Name" 41 msgstr "" 42 43 #: tformtest.listviewtestcases.columns[1].caption 44 msgid "Result" 45 msgstr "" 46 47 #: tformtestcase.caption 48 msgid "Test case" 49 msgstr "" 50 17 51 #: uengine.sautomatic 18 52 msgctxt "uengine.sautomatic" -
trunk/UEngine.pas
r110 r118 9 9 Classes, SysUtils, Graphics, Controls, ExtCtrls, Math, DateUtils, Types, 10 10 URegistry, UMetaCanvas, Generics.Collections, Generics.Defaults, UMenu, 11 UControls, UMetroPassenger, UColors, UView, URiver, UTrack, UCity, UGeometric; 11 UControls, UMetroPassenger, UColors, UView, URiver, UTrack, UCity, UGeometric, 12 UPersistentForm, UTranslator; 12 13 13 14 type … … 164 165 FOnDarkModeChange: TNotifyEvent; 165 166 FState: TGameState; 167 FTranslator: TTranslator; 166 168 LastMousePos: TPoint; 167 169 LastFocusedStation: TMapStation; … … 246 248 procedure EvaluateImprovement(Improvement: TMetroImprovement); 247 249 public 250 // Test 251 function GetSelectedOrUnusedMetroLine: TMetroLine; 252 public 248 253 AvailableTerminals: Integer; 249 254 Week: Integer; … … 304 309 procedure Paint(Canvas: TCanvas; CanvasSize: TPoint); 305 310 property Time: TDateTime read FTime; 306 property DarkMode: Boolean read FDarkMode write SetDarkMode;307 311 property State: TGameState read FState write SetState; 308 312 property ServedDaysCount: Integer read GetServedDaysCount; 313 published 314 property DarkMode: Boolean read FDarkMode write SetDarkMode; 315 property Translator: TTranslator read FTranslator write FTranslator; 309 316 property OnDarkModeChange: TNotifyEvent read FOnDarkModeChange 310 317 write FOnDarkModeChange; … … 1711 1718 BackgroundColor := Colors.MenuItemBackground; 1712 1719 BackgroundSelectedColor := Colors.MenuItemBackgroundSelected; 1713 FormMain.Translator1.LanguageListToStrings(States); 1714 Index := States.IndexOfObject(FormMain.Translator1.Language); 1720 if Assigned(Translator) then begin 1721 Translator.LanguageListToStrings(States); 1722 Index := States.IndexOfObject(Translator.Language); 1723 end; 1715 1724 if Index = -1 then Index := 0; 1716 1725 end; … … 1859 1868 begin 1860 1869 NewLanguage := TLanguage(TMenuItemComboBox(Sender).States.Objects[TMenuItemComboBox(Sender).Index]); 1861 if FormMain.Translator1.Language <> NewLanguagethen begin1862 FormMain.Translator1.Language := NewLanguage;1863 FormMain.Translator1.Translate;1870 if Assigned(Translator) and (Translator.Language <> NewLanguage) then begin 1871 Translator.Language := NewLanguage; 1872 Translator.Translate; 1864 1873 InitMenus; 1865 1874 … … 1874 1883 begin 1875 1884 FormMain.FullScreen := TMenuItemCheckBox(Sender).Checked; 1876 FormMain.PersistentForm1.SetFullScreen(FormMain.FullScreen); 1885 with TPersistentForm.Create(nil) do 1886 try 1887 SetFullScreen(FormMain.FullScreen); 1888 finally 1889 Free; 1890 end; 1877 1891 end; 1878 1892 … … 1963 1977 miTerminal: Inc(AvailableTerminals); 1964 1978 end; 1979 end; 1980 1981 function TEngine.GetSelectedOrUnusedMetroLine: TMetroLine; 1982 begin 1983 if Assigned(SelectedLine) and (SelectedLine.LineStations.Count = 0) then 1984 Result := SelectedLine 1985 else Result := GetUnusedLine; 1965 1986 end; 1966 1987 … … 3114 3135 Station := GetStationOnPos(View.PointDestToSrc(Position)); 3115 3136 if Assigned(Station) then begin 3116 if Assigned(SelectedLine) and (SelectedLine.LineStations.Count = 0) then NewLine := SelectedLine 3117 else NewLine := GetUnusedLine; 3137 NewLine := GetSelectedOrUnusedMetroLine; 3118 3138 if Assigned(NewLine) then begin 3119 3139 NewLine.ConnectStation(Station, nil, nil);
Note:
See TracChangeset
for help on using the changeset viewer.