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

    r442 r447  
    2020    procedure CloseBtnClick(Sender: TObject);
    2121    procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
    22       Shift: TShiftState; x, y: integer);
     22      Shift: TShiftState; X, Y: Integer);
    2323    procedure OKBtnClick(Sender: TObject);
    2424    procedure PaintBox1MouseUp(Sender: TObject; Button: TMouseButton;
    25       Shift: TShiftState; x, y: integer);
     25      Shift: TShiftState; X, Y: Integer);
    2626  public
    2727    procedure ShowNewContent(NewMode: TWindowMode);
     
    3030  private
    3131    Domain, MaxLines, Lines, Cut, yDomain, yFeature, yWeight, yTotal, yView,
    32       IncCap, DecCap: integer;
    33     code: array [0 .. nFeature - 1] of integer;
     32      IncCap, DecCap: Integer;
     33    Code: array [0 .. nFeature - 1] of Integer;
    3434    Template, Back: TBitmap;
    35     function IsFeatureInList(d, i: integer): boolean;
    36     procedure SetDomain(d: integer);
     35    function IsFeatureInList(D, I: Integer): Boolean;
     36    procedure SetDomain(D: Integer);
    3737  end;
    3838
     
    108108procedure TDraftDlg.OffscreenPaint;
    109109
    110   function DomainAvailable(d: integer): boolean;
    111   begin
    112     result := (upgrade[d, 0].Preq = preNone) or
    113       (MyRO.Tech[upgrade[d, 0].Preq] >= tsApplicable);
     110  function DomainAvailable(D: Integer): Boolean;
     111  begin
     112    Result := (upgrade[D, 0].Preq = preNone) or
     113      (MyRO.Tech[upgrade[D, 0].Preq] >= tsApplicable);
    114114  end;
    115115
    116116  procedure PaintTotalBars;
    117117  var
    118     i, y, dx, num, w: integer;
    119     s: string;
    120   begin
    121     with offscreen.Canvas do
     118    I, Y, dx, num, W: Integer;
     119    S: string;
     120  begin
     121    with Offscreen.Canvas do
    122122    begin
    123123      // strength bar
    124       y := yTotal;
    125       DarkGradient(offscreen.Canvas, xTotal - 6, y + 1, 184, 2);
    126       DarkGradient(offscreen.Canvas, xTotal2 + 172, y + 1, 95, 2);
    127       RisedTextOut(offscreen.Canvas, xTotal - 2, y,
     124      Y := yTotal;
     125      DarkGradient(Offscreen.Canvas, xTotal - 6, Y + 1, 184, 2);
     126      DarkGradient(Offscreen.Canvas, xTotal2 + 172, Y + 1, 95, 2);
     127      RisedTextOut(Offscreen.Canvas, xTotal - 2, Y,
    128128        Phrases.Lookup('UNITSTRENGTH'));
    129       RisedTextOut(offscreen.Canvas, xTotal + 112 + 30, y,
     129      RisedTextOut(Offscreen.Canvas, xTotal + 112 + 30, Y,
    130130        'x' + IntToStr(MyRO.DevModel.MStrength));
    131       RisedTextOut(offscreen.Canvas, xTotal2 + 148 + 30, y, '=');
    132       s := IntToStr(MyRO.DevModel.Attack) + '/' +
     131      RisedTextOut(Offscreen.Canvas, xTotal2 + 148 + 30, Y, '=');
     132      S := IntToStr(MyRO.DevModel.Attack) + '/' +
    133133        IntToStr(MyRO.DevModel.Defense);
    134       RisedTextOut(offscreen.Canvas, xTotal2 + 170 + 64 + 30 -
    135         BiColorTextWidth(offscreen.Canvas, s), y, s);
     134      RisedTextOut(Offscreen.Canvas, xTotal2 + 170 + 64 + 30 -
     135        BiColorTextWidth(Offscreen.Canvas, S), Y, S);
    136136
    137137      // transport bar
    138138      if MyRO.DevModel.MTrans > 0 then
    139139      begin
    140         y := yTotal + 19;
    141         DarkGradient(offscreen.Canvas, xTotal - 6, y + 1, 184, 1);
    142         DarkGradient(offscreen.Canvas, xTotal2 + 172, y + 1, 95, 1);
    143         RisedTextOut(offscreen.Canvas, xTotal - 2, y,
     140        Y := yTotal + 19;
     141        DarkGradient(Offscreen.Canvas, xTotal - 6, Y + 1, 184, 1);
     142        DarkGradient(Offscreen.Canvas, xTotal2 + 172, Y + 1, 95, 1);
     143        RisedTextOut(Offscreen.Canvas, xTotal - 2, Y,
    144144          Phrases.Lookup('UNITTRANSPORT'));
    145         RisedTextOut(offscreen.Canvas, xTotal + 112 + 30, y,
     145        RisedTextOut(Offscreen.Canvas, xTotal + 112 + 30, Y,
    146146          'x' + IntToStr(MyRO.DevModel.MTrans));
    147         RisedTextOut(offscreen.Canvas, xTotal2 + 148 + 30, y, '=');
     147        RisedTextOut(Offscreen.Canvas, xTotal2 + 148 + 30, Y, '=');
    148148
    149149        Font.Color := $000000;
    150150        dx := -237 - 30;
    151         for i := mcFirstNonCap - 1 downto 3 do
    152           if i in [mcSeaTrans, mcCarrier, mcAirTrans] then
     151        for I := mcFirstNonCap - 1 downto 3 do
     152          if I in [mcSeaTrans, mcCarrier, mcAirTrans] then
    153153          begin
    154             num := MyRO.DevModel.Cap[i] * MyRO.DevModel.MTrans;
     154            num := MyRO.DevModel.Cap[I] * MyRO.DevModel.MTrans;
    155155            if num > 0 then
    156156            begin
    157               inc(dx, 15);
     157              Inc(dx, 15);
    158158              Brush.Color := $C0C0C0;
    159               FrameRect(Rect(xTotal2 - 3 - dx, y + 2,
    160                 xTotal2 + 11 - dx, y + 16));
     159              FrameRect(Rect(xTotal2 - 3 - dx, Y + 2,
     160                xTotal2 + 11 - dx, Y + 16));
    161161              Brush.Style := bsClear;
    162               Sprite(offscreen, HGrSystem, xTotal2 - 1 - dx, y + 4, 10, 10,
    163                 66 + i mod 11 * 11, 137 + i div 11 * 11);
     162              Sprite(Offscreen, HGrSystem, xTotal2 - 1 - dx, Y + 4, 10, 10,
     163                66 + I mod 11 * 11, 137 + I div 11 * 11);
    164164              if num > 1 then
    165165              begin
    166                 s := IntToStr(num);
    167                 w := TextWidth(s);
    168                 inc(dx, w + 1);
     166                S := IntToStr(num);
     167                W := TextWidth(S);
     168                Inc(dx, W + 1);
    169169                Brush.Color := $FFFFFF;
    170                 FillRect(Rect(xTotal2 - 3 - dx, y + 2,
    171                   xTotal2 + w - 1 - dx, y + 16));
     170                FillRect(Rect(xTotal2 - 3 - dx, Y + 2,
     171                  xTotal2 + W - 1 - dx, Y + 16));
    172172                Brush.Style := bsClear;
    173                 Textout(xTotal2 - 3 - dx + 1, y, s);
     173                Textout(xTotal2 - 3 - dx + 1, Y, S);
    174174              end;
    175175            end;
     
    178178
    179179      // speed bar
    180       y := yTotal + 38;
    181       LoweredTextOut(offscreen.Canvas, -1, MainTexture, xTotal - 2, y,
     180      Y := yTotal + 38;
     181      LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2, Y,
    182182        Phrases.Lookup('UNITSPEED'));
    183       DLine(offscreen.Canvas, xTotal - 2, xTotal + 174, y + 16,
     183      DLine(Offscreen.Canvas, xTotal - 2, xTotal + 174, Y + 16,
    184184        MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
    185       DLine(offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, y + 16,
     185      DLine(Offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, Y + 16,
    186186        MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
    187       s := MovementToString(MyRO.DevModel.Speed);
    188       RisedTextOut(offscreen.Canvas, xTotal2 + 170 + 64 + 30 -
    189         TextWidth(s), y, s);
     187      S := MovementToString(MyRO.DevModel.Speed);
     188      RisedTextOut(Offscreen.Canvas, xTotal2 + 170 + 64 + 30 -
     189        TextWidth(S), Y, S);
    190190
    191191      // cost bar
    192       y := yTotal + 57;
    193       LoweredTextOut(offscreen.Canvas, -1, MainTexture, xTotal - 2, y,
     192      Y := yTotal + 57;
     193      LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2, Y,
    194194        Phrases.Lookup('UNITCOST'));
    195       LoweredTextOut(offscreen.Canvas, -1, MainTexture, xTotal + 112 + 30, y,
     195      LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal + 112 + 30, Y,
    196196        'x' + IntToStr(MyRO.DevModel.MCost));
    197       LoweredTextOut(offscreen.Canvas, -1, MainTexture,
    198         xTotal2 + 148 + 30, y, '=');
    199       DLine(offscreen.Canvas, xTotal - 2, xTotal + 174, y + 16,
     197      LoweredTextOut(Offscreen.Canvas, -1, MainTexture,
     198        xTotal2 + 148 + 30, Y, '=');
     199      DLine(Offscreen.Canvas, xTotal - 2, xTotal + 174, Y + 16,
    200200        MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
    201       DLine(offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, y + 16,
     201      DLine(Offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, Y + 16,
    202202        MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
    203       s := IntToStr(MyRO.DevModel.Cost);
    204       RisedTextOut(offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 12 -
    205         TextWidth(s), y, s);
    206       Sprite(offscreen, HGrSystem, xTotal2 + 170 + 54 + 30, y + 4, 10,
     203      S := IntToStr(MyRO.DevModel.Cost);
     204      RisedTextOut(Offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 12 -
     205        TextWidth(S), Y, S);
     206      Sprite(Offscreen, HGrSystem, xTotal2 + 170 + 54 + 30, Y + 4, 10,
    207207        10, 88, 115);
    208208
    209       if G.Difficulty[me] <> 2 then
     209      if G.Difficulty[Me] <> 2 then
    210210      begin // corrected cost bar
    211         y := yTotal + 76;
    212         LoweredTextOut(offscreen.Canvas, -1, MainTexture, xTotal - 2, y,
    213           Phrases.Lookup('COSTDIFF' + char(48 + G.Difficulty[me])));
    214         LoweredTextOut(offscreen.Canvas, -1, MainTexture,
    215           xTotal2 + 148 + 30, y, '=');
    216         DLine(offscreen.Canvas, xTotal - 2, xTotal + 174, y + 16,
     211        Y := yTotal + 76;
     212        LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xTotal - 2, Y,
     213          Phrases.Lookup('COSTDIFF' + char(48 + G.Difficulty[Me])));
     214        LoweredTextOut(Offscreen.Canvas, -1, MainTexture,
     215          xTotal2 + 148 + 30, Y, '=');
     216        DLine(Offscreen.Canvas, xTotal - 2, xTotal + 174, Y + 16,
    217217          MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
    218         DLine(offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, y + 16,
     218        DLine(Offscreen.Canvas, xTotal2 + 176, xTotal2 + 263, Y + 16,
    219219          MainTexture.ColorBevelShade, MainTexture.ColorBevelLight);
    220         s := IntToStr(MyRO.DevModel.Cost * BuildCostMod
    221           [G.Difficulty[me]] div 12);
    222         RisedTextOut(offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 12 -
    223           TextWidth(s), y, s);
    224         Sprite(offscreen, HGrSystem, xTotal2 + 170 + 54 + 30, y + 4, 10,
     220        S := IntToStr(MyRO.DevModel.Cost * BuildCostMod
     221          [G.Difficulty[Me]] div 12);
     222        RisedTextOut(Offscreen.Canvas, xTotal2 + 170 + 64 + 30 - 12 -
     223          TextWidth(S), Y, S);
     224        Sprite(Offscreen, HGrSystem, xTotal2 + 170 + 54 + 30, Y + 4, 10,
    225225          10, 88, 115);
    226226      end;
     
    229229
    230230var
    231   i, j, x, d, n, TextColor, CapWeight, DomainCount: integer;
     231  I, J, X, D, N, TextColor, CapWeight, DomainCount: Integer;
    232232begin
    233233  inherited;
     
    253253    Template.Height - 64 - Cut);
    254254
    255   BitBltCanvas(offscreen.Canvas, 0, 0, ClientWidth, ClientHeight,
     255  BitBltCanvas(Offscreen.Canvas, 0, 0, ClientWidth, ClientHeight,
    256256    Back.Canvas, 0, 0);
    257257
    258   offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
    259   RisedTextOut(offscreen.Canvas, 10, 7, Caption);
    260   offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
     258  Offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
     259  RisedTextOut(Offscreen.Canvas, 10, 7, Caption);
     260  Offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
    261261
    262262  with MyRO.DevModel do
    263263  begin
    264264    DomainCount := 0;
    265     for d := 0 to nDomains - 1 do
    266       if DomainAvailable(d) then
    267         inc(DomainCount);
     265    for D := 0 to nDomains - 1 do
     266      if DomainAvailable(D) then
     267        Inc(DomainCount);
    268268    if DomainCount > 1 then
    269269    begin
    270       for d := 0 to nDomains - 1 do
    271         if DomainAvailable(d) then
     270      for D := 0 to nDomains - 1 do
     271        if DomainAvailable(D) then
    272272        begin
    273           x := xDomain + d * DomainPitch;
    274           if d = Domain then
    275             ImageOp_BCC(offscreen, Templates.Data, x, yDomain, 142, 246 + 37 * d, 36,
     273          X := xDomain + D * DomainPitch;
     274          if D = Domain then
     275            ImageOp_BCC(Offscreen, Templates.Data, X, yDomain, 142, 246 + 37 * D, 36,
    276276              36, 0, $00C0FF)
    277277          else
    278             ImageOp_BCC(offscreen, Templates.Data, x, yDomain, 142, 246 + 37 * d, 36,
     278            ImageOp_BCC(Offscreen, Templates.Data, X, yDomain, 142, 246 + 37 * D, 36,
    279279              36, 0, $606060);
    280280        end;
    281       Frame(offscreen.Canvas, xDomain - 11, yDomain - 3,
     281      Frame(Offscreen.Canvas, xDomain - 11, yDomain - 3,
    282282        xDomain + 2 * DomainPitch + 46, yDomain + 38, $B0B0B0, $FFFFFF);
    283       RFrame(offscreen.Canvas, xDomain - 12, yDomain - 4,
     283      RFrame(Offscreen.Canvas, xDomain - 12, yDomain - 4,
    284284        xDomain + 2 * DomainPitch + 47, yDomain + 39, $FFFFFF, $B0B0B0);
    285285    end;
     
    294294
    295295    // display weight
    296     with offscreen.Canvas do
    297     begin
    298       for i := 0 to MaxWeight - 1 do
    299         if i < Weight then
    300           ImageOp_BCC(offscreen, Templates.Data, Point(xWeight + 20 * i, yWeight),
     296    with Offscreen.Canvas do
     297    begin
     298      for I := 0 to MaxWeight - 1 do
     299        if I < Weight then
     300          ImageOp_BCC(Offscreen, Templates.Data, Point(xWeight + 20 * I, yWeight),
    301301            WeightOn.BoundsRect, 0, $949494)
    302302        else
    303           ImageOp_BCC(offscreen, Templates.Data, Point(xWeight + 20 * i, yWeight),
     303          ImageOp_BCC(Offscreen, Templates.Data, Point(xWeight + 20 * I, yWeight),
    304304            WeightOff.BoundsRect, 0, $949494);
    305305    end;
    306306
    307     with offscreen.Canvas do
    308       for i := 0 to Lines - 1 do
     307    with Offscreen.Canvas do
     308      for I := 0 to Lines - 1 do
    309309      begin
    310         if not(code[i] in AutoFeature) then
     310        if not(Code[I] in AutoFeature) then
    311311        begin
    312312          // paint +/- butttons
    313           if code[i] < mcFirstNonCap then
     313          if Code[I] < mcFirstNonCap then
    314314          begin
    315             Dump(offscreen, HGrSystem, xFeature - 21, yFeature + 2 + LinePitch *
    316               i, 12, 12, 169, 172);
    317             Dump(offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *
    318               i, 12, 12, 169, 159);
    319             RFrame(offscreen.Canvas, xFeature - (21 + 1),
    320               yFeature + 2 + LinePitch * i - 1, xFeature - (21 - 24),
    321               yFeature + 2 + LinePitch * i + 12, MainTexture.ColorBevelShade,
     315            Dump(Offscreen, HGrSystem, xFeature - 21, yFeature + 2 + LinePitch *
     316              I, 12, 12, 169, 172);
     317            Dump(Offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *
     318              I, 12, 12, 169, 159);
     319            RFrame(Offscreen.Canvas, xFeature - (21 + 1),
     320              yFeature + 2 + LinePitch * I - 1, xFeature - (21 - 24),
     321              yFeature + 2 + LinePitch * I + 12, MainTexture.ColorBevelShade,
    322322              MainTexture.ColorBevelLight);
    323323          end
    324324          else
    325325          begin
    326             Dump(offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *
    327               i, 12, 12, 169, 185 + 13 * MyRO.DevModel.Cap[code[i]]);
    328             RFrame(offscreen.Canvas, xFeature - (9 + 1),
    329               yFeature + 2 + LinePitch * i - 1, xFeature - (21 - 24),
    330               yFeature + 2 + LinePitch * i + 12, MainTexture.ColorBevelShade,
     326            Dump(Offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *
     327              I, 12, 12, 169, 185 + 13 * MyRO.DevModel.Cap[Code[I]]);
     328            RFrame(Offscreen.Canvas, xFeature - (9 + 1),
     329              yFeature + 2 + LinePitch * I - 1, xFeature - (21 - 24),
     330              yFeature + 2 + LinePitch * I + 12, MainTexture.ColorBevelShade,
    331331              MainTexture.ColorBevelLight);
    332332          end;
    333333
    334334          // paint cost
    335           LightGradient(offscreen.Canvas, xFeature + 34,
    336             yFeature + LinePitch * i, 50, HGrSystem.Data.Canvas.Pixels
     335          LightGradient(Offscreen.Canvas, xFeature + 34,
     336            yFeature + LinePitch * I, 50, HGrSystem.Data.Canvas.Pixels
    337337            [187, 137]);
    338           if (Domain = dGround) and (code[i] = mcDefense) then
     338          if (Domain = dGround) and (Code[I] = mcDefense) then
    339339            CapWeight := 2
    340340          else
    341             CapWeight := Feature[code[i]].Weight;
    342           n := CapWeight + Feature[code[i]].Cost;
    343           d := 6;
    344           while (n - 1) * d * 2 > 48 - 10 do
    345             dec(d);
    346           for j := 0 to n - 1 do
    347             if j < CapWeight then
    348               Sprite(offscreen, HGrSystem, xFeature + 54 + (j * 2 + 1 - n) * d,
    349                 yFeature + 2 + LinePitch * i + 1, 10, 10, 88, 126)
     341            CapWeight := Feature[Code[I]].Weight;
     342          N := CapWeight + Feature[Code[I]].Cost;
     343          D := 6;
     344          while (N - 1) * D * 2 > 48 - 10 do
     345            Dec(D);
     346          for J := 0 to N - 1 do
     347            if J < CapWeight then
     348              Sprite(Offscreen, HGrSystem, xFeature + 54 + (J * 2 + 1 - N) * D,
     349                yFeature + 2 + LinePitch * I + 1, 10, 10, 88, 126)
    350350            else
    351               Sprite(offscreen, HGrSystem, xFeature + 54 + (j * 2 + 1 - n) * d,
    352                 yFeature + 2 + LinePitch * i + 1, 10, 10, 88, 115);
     351              Sprite(Offscreen, HGrSystem, xFeature + 54 + (J * 2 + 1 - N) * D,
     352                yFeature + 2 + LinePitch * I + 1, 10, 10, 88, 115);
    353353        end; // if not (code[i] in AutoFeature)
    354         DarkGradient(offscreen.Canvas, xFeature + 17,
    355           yFeature + LinePitch * i, 16, 1);
    356         ScreenTools.Frame(offscreen.Canvas, xFeature + 18, yFeature + 1 + LinePitch * i,
    357           xFeature + 20 - 2 + 13, yFeature + 2 + 1 - 2 + 13 + LinePitch * i,
     354        DarkGradient(Offscreen.Canvas, xFeature + 17,
     355          yFeature + LinePitch * I, 16, 1);
     356        ScreenTools.Frame(Offscreen.Canvas, xFeature + 18, yFeature + 1 + LinePitch * I,
     357          xFeature + 20 - 2 + 13, yFeature + 2 + 1 - 2 + 13 + LinePitch * I,
    358358          $C0C0C0, $C0C0C0);
    359         Sprite(offscreen, HGrSystem, xFeature + 20, yFeature + 2 + 1 + LinePitch
    360           * i, 10, 10, 66 + code[i] mod 11 * 11, 137 + code[i] div 11 * 11);
    361 
    362         if MyRO.DevModel.Cap[code[i]] > 0 then
     359        Sprite(Offscreen, HGrSystem, xFeature + 20, yFeature + 2 + 1 + LinePitch
     360          * I, 10, 10, 66 + Code[I] mod 11 * 11, 137 + Code[I] div 11 * 11);
     361
     362        if MyRO.DevModel.Cap[Code[I]] > 0 then
    363363          TextColor := MainTexture.ColorLitText
    364364        else
    365365          TextColor := -1;
    366366
    367         if code[i] < mcFirstNonCap then
    368           LoweredTextOut(offscreen.Canvas, TextColor, MainTexture, xFeature + 7,
    369             yFeature + LinePitch * i - 1, IntToStr(MyRO.DevModel.Cap[code[i]]));
    370         LoweredTextOut(offscreen.Canvas, TextColor, MainTexture, xFeature + 88,
    371           yFeature + LinePitch * i - 1, Phrases.Lookup('FEATURES', code[i]));
     367        if Code[I] < mcFirstNonCap then
     368          LoweredTextOut(Offscreen.Canvas, TextColor, MainTexture, xFeature + 7,
     369            yFeature + LinePitch * I - 1, IntToStr(MyRO.DevModel.Cap[Code[I]]));
     370        LoweredTextOut(Offscreen.Canvas, TextColor, MainTexture, xFeature + 88,
     371          yFeature + LinePitch * I - 1, Phrases.Lookup('FEATURES', Code[I]));
    372372      end;
    373373  end;
    374374
    375375  // free features
    376   j := 0;
    377   for i := 0 to nFeature - 1 do
    378     if (i in AutoFeature) and (1 shl Domain and Feature[i].Domains <> 0) and
    379       (Feature[i].Preq <> preNA) and
    380       ((Feature[i].Preq = preSun) and (MyRO.Wonder[woSun].EffectiveOwner = me)
    381       or (Feature[i].Preq >= 0) and (MyRO.Tech[Feature[i].Preq] >= tsApplicable)
    382       ) and not((Feature[i].Preq = adSteamEngine) and
     376  J := 0;
     377  for I := 0 to nFeature - 1 do
     378    if (I in AutoFeature) and (1 shl Domain and Feature[I].Domains <> 0) and
     379      (Feature[I].Preq <> preNA) and
     380      ((Feature[I].Preq = preSun) and (MyRO.Wonder[woSun].EffectiveOwner = Me)
     381      or (Feature[I].Preq >= 0) and (MyRO.Tech[Feature[I].Preq] >= tsApplicable)
     382      ) and not((Feature[I].Preq = adSteamEngine) and
    383383      (MyRO.Tech[adNuclearPower] >= tsApplicable)) then
    384384    begin
    385       DarkGradient(offscreen.Canvas, xWeight + 4, yWeight + 32 + LinePitch
    386         * j, 16, 1);
    387       Frame(offscreen.Canvas, xWeight + 5, yWeight + 33 + LinePitch * j,
    388         xWeight + 18, yWeight + 47 + LinePitch * j, $C0C0C0, $C0C0C0);
    389       Sprite(offscreen, HGrSystem, xWeight + 7, yWeight + 36 + LinePitch * j,
    390         10, 10, 66 + i mod 11 * 11, 137 + i div 11 * 11);
    391       LoweredTextOut(offscreen.Canvas, -1, MainTexture, xWeight + 26,
    392         yWeight + 31 + LinePitch * j, Phrases.Lookup('FEATURES', i));
    393       inc(j);
    394     end;
    395 
    396   with Tribe[me].ModelPicture[MyRO.nModel] do
    397   begin
    398     FrameImage(offscreen.Canvas, BigImp, xView + 4, yView + 4, xSizeBig,
     385      DarkGradient(Offscreen.Canvas, xWeight + 4, yWeight + 32 + LinePitch
     386        * J, 16, 1);
     387      Frame(Offscreen.Canvas, xWeight + 5, yWeight + 33 + LinePitch * J,
     388        xWeight + 18, yWeight + 47 + LinePitch * J, $C0C0C0, $C0C0C0);
     389      Sprite(Offscreen, HGrSystem, xWeight + 7, yWeight + 36 + LinePitch * J,
     390        10, 10, 66 + I mod 11 * 11, 137 + I div 11 * 11);
     391      LoweredTextOut(Offscreen.Canvas, -1, MainTexture, xWeight + 26,
     392        yWeight + 31 + LinePitch * J, Phrases.Lookup('FEATURES', I));
     393      Inc(J);
     394    end;
     395
     396  with Tribe[Me].ModelPicture[MyRO.nModel] do
     397  begin
     398    FrameImage(Offscreen.Canvas, BigImp, xView + 4, yView + 4, xSizeBig,
    399399      ySizeBig, 0, 0);
    400     Sprite(offscreen, HGr, xView, yView, 64, 44, pix mod 10 * 65 + 1,
     400    Sprite(Offscreen, HGr, xView, yView, 64, 44, pix mod 10 * 65 + 1,
    401401      pix div 10 * 49 + 1);
    402402  end;
     
    404404end;
    405405
    406 procedure TDraftDlg.SetDomain(d: integer);
    407 
    408   function Prio(fix: integer): integer;
     406procedure TDraftDlg.SetDomain(D: Integer);
     407
     408  function Prio(fix: Integer): Integer;
    409409  var
    410     FeaturePreq: integer;
     410    FeaturePreq: Integer;
    411411  begin
    412412    FeaturePreq := Feature[fix].Preq;
    413     assert(FeaturePreq <> preNA);
     413    Assert(FeaturePreq <> preNA);
    414414    if fix < mcFirstNonCap then
    415       result := 10000 + fix
     415      Result := 10000 + fix
    416416    else if FeaturePreq = preNone then
    417       result := 20000
     417      Result := 20000
    418418    else if FeaturePreq < 0 then
    419       result := 40000
     419      Result := 40000
    420420    else
    421       result := 30000 + AdvValue[FeaturePreq];
     421      Result := 30000 + AdvValue[FeaturePreq];
    422422    if not(fix in AutoFeature) then
    423       inc(result, 90000);
     423      Inc(Result, 90000);
    424424  end;
    425425
    426426var
    427   i, j, x: integer;
    428 begin
    429   Domain := d;
     427  I, J, X: Integer;
     428begin
     429  Domain := D;
    430430  Lines := 0;
    431   for i := 0 to nFeature - 1 do
    432     if IsFeatureInList(Domain, i) then
    433     begin
    434       code[Lines] := i;
    435       inc(Lines);
     431  for I := 0 to nFeature - 1 do
     432    if IsFeatureInList(Domain, I) then
     433    begin
     434      Code[Lines] := I;
     435      Inc(Lines);
    436436    end;
    437437  yFeature := yFeature0 + (MaxLines - Lines) * LinePitch div 2;
    438438
    439439  // sort features
    440   for i := 0 to Lines - 2 do
    441     for j := i + 1 to Lines - 1 do
    442       if Prio(code[i]) > Prio(code[j]) then
     440  for I := 0 to Lines - 2 do
     441    for J := I + 1 to Lines - 1 do
     442      if Prio(Code[I]) > Prio(Code[J]) then
    443443      begin // exchange
    444         x := code[i];
    445         code[i] := code[j];
    446         code[j] := x;
     444        X := Code[I];
     445        Code[I] := Code[J];
     446        Code[J] := X;
    447447      end;
    448448end;
    449449
    450 function TDraftDlg.IsFeatureInList(d, i: integer): boolean;
    451 begin
    452   result := not(i in AutoFeature) and (1 shl d and Feature[i].Domains <> 0) and
    453     (Feature[i].Preq <> preNA) and
    454     ((Feature[i].Preq = preNone) or (Feature[i].Preq = preSun) and
    455     (MyRO.Wonder[woSun].EffectiveOwner = me) or (Feature[i].Preq >= 0) and
    456     (MyRO.Tech[Feature[i].Preq] >= tsApplicable));
     450function TDraftDlg.IsFeatureInList(D, I: Integer): Boolean;
     451begin
     452  Result := not(I in AutoFeature) and (1 shl D and Feature[I].Domains <> 0) and
     453    (Feature[I].Preq <> preNA) and
     454    ((Feature[I].Preq = preNone) or (Feature[I].Preq = preSun) and
     455    (MyRO.Wonder[woSun].EffectiveOwner = Me) or (Feature[I].Preq >= 0) and
     456    (MyRO.Tech[Feature[I].Preq] >= tsApplicable));
    457457end;
    458458
    459459procedure TDraftDlg.FormShow(Sender: TObject);
    460460var
    461   count, d, i: integer;
     461  count, D, I: Integer;
    462462begin
    463463  Domain := dGround;
    464464  while (Domain < dAir) and (upgrade[Domain, 0].Preq <> preNone) and
    465465    (MyRO.Tech[upgrade[Domain, 0].Preq] < tsApplicable) do
    466     inc(Domain);
     466    Inc(Domain);
    467467
    468468  // count max number of features in any domain
    469469  MaxLines := 0;
    470   for d := 0 to nDomains - 1 do
    471     if (upgrade[d, 0].Preq = preNone) or
    472       (MyRO.Tech[upgrade[d, 0].Preq] >= tsApplicable) then
     470  for D := 0 to nDomains - 1 do
     471    if (upgrade[D, 0].Preq = preNone) or
     472      (MyRO.Tech[upgrade[D, 0].Preq] >= tsApplicable) then
    473473    begin
    474474      count := 0;
    475       for i := 0 to nFeature - 1 do
    476         if IsFeatureInList(d, i) then
    477           inc(count);
     475      for I := 0 to nFeature - 1 do
     476        if IsFeatureInList(D, I) then
     477          Inc(count);
    478478      if count > MaxLines then
    479479        MaxLines := count;
     
    493493
    494494  SetDomain(Domain);
    495   Server(sCreateDevModel, me, Domain, nil^);
     495  Server(sCreateDevModel, Me, Domain, nil^);
    496496  MyModel[MyRO.nModel] := MyRO.DevModel;
    497   InitMyModel(MyRO.nModel, false);
     497  InitMyModel(MyRO.nModel, False);
    498498  OffscreenPaint;
    499499  IncCap := -1;
     
    507507
    508508procedure TDraftDlg.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
    509   Shift: TShiftState; x, y: integer);
     509  Shift: TShiftState; X, Y: Integer);
    510510var
    511   i, d: integer;
     511  I, D: Integer;
    512512begin
    513513  if Button = mbLeft then
    514514  begin
    515     for d := 0 to nDomains - 1 do
    516       if (d <> Domain) and ((upgrade[d, 0].Preq = preNone) or
    517         (MyRO.Tech[upgrade[d, 0].Preq] >= tsApplicable)) and
    518         (x >= xDomain + d * DomainPitch) and
    519         (x < xDomain + d * DomainPitch + 36) and (y >= yDomain) and
    520         (y < yDomain + 36) then
     515    for D := 0 to nDomains - 1 do
     516      if (D <> Domain) and ((upgrade[D, 0].Preq = preNone) or
     517        (MyRO.Tech[upgrade[D, 0].Preq] >= tsApplicable)) and
     518        (X >= xDomain + D * DomainPitch) and
     519        (X < xDomain + D * DomainPitch + 36) and (Y >= yDomain) and
     520        (Y < yDomain + 36) then
    521521      begin
    522         SetDomain(d);
    523         Server(sCreateDevModel, me, Domain, nil^);
     522        SetDomain(D);
     523        Server(sCreateDevModel, Me, Domain, nil^);
    524524        MyModel[MyRO.nModel] := MyRO.DevModel;
    525         InitMyModel(MyRO.nModel, false);
     525        InitMyModel(MyRO.nModel, False);
    526526        SmartUpdateContent;
    527527      end;
    528528
    529     if (y >= yFeature) and (y < yFeature + LinePitch * Lines) then
    530     begin
    531       i := (y - yFeature) div LinePitch;
    532       if (x >= xFeature - 21) and (x < ClientWidth) and (ssShift in Shift) then
    533         HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkFeature, code[i])
    534       else if not(code[i] in AutoFeature) then
     529    if (Y >= yFeature) and (Y < yFeature + LinePitch * Lines) then
     530    begin
     531      I := (Y - yFeature) div LinePitch;
     532      if (X >= xFeature - 21) and (X < ClientWidth) and (ssShift in Shift) then
     533        HelpDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), hkFeature, Code[I])
     534      else if not(Code[I] in AutoFeature) then
    535535      begin
    536         if (code[i] < mcFirstNonCap) and (x >= xFeature - 21) and
    537           (x < xFeature - 21 + 12) then
     536        if (Code[I] < mcFirstNonCap) and (X >= xFeature - 21) and
     537          (X < xFeature - 21 + 12) then
    538538        begin
    539           IncCap := code[i];
    540           Dump(offscreen, HGrSystem, xFeature - 21, yFeature + 2 + LinePitch *
    541             i, 12, 12, 182, 172);
     539          IncCap := Code[I];
     540          Dump(Offscreen, HGrSystem, xFeature - 21, yFeature + 2 + LinePitch *
     541            I, 12, 12, 182, 172);
    542542          SmartInvalidate;
    543543        end
    544         else if (x >= xFeature - 9) and (x < xFeature - 9 + 12) then
     544        else if (X >= xFeature - 9) and (X < xFeature - 9 + 12) then
    545545        begin
    546           DecCap := code[i];
    547           if code[i] < mcFirstNonCap then
    548             Dump(offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *
    549               i, 12, 12, 182, 159)
     546          DecCap := Code[I];
     547          if Code[I] < mcFirstNonCap then
     548            Dump(Offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *
     549              I, 12, 12, 182, 159)
    550550          else
    551             Dump(offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *
    552               i, 12, 12, 182, 185 + 13 * MyRO.DevModel.Cap[code[i]]);
     551            Dump(Offscreen, HGrSystem, xFeature - 9, yFeature + 2 + LinePitch *
     552              I, 12, 12, 182, 185 + 13 * MyRO.DevModel.Cap[Code[I]]);
    553553          SmartInvalidate;
    554554        end;
     
    559559
    560560procedure TDraftDlg.PaintBox1MouseUp(Sender: TObject; Button: TMouseButton;
    561   Shift: TShiftState; x, y: integer);
     561  Shift: TShiftState; X, Y: Integer);
    562562var
    563   NewValue: integer;
     563  NewValue: Integer;
    564564begin
    565565  if IncCap >= 0 then
    566566  begin
    567567    NewValue := MyRO.DevModel.Cap[IncCap] + 1;
    568     Server(sSetDevModelCap + NewValue shl 4, me, IncCap, nil^);
     568    Server(sSetDevModelCap + NewValue shl 4, Me, IncCap, nil^);
    569569    MyModel[MyRO.nModel] := MyRO.DevModel;
    570     InitMyModel(MyRO.nModel, false);
     570    InitMyModel(MyRO.nModel, False);
    571571    SmartUpdateContent;
    572572    IncCap := -1;
     
    579579      if DecCap >= mcFirstNonCap then
    580580        NewValue := -NewValue;
    581       Server(sSetDevModelCap + NewValue shl 4, me, DecCap, nil^);
     581      Server(sSetDevModelCap + NewValue shl 4, Me, DecCap, nil^);
    582582      MyModel[MyRO.nModel] := MyRO.DevModel;
    583       InitMyModel(MyRO.nModel, false);
     583      InitMyModel(MyRO.nModel, False);
    584584    end;
    585585    SmartUpdateContent;
Note: See TracChangeset for help on using the changeset viewer.