Ignore:
Timestamp:
Nov 3, 2021, 11:22:02 AM (2 years ago)
Author:
chronos
Message:
  • Modified: Merged changes from trunk r404.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.