Changeset 126 for trunk


Ignore:
Timestamp:
Apr 23, 2023, 10:35:50 PM (19 months ago)
Author:
chronos
Message:
  • Modified: Improved code for drawing game clock.
  • Modified: Updated position of clock and exit button in game screen.
  • Modified: New game logo.
Location:
trunk
Files:
7 added
4 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormImages.lfm

    r100 r126  
    88  ClientWidth = 1053
    99  DesignTimePPI = 144
    10   LCLVersion = '2.2.2.0'
     10  LCLVersion = '2.2.4.0'
    1111  object ImageLocomotive: TImage
    1212    Left = 488
     
    329329    Width = 85
    330330    Picture.Data = {
    331       1754506F727461626C654E6574776F726B477261706869630602000089504E47
     331      1754506F727461626C654E6574776F726B47726170686963F304000089504E47
    332332      0D0A1A0A0000000D49484452000001000000010008030000006BAC5854000000
    333       21504C5445000000000000000000000000000000000000000000000000000000
    334       0000000000006DD148C10000000A74524E530010304050809FBFCFEFF438B8CF
    335       0000018A49444154789CEDDC8B718200144451893141FB2F386901F2165C724E
    336       05EC1D67547EB71B000000000000000000000000F007CB63B3FBD9C73C69595F
    337       5BADCBD9073DC87EFBEDB7DF7EFBEDB7DF7EFBEDB7DF7EFBEDB7DF7EFBEDB7DF
    338       7EFBEDB7DF7EFBEDBF0EFBEDB7DF7EFBEDB7DF7EFBEDB7DF7EFBEDB7DF7EFBED
    339       B7DF7EFBEDB7DF7EFBEDB7FF3A76EC7FADDF07FB78AFFDC7CB3D72DBB13F17A0
    340       647F2C40CBFE54809AFDA1003DFB33018AF6470234ED4F04A8DA1F08D0B57F3E
    341       40D9FEF1006DFBA703D4ED1F0ED0B77F3640E1FED1008DFB270354EE9F0CF075
    342       F6965D7C02E6027416F02D3019A0B1805F82B301FA0AF837381DA0AD803342F3
    343       01BA0A382B9C08D054C095A14C809E02AE0EA702B41408BE93BCA340F2A5EC15
    344       05A26FA5DF51E0F9793F56F6AEB4FF7E9F9C020A28A080020A28A080020A28A0
    345       80020A28A080020A28A080020A28A080020A28A080020A28A080020A28A08002
    346       0A28A080020A28A080020A28A080020A28A080020A28F05BE0B159F409500000
    347       00000000000000000000E0627E009B74DE3A9610647B0000000049454E44AE42
    348       6082
     333      63504C5445000000000000000000000000000000000000000000000000000000
     334      0000000000000000000000000000000000000000000000000000000000000000
     335      0000000000000000000000000000000000000000000000000000000000000000
     336      0000000000000000666874DE0000002074524E530016172122232E3035364C56
     337      5758688A8D9EA6AFB0C5CFD5E1E2EFF0FAFBFCFDFEF9E32D0000041F49444154
     338      789CEDDB0972D3401484E181847D355BD802DCFF94109B4016DB92ACD73DDD35
     339      DD37F8BF7AAA5295ECD6B22CCBB22CCBB22CCBB22CCBB22CCBB22CCBB22CCBB2
     340      2CCBB22CCBB22C9BB5C74F6476D6A3FFED2F9DBD1FBCBF0780547F0700AD7E3E
     341      80583F1D40AD9F0D20D74F06D0EBE70208F6530114FB990092FD4400CD7E1E80
     342      683F0D40B59F0520DB4F02D0EDE70008F7530094FB1900D2FD0400ED7E3C8078
     343      3F1C40BD1F0D20DF0F06D0EFC70218F443011CFA910016FD40008F7E1C80493F
     344      0CC0A51F0560D30F02F0E9C70018F543009CFA110056FD0000AFFE7A00B3FE72
     345      00B7FE6A00BBFE6200BFFE5A00C3FE5200C7FE4A00CBFE4200CFFE3A00D3FE32
     346      00D7FE2A00DBFE2200DFFE1A80E75F39FBAE0AC0DAEBC1019E7D1B1BE029A2DF
     347      0800D3EF0300EAB70140F5BB00C0FA4D0070FD1E00C07E0B0064BF0300B4DF00
     348      00DBAF0F00EE970740F7AB03C0FBC501F0FDDA00847E690046BF3200A55F1880
     349      D3AF0B40EA970560F5AB02D0FA450178FD9A00C47E490066BF2200B55F1080DB
     350      AF0740EE970360F7AB01D0FBC500F8FD5A001DFAA5007AF42B0114FCFEE1F34F
     351      638082FE8B87EF7C014AFADBC616A0E0F9BF78D04E00F8D0BB7CB7A27E5B80AA
     352      7E5780B27E5380BA7E4F80C27E4B80CA7E4780D27E4380DA7E3F80E27E3B80EA
     353      7E3780F27E3380FA7E2F0040BF1500A2DF0900D26F0480E9F70100F5DB00A0FA
     354      5D0060FD2600B87E0F0060BF0500B2DF0100DA6F0080EDD70700F7CB03A0FBD5
     355      01E0FDE200F87E6D0042BF3400A35F1980D22F0CC0E9D70520F5CB02B0FA5501
     356      68FDA200BC7E4D0062BF2400B35F1180DA2F08C0EDD70320F7CB01B0FBD500E8
     357      FD6200FC7E2D800EFD52003DFA9500BAF40B01F4E9D701E8D42F03D0AB5F05A0
     358      5BBF0840CDFF9F4EDA6280CB17B5ED57EBD8BF18E0F25569FA76FDEEBF2D06F8
     359      F1B2B27CB7AEFD0B0154FB4FBDFFB6100071FFEDD1979EFD8B0020FDAD9DAF14
     360      5871FF6D1100E2FEB75B27B0AE7F0100AC7F9DC0CAFEF900C0FE35026BFB6703
     361      40FB4F1758DD3F1700DC7FAAC0FAFE9900F0FED3040AFAE70110FA4F11A8E89F
     362      0540E95F2E50D23F0780D4BF54A0A67F0600AD7F994051FF3400B17F894055FF
     363      2400B57FBE4059FF1400B97FAE405DFF0400BD7F9E4061FF71800EFDAD9D4D0A
     364      54F61F05E8D23F2D50DA7F0CA053FF94406DFF11806EFDC7058AFB0F0374EC3F
     365      2650DD7F10A06BFF6181F2FE43009DFB0F09D4F71F00E8DEBF5F00D0BF1F40A0
     366      7F9F00A27F2F8044FF7D0148FF3E0091FEBB0298FE3D0032FDB70540FDF70184
     367      FA6F0AA0FAEF0148F5FF1780F5DF0510EBBF16C0F5DF0190EBDF0900FB6F0308
     368      F6B776FEE9E39AEFFF53BB0900FAFEAFBDCDE0FD370024EF1FBFCDE0FDFF0046
     369      EDBF0618B6FF2FC0B8FD3B8081FBB70023F75F010CDDFF0760ECFEB619BCBFBD
     370      19F2FD37CBB22CCBB22CCBB22CCBB22CCBB22CCBB22CCBB2BAFD06BD35104231
     371      49CD220000000049454E44AE426082
    349372    }
    350373    Proportional = True
  • trunk/UColors.pas

    r100 r126  
    1010  { TColors }
    1111
    12   TColors = record
     12  TColors = class
    1313    Background: TColor;
    1414    Background2: TColor;
  • trunk/UEngine.pas

    r125 r126  
    173173  TMetroImprovementSet = set of TMetroImprovement;
    174174  TFullScrenChangeEvent = procedure (Sender: TObject; Active: Boolean) of object;
     175
     176  { TClock }
     177
     178  TClock = class(TControl)
     179    Time: TDateTime;
     180    TextColor: TColor;
     181    BackgroundColor: TColor;
     182    procedure Paint; override;
     183  end;
    175184
    176185  { TEngine }
     
    306315    ImageNewImprovement1: TImage;
    307316    ImageNewImprovement2: TImage;
     317    Clock: TClock;
    308318    AvailableImprovements: TMetroImprovementSet;
    309319    Improvement1: TMetroImprovement;
     
    425435  SSeoul = 'Seoul';
    426436  SBeijing = 'Beijing';
     437
     438{ TClock }
     439
     440procedure TClock.Paint;
     441var
     442  ClockCenter: TPoint;
     443  Angle: Double;
     444  I: Integer;
     445  IsDay: Boolean;
     446begin
     447  IsDay := (((Time / OneHour) mod 24) > 6) and (((Time / OneHour) mod 24) < 18);
     448  if IsDay then begin
     449    Canvas.Brush.Style := bsSolid;
     450    Canvas.Brush.Color := BackgroundColor;
     451  end else begin
     452    Canvas.Brush.Style := bsSolid;
     453    Canvas.Brush.Color := TextColor;
     454  end;
     455  Canvas.Pen.Style := psSolid;
     456  Canvas.Pen.Color := TextColor;
     457  Canvas.Pen.Width := 2;
     458  ClockCenter := Point(Bounds.Left + Bounds.Width div 2,
     459    Bounds.Top + Bounds.Height div 2);
     460  Angle := Time / (12 * OneHour) * 2 * Pi - Pi / 2;
     461  Canvas.EllipseC(ClockCenter.X, ClockCenter.Y, Bounds.Width div 2, Bounds.Height div 2);
     462  Canvas.Brush.Style := bsClear;
     463
     464  if IsDay then begin
     465    Canvas.Pen.Color := TextColor;
     466  end else begin
     467    Canvas.Pen.Color := BackgroundColor;
     468  end;
     469  Canvas.Line(ClockCenter, Point(ClockCenter.X + Round(Cos(Angle) * (Bounds.Width / 2) * 0.8),
     470    ClockCenter.Y + Round(Sin(Angle) * (Bounds.Height / 2) * 0.8)));
     471  for I := 0 to 12 do begin
     472    Angle := I / 12 * 2 * Pi;
     473    Canvas.Line(ClockCenter.X + Round(Cos(Angle) * (Bounds.Width / 2) * 0.7),
     474      ClockCenter.Y + Round(Sin(Angle) * (Bounds.Height / 2) * 0.7),
     475      ClockCenter.X + Round(Cos(Angle) * (Bounds.Width / 2) * 0.9),
     476      ClockCenter.Y + Round(Sin(Angle) * (Bounds.Height / 2) * 0.9));
     477  end;
     478end;
    427479
    428480{ TMetroCarriage }
     
    22402292procedure TEngine.DrawClock(Canvas: TCanvas; CanvasSize: TPoint);
    22412293var
    2242   ClockCenter: TPoint;
    2243   Angle: Double;
     2294  X: Integer;
     2295  Y: Integer;
    22442296  Text: string;
    2245   I: Integer;
    2246   Y: Integer;
    2247   IsDay: Boolean;
    2248 const
    2249   ClockSize = 20;
    2250 begin
    2251   IsDay := (((Time / OneHour) mod 24) > 6) and (((Time / OneHour) mod 24) < 18);
    2252   if IsDay then begin
    2253     Canvas.Brush.Style := bsSolid;
    2254     Canvas.Brush.Color := Colors.Background;
    2255   end else begin
    2256     Canvas.Brush.Style := bsSolid;
    2257     Canvas.Brush.Color := Colors.Text;
    2258   end;
    2259   Canvas.Pen.Style := psSolid;
    2260   Canvas.Pen.Color := Colors.Text;
    2261   Canvas.Pen.Width := 2;
    2262   ClockCenter := Point(CanvasSize.X - 30, 40);
    2263   Angle := Time / (12 * OneHour) * 2 * Pi - Pi / 2;
    2264   Canvas.EllipseC(ClockCenter.X, ClockCenter.Y, ClockSize, ClockSize);
    2265   Canvas.Brush.Style := bsClear;
    2266 
    2267   if IsDay then begin
    2268     Canvas.Pen.Color := Colors.Text;
    2269   end else begin
    2270     Canvas.Pen.Color := Colors.Background;
    2271   end;
    2272   Canvas.Line(ClockCenter, Point(ClockCenter.X + Round(Cos(Angle) * ClockSize * 0.8),
    2273     ClockCenter.Y + Round(Sin(Angle) * ClockSize * 0.8)));
    2274   for I := 0 to 12 do begin
    2275     Angle := I / 12 * 2 * Pi;
    2276     Canvas.Line(ClockCenter.X + Round(Cos(Angle) * ClockSize * 0.7),
    2277       ClockCenter.Y + Round(Sin(Angle) * ClockSize * 0.7),
    2278       ClockCenter.X + Round(Cos(Angle) * ClockSize * 0.9),
    2279       ClockCenter.Y + Round(Sin(Angle) * ClockSize * 0.9));
    2280   end;
    2281   Y := ClockCenter.Y;
     2297begin
     2298  Clock.Time := Time;
     2299  Clock.Canvas := Canvas;
     2300  Clock.TextColor := Colors.Text;
     2301  Clock.BackgroundColor := Colors.Background;
     2302  Clock.Bounds := Bounds(ScaleX(15, 96), ScaleY(15, 96),
     2303    ScaleX(40, 96), ScaleY(40, 96));
     2304  Clock.Paint;
     2305
     2306  X := Clock.Bounds.Left + Clock.Bounds.Width + ScaleY(10, 96);
     2307  Y := Clock.Bounds.Top;
    22822308
    22832309  Canvas.Pen.Color := Colors.Text;
    22842310  Canvas.Font.Color := Colors.Text;
     2311  Canvas.Brush.Style := bsClear;
    22852312  Text := FormatDateTime('ddd', Time + 2);
    2286   Canvas.TextOut(ClockCenter.X - ClockSize - Canvas.TextWidth(Text) - ScaleX(10, 96),
    2287     Y - Canvas.TextHeight(Text) div 2, Text);
     2313  Canvas.TextOut(X, Y + (Clock.Bounds.Height - Canvas.TextHeight(Text)) div 2, Text);
     2314  X := X + ScaleX(40, 96) + ScaleY(5, 96);
     2315  Y := Clock.Bounds.Top + (Clock.Bounds.Height - ImagePause.Bounds.Height) div 2;
     2316
     2317  ImagePause.Canvas := Canvas;
     2318  ImagePause.Bounds := Bounds(X, Y, ScaleX(20, 96), ScaleY(20, 96));
     2319  ImagePause.Paint;
     2320  X := X + ImagePause.Bounds.Width + ScaleX(5, 96);
     2321
     2322  ImagePlay.Canvas := Canvas;
     2323  ImagePlay.Bounds := Bounds(X, Y, ScaleX(20, 96), ScaleY(20, 96));
     2324  ImagePlay.Paint;
     2325  X := X + ImagePlay.Bounds.Width + ScaleX(5, 96);
     2326
     2327  ImageFastForward.Canvas := Canvas;
     2328  ImageFastForward.Bounds := Bounds(X, Y, ScaleX(20, 96), ScaleY(20, 96));
     2329  ImageFastForward.Paint;
     2330
     2331  X := Clock.Bounds.Left;
     2332  Y := Clock.Bounds.Top + Clock.Bounds.Height + ScaleY(5, 96);
     2333
     2334  Canvas.Pen.Color := Colors.Text;
     2335  Canvas.Font.Color := Colors.Text;
     2336  Canvas.Brush.Style := bsClear;
     2337  Text := SDay + ' ' + IntToStr(Trunc(Time));
     2338  Canvas.TextOut(X, Y, Text);
    22882339  Y := Y + Canvas.TextHeight(Text) + ScaleY(5, 96);
    2289 
    2290   Text := SDay + ' ' + IntToStr(Trunc(Time));
    2291   Canvas.TextOut(ClockCenter.X - ClockSize - Canvas.TextWidth(Text) - ScaleX(10, 96),
    2292     Y - Canvas.TextHeight(Text) div 2, Text);
    2293   Y := Y + Canvas.TextHeight(Text) + ScaleY(5, 96);
    2294 
    2295   ImagePause.Canvas := Canvas;
    2296   ImagePause.Bounds := Bounds(CanvasSize.X - ScaleX(20 + 10, 96), Y,
    2297     ScaleX(20, 96), ScaleY(20, 96));
    2298   ImagePause.Paint;
    2299   Y := Y + ImagePause.Bounds.Height + ScaleY(5, 96);
    2300 
    2301   ImagePlay.Canvas := Canvas;
    2302   ImagePlay.Bounds := Bounds(CanvasSize.X - ScaleX(20 + 10, 96) , Y,
    2303     ScaleX(20, 96), ScaleY(20, 96));
    2304   ImagePlay.Paint;
    2305   Y := Y + ImagePlay.Bounds.Height + ScaleY(5, 96);
    2306 
    2307   ImageFastForward.Canvas := Canvas;
    2308   ImageFastForward.Bounds := Bounds(CanvasSize.X - ScaleX(20 + 10, 96) , Y,
    2309     ScaleX(20, 96), ScaleY(20, 96));
    2310   ImageFastForward.Paint;
    2311   Y := Y + ImageFastForward.Bounds.Height + ScaleY(5, 96);
    23122340end;
    23132341
     
    27782806  Text: string;
    27792807  Radius: Integer;
    2780   Angle: Real;
    2781   Pos: TPoint;
    27822808  X: Integer;
    27832809  Y: Integer;
     
    28812907  Canvas.Font.Color := Colors.Text;
    28822908  ButtonBack.Canvas := Canvas;
    2883   ButtonBack.Bounds.Left := 10;
    2884   ButtonBack.Bounds.Top := 10;
     2909  ButtonBack.Bounds := Bounds(CanvasSize.X - ButtonBack.Bounds.Width - 10, 10,
     2910    ButtonBack.Bounds.Width, ButtonBack.Bounds.Height);
    28852911  ButtonBack.Paint;
    28862912
     
    35993625begin
    36003626  inherited;
     3627  Colors := TColors.Create;
     3628  Colors.Init(FDarkMode);
    36013629  ImprovementImageSize := ScaleX(64, 96);
    36023630  IconSize := ScaleX(32, 96);
     
    36043632  ButtonBack := TImage.Create;
    36053633  ButtonBack.OnClick := ButtonBackClick;
    3606   ButtonBack.Bounds := Bounds(0, 0, ScaleX(80, 96), ScaleY(80, 96));
     3634  ButtonBack.Bounds := Bounds(0, 0, ScaleX(50, 96), ScaleY(50, 96));
    36073635  Cities := TCities.Create;
    36083636  InitCities;
     
    36413669  ImageNewImprovement2 := TImage.Create;
    36423670  ImageNewImprovement2.OnClick := ButtonNewImprovement2;
     3671  Clock := TClock.Create;
    36433672  MetaCanvas := TMetaCanvas.Create;
    3644   Colors.Init(FDarkMode);
    36453673end;
    36463674
     
    36503678  FreeAndNil(Trains);
    36513679  FreeAndNil(Carriages);
     3680  FreeAndNil(Clock);
    36523681  FreeAndNil(ImageTunnel);
    36533682  FreeAndNil(ImageTerminal);
Note: See TracChangeset for help on using the changeset viewer.