Changeset 97 for trunk/UEngine.pas
- Timestamp:
- Sep 28, 2022, 1:18:41 PM (20 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UEngine.pas
r96 r97 178 178 LastState: TGameState; 179 179 TimePerSecond: TDateTime; 180 ImprovementImageSize: Integer; 181 IconSize: Integer; 180 182 function GetServedDaysCount: Integer; 181 183 procedure ResizeView; … … 301 303 LineColorsDist = 50; 302 304 TrainSpeed = 2000; 303 ImagePassengerName = 'Images/Passenger.png';304 ImageLocomotiveName = 'Images/Locomotive.png';305 ImageLeftArrowName = 'Images/Left arrow.png';306 ImagePlayName = 'Images/Play.png';307 ImagePauseName = 'Images/Pause.png';308 ImageFastForwardName = 'Images/Fast forward.png';309 305 TrainPassengerCount = 6; 310 306 StationMinDistance = 100; … … 2173 2169 2174 2170 ImageNewTrain.Canvas := Canvas; 2175 ImageNewTrain.Bounds := Bounds((CanvasSize.X - ImageLocomotive.Bitmap.Width * ImageZoom) div 2, 2176 (CanvasSize.Y - ImageLocomotive.Bitmap.Height * ImageZoom) div 2, 2177 ImageLocomotive.Bitmap.Width * ImageZoom, 2178 ImageLocomotive.Bitmap.Height * ImageZoom); 2171 ImageNewTrain.Bounds := Bounds(CanvasSize.X div 2 - ImprovementImageSize div 2, 2172 CanvasSize.Y div 2 - ImprovementImageSize div 2, 2173 ImprovementImageSize, ImprovementImageSize); 2179 2174 ImageNewTrain.Paint; 2180 2175 2181 Y := (CanvasSize.Y - Im ageLocomotive.Bitmap.Height * ImageZoom) div 2 +2182 Round(Im ageLocomotive.Bitmap.Height * ImageZoom* 1.1);2176 Y := (CanvasSize.Y - ImprovementImageSize) div 2 + 2177 Round(ImprovementImageSize * 1.1); 2183 2178 2184 2179 Text := STrain; … … 2196 2191 Y: Integer; 2197 2192 X: Integer; 2198 const 2199 ImageZoom = 4; 2193 Center: TPoint; 2200 2194 begin 2201 2195 with Canvas do begin 2196 Center := Point(CanvasSize.X div 2, CanvasSize.Y div 2); 2197 2202 2198 Pen.Color := Self.Colors.Text; 2203 2199 Pen.Style := psSolid; … … 2226 2222 if Improvement1 <> miNone then begin 2227 2223 ImageNewImprovement1.Canvas := Canvas; 2228 ImageNewImprovement1.Bounds := Bounds(CanvasSize.X div 2 - CanvasSize.X div 8 - 2229 ImageNewImprovement1.Bitmap.Width * ImageZoom div 2, 2230 (CanvasSize.Y - ImageNewImprovement1.Bitmap.Height * ImageZoom) div 2, 2231 ImageNewImprovement1.Bitmap.Width * ImageZoom, 2232 ImageNewImprovement1.Bitmap.Height * ImageZoom); 2224 ImageNewImprovement1.Bounds := Bounds(Center.X - CanvasSize.X div 8 - 2225 ImprovementImageSize div 2, Center.Y - ImprovementImageSize div 2, 2226 ImprovementImageSize, ImprovementImageSize); 2233 2227 ImageNewImprovement1.Paint; 2234 2228 end; … … 2236 2230 if Improvement2 <> miNone then begin 2237 2231 ImageNewImprovement2.Canvas := Canvas; 2238 ImageNewImprovement2.Bounds := Bounds(CanvasSize.X div 2 + CanvasSize.X div 8 - 2239 ImageNewImprovement2.Bitmap.Width * ImageZoom div 2, 2240 (CanvasSize.Y - ImageNewImprovement2.Bitmap.Height * ImageZoom) div 2, 2241 ImageNewImprovement2.Bitmap.Width * ImageZoom, 2242 ImageNewImprovement2.Bitmap.Height * ImageZoom); 2232 ImageNewImprovement2.Bounds := Bounds(Center.X + CanvasSize.X div 8 - 2233 ImprovementImageSize div 2, Center.Y - ImprovementImageSize div 2, 2234 ImprovementImageSize, ImprovementImageSize); 2243 2235 ImageNewImprovement2.Paint; 2244 2236 end; 2245 2237 2246 Y := (CanvasSize.Y - ImageLocomotive.Bitmap.Height * ImageZoom)div 2 +2247 Round(Im ageLocomotive.Bitmap.Height * ImageZoom* 1.1);2238 Y := Center.Y - ImprovementImageSize div 2 + 2239 Round(ImprovementImageSize * 1.1); 2248 2240 2249 2241 if Improvement1 <> miNone then begin … … 2252 2244 Font.Color := Self.Colors.Text; 2253 2245 TextSize := TextExtent(Text); 2254 TextOut(C anvasSize.X div 2- CanvasSize.X div 8 - TextSize.Width div 2, Y, Text);2246 TextOut(Center.X - CanvasSize.X div 8 - TextSize.Width div 2, Y, Text); 2255 2247 end; 2256 2248 … … 2260 2252 Font.Color := Self.Colors.Text; 2261 2253 TextSize := TextExtent(Text); 2262 TextOut(C anvasSize.X div 2+ CanvasSize.X div 8 - TextSize.Width div 2, Y, Text);2254 TextOut(Center.X + CanvasSize.X div 8 - TextSize.Width div 2, Y, Text); 2263 2255 end; 2264 2256 end; … … 2427 2419 Angle: Real; 2428 2420 Pos: TPoint; 2429 begin 2421 X: Integer; 2422 Y: Integer; 2423 SeparatorSize: Integer; 2424 begin 2425 SeparatorSize := ScaleX(20, 96); 2426 X := CanvasSize.X div 2; 2427 Y := CanvasSize.Y - LineColorsDist; 2428 2430 2429 // Line selection 2431 2430 Canvas.Pen.Width := 4; … … 2445 2444 end; 2446 2445 2447 Canvas.EllipseC(CanvasSize.X div 2 - Length(LineColors) div 2 * LineColorsDist + I * LineColorsDist, 2448 CanvasSize.Y - LineColorsDist, Radius, Radius); 2449 end; 2446 Canvas.EllipseC(X - Length(LineColors) div 2 * LineColorsDist + I * LineColorsDist, 2447 Y, Radius, Radius); 2448 end; 2449 X := X - Length(LineColors) div 2 * LineColorsDist - 2 * SeparatorSize; 2450 2450 2451 2451 // Draw unused trains 2452 ImageLocomotive.Bounds := Bounds(X - IconSize, Y - IconSize div 2, 2453 IconSize, IconSize); 2454 ImageLocomotive.Canvas := Canvas; 2455 ImageLocomotive.Paint; 2456 X := X - IconSize - SeparatorSize div 3; 2457 2452 2458 Text := IntToStr(Trains.GetUnusedCount); 2453 Canvas.Draw(CanvasSize.X div 2 - Length(LineColors) div 2 * LineColorsDist - 100,2454 CanvasSize.Y - LineColorsDist - ImageLocomotive.Bitmap.Height div 2, ImageLocomotive.Bitmap);2455 2459 Canvas.Brush.Style := bsClear; 2456 2460 Canvas.Font.Size := 14; 2457 2461 Canvas.Font.Color := Colors.Text; 2458 Canvas.TextOut(CanvasSize.X div 2 - Length(LineColors) div 2 * LineColorsDist - 50 - Canvas.TextWidth(Text), 2459 CanvasSize.Y - LineColorsDist - Canvas.TextHeight(Text) div 2, Text); 2462 Canvas.TextOut(X - Canvas.TextWidth(Text), 2463 Y - Canvas.TextHeight(Text) div 2, Text); 2464 X := X - Canvas.TextWidth(Text) - SeparatorSize; 2460 2465 2461 2466 // Draw unused carriages 2462 2467 Text := IntToStr(Carriages.GetUnusedCount); 2463 Canvas.Draw(CanvasSize.X div 2 - Length(LineColors) div 2 * LineColorsDist - 200, 2464 CanvasSize.Y - LineColorsDist - ImageCarriage.Bitmap.Height div 2, ImageCarriage.Bitmap); 2468 ImageCarriage.Bounds := Bounds(X - IconSize, Y - IconSize div 2, 2469 IconSize, IconSize); 2470 ImageCarriage.Canvas := Canvas; 2471 ImageCarriage.Paint; 2472 X := X - IconSize - SeparatorSize div 3; 2473 2465 2474 Canvas.Brush.Style := bsClear; 2466 2475 Canvas.Font.Size := 14; 2467 2476 Canvas.Font.Color := Colors.Text; 2468 Canvas.TextOut(CanvasSize.X div 2 - Length(LineColors) div 2 * LineColorsDist - 150 - Canvas.TextWidth(Text), 2469 CanvasSize.Y - LineColorsDist - Canvas.TextHeight(Text) div 2, Text); 2470 2471 // Status interface 2477 Canvas.TextOut(X - Canvas.TextWidth(Text), 2478 Y - Canvas.TextHeight(Text) div 2, Text); 2479 2480 // Passenger count 2481 X := CanvasSize.X - ScaleX(30, 96); 2472 2482 Text := IntToStr(ServedPassengerCount); 2473 Canvas.Draw(CanvasSize.X - 50, CanvasSize.Y - 60, ImagePassenger.Bitmap); 2483 ImagePassenger.Bounds := Bounds(X - Canvas.TextWidth(Text), Y - IconSize div 2, 2484 IconSize, IconSize); 2485 ImagePassenger.Canvas := Canvas; 2486 ImagePassenger.Paint; 2487 X := X - Canvas.TextWidth(Text) - SeparatorSize div 3; 2488 2474 2489 Canvas.Brush.Style := bsClear; 2475 2490 Canvas.Font.Size := 14; 2476 2491 Canvas.Font.Color := Colors.Text; 2477 Canvas.TextOut( CanvasSize.X - 70- Canvas.TextWidth(Text),2478 CanvasSize.Y - 55, Text);2492 Canvas.TextOut(X - Canvas.TextWidth(Text), 2493 Y - Canvas.TextHeight(Text) div 2, Text); 2479 2494 2480 2495 DrawClock(Canvas, CanvasSize); … … 2783 2798 2784 2799 // Select unused train 2785 if (Distance(Position, Point(View.DestRect.Right div 2 - Length(LineColors) div 2 * LineColorsDist - 100, 2786 View.DestRect.Bottom - LineColorsDist)) < 30) and 2800 if (Distance(Position, ImageLocomotive.Bounds.CenterPoint) < 30) and 2787 2801 (Trains.GetUnusedCount > 0) then begin 2788 2802 SelectedTrain := Trains.GetUnused; … … 2791 2805 2792 2806 // Select unused carriage 2793 if (Distance(Position, Point(View.DestRect.Right div 2 - Length(LineColors) div 2 * LineColorsDist - 200, 2794 View.DestRect.Bottom - LineColorsDist)) < 30) and 2807 if (Distance(Position, ImageCarriage.Bounds.CenterPoint) < 30) and 2795 2808 (Carriages.GetUnusedCount > 0) then begin 2796 2809 SelectedCarriage := Carriages.GetUnused; … … 2974 2987 constructor TEngine.Create; 2975 2988 begin 2989 ImprovementImageSize := ScaleX(64, 96); 2990 IconSize := ScaleX(32, 96); 2976 2991 TimePerSecond := TimePerSecondNormal; 2977 2992 ButtonBack := TImage.Create; … … 3010 3025 ImageNewImprovement2 := TImage.Create; 3011 3026 ImageNewImprovement2.OnClick := ButtonNewImprovement2; 3012 //if FileExists(ImagePassengerName) then3013 // ImagePassenger.Picture.LoadFromFile(ImagePassengerName);3014 //if FileExists(ImageLocomotiveName) then3015 // ImageLocomotive.Picture.LoadFromFile(ImageLocomotiveName);3016 3027 MetaCanvas := TMetaCanvas.Create; 3017 3028 Cities := TCities.Create;
Note:
See TracChangeset
for help on using the changeset viewer.