Ignore:
Timestamp:
Nov 3, 2021, 11:22:02 AM (4 years ago)
Author:
chronos
Message:
  • Modified: Merged changes from trunk r404.
Location:
branches/highdpi/LocalPlayer
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/highdpi/LocalPlayer/CityScreen.pas

    r378 r405  
    88  Protocol, ClientTools, Term, ScreenTools, IsoEngine, BaseWin,
    99  LCLIntf, LCLType, Messages, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls,
    10   ButtonA, ButtonC, Area, GraphType;
     10  ButtonA, ButtonC, Area, GraphType, UTexture;
    1111
    1212const
  • branches/highdpi/LocalPlayer/ClientTools.pas

    r361 r405  
    636636procedure CityOptimizer_CityChange(cix: integer);
    637637begin
    638   if (MyRO.Government <> gAnarchy) and (MyCity[cix].Flags and
     638  if (MyRO.Government <> gAnarchy) and (cix <> -1) and (MyCity[cix].Flags and
    639639    chCaptured = 0) then
    640640  begin
     
    756756initialization
    757757
    758   Assert(nImp < 128);
    759   CalculateAdvValues;
     758Assert(nImp < 128);
     759CalculateAdvValues;
    760760
    761761end.
  • branches/highdpi/LocalPlayer/IsoEngine.pas

    r349 r405  
    10071007  end;
    10081008
    1009   if ShowObjects then
    1010   begin
    1011     if (Tile and fCanal <> 0) or (Tile and fCity <> 0) then
    1012     begin // paint canal connections
     1009  if ShowObjects then begin
     1010    // Paint canal connections
     1011    if (Tile and fCanal <> 0) or (Tile and fCity <> 0) then begin
    10131012      Conn := Connection8(Loc, fCanal or fCity);
    10141013      if Tile and fCanal <> 0 then
    10151014        Conn := Conn or ($FF - OceanConnection(Loc));
    1016       if Conn = 0 then
    1017       begin
     1015      if Conn = 0 then begin
    10181016        if Tile and fCanal <> 0 then
    1019           TSprite(x, y, spCanal)
     1017          TSprite(x, y, spCanal);
    10201018      end
    10211019      else
     
    10241022            TSprite(x, y, spCanal + 1 + Dir);
    10251023    end;
     1024
    10261025    if Tile and (fRR or fCity) <> 0 then
    10271026      RRConn := Connection8(Loc, fRR or fCity)
    10281027    else
    10291028      RRConn := 0;
    1030     if Tile and (fRoad or fRR or fCity) <> 0 then
    1031     begin // paint road connections
     1029
     1030    // Paint road connections
     1031    if Tile and (fRoad or fRR or fCity) <> 0 then begin
    10321032      Conn := Connection8(Loc, fRoad or fRR or fCity) and not RRConn;
    10331033      if (Conn = 0) and (Tile and (fRR or fCity) = 0) then
     
    10381038            TSprite(x, y, spRoad + 1 + Dir);
    10391039    end;
    1040     // paint railroad connections
     1040
     1041    // Paint railroad connections
    10411042    if (Tile and fRR <> 0) and (RRConn = 0) then
    10421043      TSprite(x, y, spRailRoad)
    1043     else if RRConn > 0 then
     1044    else if RRConn > 0 then begin
    10441045      for Dir := 0 to 7 do
    10451046        if (1 shl Dir) and RRConn <> 0 then
    10461047          TSprite(x, y, spRailRoad + 1 + Dir);
     1048    end;
    10471049  end;
    10481050end;
  • branches/highdpi/LocalPlayer/MessgEx.pas

    r361 r405  
    543543end;
    544544
    545 
    546 initialization
    547 
    548545end.
  • branches/highdpi/LocalPlayer/Term.lfm

    r349 r405  
    11object MainScreen: TMainScreen
    2   Left = 169
     2  Left = 516
    33  Height = 480
    4   Top = 596
     4  Top = 834
    55  Width = 800
    66  HorzScrollBar.Visible = False
     
    667667      OnClick = MenuClick
    668668    end
     669    object N13: TDpiMenuItem
     670      Caption = '-'
     671    end
     672    object mPrevUnit: TDpiMenuItem
     673      Tag = 100
     674      ShortCut = 46
     675      OnClick = MenuClick
     676    end
     677    object mNextUnit: TDpiMenuItem
     678      Tag = 101
     679      ShortCut = 45
     680      OnClick = MenuClick
     681    end
    669682  end
    670683  object StatPopup: TDpiPopupMenu
  • branches/highdpi/LocalPlayer/Term.pas

    r378 r405  
    2929  TMainScreen = class(TDrawDlg)
    3030    mBigTiles: TDpiMenuItem;
     31    mNextUnit: TDpiMenuItem;
     32    N13: TDpiMenuItem;
     33    mPrevUnit: TDpiMenuItem;
    3134    Timer1: TTimer;
    3235    GamePopup: TDpiPopupMenu;
     
    286289    procedure CopyMiniToPanel;
    287290    procedure PanelPaint;
    288     procedure NextUnit(NearLoc: integer; AutoTurn: boolean);
     291    procedure FocusNextUnit(Dir: Integer = 1);
     292    procedure NextUnit(NearLoc: Integer; AutoTurn: Boolean);
    289293    procedure Scroll(dx, dy: integer);
    290294    procedure SetMapPos(Loc: integer; MapPos: TPoint);
     
    24332437  begin
    24342438    SetTroopLoc(-1);
    2435     PaintAll
     2439    PaintAll;
    24362440  end { supervisor }
    24372441  { else if (ClientMode=cTurn) and (MyRO.Turn=0) then
     
    24552459          FocusOnLoc(G.lx * G.ly div 2);
    24562460      SetTroopLoc(-1);
    2457       PanelPaint
     2461      PanelPaint;
    24582462    end;
    24592463    if ShowCityList then
     
    34463450  NoMapPanel := TIsoMap.Create;
    34473451
    3448   KeyBindings.LoadFromRegistry(HKEY_CURRENT_USER, AppRegistryKey + '\KeyBindings');
    34493452  UpdateKeyShortcuts;
    34503453
     
    35453548  I: Integer;
    35463549begin
    3547   KeyBindings.SaveToRegistry(HKEY_CURRENT_USER, AppRegistryKey + '\KeyBindings');
    35483550  MainFormKeyDown := nil;
    35493551  FreeAndNil(sb);
     
    49044906end;
    49054907
     4908procedure TMainScreen.FocusNextUnit(Dir: Integer);
     4909var
     4910  i, uix, NewFocus: Integer;
     4911begin
     4912  if ClientMode >= scContact then
     4913    Exit;
     4914  DestinationMarkON := False;
     4915  PaintDestination;
     4916  NewFocus := -1;
     4917  for i := 1 to MyRO.nUn do begin
     4918    uix := (UnFocus + i * Dir + MyRO.nUn) mod MyRO.nUn;
     4919    if (MyUn[uix].Loc >= 0) and (MyUn[uix].Status and usStay = 0) then begin
     4920      NewFocus := uix;
     4921      Break;
     4922    end;
     4923  end;
     4924  if NewFocus >= 0 then begin
     4925    SetUnFocus(NewFocus);
     4926    SetTroopLoc(MyUn[NewFocus].Loc);
     4927    FocusOnLoc(TroopLoc, flRepaintPanel);
     4928  end;
     4929end;
     4930
    49064931procedure TMainScreen.FocusOnLoc(Loc: integer; Options: integer = 0);
    49074932var
     
    49304955end;
    49314956
    4932 procedure TMainScreen.NextUnit(NearLoc: integer; AutoTurn: boolean);
     4957procedure TMainScreen.NextUnit(NearLoc: Integer; AutoTurn: Boolean);
    49334958var
    4934   Dist, TestDist: single;
    4935   i, uix, NewFocus: integer;
    4936   GotoOnly: boolean;
     4959  Dist, TestDist: Single;
     4960  i, uix, NewFocus: Integer;
     4961  GotoOnly: Boolean;
    49374962begin
    49384963  Dist := 0;
    49394964  if ClientMode >= scContact then
    4940     exit;
    4941   DestinationMarkON := false;
     4965    Exit;
     4966  DestinationMarkON := False;
    49424967  PaintDestination;
    4943   for GotoOnly := GoOnPhase downto false do
    4944   begin
     4968  for GotoOnly := GoOnPhase downto False do begin
    49454969    NewFocus := -1;
    4946     for i := 1 to MyRO.nUn do
    4947     begin
     4970    for i := 1 to MyRO.nUn do begin
    49484971      uix := (UnFocus + i) mod MyRO.nUn;
    49494972      if (MyUn[uix].Loc >= 0) and (MyUn[uix].Job = jNone) and
    49504973        (MyUn[uix].Status and (usStay or usRecover or usWaiting) = usWaiting)
    49514974        and (not GotoOnly or (MyUn[uix].Status and usGoto <> 0)) then
    4952         if NearLoc < 0 then
    4953         begin
     4975        if NearLoc < 0 then begin
    49544976          NewFocus := uix;
    49554977          Break;
    4956         end
    4957         else
    4958         begin
     4978        end else begin
    49594979          TestDist := Distance(NearLoc, MyUn[uix].Loc);
    4960           if (NewFocus < 0) or (TestDist < Dist) then
    4961           begin
     4980          if (NewFocus < 0) or (TestDist < Dist) then begin
    49624981            NewFocus := uix;
    49634982            Dist := TestDist;
     
    49664985    end;
    49674986    if GotoOnly then
    4968       if NewFocus < 0 then
    4969         GoOnPhase := false
    4970       else
    4971         Break;
    4972   end;
    4973   if NewFocus >= 0 then
    4974   begin
     4987      if NewFocus < 0 then GoOnPhase := False
     4988        else Break;
     4989  end;
     4990  if NewFocus >= 0 then begin
    49754991    SetUnFocus(NewFocus);
    49764992    SetTroopLoc(MyUn[NewFocus].Loc);
    4977     FocusOnLoc(TroopLoc, flRepaintPanel)
    4978   end
    4979   else if AutoTurn and not mWaitTurn.Checked then
    4980   begin
    4981     TurnComplete := true;
     4993    FocusOnLoc(TroopLoc, flRepaintPanel);
     4994  end else
     4995  if AutoTurn and not mWaitTurn.Checked then begin
     4996    TurnComplete := True;
    49824997    SetUnFocus(-1);
    49834998    SetTroopLoc(-1);
    4984     PostMessage(Handle, WM_EOT, 0, 0)
    4985   end
    4986   else
    4987   begin
     4999    PostMessage(Handle, WM_EOT, 0, 0);
     5000  end else begin
    49885001    if { (UnFocus>=0) and } not TurnComplete and EOT.Visible then
    49895002      Play('TURNEND');
    4990     TurnComplete := true;
     5003    TurnComplete := True;
    49915004    SetUnFocus(-1);
    49925005    SetTroopLoc(-1);
     
    59625975        end
    59635976        else
    5964           NextUnit(UnStartLoc, true)
     5977          NextUnit(UnStartLoc, true);
    59655978    end
    59665979    else if (UnFocus < 0) and (Options and muAutoNext <> 0) then
     
    61676180        begin
    61686181          MyUn[uix].Status := MyUn[uix].Status and not usWaiting;
    6169           NextUnit(UnStartLoc, true)
     6182          NextUnit(UnStartLoc, true);
    61706183        end;
    61716184      end;
     
    63286341              trixFocus := TrCnt;
    63296342            inc(TrCnt);
    6330           end
     6343          end;
    63316344    end
    63326345    else // count enemy units here
     
    64436456  mStay.ShortCut := BStay.ShortCut;
    64446457  mNoOrders.ShortCut := BNoOrders.ShortCut;
     6458  mPrevUnit.ShortCut := BPrevUnit.ShortCut;
     6459  mNextUnit.ShortCut := BNextUnit.ShortCut;
    64456460  mCancel.ShortCut := BCancel.ShortCut;
    64466461  mPillage.ShortCut := BPillage.ShortCut;
     
    66366651    else if BStay.Test(ShortCut) then MenuClick(mStay)
    66376652    else if BNoOrders.Test(ShortCut) then MenuClick(mNoOrders)
     6653    else if BPrevUnit.Test(ShortCut) then MenuClick(mPrevUnit)
     6654    else if BNextUnit.Test(ShortCut) then MenuClick(mNextUnit)
    66386655    else if BCancel.Test(ShortCut) then MenuClick_Check(UnitPopup, mCancel)
    66396656    else if BPillage.Test(ShortCut) then MenuClick_Check(UnitPopup, mPillage)
     
    67186735          end
    67196736          else
    6720             PanelPaint
     6737            PanelPaint;
    67216738        end
    67226739        else
    67236740          NextUnit(UnStartLoc, true);
    6724       end
     6741      end;
    67256742    end;
    67266743    case result of
     
    67356752      if result < rExecuted then
    67366753        Play('INVALID')
    6737     end
     6754    end;
    67386755  end;
    67396756
     
    69146931  end
    69156932  else if UnFocus >= 0 then
    6916     with MyUn[UnFocus] do
     6933    with TUn(MyUn[UnFocus]) do
    69176934      if Sender = mGoOn then
    69186935      begin
     
    69456962      begin
    69466963        Centre(Loc);
    6947         PaintAllMaps
     6964        PaintAllMaps;
    69486965      end
    69496966      else if Sender = mCity then
     
    69576974            PaintAll;
    69586975            ZoomToCity(Loc0, true, chFounded);
    6959           end
     6976          end;
    69606977        end
    69616978        else
     
    70187035        if Job > jNone then
    70197036          Server(sStartJob + jNone shl 4, me, UnFocus, nil^);
    7020         NextUnit(UnStartLoc, true)
     7037        NextUnit(UnStartLoc, true);
    70217038      end
    70227039      else if Sender = mRecover then
     
    70277044        if Job > jNone then
    70287045          Server(sStartJob + jNone shl 4, me, UnFocus, nil^);
    7029         NextUnit(UnStartLoc, true)
     7046        NextUnit(UnStartLoc, true);
    70307047      end
    70317048      else if Sender = mNoOrders then
    70327049      begin
    70337050        Status := Status and not usWaiting;
    7034         NextUnit(UnStartLoc, true)
     7051        NextUnit(UnStartLoc, true);
     7052      end
     7053      else if Sender = mPrevUnit then
     7054      begin
     7055        Status := Status and not usWaiting;
     7056        FocusNextUnit(-1);
     7057      end
     7058      else if Sender = mNextUnit then
     7059      begin
     7060        Status := Status and not usWaiting;
     7061        FocusNextUnit(1);
    70357062      end
    70367063      else if Sender = mCancel then
     
    71137140              NextUnit(Loc, true)
    71147141            else
    7115               PanelPaint
     7142              PanelPaint;
    71167143          end
    71177144          else if i = eNoTime_Load then
     
    80358062end;
    80368063
    8037 initialization
    8038 
    80398064end.
    80408065
  • branches/highdpi/LocalPlayer/UKeyBindings.pas

    r303 r405  
    1717    ShortCut: TShortCut;
    1818    ShortCut2: TShortCut;
     19    DefaultShortCut: TShortCut;
     20    DefaultShortCut2: TShortCut;
    1921    function Test(AShortCut: TShortCut): Boolean;
     22    procedure Assign(Source: TKeyBinding);
     23    procedure SetDefault;
    2024  end;
    2125
     
    2327
    2428  TKeyBindings = class(TFPGObjectList<TKeyBinding>)
     29  private
    2530  public
    2631    function AddItem(const ShortName, FullName: string; ShortCut: TShortCut; ShortCut2: TShortCut = 0): TKeyBinding; overload;
     
    2934    procedure LoadFromRegistry(RootKey: HKEY; Key: string);
    3035    procedure SaveToRegistry(RootKey: HKEY; Key: string);
     36    procedure LoadToStrings(Strings: TStrings);
     37    procedure Assign(Source: TKeyBindings);
     38    procedure ResetToDefault;
     39    procedure RemoveShortCut(ShortCut: TShortCut);
    3140  end;
    3241
     
    5261  BStay: TKeyBinding;
    5362  BNoOrders: TKeyBinding;
     63  BPrevUnit: TKeyBinding;
     64  BNextUnit: TKeyBinding;
    5465  BCancel: TKeyBinding;
    5566  BPillage: TKeyBinding;
     
    123134end;
    124135
     136procedure TKeyBinding.Assign(Source: TKeyBinding);
     137begin
     138  ShortName := Source.ShortName;
     139  FullName := Source.FullName;
     140  ShortCut := Source.ShortCut;
     141  ShortCut2 := Source.ShortCut2;
     142  DefaultShortCut := Source.DefaultShortCut;
     143  DefaultShortCut2 := Source.DefaultShortCut2;
     144end;
     145
     146procedure TKeyBinding.SetDefault;
     147begin
     148  ShortCut := DefaultShortCut;
     149  ShortCut2 := DefaultShortCut2;
     150end;
     151
    125152{ TKeyBindings }
    126153
     
    133160  Result.ShortCut := ShortCut;
    134161  Result.ShortCut2 := ShortCut2;
     162  Result.DefaultShortCut := ShortCut;
     163  Result.DefaultShortCut2 := ShortCut2;
    135164  Add(Result);
    136165end;
     
    207236end;
    208237
     238procedure TKeyBindings.LoadToStrings(Strings: TStrings);
     239var
     240  I: Integer;
     241  Text: string;
     242begin
     243  Strings.Clear;
     244  for I := 0 to Count - 1 do begin
     245    Text:= '';
     246    if Items[I].ShortCut <> 0 then
     247      Text:= Text + ShortCutToText(Items[I].ShortCut);
     248    if Items[I].ShortCut2 <> 0 then begin
     249      if Text <> '' then Text := Text + ', ';
     250      Text:= Text + ShortCutToText(Items[I].ShortCut2);
     251    end;
     252    if Text <> '' then Text := Items[I].FullName + ' (' + Text + ')'
     253      else Text := Items[I].FullName;
     254    Strings.Add(Text);
     255  end;
     256end;
     257
     258procedure TKeyBindings.Assign(Source: TKeyBindings);
     259var
     260  I: Integer;
     261begin
     262  while Count < Source.Count do
     263    Add(TKeyBinding.Create);
     264  while Count > Source.Count do
     265    Delete(Count - 1);
     266  for I := 0 to Count - 1 do
     267    Items[I].Assign(Source.Items[I]);
     268end;
     269
     270procedure TKeyBindings.ResetToDefault;
     271var
     272  I: Integer;
     273begin
     274  for I := 0 to Count - 1 do
     275    Items[I].SetDefault;
     276end;
     277
     278procedure TKeyBindings.RemoveShortCut(ShortCut: TShortCut);
     279var
     280  I: Integer;
     281begin
     282  for I := 0 to Count - 1 do begin
     283    if Items[I].ShortCut = ShortCut then Items[I].ShortCut := 0;
     284    if Items[I].ShortCut2 = ShortCut then Items[I].ShortCut2 := 0;
     285  end;
     286end;
     287
    209288
    210289initialization
     
    231310  BStay := AddItem('Stay', 'Stay', 'S');
    232311  BNoOrders := AddItem('NoOrders', 'No orders', 'Space');
     312  BPrevUnit := AddItem('PrevUnit', 'Previous unit', 'Del');
     313  BNextUnit := AddItem('NextUnit', 'Next unit', 'Ins');
    233314  BCancel := AddItem('Cancel', 'Cancel', 'Ctrl+C');
    234315  BPillage := AddItem('Pillage', 'Pillage', 'Ctrl+P');
  • branches/highdpi/LocalPlayer/UnitStat.pas

    r361 r405  
    5252
    5353uses
    54   Tribes, Help, Directories;
     54  Tribes, Help, Directories, UTexture;
    5555
    5656{$R *.lfm}
Note: See TracChangeset for help on using the changeset viewer.