Ignore:
Timestamp:
Aug 21, 2025, 11:37:30 PM (5 hours ago)
Author:
chronos
Message:
  • Added: Enter key confirms battle dialog window.
  • Fixed: Potential battle dialog drawing issue.
  • Modified: Code cleanup.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Battle.pas

    r622 r709  
    6666  MaxBar := 65;
    6767
    68   // TerrType:=MyMap[ToLoc] and fTerrain;
     68  // TerrType := MyMap[ToLoc] and fTerrain;
    6969  GetUnitInfo(ToLoc, euix, UnitInfo);
    7070
     
    171171  UnshareBitmap(Buffer);
    172172  BitBltCanvas(Buffer.Canvas, 0, 0, 66, 48, ca, xm + 8 + 4, ym - 8 - 12 - 48);
    173   { if TerrType<fForest then
    174     Sprite(Buffer,HGrTerrain,0,16,66,32,1+TerrType*(xxt*2+1),1+yyt)
     173  { if TerrType < fForest then
     174    Sprite(Buffer, HGrTerrain, 0, 16, 66, 32, 1 + TerrType * (xxt * 2 + 1), 1 + yyt)
    175175    else
    176176    begin
    177     Sprite(Buffer,HGrTerrain,0,16,66,32,1+2*(xxt*2+1),1+yyt+2*(yyt*3+1));
    178     if (TerrType=fForest) and IsJungle(ToLoc div G.lx) then
    179     Sprite(Buffer,HGrTerrain,0,16,66,32,1+7*(xxt*2+1),1+yyt+19*(yyt*3+1))
    180     else Sprite(Buffer,HGrTerrain,0,16,66,32,1+7*(xxt*2+1),1+yyt+2*(2+TerrType-fForest)*(yyt*3+1));
     177      Sprite(Buffer, HGrTerrain, 0, 16, 66, 32, 1 + 2 * (xxt * 2 + 1), 1 + yyt + 2 * (yyt * 3 + 1));
     178      if (TerrType = fForest) and IsJungle(ToLoc div G.lx) then
     179      Sprite(Buffer, HGrTerrain, 0, 16, 66, 32, 1 + 7 * (xxt * 2 + 1), 1+ yyt + 19 * (yyt * 3 + 1))
     180      else Sprite(Buffer, HGrTerrain, 0, 16, 66, 32, 1 + 7 * (xxt * 2 + 1), 1 + yyt + 2 * (2 + TerrType - fForest) * (yyt * 3 + 1));
    181181    end; }
    182182  IsoMap.PaintUnit(1, 0, UnitInfo, 0);
     
    201201procedure TBattleDlg.FormShow(Sender: TObject);
    202202begin
    203   if IsSuicideQuery then
    204   begin
    205     ClientWidth := 300;
    206     ClientHeight := 288;
     203  if IsSuicideQuery then begin
     204    BoundsRect := Bounds(0, 0, 300, 288);
    207205    OKBtn.Visible := True;
    208206    CancelBtn.Visible := True;
    209207    CenterToScreen;
    210   end
    211   else
    212   begin
    213     ClientWidth := 178;
    214     ClientHeight := 178;
     208  end else begin
     209    BoundsRect := Bounds(0, 0, 178, 178);
    215210    OKBtn.Visible := False;
    216211    CancelBtn.Visible := False;
     
    226221  begin
    227222    Brush.Color := 0;
    228     FillRect(Rect(0, 0, ClientWidth, ClientHeight));
     223    FillRect(Rect(0, 0, Width, Height));
    229224    Brush.Style := TBrushStyle.bsClear;
    230225    PaintBackground(Canvas, 3 + Border, 3 + Border,
    231       ClientWidth - (6 + 2 * Border), ClientHeight - (6 + 2 * Border),
    232       ClientWidth, ClientHeight);
    233   end;
    234   Frame(Canvas, Border + 1, Border + 1, ClientWidth - (2 + Border),
    235     ClientHeight - (2 + Border), MainTexture.ColorBevelLight,
     226      Width - (6 + 2 * Border), Height - (6 + 2 * Border),
     227      Width, Height);
     228  end;
     229  Frame(Canvas, Border + 1, Border + 1, Width - (2 + Border),
     230    Height - (2 + Border), MainTexture.ColorBevelLight,
    236231    MainTexture.ColorBevelShade);
    237   Frame(Canvas, 2 + Border, 2 + Border, ClientWidth - (3 + Border),
    238     ClientHeight - (3 + Border), MainTexture.ColorBevelLight,
     232  Frame(Canvas, 2 + Border, 2 + Border, Width - (3 + Border),
     233    Height - (3 + Border), MainTexture.ColorBevelLight,
    239234    MainTexture.ColorBevelShade);
    240235
     
    243238    Canvas.Font.Assign(UniFont[ftCaption]);
    244239    S := Phrases.Lookup('TITLE_SUICIDE');
    245     RisedTextOut(Canvas, (ClientWidth - BiColorTextWidth(Canvas, S)) div 2,
     240    RisedTextOut(Canvas, (Width - BiColorTextWidth(Canvas, S)) div 2,
    246241      7 + Border, S);
    247242    Canvas.Font.Assign(UniFont[ftNormal]);
     
    249244    P := Pos('\', S);
    250245    if P = 0 then
    251       RisedTextOut(Canvas, (ClientWidth - BiColorTextWidth(Canvas, S))
    252         div 2, 205, S)
     246      RisedTextOut(Canvas, (Width - BiColorTextWidth(Canvas, S)) div 2, 205, S)
    253247    else
    254248    begin
    255249      s1 := Copy(S, 1, P - 1);
    256       RisedTextOut(Canvas, (ClientWidth - BiColorTextWidth(Canvas, s1)) div 2,
     250      RisedTextOut(Canvas, (Width - BiColorTextWidth(Canvas, s1)) div 2,
    257251        205 - MessageLineSpacing div 2, s1);
    258252      s1 := Copy(S, P + 1, 255);
    259       RisedTextOut(Canvas, (ClientWidth - BiColorTextWidth(Canvas, s1)) div 2,
     253      RisedTextOut(Canvas, (Width - BiColorTextWidth(Canvas, s1)) div 2,
    260254        205 + (MessageLineSpacing - MessageLineSpacing div 2), s1);
    261255    end;
     
    263257  end
    264258  else
    265     ym := ClientHeight div 2;
     259    ym := Height div 2;
    266260  Canvas.Font.Assign(UniFont[ftSmall]);
    267   PaintBattleOutcome(Canvas, ClientWidth div 2, ym, uix, ToLoc, Forecast);
     261  PaintBattleOutcome(Canvas, Width div 2, ym, uix, ToLoc, Forecast);
    268262
    269263  for cix := 0 to ControlCount - 1 do
     
    293287  Shift: TShiftState);
    294288begin
     289  if Key = VK_RETURN then OKBtnClick(Self)
     290  else
    295291  if not IsSuicideQuery and (Key <> VK_SHIFT) then
    296292  begin
Note: See TracChangeset for help on using the changeset viewer.