⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 natstat.pas

📁 类似文明的游戏源代码。
💻 PAS
📖 第 1 页 / 共 2 页
字号:
        else s:=IntToStr(MyRO.Tribute[pView]);
        DLine(Canvas,130+9,InnerWidth-8,43+16,
          InnerTex.clBevelShade,InnerTex.clBevelLight);
        LoweredTextOut(Canvas,-1,InnerTex,282+32,43,s);
        end
      end
    else
      RisedTextOut(Canvas,130+8,4,Phrases.Lookup('FRNOCONTACT'));
    end;

  if ContactEnabled then
    RisedTextOut(Canvas,64,73,Format(Phrases.Lookup('FROURATT'),
      [Phrases.Lookup('ATTITUDE',MyRO.Attitude[pView])]));

  if Mode<>mDialog then
    begin
    Fill(Canvas,0,64+37,InnerWidth,InnerHeight-(64+37),0,0,InnerTex);
    DLine(Canvas,2,InnerWidth-3,InnerHeight-46,InnerTex.clBevelLight,
      InnerTex.clBevelShade);
    if Mode=mSelf then
      DLine(Canvas,PanelWidth+2,InnerWidth-3,64+35,InnerTex.clBevelLight,
        InnerTex.clBevelShade);
    if Report.TurnOfCivilReport>=0 then
      begin // print civil report
      s:=Phrases.Lookup('FRCIVILREP');
      RisedTextOut(Canvas,InnerWidth-12-Canvas.TextWidth(s),105,s);
      if (Mode=mStat) and (1 shl pView and MyRO.Alive<>0) then
        begin
        s:='('+TurnToString(Report.TurnOfCivilReport)+')';
        RisedTextOut(Canvas,InnerWidth-12-Canvas.TextWidth(s),123,s);
        end;
      s:=Format(Phrases.Lookup('FRGOVMONEY'),
        [Phrases.Lookup('GOVERNMENT',Report.Government),Report.Money]);
      LoweredTextOut(Canvas,-1,InnerTex,12,117,s);
      Sprite(offscreen,HGrSystem,15+Canvas.TextWidth(s),117+5,10,10,132,115);
      WriteStat(stPop,12,148);
      WriteStat(stTerritory,12,168);
      WriteStat(stScience,InnerWidth div 2+8,148);
      WriteStat(stExplore,InnerWidth div 2+8,168);

      // display foreign relations
      for i:=0 to 2 do xout[i]:=12;
      for p1:=0 to nPl-1 do
        if (p1<>me) and (1 shl p1 and MyRO.Alive<>0)
          and (Report.Treaty[p1]>trNoContact) then
          begin
          s:=Tribe[p1].TPhrase('SHORTNAME');
          i:=0;
          while (i<3) and (xout[i]+18+Canvas.TextWidth(s)>374) do inc(i);
          if i<3 then
            begin
            yout:=198+i*20;
            Dump(offscreen,HGrSystem,xout[i],yout+2,14,14,
              67+15*Report.Treaty[p1],100);
            LoweredTextOut(Canvas,-1,InnerTex,xout[i]+18,yout,s);
            inc(xout[i], Canvas.TextWidth(s)+32)
            end
          end
      end
    else
      begin
      s:=Phrases.Lookup('FRNOCIVILREP');
      RisedTextOut(Canvas,InnerWidth-12-Canvas.TextWidth(s),64+37+4,s);
      end;
    if Report.TurnOfMilReport>=0 then
      begin
      s:=Phrases.Lookup('FRMILREP');
      RisedTextOut(Canvas,InnerWidth-12-Canvas.TextWidth(s),InnerHeight-40,s);
      if (Mode=mStat) and (1 shl pView and MyRO.Alive<>0) then
        begin
        s:='('+TurnToString(Report.TurnOfMilReport)+')';
        RisedTextOut(Canvas,InnerWidth-12-Canvas.TextWidth(s),InnerHeight-22,s);
        end;
      WriteStat(stMil,12,InnerHeight-28);
      end
    else
      begin
      s:=Phrases.Lookup('FRNOMILREP');
      RisedTextOut(Canvas,InnerWidth-12-Canvas.TextWidth(s),InnerHeight-42,s);
      end
    end
  else
    begin
    Fill(Canvas,1,64+38,41,InnerHeight-(64+37+2),0,0,OuterTex);
    Frame(Canvas,0,64+37,42,InnerHeight-1,OuterTex.clBevelLight,
      OuterTex.clBevelShade);
    Fill(Canvas,43,64+37,InnerWidth-43,InnerHeight-(64+37),0,0,InnerTex);
    SplitText(false);
    end;

  Canvas.Font.Assign(UniFont[ftTiny]);
  if Mode<>mSelf then
    begin
    case Report.Credibility of
      0..49: i:= 3; 50..90: i:=0; 91..100: i:=1; end;
    PaintProgressBar(Canvas,i,12,23,(Report.Credibility+2) div 5,0,20,OuterTex);
    s:=IntToStr(Report.Credibility);
    RisedTextOut(Canvas,12+10-(Canvas.TextWidth(s)+1) div 2,6,s);
    end;
  if (Mode=mSelf) or (G.Difficulty[me]>0) then
    begin
    case MyRO.Credibility of
      0..49: i:= 3; 50..90: i:=0; 91..100: i:=1; end;
    PaintProgressBar(Canvas,i,12,87,(MyRO.Credibility+2) div 5,0,20,OuterTex);
    s:=IntToStr(MyRO.Credibility);
    RisedTextOut(Canvas,12+10-(Canvas.TextWidth(s)+1) div 2,70,s);
    end
  end;

StatBtn.Visible:=ContactEnabled and (MyRO.Happened and phGameEnd=0);
DialogBtn.Visible:=ContactEnabled and (MyRO.Happened and phGameEnd=0);
AttUpBtn.Visible:=ContactEnabled;
AttDownBtn.Visible:=ContactEnabled;
MilitaryBtn.Visible:= (Mode=mStat) and (Report.TurnOfMilReport>=0);
BreakBtn.Visible:= (Mode=mDialog) and (ClientMode<>scDipBreak);
OfferBtn.Visible:= (Mode=mDialog) and (ClientMode<>scDipCancelTreaty)
  and (ClientMode<>scDipBreak);
DipCancelTreatyBtn.Visible:= (Mode=mDialog)
  and (MyRO.Treaty[DipMem[me].pContact]>=trPeace);
AckBtn.Visible:= (Mode=mDialog)
  and ((ClientMode=scDipCancelTreaty) or (ClientMode=scDipBreak)
  or (ClientMode=scDipOffer) and (Server(scDipAccept-sExecute,me,0,nil^)>=rExecuted));
if ClientMode=scDipOffer then AckBtn.Hint:=Phrases.Lookup('BTN_ACCEPT')
else AckBtn.Hint:=Phrases.Lookup('BTN_NOTICE');

FreeMem(List);
MarkUsedOffscreen(InnerWidth,InnerHeight);
end; {OffscreenPaint}

procedure TNatStatDlg.CloseBtnClick(Sender: TObject);
begin
Close
end;

procedure TNatStatDlg.StatBtnClick(Sender: TObject);
begin
Mode:=mStat;
ShowPVSB(sb,false);
DialogBtn.Down:=false;
OffscreenPaint;
SmartInvalidate
end;

procedure TNatStatDlg.DialogBtnClick(Sender: TObject);
var
ContactResult: integer;
AutoSwitch: boolean;
begin
if DipMem[me].pContact>=0 then
  begin
  AutoSwitch:= pView<>DipMem[me].pContact;
  pView:=DipMem[me].pContact;
  Mode:=mDialog;
  ShowPVSB(sb,true);
  StatBtn.Down:=false;
  Caption:=Tribe[pView].TPhrase('TITLE_NATION');
  OffscreenPaint;
  Invalidate;
  if AutoSwitch then SimpleMessage(Phrases.Lookup('FROPEN'),'INVALID');
  end
else
  begin
  ContactResult:=MainScreen.DipCall(scContact+pView shl 4);
  if ContactResult<rExecuted then
    begin
    DialogBtn.Down:=false;
    if ContactResult=eColdWar then
      SimpleMessage(Phrases.Lookup('FRCOLDWAR'),'INVALID')
    else if MyRO.Government=gAnarchy then
      SimpleMessage(Tribe[me].TPhrase('FRMYANARCHY'),'INVALID')
    else SimpleMessage(Tribe[pView].TPhrase('FRANARCHY'),'INVALID');
    end
  end
end;

procedure TNatStatDlg.ToggleBtnClick(Sender: TObject);
var
p1: integer;
m: TMenuItem;
begin
while Popup.Items.Count>0 do Popup.Items.Delete(0);
for p1:=0 to nPl-1 do if MyRO.Treaty[p1]>=trNone then
  begin
  m:=TMenuItem.Create(Popup);
  m.RadioItem:=true;
  m.Caption:=Tribe[p1].TPhrase('TITLE_NATION');
  m.Tag:=p1;
  m.OnClick:=PlayerClick;
  if p1=pView then m.Checked:=true;
  Popup.Items.Add(m);
  end;
Popup.Popup(Left+ToggleBtn.Left, Top+ToggleBtn.Top+ToggleBtn.Height);
end;

procedure TNatStatDlg.PlayerClick(Sender: TObject);
begin
pView:=TComponent(Sender).Tag;
Mode:=mStat;
ShowPVSB(sb,false);
StatBtn.Down:=true;
DialogBtn.Down:=false;
Caption:=Tribe[pView].TPhrase('TITLE_NATION');
OffscreenPaint;
Invalidate
end;

procedure TNatStatDlg.FormKeyDown(Sender: TObject; var Key: word;
  Shift: TShiftState);
begin
if (Mode<>mSelf) and (Key=VK_F9) then
  begin // toggle nation
  repeat pView:=(pView+1) mod nPl until MyRO.Treaty[pView]>=trNone;
  Tag:=pView;
  PlayerClick(self); // no, this is not nice
  end
else if Key=VK_ESCAPE then Close
else MainScreen.FormKeyDown(Sender, Key, Shift);
end;

procedure TNatStatDlg.FormCloseQuery(Sender: TObject;
  var CanClose: boolean);
begin
if (DipMem[me].pContact>=0) and not Closable then
  begin
  if (Mode<>mDialog) or (pView<>DipMem[me].pContact) then
    begin
    pView:=DipMem[me].pContact;
    Caption:=Tribe[pView].TPhrase('TITLE_NATION');
    Mode:=mDialog;
    ShowPVSB(sb,true);
    StatBtn.Down:=false;
    DialogBtn.Down:=true;
    OffscreenPaint;
    Invalidate;
    Update;
    end;
  SimpleMessage(Phrases.Lookup('FROPEN'),'INVALID');
  CanClose:=false
  end
end;

procedure TNatStatDlg.CloseNow;
begin
Closable:=true;
Close
end;

procedure TNatStatDlg.DecisionBtnClick(Sender: TObject);
var
DipCommand: integer;
s: string;
DummyOffer: TOffer;
begin
if Sender=BreakBtn then DipCommand:=scDipBreak
else if Sender=DipCancelTreatyBtn then DipCommand:=scDipCancelTreaty
else // if Sender=AckBtn then
  if ClientMode=scDipOffer then DipCommand:=scDipAccept
  else DipCommand:=scDipNotice;
s:=DipCommandToString(me,DipMem[me].pContact, MyRO.Treaty[DipMem[me].pContact],
  ClientMode, DipCommand, ReceivedOffer, DummyOffer);
if SimpleQuery(mkOKCancel,Format(Phrases.Lookup('FRWESAY'),[s]),'')=mrOK then
  if MainScreen.DipCall(DipCommand)>=rExecuted then
    DialogText[me]:=DialogText[me]+'\'+char(64+me)+Format(Phrases.Lookup('FRSAY'),[s]);
end;

procedure TNatStatDlg.OfferBtnClick(Sender: TObject);
var
s: string;
begin
with MessgExDlg do
  begin
  Kind:=mkOffer;
  ShowModal;
  s:=DipCommandToString(me,DipMem[me].pContact,
    MyRO.Treaty[DipMem[me].pContact],ClientMode, scDipOffer, ReceivedOffer, Offer);
  if ModalResult=mrOK then
    if MainScreen.OfferCall(Offer)>=rExecuted then
      DialogText[me]:=DialogText[me]+'\'+char(64+me)+Format(Phrases.Lookup('FRSAY'),[s]);
  end
end;

procedure TNatStatDlg.ShowNow;
begin
if Visible then begin FormShow(nil); Invalidate end else Show
end;

procedure TNatStatDlg.MilitaryBtnClick(Sender: TObject);
begin
SelectDlg.Caption:=Tribe[pView].TPhrase('TITLE_MODELS');
SelectDlg.Kind:=kEModels;
SelectDlg.pOwner:=pView;
SelectDlg.ShowModal;
end;

procedure TNatStatDlg.AttUpBtnClick(Sender: TObject);
begin
if MyRO.Attitude[pView]<nAttitude-1 then
  begin
  Server(sSetAttitude+pView shl 4,me,MyRO.Attitude[pView]+1,nil^);
  OffscreenPaint;
  SmartInvalidate
  end
end;

procedure TNatStatDlg.AttDownBtnClick(Sender: TObject);
begin
if MyRO.Attitude[pView]>0 then
  begin
  Server(sSetAttitude+pView shl 4,me,MyRO.Attitude[pView]-1,nil^);
  OffscreenPaint;
  SmartInvalidate
  end
end;

procedure TNatStatDlg.RevoBtnClick(Sender: TObject);
var
changed: boolean;
begin
if not AltGovs then
  begin
  SimpleMessage(Phrases.Lookup('NOALTGOVS'),''{!!!sound});
  exit;
  end;

changed:=false;
if MyRO.Happened and phChangeGov<>0 then
  begin
  SelectDlg.Caption:=Phrases.Lookup('TITLE_GOV');
  SelectDlg.Kind:=kGov;
  SelectDlg.ShowModal;
  if SelectDlg.result>=0 then
    begin
    Play('GOV');
    Server(sSetGovernment,me,SelectDlg.result,nil^);
    changed:=true;
    end
  end
else
  begin // revolution!
  if SimpleQuery(mkYesNo,Tribe[me].TPhrase('REVOLUTION'),'')=mrOK then
    begin
    Server(sRevolution,me,0,nil^);
    RevoBtn.Visible:=false;
    changed:=true
    end
  end;
if changed then
  begin
  SelfReport.Government:=MyRO.Government;
  MainScreen.UpdateIncome;
  OffscreenPaint;
  SmartInvalidate;
  end
end;

procedure TNatStatDlg.TaxLuxBtnClick(Sender: TObject);
var
NewTax, NewLux: integer;
begin
NewTax:=MyRO.TaxRate div 10;
NewLux:=MyRO.LuxRate div 10;
if (Sender=TaxUpBtn)
  or (Sender=ScienceDownBtn) and (MyRO.Wonder[woMich].EffectiveOwner=me) then
  begin
  if NewTax<10 then inc(NewTax);
  if NewTax+NewLux>10 then dec(NewLux);
  end
else if ((Sender=TaxDownBtn)
  or (Sender=ScienceUpBtn) and (MyRO.Wonder[woMich].EffectiveOwner=me))
  and (NewTax>0) then dec(NewTax)
else if Sender=ScienceUpBtn then
  begin
  if NewLux>0 then dec(NewLux)
  else if NewTax>0 then dec(NewTax);
  end
else if (Sender=ScienceDownBtn) and (NewLux+NewTax<100) then inc(NewLux);
if Server(sSetRates,me,NewTax+NewLux shl 4,nil^)<>eNotChanged then
  begin
  MainScreen.UpdateIncome;
  OffscreenPaint;
  SmartInvalidate;
  end
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -