Changeset 100
- Timestamp:
- Sep 28, 2022, 7:14:22 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormImages.lfm
r98 r100 787 787 Stretch = True 788 788 end 789 object ImageAchievement: TImage 790 Left = 345 791 Height = 71 792 Top = 208 793 Width = 64 794 Picture.Data = { 795 1754506F727461626C654E6574776F726B47726170686963DD05000089504E47 796 0D0A1A0A0000000D49484452000000400000004008030000009DB781EC000002 797 0A504C5445000000000000000000000000000000000000000000000000000000 798 0000000000000000000000000000000000000000000000000000000000000000 799 0000000000000000000000000000000000000000000000000000000000000000 800 0000000000000000000000000000000000000000000000000000000000000000 801 0000000000000000000000000000000000000000000000000000000000000000 802 0000000000000000000000000000000000000000000000000000000000000000 803 0000000000000000000000000000000000000000000000000000000000000000 804 0000000000000000000000000000000000000000000000000000000000000000 805 0000000000000000000000000000000000000000000000000000000000000000 806 0000000000000000000000000000000000000000000000000000000000000000 807 0000000000000000000000000000000000000000000000000000000000000000 808 0000000000000000000000000000000000000000000000000000000000000000 809 0000000000000000000000000000000000000000000000000000000000000000 810 0000000000000000000000000000000000000000000000000000000000000000 811 0000000000000000000000000000000000000000000000000000000000000000 812 0000000000000000000000000000000000000000000000000000000000000000 813 000000000000000000000000000000884D8C6A000000AD74524E530001020304 814 050708090A0C0E0F101112131415161718191A1B1E202122242526282B2D2F30 815 313334353638393A3E414243454648494A4B4F51525357585A5C5E5F60616266 816 686A6C6D6E70727374757677797A7B7C7E7F8082838687888A8D909192949798 817 999A9B9C9FA0A1A3A4A7A8A9ABAEB0B2B3B4B5B6B8BCBEBFC1C3C4C8C9CACDCE 818 CFD2D3D4D5D6D7D8D9DADBDCDDDEE0E1E2E3E5E6E7E8E9EBECEEEFF0F1F2F3F4 819 F5F6F7F8FAFBFCFD5CCA7DDC000002D549444154789CED96E95B125114C60F22 820 26214A8B1564496A9B956161645656B6D966B6D12269B699A6A6660B569ADAA6 821 D91EEDA4AD24F03F76CE0C30C330772EF03C3DF6C1F7CB3D73CEFBFE9E99CB2C 822 004CEBFFD3AC5BAF3475C3C201D48639AAE5008EF100C73980A33CC0110EA08E 823 07D8CF085ABB8605F978802FE266DEB42A00DDBCA0521D0AC0935401030AC030 824 F6BEFAFDFE0985AFB58B01B8AB00F461AF00D745F1B680D51E8CEFCC459319D7 825 1E05A01D7B65B866C5FB2F0174C4357EE9D0548CC57905E024F67653F1526EFF 826 B81060C96779E71179AAB038A80050AF858ADEA8F56775699E38B3ACDE3119ED 827 5EA386070BA7025080BDE7D15311D5101BEA9A63CD7A3A1E088743B315007883 828 533BAE15D2E99E8D8C322E4A3D071EE7072397122732B96987FF48EE53E2A851 829 F6AB18F1782F169E048003BB3E0316FD92BD4D1CC9EE522F5DD0632C962700F4 830 B4FDBBB03824D90F8823B7D4A1B7C1265C1F24E401F661FF03EEBB2D14B3AF83 831 C2CE369B901035390F20FB1916DB5500D9F42076E27DE28DF9D75EC00D09346E 832 88357AD1D784EB48A60A00B692055F389561A6D603D4D0AABC0922EAA1D9095D 833 C6282B3FA4831ABAA55AD4F3601923D7F505552C80D324DC11834606000ADFD3 834 FCBB674C3D3F78F8132D4FF359797C9899672FE9BE461E20E72A271E6A9AA195 835 47950F69E5FB5672E22447FBB87ADAD7BC2C89382973D59E730FE3C35EF7167B 836 92E9887247E4F93B86D4D2A4E2DF52DE3F3FF53C408304E07D92D595F72D9A7F 837 979516002E4701A7D3CB83330A589126C014F9CE4DE8D30480D12C6866BAF9A9 838 5339EB3FDEB624019B59CF62DDBF05984A042DD606D84457AE0AA0E887607AAB 839 0DB827148152B553A80C260D50FB30A1EA93059C616D436B72806E1D0BB05404 840 54F819DA2902CA5879F3A808D012015ECF519FE96FD3698E6F74A17212C706EA 841 BB5E90A75FFD0523FB27132E491CE7CAC657D4F26BE4575B943837CBE72EE635 842 4E6B2AF4175050B7AFF09D59AE0000000049454E44AE426082 843 } 844 Proportional = True 845 Stretch = True 846 end 789 847 end -
trunk/Forms/UFormImages.pas
r96 r100 11 11 12 12 TFormImages = class(TForm) 13 ImageAchievement: TImage; 13 14 ImageLine: TImage; 14 15 ImageCarriage: TImage; -
trunk/Forms/UFormMain.lfm
r94 r100 9 9 Color = clBlack 10 10 DesignTimePPI = 144 11 OnActivate = FormActivate12 11 OnClose = FormClose 13 12 OnCreate = FormCreate -
trunk/Forms/UFormMain.pas
r96 r100 18 18 Timer1: TTimer; 19 19 Translator1: TTranslator; 20 procedure FormActivate(Sender: TObject);21 20 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 22 21 procedure FormCreate(Sender: TObject); … … 85 84 86 85 Engine := TEngine.Create; 86 Engine.RegistryContext := ApplicationInfo1.GetRegistryContext; 87 87 LoadConfig; 88 // Load cities after language core is loaded to have city names translated 89 Engine.InitCities; 90 Engine.LoadFromRegistry; 88 91 //PaintBox1.ControlStyle := [csOpaque]; 89 92 Randomize; 90 end;91 92 procedure TFormMain.FormActivate(Sender: TObject);93 begin94 93 end; 95 94 … … 217 216 Translator1.Language := Translator1.Languages.SearchByCode(LangCode); 218 217 end else Translator1.Language := Translator1.Languages.SearchByCode(''); 219 Engine.LoadFromRegistry (CurrentContext);218 Engine.LoadFromRegistry; 220 219 finally 221 220 Free; … … 232 231 WriteString('LanguageCode', Translator1.Language.Code) 233 232 else DeleteValue('LanguageCode'); 234 Engine.SaveToRegistry (CurrentContext);233 Engine.SaveToRegistry; 235 234 finally 236 235 Free; … … 260 259 CopyImage(Engine.ImageFastForward.Bitmap, FormImages.ImageFastForward.Picture.Bitmap); 261 260 CopyImage(Engine.ImageFastForward.BitmapDisabled, FormImages.ImageFastForward.Picture.Bitmap, True); 261 CopyImage(Engine.ImageAchievement.Bitmap, FormImages.ImageAchievement.Picture.Bitmap); 262 CopyImage(Engine.ImageAchievement.BitmapDisabled, FormImages.ImageAchievement.Picture.Bitmap, True); 262 263 if Engine.DarkMode then begin 263 264 BitmapInvert(Engine.ImagePassenger.Bitmap); … … 281 282 BitmapInvert(Engine.ImageFastForward.Bitmap); 282 283 BitmapInvert(Engine.ImageFastForward.BitmapDisabled); 284 BitmapInvert(Engine.ImageAchievement.Bitmap); 285 BitmapInvert(Engine.ImageAchievement.BitmapDisabled); 283 286 end; 284 287 Engine.ImageNewTrain.Bitmap.Assign(Engine.ImageLocomotive.Bitmap); -
trunk/Languages/BigMetro.cs.po
r99 r100 40 40 msgstr "Big Metro" 41 41 42 #: uengine.scareer 43 msgid "Career" 44 msgstr "Kariéra" 45 42 46 #: uengine.scarriage 43 47 msgid "Carriage" … … 172 176 msgstr "Stanice musí mít MapStation" 173 177 178 #: uengine.ssuccess 179 msgid "Success" 180 msgstr "Úspěch" 181 182 #: uengine.ssuccessreason 183 msgid "Your metro transported enough passengers and you have reached your goal for this city." 184 msgstr "Tvé metro přepravilo dostatek cestujících a dosáhl jsi tvého cíle pro toto město." 185 174 186 #: uengine.sterminal 175 187 msgid "Terminal" … … 187 199 msgid "Tunnel" 188 200 msgstr "Tunel" 201 202 #: uengine.sunlockedcity 203 #, object-pascal-format 204 msgid "City %s is now unlocked." 205 msgstr "Město %s je nyní odemčeno." 189 206 190 207 #: uengine.sweek -
trunk/Languages/BigMetro.de.po
r99 r100 43 43 msgstr "Big Metro" 44 44 45 #: uengine.scareer 46 msgid "Career" 47 msgstr "" 48 45 49 #: uengine.scarriage 46 50 msgid "Carriage" … … 187 191 msgstr "" 188 192 193 #: uengine.ssuccess 194 msgid "Success" 195 msgstr "" 196 197 #: uengine.ssuccessreason 198 msgid "Your metro transported enough passengers and you have reached your goal for this city." 199 msgstr "" 200 189 201 #: uengine.sterminal 190 202 msgid "Terminal" … … 201 213 #: uengine.stunnel 202 214 msgid "Tunnel" 215 msgstr "" 216 217 #: uengine.sunlockedcity 218 #, object-pascal-format 219 msgid "City %s is now unlocked." 203 220 msgstr "" 204 221 -
trunk/Languages/BigMetro.fr.po
r99 r100 43 43 msgstr "Big Metro" 44 44 45 #: uengine.scareer 46 msgid "Career" 47 msgstr "" 48 45 49 #: uengine.scarriage 46 50 msgid "Carriage" … … 187 191 msgstr "" 188 192 193 #: uengine.ssuccess 194 msgid "Success" 195 msgstr "" 196 197 #: uengine.ssuccessreason 198 msgid "Your metro transported enough passengers and you have reached your goal for this city." 199 msgstr "" 200 189 201 #: uengine.sterminal 190 202 msgid "Terminal" … … 201 213 #: uengine.stunnel 202 214 msgid "Tunnel" 215 msgstr "" 216 217 #: uengine.sunlockedcity 218 #, object-pascal-format 219 msgid "City %s is now unlocked." 203 220 msgstr "" 204 221 -
trunk/Languages/BigMetro.pot
r99 r100 30 30 msgstr "" 31 31 32 #: uengine.scareer 33 msgid "Career" 34 msgstr "" 35 32 36 #: uengine.scarriage 33 37 msgid "Carriage" … … 162 166 msgstr "" 163 167 168 #: uengine.ssuccess 169 msgid "Success" 170 msgstr "" 171 172 #: uengine.ssuccessreason 173 msgid "Your metro transported enough passengers and you have reached your goal for this city." 174 msgstr "" 175 164 176 #: uengine.sterminal 165 177 msgid "Terminal" … … 176 188 #: uengine.stunnel 177 189 msgid "Tunnel" 190 msgstr "" 191 192 #: uengine.sunlockedcity 193 #, object-pascal-format 194 msgid "City %s is now unlocked." 178 195 msgstr "" 179 196 -
trunk/UCity.pas
r93 r100 4 4 5 5 uses 6 Classes, SysUtils, G enerics.Collections;6 Classes, SysUtils, Graphics, Generics.Collections, URegistry; 7 7 8 8 type 9 10 { TCity } 11 9 12 TCity = class 13 SysName: string; 10 14 Name: string; 15 Population: Integer; 11 16 Locked: Boolean; 17 LineColors: array of TColor; 18 InitialLineCount: Integer; 12 19 PassengersCountToUnlock: Integer; 20 HighestServedPassengerCount: Integer; 21 HighestServedDaysCount: Integer; 22 procedure LoadFromRegistry(Context: TRegistryContext); 23 procedure SaveToRegistry(Context: TRegistryContext); 24 constructor Create; 13 25 end; 14 26 … … 16 28 17 29 TCities = class(TObjectList<TCity>) 18 function AddNew(Name: string): TCity; 30 function AddNew(SysName, Name: string; Population: Integer): TCity; 31 procedure LoadFromRegistry(Context: TRegistryContext); 32 procedure SaveToRegistry(Context: TRegistryContext); 19 33 end; 34 35 const 36 clDarkYellow = TColor($00dede); 37 clOrange = TColor($0080ff); 38 clBrown = TColor($003090); 39 clCyan = TColor($FFFF00); 40 clPink = TColor($ff69b4); 20 41 21 42 22 43 implementation 23 44 45 { TCity } 46 47 procedure TCity.LoadFromRegistry(Context: TRegistryContext); 48 begin 49 with TRegistryEx.Create do 50 try 51 CurrentContext := Context; 52 Locked := ReadBoolWithDefault('Locked', Locked); 53 HighestServedPassengerCount := ReadIntegerWithDefault('HighestServedPassengerCount', HighestServedPassengerCount); 54 HighestServedDaysCount := ReadIntegerWithDefault('HighestServedDaysCount', HighestServedDaysCount); 55 finally 56 Free; 57 end; 58 end; 59 60 procedure TCity.SaveToRegistry(Context: TRegistryContext); 61 begin 62 with TRegistryEx.Create do 63 try 64 CurrentContext := Context; 65 WriteBool('Locked', Locked); 66 WriteInteger('HighestServedPassengerCount', HighestServedPassengerCount); 67 WriteInteger('HighestServedDaysCount', HighestServedDaysCount); 68 finally 69 Free; 70 end; 71 end; 72 73 constructor TCity.Create; 74 begin 75 PassengersCountToUnlock := 500; 76 InitialLineCount := 1; 77 LineColors := [clBlue, clRed, clDarkYellow, clGreen, 78 clPurple, clGray, clOrange, clBrown, clCyan]; 79 end; 80 24 81 { TCities } 25 82 26 function TCities.AddNew( Name: string): TCity;83 function TCities.AddNew(SysName, Name: string; Population: Integer): TCity; 27 84 begin 28 85 Result := TCity.Create; 86 Result.SysName := SysName; 29 87 Result.Name := Name; 88 Result.Population := Population; 30 89 Add(Result); 90 end; 91 92 procedure TCities.LoadFromRegistry(Context: TRegistryContext); 93 var 94 City: TCity; 95 begin 96 for City in Self do begin 97 City.LoadFromRegistry(TRegistryContext.Create(Context.RootKey, Context.Key + '/' + City.SysName)); 98 end; 99 end; 100 101 procedure TCities.SaveToRegistry(Context: TRegistryContext); 102 var 103 City: TCity; 104 begin 105 for City in Self do begin 106 City.SaveToRegistry(TRegistryContext.Create(Context.RootKey, Context.Key + '/' + City.SysName)); 107 end; 31 108 end; 32 109 -
trunk/UColors.pas
r95 r100 16 16 ShapeBackground: TColor; 17 17 MenuItemText: TColor; 18 MenuItemDisabledText: TColor; 18 19 MenuItemBackground: TColor; 19 20 MenuItemBackgroundSelected: TColor; … … 34 35 ShapeBackground := clBlack; 35 36 MenuItemText := $cccccc; 37 MenuItemDisabledText := $888888; 36 38 MenuItemBackground := $b75C01; 37 39 MenuItemBackgroundSelected := $070C81; … … 42 44 ShapeBackground := clWhite; 43 45 MenuItemText := clWhite; 46 MenuItemDisabledText := clSilver; 44 47 MenuItemBackground := $e78C31; 45 48 MenuItemBackgroundSelected := $f7bC61; -
trunk/UControls.pas
r98 r100 16 16 procedure SetEnabled(AValue: Boolean); 17 17 public 18 Ref: TObject; 18 19 Bounds: TRect; 19 20 Canvas: TCanvas; -
trunk/UEngine.pas
r99 r100 85 85 TMetroLines = class(TObjectList<TMetroLine>) 86 86 Engine: TEngine; 87 function AddNew : TMetroLine;87 function AddNew(Color: TColor): TMetroLine; 88 88 function SearchByColor(Color: TColor): TMetroLine; 89 89 end; … … 141 141 end; 142 142 143 { TMap } 144 143 145 TMap = class 144 146 Size: TPoint; … … 149 151 150 152 TGameState = (gsNotStarted, gsRunning, gsPaused, gsGameOver, gsMenu, gsNewWeek, 151 gsNewImprovement); 152 153 TMetroImprovement = (miNone, miTunnel, miTerminal, miLine, miCarriage); 153 gsNewImprovement, gsSuccess); 154 155 TMetroImprovement = (miNone, miTunnel, miTerminal, miLine, miCarriage, 156 miFastTrain); 154 157 TMetroImprovementSet = set of TMetroImprovement; 155 158 … … 175 178 MenuMain: TMenu; 176 179 MenuOptions: TMenu; 180 MenuCareer: TMenu; 177 181 MenuGame: TMenu; 178 182 LastState: TGameState; … … 180 184 ImprovementImageSize: Integer; 181 185 IconSize: Integer; 186 LineColors: array of TColor; 182 187 function GetServedDaysCount: Integer; 183 188 procedure ResizeView; … … 194 199 procedure DrawTrains(Canvas: TCanvas); 195 200 procedure DrawGameOver(Canvas: TCanvas; CanvasSize: TPoint); 201 procedure DrawHighScore(Canvas: TCanvas; CanvasSize: TPoint; Y: Integer); 202 procedure DrawSuccess(Canvas: TCanvas; CanvasSize: TPoint); 196 203 procedure DrawNewWeek(Canvas: TCanvas; CanvasSize: TPoint); 197 204 procedure DrawNewImprovement(Canvas: TCanvas; CanvasSize: TPoint); … … 209 216 procedure ShiftTrackPoints; 210 217 procedure MenuItemExit(Sender: TObject); 218 procedure MenuItemCity(Sender: TObject); 211 219 procedure MenuItemPlay(Sender: TObject); 220 procedure MenuItemCareer(Sender: TObject); 212 221 procedure MenuItemOptions(Sender: TObject); 213 222 procedure MenuItemGameContinue(Sender: TObject); … … 226 235 procedure FullScreenChanged(Sender: TObject); 227 236 procedure UpdateInterface; 228 procedure InitCities;229 237 function GetImprovementText(Improvement: TMetroImprovement): string; 230 238 function GetImprovementBitmap(Improvement: TMetroImprovement): TBitmap; … … 242 250 View: TView; 243 251 Cities: TCities; 252 City: TCity; 244 253 SelectedLine: TMetroLine; 245 254 SelectedTrain: TMetroTrain; … … 255 264 ImagePause: TImage; 256 265 ImageFastForward: TImage; 266 ImageAchievement: TImage; 257 267 ImageCarriage: TImage; 258 268 ImageTerminal: TImage; … … 267 277 HighestServedPassengerCount: Integer; 268 278 HighestServedDaysCount: Integer; 279 RegistryContext: TRegistryContext; 269 280 procedure InitMenus; 281 procedure InitCities; 270 282 procedure MouseMove(Position: TPoint); 271 283 procedure MouseUp(Button: TMouseButton; Position: TPoint); … … 276 288 procedure NewGame; 277 289 procedure Redraw; 278 procedure LoadFromRegistry (Context: TRegistryContext);279 procedure SaveToRegistry (Context: TRegistryContext);290 procedure LoadFromRegistry; 291 procedure SaveToRegistry; 280 292 constructor Create; 281 293 destructor Destroy; override; … … 291 303 292 304 const 293 clDarkYellow = TColor($00dede);294 clOrange = TColor($0080ff);295 clBrown = TColor($003090);296 clCyan = TColor($FFFF00);297 LineColors: array[0..8] of TColor = (clBlue, clRed, clDarkYellow, clGreen,298 clPurple, clGray, clOrange, clBrown, clCyan);299 305 StationSize = 30; 300 306 StationOverloadSize = 60; … … 352 358 SFrench = 'French'; 353 359 SGerman = 'German'; 360 SAutomatic = 'Automatic'; 354 361 SBack = 'Back'; 355 SAutomatic = 'Automatic';356 362 SFullScreen = 'Full screen'; 357 363 SContinue = 'Continue'; … … 361 367 SCarriage = 'Carriage'; 362 368 STunnel = 'Tunnel'; 369 SCareer = 'Career'; 370 SSuccess = 'Success'; 371 SSuccessReason = 'Your metro transported enough passengers and you have reached your goal for this city.'; 372 SUnlockedCity = 'City %s is now unlocked.'; 363 373 364 374 // Cities … … 532 542 { TMetroLines } 533 543 534 function TMetroLines.AddNew : TMetroLine;544 function TMetroLines.AddNew(Color: TColor): TMetroLine; 535 545 begin 536 546 Result := TMetroLine.Create; 537 Result.Color := LineColors[Count];538 547 Result.Engine := Engine; 539 548 Result.Index := Count; 549 Result.Color := Color; 540 550 Add(Result); 541 551 end; … … 1694 1704 end; 1695 1705 1706 procedure TEngine.MenuItemCity(Sender: TObject); 1707 begin 1708 if Sender is TMenuItemButton then begin; 1709 City := TCity(TMenuItemButton(Sender).Ref); 1710 NewGame; 1711 end; 1712 end; 1713 1696 1714 procedure TEngine.MenuItemPlay(Sender: TObject); 1697 1715 begin 1716 City := nil; 1698 1717 NewGame; 1699 1718 end; 1700 1719 1720 procedure TEngine.MenuItemCareer(Sender: TObject); 1721 var 1722 City: TCity; 1723 begin 1724 MenuCareer.Parent := MenuMain; 1725 with MenuCareer, Items do begin 1726 Clear; 1727 for City in Cities do 1728 with AddButton(City.Name, MenuItemCity) do begin 1729 Ref := City; 1730 Enabled := not City.Locked; 1731 TextSize := 40; 1732 TextColor := Colors.MenuItemText; 1733 TextDisabledColor := Colors.MenuItemDisabledText; 1734 BackgroundColor := Colors.MenuItemBackground; 1735 BackgroundSelectedColor := Colors.MenuItemBackgroundSelected; 1736 end; 1737 with AddButton(SBack, MenuItemBack) do begin 1738 TextSize := 40; 1739 TextColor := Colors.MenuItemText; 1740 TextDisabledColor := Colors.MenuItemDisabledText; 1741 BackgroundColor := Colors.MenuItemBackground; 1742 BackgroundSelectedColor := Colors.MenuItemBackgroundSelected; 1743 end; 1744 OnExit := MenuItemBack; 1745 end; 1746 1747 Menu := MenuCareer; 1748 Redraw; 1749 end; 1750 1701 1751 procedure TEngine.MenuItemOptions(Sender: TObject); 1702 1752 begin 1753 MenuOptions.Parent := MenuMain; 1754 with MenuOptions, Items do begin 1755 Clear; 1756 with AddComboBox(SLanguage, [], LanguageChanged) do begin 1757 TextSize := 40; 1758 TextColor := Colors.MenuItemText; 1759 TextDisabledColor := Colors.MenuItemDisabledText; 1760 BackgroundColor := Colors.MenuItemBackground; 1761 BackgroundSelectedColor := Colors.MenuItemBackgroundSelected; 1762 FormMain.Translator1.LanguageListToStrings(States); 1763 Index := States.IndexOfObject(FormMain.Translator1.Language); 1764 if Index = -1 then Index := 0; 1765 end; 1766 with AddCheckBox(SDarkMode, DarkModeChanged) do begin 1767 TextSize := 40; 1768 TextColor := Colors.MenuItemText; 1769 TextDisabledColor := Colors.MenuItemDisabledText; 1770 BackgroundColor := Colors.MenuItemBackground; 1771 BackgroundSelectedColor := Colors.MenuItemBackgroundSelected; 1772 Checked := DarkMode; 1773 end; 1774 with AddCheckBox(SFullScreen, FullScreenChanged) do begin 1775 TextSize := 40; 1776 TextColor := Colors.MenuItemText; 1777 TextDisabledColor := Colors.MenuItemDisabledText; 1778 BackgroundColor := Colors.MenuItemBackground; 1779 BackgroundSelectedColor := Colors.MenuItemBackgroundSelected; 1780 Checked := FormMain.FullScreen; 1781 end; 1782 with AddButton(SBack, MenuItemBack) do begin 1783 TextSize := 40; 1784 TextColor := Colors.MenuItemText; 1785 TextDisabledColor := Colors.MenuItemDisabledText; 1786 BackgroundColor := Colors.MenuItemBackground; 1787 BackgroundSelectedColor := Colors.MenuItemBackgroundSelected; 1788 end; 1789 OnExit := MenuItemBack; 1790 end; 1791 1703 1792 Menu := MenuOptions; 1704 1793 Redraw; … … 1791 1880 begin 1792 1881 State := LastState; 1882 Redraw; 1793 1883 end; 1794 1884 … … 1821 1911 FormMain.Translator1.Translate; 1822 1912 InitMenus; 1913 1914 // Recreate cities with translated names 1915 SaveToRegistry; 1916 InitCities; 1917 LoadFromRegistry; 1823 1918 end; 1824 1919 end; … … 1838 1933 1839 1934 procedure TEngine.InitCities; 1935 var 1936 I: Integer; 1840 1937 begin 1841 1938 with Cities do begin 1842 AddNew(SLondon); 1843 AddNew(SNewYork); 1844 AddNew(SPrague); 1845 AddNew(SParis); 1846 AddNew(STokyo); 1847 end; 1939 Clear; 1940 with AddNew('Prague', SPrague, 1275406) do begin 1941 LineColors := [clRed, clGreen, clYellow]; 1942 InitialLineCount := 1; 1943 PassengersCountToUnlock := 200; 1944 end; 1945 with AddNew('Paris', SParis, 2138551) do begin 1946 LineColors := [clRed, clGreen, clYellow, clBlue, clBrown, clOrange, 1947 clPurple, clOlive, clAqua, clDarkYellow, clPink]; 1948 InitialLineCount := 1; 1949 PassengersCountToUnlock := 300; 1950 end; 1951 with AddNew('Rome', SRome, 2872800) do begin 1952 LineColors := [clRed, clGreen, clYellow]; 1953 InitialLineCount := 1; 1954 PassengersCountToUnlock := 500; 1955 end; 1956 with AddNew('NewYork', SNewYork, 8804190) do begin 1957 InitialLineCount := 1; 1958 PassengersCountToUnlock := 700; 1959 end; 1960 with AddNew('London', SLondon, 9002488) do begin 1961 InitialLineCount := 3; 1962 PassengersCountToUnlock := 1000; 1963 end; 1964 with AddNew('Tokyo', STokyo, 13960236) do begin 1965 InitialLineCount := 3; 1966 PassengersCountToUnlock := 2000; 1967 end; 1968 end; 1969 for I := 1 to Cities.Count - 1 do 1970 Cities[I].Locked := True; 1848 1971 end; 1849 1972 … … 1871 1994 begin 1872 1995 case Improvement of 1873 miLine: Lines.AddNew ;1996 miLine: Lines.AddNew(LineColors[Lines.Count]); 1874 1997 miCarriage: Carriages.AddNew; 1875 1998 //miTunnel: Tunnels.AddNew; … … 1884 2007 with AddButton(SBigMetro, nil) do begin 1885 2008 Enabled := False; 1886 FontSize := 60; 1887 FontColor := Colors.Text; 2009 TextSize := 60; 2010 TextColor := Colors.Text; 2011 TextDisabledColor := Colors.Text; 1888 2012 BackgroundColor := clNone; 1889 2013 BackgroundSelectedColor := clNone; 1890 2014 end; 1891 2015 with AddButton(SPlay, MenuItemPlay) do begin 1892 FontSize := 40; 1893 FontColor := Colors.MenuItemText; 2016 TextSize := 40; 2017 TextColor := Colors.MenuItemText; 2018 TextDisabledColor := Colors.MenuItemDisabledText; 1894 2019 BackgroundColor := Colors.MenuItemBackground; 1895 2020 BackgroundSelectedColor := Colors.MenuItemBackgroundSelected; 1896 2021 end; 1897 with AddButton(SOptions, MenuItemOptions) do begin 1898 FontSize := 40; 1899 FontColor := Colors.MenuItemText; 2022 with AddButton(SCareer, MenuItemCareer) do begin 2023 TextSize := 40; 2024 TextColor := Colors.MenuItemText; 2025 TextDisabledColor := Colors.MenuItemDisabledText; 1900 2026 BackgroundColor := Colors.MenuItemBackground; 1901 2027 BackgroundSelectedColor := Colors.MenuItemBackgroundSelected; 1902 2028 end; 1903 with AddButton(SExit, MenuItemExit) do begin 1904 FontSize := 40; 1905 FontColor := Colors.MenuItemText; 2029 with AddButton(SOptions, MenuItemOptions) do begin 2030 TextSize := 40; 2031 TextColor := Colors.MenuItemText; 2032 TextDisabledColor := Colors.MenuItemDisabledText; 1906 2033 BackgroundColor := Colors.MenuItemBackground; 1907 2034 BackgroundSelectedColor := Colors.MenuItemBackgroundSelected; 1908 2035 end; 1909 OnExit := MenuItemExit; 1910 end; 1911 1912 MenuOptions.Parent := MenuMain; 1913 with MenuOptions, Items do begin 1914 Clear; 1915 with AddComboBox(SLanguage, [], LanguageChanged) do begin 1916 FontSize := 40; 1917 FontColor := Colors.MenuItemText; 2036 with AddButton(SExit, MenuItemExit) do begin 2037 TextSize := 40; 2038 TextColor := Colors.MenuItemText; 2039 TextDisabledColor := Colors.MenuItemDisabledText; 1918 2040 BackgroundColor := Colors.MenuItemBackground; 1919 2041 BackgroundSelectedColor := Colors.MenuItemBackgroundSelected; 1920 FormMain.Translator1.LanguageListToStrings(States); 1921 Index := States.IndexOfObject(FormMain.Translator1.Language); 1922 if Index = -1 then Index := 0; 1923 end; 1924 with AddCheckBox(SDarkMode, DarkModeChanged) do begin 1925 FontSize := 40; 1926 FontColor := Colors.MenuItemText; 1927 BackgroundColor := Colors.MenuItemBackground; 1928 BackgroundSelectedColor := Colors.MenuItemBackgroundSelected; 1929 Checked := DarkMode; 1930 end; 1931 with AddCheckBox(SFullScreen, FullScreenChanged) do begin 1932 FontSize := 40; 1933 FontColor := Colors.MenuItemText; 1934 BackgroundColor := Colors.MenuItemBackground; 1935 BackgroundSelectedColor := Colors.MenuItemBackgroundSelected; 1936 Checked := FormMain.FullScreen; 1937 end; 1938 with AddButton(SBack, MenuItemBack) do begin 1939 FontSize := 40; 1940 FontColor := Colors.MenuItemText; 1941 BackgroundColor := Colors.MenuItemBackground; 1942 BackgroundSelectedColor := Colors.MenuItemBackgroundSelected; 1943 end; 1944 OnExit := MenuItemBack; 2042 end; 2043 OnExit := MenuItemExit; 1945 2044 end; 1946 2045 … … 1948 2047 Clear; 1949 2048 with AddButton(SContinue, MenuItemGameContinue) do begin 1950 FontSize := 40; 1951 FontColor := Colors.MenuItemText; 2049 TextSize := 40; 2050 TextColor := Colors.MenuItemText; 2051 TextDisabledColor := Colors.MenuItemDisabledText; 1952 2052 BackgroundColor := Colors.MenuItemBackground; 1953 2053 BackgroundSelectedColor := Colors.MenuItemBackgroundSelected; 1954 2054 end; 1955 2055 with AddButton(SRestart, MenuItemGameRestart) do begin 1956 FontSize := 40; 1957 FontColor := Colors.MenuItemText; 2056 TextSize := 40; 2057 TextColor := Colors.MenuItemText; 2058 TextDisabledColor := Colors.MenuItemDisabledText; 1958 2059 BackgroundColor := Colors.MenuItemBackground; 1959 2060 BackgroundSelectedColor := Colors.MenuItemBackgroundSelected; 1960 2061 end; 1961 2062 with AddButton(SExit, MenuItemGameExit) do begin 1962 FontSize := 40; 1963 FontColor := Colors.MenuItemText; 2063 TextSize := 40; 2064 TextColor := Colors.MenuItemText; 2065 TextDisabledColor := Colors.MenuItemDisabledText; 1964 2066 BackgroundColor := Colors.MenuItemBackground; 1965 2067 BackgroundSelectedColor := Colors.MenuItemBackgroundSelected; … … 1971 2073 procedure TEngine.ButtonBackClick(Sender: TObject); 1972 2074 begin 1973 Menu := MenuGame; 1974 LastState := State; 1975 State := gsMenu; 1976 Redraw; 2075 if State = gsSuccess then begin 2076 State := gsMenu; 2077 MenuItemCareer(Self); 2078 end else begin 2079 Menu := MenuGame; 2080 LastState := State; 2081 State := gsMenu; 2082 Redraw; 2083 end; 1977 2084 end; 1978 2085 … … 2127 2234 begin 2128 2235 with Canvas do begin 2129 DrawFrame(Canvas, Bounds(CanvasSize.X div 8, 2236 DrawFrame(Canvas, Bounds(CanvasSize.X div 8, ScaleY(90, 96), 2130 2237 Round(CanvasSize.X / 4 * 3), ScaleY(210, 96))); 2131 2238 … … 2137 2244 2138 2245 Font.Size := 40; 2139 TextOut((CanvasSize.X - TextWidth(SGameOver)) div 2, Y, SGameOver); 2140 Y := Y + Round(TextHeight(SGameOver) * 1.1); 2246 Text := SGameOver; 2247 TextOut((CanvasSize.X - TextWidth(Text)) div 2, Y, Text); 2248 Y := Y + Round(TextHeight(Text) * 1.1); 2141 2249 2142 2250 Font.Size := 14; 2143 TextOut((CanvasSize.X - TextWidth(SGameOverReason)) div 2, Y, SGameOverReason); 2144 Y := Y + Round(TextHeight(SGameOverReason) * 1.1); 2251 Text := SGameOverReason; 2252 TextOut((CanvasSize.X - TextWidth(Text)) div 2, Y, Text); 2253 Y := Y + Round(TextHeight(Text) * 1.1); 2145 2254 2146 2255 Text := Format(SGameOverStatistic, [ServedPassengerCount, ServedDaysCount]); … … 2150 2259 Y := Y + ScaleY(16, 96); 2151 2260 2261 DrawHighScore(Canvas, CanvasSize, Y); 2262 end; 2263 end; 2264 2265 procedure TEngine.DrawHighScore(Canvas: TCanvas; CanvasSize: TPoint; Y: Integer); 2266 var 2267 Text: string; 2268 begin 2269 with Canvas do begin 2152 2270 // Calculate new highest score 2153 2271 Text := ''; … … 2164 2282 if (ServedDaysCount > HighestServedDaysCount) then 2165 2283 HighestServedDaysCount := ServedDaysCount; 2284 2285 if Assigned(City) then begin 2286 if (ServedPassengerCount > City.HighestServedPassengerCount) then 2287 City.HighestServedPassengerCount := ServedPassengerCount; 2288 if (ServedDaysCount > City.HighestServedDaysCount) then 2289 City.HighestServedDaysCount := ServedDaysCount; 2290 end; 2291 end; 2292 end; 2293 2294 procedure TEngine.DrawSuccess(Canvas: TCanvas; CanvasSize: TPoint); 2295 var 2296 Y: Integer; 2297 Text: string; 2298 Index: Integer; 2299 begin 2300 with Canvas do begin 2301 DrawFrame(Canvas, Bounds(CanvasSize.X div 8, ScaleY(90, 96), 2302 Round(CanvasSize.X / 4 * 3), ScaleY(230, 96))); 2303 2304 Canvas.Font.Color := Self.Colors.Text; 2305 Brush.Style := bsClear; 2306 Pen.Style := psClear; 2307 2308 Y := ScaleY(100, 96); 2309 2310 Font.Size := 40; 2311 Text := SSuccess; 2312 TextOut((CanvasSize.X - TextWidth(Text)) div 2, Y, Text); 2313 Y := Y + Round(TextHeight(Text) * 1.1); 2314 2315 Font.Size := 14; 2316 Text := SSuccessReason; 2317 TextOut((CanvasSize.X - TextWidth(Text)) div 2, Y, Text); 2318 Y := Y + Round(TextHeight(Text) * 1.1); 2319 2320 // Unlock next city 2321 if Assigned(City) then begin 2322 Index := Cities.IndexOf(City); 2323 if (Index >= 0) and ((Index + 1) < Cities.Count) then begin 2324 Cities[Index + 1].Locked := False; 2325 Font.Size := 14; 2326 Text := Format(SUnlockedCity, [Cities[Index + 1].Name]); 2327 TextOut((CanvasSize.X - TextWidth(Text)) div 2, Y, Text); 2328 Y := Y + Round(TextHeight(Text) * 1.1); 2329 end; 2330 end; 2331 2332 Text := Format(SGameOverStatistic, [ServedPassengerCount, ServedDaysCount]); 2333 TextOut((CanvasSize.X - TextWidth(Text)) div 2, Y, Text); 2334 Y := Y + Round(TextHeight(SGameOverStatistic) * 1.1); 2335 2336 Y := Y + ScaleY(16, 96); 2337 2338 DrawHighScore(Canvas, CanvasSize, Y); 2166 2339 end; 2167 2340 end; … … 2499 2672 2500 2673 // Passenger count 2501 X := CanvasSize.X - ScaleX(30, 96); 2502 Text := IntToStr(ServedPassengerCount); 2503 ImagePassenger.Bounds := Bounds(X - Canvas.TextWidth(Text), Y - IconSize div 2, 2674 X := CanvasSize.X - ScaleX(10, 96); 2675 ImagePassenger.Bounds := Bounds(X - IconSize, Y - IconSize div 2, 2504 2676 IconSize, IconSize); 2505 2677 ImagePassenger.Canvas := Canvas; 2506 2678 ImagePassenger.Paint; 2507 X := X - Canvas.TextWidth(Text)- SeparatorSize div 3;2679 X := X - IconSize - SeparatorSize div 3; 2508 2680 2509 2681 Canvas.Brush.Style := bsClear; 2510 2682 Canvas.Font.Size := 14; 2511 2683 Canvas.Font.Color := Colors.Text; 2684 Text := IntToStr(ServedPassengerCount); 2512 2685 Canvas.TextOut(X - Canvas.TextWidth(Text), 2513 2686 Y - Canvas.TextHeight(Text) div 2, Text); … … 2522 2695 ButtonBack.Bounds.Top := 10; 2523 2696 ButtonBack.Paint; 2697 2698 // City name 2699 if Assigned(City) then begin 2700 Canvas.Brush.Style := bsClear; 2701 Canvas.Font.Color := Colors.Text; 2702 Canvas.Font.Size := 20; 2703 Text := City.Name; 2704 Canvas.TextOut(20, CanvasSize.Y - 2705 Canvas.TextHeight(Text) - 20, Text); 2706 2707 X := CanvasSize.X - ScaleX(10, 96); 2708 ImageAchievement.Bounds := Bounds(X - IconSize, Y - 2 * IconSize, 2709 IconSize, IconSize); 2710 ImageAchievement.Canvas := Canvas; 2711 ImageAchievement.Paint; 2712 2713 X := X - IconSize - SeparatorSize div 3; 2714 2715 Canvas.Brush.Style := bsClear; 2716 Canvas.Font.Size := 14; 2717 Canvas.Font.Color := Colors.Text; 2718 Text := IntToStr(City.PassengersCountToUnlock); 2719 Canvas.TextOut(X - Canvas.TextWidth(Text), 2720 Y - Round(1.5 * IconSize) - Canvas.TextHeight(Text) div 2, Text); 2721 end; 2524 2722 2525 2723 // Show train grabbed by mouse … … 2633 2831 Redraw; 2634 2832 end; 2833 end; 2834 2835 if Assigned(City) and (ServedPassengerCount >= City.PassengersCountToUnlock) then begin 2836 State := gsSuccess; 2837 Redraw; 2635 2838 end; 2636 2839 end; … … 2711 2914 Redraw; 2712 2915 end else 2713 if State = gsGameOverthen begin2916 if State in [gsGameOver, gsSuccess] then begin 2714 2917 ButtonBack.MouseUp(Position); 2715 2918 end else … … 2890 3093 KeyF5 = 116; 2891 3094 KeyF6 = 117; 3095 KeyF7 = 118; 3096 KeyT = 84; 3097 KeyC = 67; 3098 KeyF = 70; 3099 KeyP = 80; 2892 3100 begin 2893 3101 if Key = KeyEsc then begin … … 2899 3107 end; 2900 3108 end; 3109 if State in [gsRunning, gsPaused] then begin 3110 if Key = KeyT then begin 3111 if Trains.GetUnusedCount > 0 then begin 3112 SelectedTrain := Trains.GetUnused; 3113 Redraw; 3114 end; 3115 end else 3116 if Key = KeyC then begin 3117 if Carriages.GetUnusedCount > 0 then begin 3118 SelectedCarriage := Carriages.GetUnused; 3119 Redraw; 3120 end; 3121 end else 3122 if Key = KeyF then begin 3123 ButtonFastForward(Self); 3124 end else 3125 if Key = KeyP then begin 3126 ButtonPlay(Self); 3127 end; 3128 end; 2901 3129 {$IFDEF DEBUG} 2902 3130 if State in [gsRunning, gsPaused] then begin … … 2921 3149 ResizeView; 2922 3150 Redraw; 3151 end else 3152 if Key = KeyF7 then begin 3153 State := gsSuccess; 3154 Redraw; 2923 3155 end; 2924 3156 end; … … 2934 3166 procedure TEngine.Clear; 2935 3167 begin 3168 ServedPassengerCount := 0; 2936 3169 Week := 1; 2937 3170 Trains.Clear; … … 2948 3181 NewStation: TMapStation; 2949 3182 InitialStationCount: Integer; 3183 InitialLineCount: Integer; 2950 3184 begin 2951 3185 Clear; 3186 if Assigned(City) then begin 3187 LineColors := City.LineColors; 3188 InitialLineCount := City.InitialLineCount; 3189 end else begin 3190 LineColors := [clBlue, clRed, clDarkYellow, clGreen, 3191 clPurple, clGray, clOrange, clBrown, clCyan]; 3192 InitialLineCount := 3; 3193 end; 2952 3194 AvailableImprovements := [miCarriage, miLine]; 2953 3195 ShapeCount := 3; 2954 ServedPassengerCount := 0;2955 3196 2956 3197 // Start with 3 stations with each different shape … … 2963 3204 end; 2964 3205 2965 for I := 0 to 2do begin2966 Lines.AddNew ;3206 for I := 0 to InitialLineCount - 1 do begin 3207 Lines.AddNew(LineColors[Lines.Count]); 2967 3208 NewTrain := TMetroTrain.Create; 2968 3209 Trains.Add(NewTrain); … … 2988 3229 end; 2989 3230 2990 procedure TEngine.LoadFromRegistry (Context: TRegistryContext);3231 procedure TEngine.LoadFromRegistry; 2991 3232 begin 2992 3233 with TRegistryEx.Create do 2993 3234 try 2994 CurrentContext := Context;3235 CurrentContext := RegistryContext; 2995 3236 DarkMode := ReadBoolWithDefault('DarkMode', False); 2996 3237 HighestServedPassengerCount := ReadIntegerWithDefault('HighestPassengers', 0); 2997 3238 HighestServedDaysCount := ReadIntegerWithDefault('HighestDays', 0); 3239 Cities.LoadFromRegistry(TRegistryContext.Create(RegistryContext.RootKey, RegistryContext.Key + '/Cities')); 2998 3240 finally 2999 3241 Free; … … 3001 3243 end; 3002 3244 3003 procedure TEngine.SaveToRegistry (Context: TRegistryContext);3245 procedure TEngine.SaveToRegistry; 3004 3246 begin 3005 3247 with TRegistryEx.Create do 3006 3248 try 3007 CurrentContext := Context;3249 CurrentContext := RegistryContext; 3008 3250 3009 3251 WriteBool('DarkMode', DarkMode); 3010 3252 WriteInteger('HighestPassengers', HighestServedPassengerCount); 3011 3253 WriteInteger('HighestDays', HighestServedDaysCount); 3254 Cities.SaveToRegistry(TRegistryContext.Create(RegistryContext.RootKey, RegistryContext.Key + '/Cities')); 3012 3255 finally 3013 3256 Free; … … 3023 3266 ButtonBack.OnClick := ButtonBackClick; 3024 3267 ButtonBack.Bounds := Bounds(0, 0, ScaleX(80, 96), ScaleY(80, 96)); 3268 Cities := TCities.Create; 3269 InitCities; 3025 3270 MenuMain := TMenu.Create; 3026 3271 MenuOptions := TMenu.Create; 3272 MenuCareer := TMenu.Create; 3027 3273 MenuGame := TMenu.Create; 3028 3274 Menu := MenuMain; … … 3049 3295 ImageFastForward := TImage.Create; 3050 3296 ImageFastForward.OnClick := ButtonFastForward; 3297 ImageAchievement := TImage.Create; 3051 3298 ImageNewTrain := TImage.Create; 3052 3299 ImageNewTrain.OnClick := ButtonNewTrain; … … 3056 3303 ImageNewImprovement2.OnClick := ButtonNewImprovement2; 3057 3304 MetaCanvas := TMetaCanvas.Create; 3058 Cities := TCities.Create;3059 InitCities;3060 3305 Colors.Init(FDarkMode); 3061 3306 end; … … 3063 3308 destructor TEngine.Destroy; 3064 3309 begin 3065 FreeAndNil(Cities);3066 3310 FreeAndNil(MetaCanvas); 3067 3311 FreeAndNil(Trains); … … 3075 3319 FreeAndNil(ImagePlay); 3076 3320 FreeAndNil(ImageFastForward); 3321 FreeAndNil(ImageAchievement); 3077 3322 FreeAndNil(ImagePause); 3078 3323 FreeAndNil(ImageCarriage); … … 3086 3331 FreeAndNil(MenuMain); 3087 3332 FreeAndNil(MenuOptions); 3333 FreeAndNil(MenuCareer); 3088 3334 FreeAndNil(MenuGame); 3335 FreeAndNil(Cities); 3089 3336 FreeAndNil(ButtonBack); 3090 3337 inherited; … … 3112 3359 MetaCanvas.DrawTo(Canvas); 3113 3360 3114 // Game over3115 3361 if State = gsGameOver then 3116 3362 begin 3117 3363 DrawGameOver(Canvas, CanvasSize); 3364 DrawGameControls(Canvas, CanvasSize); 3365 end else 3366 if State = gsSuccess then 3367 begin 3368 DrawSuccess(Canvas, CanvasSize); 3118 3369 DrawGameControls(Canvas, CanvasSize); 3119 3370 end else -
trunk/UMenu.pas
r95 r100 14 14 BackgroundColor: TColor; 15 15 BackgroundSelectedColor: TColor; 16 TextColor: TColor; 17 TextDisabledColor: TColor; 16 18 Kind: TMenuItemKind; 17 19 Text: string; 18 20 Selected: Boolean; 19 FontSize: Integer; 20 FontColor: Integer; 21 TextSize: Integer; 21 22 function GetOutputText: string; virtual; 22 23 constructor Create; override; … … 125 126 begin 126 127 Enabled := True; 127 FontSize := 40; 128 FontColor := clWhite; 128 TextSize := 40; 129 TextColor := clWhite; 130 TextDisabledColor := clSilver; 129 131 end; 130 132 … … 180 182 if Items[I].Bounds.Contains(Position) then begin 181 183 if (Items[I] is TMenuItemButton) then begin 182 if Assigned(TMenuItemButton(Items[I]).OnClick) then 183 TMenuItemButton(Items[I]).OnClick(Items[I]); 184 TMenuItemButton(Items[I]).MouseUp(Position); 184 185 end else 185 186 if (Items[I] is TMenuItemCheckBox) then begin … … 215 216 Brush.Style := bsSolid; 216 217 for I := 0 to Items.Count - 1 do begin 217 Font.Size := Items[I]. FontSize;218 Font.Size := Items[I].TextSize; 218 219 if TotalWidth < TextWidth(Items[I].GetOutputText) then 219 220 TotalWidth := TextWidth(Items[I].GetOutputText); … … 229 230 Brush.Style := bsSolid; 230 231 for I := 0 to Items.Count - 1 do begin 231 Font.Size := Items[I].FontSize; 232 Font.Color := Items[I].FontColor; 232 Font.Size := Items[I].TextSize; 233 if Items[I].Enabled then Font.Color := Items[I].TextColor 234 else Font.Color := Items[I].TextDisabledColor; 233 235 Items[I].Bounds.Left := X; 234 236 Items[I].Bounds.Top := Y;
Note:
See TracChangeset
for help on using the changeset viewer.