Changeset 66


Ignore:
Timestamp:
Nov 26, 2020, 11:00:03 PM (4 years ago)
Author:
chronos
Message:
  • Added: Show highes score on game over.
  • Fixed: Applied dark mode colors to stations.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r64 r66  
    189189    end else Translator1.Language := Translator1.Languages.SearchByCode('');
    190190    Engine.DarkMode := ReadBoolWithDefault('DarkMode', False);
     191    Engine.HighestServedPassengerCount := ReadIntegerWithDefault('HighestPassengers', 0);
     192    Engine.HighestServedDaysCount := ReadIntegerWithDefault('HighestDays', 0);
    191193  finally
    192194    Free;
     
    204206      else DeleteValue('LanguageCode');
    205207    WriteBool('DarkMode', Engine.DarkMode);
     208    WriteInteger('HighestPassengers', Engine.HighestServedPassengerCount);
     209    WriteInteger('HighestDays', Engine.HighestServedDaysCount);
    206210  finally
    207211    Free;
  • trunk/Languages/BigMetro.cs.po

    r64 r66  
    2525msgstr "Pokus o rozpojení již připojeného bodu trasy"
    2626
     27#: uengine.sday
     28msgid "Day"
     29msgstr "Den"
     30
    2731#: uengine.sgameover
    2832msgid "Game Over"
     
    3640msgid "%d passengers travelled on your metro over %d days."
    3741msgstr "%d cestujících cestovalo ve vašem metru během %d dnů."
     42
     43#: uengine.snewhighscore
     44msgid "New high score!"
     45msgstr "Nové vysoké skóre!"
     46
     47#: uengine.soldhighscore
     48msgid "Old high score was %d passengers in %d days."
     49msgstr "Dřívější vysoké skóre bylo %d cestujících v %d dnech."
    3850
    3951#: uengine.szerozoomnotalowed
  • trunk/Languages/BigMetro.po

    r64 r66  
    1515msgstr ""
    1616
     17#: uengine.sday
     18msgid "Day"
     19msgstr ""
     20
    1721#: uengine.sgameover
    1822msgid "Game Over"
     
    2529#: uengine.sgameoverstatistic
    2630msgid "%d passengers travelled on your metro over %d days."
     31msgstr ""
     32
     33#: uengine.snewhighscore
     34msgid "New high score!"
     35msgstr ""
     36
     37#: uengine.soldhighscore
     38msgid "Old high score was %d passengers in %d days."
    2739msgstr ""
    2840
  • trunk/UEngine.pas

    r65 r66  
    22
    33{$mode delphi}
     4{$IFDEF DARWIN}{$modeswitch Objectivec1}{$ENDIF}
    45
    56interface
    67
    78uses
     9  {$IFDEF Darwin}MacOSAll, CocoaAll, CocoaUtils,{$ENDIF}
    810  Classes, SysUtils, Graphics, Controls, ExtCtrls, Math, DateUtils,
    911  UMetaCanvas, fgl, UMenu;
     
    2830    Background: TColor;
    2931    Text: TColor;
     32    ShapeBackground: TColor;
    3033    MenuItemText: TColor;
    3134    MenuItemBackground: TColor;
     
    290293    MenuGame: TMenu;
    291294    ButtonBack: TMenuItemButton;
     295    function GetServedDaysCount: Integer;
    292296    procedure ResizeView;
    293297    function GetExistStationShapes: TStationShapeSet;
     
    338342    ImagePassenger: TImage;
    339343    ImageLocomotive: TImage;
     344    HighestServedPassengerCount: Integer;
     345    HighestServedDaysCount: Integer;
    340346    procedure InitMenus;
    341347    procedure MouseMove(Position: TPoint);
     
    353359    property Time: TDateTime read FTime;
    354360    property DarkMode: Boolean read FDarkMode write SetDarkMode;
     361    property ServedDaysCount: Integer read GetServedDaysCount;
    355362  end;
    356363
     
    400407  SGameOverReason = 'Overcrowding at this station has forced you to resign as metro manager.';
    401408  SGameOverStatistic = '%d passengers travelled on your metro over %d days.';
     409  SDay = 'Day';
     410  SNewHighScore = 'New high score!';
     411  SOldHighScore = 'Old high score was %d passengers in %d days.';
    402412
    403413{ TTrackLinks }
     
    13561366  View.SourceRect := Bounds(NewPoint.X, NewPoint.Y, Trunc((View.DestRect.Right - View.DestRect.Left) / View.Zoom),
    13571367    Trunc((View.DestRect.Bottom - View.DestRect.Top) / View.Zoom));
     1368end;
     1369
     1370function TEngine.GetServedDaysCount: Integer;
     1371begin
     1372  Result := Trunc(Time);
    13581373end;
    13591374
     
    16551670    Background := $2f3020;
    16561671    Text := clWhite;
     1672    ShapeBackground := clBlack;
    16571673    MenuItemText := $cccccc;
    16581674    MenuItemBackground := $b75C01;
     
    16611677    Background := $eff0e0;
    16621678    Text := clBlack;
     1679    ShapeBackground := clWhite;
    16631680    MenuItemText := clWhite;
    16641681    MenuItemBackground := $e78C31;
     
    20672084  Angle: Double;
    20682085  Text: string;
     2086  Text2: string;
    20692087  I: Integer;
    20702088const
     
    20792097  Canvas.Line(ClockCenter, Point(ClockCenter.X + Round(Cos(Angle) * ClockSize * 0.8),
    20802098    ClockCenter.Y + Round(Sin(Angle) * ClockSize * 0.8)));
    2081   Text := FormatDateTime('ddd', Time);
    2082   Canvas.TextOut(ClockCenter.X - ClockSize - Canvas.TextWidth(Text) - 5, ClockCenter.Y -
    2083     Canvas.TextWidth(Text) div 2, Text);
    20842099  for I := 0 to 12 do begin
    20852100    Angle := I / 12 * 2 * Pi;
     
    20892104      ClockCenter.Y + Round(Sin(Angle) * ClockSize * 0.9));
    20902105  end;
     2106
     2107  Canvas.Font.Color := Colors.Text;
     2108  Text := FormatDateTime('ddd', Time + 2);
     2109  Canvas.TextOut(ClockCenter.X - ClockSize - Canvas.TextWidth(Text) - 10, ClockCenter.Y -
     2110    Canvas.TextHeight(Text) div 2, Text);
     2111
     2112  Text2 := SDay + ' ' + IntToStr(Trunc(Time));
     2113  Canvas.TextOut(ClockCenter.X - ClockSize - Canvas.TextWidth(Text) - 10, ClockCenter.Y -
     2114    Canvas.TextHeight(Text2) div 2 + Trunc(Canvas.TextHeight(Text) * 1.1), Text2);
    20912115end;
    20922116
     
    21402164    Font.Size := 40;
    21412165    TextOut((Width - TextWidth(SGameOver)) div 2, Y, SGameOver);
    2142 
    21432166    Y := Y + Round(TextHeight(SGameOver) * 1.1);
     2167
    21442168    Font.Size := 14;
    21452169    TextOut((Width - TextWidth(SGameOverReason)) div 2, Y, SGameOverReason);
    2146 
    21472170    Y := Y + Round(TextHeight(SGameOverReason) * 1.1);
    2148     Text := Format(SGameOverStatistic, [ServedPassengerCount, Trunc(Time)]);
     2171
     2172    Text := Format(SGameOverStatistic, [ServedPassengerCount, ServedDaysCount]);
    21492173    TextOut((Width - TextWidth(Text)) div 2, Y, Text);
     2174    Y := Y + Round(TextHeight(SGameOverStatistic) * 1.1);
     2175
     2176    Y := Y + 16;
     2177
     2178    // Calculate new highest score
     2179    Text := '';
     2180    if (ServedPassengerCount > HighestServedPassengerCount) or
     2181      (ServedDaysCount > HighestServedDaysCount) then begin
     2182      Text := SNewHighScore + ' ';
     2183    end;
     2184    Text := Text + Format(SOldHighScore, [HighestServedPassengerCount,
     2185      HighestServedDaysCount]);
     2186    Canvas.TextOut((Canvas.Width - Canvas.TextWidth(Text)) div 2, Y, Text);
     2187    Y := Y + Round(TextHeight(Text) * 1.1);
     2188    if (ServedPassengerCount > HighestServedPassengerCount) then
     2189      HighestServedPassengerCount := ServedPassengerCount;
     2190    if (ServedDaysCount > HighestServedDaysCount) then
     2191      HighestServedDaysCount := ServedDaysCount;
    21502192  end;
    21512193end;
     
    24292471const
    24302472  KeyEsc = 27;
     2473  KeyF2 = 113;
    24312474begin
    24322475  if Key = KeyEsc then begin
     
    24382481    end;
    24392482  end;
     2483  {$IFDEF DEBUG}
     2484  if Key = KeyF2 then begin
     2485    State := gsGameOver;
     2486    Redraw;
     2487  end;
     2488  {$ENDIF}
    24402489end;
    24412490
     
    26692718    end;
    26702719
    2671     Canvas.Brush.Color := clWhite;
     2720    Canvas.Brush.Color := Colors.ShapeBackground;
    26722721    Canvas.Brush.Style := bsSolid;
    2673     Canvas.Pen.Color := clBlack;
     2722    Canvas.Pen.Color := Colors.Text;
    26742723    DrawShape(Canvas, Position, Shape, StationSize, 0);
    26752724
    26762725    // Draw passengers
    26772726    Canvas.Pen.Style := psClear;
    2678     Canvas.Brush.Color := clBlack;
     2727    Canvas.Brush.Color := Colors.Text;
    26792728    PassengerPos := Point(0, 0);
    26802729    Direction := 1;
Note: See TracChangeset for help on using the changeset viewer.