Changeset 465 for branches/highdpi/LocalPlayer/Nego.pas
- Timestamp:
- Nov 30, 2023, 10:16:14 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/LocalPlayer/Nego.pas
r361 r465 5 5 6 6 uses 7 UDpiControls, ScreenTools, BaseWin, Protocol, Term,LCLType, SysUtils, Classes, Graphics,7 UDpiControls, ScreenTools, BaseWin, Protocol, LCLType, SysUtils, Classes, Graphics, 8 8 Controls, Forms, ButtonA, ButtonB, ButtonN; 9 9 … … 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; 20 20 21 21 TCommandAllowedEnum = scDipNoticeStart..scDipBreakStart; 22 TPriceSet = set of $00..$FF; 22 23 23 24 { TNegoDlg } … … 59 60 procedure FormDestroy(Sender: TObject); 60 61 procedure FormMouseDown(Sender: TObject; Button: TMouseButton; 61 Shift: TShiftState; X, Y: integer);62 Shift: TShiftState; X, Y: Integer); 62 63 procedure OkBtnClick(Sender: TObject); 63 64 procedure BwdBtnClick(Sender: TObject); … … 69 70 procedure OfferClick(Sender: TObject); 70 71 procedure FastBtnClick(Sender: TObject); 71 72 72 public 73 73 procedure Initiate; // first turn of negotiation, initiate … … 75 75 procedure Start; // next turn of negotiation 76 76 procedure OffscreenPaint; override; 77 procedure ShowNewContent(NewMode: integer); 78 77 procedure ShowNewContent(NewMode: TWindowMode); 79 78 private 80 Page, DipCommand: integer;79 Page, DipCommand: Integer; 81 80 CurrentOffer: TOffer; 82 81 MyAllowed, OppoAllowed: TPriceSet; … … 84 83 History: array [0 .. nPl - 1] of THistory; 85 84 RomanFont: TDpiFont; 86 Costs, Delivers: array [0 .. 11] of cardinal;85 Costs, Delivers: array [0 .. 11] of Cardinal; 87 86 procedure ResetCurrentOffer; 88 87 procedure BuildCurrentOffer; 89 88 procedure FindAllowed; 90 89 procedure SplitText(Text: string; Bounds: TRect); 91 procedure PaintNationPicture(X, Y, p: integer);90 procedure PaintNationPicture(X, Y, P: Integer); 92 91 procedure SetButtonStates; 93 92 end; 94 93 95 var96 NegoDlg: TNegoDlg;97 94 98 95 implementation 99 96 100 97 uses 101 Messg, ClientTools, Diplomacy, Inp, Select, NatStat, Tribes, MessgEx ;98 Messg, ClientTools, Diplomacy, Inp, Select, NatStat, Tribes, MessgEx, Term; 102 99 103 100 {$R *.lfm} … … 136 133 'VII', 'VIII', 'IX', 'X', 'XI', 'XII', 'XIII', 'XIV', 'XV', 'XVI'); 137 134 138 ButtonPrice: array [0 .. 11] of cardinal = (opChoose, opCivilReport,135 ButtonPrice: array [0 .. 11] of Cardinal = (opChoose, opCivilReport, 139 136 opMilReport, opMap, opAllTech, opAllTech, opAllModel, opMoney, opTreaty, 140 137 opLowTreaty, opShipParts, opShipParts); … … 142 139 procedure TNegoDlg.FormCreate(Sender: TObject); 143 140 var 144 cix: integer;141 cix: Integer; 145 142 begin 146 143 InitButtons; … … 153 150 BackGraphic := HGrSystem2.Data; 154 151 case Tag shr 8 of 155 1: 156 SmartHint := Phrases.Lookup('WANT', ButtonIndex - 6); 157 2: 158 SmartHint := Phrases.Lookup('OFFER', ButtonIndex - 6); 152 1: SmartHint := Phrases.Lookup('WANT', ButtonIndex - 6); 153 2: SmartHint := Phrases.Lookup('OFFER', ButtonIndex - 6); 159 154 end; 160 155 end; 161 156 162 fillchar(History, sizeof(History), 0);157 FillChar(History, SizeOf(History), 0); 163 158 RomanFont := TDpiFont.Create; 164 159 RomanFont.Name := 'Times New Roman'; … … 184 179 procedure TNegoDlg.ResetCurrentOffer; 185 180 var 186 i: integer;181 I: Integer; 187 182 begin 188 183 CurrentOffer.nDeliver := 0; 189 184 CurrentOffer.nCost := 0; 190 for i:= 0 to 11 do191 Costs[ i] := $FFFFFFFF;192 for i:= 0 to 11 do193 Delivers[ i] := $FFFFFFFF;194 end; 195 196 procedure TNegoDlg.ShowNewContent(NewMode: integer);185 for I := 0 to 11 do 186 Costs[I] := $FFFFFFFF; 187 for I := 0 to 11 do 188 Delivers[I] := $FFFFFFFF; 189 end; 190 191 procedure TNegoDlg.ShowNewContent(NewMode: TWindowMode); 197 192 begin 198 193 inherited ShowNewContent(NewMode); … … 202 197 else 203 198 PassBtn.SmartHint := Phrases.Lookup('BTN_PASS'); 204 case MyRO.Treaty[DipMem[ me].pContact] of199 case MyRO.Treaty[DipMem[Me].pContact] of 205 200 trNone: 206 201 begin … … 238 233 begin 239 234 if ClientMode <> scDipStart then 240 with History[ me] do241 begin 242 if n= MaxHistory then243 begin 244 move(Text[2], Text[0], (MaxHistory - 2) * sizeof(integer));245 dec(n, 2);235 with History[Me] do 236 begin 237 if N = MaxHistory then 238 begin 239 Move(Text[2], Text[0], (MaxHistory - 2) * SizeOf(Integer)); 240 Dec(N, 2); 246 241 end; 247 Text[ n] := copy(DipCommandToString(DipMem[me].pContact, me,248 DipMem[ me].FormerTreaty, DipMem[me].SentCommand, ClientMode,249 DipMem[ me].SentOffer, ReceivedOffer), 1, 255);250 inc(n);242 Text[N] := Copy(DipCommandToString(DipMem[Me].pContact, Me, 243 DipMem[Me].FormerTreaty, DipMem[Me].SentCommand, ClientMode, 244 DipMem[Me].SentOffer, ReceivedOffer), 1, 255); 245 Inc(N); 251 246 end; 252 assert(History[me].nmod 2 = 1);253 254 Page := History[ me].n;247 Assert(History[Me].N mod 2 = 1); 248 249 Page := History[Me].N; 255 250 FindAllowed; 256 251 ResetCurrentOffer; … … 284 279 procedure TNegoDlg.SplitText(Text: string; Bounds: TRect); 285 280 var 286 nLines, Line, Start, Stop, OrdinaryStop, Indent, Y: integer;287 s: string;288 preview, Dot: boolean;281 nLines, Line, Start, Stop, OrdinaryStop, Indent, Y: Integer; 282 S: string; 283 preview, Dot: Boolean; 289 284 begin 290 285 nLines := 0; 291 for preview := true downto false do286 for preview := True downto False do 292 287 begin 293 288 Start := 1; … … 296 291 while Start < Length(Text) do 297 292 begin 298 Dot := false;293 Dot := False; 299 294 if (Start = 1) or (Text[Start - 1] = '\') then 300 295 if Text[Start] = '-' then 301 296 begin 302 297 Indent := ListIndent; 303 inc(Start);298 Inc(Start); 304 299 if Start = Length(Text) then 305 break;306 Dot := true;300 Break; 301 Dot := True; 307 302 end 308 303 else … … 311 306 while (Stop < Length(Text)) and (Text[Stop] <> '\') do 312 307 begin 313 inc(Stop);308 Inc(Stop); 314 309 if BiColorTextWidth(Offscreen.Canvas, 315 copy(Text, Start, Stop - Start + 1)) > Bounds.Right - Bounds.Left -310 Copy(Text, Start, Stop - Start + 1)) > Bounds.Right - Bounds.Left - 316 311 PaperBorder_Left - PaperBorder_Right - Indent then 317 312 begin 318 dec(Stop);319 break313 Dec(Stop); 314 Break 320 315 end; 321 316 end; … … 325 320 while (Text[OrdinaryStop + 1] <> ' ') and 326 321 (Text[OrdinaryStop + 1] <> '\') do 327 dec(OrdinaryStop);322 Dec(OrdinaryStop); 328 323 if (OrdinaryStop + 1 - Start) * 2 >= Stop - Start then 329 324 Stop := OrdinaryStop … … 335 330 Sprite(Offscreen, HGrSystem, Bounds.Left + PaperBorder_Left + 336 331 (ListIndent - 14), Y + 7, 8, 8, 90, 16); 337 s := copy(Text, Start, Stop - Start + 1);332 S := Copy(Text, Start, Stop - Start + 1); 338 333 BiColorTextOut(Offscreen.Canvas, Colors.Canvas.Pixels[clkMisc, 339 334 cliPaperText], $7F007F, Bounds.Left + PaperBorder_Left + 340 Indent, Y, s);335 Indent, Y, S); 341 336 end; 342 inc(Line);337 Inc(Line); 343 338 Start := Stop + 2; 344 339 end; … … 349 344 procedure TNegoDlg.FindAllowed; 350 345 var 351 i: integer;346 I: Integer; 352 347 begin 353 348 CommandAllowed := [scDipOffer - scDipStart]; 354 349 if ClientMode <> scDipBreak then 355 include(CommandAllowed, scDipBreak - scDipStart);356 if MyRO.Treaty[DipMem[ me].pContact] >= trPeace then357 include(CommandAllowed, scDipCancelTreaty - scDipStart);358 if (ClientMode = scDipOffer) and (Server(scDipAccept - sExecute, me, 0, nil^)350 Include(CommandAllowed, scDipBreak - scDipStart); 351 if MyRO.Treaty[DipMem[Me].pContact] >= trPeace then 352 Include(CommandAllowed, scDipCancelTreaty - scDipStart); 353 if (ClientMode = scDipOffer) and (Server(scDipAccept - sExecute, Me, 0, nil^) 359 354 >= rExecuted) then 360 include(CommandAllowed, scDipAccept - scDipStart);355 Include(CommandAllowed, scDipAccept - scDipStart); 361 356 362 357 MyAllowed := [opChoose shr 24, opMoney shr 24]; 363 358 OppoAllowed := [opChoose shr 24, opMoney shr 24]; 364 if not IsCivilReportNew(DipMem[ me].pContact) then359 if not IsCivilReportNew(DipMem[Me].pContact) then 365 360 begin // no up-to-date civil report 366 361 MyAllowed := MyAllowed + [opCivilReport shr 24]; 367 for i:= 0 to nAdv - 1 do368 if MyRO.Tech[ i] >= tsApplicable then362 for I := 0 to nAdv - 1 do 363 if MyRO.Tech[I] >= tsApplicable then 369 364 begin 370 365 MyAllowed := MyAllowed + [opAllTech shr 24]; 371 break366 Break 372 367 end; 373 368 OppoAllowed := OppoAllowed + [opCivilReport shr 24, opAllTech shr 24]; … … 375 370 else 376 371 begin // check techs 377 for i:= 0 to nAdv - 1 do378 if not( iin FutureTech) then379 if (MyRO.Tech[ i] < tsSeen) and380 (MyRO.EnemyReport[DipMem[ me].pContact].Tech[i] >= tsApplicable) then372 for I := 0 to nAdv - 1 do 373 if not(I in FutureTech) then 374 if (MyRO.Tech[I] < tsSeen) and 375 (MyRO.EnemyReport[DipMem[Me].pContact].Tech[I] >= tsApplicable) then 381 376 OppoAllowed := OppoAllowed + [opAllTech shr 24] 382 else if (MyRO.EnemyReport[DipMem[ me].pContact].Tech[i] < tsSeen) and383 (MyRO.Tech[ i] >= tsApplicable) then377 else if (MyRO.EnemyReport[DipMem[Me].pContact].Tech[I] < tsSeen) and 378 (MyRO.Tech[I] >= tsApplicable) then 384 379 MyAllowed := MyAllowed + [opAllTech shr 24]; 385 380 end; 386 if not IsMilReportNew(DipMem[ me].pContact) then381 if not IsMilReportNew(DipMem[Me].pContact) then 387 382 begin // no up-to-date military report 388 383 MyAllowed := MyAllowed + [opMilReport shr 24]; … … 393 388 else 394 389 begin 395 if M odalSelectDlg.OnlyChoice(kChooseModel) <> mixAll then390 if MainScreen.ModalSelectDlg.OnlyChoice(kChooseModel) <> mixAll then 396 391 MyAllowed := MyAllowed + [opAllModel shr 24]; 397 if M odalSelectDlg.OnlyChoice(kChooseEModel) <> mixAll then392 if MainScreen.ModalSelectDlg.OnlyChoice(kChooseEModel) <> mixAll then 398 393 OppoAllowed := OppoAllowed + [opAllModel shr 24]; 399 394 end; 400 if MyRO.Treaty[DipMem[ me].pContact] < trAlliance then395 if MyRO.Treaty[DipMem[Me].pContact] < trAlliance then 401 396 begin 402 397 MyAllowed := MyAllowed + [opTreaty shr 24, opMap shr 24]; … … 408 403 OppoAllowed:=OppoAllowed+[opLowTreaty shr 24]; 409 404 end; } 410 for i:= 0 to nShipPart - 1 do411 begin 412 if MyRO.Ship[ me].Parts[i] > 0 then413 include(MyAllowed, opShipParts shr 24);414 if MyRO.Ship[DipMem[ me].pContact].Parts[i] > 0 then415 include(OppoAllowed, opShipParts shr 24);416 end; 417 MyAllowed := MyAllowed - DipMem[ me].DeliveredPrices *405 for I := 0 to nShipPart - 1 do 406 begin 407 if MyRO.Ship[Me].Parts[I] > 0 then 408 Include(MyAllowed, opShipParts shr 24); 409 if MyRO.Ship[DipMem[Me].pContact].Parts[I] > 0 then 410 Include(OppoAllowed, opShipParts shr 24); 411 end; 412 MyAllowed := MyAllowed - DipMem[Me].DeliveredPrices * 418 413 [opAllTech shr 24, opAllModel shr 24, opCivilReport shr 24, 419 414 opMilReport shr 24, opMap shr 24]; 420 OppoAllowed := OppoAllowed - DipMem[ me].ReceivedPrices *415 OppoAllowed := OppoAllowed - DipMem[Me].ReceivedPrices * 421 416 [opAllTech shr 24, opAllModel shr 24, opCivilReport shr 24, 422 417 opMilReport shr 24, opMap shr 24]; 423 418 end; 424 419 425 procedure TNegoDlg.PaintNationPicture(X, Y, p: integer);420 procedure TNegoDlg.PaintNationPicture(X, Y, P: Integer); 426 421 begin 427 422 with Offscreen.Canvas do 428 423 begin 429 424 Pen.Color := $000000; 430 Brush.Color := Tribe[ p].Color;425 Brush.Color := Tribe[P].Color; 431 426 Rectangle(X - 6, Y - 1, X + 70, Y + 49); 432 427 Brush.Color := $000000; 433 Tribe[ p].InitAge(GetAge(p));434 if Assigned(Tribe[ p].faceHGr) then435 Dump(Offscreen, Tribe[ p].faceHGr, X, Y, 64, 48,436 1 + Tribe[ p].facepix mod 10 * 65, 1 + Tribe[p].facepix div 10 * 49)428 Tribe[P].InitAge(GetAge(P)); 429 if Assigned(Tribe[P].faceHGr) then 430 Dump(Offscreen, Tribe[P].faceHGr, X, Y, 64, 48, 431 1 + Tribe[P].facepix mod 10 * 65, 1 + Tribe[P].facepix div 10 * 49) 437 432 else 438 433 FillRect(Rect(X, Y, X + 64, Y + 48)); … … 444 439 procedure TNegoDlg.SetButtonStates; 445 440 var 446 cix: integer;447 IsActionPage: boolean;448 begin 449 IsActionPage := Page = History[ me].n;441 cix: Integer; 442 IsActionPage: Boolean; 443 begin 444 IsActionPage := Page = History[Me].N; 450 445 451 446 AcceptBtn.Possible := IsActionPage and … … 478 473 (ButtonPrice[Tag and $FF] shr 24 in MyAllowed); 479 474 Lit := Delivers[Tag and $FF] <> $FFFFFFFF; 480 end 475 end; 481 476 end; 482 477 end; … … 484 479 procedure TNegoDlg.OffscreenPaint; 485 480 var 486 i, cred: integer;487 s: string;488 OkEnabled: boolean;481 I, cred: Integer; 482 S: string; 483 OkEnabled: Boolean; 489 484 begin 490 485 if (OffscreenUser <> nil) and (OffscreenUser <> self) then … … 493 488 OffscreenUser := self; 494 489 495 if (DipCommand >= 0) and (Page = History[ me].n) then496 History[ me].Text[History[me].n] :=497 copy(DipCommandToString(me, DipMem[me].pContact,498 MyRO.Treaty[DipMem[ me].pContact], ClientMode, DipCommand, ReceivedOffer,490 if (DipCommand >= 0) and (Page = History[Me].N) then 491 History[Me].Text[History[Me].N] := 492 Copy(DipCommandToString(Me, DipMem[Me].pContact, 493 MyRO.Treaty[DipMem[Me].pContact], ClientMode, DipCommand, ReceivedOffer, 499 494 CurrentOffer), 1, 255); 500 495 501 FwdBtn.Visible := Page < History[ me].n;496 FwdBtn.Visible := Page < History[Me].N; 502 497 BwdBtn.Visible := Page >= 2; 503 if Page < History[ me].nthen504 OkEnabled := false498 if Page < History[Me].N then 499 OkEnabled := False 505 500 else if DipCommand = scDipOffer then 506 OkEnabled := Server(scDipOffer - sExecute, me, 0, CurrentOffer) >= rExecuted501 OkEnabled := Server(scDipOffer - sExecute, Me, 0, CurrentOffer) >= rExecuted 507 502 else 508 503 OkEnabled := DipCommand >= 0; … … 533 528 yPad1 + 41 + 42 * 2, $FFFFFF, $B0B0B0); 534 529 535 PaintNationPicture(xNationPicture0, yNationPicture, DipMem[ me].pContact);536 PaintNationPicture(xNationPicture1, yNationPicture, me);537 538 if History[ me].Text[Page - 1] <> '' then530 PaintNationPicture(xNationPicture0, yNationPicture, DipMem[Me].pContact); 531 PaintNationPicture(xNationPicture1, yNationPicture, Me); 532 533 if History[Me].Text[Page - 1] <> '' then 539 534 begin 540 535 FillSeamless(Offscreen.Canvas, xText0, yText0, wText, hText, 0, 0, Paper); 541 i:= Page - 1;542 if History[ me].Text[0] = '' then543 dec(i);544 if i< 16 then536 I := Page - 1; 537 if History[Me].Text[0] = '' then 538 Dec(I); 539 if I < 16 then 545 540 begin 546 541 Offscreen.Canvas.Font.Assign(RomanFont); 547 542 Offscreen.Canvas.TextOut 548 (xText0 + (wText - Offscreen.Canvas.TextWidth(RomanNo[ i])) div 2,549 yText0 + (hText - Offscreen.Canvas.TextHeight(RomanNo[ i])) div 2,550 RomanNo[ i]);543 (xText0 + (wText - Offscreen.Canvas.TextWidth(RomanNo[I])) div 2, 544 yText0 + (hText - Offscreen.Canvas.TextHeight(RomanNo[I])) div 2, 545 RomanNo[I]); 551 546 end 552 547 end; 553 548 FillSeamless(Offscreen.Canvas, xText1, yText1, wText, hText, 0, 0, Paper); 554 i:= Page;555 if History[ me].Text[0] = '' then556 dec(i);557 if i< 16 then549 I := Page; 550 if History[Me].Text[0] = '' then 551 Dec(I); 552 if I < 16 then 558 553 begin 559 554 Offscreen.Canvas.Font.Assign(RomanFont); 560 555 Offscreen.Canvas.TextOut 561 (xText1 + (wText - Offscreen.Canvas.TextWidth(RomanNo[ i])) div 2,562 yText1 + (hText - Offscreen.Canvas.TextHeight(RomanNo[ i])) div 2,563 RomanNo[ i]);556 (xText1 + (wText - Offscreen.Canvas.TextWidth(RomanNo[I])) div 2, 557 yText1 + (hText - Offscreen.Canvas.TextHeight(RomanNo[I])) div 2, 558 RomanNo[I]); 564 559 end; 565 560 with Offscreen.Canvas do 566 561 begin 567 562 Brush.Color := MainTexture.ColorBevelShade; 568 if History[ me].Text[Page - 1] <> '' then563 if History[Me].Text[Page - 1] <> '' then 569 564 begin 570 565 FillRect(Rect(xText0 + wText, yText0 + PaperShade, … … 584 579 { if Page=History[me].n then 585 580 begin // show attitude 586 s:=Phrases.Lookup('ATTITUDE',MyRO.EnemyReport[DipMem[me].pContact].Attitude);581 S:=Phrases.Lookup('ATTITUDE',MyRO.EnemyReport[DipMem[Me].pContact].Attitude); 587 582 //LoweredTextOut(Offscreen.Canvas,-1,MainTexture, 588 583 RisedTextOut(Offscreen.Canvas,xText0+wText div 2- 589 BiColorTextWidth(Offscreen.Canvas, s) div 2,yAttitude,s);590 s:=Phrases.Lookup('ATTITUDE',MyRO.Attitude[DipMem[me].pContact]);584 BiColorTextWidth(Offscreen.Canvas,S) div 2,yAttitude,S); 585 S:=Phrases.Lookup('ATTITUDE',MyRO.Attitude[DipMem[Me].pContact]); 591 586 //LoweredTextOut(Offscreen.Canvas,-1,MainTexture, 592 587 RisedTextOut(Offscreen.Canvas,xText1+wText div 2- 593 BiColorTextWidth(Offscreen.Canvas, s) div 2,yAttitude,s);588 BiColorTextWidth(Offscreen.Canvas,S) div 2,yAttitude,S); 594 589 end; } 595 590 596 if History[ me].Text[Page - 1] <> '' then597 SplitText(History[ me].Text[Page - 1], Rect(xText0, yText0, xText0 + wText,591 if History[Me].Text[Page - 1] <> '' then 592 SplitText(History[Me].Text[Page - 1], Rect(xText0, yText0, xText0 + wText, 598 593 yText0 + hText)); 599 if (Page < History[ me].n) or OkEnabled then600 SplitText(History[ me].Text[Page], Rect(xText1, yText1, xText1 + wText,594 if (Page < History[Me].N) or OkEnabled then 595 SplitText(History[Me].Text[Page], Rect(xText1, yText1, xText1 + wText, 601 596 yText1 + hText)); 602 597 603 598 // show credibility 604 599 Offscreen.Canvas.Font.Assign(UniFont[ftTiny]); 605 cred := MyRO.EnemyReport[DipMem[ me].pContact].Credibility;600 cred := MyRO.EnemyReport[DipMem[Me].pContact].Credibility; 606 601 case cred of 607 602 0 .. 49: 608 i:= 3;603 I := 3; 609 604 50 .. 90: 610 i:= 0;605 I := 0; 611 606 91 .. 100: 612 i:= 1;613 end; 614 PaintProgressBar(Offscreen.Canvas, i, xCred0, yCred0 + 17, (cred + 2) div 5,607 I := 1; 608 end; 609 PaintProgressBar(Offscreen.Canvas, I, xCred0, yCred0 + 17, (cred + 2) div 5, 615 610 0, 20, MainTexture); 616 s:= IntToStr(cred);611 S := IntToStr(cred); 617 612 RisedTextOut(Offscreen.Canvas, xCred0 + 10 - 618 (BiColorTextWidth(Offscreen.Canvas, s) + 1) div 2, yCred0, s);613 (BiColorTextWidth(Offscreen.Canvas, S) + 1) div 2, yCred0, S); 619 614 case MyRO.Credibility of 620 615 0 .. 49: 621 i:= 3;616 I := 3; 622 617 50 .. 90: 623 i:= 0;618 I := 0; 624 619 91 .. 100: 625 i:= 1;626 end; 627 PaintProgressBar(Offscreen.Canvas, i, xCred1, yCred1 + 17,620 I := 1; 621 end; 622 PaintProgressBar(Offscreen.Canvas, I, xCred1, yCred1 + 17, 628 623 (MyRO.Credibility + 2) div 5, 0, 20, MainTexture); 629 s:= IntToStr(MyRO.Credibility);624 S := IntToStr(MyRO.Credibility); 630 625 RisedTextOut(Offscreen.Canvas, xCred1 + 10 - 631 (BiColorTextWidth(Offscreen.Canvas, s) + 1) div 2, yCred1, s);626 (BiColorTextWidth(Offscreen.Canvas, S) + 1) div 2, yCred1, S); 632 627 633 628 MarkUsedOffscreen(ClientWidth, ClientHeight); 634 end; { OffscreenPaint }629 end; 635 630 636 631 procedure TNegoDlg.Initiate; 637 632 begin 638 History[ me].n:= 1;639 History[ me].Text[0] := '';633 History[Me].N := 1; 634 History[Me].Text[0] := ''; 640 635 end; 641 636 642 637 procedure TNegoDlg.Respond; 643 638 begin 644 History[ me].n:= 0;639 History[Me].N := 0; 645 640 end; 646 641 647 642 procedure TNegoDlg.FormMouseDown(Sender: TObject; Button: TMouseButton; 648 Shift: TShiftState; X, Y: integer);643 Shift: TShiftState; X, Y: Integer); 649 644 begin 650 645 if (X >= xNationPicture0) and (X < xNationPicture0 + 64) and 651 646 (Y >= yNationPicture) and (Y < yNationPicture + 48) then 652 NatStatDlg.ShowNewContent(FWindowMode or wmPersistent, DipMem[me].pContact)647 MainScreen.NatStatDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), DipMem[Me].pContact) 653 648 else if (X >= xNationPicture1) and (X < xNationPicture1 + 64) and 654 649 (Y >= yNationPicture) and (Y < yNationPicture + 48) then 655 NatStatDlg.ShowNewContent(FWindowMode or wmPersistent, me)650 MainScreen.NatStatDlg.ShowNewContent(WindowModeMakePersistent(FWindowMode), Me) 656 651 end; 657 652 658 653 procedure TNegoDlg.BwdBtnClick(Sender: TObject); 659 654 begin 660 dec(Page, 2);655 Dec(Page, 2); 661 656 SetButtonStates; 662 657 SmartUpdateContent; … … 665 660 procedure TNegoDlg.FwdBtnClick(Sender: TObject); 666 661 begin 667 inc(Page, 2);662 Inc(Page, 2); 668 663 SetButtonStates; 669 664 SmartUpdateContent; … … 672 667 procedure TNegoDlg.OkBtnClick(Sender: TObject); 673 668 begin 674 inc(History[me].n);669 Inc(History[Me].N); 675 670 if DipCommand = scDipOffer then 676 671 MainScreen.OfferCall(CurrentOffer) … … 698 693 procedure TNegoDlg.BuildCurrentOffer; 699 694 var 700 i: integer;695 I: Integer; 701 696 begin 702 697 CurrentOffer.nDeliver := 0; 703 698 CurrentOffer.nCost := 0; 704 for i:= 0 to 11 do705 if Delivers[ i] <> $FFFFFFFF then706 begin 707 CurrentOffer.Price[CurrentOffer.nDeliver] := Delivers[ i];708 inc(CurrentOffer.nDeliver);699 for I := 0 to 11 do 700 if Delivers[I] <> $FFFFFFFF then 701 begin 702 CurrentOffer.Price[CurrentOffer.nDeliver] := Delivers[I]; 703 Inc(CurrentOffer.nDeliver); 709 704 end; 710 for i:= 0 to 11 do711 if Costs[ i] <> $FFFFFFFF then705 for I := 0 to 11 do 706 if Costs[I] <> $FFFFFFFF then 712 707 begin 713 708 CurrentOffer.Price[CurrentOffer.nDeliver + CurrentOffer.nCost] := 714 Costs[ i];715 inc(CurrentOffer.nCost);709 Costs[I]; 710 Inc(CurrentOffer.nCost); 716 711 end; 717 712 end; … … 719 714 procedure TNegoDlg.WantClick(Sender: TObject); 720 715 var 721 a, i, max: integer;722 Price: cardinal;723 begin 724 if (Page <> History[ me].n) or (ClientMode = scDipCancelTreaty) or716 A, I, Max: Integer; 717 Price: Cardinal; 718 begin 719 if (Page <> History[Me].N) or (ClientMode = scDipCancelTreaty) or 725 720 (ClientMode = scDipBreak) then 726 exit;721 Exit; 727 722 if Costs[TButtonN(Sender).Tag and $FF] <> $FFFFFFFF then 728 723 Price := $FFFFFFFF // toggle off … … 732 727 begin 733 728 SimpleMessage(Phrases.Lookup('MAX2WANTS')); 734 exit729 Exit; 735 730 end; 736 731 Price := ButtonPrice[TButtonN(Sender).Tag and $FF]; 737 732 if not(Price shr 24 in OppoAllowed) then 738 exit;733 Exit; 739 734 case Price of 740 735 opCivilReport, opMilReport: 741 inc(Price, DipMem[me].pContact shl 16 + MyRO.Turn);736 Inc(Price, DipMem[Me].pContact shl 16 + MyRO.Turn); 742 737 // !!! choose player and year! 743 738 opMoney: … … 748 743 InputDlg.ShowModal; 749 744 if InputDlg.ModalResult <> mrOK then 750 exit;751 val(InputDlg.EInput.Text, a, i);752 if ( i <> 0) or (a <= 0) or (a>= MaxMoneyPrice) then753 exit;754 inc(Price, a);745 Exit; 746 val(InputDlg.EInput.Text, A, I); 747 if (I <> 0) or (A <= 0) or (A >= MaxMoneyPrice) then 748 Exit; 749 Inc(Price, A); 755 750 end; 756 751 opShipParts: 757 752 begin // choose type and number 758 753 if MyRO.NatBuilt[imSpacePort] = 0 then 759 with M essgExDlg do754 with MainScreen.MessgExDlg do 760 755 begin 761 756 OpenSound := 'WARNING_LOWSUPPORT'; … … 766 761 ShowModal; 767 762 if ModalResult <> mrOK then 768 exit763 Exit; 769 764 end; 770 M odalSelectDlg.ShowNewContent(wmModal, kEShipPart);771 if M odalSelectDlg.result < 0 then772 exit;773 inc(Price, ModalSelectDlg.result shl 16);774 max := MyRO.Ship[DipMem[me].pContact].Parts[ModalSelectDlg.result];765 MainScreen.ModalSelectDlg.ShowNewContent(wmModal, kEShipPart); 766 if MainScreen.ModalSelectDlg.Result < 0 then 767 Exit; 768 Inc(Price, MainScreen.ModalSelectDlg.Result shl 16); 769 Max := MyRO.Ship[DipMem[Me].pContact].Parts[MainScreen.ModalSelectDlg.Result]; 775 770 InputDlg.Caption := Phrases.Lookup('TITLE_NUMBER'); 776 771 InputDlg.EInput.Text := ''; … … 778 773 InputDlg.ShowModal; 779 774 if InputDlg.ModalResult <> mrOK then 780 exit;781 val(InputDlg.EInput.Text, a, i);782 if ( i <> 0) or (a<= 0) then783 exit;784 if a > max then785 a := max;786 if a> MaxShipPartPrice then787 a:= MaxShipPartPrice;788 inc(Price, a)775 Exit; 776 val(InputDlg.EInput.Text, A, I); 777 if (I <> 0) or (A <= 0) then 778 Exit; 779 if A > Max then 780 A := Max; 781 if A > MaxShipPartPrice then 782 A := MaxShipPartPrice; 783 Inc(Price, A); 789 784 end; 790 785 opAllTech: 791 786 begin // choose technology 792 M odalSelectDlg.ShowNewContent(wmModal, kChooseETech);793 if M odalSelectDlg.result < 0 then794 exit;795 if M odalSelectDlg.result = adAll then787 MainScreen.ModalSelectDlg.ShowNewContent(wmModal, kChooseETech); 788 if MainScreen.ModalSelectDlg.Result < 0 then 789 Exit; 790 if MainScreen.ModalSelectDlg.Result = adAll then 796 791 Price := opAllTech 797 792 else 798 Price := OpTech + M odalSelectDlg.result;793 Price := OpTech + MainScreen.ModalSelectDlg.Result; 799 794 end; 800 795 opAllModel: 801 796 begin // choose model 802 M odalSelectDlg.ShowNewContent(wmModal, kChooseEModel);803 if M odalSelectDlg.result < 0 then804 exit;805 if M odalSelectDlg.result = mixAll then797 MainScreen.ModalSelectDlg.ShowNewContent(wmModal, kChooseEModel); 798 if MainScreen.ModalSelectDlg.Result < 0 then 799 Exit; 800 if MainScreen.ModalSelectDlg.Result = mixAll then 806 801 Price := opAllModel 807 802 else 808 Price := OpModel + MyRO.EnemyModel[M odalSelectDlg.result].mix;803 Price := OpModel + MyRO.EnemyModel[MainScreen.ModalSelectDlg.Result].mix; 809 804 end; 810 805 opTreaty: 811 806 begin 812 if MyRO.Treaty[DipMem[ me].pContact] < trPeace then807 if MyRO.Treaty[DipMem[Me].pContact] < trPeace then 813 808 Price := opTreaty + trPeace 814 809 else 815 Price := opTreaty + MyRO.Treaty[DipMem[ me].pContact] + 1;810 Price := opTreaty + MyRO.Treaty[DipMem[Me].pContact] + 1; 816 811 end; 817 812 { opLowTreaty: 818 813 begin 819 if MyRO.Treaty[DipMem[ me].pContact]=trNone then Price:=opTreaty+trCeaseFire820 else Price:=opTreaty+MyRO.Treaty[DipMem[ me].pContact]-1;814 if MyRO.Treaty[DipMem[Me].pContact]=trNone then Price:=opTreaty+trCeaseFire 815 else Price:=opTreaty+MyRO.Treaty[DipMem[Me].pContact]-1; 821 816 end } 822 817 end; … … 832 827 procedure TNegoDlg.OfferClick(Sender: TObject); 833 828 var 834 a, i, max: integer;835 Price: cardinal;836 begin 837 if (Page <> History[ me].n) or (ClientMode = scDipCancelTreaty) or829 A, I, Max: Integer; 830 Price: Cardinal; 831 begin 832 if (Page <> History[Me].N) or (ClientMode = scDipCancelTreaty) or 838 833 (ClientMode = scDipBreak) then 839 exit;834 Exit; 840 835 if Delivers[TButtonN(Sender).Tag and $FF] <> $FFFFFFFF then 841 836 Price := $FFFFFFFF // toggle off … … 845 840 begin 846 841 SimpleMessage(Phrases.Lookup('MAX2OFFERS')); 847 exit842 Exit; 848 843 end; 849 844 Price := ButtonPrice[TButtonN(Sender).Tag and $FF]; 850 845 if not(Price shr 24 in MyAllowed) then 851 exit;846 Exit; 852 847 case Price of 853 848 opCivilReport, opMilReport: 854 inc(Price, me shl 16 + MyRO.Turn); // !!! choose player and year!849 Inc(Price, Me shl 16 + MyRO.Turn); // !!! choose player and year! 855 850 opMoney: 856 851 begin // choose amount … … 860 855 InputDlg.ShowModal; 861 856 if InputDlg.ModalResult <> mrOK then 862 exit;863 val(InputDlg.EInput.Text, a, i);864 if ( i <> 0) or (a <= 0) or (a>= MaxMoneyPrice) then865 exit;866 if (Price = opMoney) and ( a> MyRO.Money) then867 a:= MyRO.Money;868 inc(Price, a);857 Exit; 858 val(InputDlg.EInput.Text, A, I); 859 if (I <> 0) or (A <= 0) or (A >= MaxMoneyPrice) then 860 Exit; 861 if (Price = opMoney) and (A > MyRO.Money) then 862 A := MyRO.Money; 863 Inc(Price, A); 869 864 end; 870 865 opShipParts: 871 866 begin // choose type and number 872 M odalSelectDlg.ShowNewContent(wmModal, kShipPart);873 if M odalSelectDlg.result < 0 then874 exit;875 inc(Price, ModalSelectDlg.result shl 16);876 max := MyRO.Ship[me].Parts[ModalSelectDlg.result];867 MainScreen.ModalSelectDlg.ShowNewContent(wmModal, kShipPart); 868 if MainScreen.ModalSelectDlg.Result < 0 then 869 Exit; 870 Inc(Price, MainScreen.ModalSelectDlg.Result shl 16); 871 Max := MyRO.Ship[Me].Parts[MainScreen.ModalSelectDlg.Result]; 877 872 InputDlg.Caption := Phrases.Lookup('TITLE_NUMBER'); 878 873 InputDlg.EInput.Text := ''; … … 880 875 InputDlg.ShowModal; 881 876 if InputDlg.ModalResult <> mrOK then 882 exit;883 val(InputDlg.EInput.Text, a, i);884 if ( i <> 0) or (a<= 0) then885 exit;886 if a > max then887 a := max;888 if a> MaxShipPartPrice then889 a:= MaxShipPartPrice;890 inc(Price, a)877 Exit; 878 val(InputDlg.EInput.Text, A, I); 879 if (I <> 0) or (A <= 0) then 880 Exit; 881 if A > Max then 882 A := Max; 883 if A > MaxShipPartPrice then 884 A := MaxShipPartPrice; 885 Inc(Price, A); 891 886 end; 892 887 opAllTech: 893 888 begin // choose technology 894 M odalSelectDlg.ShowNewContent(wmModal, kChooseTech);895 if M odalSelectDlg.result < 0 then896 exit;897 if M odalSelectDlg.result = adAll then889 MainScreen.ModalSelectDlg.ShowNewContent(wmModal, kChooseTech); 890 if MainScreen.ModalSelectDlg.Result < 0 then 891 Exit; 892 if MainScreen.ModalSelectDlg.Result = adAll then 898 893 Price := opAllTech 899 894 else 900 Price := OpTech + M odalSelectDlg.result;895 Price := OpTech + MainScreen.ModalSelectDlg.Result; 901 896 end; 902 897 opAllModel: 903 898 begin // choose model 904 M odalSelectDlg.ShowNewContent(wmModal, kChooseModel);905 if M odalSelectDlg.result < 0 then906 exit;907 if M odalSelectDlg.result = mixAll then899 MainScreen.ModalSelectDlg.ShowNewContent(wmModal, kChooseModel); 900 if MainScreen.ModalSelectDlg.Result < 0 then 901 Exit; 902 if MainScreen.ModalSelectDlg.Result = mixAll then 908 903 Price := opAllModel 909 904 else 910 Price := OpModel + M odalSelectDlg.result905 Price := OpModel + MainScreen.ModalSelectDlg.Result; 911 906 end; 912 907 opTreaty: 913 908 begin 914 if MyRO.Treaty[DipMem[ me].pContact] < trPeace then909 if MyRO.Treaty[DipMem[Me].pContact] < trPeace then 915 910 Price := opTreaty + trPeace 916 911 else 917 Price := opTreaty + MyRO.Treaty[DipMem[ me].pContact] + 1;912 Price := opTreaty + MyRO.Treaty[DipMem[Me].pContact] + 1; 918 913 end; 919 914 { opLowTreaty: 920 915 begin 921 if MyRO.Treaty[DipMem[ me].pContact]=trNone then Price:=opTreaty+trCeaseFire922 else Price:=opTreaty+MyRO.Treaty[DipMem[ me].pContact]-1;916 if MyRO.Treaty[DipMem[Me].pContact]=trNone then Price:=opTreaty+trCeaseFire 917 else Price:=opTreaty+MyRO.Treaty[DipMem[Me].pContact]-1; 923 918 end } 924 919 end; … … 934 929 procedure TNegoDlg.FastBtnClick(Sender: TObject); 935 930 var 936 NewCommand: cardinal;937 begin 938 if Page <> History[ me].nthen939 exit;931 NewCommand: Cardinal; 932 begin 933 if Page <> History[Me].N then 934 Exit; 940 935 NewCommand := TButtonN(Sender).Tag and $FF + scDipStart; 941 936 if not(NewCommand - scDipStart in CommandAllowed) then 942 exit;937 Exit; 943 938 if (NewCommand = scDipCancelTreaty) and 944 (MyRO.Turn < MyRO.LastCancelTreaty[DipMem[ me].pContact] + CancelTreatyTurns)939 (MyRO.Turn < MyRO.LastCancelTreaty[DipMem[Me].pContact] + CancelTreatyTurns) 945 940 then 946 941 begin 947 942 SimpleMessage(Phrases.Lookup('CANCELTREATYRUSH')); 948 exit;943 Exit; 949 944 end; 950 945 if (NewCommand = scDipOffer) and ((ClientMode = scDipCancelTreaty) or
Note:
See TracChangeset
for help on using the changeset viewer.