Ignore:
Timestamp:
May 19, 2022, 10:39:34 PM (2 years ago)
Author:
chronos
Message:
  • Modified: Use first capital letter in identifiers.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Diagram.pas

    r442 r447  
    1919    procedure ToggleBtnClick(Sender: TObject);
    2020    procedure PlayerClick(Sender: TObject);
    21     procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);
     21    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    2222
    2323  public
    2424    procedure OffscreenPaint; override;
    2525    procedure ShowNewContent_Charts(NewMode: TWindowMode);
    26     procedure ShowNewContent_Ship(NewMode: TWindowMode; p: integer = -1);
     26    procedure ShowNewContent_Ship(NewMode: TWindowMode; P: Integer = -1);
    2727
    2828  private
    2929    Kind: (dkChart, dkShip);
    30     Player, Mode: integer;
     30    Player, Mode: Integer;
    3131  end;
    3232
     
    3434  DiaDlg: TDiaDlg;
    3535
    36 procedure PaintColonyShip(canvas: TCanvas; Player, Left, Width, Top: integer);
     36procedure PaintColonyShip(Canvas: TCanvas; Player, Left, Width, Top: Integer);
    3737
    3838implementation
     
    4545const
    4646  Border = 24;
    47   RoundPixels: array [0 .. nStat - 1] of integer = (0, 0, 0, 5, 5, 5);
     47  RoundPixels: array [0 .. nStat - 1] of Integer = (0, 0, 0, 5, 5, 5);
    4848
    4949  yArea = 48;
    50   xComp: array [0 .. 5] of integer = (-60, -28, 4, 4, 36, 68);
    51   yComp: array [0 .. 5] of integer = (-40, -40, -79, -1, -40, -40);
    52   xPow: array [0 .. 3] of integer = (-116, -116, -116, -116);
    53   yPow: array [0 .. 3] of integer = (-28, 0, -44, 16);
    54   xHab: array [0 .. 1] of integer = (23, 23);
    55   yHab: array [0 .. 1] of integer = (-81, 1);
    56 
    57 procedure PaintColonyShip(canvas: TCanvas; Player, Left, Width, Top: integer);
    58 var
    59   i, x, r, nComp, nPow, nHab: integer;
     50  xComp: array [0 .. 5] of Integer = (-60, -28, 4, 4, 36, 68);
     51  yComp: array [0 .. 5] of Integer = (-40, -40, -79, -1, -40, -40);
     52  xPow: array [0 .. 3] of Integer = (-116, -116, -116, -116);
     53  yPow: array [0 .. 3] of Integer = (-28, 0, -44, 16);
     54  xHab: array [0 .. 1] of Integer = (23, 23);
     55  yHab: array [0 .. 1] of Integer = (-81, 1);
     56
     57procedure PaintColonyShip(Canvas: TCanvas; Player, Left, Width, Top: Integer);
     58var
     59  I, X, R, nComp, nPow, nHab: Integer;
    6060begin
    6161  Canvas.Brush.Color := $000000;
    6262  Canvas.FillRect(Rect(Left, Top, Left + Width, Top + 200));
    6363  Canvas.Brush.Style := bsClear;
    64     ScreenTools.Frame(canvas, Left - 1, Top - 1, Left + Width, Top + 200,
     64    ScreenTools.Frame(Canvas, Left - 1, Top - 1, Left + Width, Top + 200,
    6565      MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
    66     RFrame(canvas, Left - 2, Top - 2, Left + Width + 1, Top + 200 + 1,
     66    RFrame(Canvas, Left - 2, Top - 2, Left + Width + 1, Top + 200 + 1,
    6767      MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
    6868
    6969    // stars
    7070    DelphiRandSeed := Player * 11111;
    71     for i := 1 to Width - 16 do
     71    for I := 1 to Width - 16 do
    7272    begin
    73       x := DelphiRandom((Width - 16) * 200);
    74       r := DelphiRandom(13) + 28;
    75       Canvas.Pixels[x div 200 + 8, x mod 200 + Top] :=
    76         (r * r * r * r div 10001) * $10101;
     73      X := DelphiRandom((Width - 16) * 200);
     74      R := DelphiRandom(13) + 28;
     75      Canvas.Pixels[X div 200 + 8, X mod 200 + Top] :=
     76        (R * R * R * R div 10001) * $10101;
    7777    end;
    7878
     
    8686    if nHab > 2 then
    8787      nHab := 2;
    88     for i := 0 to nHab - 1 do
    89       Sprite(canvas, HGrSystem2, Left + Width div 2 + xHab[i],
    90         Top + 100 + yHab[i], 80, 80, 34, 1);
    91     for i := 0 to nComp - 1 do
    92       Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[i],
    93         Top + 100 + yComp[i], 32, 80, 1, 1);
     88    for I := 0 to nHab - 1 do
     89      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xHab[I],
     90        Top + 100 + yHab[I], 80, 80, 34, 1);
     91    for I := 0 to nComp - 1 do
     92      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[I],
     93        Top + 100 + yComp[I], 32, 80, 1, 1);
    9494    if nComp > 0 then
    95       for i := 3 downto nPow do
    96         Sprite(canvas, HGrSystem2, Left + Width div 2 + xPow[i] + 40,
    97           Top + 100 + yPow[i], 16, 27, 1, 82);
    98     for i := nPow - 1 downto 0 do
    99       Sprite(canvas, HGrSystem2, Left + Width div 2 + xPow[i],
    100         Top + 100 + yPow[i], 56, 28, 58, 82);
     95      for I := 3 downto nPow do
     96        Sprite(Canvas, HGrSystem2, Left + Width div 2 + xPow[I] + 40,
     97          Top + 100 + yPow[I], 16, 27, 1, 82);
     98    for I := nPow - 1 downto 0 do
     99      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xPow[I],
     100        Top + 100 + yPow[I], 56, 28, 58, 82);
    101101    if (nComp < 3) and (nHab >= 1) then
    102       Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[2] + 32 - 16,
     102      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[2] + 32 - 16,
    103103        Top + 100 + 7 + yComp[2], 16, 27, 1, 82);
    104104    if (nComp >= 3) and (nHab < 1) then
    105       Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[2] + 32,
     105      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[2] + 32,
    106106        Top + 100 + 7 + yComp[2], 16, 27, 18, 82);
    107107    if (nComp < 4) and (nHab >= 2) then
    108       Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[3] + 32 - 16,
     108      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[3] + 32 - 16,
    109109        Top + 100 + 46 + yComp[3], 16, 27, 1, 82);
    110110    if (nComp >= 4) and (nHab < 2) then
    111       Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[3] + 32,
     111      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[3] + 32,
    112112        Top + 100 + 46 + yComp[3], 16, 27, 18, 82);
    113113    if (nComp <> 6) and (nComp <> 2) and not((nComp = 0) and (nPow < 1)) then
    114       Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[nComp],
     114      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[nComp],
    115115        Top + 100 + 7 + yComp[nComp], 16, 27, 18, 82);
    116116    if (nComp <> 6) and (nComp <> 3) and not((nComp = 0) and (nPow < 2)) then
    117       Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[nComp],
     117      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[nComp],
    118118        Top + 100 + 46 + yComp[nComp], 16, 27, 18, 82);
    119119    if nComp = 2 then
    120       Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[3],
     120      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[3],
    121121        Top + 100 + 7 + yComp[3], 16, 27, 18, 82);
    122122    if nComp = 3 then
    123       Sprite(canvas, HGrSystem2, Left + Width div 2 + xComp[4],
     123      Sprite(Canvas, HGrSystem2, Left + Width div 2 + xComp[4],
    124124        Top + 100 + 7 + yComp[4], 16, 27, 18, 82);
    125125end;
     
    142142procedure TDiaDlg.OffscreenPaint;
    143143var
    144   p, T, max, x, y, y0, Stop, r, RoundRange, LineStep: integer;
    145   s: string;
     144  P, T, Max, X, Y, y0, Stop, R, RoundRange, LineStep: Integer;
     145  S: string;
    146146  List: ^TChart;
    147147
    148   function Round(T: integer): integer;
     148  function Round(T: Integer): Integer;
    149149  var
    150     n, i: integer;
     150    N, I: Integer;
    151151  begin
    152152    if T < RoundRange then
    153       n := T
     153      N := T
    154154    else
    155       n := RoundRange;
    156     result := 0;
    157     for i := T - n to T do
    158       inc(result, List[i]);
    159     result := result div (n + 1);
    160   end;
    161 
    162   procedure ShareBar(x, y: integer; Cap: string; val0, val1: integer);
    163   begin
    164     LoweredTextOut(offscreen.canvas, -1, MainTexture, x - 2, y, Cap);
    165     DLine(offscreen.canvas, x - 2, x + 169, y + 16, MainTexture.ColorTextShade,
     155      N := RoundRange;
     156    Result := 0;
     157    for I := T - N to T do
     158      Inc(Result, List[I]);
     159    Result := Result div (N + 1);
     160  end;
     161
     162  procedure ShareBar(X, Y: Integer; Cap: string; val0, val1: Integer);
     163  begin
     164    LoweredTextOut(Offscreen.Canvas, -1, MainTexture, X - 2, Y, Cap);
     165    DLine(Offscreen.Canvas, X - 2, X + 169, Y + 16, MainTexture.ColorTextShade,
    166166      MainTexture.ColorTextLight);
    167167    if val0 > 0 then
    168       s := Format(Phrases.Lookup('SHARE'), [val0, val1])
     168      S := Format(Phrases.Lookup('SHARE'), [val0, val1])
    169169    else
    170       s := '0';
    171     RisedTextOut(offscreen.canvas,
    172       x + 170 - BiColorTextWidth(offscreen.canvas, s), y, s);
     170      S := '0';
     171    RisedTextOut(Offscreen.Canvas,
     172      X + 170 - BiColorTextWidth(Offscreen.Canvas, S), Y, S);
    173173  end;
    174174
     
    176176  inherited;
    177177  if Kind = dkChart then
    178     with offscreen.canvas do
     178    with Offscreen.Canvas do
    179179    begin
    180180      Font.Assign(UniFont[ftTiny]);
     
    186186      GetMem(List, 4 * (MyRO.Turn + 2));
    187187      if Mode = stExplore then
    188         max := G.lx * G.ly
     188        Max := G.lx * G.ly
    189189      else
    190190      begin
    191         max := -1;
    192         for p := 0 to nPl - 1 do
    193           if (G.Difficulty[p] > 0) and
    194             (Server(sGetChart + Mode shl 4, me, p, List^) >= rExecuted) then
     191        Max := -1;
     192        for P := 0 to nPl - 1 do
     193          if (G.Difficulty[P] > 0) and
     194            (Server(sGetChart + Mode shl 4, Me, P, List^) >= rExecuted) then
    195195            for T := 0 to MyRO.Turn - 1 do
    196196            begin
    197               r := Round(T);
    198               if r > max then
    199                 max := r;
     197              R := Round(T);
     198              if R > Max then
     199                Max := R;
    200200            end;
    201201      end;
     
    215215      for T := 0 to (MyRO.Turn - 1) div LineStep do
    216216      begin
    217         x := Border + (InnerWidth - 2 * Border) * T *
     217        X := Border + (InnerWidth - 2 * Border) * T *
    218218          LineStep div (MyRO.Turn - 1);
    219         MoveTo(x, Border);
    220         LineTo(x, InnerHeight - Border);
    221         s := IntToStr(abs(TurnToYear(T * LineStep)));
    222         Textout(x - TextWidth(s) div 2, Border - 16, s);
     219        MoveTo(X, Border);
     220        LineTo(X, InnerHeight - Border);
     221        S := IntToStr(abs(TurnToYear(T * LineStep)));
     222        Textout(X - TextWidth(S) div 2, Border - 16, S);
    223223      end;
    224224
    225225      y0 := 0;
    226       if max > 0 then
     226      if Max > 0 then
    227227      begin
    228         for p := 0 to nPl - 1 do
    229           if (G.Difficulty[p] > 0) and
    230             (Server(sGetChart + Mode shl 4, me, p, List^) >= rExecuted) then
     228        for P := 0 to nPl - 1 do
     229          if (G.Difficulty[P] > 0) and
     230            (Server(sGetChart + Mode shl 4, Me, P, List^) >= rExecuted) then
    231231          begin
    232             Pen.Color := Tribe[p].Color;
     232            Pen.Color := Tribe[P].Color;
    233233            Stop := MyRO.Turn - 1;
    234234            while (Stop > 0) and (List[Stop] = 0) do
    235               dec(Stop);
     235              Dec(Stop);
    236236            for T := 0 to Stop do
    237237            begin
    238               r := Round(T);
    239               x := Border + (InnerWidth - 2 * Border) * T div (MyRO.Turn - 1);
    240               y := InnerHeight - Border - (InnerHeight - 2 * Border) *
    241                 r div max;
     238              R := Round(T);
     239              X := Border + (InnerWidth - 2 * Border) * T div (MyRO.Turn - 1);
     240              Y := InnerHeight - Border - (InnerHeight - 2 * Border) *
     241                R div Max;
    242242              if T = 0 then
    243                 MoveTo(x, y)
     243                MoveTo(X, Y)
    244244                // else if Mode=stTerritory then
    245245                // begin LineTo(x,y0); LineTo(x,y) end
    246246              else if RoundPixels[Mode] = 0 then
    247247              begin
    248                 if (y <> y0) or (T = Stop) then
    249                   LineTo(x, y)
     248                if (Y <> y0) or (T = Stop) then
     249                  LineTo(X, Y)
    250250              end
    251251              else
    252                 LineTo(x, y);
    253               y0 := y;
     252                LineTo(X, Y);
     253              y0 := Y;
    254254            end;
    255255          end;
     
    258258    end
    259259  else
    260     with offscreen.canvas do
     260    with Offscreen.Canvas do
    261261    begin
    262262      Font.Assign(UniFont[ftSmall]);
    263263      FillOffscreen(0, 0, InnerWidth, InnerHeight);
    264264
    265       PaintColonyShip(offscreen.canvas, Player, 8, InnerWidth - 16, yArea);
     265      PaintColonyShip(Offscreen.Canvas, Player, 8, InnerWidth - 16, yArea);
    266266
    267267      ShareBar(InnerWidth div 2 - 85, InnerHeight - 62,
     
    277277procedure TDiaDlg.FormPaint(Sender: TObject);
    278278var
    279   s: string;
     279  S: string;
    280280begin
    281281  inherited;
    282   canvas.Font.Assign(UniFont[ftNormal]);
     282  Canvas.Font.Assign(UniFont[ftNormal]);
    283283  if Kind = dkChart then
    284     s := Phrases.Lookup('DIAGRAM', Mode)
    285   else
    286     s := Tribe[Player].TPhrase('SHORTNAME');
    287   LoweredTextOut(canvas, -1, MainTexture,
    288     (ClientWidth - BiColorTextWidth(canvas, s)) div 2, 31, s);
     284    S := Phrases.Lookup('DIAGRAM', Mode)
     285  else
     286    S := Tribe[Player].TPhrase('SHORTNAME');
     287  LoweredTextOut(Canvas, -1, MainTexture,
     288    (ClientWidth - BiColorTextWidth(Canvas, S)) div 2, 31, S);
    289289end;
    290290
     
    309309end;
    310310
    311 procedure TDiaDlg.ShowNewContent_Ship(NewMode: TWindowMode; p: integer);
     311procedure TDiaDlg.ShowNewContent_Ship(NewMode: TWindowMode; P: Integer);
    312312begin
    313313  Kind := dkShip;
    314   if p < 0 then
    315   begin
    316     Player := me;
     314  if P < 0 then
     315  begin
     316    Player := Me;
    317317    while MyRO.Ship[Player].Parts[spComp] + MyRO.Ship[Player].Parts[spPow] +
    318318      MyRO.Ship[Player].Parts[spHab] = 0 do
     
    320320  end
    321321  else
    322     Player := p;
     322    Player := P;
    323323  ToggleBtn.ButtonIndex := 28;
    324324  ToggleBtn.Hint := Phrases.Lookup('BTN_SELECT');
     
    329329procedure TDiaDlg.ToggleBtnClick(Sender: TObject);
    330330var
    331   p1: integer;
    332   m: TMenuItem;
     331  p1: Integer;
     332  M: TMenuItem;
    333333begin
    334334  if Kind = dkChart then
     
    345345        MyRO.Ship[p1].Parts[spHab] > 0 then
    346346      begin
    347         m := TMenuItem.Create(Popup);
    348         m.RadioItem := true;
    349         m.Caption := Tribe[p1].TPhrase('SHORTNAME');
    350         m.Tag := p1;
    351         m.OnClick := PlayerClick;
     347        M := TMenuItem.Create(Popup);
     348        M.RadioItem := True;
     349        M.Caption := Tribe[p1].TPhrase('SHORTNAME');
     350        M.Tag := p1;
     351        M.OnClick := PlayerClick;
    352352        if p1 = Player then
    353           m.Checked := true;
    354         Popup.Items.Add(m);
     353          M.Checked := True;
     354        Popup.Items.Add(M);
    355355      end;
    356356    Popup.Popup(Left + ToggleBtn.Left, Top + ToggleBtn.Top + ToggleBtn.Height);
     
    363363end;
    364364
    365 procedure TDiaDlg.FormKeyDown(Sender: TObject; var Key: word;
     365procedure TDiaDlg.FormKeyDown(Sender: TObject; var Key: Word;
    366366  Shift: TShiftState);
    367367begin
Note: See TracChangeset for help on using the changeset viewer.