Changeset 439 for trunk/LocalPlayer


Ignore:
Timestamp:
May 18, 2022, 11:39:46 AM (3 years ago)
Author:
chronos
Message:
  • Modified: Code cleanup.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Select.pas

    r438 r439  
    5050    cixProject: Integer;
    5151    pView: Integer;
    52     Sel: Integer;
     52    Selected: Integer;
    5353    DispLines: Integer;
    5454    Layer: Integer;
     
    5656    TechNameSpace: Integer;
    5757    ScienceNation: Integer;
    58     sb: TPVScrollbar;
    59     Lines, FirstShrinkedLine: array [0 .. MaxLayer - 1] of integer;
    60     code: array [0 .. MaxLayer - 1, 0 .. 4095] of integer;
    61     Column: array [0 .. nPl - 1] of integer;
     58    ScrollBar: TPVScrollbar;
     59    Lines: array [0 .. MaxLayer - 1] of Integer;
     60    FirstShrinkedLine: array [0 .. MaxLayer - 1] of Integer;
     61    code: array [0 .. MaxLayer - 1, 0 .. 4095] of Integer;
     62    Column: array [0 .. nPl - 1] of Integer;
    6263    Closable: Boolean;
    6364    MultiPage: Boolean;
     
    112113  inherited;
    113114  Canvas.Font.Assign(UniFont[ftNormal]);
    114   sb := TPVScrollbar.Create(Self);
    115   sb.SetBorderSpacing(36, 10, 36);
    116   sb.OnUpdate := ScrollBarUpdate;
     115  ScrollBar := TPVScrollbar.Create(Self);
     116  ScrollBar.SetBorderSpacing(36, 10, 36);
     117  ScrollBar.OnUpdate := ScrollBarUpdate;
    117118  InitButtons;
    118119  Kind := kMission;
     
    128129procedure TListDlg.FormDestroy(Sender: TObject);
    129130begin
    130   FreeAndNil(sb);
     131  FreeAndNil(ScrollBar);
    131132  FreeAndNil(ScienceNationDotBuffer);
    132133end;
     
    146147begin
    147148  { TODO: Handled by MouseWheel event
    148   if sb.Process(Msg) then  begin
    149     Sel := -2;
     149  if ScrollBar.Process(Msg) then  begin
     150    Selected := -2;
    150151    SmartUpdateContent(true);
    151152  end;
     
    155156procedure TListDlg.OnMouseLeave(var Msg: TMessage);
    156157begin
    157   if not Closable and (Sel <> -2) then
    158   begin
    159     line(Canvas, Sel, false, false);
    160     Sel := -2;
     158  if not Closable and (Selected <> -2) then
     159  begin
     160    line(Canvas, Selected, false, false);
     161    Selected := -2;
    161162  end;
    162163end;
     
    168169  inherited;
    169170  Canvas.Font.Assign(UniFont[ftNormal]);
    170   if Sel <> -2 then
    171     line(Canvas, Sel, false, true);
     171  if Selected <> -2 then
     172    line(Canvas, Selected, false, true);
    172173  s := '';
    173174  if (Kind = kAdvance) and (MyData.FarTech <> adNone) then
     
    246247  CanGrow: boolean;
    247248begin
    248   lix := code[Layer, sb.Position + l];
     249  lix := code[Layer, ScrollBar.Position + l];
    249250  y0 := 2 + (l + 1) * LineDistance;
    250   if sb.Position + l >= FirstShrinkedLine[Layer] then
    251     ofs := (sb.Position + l - FirstShrinkedLine[Layer]) and 1 * 33
     251  if ScrollBar.Position + l >= FirstShrinkedLine[Layer] then
     252    ofs := (ScrollBar.Position + l - FirstShrinkedLine[Layer]) and 1 * 33
    252253  else { if FirstShrinkedLine[Layer]<Lines[Layer] then }
    253254    ofs := 33;
     
    480481          begin
    481482            s := Tribe[mox.Owner].ModelName[mox.mix];
    482             if (Kind = kAllEModels) and (code[1, sb.Position + l] = 0) then
     483            if (Kind = kAllEModels) and (code[1, ScrollBar.Position + l] = 0) then
    483484              s := Format(Tribe[mox.Owner].TPhrase('OWNED'), [s]);
    484485          end
     
    766767
    767768    for i := -1 to DispLines do
    768       if (i + sb.Position >= 0) and (i + sb.Position < Lines[Layer]) then
     769      if (i + ScrollBar.Position >= 0) and (i + ScrollBar.Position < Lines[Layer]) then
    769770        Self.line(offscreen.Canvas, i, true, false);
    770771  end;
     
    779780begin
    780781  y := y - TitleHeight;
    781   i0 := sb.Position;
    782   Sel0 := Sel;
     782  i0 := ScrollBar.Position;
     783  Sel0 := Selected;
    783784  if (x >= SideFrame) and (x < SideFrame + InnerWidth) and (y >= 0) and
    784785    (y < InnerHeight) and (y mod LineDistance >= 4) and (y mod LineDistance < 20)
    785786  then
    786     Sel := y div LineDistance - 1
     787    Selected := y div LineDistance - 1
    787788  else
    788     Sel := -2;
    789   if (Sel < -1) or (Sel > DispLines) or (Sel + i0 < 0) or
    790     (Sel + i0 >= Lines[Layer]) then
    791     Sel := -2;
    792   if Sel <> Sel0 then
     789    Selected := -2;
     790  if (Selected < -1) or (Selected > DispLines) or (Selected + i0 < 0) or
     791    (Selected + i0 >= Lines[Layer]) then
     792    Selected := -2;
     793  if Selected <> Sel0 then
    793794  begin
    794795    if Sel0 <> -2 then
    795796      line(Canvas, Sel0, false, false);
    796     if Sel <> -2 then
    797       line(Canvas, Sel, false, true);
     797    if Selected <> -2 then
     798      line(Canvas, Selected, false, true);
    798799  end;
    799800
     
    841842  WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
    842843begin
    843   if sb.ProcessMouseWheel(WheelDelta) then begin
     844  if ScrollBar.ProcessMouseWheel(WheelDelta) then begin
    844845    PaintBox1MouseMove(nil, [], MousePos.X - Left,
    845846      MousePos.Y - Top);
     
    915916  lix: integer;
    916917begin
    917   if sb.Position + Sel >= 0 then
    918     lix := code[Layer, sb.Position + Sel];
     918  if ScrollBar.Position + Selected >= 0 then
     919    lix := code[Layer, ScrollBar.Position + Selected];
    919920  if Kind in [kScience, kCities, kCityEvents, kModels, kEModels, kAllEModels]
    920921  then
     
    922923  if (ssLeft in Shift) and not(ssShift in Shift) then
    923924  begin
    924     if Sel <> -2 then
     925    if Selected <> -2 then
    925926    begin
    926927      result := lix;
     
    931932  else if (ssLeft in Shift) and (ssShift in Shift) then
    932933  begin // show help/info popup
    933     if Sel <> -2 then
     934    if Selected <> -2 then
    934935      case Kind of
    935936        kCities:
     
    943944        kEModels:
    944945          UnitStatDlg.ShowNewContent_EnemyModel(wmPersistent,
    945             code[1, sb.Position + Sel]);
     946            code[1, ScrollBar.Position + Selected]);
    946947        kAllEModels, kChooseEModel:
    947948          if lix <> mixAll then
     
    972973  else if ssRight in Shift then
    973974  begin
    974     if Sel <> -2 then
     975    if Selected <> -2 then
    975976      case Kind of
    976977        kCities, kCityEvents:
     
    15621563  if (Kind = kAdvance) and (MyData.FarTech <> adNone) or (Kind = kModels) or
    15631564    (Kind = kEModels) then begin
    1564     sb.SetBorderSpacing(56, 10, 10);
     1565    ScrollBar.SetBorderSpacing(56, 10, 10);
    15651566    TitleHeight := WideFrame + 20;
    15661567  end else begin
    1567     sb.SetBorderSpacing(36, 10, 34);
     1568    ScrollBar.SetBorderSpacing(36, 10, 34);
    15681569    TitleHeight := WideFrame;
    15691570  end;
     
    16251626  CaptionRight := CloseBtn.Left;
    16261627  { TODO:
    1627   SetWindowPos(sb.ScrollBar.Handle, 0, SideFrame + InnerWidth - GetSystemMetrics(SM_CXVSCROLL),
     1628  SetWindowPos(ScrollBar.ScrollBar.Handle, 0, SideFrame + InnerWidth - GetSystemMetrics(SM_CXVSCROLL),
    16281629    TitleHeight, GetSystemMetrics(SM_CXVSCROLL), LineDistance * DispLines + 48,
    16291630    SWP_NOZORDER or SWP_NOREDRAW);
     
    16581659
    16591660  Layer := 0;
    1660   Sel := -2;
     1661  Selected := -2;
    16611662  ScienceNation := -1;
    1662   sb.Init(Lines[Layer] - 1, DispLines);
     1663  ScrollBar.Init(Lines[Layer] - 1, DispLines);
    16631664
    16641665  OffscreenPaint;
     
    17751776  end;
    17761777  InitLines;
    1777   Sel := -2;
    1778   sb.Init(Lines[Layer] - 1, DispLines);
     1778  Selected := -2;
     1779  ScrollBar.Init(Lines[Layer] - 1, DispLines);
    17791780  OffscreenPaint;
    17801781  Invalidate;
     
    17881789  Layer := TComponent(Sender).Tag;
    17891790
    1790   Sel := -2;
    1791   sb.Init(Lines[Layer] - 1, DispLines);
     1791  Selected := -2;
     1792  ScrollBar.Init(Lines[Layer] - 1, DispLines);
    17921793  SmartUpdateContent;
    17931794end;
     
    18921893procedure TListDlg.ScrollBarUpdate(Sender: TObject);
    18931894begin
    1894   Sel := -2;
     1895  Selected := -2;
    18951896  SmartUpdateContent(true);
    18961897end;
Note: See TracChangeset for help on using the changeset viewer.