Changeset 68 for trunk/UEngine.pas
- Timestamp:
- Nov 28, 2020, 12:17:21 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UEngine.pas
r67 r68 303 303 procedure DrawShape(Canvas: TCanvas; Position: TPoint; Shape: TStationShape; 304 304 Size: Integer; Angle: Double); 305 procedure DrawClock(Canvas: TCanvas );305 procedure DrawClock(Canvas: TCanvas; CanvasSize: TPoint); 306 306 procedure DrawTrains(Canvas: TCanvas); 307 procedure DrawGameOver(Canvas: TCanvas );307 procedure DrawGameOver(Canvas: TCanvas; CanvasSize: TPoint); 308 308 procedure DrawStationPassengerOverload(Canvas: TCanvas); 309 309 procedure DrawLines(Canvas: TCanvas); 310 310 procedure DrawStations(Canvas: TCanvas); 311 procedure DrawGameControls(Canvas: TCanvas );311 procedure DrawGameControls(Canvas: TCanvas; CanvasSize: TPoint); 312 312 procedure ComputeShapeDistance; 313 313 procedure ComputeShapeDistanceStation(Station: TMapStation; … … 361 361 destructor Destroy; override; 362 362 procedure Tick; 363 procedure Paint(Canvas: TCanvas );363 procedure Paint(Canvas: TCanvas; CanvasSize: TPoint); 364 364 property Time: TDateTime read FTime; 365 365 property DarkMode: Boolean read FDarkMode write SetDarkMode; … … 2090 2090 end; 2091 2091 2092 procedure TEngine.DrawClock(Canvas: TCanvas );2092 procedure TEngine.DrawClock(Canvas: TCanvas; CanvasSize: TPoint); 2093 2093 var 2094 2094 ClockCenter: TPoint; … … 2103 2103 Canvas.Pen.Color := Colors.Text; 2104 2104 Canvas.Pen.Width := 2; 2105 ClockCenter := Point(Canvas .Width- 30, 40);2105 ClockCenter := Point(CanvasSize.X - 30, 40); 2106 2106 Angle := Time / (12 * OneHour) * 2 * Pi - Pi / 2; 2107 2107 Canvas.EllipseC(ClockCenter.X, ClockCenter.Y, ClockSize, ClockSize); … … 2166 2166 end; 2167 2167 2168 procedure TEngine.DrawGameOver(Canvas: TCanvas );2168 procedure TEngine.DrawGameOver(Canvas: TCanvas; CanvasSize: TPoint); 2169 2169 var 2170 2170 Y: Integer; … … 2178 2178 Y := 100; 2179 2179 Font.Size := 40; 2180 TextOut(( Width- TextWidth(SGameOver)) div 2, Y, SGameOver);2180 TextOut((CanvasSize.X - TextWidth(SGameOver)) div 2, Y, SGameOver); 2181 2181 Y := Y + Round(TextHeight(SGameOver) * 1.1); 2182 2182 2183 2183 Font.Size := 14; 2184 TextOut(( Width- TextWidth(SGameOverReason)) div 2, Y, SGameOverReason);2184 TextOut((CanvasSize.X - TextWidth(SGameOverReason)) div 2, Y, SGameOverReason); 2185 2185 Y := Y + Round(TextHeight(SGameOverReason) * 1.1); 2186 2186 2187 2187 Text := Format(SGameOverStatistic, [ServedPassengerCount, ServedDaysCount]); 2188 TextOut(( Width- TextWidth(Text)) div 2, Y, Text);2188 TextOut((CanvasSize.X - TextWidth(Text)) div 2, Y, Text); 2189 2189 Y := Y + Round(TextHeight(SGameOverStatistic) * 1.1); 2190 2190 … … 2199 2199 Text := Text + Format(SOldHighScore, [HighestServedPassengerCount, 2200 2200 HighestServedDaysCount]); 2201 Canvas.TextOut((Canvas .Width - Canvas.TextWidth(Text)) div 2, Y, Text);2201 Canvas.TextOut((CanvasSize.X - TextWidth(Text)) div 2, Y, Text); 2202 2202 Y := Y + Round(TextHeight(Text) * 1.1); 2203 2203 if (ServedPassengerCount > HighestServedPassengerCount) then … … 2363 2363 end; 2364 2364 2365 procedure TEngine.DrawGameControls(Canvas: TCanvas );2365 procedure TEngine.DrawGameControls(Canvas: TCanvas; CanvasSize: TPoint); 2366 2366 var 2367 2367 I: Integer; … … 2388 2388 end; 2389 2389 2390 Canvas.EllipseC(Canvas .Widthdiv 2 - Length(LineColors) div 2 * LineColorsDist + I * LineColorsDist,2391 Canvas .Height- LineColorsDist, Radius, Radius);2390 Canvas.EllipseC(CanvasSize.X div 2 - Length(LineColors) div 2 * LineColorsDist + I * LineColorsDist, 2391 CanvasSize.Y - LineColorsDist, Radius, Radius); 2392 2392 end; 2393 2393 2394 2394 // Draw unused trains 2395 2395 Text := IntToStr(Trains.GetUnusedCount); 2396 Canvas.Draw(Canvas .Widthdiv 2 - Length(LineColors) div 2 * LineColorsDist - 100,2397 Canvas .Height- LineColorsDist - ImageLocomotive.Picture.Bitmap.Height div 2, ImageLocomotive.Picture.Bitmap);2396 Canvas.Draw(CanvasSize.X div 2 - Length(LineColors) div 2 * LineColorsDist - 100, 2397 CanvasSize.Y - LineColorsDist - ImageLocomotive.Picture.Bitmap.Height div 2, ImageLocomotive.Picture.Bitmap); 2398 2398 Canvas.Brush.Style := bsClear; 2399 2399 Canvas.Font.Size := 14; 2400 2400 Canvas.Font.Color := Colors.Text; 2401 Canvas.TextOut(Canvas .Widthdiv 2 - Length(LineColors) div 2 * LineColorsDist - 50 - Canvas.TextWidth(Text),2402 Canvas .Height- LineColorsDist - Canvas.TextHeight(Text) div 2, Text);2401 Canvas.TextOut(CanvasSize.X div 2 - Length(LineColors) div 2 * LineColorsDist - 50 - Canvas.TextWidth(Text), 2402 CanvasSize.Y - LineColorsDist - Canvas.TextHeight(Text) div 2, Text); 2403 2403 2404 2404 // Status interface 2405 2405 Text := IntToStr(ServedPassengerCount); 2406 Canvas.Draw(Canvas .Width - 50, Canvas.Height- 60, ImagePassenger.Picture.Bitmap);2406 Canvas.Draw(CanvasSize.X - 50, CanvasSize.Y - 60, ImagePassenger.Picture.Bitmap); 2407 2407 Canvas.Brush.Style := bsClear; 2408 2408 Canvas.Font.Size := 14; 2409 2409 Canvas.Font.Color := Colors.Text; 2410 Canvas.TextOut(Canvas.Width - 70 - Canvas.TextWidth(Text), Canvas.Height - 55, Text); 2411 2412 DrawClock(Canvas); 2410 Canvas.TextOut(CanvasSize.X - 70 - Canvas.TextWidth(Text), 2411 CanvasSize.Y - 55, Text); 2412 2413 DrawClock(Canvas, CanvasSize); 2413 2414 2414 2415 // Back button … … 2838 2839 end; 2839 2840 2840 procedure TEngine.Paint(Canvas: TCanvas );2841 procedure TEngine.Paint(Canvas: TCanvas; CanvasSize: TPoint); 2841 2842 begin 2842 2843 MetaCanvas.Size := Point(Canvas.Width, Canvas.Height); … … 2860 2861 2861 2862 if State <> gsMenu then begin 2862 DrawGameControls(Canvas );2863 DrawGameControls(Canvas, CanvasSize); 2863 2864 end; 2864 2865 … … 2866 2867 if State = gsGameOver then 2867 2868 begin 2868 DrawGameOver(Canvas );2869 DrawGameOver(Canvas, CanvasSize); 2869 2870 end else 2870 2871 if State = gsMenu then begin 2871 Menu.Paint(Canvas );2872 Menu.Paint(Canvas, CanvasSize); 2872 2873 end; 2873 2874
Note:
See TracChangeset
for help on using the changeset viewer.