Changeset 662


Ignore:
Timestamp:
Jul 5, 2025, 9:46:37 AM (7 hours ago)
Author:
chronos
Message:
  • Added: Allow to move with up, down, page up, page down, home and end keys in selection dialog.
  • Added: Open product selection dialog with P key in city dialog.
  • Added: Close city dialog with return key.
Location:
trunk/LocalPlayer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/CityScreen.pas

    r622 r662  
    17481748  Shift: TShiftState);
    17491749begin
     1750  if Key = VK_P then begin
     1751    if ProdHint then begin
     1752      ProdHint := False;
     1753      SmartUpdateContent;
     1754    end;
     1755    ChooseProject;
     1756  end else
     1757  if Key = VK_RETURN then begin
     1758    CloseBtnClick(Self);
     1759  end else
    17501760  if ((Key = VK_UP) or (Key = VK_NUMPAD8)) and (cix >= 0) and
    17511761    (WindowMode = wmPersistent) then
  • trunk/LocalPlayer/Select.pas

    r622 r662  
    66uses
    77  Protocol, ClientTools, ScreenTools, PVSB, BaseWin, LCLIntf, LCLType, Messages,
    8   SysUtils, Classes, ButtonB, ButtonBase, Types,
     8  SysUtils, Classes, ButtonB, ButtonBase, Types, Math,
    99  {$IFDEF DPI}Dpi.Graphics, Dpi.Controls, Dpi.Forms, Dpi.ExtCtrls, Dpi.Menus,
    1010  Dpi.Common, System.UITypes{$ELSE}
     
    6666    MultiPage: Boolean;
    6767    ScienceNationDotBuffer: TBitmap;
     68    function GetSelectionIndex: Integer;
    6869    procedure ScrollBarUpdate(Sender: TObject);
    6970    procedure InitLines;
    70     procedure Line(ca: TCanvas; L: Integer; NonText, lit: Boolean);
     71    procedure Line(ca: TCanvas; L: Integer; NonText, Lit: Boolean);
    7172    function RenameModel(mix: Integer): Boolean;
    7273    procedure OnScroll(var Msg: TMessage); message WM_VSCROLL;
    7374    procedure OnMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
     75    procedure SetSelectionIndex(Index: Integer);
    7476  public
    7577    Result: Integer;
     
    189191end;
    190192
    191 procedure TListDlg.Line(ca: TCanvas; L: Integer; NonText, lit: Boolean);
     193procedure TListDlg.Line(ca: TCanvas; L: Integer; NonText, Lit: Boolean);
    192194// paint a line
    193195
     
    237239
    238240var
    239   icon, ofs, X, Y, y0, lix, I, J, TextColor, Available, First, Test,
     241  Icon, ofs, X, Y, y0, lix, I, J, TextColor, Available, First, Test,
    240242    FutureCount, Growth, TrueFood, TrueProd: Integer;
    241243  CityReport: TCityReportNew;
     
    261263        Y := Y + TitleHeight;
    262264      end;
    263       if lit then
     265      if Lit then
    264266        TextColor := MainTexture.ColorLitText
    265267      else
     
    433435      Y := Y + TitleHeight;
    434436    end;
    435     if lit then
     437    if Lit then
    436438      TextColor := MainTexture.ColorLitText
    437439    else
     
    552554
    553555            if NonText then
    554             begin // show tech icon
     556            begin // show tech Icon
    555557              if lix = adNexus then
    556558              begin
     
    604606                if lix = MyRO.ResearchTech then
    605607                begin
    606                   Server(sGetTechCost, Me, 0, icon);
    607                   icon := 4 + MyRO.Research * 4 div icon;
    608                   if icon > 4 + 3 then
    609                     icon := 4 + 3
     608                  Server(sGetTechCost, Me, 0, Icon);
     609                  Icon := 4 + MyRO.Research * 4 div Icon;
     610                  if Icon > 4 + 3 then
     611                    Icon := 4 + 3
    610612                end
    611613                else if (lix >= adMilitary) then
    612                   icon := -1
     614                  Icon := -1
    613615                else if lix in FutureTech then
    614616                begin
    615                   icon := -1;
     617                  Icon := -1;
    616618                  FutureCount := MyRO.Tech[lix];
    617619                end
    618620                else if MyRO.Tech[lix] = tsSeen then
    619                   icon := 1
     621                  Icon := 1
    620622                else if MyRO.Tech[lix] >= tsApplicable then
    621                   icon := 2
     623                  Icon := 2
    622624                else
    623                   icon := -1
     625                  Icon := -1
    624626              else
    625627                with MyRO.EnemyReport[Column[J]]^ do // enemy science
     
    629631                    (Tech[lix] < tsApplicable)) then
    630632                  begin
    631                     icon := 4 + ResearchDone div 25;
    632                     if icon > 4 + 3 then
    633                       icon := 4 + 3;
     633                    Icon := 4 + ResearchDone div 25;
     634                    if Icon > 4 + 3 then
     635                      Icon := 4 + 3;
    634636                  end
    635637                  else if lix = adMilitary then
    636                     icon := -1
     638                    Icon := -1
    637639                  else if lix in FutureTech then
    638640                  begin
    639                     icon := -1;
     641                    Icon := -1;
    640642                    FutureCount := Tech[lix]
    641643                  end
    642644                  else if Tech[lix] >= tsApplicable then
    643                     icon := 2
     645                    Icon := 2
    644646                  else if Tech[lix] = tsSeen then
    645                     icon := 1
     647                    Icon := 1
    646648                  else
    647                     icon := -1;
    648               if icon >= 0 then
     649                    Icon := -1;
     650              if Icon >= 0 then
    649651                Sprite(Offscreen, HGrSystem, 104 - 33 + 15 + 3 + TechNameSpace +
    650                   24 * J, y0 + 3, 14, 14, 67 + icon * 15, 85)
     652                  24 * J, y0 + 3, 14, 14, 67 + Icon * 15, 85)
    651653              else if (Kind = kScience) and (FutureCount > 0) then
    652654              begin
     
    710712      Y := Y + TitleHeight;
    711713    end;
    712     if lit then
     714    if Lit then
    713715      TextColor := MainTexture.ColorLitText
    714716    else
     
    788790    (Selected + i0 >= Lines[Layer]) then
    789791    Selected := -2;
    790   if Selected <> Sel0 then
    791   begin
     792  if Selected <> Sel0 then begin
    792793    if Sel0 <> -2 then
    793794      Line(Canvas, Sel0, False, False);
     
    18611862end;
    18621863
     1864function TListDlg.GetSelectionIndex: Integer;
     1865begin
     1866  if Selected >= 0 then Result := ScrollBar.Position + Selected
     1867    else Result := -1;
     1868end;
     1869
     1870procedure TListDlg.SetSelectionIndex(Index: Integer);
     1871var
     1872  NewSelected: Integer;
     1873  NewScrollBarPos: Integer;
     1874  Over: Integer;
     1875  Under: Integer;
     1876begin
     1877  if Index < 0 then Index := 0;
     1878  if Index > Lines[Layer] - 1 then Index := Lines[Layer] - 1;
     1879
     1880  NewSelected := Index - ScrollBar.Position;
     1881  NewScrollBarPos := ScrollBar.Position;
     1882
     1883  Over := NewSelected - Min(DispLines, Lines[Layer] - NewScrollBarPos);
     1884  if Over > 0 then begin
     1885    Inc(NewScrollBarPos, Over);
     1886    Dec(NewSelected, Over);
     1887  end;
     1888
     1889  Under := -NewSelected;
     1890  if Under > 0 then begin
     1891    Dec(NewScrollBarPos, Under);
     1892    Inc(NewSelected, Under);
     1893  end;
     1894
     1895  if (NewSelected <> Selected) or (NewScrollBarPos <> ScrollBar.Position) then begin
     1896    if Selected >= 0 then Line(Canvas, Selected, False, False);
     1897
     1898    ScrollBar.Position := NewScrollBarPos;
     1899    Selected := NewSelected;
     1900
     1901    Line(Canvas, Selected, False, True);
     1902  end;
     1903end;
     1904
    18631905procedure TListDlg.FormKeyDown(Sender: TObject; var Key: Word;
    18641906  Shift: TShiftState);
    1865 begin
     1907var
     1908  LastSelectionIndex: Integer;
     1909begin
     1910  if (Key = VK_RIGHT) or (Key = VK_NUMPAD6) then begin
     1911    if MultiPage and (Layer < MaxLayer - 1) then begin
     1912      LastSelectionIndex := GetSelectionIndex;
     1913      Inc(Layer);
     1914      if Lines[Layer] = 0 then Inc(Layer);
     1915      ScrollBar.Init(Lines[Layer] - 1, DispLines);
     1916      SetSelectionIndex(LastSelectionIndex);
     1917      SmartUpdateContent;
     1918    end;
     1919  end else
     1920  if (Key = VK_LEFT) or (Key = VK_NUMPAD4) then begin
     1921    if MultiPage and (Layer > 0) then begin
     1922      LastSelectionIndex := GetSelectionIndex;
     1923      Dec(Layer);
     1924      if Lines[Layer] = 0 then Dec(Layer);
     1925      ScrollBar.Init(Lines[Layer] - 1, DispLines);
     1926      SetSelectionIndex(LastSelectionIndex);
     1927      SmartUpdateContent;
     1928    end;
     1929  end else
     1930  if (Key = VK_UP) or (Key = VK_NUMPAD8) then begin
     1931    SetSelectionIndex(GetSelectionIndex - 1);
     1932  end else
     1933  if (Key = VK_DOWN) or (Key = VK_NUMPAD2) then begin
     1934    SetSelectionIndex(GetSelectionIndex + 1);
     1935  end else
     1936  if (Key = VK_HOME) or (Key = VK_NUMPAD7) then begin
     1937    SetSelectionIndex(0);
     1938  end else
     1939  if (Key = VK_END) or (Key = VK_NUMPAD1) then begin
     1940    SetSelectionIndex(Lines[Layer]);
     1941  end else
     1942  if (Key = VK_PRIOR) or (Key = VK_NUMPAD9) then begin
     1943    SetSelectionIndex(GetSelectionIndex - ScrollBar.PageSize);
     1944  end else
     1945  if (Key = VK_NEXT) or (Key = VK_NUMPAD3) then begin
     1946    SetSelectionIndex(GetSelectionIndex + ScrollBar.PageSize);
     1947  end else
     1948  if Key = VK_RETURN then begin
     1949    PaintBox1MouseDown(Self, TMouseButton.mbLeft, [ssLeft], 0, 0);
     1950  end else
    18661951  if (Key = VK_F2) and (Kind in [kModels, kEModels]) then // my key
    18671952    // !!! toggle
Note: See TracChangeset for help on using the changeset viewer.