Changeset 99


Ignore:
Timestamp:
Sep 28, 2022, 4:28:06 PM (2 years ago)
Author:
chronos
Message:
  • Fixed: Redrawing scene during paused game.
  • Fixed: Disable controls during game over.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Languages/BigMetro.cs.po

    r96 r99  
    7373msgstr "Odejít"
    7474
     75#: uengine.sfrench
     76msgid "French"
     77msgstr "Francouzština"
     78
    7579#: uengine.sfullscreen
    7680msgctxt "uengine.sfullscreen"
     
    8387
    8488#: uengine.sgameoverreason
    85 msgid "Overcrowding at this station has forced you to resign as metro manager."
    86 msgstr "Přeplnění v této stanici vás donutilo odstoupit z pozice správce metra."
     89msgid "Overcrowding at one of your stations has forced you to resign as metro manager."
     90msgstr "Přeplnění v jedné z tvých stanic tě donutilo odstoupit z pozice správce metra."
    8791
    8892#: uengine.sgameoverstatistic
    8993#, object-pascal-format
    9094msgid "%d passengers travelled on your metro over %d days."
    91 msgstr "%d cestujících cestovalo ve vašem metru během %d dnů."
     95msgstr "%d cestujících cestovalo ve tvém metru během %d dnů."
     96
     97#: uengine.sgerman
     98msgid "German"
     99msgstr "Němčina"
    92100
    93101#: uengine.slanguage
     
    151159msgid "Try again"
    152160msgstr "Zkusit znovu"
     161
     162#: uengine.srome
     163msgid "Rome"
     164msgstr "Řím"
    153165
    154166#: uengine.sstationnotdefined
  • trunk/Languages/BigMetro.de.po

    r96 r99  
    8181msgstr "Beenden"
    8282
     83#: uengine.sfrench
     84msgid "French"
     85msgstr ""
     86
    8387#: uengine.sfullscreen
    8488#, fuzzy
     
    9296
    9397#: uengine.sgameoverreason
    94 msgid "Overcrowding at this station has forced you to resign as metro manager."
     98#, fuzzy
     99#| msgid "Overcrowding at this station has forced you to resign as metro manager."
     100msgid "Overcrowding at one of your stations has forced you to resign as metro manager."
    95101msgstr "Die Passagiere an einer Station haben zu lange gewartet. Du musst als Metro manager zurücktreten."
    96102
     
    100106msgstr "%d Passagiere fuhren mit deiner Metro über %d Tage."
    101107
     108#: uengine.sgerman
     109msgid "German"
     110msgstr ""
     111
    102112#: uengine.slanguage
    103113#, fuzzy
     
    165175msgstr "Neustart"
    166176
     177#: uengine.srome
     178msgid "Rome"
     179msgstr ""
     180
    167181#: uengine.sstationnotdefined
    168182msgid "Station have to be defined"
  • trunk/Languages/BigMetro.fr.po

    r96 r99  
    8181msgstr "Sortie"
    8282
     83#: uengine.sfrench
     84msgid "French"
     85msgstr ""
     86
    8387#: uengine.sfullscreen
    8488#, fuzzy
     
    9296
    9397#: uengine.sgameoverreason
    94 msgid "Overcrowding at this station has forced you to resign as metro manager."
     98#, fuzzy
     99#| msgid "Overcrowding at this station has forced you to resign as metro manager."
     100msgid "Overcrowding at one of your stations has forced you to resign as metro manager."
    95101msgstr "Les passagers ont attendu trop longtemps. Vous avez été licencié."
    96102
     
    100106msgstr "%d passagers ont pris votre métro pendant %d jours."
    101107
     108#: uengine.sgerman
     109msgid "German"
     110msgstr ""
     111
    102112#: uengine.slanguage
    103113#, fuzzy
     
    165175msgstr "Redémarrer"
    166176
     177#: uengine.srome
     178msgid "Rome"
     179msgstr ""
     180
    167181#: uengine.sstationnotdefined
    168182msgid "Station have to be defined"
  • trunk/Languages/BigMetro.pot

    r96 r99  
    6363msgstr ""
    6464
     65#: uengine.sfrench
     66msgid "French"
     67msgstr ""
     68
    6569#: uengine.sfullscreen
    6670msgctxt "uengine.sfullscreen"
     
    7377
    7478#: uengine.sgameoverreason
    75 msgid "Overcrowding at this station has forced you to resign as metro manager."
     79msgid "Overcrowding at one of your stations has forced you to resign as metro manager."
    7680msgstr ""
    7781
     
    8185msgstr ""
    8286
     87#: uengine.sgerman
     88msgid "German"
     89msgstr ""
     90
    8391#: uengine.slanguage
    8492msgctxt "uengine.slanguage"
     
    140148msgctxt "uengine.srestart"
    141149msgid "Try again"
     150msgstr ""
     151
     152#: uengine.srome
     153msgid "Rome"
    142154msgstr ""
    143155
  • trunk/UEngine.pas

    r98 r99  
    187187    function GetTrainOnPos(Pos: TPoint): TMetroTrain;
    188188    function GetCarriageOnPos(Pos: TPoint): TMetroCarriage;
     189    procedure DrawFrame(Canvas: TCanvas; Rect: TRect);
    189190    procedure DrawLine(Canvas: TCanvas; Pos: TPoint);
    190191    procedure DrawShape(Canvas: TCanvas; Position: TPoint; Shape: TStationShape;
     
    329330resourcestring
    330331  SGameOver = 'Game Over';
    331   SGameOverReason = 'Overcrowding at this station has forced you to resign as metro manager.';
     332  SGameOverReason = 'Overcrowding at one of your stations has forced you to resign as metro manager.';
    332333  SGameOverStatistic = '%d passengers travelled on your metro over %d days.';
    333334  SDay = 'Day';
     
    349350  SCzech = 'Czech';
    350351  SEnglish = 'English';
     352  SFrench = 'French';
     353  SGerman = 'German';
    351354  SBack = 'Back';
    352355  SAutomatic = 'Automatic';
     
    365368  SNewYork = 'New York';
    366369  STokyo = 'Tokyo';
     370  SRome = 'Rome';
    367371
    368372{ TMetroCarriage }
     
    11501154      end;
    11511155    end;
     1156  end;
     1157end;
     1158
     1159procedure TEngine.DrawFrame(Canvas: TCanvas; Rect: TRect);
     1160begin
     1161  with Canvas do begin
     1162    Pen.Color := Self.Colors.Text;
     1163    Pen.Style := psSolid;
     1164    Pen.Width := ScaleX(2, 96);
     1165    Brush.Color := Self.Colors.Background2;
     1166    Brush.Style := bsSolid;
     1167    Rectangle(Rect);
     1168    Pen.Style := psClear;
    11521169  end;
    11531170end;
     
    21102127begin
    21112128  with Canvas do begin
     2129    DrawFrame(Canvas, Bounds(CanvasSize.X div 8,  ScaleY(90, 96),
     2130      Round(CanvasSize.X / 4 * 3), ScaleY(210, 96)));
     2131
    21122132    Canvas.Font.Color := Self.Colors.Text;
    2113     Brush.Style := bsSolid;
    2114     Brush.Color := Self.Colors.Background;
     2133    Brush.Style := bsClear;
     2134    Pen.Style := psClear;
    21152135
    21162136    Y := ScaleY(100, 96);
     2137
    21172138    Font.Size := 40;
    21182139    TextOut((CanvasSize.X - TextWidth(SGameOver)) div 2, Y, SGameOver);
     
    21522173  Y: Integer;
    21532174  X: Integer;
    2154 const
    2155   ImageZoom = 4;
    21562175begin
    21572176  with Canvas do begin
    2158     Pen.Color := Self.Colors.Text;
    2159     Pen.Style := psSolid;
    2160     Pen.Width := ScaleX(2, 96);
    2161     Brush.Color := Self.Colors.Background2;
    2162     Brush.Style := bsSolid;
    2163     Rectangle(Bounds(CanvasSize.X div 4, CanvasSize.Y div 4, CanvasSize.X div 2, CanvasSize.Y div 2));
    2164     Pen.Style := psClear;
     2177
     2178    DrawFrame(Canvas, Bounds(CanvasSize.X div 4, CanvasSize.Y div 4, CanvasSize.X div 2, CanvasSize.Y div 2));
    21652179    X := CanvasSize.X div 4 + ScaleX(10, 96);
    21662180    Y := CanvasSize.Y div 4 + ScaleX(10, 96);
     
    22082222    Center := Point(CanvasSize.X div 2, CanvasSize.Y div 2);
    22092223
    2210     Pen.Color := Self.Colors.Text;
    2211     Pen.Style := psSolid;
    2212     Pen.Width := ScaleX(2, 96);
    2213     Brush.Color := Self.Colors.Background2;
    2214     Brush.Style := bsSolid;
    2215     Rectangle(Bounds(CanvasSize.X div 4, CanvasSize.Y div 4, CanvasSize.X div 2, CanvasSize.Y div 2));
    2216     Pen.Style := psClear;
     2224    DrawFrame(Canvas, Bounds(CanvasSize.X div 4, CanvasSize.Y div 4, CanvasSize.X div 2, CanvasSize.Y div 2));
    22172225    X := CanvasSize.X div 4 + ScaleX(10, 96);
    22182226    Y := CanvasSize.Y div 4 + ScaleX(10, 96);
     
    26442652  end;
    26452653
     2654  if Assigned(SelectedTrain) or Assigned(SelectedCarriage) then Redraw;
     2655
    26462656  LastMousePos := Position;
    26472657  if MouseHold then begin
    2648       FocusedStation := GetStationOnPos(View.PointDestToSrc(Position));
    2649       Line := nil;
    2650       if Assigned(TrackStationDown) then begin
    2651         Line := TMetroLine(TrackStationDown.Track.Owner);
    2652         Redraw;
    2653       end;
    2654       if Assigned(TrackStationUp) then begin
    2655         Line := TMetroLine(TrackStationUp.Track.Owner);
    2656         Redraw;
    2657       end;
    2658       if Assigned(Line) and not Assigned(LastFocusedStation) and Assigned(FocusedStation) then begin
    2659         if Assigned(TrackStationDown) and (TLineStation(TrackStationDown.OwnerPoint).MapStation = FocusedStation) then begin
    2660           // Disconnect down
    2661           CurrentTrackPoint := TrackStationDown;
    2662           TrackStationDown := TrackStationDown.GetDown;
    2663           Line.DisconnectStation(TLineStation(CurrentTrackPoint.OwnerPoint));
    2664         end else
    2665         if Assigned(TrackStationUp) and (TLineStation(TrackStationUp.OwnerPoint).MapStation = FocusedStation) then begin
    2666           // Disconnect up
    2667           CurrentTrackPoint := TrackStationUp;
    2668           if Assigned(TrackStationUp) then
    2669             TrackStationUp := TrackStationUp.GetUp;
    2670           Line.DisconnectStation(TLineStation(CurrentTrackPoint.OwnerPoint));
    2671         end else
    2672         if Assigned(Line) and ((not Line.IsCircular) or ((TrackStationDown <> nil) and (TrackStationUp <> nil))) and
    2673         ((Line.LineStations.SearchMapStation(FocusedStation) = nil) or
    2674         ((Line.LineStations.Count > 0) and
    2675         ((Line.LineStations.First.MapStation = FocusedStation) or
    2676         (Line.LineStations.Last.MapStation = FocusedStation)) and
    2677         ((TrackStationDown = nil) or (TrackStationUp = nil)) and
    2678         (not Line.IsCircular))) then begin
    2679           if Assigned(TrackStationDown) then LineStationDown := TLineStation(TrackStationDown.OwnerPoint)
    2680             else LineStationDown := nil;
    2681           if Assigned(TrackStationUp) then LineStationUp := TLineStation(TrackStationUp.OwnerPoint)
    2682             else LineStationUp := nil;
    2683           Line.ConnectStation(FocusedStation, LineStationDown, LineStationUp);
    2684           if Assigned(TrackStationDown) then TrackStationDown := TrackStationDown.GetUp
    2685             else if Assigned(TrackStationUp) then TrackStationUp := TrackStationUp.GetDown;
    2686         end;
    2687       end;
    2688       LastFocusedStation := FocusedStation;
     2658    FocusedStation := GetStationOnPos(View.PointDestToSrc(Position));
     2659    Line := nil;
     2660    if Assigned(TrackStationDown) then begin
     2661      Line := TMetroLine(TrackStationDown.Track.Owner);
     2662      Redraw;
     2663    end;
     2664    if Assigned(TrackStationUp) then begin
     2665      Line := TMetroLine(TrackStationUp.Track.Owner);
     2666      Redraw;
     2667    end;
     2668    if Assigned(Line) and not Assigned(LastFocusedStation) and Assigned(FocusedStation) then begin
     2669      if Assigned(TrackStationDown) and (TLineStation(TrackStationDown.OwnerPoint).MapStation = FocusedStation) then begin
     2670        // Disconnect down
     2671        CurrentTrackPoint := TrackStationDown;
     2672        TrackStationDown := TrackStationDown.GetDown;
     2673        Line.DisconnectStation(TLineStation(CurrentTrackPoint.OwnerPoint));
     2674      end else
     2675      if Assigned(TrackStationUp) and (TLineStation(TrackStationUp.OwnerPoint).MapStation = FocusedStation) then begin
     2676        // Disconnect up
     2677        CurrentTrackPoint := TrackStationUp;
     2678        if Assigned(TrackStationUp) then
     2679          TrackStationUp := TrackStationUp.GetUp;
     2680        Line.DisconnectStation(TLineStation(CurrentTrackPoint.OwnerPoint));
     2681      end else
     2682      if Assigned(Line) and ((not Line.IsCircular) or ((TrackStationDown <> nil) and (TrackStationUp <> nil))) and
     2683      ((Line.LineStations.SearchMapStation(FocusedStation) = nil) or
     2684      ((Line.LineStations.Count > 0) and
     2685      ((Line.LineStations.First.MapStation = FocusedStation) or
     2686      (Line.LineStations.Last.MapStation = FocusedStation)) and
     2687      ((TrackStationDown = nil) or (TrackStationUp = nil)) and
     2688      (not Line.IsCircular))) then begin
     2689        if Assigned(TrackStationDown) then LineStationDown := TLineStation(TrackStationDown.OwnerPoint)
     2690          else LineStationDown := nil;
     2691        if Assigned(TrackStationUp) then LineStationUp := TLineStation(TrackStationUp.OwnerPoint)
     2692          else LineStationUp := nil;
     2693        Line.ConnectStation(FocusedStation, LineStationDown, LineStationUp);
     2694        if Assigned(TrackStationDown) then TrackStationDown := TrackStationDown.GetUp
     2695          else if Assigned(TrackStationUp) then TrackStationUp := TrackStationUp.GetDown;
     2696      end;
     2697    end;
     2698    LastFocusedStation := FocusedStation;
    26892699  end;
    26902700end;
     
    27002710      Menu.MouseUp(Button, Position);
    27012711      Redraw;
     2712    end else
     2713    if State = gsGameOver then begin
     2714      ButtonBack.MouseUp(Position);
    27022715    end else
    27032716    if State = gsNewWeek then begin
     
    27092722    end
    27102723    else
    2711     if State = gsRunning then begin
     2724    if State in [gsRunning, gsPaused] then begin
    27122725      ButtonBack.MouseUp(Position);
    27132726      ImagePause.MouseUp(Position);
    27142727      ImagePlay.MouseUp(Position);
    27152728      ImageFastForward.MouseUp(Position);
     2729      Redraw;
    27162730
    27172731      // Place selected train if focused track
     
    27932807  NewIndex: Integer;
    27942808begin
    2795   if (Button = mbLeft) and (State <> gsMenu) then begin
    2796     MouseHold := True;
    2797     LastFocusedStation := nil;
    2798 
    2799     // Train selection
    2800     SelectedTrain := GetTrainOnPos(View.PointDestToSrc(Position));
    2801     if Assigned(SelectedTrain) then begin
    2802       Exit;
    2803     end;
    2804 
    2805     // Carriage selection
    2806     SelectedCarriage := GetCarriageOnPos(View.PointDestToSrc(Position));
    2807     if Assigned(SelectedCarriage) then begin
    2808       Exit;
    2809     end;
    2810 
    2811     // Select unused train
    2812     if (Distance(Position, ImageLocomotive.Bounds.CenterPoint) < 30) and
    2813     (Trains.GetUnusedCount > 0) then begin
    2814       SelectedTrain := Trains.GetUnused;
    2815       Exit;
    2816     end;
    2817 
    2818     // Select unused carriage
    2819     if (Distance(Position, ImageCarriage.Bounds.CenterPoint) < 30) and
    2820     (Carriages.GetUnusedCount > 0) then begin
    2821       SelectedCarriage := Carriages.GetUnused;
    2822       Exit;
    2823     end;
    2824 
    2825     // New track creation from selected station as start
    2826     Station := GetStationOnPos(View.PointDestToSrc(Position));
    2827     if Assigned(Station) then begin
    2828       if Assigned(SelectedLine) and (SelectedLine.LineStations.Count = 0) then NewLine := SelectedLine
    2829         else NewLine := GetUnusedLine;
    2830       if Assigned(NewLine) then begin
    2831         NewLine.ConnectStation(Station, nil, nil);
    2832         TrackStationDown := NewLine.Track.Points.Last;
    2833         TrackStationUp := nil;
    2834         LastFocusedStation := Station;
    2835         SelectedLine := NewLine;
     2809  if (Button = mbLeft) then begin
     2810    if State in [gsRunning, gsPaused] then begin
     2811      MouseHold := True;
     2812      LastFocusedStation := nil;
     2813      Redraw;
     2814
     2815      // Train selection
     2816      SelectedTrain := GetTrainOnPos(View.PointDestToSrc(Position));
     2817      if Assigned(SelectedTrain) then begin
    28362818        Exit;
    28372819      end;
    2838     end;
    2839 
    2840     // Line selection
    2841     Track := GetTrackOnPos(View.PointDestToSrc(Position));
    2842     if Assigned(Track) and Assigned(Track.Points[0]) and Assigned(Track.Points[1]) then begin
    2843       SelectedLine := TMetroLine(Track.Points[0].Track.Owner);
    2844 
    2845       TrackStationDown := Track.Points[0];
    2846       NewIndex := TrackStationDown.Track.Points.IndexOf(TrackStationDown);
    2847       while Assigned(TrackStationDown) and (not Assigned(TrackStationDown.OwnerPoint)) do begin
    2848         NewIndex := NewIndex - 1;
    2849         if NewIndex >= 0 then TrackStationDown := TrackStationDown.Track.Points[NewIndex]
    2850           else TrackStationDown := nil;
    2851       end;
    2852       TrackStationUp := Track.Points[1];
    2853       NewIndex := TrackStationUp.Track.Points.IndexOf(TrackStationDown);
    2854       while Assigned(TrackStationUp) and (not Assigned(TrackStationUp.OwnerPoint)) do begin
    2855         NewIndex := NewIndex + 1;
    2856         if NewIndex < TrackStationUp.Track.Points.Count then
    2857           TrackStationUp := TrackStationUp.Track.Points[NewIndex]
    2858           else TrackStationUp := nil;
    2859       end;
    2860       Track.Free;
    2861       Exit;
    2862     end;
    2863     if Assigned(Track) then Track.Free;
     2820
     2821      // Carriage selection
     2822      SelectedCarriage := GetCarriageOnPos(View.PointDestToSrc(Position));
     2823      if Assigned(SelectedCarriage) then begin
     2824        Exit;
     2825      end;
     2826
     2827      // Select unused train
     2828      if (Distance(Position, ImageLocomotive.Bounds.CenterPoint) < 30) and
     2829      (Trains.GetUnusedCount > 0) then begin
     2830        SelectedTrain := Trains.GetUnused;
     2831        Exit;
     2832      end;
     2833
     2834      // Select unused carriage
     2835      if (Distance(Position, ImageCarriage.Bounds.CenterPoint) < 30) and
     2836      (Carriages.GetUnusedCount > 0) then begin
     2837        SelectedCarriage := Carriages.GetUnused;
     2838        Exit;
     2839      end;
     2840
     2841      // New track creation from selected station as start
     2842      Station := GetStationOnPos(View.PointDestToSrc(Position));
     2843      if Assigned(Station) then begin
     2844        if Assigned(SelectedLine) and (SelectedLine.LineStations.Count = 0) then NewLine := SelectedLine
     2845          else NewLine := GetUnusedLine;
     2846        if Assigned(NewLine) then begin
     2847          NewLine.ConnectStation(Station, nil, nil);
     2848          TrackStationDown := NewLine.Track.Points.Last;
     2849          TrackStationUp := nil;
     2850          LastFocusedStation := Station;
     2851          SelectedLine := NewLine;
     2852          Exit;
     2853        end;
     2854      end;
     2855
     2856      // Line selection
     2857      Track := GetTrackOnPos(View.PointDestToSrc(Position));
     2858      if Assigned(Track) and Assigned(Track.Points[0]) and Assigned(Track.Points[1]) then begin
     2859        SelectedLine := TMetroLine(Track.Points[0].Track.Owner);
     2860
     2861        TrackStationDown := Track.Points[0];
     2862        NewIndex := TrackStationDown.Track.Points.IndexOf(TrackStationDown);
     2863        while Assigned(TrackStationDown) and (not Assigned(TrackStationDown.OwnerPoint)) do begin
     2864          NewIndex := NewIndex - 1;
     2865          if NewIndex >= 0 then TrackStationDown := TrackStationDown.Track.Points[NewIndex]
     2866            else TrackStationDown := nil;
     2867        end;
     2868        TrackStationUp := Track.Points[1];
     2869        NewIndex := TrackStationUp.Track.Points.IndexOf(TrackStationDown);
     2870        while Assigned(TrackStationUp) and (not Assigned(TrackStationUp.OwnerPoint)) do begin
     2871          NewIndex := NewIndex + 1;
     2872          if NewIndex < TrackStationUp.Track.Points.Count then
     2873            TrackStationUp := TrackStationUp.Track.Points[NewIndex]
     2874            else TrackStationUp := nil;
     2875        end;
     2876        Track.Free;
     2877        Exit;
     2878      end;
     2879      if Assigned(Track) then Track.Free;
     2880    end;
    28642881  end;
    28652882end;
     
    28832900  end;
    28842901  {$IFDEF DEBUG}
    2885   if Key = KeyF2 then begin
    2886     if State = gsRunning then begin
     2902  if State in [gsRunning, gsPaused] then begin
     2903    if Key = KeyF2 then begin
    28872904      State := gsGameOver;
    28882905      Redraw;
    28892906    end;
    2890   end else
    2891   if Key = KeyF3 then begin
    2892     if State = gsRunning then begin
     2907    if Key = KeyF3 then begin
    28932908      Trains.AddNew;
    28942909      Redraw;
    28952910    end;
    2896   end else
    2897   if Key = KeyF4 then begin
    2898     if State = gsRunning then begin
     2911    if Key = KeyF4 then begin
    28992912      Carriages.AddNew;
    29002913      Redraw;
    29012914    end;
    2902   end else
    2903   if Key = KeyF5 then begin
    2904     if State = gsRunning then begin
     2915    if Key = KeyF5 then begin
    29052916      State := gsNewWeek;
    29062917      Redraw;
    29072918    end;
    2908   end else
    2909   if Key = KeyF6 then begin
    2910     if State = gsRunning then begin
     2919    if Key = KeyF6 then begin
    29112920      Stations.AddNew;
    29122921      ResizeView;
     
    31073116  begin
    31083117    DrawGameOver(Canvas, CanvasSize);
     3118    DrawGameControls(Canvas, CanvasSize);
    31093119  end else
    31103120  if State = gsMenu then begin
Note: See TracChangeset for help on using the changeset viewer.