Changeset 76


Ignore:
Timestamp:
May 18, 2021, 10:25:20 PM (3 years ago)
Author:
chronos
Message:
  • Fixed: Colors inversion of used images if dark mode active.
  • Fixed: Back button arrow drawn as image instead of font. Left arrow was not supported under Ubuntu.
  • Modified: Allow to start new track from already connected station.
Location:
trunk
Files:
3 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormImages.lfm

    r41 r76  
    11object FormImages: TFormImages
    22  Left = 1198
    3   Height = 349
     3  Height = 524
    44  Top = 264
    5   Width = 702
     5  Width = 1053
    66  Caption = 'FormImages'
    7   ClientHeight = 349
    8   ClientWidth = 702
    9   LCLVersion = '1.6.2.0'
     7  ClientHeight = 524
     8  ClientWidth = 1053
     9  DesignTimePPI = 144
     10  LCLVersion = '2.0.12.0'
    1011  object ImageLocomotive: TImage
    11     Left = 32
    12     Height = 34
    13     Top = 32
    14     Width = 32
     12    Left = 48
     13    Height = 51
     14    Top = 48
     15    Width = 48
    1516    Picture.Data = {
    1617      1754506F727461626C654E6574776F726B477261706869634E04000089504E47
     
    5354  end
    5455  object ImagePassenger: TImage
    55     Left = 33
    56     Height = 32
    57     Top = 64
    58     Width = 32
     56    Left = 50
     57    Height = 48
     58    Top = 96
     59    Width = 48
    5960    Picture.Data = {
    6061      1754506F727461626C654E6574776F726B477261706869638C02000089504E47
     
    8384  end
    8485  object ImageTunnel: TImage
    85     Left = 32
    86     Height = 51
    87     Top = 104
    88     Width = 56
     86    Left = 48
     87    Height = 76
     88    Top = 156
     89    Width = 84
    8990    Picture.Data = {
    9091      1754506F727461626C654E6574776F726B47726170686963E40E000089504E47
     
    211212  end
    212213  object ImageScreenshot: TImage
    213     Left = 33
    214     Height = 32
    215     Top = 168
    216     Width = 34
     214    Left = 50
     215    Height = 48
     216    Top = 252
     217    Width = 51
    217218    Picture.Data = {
    218219      1754506F727461626C654E6574776F726B477261706869631C0E000089504E47
     
    332333    }
    333334  end
     335  object ImageLeftArrow: TImage
     336    Left = 163
     337    Height = 79
     338    Top = 57
     339    Width = 85
     340    Picture.Data = {
     341      1754506F727461626C654E6574776F726B477261706869630602000089504E47
     342      0D0A1A0A0000000D49484452000001000000010008030000006BAC5854000000
     343      21504C5445000000000000000000000000000000000000000000000000000000
     344      0000000000006DD148C10000000A74524E530010304050809FBFCFEFF438B8CF
     345      0000018A49444154789CEDDC8B718200144451893141FB2F386901F2165C724E
     346      05EC1D67547EB71B000000000000000000000000F007CB63B3FBD9C73C69595F
     347      5BADCBD9073DC87EFBEDB7DF7EFBEDB7DF7EFBEDB7DF7EFBEDB7DF7EFBEDB7DF
     348      7EFBEDB7DF7EFBEDBF0EFBEDB7DF7EFBEDB7DF7EFBEDB7DF7EFBEDB7DF7EFBED
     349      B7DF7EFBEDB7DF7EFBEDB7FF3A76EC7FADDF07FB78AFFDC7CB3D72DBB13F17A0
     350      647F2C40CBFE54809AFDA1003DFB33018AF6470234ED4F04A8DA1F08D0B57F3E
     351      40D9FEF1006DFBA703D4ED1F0ED0B77F3640E1FED1008DFB270354EE9F0CF075
     352      F6965D7C02E6027416F02D3019A0B1805F82B301FA0AF837381DA0AD803342F3
     353      01BA0A382B9C08D054C095A14C809E02AE0EA702B41408BE93BCA340F2A5EC15
     354      05A26FA5DF51E0F9793F56F6AEB4FF7E9F9C020A28A080020A28A080020A28A0
     355      80020A28A080020A28A080020A28A080020A28A080020A28A080020A28A08002
     356      0A28A080020A28A080020A28A080020A28A080020A28F05BE0B159F409500000
     357      00000000000000000000E0627E009B74DE3A9610647B0000000049454E44AE42
     358      6082
     359    }
     360    Proportional = True
     361    Stretch = True
     362  end
    334363end
  • trunk/Forms/UFormImages.pas

    r41 r76  
    1313
    1414  TFormImages = class(TForm)
     15    ImageLeftArrow: TImage;
    1516    ImageLocomotive: TImage;
    1617    ImagePassenger: TImage;
  • trunk/Forms/UFormMain.lfm

    r71 r76  
    1515  OnKeyUp = FormKeyUp
    1616  OnShow = FormShow
    17   LCLVersion = '2.0.10.0'
     17  LCLVersion = '2.0.12.0'
    1818  object PaintBox1: TPaintBox
    1919    Left = 0
  • trunk/Forms/UFormMain.pas

    r69 r76  
    4444    procedure LoadConfig;
    4545    procedure SaveConfig;
     46    procedure LoadGraphicAssets;
     47    procedure DarkModeChange(Sender: TObject);
    4648  public
    4749    FullScreen: Boolean;
     
    5961
    6062uses
    61   UFormImages;
     63  UFormImages, UPixelPointer;
    6264
    6365{ TFormMain }
     
    114116    FullScreen := PersistentForm1.FormFullScreen;
    115117    Engine.InitMenus;
    116     Engine.ImagePassenger.Picture.Assign(FormImages.ImagePassenger.Picture);
    117     Engine.ImageLocomotive.Picture.Assign(FormImages.ImageLocomotive.Picture);
     118    Engine.OnDarkModeChange := DarkModeChange;
    118119    Engine.Map.Size := Point(PaintBox1.Width, PaintBox1.Height);
    119120    Engine.View.DestRect := Rect(0, 0, PaintBox1.Width, PaintBox1.Height);
    120121    Engine.MainMenu;
     122    LoadGraphicAssets;
    121123  end;
    122124end;
     
    212214end;
    213215
     216procedure TFormMain.LoadGraphicAssets;
     217begin
     218  Engine.ImagePassenger.Picture.Assign(FormImages.ImagePassenger.Picture);
     219  Engine.ImageLocomotive.Picture.Assign(FormImages.ImageLocomotive.Picture);
     220  Engine.ButtonBack.Bitmap.Assign(FormImages.ImageLeftArrow.Picture.Bitmap);
     221  if Engine.DarkMode then begin
     222    BitmapInvert(Engine.ImagePassenger.Picture.Bitmap);
     223    BitmapInvert(Engine.ImageLocomotive.Picture.Bitmap);
     224    BitmapInvert(Engine.ButtonBack.Bitmap);
     225  end;
     226end;
     227
     228procedure TFormMain.DarkModeChange(Sender: TObject);
     229begin
     230  LoadGraphicAssets;
     231end;
     232
    214233
    215234end.
  • trunk/Languages/BigMetro.cs.po

    r66 r76  
    1111"Language: cs\n"
    1212"X-Generator: Poedit 2.4.1\n"
     13
     14#: tformimages.caption
     15msgid "FormImages"
     16msgstr ""
    1317
    1418#: tformmain.caption
     
    108112msgid "Try again"
    109113msgstr "Zkusit znovu"
     114
  • trunk/Languages/BigMetro.po

    r66 r76  
    11msgid ""
    22msgstr "Content-Type: text/plain; charset=UTF-8"
     3
     4#: tformimages.caption
     5msgid "FormImages"
     6msgstr ""
    37
    48#: tformmain.caption
  • trunk/Packages/Common/Common.lpk

    r60 r76  
    4040    <License Value="GNU/GPL"/>
    4141    <Version Minor="7"/>
    42     <Files Count="26">
     42    <Files Count="27">
    4343      <Item1>
    4444        <Filename Value="StopWatch.pas"/>
     
    156156        <UnitName Value="ULanguages"/>
    157157      </Item26>
     158      <Item27>
     159        <Filename Value="UPixelPointer.pas"/>
     160        <UnitName Value="UPixelPointer"/>
     161      </Item27>
    158162    </Files>
    159163    <i18n>
  • trunk/Packages/Common/Common.pas

    r60 r76  
    1313  UJobProgressView, UXMLUtils, UApplicationInfo, USyncCounter, UListViewSort,
    1414  UPersistentForm, UFindFile, UScaleDPI, UTheme, UStringTable, UMetaCanvas,
    15   UGeometric, UTranslator, ULanguages, LazarusPackageIntf;
     15  UGeometric, UTranslator, ULanguages, UPixelPointer, LazarusPackageIntf;
    1616
    1717implementation
  • trunk/UEngine.pas

    r73 r76  
    277277  private
    278278    FDarkMode: Boolean;
     279    FOnDarkModeChange: TNotifyEvent;
    279280    LastMousePos: TPoint;
    280281    LastFocusedStation: TMapStation;
     
    292293    MenuOptions: TMenu;
    293294    MenuGame: TMenu;
    294     ButtonBack: TMenuItemButton;
    295295    LastState: TGameState;
    296296    function GetServedDaysCount: Integer;
     
    345345    State: TGameState;
    346346    RedrawPending: Boolean;
     347    ButtonBack: TMenuItemImage;
    347348    ImagePassenger: TImage;
    348349    ImageLocomotive: TImage;
     
    365366    property DarkMode: Boolean read FDarkMode write SetDarkMode;
    366367    property ServedDaysCount: Integer read GetServedDaysCount;
     368    property OnDarkModeChange: TNotifyEvent read FOnDarkModeChange
     369      write FOnDarkModeChange;
    367370  end;
    368371
     
    382385  ImagePassengerName = 'Images/Passenger.png';
    383386  ImageLocomotiveName = 'Images/Locomotive.png';
     387  ImageLeftArrowName = 'Images/Left arrow.png';
    384388  TrainPassengerCount = 6;
    385389  StationMinDistance = 100;
     
    403407
    404408uses
    405   UGeometric, UFormMain, ULanguages;
     409  UGeometric, UFormMain, ULanguages, UPixelPointer;
    406410
    407411resourcestring
     
    16671671  FDarkMode := AValue;
    16681672  InitColors;
     1673  if Assigned(FOnDarkModeChange) then FOnDarkModeChange(Self);
    16691674end;
    16701675
     
    26432648  NewIndex: Integer;
    26442649begin
    2645   if Button = mbLeft then begin
    2646     if State <> gsMenu then begin
     2650  if (Button = mbLeft) and (State <> gsMenu) then begin
    26472651    MouseHold := True;
    26482652    LastFocusedStation := nil;
     
    26562660    // Select unused train
    26572661    if (Distance(Position, Point(View.DestRect.Right div 2 - Length(LineColors) div 2 * LineColorsDist - 100,
    2658     View.DestRect.Bottom - LineColorsDist)) < 30) and
     2662      View.DestRect.Bottom - LineColorsDist)) < 30) and
    26592663    (Trains.GetUnusedCount > 0) then begin
    26602664      SelectedTrain := Trains.GetUnusedTrain;
    26612665      Exit;
     2666    end;
     2667
     2668    // New track creation from selected station as start
     2669    Station := GetStationOnPos(View.PointDestToSrc(Position));
     2670    if Assigned(Station) then begin
     2671      if Assigned(SelectedLine) and (SelectedLine.LineStations.Count = 0) then NewLine := SelectedLine
     2672        else NewLine := GetUnusedLine;
     2673      if Assigned(NewLine) then begin
     2674        NewLine.ConnectStation(Station, nil, nil);
     2675        TrackStationDown := NewLine.Track.Points.Last;
     2676        TrackStationUp := nil;
     2677        LastFocusedStation := Station;
     2678        SelectedLine := NewLine;
     2679        Exit;
     2680      end;
    26622681    end;
    26632682
     
    26862705    end;
    26872706    if Assigned(Track) then Track.Free;
    2688 
    2689     // New track creation from selected station as start
    2690     Station := GetStationOnPos(View.PointDestToSrc(Position));
    2691     if Assigned(Station) then begin
    2692       if Assigned(SelectedLine) and (SelectedLine.LineStations.Count = 0) then NewLine := SelectedLine
    2693         else NewLine := GetUnusedLine;
    2694       if Assigned(NewLine) then begin
    2695         NewLine.ConnectStation(Station, nil, nil);
    2696         TrackStationDown := NewLine.Track.Points.Last;
    2697         TrackStationUp := nil;
    2698         LastFocusedStation := Station;
    2699       end;
    2700     end;
    2701     end;
    27022707  end;
    27032708end;
     
    27872792constructor TEngine.Create;
    27882793begin
    2789   ButtonBack := TMenuItemButton.Create;
    2790   ButtonBack.Text := '🡸';
     2794  ButtonBack := TMenuItemImage.Create;
    27912795  ButtonBack.OnClick := ButtonBackClick;
    27922796  ButtonBack.BackgroundColor := clNone;
     2797  ButtonBack.Bounds := Bounds(0, 0, ScaleX(80, 96), ScaleY(80, 96));
    27932798  MenuMain := TMenu.Create;
    27942799  MenuOptions := TMenu.Create;
  • trunk/UMenu.pas

    r68 r76  
    2525    procedure Paint(Canvas: TCanvas; P: TPoint); virtual;
    2626    function GetOutputText: string; virtual;
    27     constructor Create;
     27    constructor Create; virtual;
    2828  end;
    2929
     
    4747    Index: Integer;
    4848    States: TStringList;
    49     constructor Create;
     49    constructor Create; override;
    5050    destructor Destroy; override;
    5151    procedure Paint(Canvas: TCanvas; P: TPoint); override;
     
    6262    procedure Paint(Canvas: TCanvas; P: TPoint); override;
    6363    property OnClick: TNotifyEvent read FOnClick write FOnClick;
     64  end;
     65
     66  { TMenuItemImage }
     67
     68  TMenuItemImage = class(TMenuItem)
     69  private
     70    FOnClick: TNotifyEvent;
     71  public
     72    Bitmap: TBitmap;
     73    procedure Paint(Canvas: TCanvas; P: TPoint); override;
     74    property OnClick: TNotifyEvent read FOnClick write FOnClick;
     75    constructor Create; override;
     76    destructor Destroy; override;
    6477  end;
    6578
     
    105118implementation
    106119
     120{ TMenuItemImage }
     121
     122procedure TMenuItemImage.Paint(Canvas: TCanvas; P: TPoint);
     123begin
     124  if Selected then Canvas.Brush.Color := BackgroundSelectedColor
     125    else Canvas.Brush.Color := BackgroundColor;
     126  if Canvas.Brush.Color = clNone then Canvas.Brush.Style := bsClear
     127    else Canvas.Brush.Style := bsSolid;
     128  Canvas.StretchDraw(Bounds, Bitmap);
     129end;
     130
     131constructor TMenuItemImage.Create;
     132begin
     133  inherited;
     134  Bitmap := TBitmap.Create;
     135end;
     136
     137destructor TMenuItemImage.Destroy;
     138begin
     139  FreeAndNil(Bitmap);
     140  inherited;
     141end;
     142
    107143{ TMenuItemButton }
    108144
     
    155191constructor TMenuItemComboBox.Create;
    156192begin
     193  inherited;
    157194  States := TStringList.Create;
    158195end;
     
    160197destructor TMenuItemComboBox.Destroy;
    161198begin
    162   States.Free;
     199  FreeAndNil(States);
    163200  inherited;
    164201end;
Note: See TracChangeset for help on using the changeset viewer.