Changeset 447 for trunk/LocalPlayer/Nego.pas
- Timestamp:
- May 19, 2022, 10:39:34 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/Nego.pas
r442 r447 15 15 type 16 16 THistory = record 17 n: Integer;17 N: Integer; 18 18 Text: array[0 .. MaxHistory - 1] of ansistring; 19 19 end; … … 59 59 procedure FormDestroy(Sender: TObject); 60 60 procedure FormMouseDown(Sender: TObject; Button: TMouseButton; 61 Shift: TShiftState; X, Y: integer);61 Shift: TShiftState; X, Y: Integer); 62 62 procedure OkBtnClick(Sender: TObject); 63 63 procedure BwdBtnClick(Sender: TObject); … … 78 78 79 79 private 80 Page, DipCommand: integer;80 Page, DipCommand: Integer; 81 81 CurrentOffer: TOffer; 82 82 MyAllowed, OppoAllowed: TPriceSet; … … 84 84 History: array [0 .. nPl - 1] of THistory; 85 85 RomanFont: TFont; 86 Costs, Delivers: array [0 .. 11] of cardinal;86 Costs, Delivers: array [0 .. 11] of Cardinal; 87 87 procedure ResetCurrentOffer; 88 88 procedure BuildCurrentOffer; 89 89 procedure FindAllowed; 90 90 procedure SplitText(Text: string; Bounds: TRect); 91 procedure PaintNationPicture(X, Y, p: integer);91 procedure PaintNationPicture(X, Y, P: Integer); 92 92 procedure SetButtonStates; 93 93 end; … … 183 183 procedure TNegoDlg.ResetCurrentOffer; 184 184 var 185 i: integer;185 I: Integer; 186 186 begin 187 187 CurrentOffer.nDeliver := 0; 188 188 CurrentOffer.nCost := 0; 189 for i:= 0 to 11 do190 Costs[ i] := $FFFFFFFF;191 for i:= 0 to 11 do192 Delivers[ i] := $FFFFFFFF;189 for I := 0 to 11 do 190 Costs[I] := $FFFFFFFF; 191 for I := 0 to 11 do 192 Delivers[I] := $FFFFFFFF; 193 193 end; 194 194 … … 201 201 else 202 202 PassBtn.SmartHint := Phrases.Lookup('BTN_PASS'); 203 case MyRO.Treaty[DipMem[ me].pContact] of203 case MyRO.Treaty[DipMem[Me].pContact] of 204 204 trNone: 205 205 begin … … 237 237 begin 238 238 if ClientMode <> scDipStart then 239 with History[ me] do240 begin 241 if n= MaxHistory then242 begin 243 move(Text[2], Text[0], (MaxHistory - 2) * sizeof(integer));244 dec(n, 2);239 with History[Me] do 240 begin 241 if N = MaxHistory then 242 begin 243 Move(Text[2], Text[0], (MaxHistory - 2) * SizeOf(Integer)); 244 Dec(N, 2); 245 245 end; 246 Text[ n] := copy(DipCommandToString(DipMem[me].pContact, me,247 DipMem[ me].FormerTreaty, DipMem[me].SentCommand, ClientMode,248 DipMem[ me].SentOffer, ReceivedOffer), 1, 255);249 inc(n);246 Text[N] := Copy(DipCommandToString(DipMem[Me].pContact, Me, 247 DipMem[Me].FormerTreaty, DipMem[Me].SentCommand, ClientMode, 248 DipMem[Me].SentOffer, ReceivedOffer), 1, 255); 249 Inc(N); 250 250 end; 251 assert(History[me].nmod 2 = 1);252 253 Page := History[ me].n;251 Assert(History[Me].N mod 2 = 1); 252 253 Page := History[Me].N; 254 254 FindAllowed; 255 255 ResetCurrentOffer; … … 283 283 procedure TNegoDlg.SplitText(Text: string; Bounds: TRect); 284 284 var 285 nLines, Line, Start, Stop, OrdinaryStop, Indent, Y: integer;286 s: string;287 preview, Dot: boolean;285 nLines, Line, Start, Stop, OrdinaryStop, Indent, Y: Integer; 286 S: string; 287 preview, Dot: Boolean; 288 288 begin 289 289 nLines := 0; 290 for preview := true downto false do290 for preview := True downto False do 291 291 begin 292 292 Start := 1; … … 295 295 while Start < Length(Text) do 296 296 begin 297 Dot := false;297 Dot := False; 298 298 if (Start = 1) or (Text[Start - 1] = '\') then 299 299 if Text[Start] = '-' then 300 300 begin 301 301 Indent := ListIndent; 302 inc(Start);302 Inc(Start); 303 303 if Start = Length(Text) then 304 break;305 Dot := true;304 Break; 305 Dot := True; 306 306 end 307 307 else … … 310 310 while (Stop < Length(Text)) and (Text[Stop] <> '\') do 311 311 begin 312 inc(Stop);312 Inc(Stop); 313 313 if BiColorTextWidth(Offscreen.Canvas, 314 copy(Text, Start, Stop - Start + 1)) > Bounds.Right - Bounds.Left -314 Copy(Text, Start, Stop - Start + 1)) > Bounds.Right - Bounds.Left - 315 315 PaperBorder_Left - PaperBorder_Right - Indent then 316 316 begin 317 dec(Stop);318 break317 Dec(Stop); 318 Break 319 319 end; 320 320 end; … … 324 324 while (Text[OrdinaryStop + 1] <> ' ') and 325 325 (Text[OrdinaryStop + 1] <> '\') do 326 dec(OrdinaryStop);326 Dec(OrdinaryStop); 327 327 if (OrdinaryStop + 1 - Start) * 2 >= Stop - Start then 328 328 Stop := OrdinaryStop … … 334 334 Sprite(Offscreen, HGrSystem, Bounds.Left + PaperBorder_Left + 335 335 (ListIndent - 14), Y + 7, 8, 8, 90, 16); 336 s := copy(Text, Start, Stop - Start + 1);336 S := Copy(Text, Start, Stop - Start + 1); 337 337 BiColorTextOut(Offscreen.Canvas, Colors.Canvas.Pixels[clkMisc, 338 338 cliPaperText], $7F007F, Bounds.Left + PaperBorder_Left + 339 Indent, Y, s);339 Indent, Y, S); 340 340 end; 341 inc(Line);341 Inc(Line); 342 342 Start := Stop + 2; 343 343 end; … … 348 348 procedure TNegoDlg.FindAllowed; 349 349 var 350 i: integer;350 I: Integer; 351 351 begin 352 352 CommandAllowed := [scDipOffer - scDipStart]; 353 353 if ClientMode <> scDipBreak then 354 include(CommandAllowed, scDipBreak - scDipStart);355 if MyRO.Treaty[DipMem[ me].pContact] >= trPeace then356 include(CommandAllowed, scDipCancelTreaty - scDipStart);357 if (ClientMode = scDipOffer) and (Server(scDipAccept - sExecute, me, 0, nil^)354 Include(CommandAllowed, scDipBreak - scDipStart); 355 if MyRO.Treaty[DipMem[Me].pContact] >= trPeace then 356 Include(CommandAllowed, scDipCancelTreaty - scDipStart); 357 if (ClientMode = scDipOffer) and (Server(scDipAccept - sExecute, Me, 0, nil^) 358 358 >= rExecuted) then 359 include(CommandAllowed, scDipAccept - scDipStart);359 Include(CommandAllowed, scDipAccept - scDipStart); 360 360 361 361 MyAllowed := [opChoose shr 24, opMoney shr 24]; 362 362 OppoAllowed := [opChoose shr 24, opMoney shr 24]; 363 if not IsCivilReportNew(DipMem[ me].pContact) then363 if not IsCivilReportNew(DipMem[Me].pContact) then 364 364 begin // no up-to-date civil report 365 365 MyAllowed := MyAllowed + [opCivilReport shr 24]; 366 for i:= 0 to nAdv - 1 do367 if MyRO.Tech[ i] >= tsApplicable then366 for I := 0 to nAdv - 1 do 367 if MyRO.Tech[I] >= tsApplicable then 368 368 begin 369 369 MyAllowed := MyAllowed + [opAllTech shr 24]; 370 break370 Break 371 371 end; 372 372 OppoAllowed := OppoAllowed + [opCivilReport shr 24, opAllTech shr 24]; … … 374 374 else 375 375 begin // check techs 376 for i:= 0 to nAdv - 1 do377 if not( iin FutureTech) then378 if (MyRO.Tech[ i] < tsSeen) and379 (MyRO.EnemyReport[DipMem[ me].pContact].Tech[i] >= tsApplicable) then376 for I := 0 to nAdv - 1 do 377 if not(I in FutureTech) then 378 if (MyRO.Tech[I] < tsSeen) and 379 (MyRO.EnemyReport[DipMem[Me].pContact].Tech[I] >= tsApplicable) then 380 380 OppoAllowed := OppoAllowed + [opAllTech shr 24] 381 else if (MyRO.EnemyReport[DipMem[ me].pContact].Tech[i] < tsSeen) and382 (MyRO.Tech[ i] >= tsApplicable) then381 else if (MyRO.EnemyReport[DipMem[Me].pContact].Tech[I] < tsSeen) and 382 (MyRO.Tech[I] >= tsApplicable) then 383 383 MyAllowed := MyAllowed + [opAllTech shr 24]; 384 384 end; 385 if not IsMilReportNew(DipMem[ me].pContact) then385 if not IsMilReportNew(DipMem[Me].pContact) then 386 386 begin // no up-to-date military report 387 387 MyAllowed := MyAllowed + [opMilReport shr 24]; … … 397 397 OppoAllowed := OppoAllowed + [opAllModel shr 24]; 398 398 end; 399 if MyRO.Treaty[DipMem[ me].pContact] < trAlliance then399 if MyRO.Treaty[DipMem[Me].pContact] < trAlliance then 400 400 begin 401 401 MyAllowed := MyAllowed + [opTreaty shr 24, opMap shr 24]; … … 407 407 OppoAllowed:=OppoAllowed+[opLowTreaty shr 24]; 408 408 end; } 409 for i:= 0 to nShipPart - 1 do410 begin 411 if MyRO.Ship[ me].Parts[i] > 0 then412 include(MyAllowed, opShipParts shr 24);413 if MyRO.Ship[DipMem[ me].pContact].Parts[i] > 0 then414 include(OppoAllowed, opShipParts shr 24);415 end; 416 MyAllowed := MyAllowed - DipMem[ me].DeliveredPrices *409 for I := 0 to nShipPart - 1 do 410 begin 411 if MyRO.Ship[Me].Parts[I] > 0 then 412 Include(MyAllowed, opShipParts shr 24); 413 if MyRO.Ship[DipMem[Me].pContact].Parts[I] > 0 then 414 Include(OppoAllowed, opShipParts shr 24); 415 end; 416 MyAllowed := MyAllowed - DipMem[Me].DeliveredPrices * 417 417 [opAllTech shr 24, opAllModel shr 24, opCivilReport shr 24, 418 418 opMilReport shr 24, opMap shr 24]; 419 OppoAllowed := OppoAllowed - DipMem[ me].ReceivedPrices *419 OppoAllowed := OppoAllowed - DipMem[Me].ReceivedPrices * 420 420 [opAllTech shr 24, opAllModel shr 24, opCivilReport shr 24, 421 421 opMilReport shr 24, opMap shr 24]; 422 422 end; 423 423 424 procedure TNegoDlg.PaintNationPicture(X, Y, p: integer);424 procedure TNegoDlg.PaintNationPicture(X, Y, P: Integer); 425 425 begin 426 426 with Offscreen.Canvas do 427 427 begin 428 428 Pen.Color := $000000; 429 Brush.Color := Tribe[ p].Color;429 Brush.Color := Tribe[P].Color; 430 430 Rectangle(X - 6, Y - 1, X + 70, Y + 49); 431 431 Brush.Color := $000000; 432 Tribe[ p].InitAge(GetAge(p));433 if Assigned(Tribe[ p].faceHGr) then434 Dump(Offscreen, Tribe[ p].faceHGr, X, Y, 64, 48,435 1 + Tribe[ p].facepix mod 10 * 65, 1 + Tribe[p].facepix div 10 * 49)432 Tribe[P].InitAge(GetAge(P)); 433 if Assigned(Tribe[P].faceHGr) then 434 Dump(Offscreen, Tribe[P].faceHGr, X, Y, 64, 48, 435 1 + Tribe[P].facepix mod 10 * 65, 1 + Tribe[P].facepix div 10 * 49) 436 436 else 437 437 FillRect(Rect(X, Y, X + 64, Y + 48)); … … 443 443 procedure TNegoDlg.SetButtonStates; 444 444 var 445 cix: integer;446 IsActionPage: boolean;447 begin 448 IsActionPage := Page = History[ me].n;445 cix: Integer; 446 IsActionPage: Boolean; 447 begin 448 IsActionPage := Page = History[Me].N; 449 449 450 450 AcceptBtn.Possible := IsActionPage and … … 483 483 procedure TNegoDlg.OffscreenPaint; 484 484 var 485 i, cred: integer;486 s: string;487 OkEnabled: boolean;485 I, cred: Integer; 486 S: string; 487 OkEnabled: Boolean; 488 488 begin 489 489 if (OffscreenUser <> nil) and (OffscreenUser <> self) then … … 492 492 OffscreenUser := self; 493 493 494 if (DipCommand >= 0) and (Page = History[ me].n) then495 History[ me].Text[History[me].n] :=496 copy(DipCommandToString(me, DipMem[me].pContact,497 MyRO.Treaty[DipMem[ me].pContact], ClientMode, DipCommand, ReceivedOffer,494 if (DipCommand >= 0) and (Page = History[Me].N) then 495 History[Me].Text[History[Me].N] := 496 Copy(DipCommandToString(Me, DipMem[Me].pContact, 497 MyRO.Treaty[DipMem[Me].pContact], ClientMode, DipCommand, ReceivedOffer, 498 498 CurrentOffer), 1, 255); 499 499 500 FwdBtn.Visible := Page < History[ me].n;500 FwdBtn.Visible := Page < History[Me].N; 501 501 BwdBtn.Visible := Page >= 2; 502 if Page < History[ me].nthen503 OkEnabled := false502 if Page < History[Me].N then 503 OkEnabled := False 504 504 else if DipCommand = scDipOffer then 505 OkEnabled := Server(scDipOffer - sExecute, me, 0, CurrentOffer) >= rExecuted505 OkEnabled := Server(scDipOffer - sExecute, Me, 0, CurrentOffer) >= rExecuted 506 506 else 507 507 OkEnabled := DipCommand >= 0; … … 532 532 yPad1 + 41 + 42 * 2, $FFFFFF, $B0B0B0); 533 533 534 PaintNationPicture(xNationPicture0, yNationPicture, DipMem[ me].pContact);535 PaintNationPicture(xNationPicture1, yNationPicture, me);536 537 if History[ me].Text[Page - 1] <> '' then534 PaintNationPicture(xNationPicture0, yNationPicture, DipMem[Me].pContact); 535 PaintNationPicture(xNationPicture1, yNationPicture, Me); 536 537 if History[Me].Text[Page - 1] <> '' then 538 538 begin 539 539 FillSeamless(Offscreen.Canvas, xText0, yText0, wText, hText, 0, 0, Paper); 540 i:= Page - 1;541 if History[ me].Text[0] = '' then542 dec(i);543 if i< 16 then540 I := Page - 1; 541 if History[Me].Text[0] = '' then 542 Dec(I); 543 if I < 16 then 544 544 begin 545 545 Offscreen.Canvas.Font.Assign(RomanFont); 546 546 Offscreen.Canvas.TextOut 547 (xText0 + (wText - Offscreen.Canvas.TextWidth(RomanNo[ i])) div 2,548 yText0 + (hText - Offscreen.Canvas.TextHeight(RomanNo[ i])) div 2,549 RomanNo[ i]);547 (xText0 + (wText - Offscreen.Canvas.TextWidth(RomanNo[I])) div 2, 548 yText0 + (hText - Offscreen.Canvas.TextHeight(RomanNo[I])) div 2, 549 RomanNo[I]); 550 550 end 551 551 end; 552 552 FillSeamless(Offscreen.Canvas, xText1, yText1, wText, hText, 0, 0, Paper); 553 i:= Page;554 if History[ me].Text[0] = '' then555 dec(i);556 if i< 16 then553 I := Page; 554 if History[Me].Text[0] = '' then 555 Dec(I); 556 if I < 16 then 557 557 begin 558 558 Offscreen.Canvas.Font.Assign(RomanFont); 559 559 Offscreen.Canvas.TextOut 560 (xText1 + (wText - Offscreen.Canvas.TextWidth(RomanNo[ i])) div 2,561 yText1 + (hText - Offscreen.Canvas.TextHeight(RomanNo[ i])) div 2,562 RomanNo[ i]);560 (xText1 + (wText - Offscreen.Canvas.TextWidth(RomanNo[I])) div 2, 561 yText1 + (hText - Offscreen.Canvas.TextHeight(RomanNo[I])) div 2, 562 RomanNo[I]); 563 563 end; 564 564 with Offscreen.Canvas do 565 565 begin 566 566 Brush.Color := MainTexture.ColorBevelShade; 567 if History[ me].Text[Page - 1] <> '' then567 if History[Me].Text[Page - 1] <> '' then 568 568 begin 569 569 FillRect(Rect(xText0 + wText, yText0 + PaperShade, … … 583 583 { if Page=History[me].n then 584 584 begin // show attitude 585 s:=Phrases.Lookup('ATTITUDE',MyRO.EnemyReport[DipMem[me].pContact].Attitude);585 S:=Phrases.Lookup('ATTITUDE',MyRO.EnemyReport[DipMem[Me].pContact].Attitude); 586 586 //LoweredTextOut(Offscreen.Canvas,-1,MainTexture, 587 587 RisedTextOut(Offscreen.Canvas,xText0+wText div 2- 588 BiColorTextWidth(Offscreen.Canvas, s) div 2,yAttitude,s);589 s:=Phrases.Lookup('ATTITUDE',MyRO.Attitude[DipMem[me].pContact]);588 BiColorTextWidth(Offscreen.Canvas,S) div 2,yAttitude,S); 589 S:=Phrases.Lookup('ATTITUDE',MyRO.Attitude[DipMem[Me].pContact]); 590 590 //LoweredTextOut(Offscreen.Canvas,-1,MainTexture, 591 591 RisedTextOut(Offscreen.Canvas,xText1+wText div 2- 592 BiColorTextWidth(Offscreen.Canvas, s) div 2,yAttitude,s);592 BiColorTextWidth(Offscreen.Canvas,S) div 2,yAttitude,S); 593 593 end; } 594 594 595 if History[ me].Text[Page - 1] <> '' then596 SplitText(History[ me].Text[Page - 1], Rect(xText0, yText0, xText0 + wText,595 if History[Me].Text[Page - 1] <> '' then 596 SplitText(History[Me].Text[Page - 1], Rect(xText0, yText0, xText0 + wText, 597 597 yText0 + hText)); 598 if (Page < History[ me].n) or OkEnabled then599 SplitText(History[ me].Text[Page], Rect(xText1, yText1, xText1 + wText,598 if (Page < History[Me].N) or OkEnabled then 599 SplitText(History[Me].Text[Page], Rect(xText1, yText1, xText1 + wText, 600 600 yText1 + hText)); 601 601 602 602 // show credibility 603 603 Offscreen.Canvas.Font.Assign(UniFont[ftTiny]); 604 cred := MyRO.EnemyReport[DipMem[ me].pContact].Credibility;604 cred := MyRO.EnemyReport[DipMem[Me].pContact].Credibility; 605 605 case cred of 606 606 0 .. 49: 607 i:= 3;607 I := 3; 608 608 50 .. 90: 609 i:= 0;609 I := 0; 610 610 91 .. 100: 611 i:= 1;612 end; 613 PaintProgressBar(Offscreen.Canvas, i, xCred0, yCred0 + 17, (cred + 2) div 5,611 I := 1; 612 end; 613 PaintProgressBar(Offscreen.Canvas, I, xCred0, yCred0 + 17, (cred + 2) div 5, 614 614 0, 20, MainTexture); 615 s:= IntToStr(cred);615 S := IntToStr(cred); 616 616 RisedTextOut(Offscreen.Canvas, xCred0 + 10 - 617 (BiColorTextWidth(Offscreen.Canvas, s) + 1) div 2, yCred0, s);617 (BiColorTextWidth(Offscreen.Canvas, S) + 1) div 2, yCred0, S); 618 618 case MyRO.Credibility of 619 619 0 .. 49: 620 i:= 3;620 I := 3; 621 621 50 .. 90: 622 i:= 0;622 I := 0; 623 623 91 .. 100: 624 i:= 1;625 end; 626 PaintProgressBar(Offscreen.Canvas, i, xCred1, yCred1 + 17,624 I := 1; 625 end; 626 PaintProgressBar(Offscreen.Canvas, I, xCred1, yCred1 + 17, 627 627 (MyRO.Credibility + 2) div 5, 0, 20, MainTexture); 628 s:= IntToStr(MyRO.Credibility);628 S := IntToStr(MyRO.Credibility); 629 629 RisedTextOut(Offscreen.Canvas, xCred1 + 10 - 630 (BiColorTextWidth(Offscreen.Canvas, s) + 1) div 2, yCred1, s);630 (BiColorTextWidth(Offscreen.Canvas, S) + 1) div 2, yCred1, S); 631 631 632 632 MarkUsedOffscreen(ClientWidth, ClientHeight); … … 635 635 procedure TNegoDlg.Initiate; 636 636 begin 637 History[ me].n:= 1;638 History[ me].Text[0] := '';637 History[Me].N := 1; 638 History[Me].Text[0] := ''; 639 639 end; 640 640 641 641 procedure TNegoDlg.Respond; 642 642 begin 643 History[ me].n:= 0;643 History[Me].N := 0; 644 644 end; 645 645 646 646 procedure TNegoDlg.FormMouseDown(Sender: TObject; Button: TMouseButton; 647 Shift: TShiftState; X, Y: integer);647 Shift: TShiftState; X, Y: Integer); 648 648 begin 649 649 if (X >= xNationPicture0) and (X < xNationPicture0 + 64) and 650 650 (Y >= yNationPicture) and (Y < yNationPicture + 48) then 651 NatStatDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), DipMem[ me].pContact)651 NatStatDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), DipMem[Me].pContact) 652 652 else if (X >= xNationPicture1) and (X < xNationPicture1 + 64) and 653 653 (Y >= yNationPicture) and (Y < yNationPicture + 48) then 654 NatStatDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), me)654 NatStatDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), Me) 655 655 end; 656 656 657 657 procedure TNegoDlg.BwdBtnClick(Sender: TObject); 658 658 begin 659 dec(Page, 2);659 Dec(Page, 2); 660 660 SetButtonStates; 661 661 SmartUpdateContent; … … 664 664 procedure TNegoDlg.FwdBtnClick(Sender: TObject); 665 665 begin 666 inc(Page, 2);666 Inc(Page, 2); 667 667 SetButtonStates; 668 668 SmartUpdateContent; … … 671 671 procedure TNegoDlg.OkBtnClick(Sender: TObject); 672 672 begin 673 inc(History[me].n);673 Inc(History[Me].N); 674 674 if DipCommand = scDipOffer then 675 675 MainScreen.OfferCall(CurrentOffer) … … 697 697 procedure TNegoDlg.BuildCurrentOffer; 698 698 var 699 i: integer;699 I: Integer; 700 700 begin 701 701 CurrentOffer.nDeliver := 0; 702 702 CurrentOffer.nCost := 0; 703 for i:= 0 to 11 do704 if Delivers[ i] <> $FFFFFFFF then705 begin 706 CurrentOffer.Price[CurrentOffer.nDeliver] := Delivers[ i];707 inc(CurrentOffer.nDeliver);703 for I := 0 to 11 do 704 if Delivers[I] <> $FFFFFFFF then 705 begin 706 CurrentOffer.Price[CurrentOffer.nDeliver] := Delivers[I]; 707 Inc(CurrentOffer.nDeliver); 708 708 end; 709 for i:= 0 to 11 do710 if Costs[ i] <> $FFFFFFFF then709 for I := 0 to 11 do 710 if Costs[I] <> $FFFFFFFF then 711 711 begin 712 712 CurrentOffer.Price[CurrentOffer.nDeliver + CurrentOffer.nCost] := 713 Costs[ i];714 inc(CurrentOffer.nCost);713 Costs[I]; 714 Inc(CurrentOffer.nCost); 715 715 end; 716 716 end; … … 718 718 procedure TNegoDlg.WantClick(Sender: TObject); 719 719 var 720 a, i, max: integer;721 Price: cardinal;722 begin 723 if (Page <> History[ me].n) or (ClientMode = scDipCancelTreaty) or720 A, I, Max: Integer; 721 Price: Cardinal; 722 begin 723 if (Page <> History[Me].N) or (ClientMode = scDipCancelTreaty) or 724 724 (ClientMode = scDipBreak) then 725 exit;725 Exit; 726 726 if Costs[TButtonN(Sender).Tag and $FF] <> $FFFFFFFF then 727 727 Price := $FFFFFFFF // toggle off … … 731 731 begin 732 732 SimpleMessage(Phrases.Lookup('MAX2WANTS')); 733 exit733 Exit 734 734 end; 735 735 Price := ButtonPrice[TButtonN(Sender).Tag and $FF]; 736 736 if not(Price shr 24 in OppoAllowed) then 737 exit;737 Exit; 738 738 case Price of 739 739 opCivilReport, opMilReport: 740 inc(Price, DipMem[me].pContact shl 16 + MyRO.Turn);740 Inc(Price, DipMem[Me].pContact shl 16 + MyRO.Turn); 741 741 // !!! choose player and year! 742 742 opMoney: … … 747 747 InputDlg.ShowModal; 748 748 if InputDlg.ModalResult <> mrOK then 749 exit;750 val(InputDlg.EInput.Text, a, i);751 if ( i <> 0) or (a <= 0) or (a>= MaxMoneyPrice) then752 exit;753 inc(Price, a);749 Exit; 750 val(InputDlg.EInput.Text, A, I); 751 if (I <> 0) or (A <= 0) or (A >= MaxMoneyPrice) then 752 Exit; 753 Inc(Price, A); 754 754 end; 755 755 opShipParts: … … 765 765 ShowModal; 766 766 if ModalResult <> mrOK then 767 exit767 Exit 768 768 end; 769 769 ModalSelectDlg.ShowNewContent(wmModal, kEShipPart); 770 if ModalSelectDlg. result < 0 then771 exit;772 inc(Price, ModalSelectDlg.result shl 16);773 max := MyRO.Ship[DipMem[me].pContact].Parts[ModalSelectDlg.result];770 if ModalSelectDlg.Result < 0 then 771 Exit; 772 Inc(Price, ModalSelectDlg.Result shl 16); 773 Max := MyRO.Ship[DipMem[Me].pContact].Parts[ModalSelectDlg.Result]; 774 774 InputDlg.Caption := Phrases.Lookup('TITLE_NUMBER'); 775 775 InputDlg.EInput.Text := ''; … … 777 777 InputDlg.ShowModal; 778 778 if InputDlg.ModalResult <> mrOK then 779 exit;780 val(InputDlg.EInput.Text, a, i);781 if ( i <> 0) or (a<= 0) then782 exit;783 if a > max then784 a := max;785 if a> MaxShipPartPrice then786 a:= MaxShipPartPrice;787 inc(Price, a);779 Exit; 780 val(InputDlg.EInput.Text, A, I); 781 if (I <> 0) or (A <= 0) then 782 Exit; 783 if A > Max then 784 A := Max; 785 if A > MaxShipPartPrice then 786 A := MaxShipPartPrice; 787 Inc(Price, A); 788 788 end; 789 789 opAllTech: 790 790 begin // choose technology 791 791 ModalSelectDlg.ShowNewContent(wmModal, kChooseETech); 792 if ModalSelectDlg. result < 0 then793 exit;794 if ModalSelectDlg. result = adAll then792 if ModalSelectDlg.Result < 0 then 793 Exit; 794 if ModalSelectDlg.Result = adAll then 795 795 Price := opAllTech 796 796 else 797 Price := OpTech + ModalSelectDlg. result;797 Price := OpTech + ModalSelectDlg.Result; 798 798 end; 799 799 opAllModel: 800 800 begin // choose model 801 801 ModalSelectDlg.ShowNewContent(wmModal, kChooseEModel); 802 if ModalSelectDlg. result < 0 then803 exit;804 if ModalSelectDlg. result = mixAll then802 if ModalSelectDlg.Result < 0 then 803 Exit; 804 if ModalSelectDlg.Result = mixAll then 805 805 Price := opAllModel 806 806 else 807 Price := OpModel + MyRO.EnemyModel[ModalSelectDlg. result].mix;807 Price := OpModel + MyRO.EnemyModel[ModalSelectDlg.Result].mix; 808 808 end; 809 809 opTreaty: 810 810 begin 811 if MyRO.Treaty[DipMem[ me].pContact] < trPeace then811 if MyRO.Treaty[DipMem[Me].pContact] < trPeace then 812 812 Price := opTreaty + trPeace 813 813 else 814 Price := opTreaty + MyRO.Treaty[DipMem[ me].pContact] + 1;814 Price := opTreaty + MyRO.Treaty[DipMem[Me].pContact] + 1; 815 815 end; 816 816 { opLowTreaty: 817 817 begin 818 if MyRO.Treaty[DipMem[ me].pContact]=trNone then Price:=opTreaty+trCeaseFire819 else Price:=opTreaty+MyRO.Treaty[DipMem[ me].pContact]-1;818 if MyRO.Treaty[DipMem[Me].pContact]=trNone then Price:=opTreaty+trCeaseFire 819 else Price:=opTreaty+MyRO.Treaty[DipMem[Me].pContact]-1; 820 820 end } 821 821 end; … … 831 831 procedure TNegoDlg.OfferClick(Sender: TObject); 832 832 var 833 a, i, max: integer;834 Price: cardinal;835 begin 836 if (Page <> History[ me].n) or (ClientMode = scDipCancelTreaty) or833 A, I, Max: Integer; 834 Price: Cardinal; 835 begin 836 if (Page <> History[Me].N) or (ClientMode = scDipCancelTreaty) or 837 837 (ClientMode = scDipBreak) then 838 exit;838 Exit; 839 839 if Delivers[TButtonN(Sender).Tag and $FF] <> $FFFFFFFF then 840 840 Price := $FFFFFFFF // toggle off … … 844 844 begin 845 845 SimpleMessage(Phrases.Lookup('MAX2OFFERS')); 846 exit;846 Exit; 847 847 end; 848 848 Price := ButtonPrice[TButtonN(Sender).Tag and $FF]; 849 849 if not(Price shr 24 in MyAllowed) then 850 exit;850 Exit; 851 851 case Price of 852 852 opCivilReport, opMilReport: 853 inc(Price, me shl 16 + MyRO.Turn); // !!! choose player and year!853 Inc(Price, Me shl 16 + MyRO.Turn); // !!! choose player and year! 854 854 opMoney: 855 855 begin // choose amount … … 859 859 InputDlg.ShowModal; 860 860 if InputDlg.ModalResult <> mrOK then 861 exit;862 val(InputDlg.EInput.Text, a, i);863 if ( i <> 0) or (a <= 0) or (a>= MaxMoneyPrice) then864 exit;865 if (Price = opMoney) and ( a> MyRO.Money) then866 a:= MyRO.Money;867 inc(Price, a);861 Exit; 862 val(InputDlg.EInput.Text, A, I); 863 if (I <> 0) or (A <= 0) or (A >= MaxMoneyPrice) then 864 Exit; 865 if (Price = opMoney) and (A > MyRO.Money) then 866 A := MyRO.Money; 867 Inc(Price, A); 868 868 end; 869 869 opShipParts: 870 870 begin // choose type and number 871 871 ModalSelectDlg.ShowNewContent(wmModal, kShipPart); 872 if ModalSelectDlg. result < 0 then873 exit;874 inc(Price, ModalSelectDlg.result shl 16);875 max := MyRO.Ship[me].Parts[ModalSelectDlg.result];872 if ModalSelectDlg.Result < 0 then 873 Exit; 874 Inc(Price, ModalSelectDlg.Result shl 16); 875 Max := MyRO.Ship[Me].Parts[ModalSelectDlg.Result]; 876 876 InputDlg.Caption := Phrases.Lookup('TITLE_NUMBER'); 877 877 InputDlg.EInput.Text := ''; … … 879 879 InputDlg.ShowModal; 880 880 if InputDlg.ModalResult <> mrOK then 881 exit;882 val(InputDlg.EInput.Text, a, i);883 if ( i <> 0) or (a<= 0) then884 exit;885 if a > max then886 a := max;887 if a> MaxShipPartPrice then888 a:= MaxShipPartPrice;889 inc(Price, a);881 Exit; 882 val(InputDlg.EInput.Text, A, I); 883 if (I <> 0) or (A <= 0) then 884 Exit; 885 if A > Max then 886 A := Max; 887 if A > MaxShipPartPrice then 888 A := MaxShipPartPrice; 889 Inc(Price, A); 890 890 end; 891 891 opAllTech: 892 892 begin // choose technology 893 893 ModalSelectDlg.ShowNewContent(wmModal, kChooseTech); 894 if ModalSelectDlg. result < 0 then895 exit;896 if ModalSelectDlg. result = adAll then894 if ModalSelectDlg.Result < 0 then 895 Exit; 896 if ModalSelectDlg.Result = adAll then 897 897 Price := opAllTech 898 898 else 899 Price := OpTech + ModalSelectDlg. result;899 Price := OpTech + ModalSelectDlg.Result; 900 900 end; 901 901 opAllModel: 902 902 begin // choose model 903 903 ModalSelectDlg.ShowNewContent(wmModal, kChooseModel); 904 if ModalSelectDlg. result < 0 then905 exit;906 if ModalSelectDlg. result = mixAll then904 if ModalSelectDlg.Result < 0 then 905 Exit; 906 if ModalSelectDlg.Result = mixAll then 907 907 Price := opAllModel 908 908 else 909 Price := OpModel + ModalSelectDlg. result;909 Price := OpModel + ModalSelectDlg.Result; 910 910 end; 911 911 opTreaty: 912 912 begin 913 if MyRO.Treaty[DipMem[ me].pContact] < trPeace then913 if MyRO.Treaty[DipMem[Me].pContact] < trPeace then 914 914 Price := opTreaty + trPeace 915 915 else 916 Price := opTreaty + MyRO.Treaty[DipMem[ me].pContact] + 1;916 Price := opTreaty + MyRO.Treaty[DipMem[Me].pContact] + 1; 917 917 end; 918 918 { opLowTreaty: 919 919 begin 920 if MyRO.Treaty[DipMem[ me].pContact]=trNone then Price:=opTreaty+trCeaseFire921 else Price:=opTreaty+MyRO.Treaty[DipMem[ me].pContact]-1;920 if MyRO.Treaty[DipMem[Me].pContact]=trNone then Price:=opTreaty+trCeaseFire 921 else Price:=opTreaty+MyRO.Treaty[DipMem[Me].pContact]-1; 922 922 end } 923 923 end; … … 933 933 procedure TNegoDlg.FastBtnClick(Sender: TObject); 934 934 var 935 NewCommand: cardinal;936 begin 937 if Page <> History[ me].nthen938 exit;935 NewCommand: Cardinal; 936 begin 937 if Page <> History[Me].N then 938 Exit; 939 939 NewCommand := TButtonN(Sender).Tag and $FF + scDipStart; 940 940 if not(NewCommand - scDipStart in CommandAllowed) then 941 exit;941 Exit; 942 942 if (NewCommand = scDipCancelTreaty) and 943 (MyRO.Turn < MyRO.LastCancelTreaty[DipMem[ me].pContact] + CancelTreatyTurns)943 (MyRO.Turn < MyRO.LastCancelTreaty[DipMem[Me].pContact] + CancelTreatyTurns) 944 944 then 945 945 begin 946 946 SimpleMessage(Phrases.Lookup('CANCELTREATYRUSH')); 947 exit;947 Exit; 948 948 end; 949 949 if (NewCommand = scDipOffer) and ((ClientMode = scDipCancelTreaty) or
Note:
See TracChangeset
for help on using the changeset viewer.