Changeset 62


Ignore:
Timestamp:
Nov 25, 2020, 4:25:09 PM (4 years ago)
Author:
chronos
Message:
  • Added: Main game menu.
Location:
trunk
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/BigMetro.lpi

    r61 r62  
    8787      </Item2>
    8888    </RequiredPackages>
    89     <Units Count="5">
     89    <Units Count="6">
    9090      <Unit0>
    9191        <Filename Value="BigMetro.lpr"/>
     
    114114        <ResourceBaseClass Value="Form"/>
    115115      </Unit4>
     116      <Unit5>
     117        <Filename Value="UMenu.pas"/>
     118        <IsPartOfProject Value="True"/>
     119      </Unit5>
    116120    </Units>
    117121  </ProjectOptions>
  • trunk/BigMetro.lpr

    r55 r62  
    88  {$ENDIF}
    99  Interfaces, // this includes the LCL widgetset
    10   Forms, SysUtils, UFormMain, UFormImages, Common;
     10  Forms, SysUtils, UFormMain, UFormImages, Common, UMenu;
    1111
    1212{$R *.res}
    1313
    14 {$IFDEF DEBUG}
     14{$if declared(UseHeapTrace)}
    1515const
    1616  HeapTraceLog = 'heaptrclog.trc';
     
    1818
    1919begin
    20   Application.Scaled:=True;
    21   {$IFDEF DEBUG}
     20  {$if declared(UseHeapTrace)}
    2221  // Heap trace
    2322  DeleteFile(ExtractFilePath(ParamStr(0)) + HeapTraceLog);
     
    2625
    2726  RequireDerivedFormResource := True;
     27  Application.Scaled:=True;
    2828  Application.Initialize;
    2929  Application.CreateForm(TFormMain, FormMain);
  • trunk/Forms/UFormMain.lfm

    r61 r62  
    3535    Top = 21
    3636  end
     37  object Translator1: TTranslator
     38    POFilesFolder = 'Languages'
     39    Left = 496
     40    Top = 358
     41  end
     42  object ApplicationInfo1: TApplicationInfo
     43    Identification = 1
     44    VersionMajor = 1
     45    VersionMinor = 1
     46    VersionBugFix = 0
     47    HomePage = 'https://app.zdechov.net/BigMetro'
     48    AuthorsName = 'Chronosoft'
     49    EmailContact = 'robie@centrum.cz'
     50    AppName = 'Big Metro'
     51    Description = 'Enjoyable real-time metro building game.'
     52    ReleaseDate = 44160
     53    RegistryKey = '\Software\Chronosoft\BigMetro'
     54    RegistryRoot = rrKeyCurrentUser
     55    License = 'CC0'
     56    Left = 484
     57    Top = 460
     58  end
    3759end
  • trunk/Forms/UFormMain.pas

    r51 r62  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
    9   ExtCtrls, UEngine, LCLType, types;
     9  ExtCtrls, UEngine, LCLType, types, UTranslator, UApplicationInfo, URegistry;
    1010
    1111type
     
    1414
    1515  TFormMain = class(TForm)
     16    ApplicationInfo1: TApplicationInfo;
    1617    PaintBox1: TPaintBox;
    1718    Timer1: TTimer;
     19    Translator1: TTranslator;
    1820    procedure FormCreate(Sender: TObject);
    1921    procedure FormDestroy(Sender: TObject);
     
    3335    procedure PaintBox1Resize(Sender: TObject);
    3436    procedure Timer1Timer(Sender: TObject);
     37  private
     38    procedure LoadConfig;
     39    procedure SaveConfig;
    3540  public
    3641    Engine: TEngine;
     
    5257procedure TFormMain.FormCreate(Sender: TObject);
    5358begin
     59  LoadConfig;
    5460  Engine := TEngine.Create;
    5561  //PaintBox1.ControlStyle := [csOpaque];
     62  Randomize;
    5663end;
    5764
     
    5966begin
    6067  Engine.Free;
     68  SaveConfig;
    6169end;
    6270
     
    7684  Engine.Map.Size := Point(PaintBox1.Width, PaintBox1.Height);
    7785  Engine.View.DestRect := Rect(0, 0, PaintBox1.Width, PaintBox1.Height);
    78   Engine.Reset;
     86  Engine.MainMenu;
    7987end;
    8088
     
    132140end;
    133141
     142procedure TFormMain.LoadConfig;
     143var
     144  LangCode: string;
     145begin
     146  with TRegistryEx.Create do
     147  try
     148    CurrentContext := ApplicationInfo1.GetRegistryContext;
     149
     150    if ValueExists('LanguageCode') then begin
     151      LangCode := ReadStringWithDefault('LanguageCode', '');
     152      Translator1.Language := Translator1.Languages.SearchByCode(LangCode);
     153    end else Translator1.Language := Translator1.Languages.SearchByCode('');
     154    //ThemeManager1.Theme := ThemeManager1.Themes.FindByName(ReadStringWithDefault('Theme', 'System'));
     155  finally
     156    Free;
     157  end;
     158end;
     159
     160procedure TFormMain.SaveConfig;
     161begin
     162  with TRegistryEx.Create do
     163  try
     164    CurrentContext := ApplicationInfo1.GetRegistryContext;
     165
     166    if Assigned(Translator1.Language) and (Translator1.Language.Code <> '') then
     167      WriteString('LanguageCode', Translator1.Language.Code)
     168      else DeleteValue('LanguageCode');
     169    //WriteString('Theme', ThemeManager1.Theme.Name);
     170  finally
     171    Free;
     172  end;
     173end;
     174
     175
    134176end.
    135177
  • trunk/Languages

    • Property svn:ignore set to
      *.mo
  • trunk/Languages/BigMetro.cs.po

    r61 r62  
    1313
    1414#: tformmain.caption
     15msgctxt "tformmain.caption"
    1516msgid "Big Metro"
    1617msgstr "Big Metro"
     
    3940msgid "Zero zoom not allowed"
    4041msgstr "Nulové přiblížení není povoleno"
     42
     43#: umenu.sback
     44msgid "Back"
     45msgstr "Zpět"
     46
     47#: umenu.sbigmetro
     48msgctxt "umenu.sbigmetro"
     49msgid "Big Metro"
     50msgstr "Big Metro"
     51
     52#: umenu.sczech
     53msgid "Czech"
     54msgstr "Čeština"
     55
     56#: umenu.sdarkmode
     57msgid "Dark mode"
     58msgstr "Temný režim"
     59
     60#: umenu.senglish
     61msgid "English"
     62msgstr "Angličtina"
     63
     64#: umenu.sexit
     65msgctxt "umenu.sexit"
     66msgid "Exit"
     67msgstr "Odejít"
     68
     69#: umenu.slanguage
     70#, fuzzy
     71#| msgid "Jazyk"
     72msgid "Language"
     73msgstr "Jazyk"
     74
     75#: umenu.soptions
     76msgctxt "umenu.soptions"
     77msgid "Options"
     78msgstr "Volby"
     79
     80#: umenu.splay
     81msgctxt "umenu.splay"
     82msgid "Play"
     83msgstr "Hrát"
     84
  • trunk/Languages/BigMetro.po

    r61 r62  
    33
    44#: tformmain.caption
     5msgctxt "tformmain.caption"
    56msgid "Big Metro"
    67msgstr ""
     
    3031msgstr ""
    3132
     33#: umenu.sback
     34msgid "Back"
     35msgstr ""
     36
     37#: umenu.sbigmetro
     38msgctxt "umenu.sbigmetro"
     39msgid "Big Metro"
     40msgstr ""
     41
     42#: umenu.sczech
     43msgid "Czech"
     44msgstr ""
     45
     46#: umenu.sdarkmode
     47msgid "Dark mode"
     48msgstr ""
     49
     50#: umenu.senglish
     51msgid "English"
     52msgstr ""
     53
     54#: umenu.sexit
     55msgctxt "umenu.sexit"
     56msgid "Exit"
     57msgstr ""
     58
     59#: umenu.slanguage
     60msgid "Language"
     61msgstr ""
     62
     63#: umenu.soptions
     64msgctxt "umenu.soptions"
     65msgid "Options"
     66msgstr ""
     67
     68#: umenu.splay
     69msgctxt "umenu.splay"
     70msgid "Play"
     71msgstr ""
     72
  • trunk/Packages/Common/UMetaCanvas.pas

    r60 r62  
    66
    77uses
    8   Classes, SysUtils, Graphics, Contnrs, Types;
     8  Classes, SysUtils, Graphics, Contnrs, Types, fgl;
    99
    1010type
     
    1717    procedure Zoom(Factor: Double); virtual;
    1818    procedure Move(Delta: TPoint); virtual;
     19  end;
     20
     21  TCanvasObjects = class(TFPGObjectList<TCanvasObject>)
    1922  end;
    2023
     
    133136    procedure DoLineTo(X, Y: Integer); override;
    134137  public
    135     Objects: TObjectList;
     138    Objects: TCanvasObjects;
    136139    procedure FillRect(const ARect: TRect); overload; override;
    137140    procedure FillRect(X1,Y1,X2,Y2: Integer); overload;
     
    154157  end;
    155158
     159
    156160implementation
    157161
     
    198202  Pen.Free;
    199203  Brush.Free;
    200   inherited Destroy;
     204  inherited;
    201205end;
    202206
     
    228232destructor TCanvasStretchDraw.Destroy;
    229233begin
    230   inherited Destroy;
     234  inherited;
    231235end;
    232236
     
    264268  Pen.Free;
    265269  Brush.Free;
    266   inherited Destroy;
     270  inherited;
    267271end;
    268272
     
    304308  Brush.Free;
    305309  Pen.Free;
    306   inherited Destroy;
     310  inherited;
    307311end;
    308312
     
    336340begin
    337341  Pen.Free;
    338   inherited Destroy;
     342  inherited;
    339343end;
    340344
     
    375379  Pen.Free;
    376380  Brush.Free;
    377   inherited Destroy;
     381  inherited;
    378382end;
    379383
     
    408412  Brush.Free;
    409413  Font.Free;
    410   inherited Destroy;
     414  inherited;
    411415end;
    412416
     
    633637begin
    634638  for I := 0 to Objects.Count - 1 do
    635     TCanvasObject(Objects[I]).Paint(Canvas);
     639    Objects[I].Paint(Canvas);
    636640end;
    637641
     
    641645begin
    642646  for I := 0 to Objects.Count - 1 do
    643     TCanvasObject(Objects[I]).Zoom(Factor);
     647    Objects[I].Zoom(Factor);
    644648end;
    645649
     
    649653begin
    650654  for I := 0 to Objects.Count - 1 do
    651     TCanvasObject(Objects[I]).Move(Delta);
     655    Objects[I].Move(Delta);
    652656end;
    653657
     
    656660  inherited;
    657661  FPenPos := Point(0, 0);
    658   Objects := TObjectList.Create;
     662  Objects := TCanvasObjects.Create;
    659663end;
    660664
     
    662666begin
    663667  Objects.Free;
    664   inherited Destroy;
     668  inherited;
    665669end;
    666670
  • trunk/UEngine.pas

    r61 r62  
    77uses
    88  Classes, SysUtils, Graphics, Controls, ExtCtrls, Math, DateUtils,
    9   UMetaCanvas, fgl;
     9  UMetaCanvas, fgl, UMenu;
    1010
    1111type
     
    259259  end;
    260260
    261   TGameState = (gsNotStarted, gsRunning, gsPaused, gsGameOver);
     261  TGameState = (gsNotStarted, gsRunning, gsPaused, gsGameOver, gsMenu);
    262262
    263263  { TEngine }
     
    276276    FLastTime: TDateTime;
    277277    MetaCanvas: TMetaCanvas;
     278    Menu: TMenu;
     279    MenuMain: TMenu;
     280    MenuOptions: TMenu;
    278281    procedure ResizeView;
    279282    function GetExistStationShapes: TStationShapeSet;
     
    292295    function GetUnusedLine: TMetroLine;
    293296    procedure ShiftTrackPoints;
     297    procedure MenuItemExit(Sender: TObject);
     298    procedure MenuItemPlay(Sender: TObject);
     299    procedure MenuItemOptions(Sender: TObject);
     300    procedure MenuItemBack(Sender: TObject);
     301    procedure DarkModeChanged(Sender: TObject);
     302    procedure LanguageChanged(Sender: TObject);
     303    procedure InitMenus;
    294304  public
    295305    Passengers: TMetroPassengers;
     
    312322    procedure MouseUp(Button: TMouseButton; Position: TPoint);
    313323    procedure MouseDown(Button: TMouseButton; Position: TPoint);
    314     procedure Reset;
     324    procedure MainMenu;
     325    procedure NewGame;
    315326    procedure Redraw;
    316327    constructor Create;
     
    345356  EndStationLength = 50;
    346357  ShowDistances = False;
    347   //TimePerSecond = (60 * OneMinute);
    348   TimePerSecond = (60 * OneMinute);
     358  TimePerSecond = 60 * OneMinute;
    349359  NewStationPeriod = 1;
    350360  NewShapePeriod = 10;
     
    354364  VisiblePassengersPerLine = 6;
    355365
     366
    356367implementation
    357368
    358369uses
    359   UGeometric;
     370  UGeometric, UFormMain, ULanguages;
    360371
    361372resourcestring
     
    375386  I := 0;
    376387  while (I < 0) and
    377   ((Items[I].Points.First <> Point1) or (Items[I].Points.Last <> Point2))
    378   and ((Items[I].Points.First <> Point2) or (Items[I].Points.Last <> Point1)) do
     388    ((Items[I].Points.First <> Point1) or (Items[I].Points.Last <> Point2)) and
     389    ((Items[I].Points.First <> Point2) or (Items[I].Points.Last <> Point1)) do
    379390  Inc(I);
    380391  if I < 0 then Result := Items[I]
     
    15361547  Station: TMapStation;
    15371548begin
    1538   // Reset all distances
     1549  // NewGame all distances
    15391550  for Station in Stations do
    15401551  with Station do begin
     
    15781589        end else begin
    15791590          // If circular then trains might go in single direction so passengers
    1580           // waiting for oposite directions are wrong
     1591          // waiting for opposite directions are wrong
    15811592          DirectionUp := False;
    15821593          DirectionDown := False;
     
    17811792  MapStation: TMapStation;
    17821793begin
    1783   // Reset all trackpoints position shift
     1794  // NewGame all trackpoints position shift
    17841795  for MetroLine in Lines do
    17851796    for TrackPoint in MetroLine.Track.Points do
     
    18391850end;
    18401851
     1852procedure TEngine.MenuItemExit(Sender: TObject);
     1853begin
     1854  FormMain.Close;
     1855end;
     1856
     1857procedure TEngine.MenuItemPlay(Sender: TObject);
     1858begin
     1859  NewGame;
     1860end;
     1861
     1862procedure TEngine.MenuItemOptions(Sender: TObject);
     1863begin
     1864  Menu := MenuOptions;
     1865  Redraw;
     1866end;
     1867
     1868procedure TEngine.MenuItemBack(Sender: TObject);
     1869begin
     1870  if Assigned(Menu.Parent) then begin
     1871    Menu := Menu.Parent;
     1872    Redraw;
     1873  end;
     1874end;
     1875
     1876procedure TEngine.DarkModeChanged(Sender: TObject);
     1877begin
     1878
     1879end;
     1880
     1881procedure TEngine.LanguageChanged(Sender: TObject);
     1882var
     1883  NewLanguage: TLanguage;
     1884begin
     1885  NewLanguage := TLanguage(TMenuItemComboBox(MenuOptions.Items[0]).States.Objects[TMenuItemComboBox(MenuOptions.Items[0]).Index]);
     1886  if FormMain.Translator1.Language <> NewLanguage then begin
     1887    FormMain.Translator1.Language := NewLanguage;
     1888    FormMain.Translator1.Translate;
     1889    InitMenus;
     1890  end;
     1891end;
     1892
     1893procedure TEngine.InitMenus;
     1894begin
     1895  with MenuMain.Items do begin
     1896    Clear;
     1897    AddButton(SPlay, MenuItemPlay);
     1898    AddButton(SOptions, MenuItemOptions);
     1899    AddButton(SExit, MenuItemExit);
     1900  end;
     1901  MenuOptions.Parent := MenuMain;
     1902  with MenuOptions.Items do begin
     1903    Clear;
     1904    with AddComboBox(SLanguage, [], LanguageChanged) do begin
     1905      FormMain.Translator1.LanguageListToStrings(States);
     1906      Index := States.IndexOfObject(FormMain.Translator1.Language);
     1907      if Index = -1 then Index := 0;
     1908    end;
     1909    AddCheckBox(SDarkMode, DarkModeChanged);
     1910    AddButton(SBack, MenuItemBack);
     1911  end;
     1912end;
     1913
    18411914procedure TEngine.DrawClock(Canvas: TCanvas);
    18421915var
     
    18781951  Passenger: TMetroPassenger;
    18791952begin
    1880   // Draw trains
    18811953  for Train in Trains do
    18821954  with Train do begin
     
    19992071  LineStationUp: TLineStation;
    20002072  CurrentTrackPoint: TTrackPoint;
    2001 begin
     2073  I: Integer;
     2074begin
     2075  if State = gsMenu then begin
     2076    Menu.MouseMove(Position);
     2077    Redraw;
     2078  end;
     2079
    20022080  LastMousePos := Position;
    20032081  if MouseHold then begin
     
    20522130begin
    20532131  if Button = mbLeft then begin
    2054     // Place selected train if focused track
    2055     if Assigned(SelectedTrain) then begin
    2056       SelectedTrain.TargetStation := nil;
    2057       SelectedTrain.BaseTrackPoint := nil;
    2058       if Assigned(SelectedTrain.Line) then begin
    2059         SelectedTrain.Line.Trains.Remove(SelectedTrain);
    2060         SelectedTrain.Line := nil;
    2061       end;
    2062       FocusedTrack := GetTrackOnPos(View.PointDestToSrc(Position));
    2063       if Assigned(FocusedTrack.Points[0]) then begin
    2064         SelectedTrain.Line := FocusedTrack.Points[0].Track.Line;
    2065         SelectedTrain.Line.Trains.Add(SelectedTrain);
    2066         SelectedTrain.BaseTrackPoint := FocusedTrack.Points[0];
    2067       end else
    2068       if Assigned(FocusedTrack.Points[1]) then begin
    2069         SelectedTrain.Line := FocusedTrack.Points[1].Track.Line;
    2070         SelectedTrain.Line.Trains.Add(SelectedTrain);
    2071         SelectedTrain.BaseTrackPoint := FocusedTrack.Points[1];
    2072       end;
    2073       FocusedTrack.Free;
    2074     end;
    2075 
    2076     // Line color selection
    2077     for I := 0 to Lines.Count - 1 do
    2078       if Distance(Point(View.DestRect.Right div 2 - Length(LineColors) div 2 * LineColorsDist + I * LineColorsDist,
    2079         View.DestRect.Bottom - LineColorsDist), Position) < 20 then begin
    2080           SelectedLine := Lines[I];
    2081           Exit;
     2132    if State = gsMenu then begin
     2133      Menu.MouseUp(Button, Position);
     2134      Redraw;
     2135    end else begin
     2136        // Place selected train if focused track
     2137      if Assigned(SelectedTrain) then begin
     2138        SelectedTrain.TargetStation := nil;
     2139        SelectedTrain.BaseTrackPoint := nil;
     2140        if Assigned(SelectedTrain.Line) then begin
     2141          SelectedTrain.Line.Trains.Remove(SelectedTrain);
     2142          SelectedTrain.Line := nil;
    20822143        end;
    2083 
    2084     // Remove single line station on line
    2085     if Assigned(TrackStationDown) and (TrackStationDown.Track.Line.LineStations.Count = 1) then begin
    2086       TrackStationDown.Track.Line.DisconnectStation(TrackStationDown.Track.Line.LineStations.First);
    2087     end;
    2088     if Assigned(TrackStationUp) and (TrackStationUp.Track.Line.LineStations.Count = 1) then begin
    2089       TrackStationUp.Track.Line.DisconnectStation(TrackStationUp.Track.Line.LineStations.First);
     2144        FocusedTrack := GetTrackOnPos(View.PointDestToSrc(Position));
     2145        if Assigned(FocusedTrack.Points[0]) then begin
     2146          SelectedTrain.Line := FocusedTrack.Points[0].Track.Line;
     2147          SelectedTrain.Line.Trains.Add(SelectedTrain);
     2148          SelectedTrain.BaseTrackPoint := FocusedTrack.Points[0];
     2149        end else
     2150        if Assigned(FocusedTrack.Points[1]) then begin
     2151          SelectedTrain.Line := FocusedTrack.Points[1].Track.Line;
     2152          SelectedTrain.Line.Trains.Add(SelectedTrain);
     2153          SelectedTrain.BaseTrackPoint := FocusedTrack.Points[1];
     2154        end;
     2155        FocusedTrack.Free;
     2156      end;
     2157
     2158      // Line color selection
     2159      for I := 0 to Lines.Count - 1 do
     2160        if Distance(Point(View.DestRect.Right div 2 - Length(LineColors) div 2 * LineColorsDist + I * LineColorsDist,
     2161          View.DestRect.Bottom - LineColorsDist), Position) < 20 then begin
     2162            SelectedLine := Lines[I];
     2163            Exit;
     2164          end;
     2165
     2166      // Remove single line station on line
     2167      if Assigned(TrackStationDown) and (TrackStationDown.Track.Line.LineStations.Count = 1) then begin
     2168        TrackStationDown.Track.Line.DisconnectStation(TrackStationDown.Track.Line.LineStations.First);
     2169      end;
     2170      if Assigned(TrackStationUp) and (TrackStationUp.Track.Line.LineStations.Count = 1) then begin
     2171        TrackStationUp.Track.Line.DisconnectStation(TrackStationUp.Track.Line.LineStations.First);
     2172      end;
    20902173    end;
    20912174  end else
     
    21642247end;
    21652248
    2166 procedure TEngine.Reset;
     2249procedure TEngine.MainMenu;
     2250begin
     2251  State := gsMenu;
     2252  Redraw;
     2253end;
     2254
     2255procedure TEngine.NewGame;
    21672256var
    21682257  NewTrain: TMetroTrain;
     
    22142303constructor TEngine.Create;
    22152304begin
     2305  MenuMain := TMenu.Create;
     2306  MenuOptions := TMenu.Create;
     2307  Menu := MenuMain;
     2308  InitMenus;
    22162309  Stations := TMapStations.Create;
    22172310  Stations.Engine := Self;
     
    22432336  FreeAndNil(Stations);
    22442337  FreeAndNil(Lines);
     2338  FreeAndNil(MenuMain);
     2339  FreeAndNil(MenuOptions);
    22452340  inherited;
    22462341end;
     
    23422437    *)
    23432438  end;
     2439
    23442440  // Draw design time lines
    23452441  if Assigned(TrackStationDown) and Assigned(TrackStationDown.LineStation) then begin
     
    24052501  end;
    24062502
    2407   // Clear background
     2503  // MainMenu background
    24082504  TargetCanvas.Brush.Color := $eff0e0;
    24092505  TargetCanvas.Brush.Style := bsSolid;
     
    24162512  MetaCanvas.DrawTo(TargetCanvas);
    24172513
    2418   // Line selection
    2419   TargetCanvas.Pen.Width := 4;
    2420   for I := 0 to High(LineColors) do begin
    2421     if Assigned(Lines.SearchByColor(LineColors[I])) then begin
    2422       TargetCanvas.Brush.Color := LineColors[I];
    2423       Size := 15;
    2424     end else begin
    2425       TargetCanvas.Brush.Color := clSilver;
    2426       Size := 5;
    2427     end;
    2428     TargetCanvas.Pen.Color := clBlack;
    2429     if Assigned(SelectedLine) and (SelectedLine.Color = LineColors[I]) then begin
    2430       TargetCanvas.Pen.Style := psSolid;
    2431     end else begin
    2432       TargetCanvas.Pen.Style := psClear;
    2433     end;
    2434 
    2435     TargetCanvas.EllipseC(TargetCanvas.Width div 2 - Length(LineColors) div 2 * LineColorsDist + I * LineColorsDist,
    2436       TargetCanvas.Height - LineColorsDist, Size, Size);
    2437   end;
    2438 
    2439   // Draw unused trains
    2440   Text := IntToStr(Trains.GetUnusedCount);
    2441   TargetCanvas.Draw(Canvas.Width div 2 - Length(LineColors) div 2 * LineColorsDist - 100,
    2442     TargetCanvas.Height - LineColorsDist - ImageLocomotive.Picture.Bitmap.Height div 2, ImageLocomotive.Picture.Bitmap);
    2443   TargetCanvas.Brush.Style := bsClear;
    2444   TargetCanvas.Font.Size := 14;
    2445   TargetCanvas.Font.Color := clBlack;
    2446   TargetCanvas.TextOut(TargetCanvas.Width div 2 - Length(LineColors) div 2 * LineColorsDist - 50 - TargetCanvas.TextWidth(Text),
    2447     TargetCanvas.Height - LineColorsDist - TargetCanvas.TextHeight(Text) div 2, Text);
    2448 
    2449   // Status interface
    2450   Text := IntToStr(ServedPassengerCount);
    2451   TargetCanvas.Draw(TargetCanvas.Width - 50, TargetCanvas.Height - 60, ImagePassenger.Picture.Bitmap);
    2452   TargetCanvas.Brush.Style := bsClear;
    2453   TargetCanvas.Font.Size := 14;
    2454   TargetCanvas.Font.Color := clBlack;
    2455   TargetCanvas.TextOut(TargetCanvas.Width - 70 - TargetCanvas.TextWidth(Text), TargetCanvas.Height - 55, Text);
    2456 
    2457   DrawClock(TargetCanvas);
    2458 
    2459   // Show grabbed train by mouse
     2514  if State <> gsMenu then begin
     2515    // Line selection
     2516    TargetCanvas.Pen.Width := 4;
     2517    for I := 0 to High(LineColors) do begin
     2518      if Assigned(Lines.SearchByColor(LineColors[I])) then begin
     2519        TargetCanvas.Brush.Color := LineColors[I];
     2520        Size := 15;
     2521      end else begin
     2522        TargetCanvas.Brush.Color := clSilver;
     2523        Size := 5;
     2524      end;
     2525      TargetCanvas.Pen.Color := clBlack;
     2526      if Assigned(SelectedLine) and (SelectedLine.Color = LineColors[I]) then begin
     2527        TargetCanvas.Pen.Style := psSolid;
     2528      end else begin
     2529        TargetCanvas.Pen.Style := psClear;
     2530      end;
     2531
     2532      TargetCanvas.EllipseC(TargetCanvas.Width div 2 - Length(LineColors) div 2 * LineColorsDist + I * LineColorsDist,
     2533        TargetCanvas.Height - LineColorsDist, Size, Size);
     2534    end;
     2535
     2536    // Draw unused trains
     2537    Text := IntToStr(Trains.GetUnusedCount);
     2538    TargetCanvas.Draw(Canvas.Width div 2 - Length(LineColors) div 2 * LineColorsDist - 100,
     2539      TargetCanvas.Height - LineColorsDist - ImageLocomotive.Picture.Bitmap.Height div 2, ImageLocomotive.Picture.Bitmap);
     2540    TargetCanvas.Brush.Style := bsClear;
     2541    TargetCanvas.Font.Size := 14;
     2542    TargetCanvas.Font.Color := clBlack;
     2543    TargetCanvas.TextOut(TargetCanvas.Width div 2 - Length(LineColors) div 2 * LineColorsDist - 50 - TargetCanvas.TextWidth(Text),
     2544      TargetCanvas.Height - LineColorsDist - TargetCanvas.TextHeight(Text) div 2, Text);
     2545
     2546    // Status interface
     2547    Text := IntToStr(ServedPassengerCount);
     2548    TargetCanvas.Draw(TargetCanvas.Width - 50, TargetCanvas.Height - 60, ImagePassenger.Picture.Bitmap);
     2549    TargetCanvas.Brush.Style := bsClear;
     2550    TargetCanvas.Font.Size := 14;
     2551    TargetCanvas.Font.Color := clBlack;
     2552    TargetCanvas.TextOut(TargetCanvas.Width - 70 - TargetCanvas.TextWidth(Text), TargetCanvas.Height - 55, Text);
     2553
     2554    DrawClock(TargetCanvas);
     2555  end;
     2556
     2557  // Show train grabbed by mouse
    24602558  if Assigned(SelectedTrain) then begin
    24612559    TargetCanvas.Brush.Color := clBlack; //SelectedTrain.Line.Color;
     
    24832581    Text := Format(SGameOverStatistic, [ServedPassengerCount, Trunc(Time)]);
    24842582    TargetCanvas.TextOut((TargetCanvas.Width - TargetCanvas.TextWidth(Text)) div 2, 180, Text);
    2485   end;
     2583  end else
     2584  if State = gsMenu then begin
     2585    Menu.Paint(TargetCanvas);
     2586  end;
     2587
    24862588  RedrawPending := False;
    24872589end;
Note: See TracChangeset for help on using the changeset viewer.