Changeset 414 for trunk/LocalPlayer


Ignore:
Timestamp:
Nov 17, 2021, 1:18:21 AM (3 years ago)
Author:
chronos
Message:
Location:
trunk/LocalPlayer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/NatStat.pas

    r352 r414  
    55
    66uses
    7   Protocol, ClientTools, Term, ScreenTools, BaseWin,
    8 
    9   LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms,
    10   ButtonB, ButtonC, Menus, EOTButton;
     7  Protocol, ClientTools, Term, ScreenTools, BaseWin, LCLIntf, LCLType, SysUtils,
     8  Classes, Graphics, Controls, Forms, ButtonB, ButtonC, Menus, EOTButton;
    119
    1210type
     
    3230    procedure ScrollDownBtnClick(Sender: TObject);
    3331    procedure TellAIBtnClick(Sender: TObject);
    34 
    3532  public
    3633    procedure CheckAge;
    3734    procedure ShowNewContent(NewMode: integer; p: integer = -1);
    3835    procedure EcoChange;
    39 
    4036  protected
    4137    procedure OffscreenPaint; override;
    42 
    4338  private
    4439    pView, AgePrepared, LinesDown: integer;
     
    305300          Phrases.Lookup('FREXTINCT'));
    306301        LoweredTextOut(Canvas, -1, MainTexture, xAttrib, yAttrib + 28,
    307           TurnToString(CurrentReport.TurnOfCivilReport))
     302          TurnToString(CurrentReport.TurnOfCivilReport));
    308303      end
    309304      else
     
    320315        s := Phrases.Lookup('FRNOCONTACT');
    321316        LoweredTextOut(Canvas, -1, MainTexture,
    322           (ClientWidth - BiColorTextWidth(Canvas, s)) div 2, yRelation + 9, s)
     317          (ClientWidth - BiColorTextWidth(Canvas, s)) div 2, yRelation + 9, s);
    323318      end
    324319      else if ShowContact then
     
    379374          end;
    380375          inc(y);
    381         end
     376        end;
    382377      end;
    383378    end
     
    403398procedure TNatStatDlg.CloseBtnClick(Sender: TObject);
    404399begin
    405   Close
     400  Close;
    406401end;
    407402
     
    421416      begin
    422417        if MainScreen.ContactRefused(pView, 'FRANARCHY') then
    423           SmartUpdateContent
     418          SmartUpdateContent;
    424419      end
    425420      else
     
    427422  end
    428423  else
    429     Close
     424    Close;
    430425end;
    431426
     
    501496  end
    502497  else
    503     inherited
     498    inherited;
    504499end;
    505500
     
    510505    SelfReport.Government := MyRO.Government;
    511506    SelfReport.Money := MyRO.Money;
    512     SmartUpdateContent
    513   end
     507    SmartUpdateContent;
     508  end;
    514509end;
    515510
     
    520515    dec(LinesDown);
    521516    SmartUpdateContent;
    522   end
     517  end;
    523518end;
    524519
     
    529524    inc(LinesDown);
    530525    SmartUpdateContent;
    531   end
     526  end;
    532527end;
    533528
     
    540535  else
    541536    TellAIBtn.ButtonIndex := 2;
    542   SmartUpdateContent
     537  SmartUpdateContent;
    543538end;
    544539
  • trunk/LocalPlayer/Term.pas

    r387 r414  
    368368
    369369  TPriceSet = set of $00 .. $FF;
     370  TFormAction = (faClose, faEnable, faDisable, faUpdate, faSmartUpdateContent);
    370371
    371372const
     
    536537  lxmax_xxx = 130;
    537538  LeftPanelWidth = 70;
    538   LeftPanelWidth_Editor = 46;
    539539  overlap = PanelHeight - MidPanelHeight;
    540540  yTroop = PanelHeight - 83;
    541541  xPalace = 66;
    542542  yPalace = 24; // 120;
    543   xAdvisor = 108;
    544   yAdvisor = 48;
     543{  xAdvisor = 108;
     544  yAdvisor = 48;}
    545545  xUnitText = 80;
    546   PaperShade = 3;
    547546  BlinkOnTime = 12;
    548547  BlinkOffTime = 6;
     
    10961095          ChosenResearch := ModalSelectDlg.result;
    10971096          // can be researched immediately
    1098           MyData.FarTech := adNone
     1097          MyData.FarTech := adNone;
    10991098        end;
    11001099    end;
     
    11061105  ListDlg.TechChange;
    11071106  result := true;
     1107end;
     1108
     1109procedure ApplyToVisibleForms(FormAction: TFormAction);
     1110var
     1111  I: Integer;
     1112  Form: TForm;
     1113begin
     1114  for I := 0 to Screen.FormCount - 1 do begin
     1115    Form := Screen.Forms[I];
     1116    if Form.Visible and (Form is TBufferedDrawDlg) then begin
     1117      case FormAction of
     1118        faClose: Form.Close;
     1119        faEnable: Form.Enabled := True;
     1120        faDisable: Form.Enabled := False;
     1121        faUpdate: begin
     1122          if @Form.OnShow <> nil then Form.OnShow(nil);
     1123            Form.Invalidate;
     1124            Form.Update;
     1125        end;
     1126        faSmartUpdateContent: TBufferedDrawDlg(Form).SmartUpdateContent(False);
     1127      end;
     1128    end;
     1129  end;
    11081130end;
    11091131
     
    11491171    if G.RO[DipMem[me].pContact] <> nil then
    11501172    begin // close windows for next player
    1151       for i := 0 to Screen.FormCount - 1 do
    1152         if Screen.Forms[i].Visible and (Screen.Forms[i] is TBufferedDrawDlg)
    1153         then
    1154           Screen.Forms[i].Close;
     1173      ApplyToVisibleForms(faClose);
    11551174    end
    11561175    else
     
    11651184
    11661185function TMainScreen.OfferCall(var Offer: TOffer): integer;
    1167 var
    1168   i: integer;
    11691186begin
    11701187  result := Server(scDipOffer, me, 0, Offer);
     
    11771194    if G.RO[DipMem[me].pContact] <> nil then
    11781195    begin // close windows for next player
    1179       for i := 0 to Screen.FormCount - 1 do
    1180         if Screen.Forms[i].Visible and (Screen.Forms[i] is TBufferedDrawDlg)
    1181         then
    1182           Screen.Forms[i].Close;
     1196      ApplyToVisibleForms(faClose);
    11831197    end
    11841198    else
     
    18511865      begin
    18521866        NewAgeCenterTo := -1;
    1853         Loc1 := dLoc(Loc1, -dx, -dy)
     1867        Loc1 := dLoc(Loc1, -dx, -dy);
    18541868      end
    18551869      else
     
    18591873      end
    18601874    end;
    1861     Centre(Loc1)
    1862   end;
    1863 
    1864   for i := 0 to Screen.FormCount - 1 do
    1865     if Screen.Forms[i] is TBufferedDrawDlg then
    1866       Screen.Forms[i].Enabled := true;
     1875    Centre(Loc1);
     1876  end;
     1877
     1878  ApplyToVisibleForms(faEnable);
    18671879
    18681880  if ClientMode <> cResume then
     
    18751887    // first turn after anarchy -- don't show despotism palace!
    18761888    Update;
    1877     for i := 0 to Screen.FormCount - 1 do
    1878       if (Screen.Forms[i].Visible) and (Screen.Forms[i] is TBufferedDrawDlg)
    1879       then
    1880       begin
    1881         if @Screen.Forms[i].OnShow <> nil then
    1882           Screen.Forms[i].OnShow(nil);
    1883         Screen.Forms[i].Invalidate;
    1884         Screen.Forms[i].Update;
    1885       end;
     1889    ApplyToVisibleForms(faUpdate);
    18861890
    18871891    if MyRO.Happened and phGameEnd <> 0 then
     
    27082712        SaveSettings;
    27092713        CityDlg.CloseAction := None;
    2710         for i := 0 to Screen.FormCount - 1 do
    2711           if Screen.Forms[i].Visible and (Screen.Forms[i] is TBufferedDrawDlg)
    2712           then
    2713             Screen.Forms[i].Close;
     2714        ApplyToVisibleForms(faClose);
    27142715        if LogDlg.Visible then
    27152716          LogDlg.Close;
     
    37593760
    37603761var
    3761   i, p1, uix, cix, CenterLoc: integer;
     3762  p1, uix, cix, CenterLoc: integer;
    37623763  MsgItem: string;
    37633764  CityReport: TCityReport;
     
    37673768  result := false;
    37683769  if ClientMode >= scDipOffer then
    3769     exit;
    3770 
    3771   if supervising and (me <> 0) then
    3772   begin
    3773     for i := 0 to Screen.FormCount - 1 do
    3774       if Screen.Forms[i].Visible and (Screen.Forms[i] is TBufferedDrawDlg) then
    3775         Screen.Forms[i].Close; // close windows
     3770    Exit;
     3771
     3772  if supervising and (me <> 0) then begin
     3773    ApplyToVisibleForms(faClose);
    37763774    ItsMeAgain(0);
    37773775  end;
     
    39153913
    39163914  CityDlg.CloseAction := None;
    3917   if IsMultiPlayerGame then
    3918   begin // close windows for next player
    3919     for i := 0 to Screen.FormCount - 1 do
    3920       if Screen.Forms[i].Visible and (Screen.Forms[i] is TBufferedDrawDlg) then
    3921         Screen.Forms[i].Close;
    3922   end
    3923   else
    3924   begin
     3915  if IsMultiPlayerGame then begin
     3916    // Close windows for next player
     3917    ApplyToVisibleForms(faClose);
     3918  end else begin
    39253919    if CityDlg.Visible then
    39263920      CityDlg.Close;
     
    39283922      UnitStatDlg.Close;
    39293923  end;
    3930   for i := 0 to Screen.FormCount - 1 do
    3931     if Screen.Forms[i].Visible and (Screen.Forms[i] is TBufferedDrawDlg) then
    3932       Screen.Forms[i].Enabled := false;
     3924  ApplyToVisibleForms(faDisable);
    39333925
    39343926  if Server(sTurn, pTurn, 0, nil^) >= rExecuted then
     
    59005892            ShowModal;
    59015893            MyData.ToldWonders[i] := MyRO.Wonder[i];
    5902           end
     5894          end;
    59035895    end;
    59045896    if CityCaptured and (MyMap[ToLoc] and fCity <> 0) then
     
    64156407    ((p = 0) or (1 shl p and G.RO[0].Alive <> 0)) then
    64166408  begin
    6417     for i := 0 to Screen.FormCount - 1 do
    6418       if Screen.Forms[i].Visible and (Screen.Forms[i] is TBufferedDrawDlg) then
    6419         Screen.Forms[i].Close; // close windows
     6409    ApplyToVisibleForms(faClose);
    64206410    ItsMeAgain(p);
    64216411    SumCities(TaxSum, ScienceSum);
     
    67456735    else
    67466736      if result < rExecuted then
    6747         Play('INVALID')
     6737        Play('INVALID');
    67486738    end;
    67496739  end;
     
    67706760      end
    67716761      else
    6772         Server(sAbandonMap, me, 0, nil^)
     6762        Server(sAbandonMap, me, 0, nil^);
    67736763    end
    67746764    else
     
    67816771            Server(sResign, 0, 0, nil^);
    67826772          mrOK:
    6783             Server(sBreak, 0, 0, nil^)
     6773            Server(sBreak, 0, 0, nil^);
    67846774        end
    67856775      end
    67866776      else
    6787         Server(sResign, 0, 0, nil^)
     6777        Server(sResign, 0, 0, nil^);
    67886778    end
    67896779  else if Sender = mEmpire then
     
    68116801          CityOptimizer_BeginOfTurn;
    68126802          RevolutionChanged := true;
    6813         end
     6803        end;
    68146804      end
    68156805      else
     
    68346824      if RevolutionChanged then
    68356825        UpdateViews(true);
    6836     end
     6826    end;
    68376827  end
    68386828  else if Sender = mWebsite then
     
    68476837      MapValid := false;
    68486838      PaintAllMaps;
    6849     end
     6839    end;
    68506840  end
    68516841  else if Sender = mJump then
     
    68716861        MyMap[MyUn[UnFocus].Loc] and fTerrain)
    68726862    else
    6873       EnhanceDlg.ShowNewContent(wmPersistent)
     6863      EnhanceDlg.ShowNewContent(wmPersistent);
    68746864  end
    68756865  else if Sender = mCityTypes then
     
    71547144            begin
    71557145              MyUn[uix].Status := MyUn[uix].Status or usWaiting;
    7156               NewFocus := uix
     7146              NewFocus := uix;
    71577147            end;
    71587148          end;
     
    71617151            SetUnFocus(NewFocus);
    71627152            SetTroopLoc(Loc);
    7163             PanelPaint
     7153            PanelPaint;
    71647154          end;
    71657155        end
    71667156      else if Sender = mSelectTransport then
    7167         Server(sSelectTransport, me, UnFocus, nil^)
     7157        Server(sSelectTransport, me, UnFocus, nil^);
    71687158end;
    71697159
     
    79987988
    79997989procedure TMainScreen.SetTileSize(TileSize: TTileSize; Loc: Integer; MapPos: TPoint);
    8000 var
    8001   i: integer;
    80027990begin
    80037991  MainMap.TileSize := TileSize;
     
    80067994  SetMapPos(Loc, MapPos);
    80077995  PaintAllMaps;
    8008   for i := 0 to Screen.FormCount - 1 do
    8009     if Screen.Forms[i].Visible and (Screen.Forms[i] is TBufferedDrawDlg) then
    8010       TBufferedDrawDlg(Screen.Forms[i]).SmartUpdateContent(false);
     7996  ApplyToVisibleForms(faSmartUpdateContent);
    80117997end;
    80127998
Note: See TracChangeset for help on using the changeset viewer.