- Timestamp:
- Nov 28, 2020, 12:17:21 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMain.pas
r66 r68 75 75 if not Initialized then begin 76 76 Initialized := True; 77 PersistentForm1.RegistryContext := ApplicationInfo1.GetRegistryContext; 78 PersistentForm1.Load(Self, False, True); 79 FullScreen := PersistentForm1.FormFullScreen; 80 Randomize; 81 Engine.InitMenus; 82 Engine.ImagePassenger.Picture.Assign(FormImages.ImagePassenger.Picture); 83 Engine.ImageLocomotive.Picture.Assign(FormImages.ImageLocomotive.Picture); 84 Engine.Map.Size := Point(PaintBox1.Width, PaintBox1.Height); 85 Engine.View.DestRect := Rect(0, 0, PaintBox1.Width, PaintBox1.Height); 86 Engine.MainMenu; 77 87 end; 78 88 end; … … 111 121 procedure TFormMain.FormShow(Sender: TObject); 112 122 begin 113 PersistentForm1.RegistryContext := ApplicationInfo1.GetRegistryContext;114 PersistentForm1.Load(Self, False, True);115 FullScreen := PersistentForm1.FormFullScreen;116 Randomize;117 Engine.InitMenus;118 Engine.ImagePassenger.Picture.Assign(FormImages.ImagePassenger.Picture);119 Engine.ImageLocomotive.Picture.Assign(FormImages.ImageLocomotive.Picture);120 Engine.Map.Size := Point(PaintBox1.Width, PaintBox1.Height);121 Engine.View.DestRect := Rect(0, 0, PaintBox1.Width, PaintBox1.Height);122 Engine.MainMenu;123 123 end; 124 124 … … 156 156 begin 157 157 Engine.View.DestRect := Rect(0, 0, PaintBox1.Width, PaintBox1.Height); 158 Engine.Paint(PaintBox1.Canvas );158 Engine.Paint(PaintBox1.Canvas, Point(PaintBox1.Width, PaintBox1.Height)); 159 159 end; 160 160 -
trunk/Packages/Common/UPersistentForm.pas
r63 r68 317 317 Form.RestoredHeight); 318 318 ShowWindow(Form.Handle, SW_SHOWFULLSCREEN); 319 {$IFDEF WINDOWS} 320 Form.BorderStyle := bsNone; 321 {$ENDIF} 319 322 end else begin 320 323 FormFullScreen := False; … … 323 326 //Form.BoundsRect := FormRestoredSize; 324 327 end else if Form.WindowState = wsMaximized then ShowWindow(Form.Handle, SW_SHOWMAXIMIZED); 328 {$IFDEF WINDOWS} 329 Form.BorderStyle := bsSizeable; 330 {$ENDIF} 325 331 end; 326 332 end; -
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 -
trunk/UMenu.pas
r64 r68 81 81 procedure MouseMove(Position: TPoint); 82 82 procedure MouseUp(Button: TMouseButton; Position: TPoint); 83 procedure Paint(Canvas: TCanvas );83 procedure Paint(Canvas: TCanvas; CanvasSize: TPoint); 84 84 constructor Create; 85 85 destructor Destroy; override; … … 216 216 end; 217 217 218 procedure TMenu.Paint(Canvas: TCanvas );218 procedure TMenu.Paint(Canvas: TCanvas; CanvasSize: TPoint); 219 219 var 220 220 I: Integer; … … 240 240 end; 241 241 242 X := ( Width- TotalWidth) div 2;243 Y := ( Height- TotalHeight) div 2;242 X := (CanvasSize.X - TotalWidth) div 2; 243 Y := (CanvasSize.Y - TotalHeight) div 2; 244 244 245 245 // Menu items
Note:
See TracChangeset
for help on using the changeset viewer.