Changeset 246 for branches/highdpi/LocalPlayer/Term.pas
- Timestamp:
- May 21, 2020, 8:17:38 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/LocalPlayer/Term.pas
r244 r246 287 287 Offscreen: TDpiBitmap; 288 288 OffscreenUser: TDpiForm; 289 procedure CreateParams(var p: TCreateParams); override;290 289 procedure Client(Command, NewPlayer: integer; var Data); 291 290 procedure SetAIName(p: integer; Name: string); … … 532 531 SmallScreen, GameOK, MapValid, skipped, idle: boolean; 533 532 534 SaveOption: array [0 ..nSaveOption - 1] of integer;535 MiniColors: array [0 ..fTerrain, 0..1] of TColor;533 SaveOption: array [0 .. nSaveOption - 1] of integer; 534 MiniColors: array [0 .. 11, 0 .. 1] of TColor; 536 535 MainMap: TIsoMap; 537 536 CurrentMoveInfo: record AfterMovePaintRadius, AfterAttackExpeller: integer; … … 555 554 Sharpen = 80; 556 555 type 557 TBuffer = array [0 .. 99999, 0 .. 2] of integer;556 TBuffer = array [0 .. 99999, 0 .. 2] of Integer; 558 557 var 559 sum, Cnt, dx, dy, nx, ny, ix, iy, ir, x, y, c, ch, xdivider,560 ydivider: integer;561 resampled: ^TBuffer;558 Sum, Cnt, dx, dy, nx, ny, ix, iy, ir, x, y, c, ch: Integer; 559 xdivider, ydivider: Integer; 560 Resampled: ^TBuffer; 562 561 PixelPtr: TPixelPointer; 563 562 begin 564 nx := BigImp. width div xSizeBig * xSizeSmall;565 ny := BigImp. height div ySizeBig * ySizeSmall;563 nx := BigImp.Width div xSizeBig * xSizeSmall; 564 ny := BigImp.Height div ySizeBig * ySizeSmall; 566 565 567 566 // resample icons 568 GetMem( resampled, nx * ny * 12);569 FillChar( resampled^, nx * ny * 12, 0);567 GetMem(Resampled, nx * ny * 12); 568 FillChar(Resampled^, nx * ny * 12, 0); 570 569 BigImp.BeginUpdate; 571 for ix := 0 to BigImp.width div xSizeBig - 1 do 572 for iy := 0 to BigImp.height div ySizeBig - 1 do 573 for y := 0 to ySizeBig - 2 * cut - 1 do 574 begin 575 ydivider := (y * ySizeSmall div (ySizeBig - 2 * cut) + 1) * 576 (ySizeBig - 2 * cut) - y * ySizeSmall; 570 for ix := 0 to BigImp.Width div xSizeBig - 1 do 571 for iy := 0 to BigImp.Height div ySizeBig - 1 do begin 572 PixelPtr := PixelPointer(BigImp, ScaleToNative(ix * xSizeBig), 573 ScaleToNative(cut + iy * ySizeBig)); 574 for y := 0 to ScaleToNative(ySizeBig - 2 * cut) - 1 do begin 575 ydivider := (ScaleFromNative(y) * ySizeSmall div (ySizeBig - 2 * cut) + 1) * 576 (ySizeBig - 2 * cut) - ScaleFromNative(y) * ySizeSmall; 577 577 if ydivider > ySizeSmall then 578 578 ydivider := ySizeSmall; 579 PixelPtr := PixelPointer(BigImp, 0, cut + iy * ySizeBig + y); 580 for x := 0 to xSizeBig - 1 do 581 begin 582 ir := ix * xSizeSmall + iy * nx * ySizeSmall + x * 583 xSizeSmall div xSizeBig + y * 579 for x := 0 to ScaleToNative(xSizeBig) - 1 do begin 580 ir := ix * xSizeSmall + iy * nx * ySizeSmall + ScaleFromNative(x) * 581 xSizeSmall div xSizeBig + ScaleFromNative(y) * 584 582 ySizeSmall div (ySizeBig - 2 * cut) * nx; 585 xdivider := ( x * xSizeSmall div xSizeBig + 1) * xSizeBig - x*586 xSize Small;583 xdivider := (ScaleFromNative(x) * xSizeSmall div xSizeBig + 1) * 584 xSizeBig - ScaleFromNative(x) * xSizeSmall; 587 585 if xdivider > xSizeSmall then 588 586 xdivider := xSizeSmall; 589 for ch := 0 to 2 do 590 begin 591 PixelPtr.SetX(ix * xSizeBig + x); 587 for ch := 0 to 2 do begin 592 588 c := PixelPtr.Pixel^.Planes[ch]; 593 inc(resampled[ir, ch], c * xdivider * ydivider);589 Inc(Resampled[ir, ch], c * xdivider * ydivider); 594 590 if xdivider < xSizeSmall then 595 inc(resampled[ir + 1, ch], c * (xSizeSmall - xdivider) *591 Inc(Resampled[ir + 1, ch], c * (xSizeSmall - xdivider) * 596 592 ydivider); 597 593 if ydivider < ySizeSmall then 598 inc(resampled[ir + nx, ch],594 Inc(Resampled[ir + nx, ch], 599 595 c * xdivider * (ySizeSmall - ydivider)); 600 596 if (xdivider < xSizeSmall) and (ydivider < ySizeSmall) then 601 inc(resampled[ir + nx + 1, ch], c * (xSizeSmall - xdivider) *597 Inc(Resampled[ir + nx + 1, ch], c * (xSizeSmall - xdivider) * 602 598 (ySizeSmall - ydivider)); 603 599 end; 600 PixelPtr.NextPixel; 604 601 end; 602 PixelPtr.NextLine; 605 603 end; 604 end; 606 605 BigImp.EndUpdate; 607 606 608 // sharpen resampled icons607 // Sharpen Resampled icons 609 608 SmallImp.SetSize(nx, ny); 610 609 SmallImp.BeginUpdate; 611 for y := 0 to ny - 1 do begin612 PixelPtr := PixelPointer(SmallImp, 0, y);613 for x := 0 to nx - 1 do610 PixelPtr := PixelPointer(SmallImp); 611 for y := 0 to ScaleToNative(ny) - 1 do begin 612 for x := 0 to ScaleToNative(nx) - 1 do begin 614 613 for ch := 0 to 2 do begin 615 sum := 0;614 Sum := 0; 616 615 Cnt := 0; 617 616 for dy := -1 to 1 do 618 if ((dy >= 0) or ( ymod ySizeSmall > 0)) and619 ((dy <= 0) or ( ymod ySizeSmall < ySizeSmall - 1)) then617 if ((dy >= 0) or (ScaleFromNative(y) mod ySizeSmall > 0)) and 618 ((dy <= 0) or (ScaleFromNative(y) mod ySizeSmall < ySizeSmall - 1)) then 620 619 for dx := -1 to 1 do 621 if ((dx >= 0) or ( xmod xSizeSmall > 0)) and622 ((dx <= 0) or ( xmod xSizeSmall < xSizeSmall - 1)) then620 if ((dx >= 0) or (ScaleFromNative(x) mod xSizeSmall > 0)) and 621 ((dx <= 0) or (ScaleFromNative(x) mod xSizeSmall < xSizeSmall - 1)) then 623 622 begin 624 inc(sum, resampled[x + dx + nx * (y+ dy), ch]);625 inc(Cnt);623 Inc(Sum, Resampled[ScaleFromNative(x) + dx + nx * (ScaleFromNative(y) + dy), ch]); 624 Inc(Cnt); 626 625 end; 627 sum := ((Cnt * Sharpen + 800) * resampled[x + nx * y, ch] - sum *626 Sum := ((Cnt * Sharpen + 800) * Resampled[ScaleFromNative(x) + nx * ScaleFromNative(y), ch] - Sum * 628 627 Sharpen) div (800 * xSizeBig * (ySizeBig - 2 * cut)); 629 if sum < 0 then sum := 0; 630 if sum > 255 then sum := 255; 631 PixelPtr.SetX(x); 632 PixelPtr.Pixel^.Planes[ch] := sum; 628 if Sum < 0 then Sum := 0; 629 if Sum > 255 then Sum := 255; 630 PixelPtr.Pixel^.Planes[ch] := Sum; 633 631 end; 632 PixelPtr.NextPixel; 633 end; 634 PixelPtr.NextLine; 634 635 end; 635 636 SmallImp.EndUpdate; 636 FreeMem( resampled);637 FreeMem(Resampled); 637 638 end; 638 639 … … 3399 3400 { *** main part *** } 3400 3401 3401 procedure TMainScreen.CreateParams(var p: TCreateParams);3402 begin3403 inherited;3404 if FullScreen then begin3405 p.Style := $87000000;3406 BorderStyle := bsNone;3407 BorderIcons := [];3408 end;3409 end;3410 3411 3402 procedure TMainScreen.FormCreate(Sender: TObject); 3412 3403 var … … 4077 4068 MiniPixel := PixelPointer(Mini); 4078 4069 PrevMiniPixel := PixelPointer(Mini); 4079 for y := 0 to ScaleTo Vcl(G.ly) - 1 do4080 begin 4081 for x := 0 to ScaleTo Vcl(G.lx) - 1 do4082 if MyMap[ScaleFrom Vcl(x) + G.lx * ScaleFromVcl(y)] and fTerrain <> fUNKNOWN then4083 begin 4084 Loc := ScaleFrom Vcl(x) + G.lx * ScaleFromVcl(y);4070 for y := 0 to ScaleToNative(G.ly) - 1 do 4071 begin 4072 for x := 0 to ScaleToNative(G.lx) - 1 do 4073 if MyMap[ScaleFromNative(x) + G.lx * ScaleFromNative(y)] and fTerrain <> fUNKNOWN then 4074 begin 4075 Loc := ScaleFromNative(x) + G.lx * ScaleFromNative(y); 4085 4076 for i := 0 to 1 do 4086 4077 begin 4087 xm := ((x - ScaleTo Vcl(xwMini)) * 2 + i + y and 1 - ScaleToVcl(hw) +4088 ScaleTo Vcl(G.lx) * 5) mod (ScaleToVcl(G.lx) * 2);4078 xm := ((x - ScaleToNative(xwMini)) * 2 + i + y and 1 - ScaleToNative(hw) + 4079 ScaleToNative(G.lx) * 5) mod (ScaleToNative(G.lx) * 2); 4089 4080 MiniPixel.SetXY(xm, y); 4090 4081 cm := MiniColors[MyMap[Loc] and fTerrain, i]; … … 6092 6083 NoMap.PaintUnit(xMoving - xMin, yMoving - yMin, UnitInfo, 0); 6093 6084 PaintBufferToScreen(xMin, yMin, xRange, yRange); 6085 {$IFDEF LINUX} 6086 // TODO: Force animation under linux 6087 DpiApplication.ProcessMessages; 6088 {$ENDIF} 6094 6089 6095 6090 SliceCount := 0; … … 6097 6092 repeat 6098 6093 if (SliceCount = 0) or 6099 ( MillisecondOf(Ticks - Ticks0) * 12* (SliceCount + 1) div SliceCount6094 (Round(((Ticks - Ticks0) * 12) / OneMillisecond) * (SliceCount + 1) div SliceCount 6100 6095 < MoveTime) then 6101 6096 begin 6102 6097 if not idle or (GameMode = cMovie) then 6103 6098 DpiApplication.ProcessMessages; 6104 {$IFDEF LINUX}6105 // TODO: Force animation under linux6106 DpiApplication.ProcessMessages;6107 {$ENDIF}6108 6099 Sleep(1); 6109 6100 inc(SliceCount) 6110 6101 end; 6111 6102 Ticks := NowPrecise; 6112 until ( Ticks - Ticks0) / OneMillisecond * 12>= MoveTime;6103 until (((Ticks - Ticks0) * 12) / OneMillisecond) >= MoveTime; 6113 6104 Ticks0 := Ticks 6114 6105 end; … … 6551 6542 time1 := NowPrecise; 6552 6543 SimpleMessage(Format('Map repaint time: %.3f ms', 6553 [ MillisecondOf(time1 - time0)]));6544 [(time1 - time0) / OneMillisecond])); 6554 6545 end 6555 6546 end … … 7628 7619 InitPopup(GamePopup); 7629 7620 if FullScreen then 7630 // GamePopup.FItems.Count7631 7621 GamePopup.Popup(Left, Top + TopBarHeight - 1) 7632 7622 else … … 7807 7797 procedure TMainScreen.FormShow(Sender: TObject); 7808 7798 begin 7809 Timer1.Enabled := true; 7810 Left := 0; 7811 Top := 0; 7799 if FullScreen then begin 7800 WindowState := wsFullScreen; 7801 BorderStyle := bsNone; 7802 BorderIcons := []; 7803 end else begin 7804 WindowState := wsMaximized; 7805 BorderStyle := bsSizeable; 7806 BorderIcons := [biSystemMenu, biMinimize, biMaximize]; 7807 end; 7808 Timer1.Enabled := True; 7812 7809 end; 7813 7810
Note:
See TracChangeset
for help on using the changeset viewer.