Ignore:
Timestamp:
Jan 7, 2017, 11:32:14 AM (8 years ago)
Author:
chronos
Message:
  • Modified: Formated all project source files using Delphi formatter as original indentation and other formatting was really bad.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Nego.pas

    r2 r6  
    11{$INCLUDE switches}
    2 
    32unit Nego;
    43
     
    65
    76uses
    8   ScreenTools,BaseWin,Protocol,Term,
     7  ScreenTools, BaseWin, Protocol, Term,
    98
    109  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, ButtonA,
    1110  ButtonBase, ButtonB, ButtonC, ButtonN;
    1211
    13 
    1412const
    15 MaxHistory=62;
     13  MaxHistory = 62;
    1614
    1715type
    18   THistory=record
     16  THistory = record
    1917    n: integer;
    20     Text: array[0..MaxHistory-1] of ansistring;
    21     end;
     18    Text: array [0 .. MaxHistory - 1] of ansistring;
     19  end;
    2220
    2321  TNegoDlg = class(TBufferedDrawDlg)
     
    5654    procedure FormCreate(Sender: TObject);
    5755    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
    58       Shift: TShiftState; X, Y: Integer);
     56      Shift: TShiftState; X, Y: integer);
    5957    procedure OkBtnClick(Sender: TObject);
    6058    procedure BwdBtnClick(Sender: TObject);
    6159    procedure FwdBtnClick(Sender: TObject);
    6260    procedure CloseBtnClick(Sender: TObject);
    63     procedure FormKeyDown(Sender: TObject; var Key: Word;
    64       Shift: TShiftState);
     61    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    6562    procedure FormShow(Sender: TObject);
    6663    procedure WantClick(Sender: TObject);
     
    7976    CurrentOffer: TOffer;
    8077    MyAllowed, OppoAllowed: TPriceSet;
    81     CommandAllowed: set of scDipNotice-scDipStart..scDipBreak-scDipStart;
    82     History: array[0..nPl-1] of THistory;
     78    CommandAllowed: set of scDipNotice - scDipStart .. scDipBreak - scDipStart;
     79    History: array [0 .. nPl - 1] of THistory;
    8380    RomanFont: TFont;
    84     Costs,Delivers: array[0..11] of cardinal;
     81    Costs, Delivers: array [0 .. 11] of cardinal;
    8582    procedure ResetCurrentOffer;
    8683    procedure BuildCurrentOffer;
    8784    procedure FindAllowed;
    8885    procedure SplitText(Text: string; Bounds: TRect);
    89     procedure PaintNationPicture(x,y,p: integer);
     86    procedure PaintNationPicture(X, Y, p: integer);
    9087    procedure SetButtonStates;
    9188  end;
     
    9794
    9895uses
    99 Messg,ClientTools,Diplomacy, Inp, Select, NatStat, Help,Tribes, MessgEx;
     96  Messg, ClientTools, Diplomacy, Inp, Select, NatStat, Help, Tribes, MessgEx;
    10097
    10198{$R *.DFM}
    10299
    103100const
    104 xPadC=140; yPadC=427;
    105 xPad0=140; yPad0=13;
    106 xPad1=334; yPad1=13;
    107 wIcon=40; hIcon=40;
    108 wText=300; hText=256;
    109 xText0=14; yText0=154;
    110 xText1=326; yText1=154;
    111 xNationPicture0=20; xNationPicture1=556;
    112 yNationPicture=40;
    113 yAttitude=148;
    114 xCred0=42; yCred0=92;
    115 xCred1=578; yCred1=92;
    116 PaperShade=3;
    117 PaperBorder_Left=12; PaperBorder_Right=8;
    118 ListIndent=24;
    119 
    120 opLowTreaty=$FE000000;
    121 
    122 RomanNo: array[0..15] of string=
    123 ('I','II','III','IV','V','VI','VII','VIII','IX','X','XI','XII','XIII','XIV','XV','XVI');
    124 
    125 ButtonPrice: array[0..11] of cardinal=
    126 (opChoose,opCivilReport,opMilReport,opMap,opAllTech,opAllTech,opAllModel,opMoney,
    127   opTreaty,opLowTreaty,opShipParts,opShipParts);
    128 
     101  xPadC = 140;
     102  yPadC = 427;
     103  xPad0 = 140;
     104  yPad0 = 13;
     105  xPad1 = 334;
     106  yPad1 = 13;
     107  wIcon = 40;
     108  hIcon = 40;
     109  wText = 300;
     110  hText = 256;
     111  xText0 = 14;
     112  yText0 = 154;
     113  xText1 = 326;
     114  yText1 = 154;
     115  xNationPicture0 = 20;
     116  xNationPicture1 = 556;
     117  yNationPicture = 40;
     118  yAttitude = 148;
     119  xCred0 = 42;
     120  yCred0 = 92;
     121  xCred1 = 578;
     122  yCred1 = 92;
     123  PaperShade = 3;
     124  PaperBorder_Left = 12;
     125  PaperBorder_Right = 8;
     126  ListIndent = 24;
     127
     128  opLowTreaty = $FE000000;
     129
     130  RomanNo: array [0 .. 15] of string = ('I', 'II', 'III', 'IV', 'V', 'VI',
     131    'VII', 'VIII', 'IX', 'X', 'XI', 'XII', 'XIII', 'XIV', 'XV', 'XVI');
     132
     133  ButtonPrice: array [0 .. 11] of cardinal = (opChoose, opCivilReport,
     134    opMilReport, opMap, opAllTech, opAllTech, opAllModel, opMoney, opTreaty,
     135    opLowTreaty, opShipParts, opShipParts);
    129136
    130137procedure TNegoDlg.FormCreate(Sender: TObject);
    131138var
    132 cix: integer;
    133 begin
    134 InitButtons();
    135 for cix:=0 to ComponentCount-1 do
    136   if Components[cix] is TButtonN then with TButtonN(Components[cix]) do
    137     begin
    138     Graphic:=GrExt[HGrSystem].Data;
    139     Mask:=GrExt[HGrSystem].Mask;
    140     BackGraphic:=GrExt[HGrSystem2].Data;
    141     case Tag shr 8 of
    142       1: SmartHint:=Phrases.Lookup('WANT', ButtonIndex-6);
    143       2: SmartHint:=Phrases.Lookup('OFFER', ButtonIndex-6);
     139  cix: integer;
     140begin
     141  InitButtons();
     142  for cix := 0 to ComponentCount - 1 do
     143    if Components[cix] is TButtonN then
     144      with TButtonN(Components[cix]) do
     145      begin
     146        Graphic := GrExt[HGrSystem].Data;
     147        Mask := GrExt[HGrSystem].Mask;
     148        BackGraphic := GrExt[HGrSystem2].Data;
     149        case Tag shr 8 of
     150          1:
     151            SmartHint := Phrases.Lookup('WANT', ButtonIndex - 6);
     152          2:
     153            SmartHint := Phrases.Lookup('OFFER', ButtonIndex - 6);
     154        end;
    144155      end;
     156
     157  fillchar(History, sizeof(History), 0);
     158  RomanFont := TFont.Create;
     159  RomanFont.Name := 'Times New Roman';
     160  RomanFont.Size := Round(144 * 72 / RomanFont.PixelsPerInch);
     161  RomanFont.Color := Colors.Canvas.Pixels[clkMisc, cliPaper];
     162  HelpContext := 'DIPLOMACY';
     163  OkBtn.Caption := Phrases.Lookup('BTN_OK');
     164  AcceptBtn.SmartHint := Phrases.Lookup('BTN_ACCEPT');
     165  ExitBtn.SmartHint := Phrases.Lookup('BTN_BREAK');
     166  CancelTreatyBtn.SmartHint := Phrases.Lookup('BTN_CNTREATY');
     167end;
     168
     169procedure TNegoDlg.FormShow(Sender: TObject);
     170begin
     171  OffscreenPaint;
     172end;
     173
     174procedure TNegoDlg.ResetCurrentOffer;
     175var
     176  i: integer;
     177begin
     178  CurrentOffer.nDeliver := 0;
     179  CurrentOffer.nCost := 0;
     180  for i := 0 to 11 do
     181    Costs[i] := $FFFFFFFF;
     182  for i := 0 to 11 do
     183    Delivers[i] := $FFFFFFFF;
     184end;
     185
     186procedure TNegoDlg.ShowNewContent(NewMode: integer);
     187begin
     188  inherited ShowNewContent(NewMode);
     189  SetButtonStates;
     190  if (ClientMode = scDipCancelTreaty) or (ClientMode = scDipBreak) then
     191    PassBtn.SmartHint := Phrases.Lookup('BTN_NOTICE')
     192  else
     193    PassBtn.SmartHint := Phrases.Lookup('BTN_PASS');
     194  case MyRO.Treaty[DipMem[me].pContact] of
     195    trNone:
     196      begin
     197        WantHiTreatyBtn.SmartHint := Phrases.Lookup('BTN_WANTPEACE');
     198        OfferHiTreatyBtn.SmartHint := Phrases.Lookup('BTN_OFFERPEACE');
     199        // WantLoTreatyBtn.SmartHint:=Phrases.Lookup('BTN_WANTCEASEFIRE');
     200        // OfferLoTreatyBtn.SmartHint:=Phrases.Lookup('BTN_OFFERCEASEFIRE');
     201      end;
     202    { trCeasefire:
     203      begin
     204      WantHiTreatyBtn.SmartHint:=Phrases.Lookup('BTN_WANTPEACE');
     205      OfferHiTreatyBtn.SmartHint:=Phrases.Lookup('BTN_OFFERPEACE');
     206      end; }
     207    trPeace:
     208      begin
     209        WantHiTreatyBtn.SmartHint := Phrases.Lookup('BTN_WANTFRIENDLY');
     210        OfferHiTreatyBtn.SmartHint := Phrases.Lookup('BTN_OFFERFRIENDLY');
     211        // WantLoTreatyBtn.SmartHint:=Phrases.Lookup('BTN_WANTENDPEACE');
     212        // OfferLoTreatyBtn.SmartHint:=Phrases.Lookup('BTN_OFFERENDPEACE');
     213      end;
     214    trFriendlyContact:
     215      begin
     216        WantHiTreatyBtn.SmartHint := Phrases.Lookup('BTN_WANTALLIANCE');
     217        OfferHiTreatyBtn.SmartHint := Phrases.Lookup('BTN_OFFERALLIANCE');
     218      end;
     219    { trAlliance:
     220      begin
     221      WantLoTreatyBtn.SmartHint:=Phrases.Lookup('BTN_WANTENDALLIANCE');
     222      OfferLoTreatyBtn.SmartHint:=Phrases.Lookup('BTN_OFFERENDALLIANCE');
     223      end; }
     224  end;
     225end;
     226
     227procedure TNegoDlg.Start;
     228begin
     229  if ClientMode <> scDipStart then
     230    with History[me] do
     231    begin
     232      if n = MaxHistory then
     233      begin
     234        move(Text[2], Text[0], (MaxHistory - 2) * sizeof(integer));
     235        dec(n, 2);
     236      end;
     237      Text[n] := copy(DipCommandToString(DipMem[me].pContact, me,
     238        DipMem[me].FormerTreaty, DipMem[me].SentCommand, ClientMode,
     239        DipMem[me].SentOffer, ReceivedOffer), 1, 255);
     240      inc(n);
    145241    end;
    146 
    147 fillchar(History, sizeof(History), 0);
    148 RomanFont:=TFont.Create;
    149 RomanFont.Name:='Times New Roman';
    150 RomanFont.Size:=Round(144 * 72/RomanFont.PixelsPerInch);
    151 RomanFont.Color:=Colors.Canvas.Pixels[clkMisc,cliPaper];
    152 HelpContext:='DIPLOMACY';
    153 OkBtn.Caption:=Phrases.Lookup('BTN_OK');
    154 AcceptBtn.SmartHint:=Phrases.Lookup('BTN_ACCEPT');
    155 ExitBtn.SmartHint:=Phrases.Lookup('BTN_BREAK');
    156 CancelTreatyBtn.SmartHint:=Phrases.Lookup('BTN_CNTREATY');
    157 end;
    158 
    159 procedure TNegoDlg.FormShow(Sender: TObject);
    160 begin
    161 OffscreenPaint;
    162 end;
    163 
    164 procedure TNegoDlg.ResetCurrentOffer;
    165 var
    166 i: integer;
    167 begin
    168 CurrentOffer.nDeliver:=0;
    169 CurrentOffer.nCost:=0;
    170 for i:=0 to 11 do
    171   Costs[i]:=$FFFFFFFF;
    172 for i:=0 to 11 do
    173   Delivers[i]:=$FFFFFFFF;
    174 end;
    175 
    176 procedure TNegoDlg.ShowNewContent(NewMode: integer);
    177 begin
    178 inherited ShowNewContent(NewMode);
    179 SetButtonStates;
    180 if (ClientMode=scDipCancelTreaty) or (ClientMode=scDipBreak) then
    181   PassBtn.SmartHint:=Phrases.Lookup('BTN_NOTICE')
    182 else PassBtn.SmartHint:=Phrases.Lookup('BTN_PASS');
    183 case MyRO.Treaty[DipMem[me].pContact] of
    184   trNone:
    185     begin
    186     WantHiTreatyBtn.SmartHint:=Phrases.Lookup('BTN_WANTPEACE');
    187     OfferHiTreatyBtn.SmartHint:=Phrases.Lookup('BTN_OFFERPEACE');
    188     //WantLoTreatyBtn.SmartHint:=Phrases.Lookup('BTN_WANTCEASEFIRE');
    189     //OfferLoTreatyBtn.SmartHint:=Phrases.Lookup('BTN_OFFERCEASEFIRE');
    190     end;
    191   {trCeasefire:
    192     begin
    193     WantHiTreatyBtn.SmartHint:=Phrases.Lookup('BTN_WANTPEACE');
    194     OfferHiTreatyBtn.SmartHint:=Phrases.Lookup('BTN_OFFERPEACE');
    195     end;}
    196   trPeace:
    197     begin
    198     WantHiTreatyBtn.SmartHint:=Phrases.Lookup('BTN_WANTFRIENDLY');
    199     OfferHiTreatyBtn.SmartHint:=Phrases.Lookup('BTN_OFFERFRIENDLY');
    200     //WantLoTreatyBtn.SmartHint:=Phrases.Lookup('BTN_WANTENDPEACE');
    201     //OfferLoTreatyBtn.SmartHint:=Phrases.Lookup('BTN_OFFERENDPEACE');
    202     end;
    203   trFriendlyContact:
    204     begin
    205     WantHiTreatyBtn.SmartHint:=Phrases.Lookup('BTN_WANTALLIANCE');
    206     OfferHiTreatyBtn.SmartHint:=Phrases.Lookup('BTN_OFFERALLIANCE');
    207     end;
    208   {trAlliance:
    209     begin
    210     WantLoTreatyBtn.SmartHint:=Phrases.Lookup('BTN_WANTENDALLIANCE');
    211     OfferLoTreatyBtn.SmartHint:=Phrases.Lookup('BTN_OFFERENDALLIANCE');
    212     end;}
    213   end;
    214 end;
    215 
    216 procedure TNegoDlg.Start;
    217 begin
    218 if ClientMode<>scDipStart then with History[me] do
    219   begin
    220   if n=MaxHistory then
    221     begin
    222     move(Text[2], Text[0], (MaxHistory-2)*sizeof(integer));
    223     dec(n,2);
    224     end;
    225   Text[n]:=copy(DipCommandToString(DipMem[me].pContact,me,
    226     DipMem[me].FormerTreaty, DipMem[me].SentCommand, ClientMode,
    227     DipMem[me].SentOffer, ReceivedOffer),1,255);
    228   inc(n);
    229   end;
    230 assert(History[me].n mod 2=1);
    231 
    232 Page:=History[me].n;
    233 FindAllowed;
    234 ResetCurrentOffer;
    235 
    236 (*if (ClientMode=scDipOffer) and (ReceivedOffer.nDeliver=1)
    237   and (ReceivedOffer.nCost=0) and (ReceivedOffer.Price[0] and opMask=opTreaty) then
    238   begin // prepare to demand price for treaty
    239   CurrentOffer.nDeliver:=1;
    240   CurrentOffer.Price[0]:=ReceivedOffer.Price[0];
    241   CurrentOffer.nCost:=0;
    242   end
    243 else
    244   begin
    245   if (ClientMode=scDipOffer) and (ReceivedOffer.nCost>0) then
     242  assert(History[me].n mod 2 = 1);
     243
     244  Page := History[me].n;
     245  FindAllowed;
     246  ResetCurrentOffer;
     247
     248  (* if (ClientMode=scDipOffer) and (ReceivedOffer.nDeliver=1)
     249    and (ReceivedOffer.nCost=0) and (ReceivedOffer.Price[0] and opMask=opTreaty) then
     250    begin // prepare to demand price for treaty
     251    CurrentOffer.nDeliver:=1;
     252    CurrentOffer.Price[0]:=ReceivedOffer.Price[0];
     253    CurrentOffer.nCost:=0;
     254    end
     255    else
     256    begin
     257    if (ClientMode=scDipOffer) and (ReceivedOffer.nCost>0) then
    246258    begin
    247259    CurrentOffer.nDeliver:=1;
    248260    CurrentOffer.Price[0]:=ReceivedOffer.Price[ReceivedOffer.nDeliver]
    249261    end
    250   else CurrentOffer.nDeliver:=0;
    251   if (ClientMode=scDipOffer) and (ReceivedOffer.nDeliver>0) then
     262    else CurrentOffer.nDeliver:=0;
     263    if (ClientMode=scDipOffer) and (ReceivedOffer.nDeliver>0) then
    252264    begin
    253265    CurrentOffer.nCost:=1;
    254266    CurrentOffer.Price[CurrentOffer.nDeliver]:=ReceivedOffer.Price[0]
    255267    end
    256   else CurrentOffer.nCost:=0
    257   end;*)
    258 DipCommand:=-1;
    259 ShowNewContent(wmPersistent);
     268    else CurrentOffer.nCost:=0
     269    end; *)
     270  DipCommand := -1;
     271  ShowNewContent(wmPersistent);
    260272end;
    261273
    262274procedure TNegoDlg.SplitText(Text: string; Bounds: TRect);
    263275var
    264 nLines,Line,Start,Stop,OrdinaryStop,Indent,y: integer;
    265 s: string;
    266 preview, Dot: boolean;
    267 begin
    268 for preview:=true downto false do
    269   begin
    270   Start:=1;
    271   Line:=0;
    272   Indent:=0;
    273   while Start<Length(Text) do
    274     begin
    275     Dot:=false;
    276     if (Start=1) or (Text[Start-1]='\') then
    277       if Text[Start]='-' then
     276  nLines, Line, Start, Stop, OrdinaryStop, Indent, Y: integer;
     277  s: string;
     278  preview, Dot: boolean;
     279begin
     280  for preview := true downto false do
     281  begin
     282    Start := 1;
     283    Line := 0;
     284    Indent := 0;
     285    while Start < Length(Text) do
     286    begin
     287      Dot := false;
     288      if (Start = 1) or (Text[Start - 1] = '\') then
     289        if Text[Start] = '-' then
    278290        begin
    279         Indent:=ListIndent;
    280         inc(Start);
    281         if Start=Length(Text) then break;
    282         Dot:=true;
     291          Indent := ListIndent;
     292          inc(Start);
     293          if Start = Length(Text) then
     294            break;
     295          Dot := true;
    283296        end
    284       else Indent:=0;
    285     Stop:=Start;
    286     while (Stop<Length(Text)) and (Text[Stop]<>'\') do
    287       begin
    288       inc(Stop);
    289       if BiColorTextWidth(Offscreen.Canvas,Copy(Text,Start,Stop-Start+1))
    290         >Bounds.Right-Bounds.Left-PaperBorder_Left-PaperBorder_Right-Indent then
    291         begin dec(Stop); break end;
     297        else
     298          Indent := 0;
     299      Stop := Start;
     300      while (Stop < Length(Text)) and (Text[Stop] <> '\') do
     301      begin
     302        inc(Stop);
     303        if BiColorTextWidth(Offscreen.Canvas,
     304          copy(Text, Start, Stop - Start + 1)) > Bounds.Right - Bounds.Left -
     305          PaperBorder_Left - PaperBorder_Right - Indent then
     306        begin
     307          dec(Stop);
     308          break
     309        end;
    292310      end;
    293     if Stop<>Length(Text) then
    294       begin
    295       OrdinaryStop:=Stop;
    296       while (Text[OrdinaryStop+1]<>' ') and (Text[OrdinaryStop+1]<>'\') do
    297         dec(OrdinaryStop);
    298       if (OrdinaryStop+1-Start)*2>=Stop-Start then
    299         Stop:=OrdinaryStop
     311      if Stop <> Length(Text) then
     312      begin
     313        OrdinaryStop := Stop;
     314        while (Text[OrdinaryStop + 1] <> ' ') and
     315          (Text[OrdinaryStop + 1] <> '\') do
     316          dec(OrdinaryStop);
     317        if (OrdinaryStop + 1 - Start) * 2 >= Stop - Start then
     318          Stop := OrdinaryStop
    300319      end;
    301     if not preview then
    302       begin
    303       y:=(Bounds.Top+Bounds.Bottom) div 2-10*nLines+20*Line-1;
    304       if Dot then
    305         Sprite(offscreen,HGrSystem,Bounds.Left+PaperBorder_Left+(ListIndent-14),
    306           y+7,8,8,90,16);
    307       s:=Copy(Text,Start,Stop-Start+1);
    308       BiColorTextOut(Offscreen.Canvas,Colors.Canvas.Pixels[clkMisc,cliPaperText],
    309         $7F007F,Bounds.Left+PaperBorder_Left+Indent,y,s);
     320      if not preview then
     321      begin
     322        Y := (Bounds.Top + Bounds.Bottom) div 2 - 10 * nLines + 20 * Line - 1;
     323        if Dot then
     324          Sprite(Offscreen, HGrSystem, Bounds.Left + PaperBorder_Left +
     325            (ListIndent - 14), Y + 7, 8, 8, 90, 16);
     326        s := copy(Text, Start, Stop - Start + 1);
     327        BiColorTextOut(Offscreen.Canvas, Colors.Canvas.Pixels[clkMisc,
     328          cliPaperText], $7F007F, Bounds.Left + PaperBorder_Left +
     329          Indent, Y, s);
    310330      end;
    311     inc(Line);
    312     Start:=Stop+2;
     331      inc(Line);
     332      Start := Stop + 2;
    313333    end;
    314   nLines:=Line;
     334    nLines := Line;
    315335  end
    316336end;
     
    318338procedure TNegoDlg.FindAllowed;
    319339var
    320 i: integer;
    321 begin
    322 CommandAllowed:=[scDipOffer-scDipStart];
    323 if ClientMode<>scDipBreak then include(CommandAllowed,scDipBreak-scDipStart);
    324 if MyRO.Treaty[DipMem[me].pContact]>=trPeace then
    325   include(CommandAllowed,scDipCancelTreaty-scDipStart);
    326 if (ClientMode=scDipOffer)
    327   and (Server(scDipAccept-sExecute,me,0,nil^)>=rExecuted) then
    328   include(CommandAllowed,scDipAccept-scDipStart);
    329 
    330 MyAllowed:=[opChoose shr 24, opMoney shr 24];
    331 OppoAllowed:=[opChoose shr 24, opMoney shr 24];
    332 if not IsCivilReportNew(DipMem[me].pContact) then
     340  i: integer;
     341begin
     342  CommandAllowed := [scDipOffer - scDipStart];
     343  if ClientMode <> scDipBreak then
     344    include(CommandAllowed, scDipBreak - scDipStart);
     345  if MyRO.Treaty[DipMem[me].pContact] >= trPeace then
     346    include(CommandAllowed, scDipCancelTreaty - scDipStart);
     347  if (ClientMode = scDipOffer) and (Server(scDipAccept - sExecute, me, 0, nil^)
     348    >= rExecuted) then
     349    include(CommandAllowed, scDipAccept - scDipStart);
     350
     351  MyAllowed := [opChoose shr 24, opMoney shr 24];
     352  OppoAllowed := [opChoose shr 24, opMoney shr 24];
     353  if not IsCivilReportNew(DipMem[me].pContact) then
    333354  begin // no up-to-date civil report
    334   MyAllowed:=MyAllowed+[opCivilReport shr 24];
    335   for i:=0 to nAdv-1 do if MyRO.Tech[i]>=tsApplicable then
    336     begin MyAllowed:=MyAllowed+[opAllTech shr 24]; break end;
    337   OppoAllowed:=OppoAllowed+[opCivilReport shr 24,opAllTech shr 24];
     355    MyAllowed := MyAllowed + [opCivilReport shr 24];
     356    for i := 0 to nAdv - 1 do
     357      if MyRO.Tech[i] >= tsApplicable then
     358      begin
     359        MyAllowed := MyAllowed + [opAllTech shr 24];
     360        break
     361      end;
     362    OppoAllowed := OppoAllowed + [opCivilReport shr 24, opAllTech shr 24];
    338363  end
    339 else
     364  else
    340365  begin // check techs
    341   for i:=0 to nAdv-1 do if not (i in FutureTech) then
    342     if (MyRO.Tech[i]<tsSeen)
    343       and (MyRO.EnemyReport[DipMem[me].pContact].Tech[i]>=tsApplicable) then
    344       OppoAllowed:=OppoAllowed+[opAllTech shr 24]
    345     else if (MyRO.EnemyReport[DipMem[me].pContact].Tech[i]<tsSeen)
    346       and (MyRO.Tech[i]>=tsApplicable) then
    347       MyAllowed:=MyAllowed+[opAllTech shr 24];
    348   end;
    349 if not IsMilReportNew(DipMem[me].pContact) then
     366    for i := 0 to nAdv - 1 do
     367      if not(i in FutureTech) then
     368        if (MyRO.Tech[i] < tsSeen) and
     369          (MyRO.EnemyReport[DipMem[me].pContact].Tech[i] >= tsApplicable) then
     370          OppoAllowed := OppoAllowed + [opAllTech shr 24]
     371        else if (MyRO.EnemyReport[DipMem[me].pContact].Tech[i] < tsSeen) and
     372          (MyRO.Tech[i] >= tsApplicable) then
     373          MyAllowed := MyAllowed + [opAllTech shr 24];
     374  end;
     375  if not IsMilReportNew(DipMem[me].pContact) then
    350376  begin // no up-to-date military report
    351   MyAllowed:=MyAllowed+[opMilReport shr 24];
    352   if MyRO.nModel>3 then
    353     MyAllowed:=MyAllowed+[opAllModel shr 24];
    354   OppoAllowed:=OppoAllowed+[opMilReport shr 24,opAllModel shr 24];
     377    MyAllowed := MyAllowed + [opMilReport shr 24];
     378    if MyRO.nModel > 3 then
     379      MyAllowed := MyAllowed + [opAllModel shr 24];
     380    OppoAllowed := OppoAllowed + [opMilReport shr 24, opAllModel shr 24];
    355381  end
    356 else
    357   begin
    358   if ModalSelectDlg.OnlyChoice(kChooseModel)<>mixAll then
    359     MyAllowed:=MyAllowed+[opAllModel shr 24];
    360   if ModalSelectDlg.OnlyChoice(kChooseEModel)<>mixAll then
    361     OppoAllowed:=OppoAllowed+[opAllModel shr 24];
    362   end;
    363 if MyRO.Treaty[DipMem[me].pContact]<trAlliance then
    364   begin
    365   MyAllowed:=MyAllowed+[opTreaty shr 24,opMap shr 24];
    366   OppoAllowed:=OppoAllowed+[opTreaty shr 24,opMap shr 24];
    367   end;
    368 {if MyRO.Treaty[DipMem[me].pContact] in [trNone,trPeace,trAlliance] then
    369   begin
    370   MyAllowed:=MyAllowed+[opLowTreaty shr 24];
    371   OppoAllowed:=OppoAllowed+[opLowTreaty shr 24];
    372   end;}
    373 for i:=0 to nShipPart-1 do
    374   begin
    375   if MyRO.Ship[me].Parts[i]>0 then
    376     include(MyAllowed, opShipParts shr 24);
    377   if MyRO.Ship[DipMem[me].pContact].Parts[i]>0 then
    378     include(OppoAllowed, opShipParts shr 24);
    379   end;
    380 MyAllowed:=MyAllowed-DipMem[me].DeliveredPrices*[opAllTech shr 24,opAllModel shr 24,opCivilReport shr 24,opMilReport shr 24,opMap shr 24];
    381 OppoAllowed:=OppoAllowed-DipMem[me].ReceivedPrices*[opAllTech shr 24,opAllModel shr 24,opCivilReport shr 24,opMilReport shr 24,opMap shr 24];
    382 end;
    383 
    384 procedure TNegoDlg.PaintNationPicture(x,y,p: integer);
    385 begin
    386 with Offscreen.Canvas do
    387   begin
    388   Pen.Color:=$000000;
    389   Brush.Color:=Tribe[p].Color;
    390   Rectangle(x-6,y-1,x+70,y+49);
    391   Brush.Color:=$000000;
    392   Tribe[p].InitAge(GetAge(p));
    393   if Tribe[p].faceHGr>=0 then
    394     Dump(offscreen,Tribe[p].faceHGr,x,y,64,48,
    395       1+Tribe[p].facepix mod 10 *65,1+Tribe[p].facepix div 10 *49)
    396   else FillRect(Rect(x,y,x+64,y+48));
    397   Brush.Style:=bsClear;
    398   Frame(Offscreen.Canvas,x-1,y-1,x+64,y+48,$000000,$000000);
     382  else
     383  begin
     384    if ModalSelectDlg.OnlyChoice(kChooseModel) <> mixAll then
     385      MyAllowed := MyAllowed + [opAllModel shr 24];
     386    if ModalSelectDlg.OnlyChoice(kChooseEModel) <> mixAll then
     387      OppoAllowed := OppoAllowed + [opAllModel shr 24];
     388  end;
     389  if MyRO.Treaty[DipMem[me].pContact] < trAlliance then
     390  begin
     391    MyAllowed := MyAllowed + [opTreaty shr 24, opMap shr 24];
     392    OppoAllowed := OppoAllowed + [opTreaty shr 24, opMap shr 24];
     393  end;
     394  { if MyRO.Treaty[DipMem[me].pContact] in [trNone,trPeace,trAlliance] then
     395    begin
     396    MyAllowed:=MyAllowed+[opLowTreaty shr 24];
     397    OppoAllowed:=OppoAllowed+[opLowTreaty shr 24];
     398    end; }
     399  for i := 0 to nShipPart - 1 do
     400  begin
     401    if MyRO.Ship[me].Parts[i] > 0 then
     402      include(MyAllowed, opShipParts shr 24);
     403    if MyRO.Ship[DipMem[me].pContact].Parts[i] > 0 then
     404      include(OppoAllowed, opShipParts shr 24);
     405  end;
     406  MyAllowed := MyAllowed - DipMem[me].DeliveredPrices *
     407    [opAllTech shr 24, opAllModel shr 24, opCivilReport shr 24,
     408    opMilReport shr 24, opMap shr 24];
     409  OppoAllowed := OppoAllowed - DipMem[me].ReceivedPrices *
     410    [opAllTech shr 24, opAllModel shr 24, opCivilReport shr 24,
     411    opMilReport shr 24, opMap shr 24];
     412end;
     413
     414procedure TNegoDlg.PaintNationPicture(X, Y, p: integer);
     415begin
     416  with Offscreen.Canvas do
     417  begin
     418    Pen.Color := $000000;
     419    Brush.Color := Tribe[p].Color;
     420    Rectangle(X - 6, Y - 1, X + 70, Y + 49);
     421    Brush.Color := $000000;
     422    Tribe[p].InitAge(GetAge(p));
     423    if Tribe[p].faceHGr >= 0 then
     424      Dump(Offscreen, Tribe[p].faceHGr, X, Y, 64, 48,
     425        1 + Tribe[p].facepix mod 10 * 65, 1 + Tribe[p].facepix div 10 * 49)
     426    else
     427      FillRect(Rect(X, Y, X + 64, Y + 48));
     428    Brush.Style := bsClear;
     429    Frame(Offscreen.Canvas, X - 1, Y - 1, X + 64, Y + 48, $000000, $000000);
    399430  end
    400431end;
     
    402433procedure TNegoDlg.SetButtonStates;
    403434var
    404 cix: integer;
    405 IsActionPage: boolean;
    406 begin
    407 IsActionPage:= Page=History[me].n;
    408 
    409 AcceptBtn.Possible:= IsActionPage and (scDipAccept-scDipStart in CommandAllowed);
    410 AcceptBtn.Lit:= DipCommand=scDipAccept;
    411 PassBtn.Possible:= IsActionPage and (scDipOffer-scDipStart in CommandAllowed);
    412 PassBtn.Lit:= (DipCommand=scDipNotice)
    413   or (DipCommand=scDipOffer) and (CurrentOffer.nDeliver=0) and (CurrentOffer.nCost=0);
    414 ExitBtn.Possible:= IsActionPage and (scDipBreak-scDipStart in CommandAllowed);
    415 ExitBtn.Lit:= DipCommand=scDipBreak;
    416 CancelTreatyBtn.Possible:= IsActionPage and (scDipCancelTreaty-scDipStart in CommandAllowed);
    417 CancelTreatyBtn.Lit:= DipCommand=scDipCancelTreaty;
    418 
    419 for cix:=0 to ComponentCount-1 do
    420   if Components[cix] is TButtonN then
    421     with TButtonN(Components[cix]) do
    422       case Tag shr 8 of
    423         1: // Costs
    424           begin
    425           Possible:= IsActionPage and (ButtonPrice[Tag and $FF] shr 24 in OppoAllowed);
    426           Lit:=Costs[Tag and $FF]<>$FFFFFFFF;
    427           end;
    428         2: // Delivers
    429           begin
    430           Possible:= IsActionPage and (ButtonPrice[Tag and $FF] shr 24 in MyAllowed);
    431           Lit:=Delivers[Tag and $FF]<>$FFFFFFFF;
    432           end
     435  cix: integer;
     436  IsActionPage: boolean;
     437begin
     438  IsActionPage := Page = History[me].n;
     439
     440  AcceptBtn.Possible := IsActionPage and
     441    (scDipAccept - scDipStart in CommandAllowed);
     442  AcceptBtn.Lit := DipCommand = scDipAccept;
     443  PassBtn.Possible := IsActionPage and
     444    (scDipOffer - scDipStart in CommandAllowed);
     445  PassBtn.Lit := (DipCommand = scDipNotice) or (DipCommand = scDipOffer) and
     446    (CurrentOffer.nDeliver = 0) and (CurrentOffer.nCost = 0);
     447  ExitBtn.Possible := IsActionPage and
     448    (scDipBreak - scDipStart in CommandAllowed);
     449  ExitBtn.Lit := DipCommand = scDipBreak;
     450  CancelTreatyBtn.Possible := IsActionPage and
     451    (scDipCancelTreaty - scDipStart in CommandAllowed);
     452  CancelTreatyBtn.Lit := DipCommand = scDipCancelTreaty;
     453
     454  for cix := 0 to ComponentCount - 1 do
     455    if Components[cix] is TButtonN then
     456      with TButtonN(Components[cix]) do
     457        case Tag shr 8 of
     458          1: // Costs
     459            begin
     460              Possible := IsActionPage and
     461                (ButtonPrice[Tag and $FF] shr 24 in OppoAllowed);
     462              Lit := Costs[Tag and $FF] <> $FFFFFFFF;
     463            end;
     464          2: // Delivers
     465            begin
     466              Possible := IsActionPage and
     467                (ButtonPrice[Tag and $FF] shr 24 in MyAllowed);
     468              Lit := Delivers[Tag and $FF] <> $FFFFFFFF;
     469            end
    433470        end;
    434471end;
     
    436473procedure TNegoDlg.OffscreenPaint;
    437474var
    438 i,cred: integer;
    439 s: string;
    440 OkEnabled: boolean;
    441 begin
    442 if (OffscreenUser<>nil) and (OffscreenUser<>self) then OffscreenUser.Update;
     475  i, cred: integer;
     476  s: string;
     477  OkEnabled: boolean;
     478begin
     479  if (OffscreenUser <> nil) and (OffscreenUser <> self) then
     480    OffscreenUser.Update;
    443481  // complete working with old owner to prevent rebound
    444 OffscreenUser:=self;
    445 
    446 if (DipCommand>=0) and (Page=History[me].n) then
    447   History[me].Text[History[me].n]:=copy(DipCommandToString(me,DipMem[me].pContact,
    448     MyRO.Treaty[DipMem[me].pContact],ClientMode, DipCommand, ReceivedOffer, CurrentOffer),1,255);
    449 
    450 FwdBtn.Visible:= Page<History[me].n;
    451 BwdBtn.Visible:= Page>=2;
    452 if Page<History[me].n then OkEnabled:=false
    453 else if DipCommand=scDipOffer then
    454   OkEnabled:= Server(scDipOffer-sExecute,me,0,CurrentOffer)>=rExecuted
    455 else OkEnabled:= DipCommand>=0;
    456 OkBtn.Visible:=OkEnabled;
    457 
    458 Fill(Offscreen.Canvas,3,3,ClientWidth-6,ClientHeight-6,
    459   (wMaintexture-ClientWidth) div 2,(hMaintexture-ClientHeight) div 2);
    460 Frame(Offscreen.Canvas,0,0,ClientWidth-1,ClientHeight-1,0,0);
    461 Frame(Offscreen.Canvas,1,1,ClientWidth-2,ClientHeight-2,MainTexture.clBevelLight,MainTexture.clBevelShade);
    462 Frame(Offscreen.Canvas,2,2,ClientWidth-3,ClientHeight-3,MainTexture.clBevelLight,MainTexture.clBevelShade);
    463 Corner(Offscreen.Canvas,1,1,0,MainTexture);
    464 Corner(Offscreen.Canvas,ClientWidth-9,1,1,MainTexture);
    465 Corner(Offscreen.Canvas,1,ClientHeight-9,2,MainTexture);
    466 Corner(Offscreen.Canvas,ClientWidth-9,ClientHeight-9,3,MainTexture);
    467 
    468 BtnFrame(Offscreen.Canvas,OkBtn.BoundsRect,MainTexture);
    469 BtnFrame(Offscreen.Canvas,BwdBtn.BoundsRect,MainTexture);
    470 BtnFrame(Offscreen.Canvas,FwdBtn.BoundsRect,MainTexture);
    471 BtnFrame(Offscreen.Canvas,CloseBtn.BoundsRect,MainTexture);
    472 
    473 RFrame(Offscreen.Canvas,xPadC-2, yPadC-2, xPadC+41+42*3,yPadC+41,
    474   $FFFFFF,$B0B0B0);
    475 RFrame(Offscreen.Canvas,xPad0-2, yPad0-2,xPad0+41+42*3,
    476   yPad0+41+42*2,$FFFFFF,$B0B0B0);
    477 RFrame(Offscreen.Canvas,xPad1-2, yPad1-2,xPad1+41+42*3,
    478   yPad1+41+42*2,$FFFFFF,$B0B0B0);
    479 
    480 PaintNationPicture(xNationPicture0,yNationPicture,DipMem[me].pContact);
    481 PaintNationPicture(xNationPicture1,yNationPicture,me);
    482 
    483 if History[me].Text[Page-1]<>'' then
    484   begin
    485   FillSeamless(Offscreen.Canvas, xText0, yText0, wText, hText, 0, 0, Paper);
    486   i:=Page-1;
    487   if History[me].Text[0]='' then dec(i);
    488   if i<16 then
    489     begin
     482  OffscreenUser := self;
     483
     484  if (DipCommand >= 0) and (Page = History[me].n) then
     485    History[me].Text[History[me].n] :=
     486      copy(DipCommandToString(me, DipMem[me].pContact,
     487      MyRO.Treaty[DipMem[me].pContact], ClientMode, DipCommand, ReceivedOffer,
     488      CurrentOffer), 1, 255);
     489
     490  FwdBtn.Visible := Page < History[me].n;
     491  BwdBtn.Visible := Page >= 2;
     492  if Page < History[me].n then
     493    OkEnabled := false
     494  else if DipCommand = scDipOffer then
     495    OkEnabled := Server(scDipOffer - sExecute, me, 0, CurrentOffer) >= rExecuted
     496  else
     497    OkEnabled := DipCommand >= 0;
     498  OkBtn.Visible := OkEnabled;
     499
     500  Fill(Offscreen.Canvas, 3, 3, ClientWidth - 6, ClientHeight - 6,
     501    (wMaintexture - ClientWidth) div 2, (hMaintexture - ClientHeight) div 2);
     502  Frame(Offscreen.Canvas, 0, 0, ClientWidth - 1, ClientHeight - 1, 0, 0);
     503  Frame(Offscreen.Canvas, 1, 1, ClientWidth - 2, ClientHeight - 2,
     504    MainTexture.clBevelLight, MainTexture.clBevelShade);
     505  Frame(Offscreen.Canvas, 2, 2, ClientWidth - 3, ClientHeight - 3,
     506    MainTexture.clBevelLight, MainTexture.clBevelShade);
     507  Corner(Offscreen.Canvas, 1, 1, 0, MainTexture);
     508  Corner(Offscreen.Canvas, ClientWidth - 9, 1, 1, MainTexture);
     509  Corner(Offscreen.Canvas, 1, ClientHeight - 9, 2, MainTexture);
     510  Corner(Offscreen.Canvas, ClientWidth - 9, ClientHeight - 9, 3, MainTexture);
     511
     512  BtnFrame(Offscreen.Canvas, OkBtn.BoundsRect, MainTexture);
     513  BtnFrame(Offscreen.Canvas, BwdBtn.BoundsRect, MainTexture);
     514  BtnFrame(Offscreen.Canvas, FwdBtn.BoundsRect, MainTexture);
     515  BtnFrame(Offscreen.Canvas, CloseBtn.BoundsRect, MainTexture);
     516
     517  RFrame(Offscreen.Canvas, xPadC - 2, yPadC - 2, xPadC + 41 + 42 * 3,
     518    yPadC + 41, $FFFFFF, $B0B0B0);
     519  RFrame(Offscreen.Canvas, xPad0 - 2, yPad0 - 2, xPad0 + 41 + 42 * 3,
     520    yPad0 + 41 + 42 * 2, $FFFFFF, $B0B0B0);
     521  RFrame(Offscreen.Canvas, xPad1 - 2, yPad1 - 2, xPad1 + 41 + 42 * 3,
     522    yPad1 + 41 + 42 * 2, $FFFFFF, $B0B0B0);
     523
     524  PaintNationPicture(xNationPicture0, yNationPicture, DipMem[me].pContact);
     525  PaintNationPicture(xNationPicture1, yNationPicture, me);
     526
     527  if History[me].Text[Page - 1] <> '' then
     528  begin
     529    FillSeamless(Offscreen.Canvas, xText0, yText0, wText, hText, 0, 0, Paper);
     530    i := Page - 1;
     531    if History[me].Text[0] = '' then
     532      dec(i);
     533    if i < 16 then
     534    begin
     535      Offscreen.Canvas.Font.Assign(RomanFont);
     536      Offscreen.Canvas.TextOut
     537        (xText0 + (wText - Offscreen.Canvas.TextWidth(RomanNo[i])) div 2,
     538        yText0 + (hText - Offscreen.Canvas.TextHeight(RomanNo[i])) div 2,
     539        RomanNo[i]);
     540    end
     541  end;
     542  FillSeamless(Offscreen.Canvas, xText1, yText1, wText, hText, 0, 0, Paper);
     543  i := Page;
     544  if History[me].Text[0] = '' then
     545    dec(i);
     546  if i < 16 then
     547  begin
    490548    Offscreen.Canvas.Font.Assign(RomanFont);
    491     Offscreen.Canvas.TextOut(xText0+(wText-Offscreen.Canvas.TextWidth(RomanNo[i])) div 2,
    492       yText0+(hText-Offscreen.Canvas.TextHeight(RomanNo[i])) div 2,RomanNo[i]);
    493     end
    494   end;
    495 FillSeamless(Offscreen.Canvas, xText1, yText1, wText, hText, 0, 0, Paper);
    496 i:=Page;
    497 if History[me].Text[0]='' then dec(i);
    498 if i<16 then
    499   begin
    500   Offscreen.Canvas.Font.Assign(RomanFont);
    501   Offscreen.Canvas.TextOut(xText1+(wText-Offscreen.Canvas.TextWidth(RomanNo[i])) div 2,
    502     yText1+(hText-Offscreen.Canvas.TextHeight(RomanNo[i])) div 2,RomanNo[i]);
    503   end;
    504 with Offscreen.Canvas do
    505   begin
    506   Brush.Color:=MainTexture.clBevelShade;
    507   if History[me].Text[Page-1]<>'' then
    508     begin
    509     FillRect(Rect(xText0+wText, yText0+PaperShade, xText0+wText+PaperShade,
    510       yText0+hText+PaperShade));
    511     FillRect(Rect(xText0+PaperShade, yText0+hText, xText0+wText+PaperShade,
    512       yText0+hText+PaperShade));
     549    Offscreen.Canvas.TextOut
     550      (xText1 + (wText - Offscreen.Canvas.TextWidth(RomanNo[i])) div 2,
     551      yText1 + (hText - Offscreen.Canvas.TextHeight(RomanNo[i])) div 2,
     552      RomanNo[i]);
     553  end;
     554  with Offscreen.Canvas do
     555  begin
     556    Brush.Color := MainTexture.clBevelShade;
     557    if History[me].Text[Page - 1] <> '' then
     558    begin
     559      FillRect(Rect(xText0 + wText, yText0 + PaperShade,
     560        xText0 + wText + PaperShade, yText0 + hText + PaperShade));
     561      FillRect(Rect(xText0 + PaperShade, yText0 + hText,
     562        xText0 + wText + PaperShade, yText0 + hText + PaperShade));
    513563    end;
    514   FillRect(Rect(xText1+wText, yText1+PaperShade, xText1+wText+PaperShade,
    515     yText1+hText+PaperShade));
    516   FillRect(Rect(xText1+PaperShade, yText1+hText, xText1+wText+PaperShade,
    517     yText1+hText+PaperShade));
    518   Brush.Style:=bsClear;
    519   end;
    520 
    521 Offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
    522 
    523 {if Page=History[me].n then
    524   begin // show attitude
    525   s:=Phrases.Lookup('ATTITUDE',MyRO.EnemyReport[DipMem[me].pContact].Attitude);
    526   //LoweredTextOut(Offscreen.Canvas,-1,MainTexture,
    527   RisedTextOut(Offscreen.Canvas,xText0+wText div 2-
     564    FillRect(Rect(xText1 + wText, yText1 + PaperShade,
     565      xText1 + wText + PaperShade, yText1 + hText + PaperShade));
     566    FillRect(Rect(xText1 + PaperShade, yText1 + hText,
     567      xText1 + wText + PaperShade, yText1 + hText + PaperShade));
     568    Brush.Style := bsClear;
     569  end;
     570
     571  Offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
     572
     573  { if Page=History[me].n then
     574    begin // show attitude
     575    s:=Phrases.Lookup('ATTITUDE',MyRO.EnemyReport[DipMem[me].pContact].Attitude);
     576    //LoweredTextOut(Offscreen.Canvas,-1,MainTexture,
     577    RisedTextOut(Offscreen.Canvas,xText0+wText div 2-
    528578    BiColorTextWidth(Offscreen.Canvas,s) div 2,yAttitude,s);
    529   s:=Phrases.Lookup('ATTITUDE',MyRO.Attitude[DipMem[me].pContact]);
    530   //LoweredTextOut(Offscreen.Canvas,-1,MainTexture,
    531   RisedTextOut(Offscreen.Canvas,xText1+wText div 2-
     579    s:=Phrases.Lookup('ATTITUDE',MyRO.Attitude[DipMem[me].pContact]);
     580    //LoweredTextOut(Offscreen.Canvas,-1,MainTexture,
     581    RisedTextOut(Offscreen.Canvas,xText1+wText div 2-
    532582    BiColorTextWidth(Offscreen.Canvas,s) div 2,yAttitude,s);
    533   end;}
    534 
    535 if History[me].Text[Page-1]<>'' then
    536   SplitText(History[me].Text[Page-1],
    537     Rect(xText0, yText0, xText0+wText, yText0+hText));
    538 if (Page<History[me].n) or OkEnabled then
    539   SplitText(History[me].Text[Page], Rect(xText1, yText1, xText1+wText, yText1+hText));
    540 
    541 // show credibility
    542 Offscreen.Canvas.Font.Assign(UniFont[ftTiny]);
    543 cred:=MyRO.EnemyReport[DipMem[me].pContact].Credibility;
    544 case cred of
    545   0..49: i:= 3; 50..90: i:=0; 91..100: i:=1; end;
    546 PaintProgressBar(Offscreen.Canvas,i,xCred0,yCred0+17,(cred+2) div 5,0,20,MainTexture);
    547 s:=IntToStr(cred);
    548 RisedTextOut(Offscreen.Canvas,xCred0+10-(BiColorTextWidth(Offscreen.Canvas,s)+1) div 2,yCred0,s);
    549 case MyRO.Credibility of
    550   0..49: i:= 3; 50..90: i:=0; 91..100: i:=1; end;
    551 PaintProgressBar(Offscreen.Canvas,i,xCred1,yCred1+17,(MyRO.Credibility+2) div 5,0,20,MainTexture);
    552 s:=IntToStr(MyRO.Credibility);
    553 RisedTextOut(Offscreen.Canvas,xCred1+10-(BiColorTextWidth(Offscreen.Canvas,s)+1) div 2,yCred1,s);
    554 
    555 MarkUsedOffscreen(ClientWidth,ClientHeight);
    556 end; {OffscreenPaint}
     583    end; }
     584
     585  if History[me].Text[Page - 1] <> '' then
     586    SplitText(History[me].Text[Page - 1], Rect(xText0, yText0, xText0 + wText,
     587      yText0 + hText));
     588  if (Page < History[me].n) or OkEnabled then
     589    SplitText(History[me].Text[Page], Rect(xText1, yText1, xText1 + wText,
     590      yText1 + hText));
     591
     592  // show credibility
     593  Offscreen.Canvas.Font.Assign(UniFont[ftTiny]);
     594  cred := MyRO.EnemyReport[DipMem[me].pContact].Credibility;
     595  case cred of
     596    0 .. 49:
     597      i := 3;
     598    50 .. 90:
     599      i := 0;
     600    91 .. 100:
     601      i := 1;
     602  end;
     603  PaintProgressBar(Offscreen.Canvas, i, xCred0, yCred0 + 17, (cred + 2) div 5,
     604    0, 20, MainTexture);
     605  s := IntToStr(cred);
     606  RisedTextOut(Offscreen.Canvas, xCred0 + 10 -
     607    (BiColorTextWidth(Offscreen.Canvas, s) + 1) div 2, yCred0, s);
     608  case MyRO.Credibility of
     609    0 .. 49:
     610      i := 3;
     611    50 .. 90:
     612      i := 0;
     613    91 .. 100:
     614      i := 1;
     615  end;
     616  PaintProgressBar(Offscreen.Canvas, i, xCred1, yCred1 + 17,
     617    (MyRO.Credibility + 2) div 5, 0, 20, MainTexture);
     618  s := IntToStr(MyRO.Credibility);
     619  RisedTextOut(Offscreen.Canvas, xCred1 + 10 -
     620    (BiColorTextWidth(Offscreen.Canvas, s) + 1) div 2, yCred1, s);
     621
     622  MarkUsedOffscreen(ClientWidth, ClientHeight);
     623end; { OffscreenPaint }
    557624
    558625procedure TNegoDlg.Initiate;
    559626begin
    560 History[me].n:=1;
    561 History[me].Text[0]:='';
     627  History[me].n := 1;
     628  History[me].Text[0] := '';
    562629end;
    563630
    564631procedure TNegoDlg.Respond;
    565632begin
    566 History[me].n:=0;
     633  History[me].n := 0;
    567634end;
    568635
    569636procedure TNegoDlg.FormMouseDown(Sender: TObject; Button: TMouseButton;
    570   Shift: TShiftState; X, Y: Integer);
    571 begin
    572 if (x>=xNationPicture0) and (x<xNationPicture0+64)
    573   and (y>=yNationPicture) and (y<yNationPicture+48) then
    574   NatStatDlg.ShowNewContent(FWindowMode or wmPersistent, DipMem[me].pContact)
    575 else if (x>=xNationPicture1) and (x<xNationPicture1+64)
    576   and (y>=yNationPicture) and (y<yNationPicture+48) then
    577   NatStatDlg.ShowNewContent(FWindowMode or wmPersistent,me)
     637  Shift: TShiftState; X, Y: integer);
     638begin
     639  if (X >= xNationPicture0) and (X < xNationPicture0 + 64) and
     640    (Y >= yNationPicture) and (Y < yNationPicture + 48) then
     641    NatStatDlg.ShowNewContent(FWindowMode or wmPersistent, DipMem[me].pContact)
     642  else if (X >= xNationPicture1) and (X < xNationPicture1 + 64) and
     643    (Y >= yNationPicture) and (Y < yNationPicture + 48) then
     644    NatStatDlg.ShowNewContent(FWindowMode or wmPersistent, me)
    578645end;
    579646
    580647procedure TNegoDlg.BwdBtnClick(Sender: TObject);
    581648begin
    582 dec(Page,2);
    583 SetButtonStates;
    584 SmartUpdateContent;
     649  dec(Page, 2);
     650  SetButtonStates;
     651  SmartUpdateContent;
    585652end;
    586653
    587654procedure TNegoDlg.FwdBtnClick(Sender: TObject);
    588655begin
    589 inc(Page,2);
    590 SetButtonStates;
    591 SmartUpdateContent;
     656  inc(Page, 2);
     657  SetButtonStates;
     658  SmartUpdateContent;
    592659end;
    593660
    594661procedure TNegoDlg.OkBtnClick(Sender: TObject);
    595662begin
    596 inc(History[me].n);
    597 if DipCommand=scDipOffer then
    598   MainScreen.OfferCall(CurrentOffer)
    599 else MainScreen.DipCall(DipCommand);
     663  inc(History[me].n);
     664  if DipCommand = scDipOffer then
     665    MainScreen.OfferCall(CurrentOffer)
     666  else
     667    MainScreen.DipCall(DipCommand);
    600668end;
    601669
    602670procedure TNegoDlg.CloseBtnClick(Sender: TObject);
    603671begin
    604 Close
     672  Close
    605673end;
    606674
     
    608676  Shift: TShiftState);
    609677begin
    610 if Key=VK_RETURN then
    611   begin
    612   if OkBtn.Visible then OkBtnClick(nil)
     678  if Key = VK_RETURN then
     679  begin
     680    if OkBtn.Visible then
     681      OkBtnClick(nil)
    613682  end
    614 else inherited
     683  else
     684    inherited
    615685end;
    616686
    617687procedure TNegoDlg.BuildCurrentOffer;
    618688var
    619 i: integer;
    620 begin
    621 CurrentOffer.nDeliver:=0;
    622 CurrentOffer.nCost:=0;
    623 for i:=0 to 11 do if Delivers[i]<>$FFFFFFFF then
    624   begin
    625   CurrentOffer.Price[CurrentOffer.nDeliver]:=Delivers[i];
    626   inc(CurrentOffer.nDeliver);
    627   end;
    628 for i:=0 to 11 do if Costs[i]<>$FFFFFFFF then
    629   begin
    630   CurrentOffer.Price[CurrentOffer.nDeliver+CurrentOffer.nCost]:=Costs[i];
    631   inc(CurrentOffer.nCost);
    632   end;
     689  i: integer;
     690begin
     691  CurrentOffer.nDeliver := 0;
     692  CurrentOffer.nCost := 0;
     693  for i := 0 to 11 do
     694    if Delivers[i] <> $FFFFFFFF then
     695    begin
     696      CurrentOffer.Price[CurrentOffer.nDeliver] := Delivers[i];
     697      inc(CurrentOffer.nDeliver);
     698    end;
     699  for i := 0 to 11 do
     700    if Costs[i] <> $FFFFFFFF then
     701    begin
     702      CurrentOffer.Price[CurrentOffer.nDeliver + CurrentOffer.nCost] :=
     703        Costs[i];
     704      inc(CurrentOffer.nCost);
     705    end;
    633706end;
    634707
    635708procedure TNegoDlg.WantClick(Sender: TObject);
    636709var
    637 a,i,max: integer;
    638 Price: cardinal;
    639 begin
    640 if (Page<>History[me].n)
    641   or (ClientMode=scDipCancelTreaty) or (ClientMode=scDipBreak) then
    642   exit;
    643 if Costs[TButtonN(Sender).Tag and $FF]<>$FFFFFFFF then
    644   Price:=$FFFFFFFF // toggle off
    645 else
    646   begin
    647   if CurrentOffer.nCost>=2 then
    648     begin
    649     SimpleMessage(Phrases.Lookup('MAX2WANTS'));
    650     exit
     710  a, i, max: integer;
     711  Price: cardinal;
     712begin
     713  if (Page <> History[me].n) or (ClientMode = scDipCancelTreaty) or
     714    (ClientMode = scDipBreak) then
     715    exit;
     716  if Costs[TButtonN(Sender).Tag and $FF] <> $FFFFFFFF then
     717    Price := $FFFFFFFF // toggle off
     718  else
     719  begin
     720    if CurrentOffer.nCost >= 2 then
     721    begin
     722      SimpleMessage(Phrases.Lookup('MAX2WANTS'));
     723      exit
    651724    end;
    652   Price:=ButtonPrice[TButtonN(Sender).Tag and $FF];
    653   if not (Price shr 24 in OppoAllowed) then exit;
    654   case Price of
    655     opCivilReport, opMilReport:
    656       inc(Price,DipMem[me].pContact shl 16+MyRO.Turn); // !!! choose player and year!
    657     opMoney:
    658       begin // choose amount
    659       InputDlg.Caption:=Phrases.Lookup('TITLE_AMOUNT');
    660       InputDlg.EInput.Text:='';
    661       InputDlg.CenterToRect(BoundsRect);
    662       InputDlg.ShowModal;
    663       if InputDlg.ModalResult<>mrOK then exit;
    664       val(InputDlg.EInput.Text,a,i);
    665       if (i<>0) or (a<=0) or (a>=MaxMoneyPrice) then exit;
    666       inc(Price,a);
    667       end;
    668     opShipParts:
    669       begin // choose type and number
    670       if MyRO.NatBuilt[imSpacePort]=0 then with MessgExDlg do
     725    Price := ButtonPrice[TButtonN(Sender).Tag and $FF];
     726    if not(Price shr 24 in OppoAllowed) then
     727      exit;
     728    case Price of
     729      opCivilReport, opMilReport:
     730        inc(Price, DipMem[me].pContact shl 16 + MyRO.Turn);
     731        // !!! choose player and year!
     732      opMoney:
     733        begin // choose amount
     734          InputDlg.Caption := Phrases.Lookup('TITLE_AMOUNT');
     735          InputDlg.EInput.Text := '';
     736          InputDlg.CenterToRect(BoundsRect);
     737          InputDlg.ShowModal;
     738          if InputDlg.ModalResult <> mrOK then
     739            exit;
     740          val(InputDlg.EInput.Text, a, i);
     741          if (i <> 0) or (a <= 0) or (a >= MaxMoneyPrice) then
     742            exit;
     743          inc(Price, a);
     744        end;
     745      opShipParts:
     746        begin // choose type and number
     747          if MyRO.NatBuilt[imSpacePort] = 0 then
     748            with MessgExDlg do
     749            begin
     750              OpenSound := 'WARNING_LOWSUPPORT';
     751              MessgText := Phrases.Lookup('NOSPACEPORT');
     752              Kind := mkYesNo;
     753              IconKind := mikImp;
     754              IconIndex := imSpacePort;
     755              ShowModal;
     756              if ModalResult <> mrOK then
     757                exit
     758            end;
     759          ModalSelectDlg.ShowNewContent(wmModal, kEShipPart);
     760          if ModalSelectDlg.result < 0 then
     761            exit;
     762          inc(Price, ModalSelectDlg.result shl 16);
     763          max := MyRO.Ship[DipMem[me].pContact].Parts[ModalSelectDlg.result];
     764          InputDlg.Caption := Phrases.Lookup('TITLE_NUMBER');
     765          InputDlg.EInput.Text := '';
     766          InputDlg.CenterToRect(BoundsRect);
     767          InputDlg.ShowModal;
     768          if InputDlg.ModalResult <> mrOK then
     769            exit;
     770          val(InputDlg.EInput.Text, a, i);
     771          if (i <> 0) or (a <= 0) then
     772            exit;
     773          if a > max then
     774            a := max;
     775          if a > MaxShipPartPrice then
     776            a := MaxShipPartPrice;
     777          inc(Price, a)
     778        end;
     779      opAllTech:
     780        begin // choose technology
     781          ModalSelectDlg.ShowNewContent(wmModal, kChooseETech);
     782          if ModalSelectDlg.result < 0 then
     783            exit;
     784          if ModalSelectDlg.result = adAll then
     785            Price := opAllTech
     786          else
     787            Price := OpTech + ModalSelectDlg.result;
     788        end;
     789      opAllModel:
     790        begin // choose model
     791          ModalSelectDlg.ShowNewContent(wmModal, kChooseEModel);
     792          if ModalSelectDlg.result < 0 then
     793            exit;
     794          if ModalSelectDlg.result = mixAll then
     795            Price := opAllModel
     796          else
     797            Price := OpModel + MyRO.EnemyModel[ModalSelectDlg.result].mix;
     798        end;
     799      opTreaty:
    671800        begin
    672         OpenSound:='WARNING_LOWSUPPORT';
    673         MessgText:=Phrases.Lookup('NOSPACEPORT');
    674         Kind:=mkYesNo;
    675         IconKind:=mikImp;
    676         IconIndex:=imSpacePort;
    677         ShowModal;
    678         if ModalResult<>mrOK then exit
    679         end;
    680       ModalSelectDlg.ShowNewContent(wmModal,kEShipPart);
    681       if ModalSelectDlg.result<0 then exit;
    682       inc(Price, ModalSelectDlg.result shl 16);
    683       max:=MyRO.Ship[DipMem[me].pContact].Parts[ModalSelectDlg.result];
    684       InputDlg.Caption:=Phrases.Lookup('TITLE_NUMBER');
    685       InputDlg.EInput.Text:='';
    686       InputDlg.CenterToRect(BoundsRect);
    687       InputDlg.ShowModal;
    688       if InputDlg.ModalResult<>mrOK then exit;
    689       val(InputDlg.EInput.Text,a,i);
    690       if (i<>0) or (a<=0) then exit;
    691       if a>max then a:=max;
    692       if a>MaxShipPartPrice then a:=MaxShipPartPrice;
    693       inc(Price,a)
    694       end;
    695     opAllTech:
    696       begin // choose technology
    697       ModalSelectDlg.ShowNewContent(wmModal,kChooseETech);
    698       if ModalSelectDlg.result<0 then exit;
    699       if ModalSelectDlg.result=adAll then Price:=opAllTech
    700       else Price:=OpTech+ModalSelectDlg.result;
    701       end;
    702     opAllModel:
    703       begin // choose model
    704       ModalSelectDlg.ShowNewContent(wmModal,kChooseEModel);
    705       if ModalSelectDlg.result<0 then exit;
    706       if ModalSelectDlg.result=mixAll then Price:=opAllModel
    707       else Price:=OpModel+MyRO.EnemyModel[ModalSelectDlg.result].mix;
    708       end;
    709     opTreaty:
    710       begin
    711       if MyRO.Treaty[DipMem[me].pContact]<trPeace then Price:=opTreaty+trPeace
    712       else Price:=opTreaty+MyRO.Treaty[DipMem[me].pContact]+1;
    713       end;
    714 {    opLowTreaty:
    715       begin
    716       if MyRO.Treaty[DipMem[me].pContact]=trNone then Price:=opTreaty+trCeaseFire
    717       else Price:=opTreaty+MyRO.Treaty[DipMem[me].pContact]-1;
    718       end}
     801          if MyRO.Treaty[DipMem[me].pContact] < trPeace then
     802            Price := opTreaty + trPeace
     803          else
     804            Price := opTreaty + MyRO.Treaty[DipMem[me].pContact] + 1;
     805        end;
     806      { opLowTreaty:
     807        begin
     808        if MyRO.Treaty[DipMem[me].pContact]=trNone then Price:=opTreaty+trCeaseFire
     809        else Price:=opTreaty+MyRO.Treaty[DipMem[me].pContact]-1;
     810        end }
    719811    end;
    720812  end;
    721813
    722 Costs[TButtonN(Sender).Tag and $FF]:=Price;
    723 BuildCurrentOffer;
    724 DipCommand:=scDipOffer;
    725 SetButtonStates;
    726 SmartUpdateContent;
     814  Costs[TButtonN(Sender).Tag and $FF] := Price;
     815  BuildCurrentOffer;
     816  DipCommand := scDipOffer;
     817  SetButtonStates;
     818  SmartUpdateContent;
    727819end;
    728820
    729821procedure TNegoDlg.OfferClick(Sender: TObject);
    730822var
    731 a,i,max: integer;
    732 Price: cardinal;
    733 begin
    734 if (Page<>History[me].n)
    735   or (ClientMode=scDipCancelTreaty) or (ClientMode=scDipBreak) then
    736   exit;
    737 if Delivers[TButtonN(Sender).Tag and $FF]<>$FFFFFFFF then
    738   Price:=$FFFFFFFF // toggle off
    739 else
    740   begin
    741   if CurrentOffer.nDeliver>=2 then
    742     begin
    743     SimpleMessage(Phrases.Lookup('MAX2OFFERS'));
    744     exit
     823  a, i, max: integer;
     824  Price: cardinal;
     825begin
     826  if (Page <> History[me].n) or (ClientMode = scDipCancelTreaty) or
     827    (ClientMode = scDipBreak) then
     828    exit;
     829  if Delivers[TButtonN(Sender).Tag and $FF] <> $FFFFFFFF then
     830    Price := $FFFFFFFF // toggle off
     831  else
     832  begin
     833    if CurrentOffer.nDeliver >= 2 then
     834    begin
     835      SimpleMessage(Phrases.Lookup('MAX2OFFERS'));
     836      exit
    745837    end;
    746   Price:=ButtonPrice[TButtonN(Sender).Tag and $FF];
    747   if not (Price shr 24 in MyAllowed) then exit;
    748   case Price of
    749     opCivilReport, opMilReport:
    750       inc(Price,me shl 16+MyRO.Turn); // !!! choose player and year!
    751     opMoney:
    752       begin // choose amount
    753       InputDlg.Caption:=Phrases.Lookup('TITLE_AMOUNT');
    754       InputDlg.EInput.Text:='';
    755       InputDlg.CenterToRect(BoundsRect);
    756       InputDlg.ShowModal;
    757       if InputDlg.ModalResult<>mrOK then exit;
    758       val(InputDlg.EInput.Text,a,i);
    759       if (i<>0) or (a<=0) or (a>=MaxMoneyPrice) then exit;
    760       if (Price=opMoney) and (a>MyRO.Money) then
    761         a:=MyRO.Money;
    762       inc(Price,a);
    763       end;
    764     opShipParts:
    765       begin // choose type and number
    766       ModalSelectDlg.ShowNewContent(wmModal,kShipPart);
    767       if ModalSelectDlg.result<0 then exit;
    768       inc(Price, ModalSelectDlg.result shl 16);
    769       max:=MyRO.Ship[me].Parts[ModalSelectDlg.result];
    770       InputDlg.Caption:=Phrases.Lookup('TITLE_NUMBER');
    771       InputDlg.EInput.Text:='';
    772       InputDlg.CenterToRect(BoundsRect);
    773       InputDlg.ShowModal;
    774       if InputDlg.ModalResult<>mrOK then exit;
    775       val(InputDlg.EInput.Text,a,i);
    776       if (i<>0) or (a<=0) then exit;
    777       if a>max then a:=max;
    778       if a>MaxShipPartPrice then a:=MaxShipPartPrice;
    779       inc(Price,a)
    780       end;
    781     opAllTech:
    782       begin // choose technology
    783       ModalSelectDlg.ShowNewContent(wmModal,kChooseTech);
    784       if ModalSelectDlg.result<0 then exit;
    785       if ModalSelectDlg.result=adAll then Price:=opAllTech
    786       else Price:=OpTech+ModalSelectDlg.result;
    787       end;
    788     opAllModel:
    789       begin // choose model
    790       ModalSelectDlg.ShowNewContent(wmModal,kChooseModel);
    791       if ModalSelectDlg.result<0 then exit;
    792       if ModalSelectDlg.result=mixAll then Price:=opAllModel
    793       else Price:=opModel+ModalSelectDlg.result
    794       end;
    795     opTreaty:
    796       begin
    797       if MyRO.Treaty[DipMem[me].pContact]<trPeace then Price:=opTreaty+trPeace
    798       else Price:=opTreaty+MyRO.Treaty[DipMem[me].pContact]+1;
    799       end;
    800 {    opLowTreaty:
    801       begin
    802       if MyRO.Treaty[DipMem[me].pContact]=trNone then Price:=opTreaty+trCeaseFire
    803       else Price:=opTreaty+MyRO.Treaty[DipMem[me].pContact]-1;
    804       end}
     838    Price := ButtonPrice[TButtonN(Sender).Tag and $FF];
     839    if not(Price shr 24 in MyAllowed) then
     840      exit;
     841    case Price of
     842      opCivilReport, opMilReport:
     843        inc(Price, me shl 16 + MyRO.Turn); // !!! choose player and year!
     844      opMoney:
     845        begin // choose amount
     846          InputDlg.Caption := Phrases.Lookup('TITLE_AMOUNT');
     847          InputDlg.EInput.Text := '';
     848          InputDlg.CenterToRect(BoundsRect);
     849          InputDlg.ShowModal;
     850          if InputDlg.ModalResult <> mrOK then
     851            exit;
     852          val(InputDlg.EInput.Text, a, i);
     853          if (i <> 0) or (a <= 0) or (a >= MaxMoneyPrice) then
     854            exit;
     855          if (Price = opMoney) and (a > MyRO.Money) then
     856            a := MyRO.Money;
     857          inc(Price, a);
     858        end;
     859      opShipParts:
     860        begin // choose type and number
     861          ModalSelectDlg.ShowNewContent(wmModal, kShipPart);
     862          if ModalSelectDlg.result < 0 then
     863            exit;
     864          inc(Price, ModalSelectDlg.result shl 16);
     865          max := MyRO.Ship[me].Parts[ModalSelectDlg.result];
     866          InputDlg.Caption := Phrases.Lookup('TITLE_NUMBER');
     867          InputDlg.EInput.Text := '';
     868          InputDlg.CenterToRect(BoundsRect);
     869          InputDlg.ShowModal;
     870          if InputDlg.ModalResult <> mrOK then
     871            exit;
     872          val(InputDlg.EInput.Text, a, i);
     873          if (i <> 0) or (a <= 0) then
     874            exit;
     875          if a > max then
     876            a := max;
     877          if a > MaxShipPartPrice then
     878            a := MaxShipPartPrice;
     879          inc(Price, a)
     880        end;
     881      opAllTech:
     882        begin // choose technology
     883          ModalSelectDlg.ShowNewContent(wmModal, kChooseTech);
     884          if ModalSelectDlg.result < 0 then
     885            exit;
     886          if ModalSelectDlg.result = adAll then
     887            Price := opAllTech
     888          else
     889            Price := OpTech + ModalSelectDlg.result;
     890        end;
     891      opAllModel:
     892        begin // choose model
     893          ModalSelectDlg.ShowNewContent(wmModal, kChooseModel);
     894          if ModalSelectDlg.result < 0 then
     895            exit;
     896          if ModalSelectDlg.result = mixAll then
     897            Price := opAllModel
     898          else
     899            Price := OpModel + ModalSelectDlg.result
     900        end;
     901      opTreaty:
     902        begin
     903          if MyRO.Treaty[DipMem[me].pContact] < trPeace then
     904            Price := opTreaty + trPeace
     905          else
     906            Price := opTreaty + MyRO.Treaty[DipMem[me].pContact] + 1;
     907        end;
     908      { opLowTreaty:
     909        begin
     910        if MyRO.Treaty[DipMem[me].pContact]=trNone then Price:=opTreaty+trCeaseFire
     911        else Price:=opTreaty+MyRO.Treaty[DipMem[me].pContact]-1;
     912        end }
    805913    end;
    806914  end;
    807915
    808 Delivers[TButtonN(Sender).Tag and $FF]:=Price;
    809 BuildCurrentOffer;
    810 DipCommand:=scDipOffer;
    811 SetButtonStates;
    812 SmartUpdateContent;
     916  Delivers[TButtonN(Sender).Tag and $FF] := Price;
     917  BuildCurrentOffer;
     918  DipCommand := scDipOffer;
     919  SetButtonStates;
     920  SmartUpdateContent;
    813921end;
    814922
    815923procedure TNegoDlg.FastBtnClick(Sender: TObject);
    816924var
    817 NewCommand: cardinal;
    818 begin
    819 if Page<>History[me].n then exit;
    820 NewCommand:=TButtonN(Sender).Tag and $FF+scDipStart;
    821 if not (NewCommand-scDipStart in CommandAllowed) then exit;
    822 if (NewCommand=scDipCancelTreaty)
    823   and (MyRO.Turn<MyRO.LastCancelTreaty[DipMem[me].pContact]+CancelTreatyTurns) then
    824   begin
    825   SimpleMessage(Phrases.Lookup('CANCELTREATYRUSH'));
    826   exit;
    827   end;
    828 if (NewCommand=scDipOffer)
    829   and ((ClientMode=scDipCancelTreaty) or (ClientMode=scDipBreak)) then
    830   DipCommand:=scDipNotice
    831 else DipCommand:=NewCommand;
    832 ResetCurrentOffer;
    833 SetButtonStates;
    834 SmartUpdateContent;
     925  NewCommand: cardinal;
     926begin
     927  if Page <> History[me].n then
     928    exit;
     929  NewCommand := TButtonN(Sender).Tag and $FF + scDipStart;
     930  if not(NewCommand - scDipStart in CommandAllowed) then
     931    exit;
     932  if (NewCommand = scDipCancelTreaty) and
     933    (MyRO.Turn < MyRO.LastCancelTreaty[DipMem[me].pContact] + CancelTreatyTurns)
     934  then
     935  begin
     936    SimpleMessage(Phrases.Lookup('CANCELTREATYRUSH'));
     937    exit;
     938  end;
     939  if (NewCommand = scDipOffer) and ((ClientMode = scDipCancelTreaty) or
     940    (ClientMode = scDipBreak)) then
     941    DipCommand := scDipNotice
     942  else
     943    DipCommand := NewCommand;
     944  ResetCurrentOffer;
     945  SetButtonStates;
     946  SmartUpdateContent;
    835947end;
    836948
    837949end.
    838 
Note: See TracChangeset for help on using the changeset viewer.