Changeset 246 for branches/highdpi/LocalPlayer
- Timestamp:
- May 21, 2020, 8:17:38 PM (5 years ago)
- Location:
- branches/highdpi/LocalPlayer
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/LocalPlayer/CityScreen.lfm
r210 r246 21 21 OnShow = FormShow 22 22 PixelsPerInch = 96 23 Scaled = False 23 24 object CloseBtn: TButtonA 24 25 Left = 335 -
branches/highdpi/LocalPlayer/CityScreen.pas
r210 r246 435 435 end; 436 436 end; 437 438 procedure MakeRed(X, Y, W, H: Integer);439 var440 XX, YY: Integer;441 Gray: Integer;442 PixelPtr: TPixelPointer;443 begin444 X := ScaleToVcl(X);445 Y := ScaleToVcl(Y);446 W := ScaleToVcl(W);447 H := ScaleToVcl(H);448 Offscreen.BeginUpdate;449 PixelPtr := PixelPointer(Offscreen, X, Y);450 for YY := 0 to H - 1 do begin451 for XX := 0 to W - 1 do begin452 Gray := (Integer(PixelPtr.Pixel^.B) + Integer(PixelPtr.Pixel^.G) +453 Integer(PixelPtr.Pixel^.R)) * 85 shr 8;454 PixelPtr.Pixel^.B := 0;455 PixelPtr.Pixel^.G := 0;456 PixelPtr.Pixel^.R := Gray; // 255-(255-gray) div 2;457 PixelPtr.NextPixel;458 end;459 PixelPtr.NextLine;460 end;461 Offscreen.EndUpdate;462 end;463 464 437 var 465 438 line, MessageCount: integer; … … 565 538 if not IsCityAlive then 566 539 begin 567 MakeRed( 18, 280, 298, 40);540 MakeRed(Offscreen, 18, 280, 298, 40); 568 541 if cGov = gAnarchy then 569 542 s := Phrases.Lookup('GOVERNMENT', gAnarchy) … … 701 674 else 702 675 begin 703 MakeRed( xHapp + dxBar - 6, yHapp + 2 * dyBar, wBar + 10, 38);676 MakeRed(Offscreen, xHapp + dxBar - 6, yHapp + 2 * dyBar, wBar + 10, 38); 704 677 CountBar(offscreen, xHapp + dxBar, yHapp + 2 * dyBar, wBar, 18, 705 678 Phrases.Lookup('LACK'), -Report.HappinessBalance, RedTex); … … 726 699 else 727 700 begin 728 MakeRed( xFood + dxBar - 6, yFood + 2 * dyBar, wBar + 10, 38);701 MakeRed(Offscreen, xFood + dxBar - 6, yFood + 2 * dyBar, wBar + 10, 38); 729 702 CountBar(offscreen, xFood + dxBar, yFood + 2 * dyBar, wBar, 1, 730 703 Phrases.Lookup('LACK'), -Report.FoodSurplus, RedTex); … … 759 732 else 760 733 begin 761 MakeRed( xProd + dxBar - 6, yProd + dyBar + 17, wBar + 10, 38);734 MakeRed(Offscreen, xProd + dxBar - 6, yProd + dyBar + 17, wBar + 10, 38); 762 735 CountBar(offscreen, xProd + dxBar, yProd + dyBar + 16, wBar, 3, 763 736 Phrases.Lookup('LACK'), -Report.Production, RedTex); … … 1684 1657 end 1685 1658 else 1659 if OpenSoundEvent >= 0 then 1686 1660 Play(CityEventSoundItem[OpenSoundEvent]); 1687 1661 OpenSoundEvent := -2; -
branches/highdpi/LocalPlayer/Diagram.lfm
r244 r246 18 18 OnShow = FormShow 19 19 PixelsPerInch = 96 20 Scaled = False 20 21 object CloseBtn: TButtonB 21 22 Left = 380 -
branches/highdpi/LocalPlayer/Draft.lfm
r210 r246 19 19 OnShow = FormShow 20 20 LCLVersion = '1.6.0.4' 21 PixelsPerInch = 96 22 Scaled = False 21 23 object OKBtn: TButtonA 22 24 Left = 196 -
branches/highdpi/LocalPlayer/Help.lfm
r210 r246 22 22 OnPaint = FormPaint 23 23 PixelsPerInch = 96 24 Scaled = False 24 25 object CloseBtn: TButtonB 25 26 Left = 522 -
branches/highdpi/LocalPlayer/Help.pas
r213 r246 443 443 MaxSum = 9 * 9 * 255 * 75 div 100; 444 444 var 445 x, y, dx, dy, xSrc, ySrc, Sum, xx: integer;445 x, y, dx, dy, xSrc, ySrc, sum, xx: integer; 446 446 Heaven: array [0..nHeaven] of integer; 447 PaintPtr: TPixelPointer; 448 CoalPtr: TPixelPointer; 447 PaintPtr, CoalPtr: TPixelPointer; 449 448 ImpPtr: array [-1..1] of TPixelPointer; 450 449 begin … … 458 457 xSrc := iix mod 7 * xSizeBig; 459 458 ySrc := (iix div 7 + 1) * ySizeBig; 460 for y := 0 to ScaleTo Vcl(ySizeBig * 2)- 1 do461 if ((ScaleTo Vcl(y0) + y) >= 0) and ((ScaleToVcl(y0) + y) < ScaleToVcl(InnerHeight)) then begin462 PaintPtr := PixelPointer(OffScreen, 0, ScaleTo Vcl(y0) + y);463 CoalPtr := PixelPointer(Templates, 0, ScaleTo Vcl(yCoal) + y);459 for y := 0 to ScaleToNative(ySizeBig) * 2 - 1 do 460 if ((ScaleToNative(y0) + y) >= 0) and ((ScaleToNative(y0) + y) < ScaleToNative(InnerHeight)) then begin 461 PaintPtr := PixelPointer(OffScreen, 0, ScaleToNative(y0) + y); 462 CoalPtr := PixelPointer(Templates, 0, ScaleToNative(yCoal) + y); 464 463 for dy := -1 to 1 do 465 if ((Max(y + ScaleTo Vcl(dy), 0) shr 1) >= 0) and ((Max(y + ScaleToVcl(dy), 0) shr 1) < ScaleToVcl(ySizeBig)) then466 ImpPtr[dy] := PixelPointer(BigImp, 0, ScaleTo Vcl(ySrc) + (Max(y + ScaleToVcl(dy), 0) shr 1));467 for x := 0 to ScaleTo Vcl(xSizeBig * 2)- 1 do begin468 Sum := 0;464 if ((Max(y + ScaleToNative(dy), 0) shr 1) >= 0) and ((Max(y + ScaleToNative(dy), 0) shr 1) < ScaleToNative(ySizeBig)) then 465 ImpPtr[dy] := PixelPointer(BigImp, 0, ScaleToNative(ySrc) + (Max(y + ScaleToNative(dy), 0) shr 1)); 466 for x := 0 to ScaleToNative(xSizeBig) * 2 - 1 do begin 467 sum := 0; 469 468 for dx := -1 to 1 do begin 470 xx := ScaleTo Vcl(xSrc) + Max((x + ScaleToVcl(dx)), 0) shr 1;469 xx := ScaleToNative(xSrc) + Max((x + ScaleToNative(dx)), 0) shr 1; 471 470 for dy := -1 to 1 do begin 472 471 ImpPtr[dy].SetX(xx); 473 if ((y + ScaleTo Vcl(dy)) shr 1 < 0) or ((y + ScaleToVcl(dy)) shr 1 >= ScaleToVcl(ySizeBig)) or474 ((x + ScaleTo Vcl(dx)) shr 1 < 0) or ((x + ScaleToVcl(dx)) shr 1 >= ScaleToVcl(xSizeBig)) or475 ((y + ScaleTo Vcl(dy)) shr 1 < ScaleToVcl(nHeaven)) and472 if ((y + ScaleToNative(dy)) shr 1 < 0) or ((y + ScaleToNative(dy)) shr 1 >= ScaleToNative(ySizeBig)) or 473 ((x + ScaleToNative(dx)) shr 1 < 0) or ((x + ScaleToNative(dx)) shr 1 >= ScaleToNative(xSizeBig)) or 474 ((y + ScaleToNative(dy)) shr 1 < ScaleToNative(nHeaven)) and 476 475 (ImpPtr[dy].Pixel^.B shl 16 + ImpPtr[dy].Pixel^.G shl 8 + 477 ImpPtr[dy].Pixel^.R = Heaven[(ScaleFrom Vcl(y) + dy) shr 1]) then478 Sum := Sum + 9 * 255476 ImpPtr[dy].Pixel^.R = Heaven[(ScaleFromNative(y) + dy) shr 1]) then 477 sum := sum + 9 * 255 479 478 else 480 Sum := Sum + ImpPtr[dy].Pixel^.B + 5 * ImpPtr[dy].Pixel^.G + 3 *479 sum := sum + ImpPtr[dy].Pixel^.B + 5 * ImpPtr[dy].Pixel^.G + 3 * 481 480 ImpPtr[dy].Pixel^.R; 482 481 end; 483 482 end; 484 if Sum < MaxSum then begin // no saturation485 CoalPtr.SetX(ScaleTo Vcl(xCoal) + x);486 Sum := 1 shl 22 - (MaxSum - Sum) * (256 - CoalPtr.Pixel^.B * 2);483 if sum < MaxSum then begin // no saturation 484 CoalPtr.SetX(ScaleToNative(xCoal) + x); 485 sum := 1 shl 22 - (MaxSum - sum) * (256 - CoalPtr.Pixel^.B * 2); 487 486 PaintPtr.SetX(x0 + x); 488 PaintPtr.Pixel^.B := PaintPtr.Pixel^.B * Sum shr 22;489 PaintPtr.Pixel^.G := PaintPtr.Pixel^.G * Sum shr 22;490 PaintPtr.Pixel^.R := PaintPtr.Pixel^.R * Sum shr 22;487 PaintPtr.Pixel^.B := PaintPtr.Pixel^.B * sum shr 22; 488 PaintPtr.Pixel^.G := PaintPtr.Pixel^.G * sum shr 22; 489 PaintPtr.Pixel^.R := PaintPtr.Pixel^.R * sum shr 22; 491 490 end; 492 491 end; -
branches/highdpi/LocalPlayer/IsoEngine.pas
r212 r246 1015 1015 1 + 8 * (xxt * 2 + 1), 1 + yyt + 16 * (yyt * 3 + 1)); 1016 1016 Borders.BeginUpdate; 1017 PixelPtr := PixelPointer(Borders, ScaleTo Vcl(0), ScaleToVcl(p1 * (yyt * 2)));1018 for dy := 0 to ScaleTo Vcl(yyt * 2) - 1 do begin1019 for dx := 0 to ScaleTo Vcl(xxt * 2) - 1 do begin1017 PixelPtr := PixelPointer(Borders, ScaleToNative(0), ScaleToNative(p1 * (yyt * 2))); 1018 for dy := 0 to ScaleToNative(yyt * 2) - 1 do begin 1019 for dx := 0 to ScaleToNative(xxt * 2) - 1 do begin 1020 1020 if PixelPtr.Pixel^.B = 99 then begin 1021 1021 PixelPtr.Pixel^.B := Tribe[p1].Color shr 16 and $FF; … … 1339 1339 begin 1340 1340 FOutput.BeginUpdate; 1341 Line := PixelPointer(FOutput, ScaleTo Vcl(x0), ScaleToVcl(y0));1342 for y := 0 to ScaleTo Vcl(Height) - 1 do begin1343 y_n := (ScaleFrom Vcl(y) + y0 - ym) / yyt;1344 if Abs(y_n) < rShade then begin1341 Line := PixelPointer(FOutput, ScaleToNative(x0), ScaleToNative(y0)); 1342 for y := 0 to ScaleToNative(Height) - 1 do begin 1343 y_n := (ScaleFromNative(y) + y0 - ym) / yyt; 1344 if abs(y_n) < rShade then begin 1345 1345 // Darken left and right parts of elipsis 1346 w_n := Sqrt(Sqr(rShade) - Sqr(y_n));1347 wBright := Trunc(w_n * xxt + 0.5);1346 w_n := sqrt(sqr(rShade) - sqr(y_n)); 1347 wBright := trunc(w_n * xxt + 0.5); 1348 1348 Line.SetX(0); 1349 MakeDark(@Line, ScaleTo Vcl(xm - wBright));1350 Line.SetX(ScaleTo Vcl(xm + wBright));1351 MakeDark(@Line, ScaleTo Vcl(Width - xm - wBright));1349 MakeDark(@Line, ScaleToNative(xm - wBright)); 1350 Line.SetX(ScaleToNative(xm + wBright)); 1351 MakeDark(@Line, ScaleToNative(Width - xm - wBright)); 1352 1352 end else begin 1353 1353 // Darken entire line 1354 1354 Line.SetX(0); 1355 MakeDark(@Line, ScaleTo Vcl(Width));1355 MakeDark(@Line, ScaleToNative(Width)); 1356 1356 end; 1357 1357 Line.NextLine; -
branches/highdpi/LocalPlayer/MessgEx.lfm
r210 r246 20 20 OnShow = FormShow 21 21 PixelsPerInch = 96 22 Scaled = False 22 23 object Button1: TButtonA 23 24 Left = 43 -
branches/highdpi/LocalPlayer/MessgEx.pas
r216 r246 212 212 Sleep(1); 213 213 Ticks := NowPrecise; 214 until MovieCancelled or ( MillisecondOf(Ticks - Ticks0) >= 1500);214 until MovieCancelled or (Round((Ticks - Ticks0) / OneMillisecond) >= 1500); 215 215 Hide; 216 216 end; … … 237 237 Screwed: array [0 .. wScrewed - 1, 0 .. hScrewed - 1, 0 .. 3] of single; 238 238 SrcPtr: TPixelPointer; 239 begin 239 Width: Integer; 240 Height: Integer; 241 begin 242 Width := 56; 243 Height := 40; 240 244 if IconIndex >= 0 then begin 241 245 xIcon := IconIndex mod 7 * xSizeBig; 242 246 yIcon := (IconIndex + SystemIconLines * 7) div 7 * ySizeBig; 243 247 // prepare screwed icon 244 fillchar(Screwed, sizeof(Screwed), 0);248 FillChar(Screwed, sizeof(Screwed), 0); 245 249 BigImp.BeginUpdate; 246 for iy := 0 to 39 do begin247 for ix := 0 to 55do begin248 SrcPtr := PixelPointer(BigImp, ix + xIcon, iy + yIcon);249 xR := ix * (37 + iy * 5 / 40) / 56;250 SrcPtr := PixelPointer(BigImp, ScaleToNative(xIcon), ScaleToNative(yIcon)); 251 for iy := 0 to ScaleToNative(Height) - 1 do begin 252 for ix := 0 to ScaleToNative(Width) - 1 do begin 253 xR := ScaleFromNative(ix) * (37 + ScaleFromNative(iy) * 5 / Height) / Width; 250 254 xDst := Trunc(xR); 251 255 xR := Frac(xR); 252 x1 := (120 - ix) * (120 - ix) - 10000;253 yR := iy * 18 / 40+ x1 * x1 / 4000000;256 x1 := (120 - ScaleFromNative(ix)) * (120 - ScaleFromNative(ix)) - 10000; 257 yR := ScaleFromNative(iy) * 18 / Height + x1 * x1 / 4000000; 254 258 yDst := Trunc(yR); 255 259 yR := Frac(yR); … … 272 276 Screwed[xDst + dx, yDst + dy, 3] := Screwed[xDst + dx, yDst + dy, 273 277 3] + share; 274 end; 275 end; 278 end; 279 SrcPtr.NextPixel; 280 end; 281 SrcPtr.NextLine; 276 282 end; 277 283 BigImp.EndUpdate; … … 373 379 begin 374 380 p1 := MyRO.Wonder[IconIndex].EffectiveOwner; 381 // TODO: Explicitly clear background to black but in fact BitBlt SRCCOPY should do it 382 Buffer.Canvas.FillRect(0, 0, 1, 1); 375 383 DpiBitCanvas(Buffer.Canvas, 0, 0, xSizeBig + 2 * GlowRange, 376 384 ySizeBig + 2 * GlowRange, Canvas, -
branches/highdpi/LocalPlayer/NatStat.lfm
r244 r246 17 17 OnShow = FormShow 18 18 PixelsPerInch = 96 19 Scaled = False 19 20 object ToggleBtn: TButtonB 20 21 Left = 6 -
branches/highdpi/LocalPlayer/Select.lfm
r244 r246 23 23 OnShow = FormShow 24 24 PixelsPerInch = 96 25 Scaled = False 25 26 object CloseBtn: TButtonB 26 27 Left = 343 -
branches/highdpi/LocalPlayer/Select.pas
r244 r246 578 578 295 + (AdvIcon[lix] - 84) div 8 * 21); 579 579 j := AdvValue[lix] div 1000; 580 DpiBitCanvas( Canvas, (8 + 16 - 4), y0 + 2, 14, 14,580 DpiBitCanvas(offscreen.Canvas, (8 + 16 - 4), y0 + 2, 14, 14, 581 581 GrExt[HGrSystem].Mask.Canvas, 127 + j * 15, 582 582 85, SRCAND); … … 754 754 end; 755 755 end; 756 756 757 for i := -1 to DispLines do 757 758 if (i + sb.Position >= 0) and (i + sb.Position < Lines[Layer]) then -
branches/highdpi/LocalPlayer/TechTree.pas
r210 r246 9 9 10 10 type 11 12 { TTechTreeDlg } 13 11 14 TTechTreeDlg = class(TDrawDlg) 12 15 CloseBtn: TButtonB; 13 16 procedure FormCreate(Sender: TObject); 17 procedure FormDestroy(Sender: TObject); 14 18 procedure FormPaint(Sender: TObject); 15 19 procedure FormShow(Sender: TObject); … … 24 28 xOffset, yOffset, xDown, yDown: Integer; 25 29 Image: TDpiBitmap; 26 dragging: boolean;30 Dragging: Boolean; 27 31 end; 28 32 … … 72 76 InitButtons; 73 77 Image := nil; 78 end; 79 80 procedure TTechTreeDlg.FormDestroy(Sender: TObject); 81 begin 82 FreeAndNil(Image); 74 83 end; 75 84 … … 121 130 X, Y, ad: Integer; 122 131 s: string; 132 NewWidth: Integer; 133 NewHeight: Integer; 123 134 const 124 135 TransparentColor = $7F007F; … … 164 175 165 176 // fit window to image, center image in window, center window to screen 166 width := min(DpiScreen.width - 40, Image.width + LeftBorder + RightBorder + 2 * 167 BlackBorder); 168 height := min(DpiScreen.height - 40, Image.height + TopBorder + BottomBorder + 2 169 * BlackBorder); 170 Left := (DpiScreen.width - width) div 2; 171 Top := (DpiScreen.height - height) div 2; 177 NewWidth := Min(DpiScreen.Width - 40, Image.Width + LeftBorder + RightBorder + 2 * BlackBorder); 178 NewHeight := Min(DpiScreen.Height - 40, Image.Height + TopBorder + BottomBorder + 2 * BlackBorder); 179 BoundsRect := Bounds((DpiScreen.Width - NewWidth) div 2, 180 (DpiScreen.Height - NewHeight) div 2, 181 NewWidth, NewHeight); 172 182 CloseBtn.Left := width - CloseBtn.width - BlackBorder - 8; 173 183 CloseBtn.Top := BlackBorder + 8; 174 xOffset := (ClientWidth - Image. width + LeftBorder - RightBorder) div 2 -184 xOffset := (ClientWidth - Image.Width + LeftBorder - RightBorder) div 2 - 175 185 BlackBorder; 176 yOffset := ClientHeight - 2 * BlackBorder - Image. height - BottomBorder;186 yOffset := ClientHeight - 2 * BlackBorder - Image.Height - BottomBorder; 177 187 end; 178 188 -
branches/highdpi/LocalPlayer/Term.lfm
r244 r246 1 1 object MainScreen: TMainScreen 2 2 Left = 231 3 Height = 6003 Height = 480 4 4 Top = 190 5 Width = 10005 Width = 800 6 6 HorzScrollBar.Visible = False 7 7 VertScrollBar.Visible = False 8 8 Caption = 'C-evo' 9 ClientHeight = 60010 ClientWidth = 10009 ClientHeight = 480 10 ClientWidth = 800 11 11 Color = clBtnFace 12 Constraints.MinHeight = 600 13 Constraints.MinWidth = 1000 14 DesignTimePPI = 120 12 Constraints.MinHeight = 480 13 Constraints.MinWidth = 800 15 14 Font.Color = clWindowText 16 Font.Height = -1 615 Font.Height = -13 17 16 Font.Name = 'MS Sans Serif' 18 17 KeyPreview = True … … 31 30 OnShow = FormShow 32 31 Position = poDefault 33 LCLVersion = '2.0.6.0' 32 PixelsPerInch = 96 33 Scaled = False 34 LCLVersion = '1.6.0.4' 34 35 WindowState = wsMaximized 35 36 object UnitBtn: TButtonB 36 37 Tag = 14 37 Left = 2 6038 Height = 3139 Top = 48040 Width = 3138 Left = 208 39 Height = 25 40 Top = 384 41 Width = 25 41 42 Visible = False 42 43 Down = False … … 47 48 object MapBtn0: TButtonC 48 49 Tag = 51 49 Left = 2050 Height = 1 551 Top = 3 8052 Width = 1 550 Left = 16 51 Height = 12 52 Top = 304 53 Width = 12 53 54 Visible = False 54 55 Down = False … … 59 60 object MapBtn1: TButtonC 60 61 Tag = 291 61 Left = 2062 Height = 1 563 Top = 40064 Width = 1 562 Left = 16 63 Height = 12 64 Top = 320 65 Width = 12 65 66 Visible = False 66 67 Down = False … … 71 72 object MapBtn4: TButtonC 72 73 Tag = 1028 73 Left = 2074 Height = 1 575 Top = 46076 Width = 1 574 Left = 16 75 Height = 12 76 Top = 368 77 Width = 12 77 78 Visible = False 78 79 Down = False … … 83 84 object MapBtn5: TButtonC 84 85 Tag = 1328 85 Left = 2086 Height = 1 587 Top = 48088 Width = 1 586 Left = 16 87 Height = 12 88 Top = 384 89 Width = 12 89 90 Visible = False 90 91 Down = False … … 95 96 object MapBtn6: TButtonC 96 97 Tag = 1541 97 Left = 2098 Height = 1 599 Top = 500100 Width = 1 598 Left = 16 99 Height = 12 100 Top = 400 101 Width = 12 101 102 Visible = False 102 103 Down = False … … 107 108 object TerrainBtn: TButtonB 108 109 Tag = 28 109 Left = 300110 Height = 31111 Top = 480112 Width = 31110 Left = 240 111 Height = 25 112 Top = 384 113 Width = 25 113 114 Visible = False 114 115 Down = False … … 119 120 object UnitInfoBtn: TButtonB 120 121 Tag = 15 121 Left = 220122 Height = 31123 Top = 480124 Width = 31122 Left = 176 123 Height = 25 124 Top = 384 125 Width = 25 125 126 Visible = False 126 127 Down = False … … 130 131 end 131 132 object EOT: TEOTButton 132 Left = 890133 Height = 60134 Top = 460135 Width = 60133 Left = 712 134 Height = 48 135 Top = 368 136 Width = 48 136 137 Visible = False 137 138 Down = False … … 142 143 object MenuArea: TArea 143 144 Left = 2 144 Height = 45145 Height = 36 145 146 Top = 1 146 Width = 45147 Width = 36 147 148 end 148 149 object TreasuryArea: TArea 149 Left = 2 60150 Height = 45150 Left = 208 151 Height = 36 151 152 Top = 1 152 Width = 205153 Width = 164 153 154 end 154 155 object ResearchArea: TArea 155 Left = 480156 Height = 45156 Left = 384 157 Height = 36 157 158 Top = 1 158 Width = 300159 Width = 240 159 160 end 160 161 object ManagementArea: TArea 161 Left = 880162 Height = 50163 Top = 3 90164 Width = 70162 Left = 704 163 Height = 40 164 Top = 312 165 Width = 56 165 166 end 166 167 object MovieSpeed1Btn: TButtonB 167 168 Tag = 256 168 Left = 480169 Height = 31170 Top = 480171 Width = 31169 Left = 384 170 Height = 25 171 Top = 384 172 Width = 25 172 173 Visible = False 173 174 Down = False … … 178 179 object MovieSpeed2Btn: TButtonB 179 180 Tag = 512 180 Left = 520181 Height = 31182 Top = 480183 Width = 31181 Left = 416 182 Height = 25 183 Top = 384 184 Width = 25 184 185 Visible = False 185 186 Down = False … … 190 191 object MovieSpeed3Btn: TButtonB 191 192 Tag = 768 192 Left = 560193 Height = 31194 Top = 480195 Width = 31193 Left = 448 194 Height = 25 195 Top = 384 196 Width = 25 196 197 Visible = False 197 198 Down = False … … 202 203 object MovieSpeed4Btn: TButtonB 203 204 Tag = 1024 204 Left = 600205 Height = 31206 Top = 480207 Width = 31205 Left = 480 206 Height = 25 207 Top = 384 208 Width = 25 208 209 Visible = False 209 210 Down = False … … 216 217 Interval = 50 217 218 OnTimer = Timer1Timer 218 left = 10219 top = 60219 left = 8 220 top = 48 220 221 end 221 222 object GamePopup: TDpiPopupMenu 222 223 AutoPopup = False 223 left = 50224 top = 60224 left = 40 225 top = 48 225 226 object mHelp: TDpiMenuItem 226 227 Tag = 7 … … 458 459 RadioItem = True 459 460 OnClick = mBigTilesClick 460 end 461 end 461 462 end 462 463 object mSound: TDpiMenuItem … … 586 587 object UnitPopup: TDpiPopupMenu 587 588 AutoPopup = False 588 left = 1 30589 top = 60589 left = 104 590 top = 48 590 591 object mdisband: TDpiMenuItem 591 592 Tag = 72 … … 669 670 object StatPopup: TDpiPopupMenu 670 671 AutoPopup = False 671 left = 90672 top = 60672 left = 72 673 top = 48 673 674 object mUnitStat: TDpiMenuItem 674 675 Tag = 9 … … 725 726 end 726 727 object EditPopup: TDpiPopupMenu 727 left = 210728 top = 60728 left = 168 729 top = 48 729 730 object mCreateUnit: TDpiMenuItem 730 731 Tag = 47 … … 732 733 end 733 734 object TerrainPopup: TDpiPopupMenu 734 left = 1 70735 top = 60735 left = 136 736 top = 48 736 737 object mtrans: TDpiMenuItem 737 738 Tag = 273 -
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 -
branches/highdpi/LocalPlayer/Wonders.lfm
r210 r246 17 17 OnShow = FormShow 18 18 PixelsPerInch = 96 19 Scaled = False 19 20 object CloseBtn: TButtonB 20 21 Left = 442 -
branches/highdpi/LocalPlayer/Wonders.pas
r210 r246 87 87 procedure TWondersDlg.PaintBackgroundShape; 88 88 const 89 darken = 24;89 Darken = 24; 90 90 // space=pi/120; 91 91 amax0 = 15734; // 1 shl 16*tan(pi/12-space); … … 103 103 C: Integer; 104 104 Ch: Integer; 105 Line: array [0.. 1] of TPixelPointer;105 Line: array [0..3] of TPixelPointer; 106 106 Width: Integer; 107 107 Height: Integer; 108 CenterNative: TPoint; 109 begin 110 Width := ScaleToVcl(180); 111 Height := ScaleToVcl(128); 112 CenterNative := ScalePointtoVcl(Center); 108 begin 109 Width := ScaleToNative(180); 110 Height := ScaleToNative(128); 113 111 Offscreen.BeginUpdate; 114 Line[0] := PixelPointer(Offscreen); 115 Line[1] := PixelPointer(Offscreen); 112 Line[0] := PixelPointer(Offscreen, ScaleToNative(Center.X), ScaleToNative(Center.Y)); 113 Line[1] := PixelPointer(Offscreen, ScaleToNative(Center.X), ScaleToNative(Center.Y) - 1); 114 Line[2] := PixelPointer(Offscreen, ScaleToNative(Center.X) - 1, ScaleToNative(Center.Y)); 115 Line[3] := PixelPointer(Offscreen, ScaleToNative(Center.X) - 1, ScaleToNative(Center.Y) - 1); 116 116 for Y := 0 to Height - 1 do begin 117 117 for X := 0 to Width - 1 do begin 118 118 r := X * X * ((Height div 4) * (Height div 4)) + Y * Y * ((Width div 4) * (Width div 4)); 119 119 ax := ((1 shl 16 div (Height div 4)) * (Width div 4)) * Y; 120 if (r < ScaleTo Vcl(8) * Height * Width * Width) and120 if (r < ScaleToNative(8) * Height * Width * Width) and 121 121 ((r >= (Height div 4) * (Height div 2) * (Width div 2) * (Width div 2)) and (ax < amax2 * X) and 122 122 ((ax < amax0 * X) or (ax > amin2 * X)) or (ax > amin1 * X) and 123 ((ax < amax1 * X) or (ax > amin3 * X))) then 124 for i := 0 to 1 do 125 for ch := 0 to 2 do begin 126 Line[0].SetXY(CenterNative.X + X, CenterNative.Y + Y); 127 Line[1].SetXY(CenterNative.X + X, CenterNative.Y - 1 - Y); 128 c := Line[i].Pixel^.Planes[ch] - darken; 129 if c < 0 then Line[i].Pixel^.Planes[ch] := 0 130 else Line[i].Pixel^.Planes[ch] := c; 131 Line[0].SetXY(CenterNative.X - 1 - X, CenterNative.Y + Y); 132 Line[1].SetXY(CenterNative.X - 1 - X, CenterNative.Y - 1 - Y); 133 c := Line[i].Pixel^.Planes[ch] - darken; 134 if c < 0 then Line[i].Pixel^.Planes[ch] := 0 135 else Line[i].Pixel^.Planes[ch] := c; 136 end; 137 end; 123 ((ax < amax1 * X) or (ax > amin3 * X))) then begin 124 for ch := 0 to 2 do begin 125 c := Line[0].Pixel^.Planes[ch] - Darken; 126 if c < 0 then Line[0].Pixel^.Planes[ch] := 0 127 else Line[0].Pixel^.Planes[ch] := c; 128 c := Line[1].Pixel^.Planes[ch] - Darken; 129 if c < 0 then Line[1].Pixel^.Planes[ch] := 0 130 else Line[1].Pixel^.Planes[ch] := c; 131 c := Line[2].Pixel^.Planes[ch] - Darken; 132 if c < 0 then Line[2].Pixel^.Planes[ch] := 0 133 else Line[2].Pixel^.Planes[ch] := c; 134 c := Line[3].Pixel^.Planes[ch] - Darken; 135 if c < 0 then Line[3].Pixel^.Planes[ch] := 0 136 else Line[3].Pixel^.Planes[ch] := c; 137 end; 138 end; 139 Line[0].NextPixel; 140 Line[1].NextPixel; 141 Line[2].PreviousPixel; 142 Line[3].PreviousPixel; 143 end; 144 Line[0].NextLine; 145 Line[1].PreviousLine; 146 Line[2].NextLine; 147 Line[3].PreviousLine; 138 148 end; 139 149 Offscreen.EndUpdate; … … 150 160 x0Src := (i mod 7) * xSizeBig; 151 161 y0Src := (i div 7 + SystemIconLines) * ySizeBig; 152 153 Src := PixelPointer(BigImp, ScaleToVcl(x0Src), ScaleToVcl(y0Src)); 154 Dst := PixelPointer(Offscreen, ScaleToVcl(x0Dst), ScaleToVcl(y0Dst)); 155 for Y := 0 to ScaleToVcl(ySizeBig) - 1 do begin 156 for X := 0 to ScaleToVcl(xSizeBig) - 1 do begin 162 Src := PixelPointer(BigImp, ScaleToNative(x0Src), ScaleToNative(y0Src)); 163 Dst := PixelPointer(Offscreen, ScaleToNative(x0Dst), ScaleToNative(y0Dst)); 164 for Y := 0 to ScaleToNative(ySizeBig) - 1 do begin 165 for X := 0 to ScaleToNative(xSizeBig) - 1 do begin 157 166 Darken := ((255 - Src.Pixel^.B) * 3 + (255 - Src.Pixel^.G) * 158 167 15 + (255 - Src.Pixel^.R) * 9) div 128;
Note:
See TracChangeset
for help on using the changeset viewer.