Ignore:
Timestamp:
Nov 30, 2023, 10:16:14 PM (12 months ago)
Author:
chronos
Message:
  • Modified: Updated high dpi branch from trunk.
  • Modified: Use generics.collections instead of fgl.
  • Modified: Compile with Delphi syntax.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/highdpi/LocalPlayer/MessgEx.pas

    r412 r465  
    55
    66uses
    7   UDpiControls, Messg, Protocol, ScreenTools, Platform, DateUtils,
    8   LCLIntf, LCLType, Messages, SysUtils, Classes, Graphics, Controls, Forms, ButtonA,
    9   ButtonB, StdCtrls, DrawDlg;
     7  UDpiControls, Messg, Protocol, ScreenTools, Platform, DateUtils, LCLIntf, LCLType, Messages,
     8  SysUtils, Classes, Graphics, Controls, Forms, ButtonA, ButtonB, StdCtrls,
     9  DrawDlg, Help;
    1010
    1111type
     
    1313    mikPureIcon, mikMyArmy, mikEnemyArmy, mikFullControl, mikShip, mikBigIcon,
    1414    mikEnemyShipComplete);
     15
     16  { TMessgExDlg }
    1517
    1618  TMessgExDlg = class(TBaseMessgDlg)
     
    3234    Kind: TMessageKind;
    3335    IconIndex: Integer;
    34     HelpKind: Integer;
     36    HelpKind: TLinkCategory;
    3537    HelpNo: Integer;
    3638    CenterTo: Integer;
    3739    IconKind: TMessageIconKind;
    3840    OpenSound: string;
    39     function ShowModal: integer; override;
     41    function ShowModal: Integer; override;
    4042    procedure CancelMovie;
    4143  private
    42     MovieCancelled: boolean;
    43     procedure PaintBook(ca: TDpiCanvas; x, y, clPage, clCover: integer);
     44    MovieCancelled: Boolean;
     45    procedure PaintBook(ca: TDpiCanvas; X, Y, clPage, clCover: Integer);
    4446    procedure PaintMyArmy;
    4547    procedure PaintEnemyArmy;
     
    4749  end;
    4850
    49 var
    50   MessgExDlg: TMessgExDlg;
    5151
    5252procedure SoundMessageEx(SimpleText, SoundItem: string);
    53 procedure TribeMessage(p: integer; SimpleText, SoundItem: string);
     53procedure TribeMessage(P: Integer; SimpleText, SoundItem: string);
    5454function SimpleQuery(QueryKind: TMessageKind; SimpleText, SoundItem: string)
    55   : integer;
     55  : Integer;
    5656procedure ContextMessage(SimpleText, SoundItem: string;
    57   ContextKind, ContextNo: integer);
     57  ContextKind: TLinkCategory; ContextNo: Integer);
     58
    5859
    5960implementation
    6061
    6162uses
    62   ClientTools, BaseWin, Term, Help, UnitStat, Tribes, UPixelPointer,
    63   IsoEngine, Diagram, Sound;
     63  ClientTools, BaseWin, Term, UnitStat, Tribes, PixelPointer,
     64  Diagram, Sound;
    6465
    6566{$R *.lfm}
     
    7879procedure TMessgExDlg.FormShow(Sender: TObject);
    7980var
    80   i: integer;
     81  I: Integer;
    8182begin
    8283  if IconKind = mikEnemyArmy then
     
    147148  end;
    148149
    149   SplitText(true);
     150  SplitText(True);
    150151  ClientHeight := 72 + Border + TopSpace + Lines * MessageLineSpacing;
    151152  if GameMode = cMovie then
     
    178179      end;
    179180  end;
    180   for i := 0 to ControlCount - 1 do
    181     Controls[i].Top := ClientHeight - (34 + Border);
     181  for I := 0 to ControlCount - 1 do
     182    Controls[I].Top := ClientHeight - (34 + Border);
    182183  if Kind = mkModel then
    183184    EInput.Top := ClientHeight - (76 + Border);
    184185end;
    185186
    186 function TMessgExDlg.ShowModal: integer;
     187function TMessgExDlg.ShowModal: Integer;
    187188var
    188189  Ticks0: TDateTime;
    189190  Ticks: TDateTime;
    190191begin
     192  Caption := Phrases.Lookup('TITLE_MESSAGE');
    191193  if GameMode = cMovie then
    192194  begin
    193195    if not((GameMode = cMovie) and (MovieSpeed = 4)) then
    194196    begin
    195       MovieCancelled := false;
     197      MovieCancelled := False;
    196198      Show;
    197199      Ticks0 := NowPrecise;
     
    203205      Hide;
    204206    end;
    205     result := mrOk;
     207    Result := mrOk;
    206208  end
    207209  else
    208     result := inherited;
     210    Result := inherited;
     211  //Gtk2Fix;
    209212end;
    210213
    211214procedure TMessgExDlg.CancelMovie;
    212215begin
    213   MovieCancelled := true;
    214 end;
    215 
    216 procedure TMessgExDlg.PaintBook(ca: TDpiCanvas; x, y, clPage, clCover: integer);
     216  MovieCancelled := True;
     217end;
     218
     219procedure TMessgExDlg.PaintBook(ca: TDpiCanvas; X, Y, clPage, clCover: Integer);
    217220const
    218221  xScrewed = 77;
     
    220223  wScrewed = 43;
    221224  hScrewed = 27;
     225type
     226  TScrewed = array [0 .. wScrewed - 1, 0 .. hScrewed - 1, 0 .. 3] of Single;
    222227var
    223   ix, iy, xDst, yDst, dx, dy, xIcon, yIcon: integer;
     228  ix, iy, xDst, yDst, dx, dy, xIcon, yIcon: Integer;
    224229  BookRect: TRect;
    225   x1, xR, yR, share: single;
    226   Screwed: array [0 .. wScrewed - 1, 0 .. hScrewed - 1, 0 .. 3] of single;
     230  x1, xR, yR, share: Single;
     231  Screwed: TScrewed;
    227232  SrcPtr: TPixelPointer;
    228233  Width: Integer;
     
    235240    yIcon := (IconIndex + SystemIconLines * 7) div 7 * ySizeBig;
    236241    // prepare screwed icon
    237     FillChar(Screwed, sizeof(Screwed), 0);
     242    Screwed := Default(TScrewed);
    238243    BigImp.BeginUpdate;
    239     SrcPtr := PixelPointer(BigImp, ScaleToNative(xIcon), ScaleToNative(yIcon));
     244    SrcPtr := TPixelPointer.Create(BigImp, ScaleToNative(xIcon), ScaleToNative(yIcon));
    240245    for iy := 0 to ScaleToNative(Height) - 1 do begin
    241246      for ix := 0 to ScaleToNative(Width) - 1 do begin
     
    277282    BookRect := SmallBook.BoundsRect;
    278283  end;
    279   x := x - BookRect.Width div 2;
     284  X := X - BookRect.Width div 2;
    280285
    281286  // paint
    282287  UnshareBitmap(LogoBuffer);
    283   DpiBitCanvas(LogoBuffer.Canvas, 0, 0, BookRect.Width, BookRect.Height, ca, x, y);
     288  DpiBitBltCanvas(LogoBuffer.Canvas, 0, 0, BookRect.Width, BookRect.Height, ca, X, Y);
    284289
    285290  if IconIndex >= 0 then
     
    294299  ImageOp_BCC(LogoBuffer, Templates.Data, Point(0, 0), BookRect, clCover, clPage);
    295300
    296   DpiBitCanvas(ca, x, y, BookRect.Width, BookRect.Height, LogoBuffer.Canvas, 0, 0);
     301  DpiBitBltCanvas(ca, X, Y, BookRect.Width, BookRect.Height, LogoBuffer.Canvas, 0, 0);
    297302end;
    298303
     
    303308procedure TMessgExDlg.PaintEnemyArmy;
    304309var
    305   emix, ix, iy, x, y, count, UnitsInLine: integer;
     310  emix, ix, iy, X, Y, count, UnitsInLine: Integer;
    306311begin
    307312  ix := 0;
     
    314319    for count := 0 to LostArmy[emix] - 1 do
    315320    begin
    316       x := ClientWidth div 2 + ix * 64 - UnitsInLine * 32;
    317       y := 26 + Border + TopSpace + Lines * MessageLineSpacing + iy * 48;
     321      X := ClientWidth div 2 + ix * 64 - UnitsInLine * 32;
     322      Y := 26 + Border + TopSpace + Lines * MessageLineSpacing + iy * 48;
    318323      with MyRO.EnemyModel[emix], Tribe[Owner].ModelPicture[mix] do
    319324      begin
    320         DpiBitCanvas(Canvas, x, y, 64, 48, HGr.Mask.Canvas,
     325        DpiBitBltCanvas(Canvas, X, Y, 64, 48, HGr.Mask.Canvas,
    321326          pix mod 10 * 65 + 1, pix div 10 * 49 + 1, SRCAND);
    322         DpiBitCanvas(Canvas, x, y, 64, 48, HGr.Data.Canvas,
     327        DpiBitBltCanvas(Canvas, X, Y, 64, 48, HGr.Data.Canvas,
    323328          pix mod 10 * 65 + 1, pix div 10 * 49 + 1, SRCPAINT);
    324329      end;
    325330
    326331      // next position
    327       inc(ix);
     332      Inc(ix);
    328333      if ix = LostUnitsPerLine then
    329334      begin // next line
    330335        ix := 0;
    331         inc(iy);
     336        Inc(iy);
    332337        if iy = 6 then
    333           exit;
     338          Exit;
    334339        UnitsInLine := nLostArmy - LostUnitsPerLine * iy;
    335340        if UnitsInLine > LostUnitsPerLine then
     
    341346procedure TMessgExDlg.FormPaint(Sender: TObject);
    342347var
    343   p1, clSaveTextLight, clSaveTextShade: integer;
     348  p1, clSaveTextLight, clSaveTextShade: Integer;
    344349begin
    345350  if (IconKind = mikImp) and (IconIndex = 27) then
     
    362367        p1 := MyRO.Wonder[IconIndex].EffectiveOwner;
    363368        UnshareBitmap(Buffer);
    364         DpiBitCanvas(Buffer.Canvas, 0, 0, xSizeBig + 2 * GlowRange,
     369        DpiBitBltCanvas(Buffer.Canvas, 0, 0, xSizeBig + 2 * GlowRange,
    365370          ySizeBig + 2 * GlowRange, Canvas,
    366371          ClientWidth div 2 - (28 + GlowRange), 24 - GlowRange);
    367         DpiBitCanvas(Buffer.Canvas, GlowRange, GlowRange, xSizeBig, ySizeBig,
     372        DpiBitBltCanvas(Buffer.Canvas, GlowRange, GlowRange, xSizeBig, ySizeBig,
    368373          BigImp.Canvas, IconIndex mod 7 * xSizeBig,
    369374          (IconIndex + SystemIconLines * 7) div 7 * ySizeBig);
     
    373378          GlowFrame(Buffer, GlowRange, GlowRange, xSizeBig, ySizeBig,
    374379            Tribe[p1].Color);
    375         DpiBitCanvas(Canvas, ClientWidth div 2 - (28 + GlowRange),
     380        DpiBitBltCanvas(Canvas, ClientWidth div 2 - (28 + GlowRange),
    376381          24 - GlowRange, xSizeBig + 2 * GlowRange, ySizeBig + 2 * GlowRange,
    377382          Buffer.Canvas, 0, 0);
     
    387392      end;
    388393    mikModel:
    389       with Tribe[me].ModelPicture[IconIndex] do
     394      with Tribe[Me].ModelPicture[IconIndex] do
    390395      begin
    391396        FrameImage(Canvas, BigImp, ClientWidth div 2 - 28, 24, xSizeBig,
    392397          ySizeBig, 0, 0);
    393         DpiBitCanvas(Canvas, ClientWidth div 2 - 32, 20, 64, 44,
     398        DpiBitBltCanvas(Canvas, ClientWidth div 2 - 32, 20, 64, 44,
    394399          HGr.Mask.Canvas, pix mod 10 * 65 + 1,
    395400          pix div 10 * 49 + 1, SRCAND);
    396         DpiBitCanvas(Canvas, ClientWidth div 2 - 32, 20, 64, 44,
     401        DpiBitBltCanvas(Canvas, ClientWidth div 2 - 32, 20, 64, 44,
    397402          HGr.Data.Canvas, pix mod 10 * 65 + 1,
    398403          pix div 10 * 49 + 1, SRCPAINT);
     
    406411        Frame(Canvas, ClientWidth div 2 - 32 - 1, 24 - 1,
    407412          ClientWidth div 2 + 32, 24 + 48, $000000, $000000);
    408         DpiBitCanvas(Canvas, ClientWidth div 2 - 32, 24, 64, 48,
     413        DpiBitBltCanvas(Canvas, ClientWidth div 2 - 32, 24, 64, 48,
    409414          Tribe[IconIndex].faceHGr.Data.Canvas,
    410415          1 + Tribe[IconIndex].facepix mod 10 * 65,
     
    420425    mikEnemyShipComplete:
    421426      begin
    422         DpiBitCanvas(Buffer.Canvas, 0, 0, 140, 120, Canvas,
     427        DpiBitBltCanvas(Buffer.Canvas, 0, 0, 140, 120, Canvas,
    423428          (ClientWidth - 140) div 2, 24);
    424429        ImageOp_BCC(Buffer, Templates.Data, Point(0, 0), StarshipDeparted.BoundsRect, 0, $FFFFFF);
    425         DpiBitCanvas(Canvas, (ClientWidth - 140) div 2, 24, 140, 120,
     430        DpiBitBltCanvas(Canvas, (ClientWidth - 140) div 2, 24, 140, 120,
    426431          Buffer.Canvas, 0, 0);
    427432      end;
     
    451456begin
    452457  if Kind = mkOkHelp then
    453     HelpDlg.ShowNewContent(wmSubmodal, HelpKind, HelpNo)
     458    MainScreen.HelpDlg.ShowNewContent(wmSubmodal, HelpKind, HelpNo)
    454459  else if Kind = mkModel then
    455     UnitStatDlg.ShowNewContent_OwnModel(wmSubmodal, IconIndex)
     460    MainScreen.UnitStatDlg.ShowNewContent_OwnModel(wmSubmodal, IconIndex)
    456461  else
    457462    ModalResult := mrIgnore;
     
    482487// because Messg.SoundMessage not capable of movie mode
    483488begin
    484   with MessgExDlg do
     489  with MainScreen.MessgExDlg do
    485490  begin
    486491    MessgText := SimpleText;
     
    491496end;
    492497
    493 procedure TribeMessage(p: integer; SimpleText, SoundItem: string);
    494 begin
    495   with MessgExDlg do
     498procedure TribeMessage(P: Integer; SimpleText, SoundItem: string);
     499begin
     500  with MainScreen.MessgExDlg do
    496501  begin
    497502    OpenSound := SoundItem;
     
    499504    Kind := mkOk;
    500505    IconKind := mikTribe;
    501     IconIndex := p;
     506    IconIndex := P;
    502507    ShowModal;
    503508  end;
     
    505510
    506511function SimpleQuery(QueryKind: TMessageKind; SimpleText, SoundItem: string)
    507   : integer;
    508 begin
    509   with MessgExDlg do
     512  : Integer;
     513begin
     514  with MainScreen.MessgExDlg do
    510515  begin
    511516    MessgText := SimpleText;
     
    513518    Kind := QueryKind;
    514519    ShowModal;
    515     result := ModalResult;
     520    Result := ModalResult;
    516521  end;
    517522end;
    518523
    519524procedure ContextMessage(SimpleText, SoundItem: string;
    520   ContextKind, ContextNo: integer);
    521 begin
    522   with MessgExDlg do
     525  ContextKind: TLinkCategory; ContextNo: Integer);
     526begin
     527  with MainScreen.MessgExDlg do
    523528  begin
    524529    MessgText := SimpleText;
     
    543548end;
    544549
    545 
    546 initialization
    547 
    548550end.
Note: See TracChangeset for help on using the changeset viewer.