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/Rates.pas

    r361 r465  
    55
    66uses
    7   UDpiControls, Protocol, ScreenTools, BaseWin, LCLIntf, LCLType,
    8 
    9   SysUtils, Classes, Graphics, Controls, Forms,
    10   ButtonB, ButtonC;
     7  UDpiControls, Protocol, ScreenTools, BaseWin, LCLIntf, LCLType, SysUtils, Classes, Graphics,
     8  Controls, Forms, ButtonB, ButtonC;
    119
    1210type
     
    2321  public
    2422    procedure OffscreenPaint; override;
    25     procedure ShowNewContent(NewMode: integer);
    26   end;
    27 
    28 var
    29   RatesDlg: TRatesDlg;
     23    procedure ShowNewContent(NewMode: TWindowMode);
     24  end;
     25
    3026
    3127implementation
     
    4743procedure TRatesDlg.OffscreenPaint;
    4844var
    49   p, x, y, current, max, i: integer;
    50   s, s1: string;
     45  P, X, Y, current, Max, I: Integer;
     46  S, s1: string;
    5147begin
    5248  if (OffscreenUser <> nil) and (OffscreenUser <> self) then
     
    6561  BtnFrame(Offscreen.Canvas, CloseBtn.BoundsRect, MainTexture);
    6662  Offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
    67   s := Phrases.Lookup('TITLE_RATES');
     63  S := Phrases.Lookup('TITLE_RATES');
    6864  RisedTextOut(Offscreen.Canvas,
    69     (ClientWidth - BiColorTextWidth(Offscreen.Canvas, s)) div 2 - 1, 7, s);
    70 
    71   if MyRO.Wonder[woLiberty].EffectiveOwner = me then
    72     s := Phrases.Lookup('NORATES')
    73   else
    74     s := Phrases.Lookup('RATES');
     65    (ClientWidth - BiColorTextWidth(Offscreen.Canvas, S)) div 2 - 1, 7, S);
     66
     67  if MyRO.Wonder[woLiberty].EffectiveOwner = Me then
     68    S := Phrases.Lookup('NORATES')
     69  else
     70    S := Phrases.Lookup('RATES');
    7571  Offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
    76   p := pos('\', s);
    77   if p = 0 then
    78     RisedTextOut(Offscreen.Canvas, (ClientWidth - BiColorTextWidth(Canvas, s))
    79       div 2, 114, s)
    80   else
    81   begin
    82     s1 := copy(s, 1, p - 1);
     72  P := Pos('\', S);
     73  if P = 0 then
     74    RisedTextOut(Offscreen.Canvas, (ClientWidth - BiColorTextWidth(Canvas, S))
     75      div 2, 114, S)
     76  else
     77  begin
     78    s1 := Copy(S, 1, P - 1);
    8379    RisedTextOut(Offscreen.Canvas,
    8480      (ClientWidth - BiColorTextWidth(Offscreen.Canvas, s1)) div 2,
    8581      114 - MessageLineSpacing div 2, s1);
    86     s1 := copy(s, p + 1, 255);
     82    s1 := Copy(S, P + 1, 255);
    8783    RisedTextOut(Offscreen.Canvas,
    8884      (ClientWidth - BiColorTextWidth(Offscreen.Canvas, s1)) div 2,
     
    9187  Offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
    9288
    93   if MyRO.Wonder[woLiberty].EffectiveOwner = me then
     89  if MyRO.Wonder[woLiberty].EffectiveOwner = Me then
    9490  begin
    9591    GlowFrame(Offscreen, ClientWidth div 2 - xSizeBig div 2, 52, xSizeBig,
    96       ySizeBig, Tribe[me].Color);
    97     DpiBitCanvas(Offscreen.Canvas, ClientWidth div 2 - xSizeBig div 2, 52,
     92      ySizeBig, Tribe[Me].Color);
     93    DpiBitBltCanvas(Offscreen.Canvas, ClientWidth div 2 - xSizeBig div 2, 52,
    9894      xSizeBig, ySizeBig, BigImp.Canvas, (woLiberty mod 7) * xSizeBig,
    9995      (woLiberty div 7 + SystemIconLines) * ySizeBig);
     
    10399    // ImageOp_CBC(Offscreen,Templates,260,40,145,112,36,36,$404000,$8B8BEB);
    104100
    105     s := Phrases.Lookup('SCIENCE');
    106     RisedTextOut(Offscreen.Canvas,
    107       16 + 120 - BiColorTextWidth(Offscreen.Canvas, s), 44, s);
    108     s := Format('%d%%', [100 - MyRO.TaxRate - MyRO.LuxRate]);
    109     RisedTextOut(Offscreen.Canvas,
    110       16 + 120 - BiColorTextWidth(Offscreen.Canvas, s), 60, s);
     101    S := Phrases.Lookup('SCIENCE');
     102    RisedTextOut(Offscreen.Canvas,
     103      16 + 120 - BiColorTextWidth(Offscreen.Canvas, S), 44, S);
     104    S := Format('%d%%', [100 - MyRO.TaxRate - MyRO.LuxRate]);
     105    RisedTextOut(Offscreen.Canvas,
     106      16 + 120 - BiColorTextWidth(Offscreen.Canvas, S), 60, S);
    111107    // PaintProgressBar(Offscreen.Canvas,2,16,81,(100-MyRO.LuxRate-MyRO.TaxRate)*120 div 100,0,120,MainTexture);
    112108
    113109    // reverse progress bar for science
    114     x := 16;
    115     y := 81;
     110    X := 16;
     111    Y := 81;
    116112    current := (100 - MyRO.LuxRate - MyRO.TaxRate) * 120 div 100;
    117     max := 120;
    118     Frame(Offscreen.Canvas, x - 1, y - 1, x + max, y + 7, $000000, $000000);
    119     RFrame(Offscreen.Canvas, x - 2, y - 2, x + max + 1, y + 8,
     113    Max := 120;
     114    Frame(Offscreen.Canvas, X - 1, Y - 1, X + Max, Y + 7, $000000, $000000);
     115    RFrame(Offscreen.Canvas, X - 2, Y - 2, X + Max + 1, Y + 8,
    120116      MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
    121117    with Offscreen.Canvas do
    122118    begin
    123       for i := 0 to current div 8 - 1 do
    124         DpiBitCanvas(Offscreen.Canvas, x + max - 8 - i * 8, y, 8, 7,
     119      for I := 0 to current div 8 - 1 do
     120        DpiBitBltCanvas(Offscreen.Canvas, X + Max - 8 - I * 8, Y, 8, 7,
    125121          HGrSystem.Data.Canvas, 104, 9 + 8 * 2);
    126       DpiBitCanvas(Offscreen.Canvas, x + max - current, y, current - 8 * (current div 8), 7,
     122      DpiBitBltCanvas(Offscreen.Canvas, X + Max - current, Y, current - 8 * (current div 8), 7,
    127123        HGrSystem.Data.Canvas, 104, 9 + 8 * 2);
    128124      Brush.Color := $000000;
    129       FillRect(Rect(x, y, x + max - current, y + 7));
     125      FillRect(Rect(X, Y, X + Max - current, Y + 7));
    130126      Brush.Style := bsClear;
    131127    end;
    132128
    133129    RisedTextOut(Offscreen.Canvas, 16 + 160, 44, Phrases.Lookup('LUX'));
    134     s := Format('%d%%', [MyRO.LuxRate]);
    135     RisedTextOut(Offscreen.Canvas,
    136       16 + 160 { +120-BiColorTextWidth(Offscreen.Canvas,s) } , 60, s);
     130    S := Format('%d%%', [MyRO.LuxRate]);
     131    RisedTextOut(Offscreen.Canvas,
     132      16 + 160 { +120-BiColorTextWidth(Offscreen.Canvas,s) } , 60, S);
    137133    PaintProgressBar(Offscreen.Canvas, 5, 16 + 160, 81,
    138134      MyRO.LuxRate * 120 div 100, 0, 120, MainTexture);
     
    145141    MainTexture.ColorBevelLight);
    146142  RisedTextOut(Offscreen.Canvas, 16 + 80, 164, Phrases.Lookup('TAXRATE'));
    147   s := Format('%d%%', [MyRO.TaxRate]);
     143  S := Format('%d%%', [MyRO.TaxRate]);
    148144  RisedTextOut(Offscreen.Canvas,
    149     16 + 80 { +120-BiColorTextWidth(Offscreen.Canvas,s) } , 180, s);
     145    16 + 80 { +120-BiColorTextWidth(Offscreen.Canvas,s) } , 180, S);
    150146  PaintProgressBar(Offscreen.Canvas, 0, 16 + 80, 201,
    151147    MyRO.TaxRate * 120 div 100, 0, 120, MainTexture);
     
    157153end;
    158154
    159 procedure TRatesDlg.ShowNewContent(NewMode: integer);
     155procedure TRatesDlg.ShowNewContent(NewMode: TWindowMode);
    160156begin
    161157  inherited ShowNewContent(NewMode);
     
    164160procedure TRatesDlg.FormShow(Sender: TObject);
    165161begin
    166   if MyRO.Wonder[woLiberty].EffectiveOwner = me then
    167   begin
    168     ScienceBtn.Visible := false;
    169     LuxBtn.Visible := false;
     162  Caption := Phrases.Lookup('TITLE_RATES');
     163  if MyRO.Wonder[woLiberty].EffectiveOwner = Me then
     164  begin
     165    ScienceBtn.Visible := False;
     166    LuxBtn.Visible := False;
    170167  end
    171168  else
    172169  begin
    173     ScienceBtn.Visible := true;
    174     LuxBtn.Visible := true;
     170    ScienceBtn.Visible := True;
     171    LuxBtn.Visible := True;
    175172  end;
    176173  OffscreenPaint;
     
    184181procedure TRatesDlg.TaxLuxBtnClick(Sender: TObject);
    185182var
    186   NewTax, NewLux: integer;
     183  NewTax, NewLux: Integer;
    187184begin
    188185  NewTax := MyRO.TaxRate div 10;
     
    191188  begin
    192189    if NewTax < 10 then
    193       inc(NewTax);
     190      Inc(NewTax);
    194191    if NewTax + NewLux > 10 then
    195       dec(NewLux);
     192      Dec(NewLux);
    196193  end
    197194  else if (Sender = TaxDownBtn) and (NewTax > 0) then
    198     dec(NewTax)
     195    Dec(NewTax)
    199196  else if (Sender = ScienceBtn) and (NewLux > 0) then
    200     dec(NewLux)
     197    Dec(NewLux)
    201198  else if (Sender = LuxBtn) and (NewLux + NewTax < 100) then
    202     inc(NewLux);
    203   if Server(sSetRates, me, NewTax + NewLux shl 4, nil^) <> eNotChanged then
     199    Inc(NewLux);
     200  if Server(sSetRates, Me, NewTax + NewLux shl 4, nil^) <> eNotChanged then
    204201  begin
    205202    CityOptimizer_BeginOfTurn;
    206203    SmartUpdateContent;
    207     MainScreen.UpdateViews(true);
     204    MainScreen.UpdateViews(True);
    208205  end;
    209206end;
Note: See TracChangeset for help on using the changeset viewer.