Changeset 212
- Timestamp:
- May 9, 2020, 9:35:25 PM (5 years ago)
- Location:
- branches/highdpi
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/LocalPlayer/Help.pas
r210 r212 445 445 x, y, dx, dy, xSrc, ySrc, sum, xx: integer; 446 446 Heaven: array [0..nHeaven] of integer; 447 PaintPtr, CoalPtr: TPixelPointer; 447 PaintPtr: TPixelPointer; 448 CoalPtr: TPixelPointer; 448 449 ImpPtr: array [-1..1] of TPixelPointer; 449 450 begin -
branches/highdpi/LocalPlayer/IsoEngine.pas
r210 r212 34 34 function IsShoreTile(Loc: integer): boolean; 35 35 procedure MakeDark(Line: PPixelPointer; Length: Integer); 36 procedure ShadeOutside(x0, y0, x1, y1, xm, ym: integer);36 procedure ShadeOutside(x0, y0, Width, Height, xm, ym: integer); 37 37 protected 38 38 FOutput: TDpiBitmap; … … 1015 1015 1 + 8 * (xxt * 2 + 1), 1 + yyt + 16 * (yyt * 3 + 1)); 1016 1016 Borders.BeginUpdate; 1017 for dy := 0 to yyt * 2 - 1 do 1018 begin 1019 PixelPtr := PixelPointer(Borders, 0, p1 * (yyt * 2) + dy); 1020 for dx := 0 to xxt * 2 - 1 do begin 1017 PixelPtr := PixelPointer(Borders, ScaleToVcl(0), ScaleToVcl(p1 * (yyt * 2))); 1018 for dy := 0 to ScaleToVcl(yyt * 2) - 1 do begin 1019 for dx := 0 to ScaleToVcl(xxt * 2) - 1 do begin 1021 1020 if PixelPtr.Pixel^.B = 99 then begin 1022 1021 PixelPtr.Pixel^.B := Tribe[p1].Color shr 16 and $FF; … … 1026 1025 PixelPtr.NextPixel; 1027 1026 end; 1027 PixelPtr.NextLine; 1028 1028 end; 1029 1029 Borders.EndUpdate; … … 1330 1330 end; 1331 1331 1332 procedure TIsoMap.ShadeOutside(x0, y0, x1, y1, xm, ym: integer);1332 procedure TIsoMap.ShadeOutside(x0, y0, Width, Height, xm, ym: integer); 1333 1333 const 1334 1334 rShade = 3.75; … … 1339 1339 begin 1340 1340 FOutput.BeginUpdate; 1341 for y := y0 to y1 - 1 do begin1342 Line := PixelPointer(FOutput, 0, y);1343 y_n := ( y- ym) / yyt;1344 if abs(y_n) < rShade then begin1341 Line := PixelPointer(FOutput, ScaleToVcl(x0), ScaleToVcl(y0)); 1342 for y := 0 to ScaleToVcl(Height) - 1 do begin 1343 y_n := (ScaleFromVcl(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);1348 Line.SetX( x0);1349 MakeDark(@Line, xm - x0 - wBright);1350 Line.SetX( xm + wBright);1351 MakeDark(@Line, x1 - xm - wBright);1346 w_n := Sqrt(Sqr(rShade) - Sqr(y_n)); 1347 wBright := Trunc(w_n * xxt + 0.5); 1348 Line.SetX(0); 1349 MakeDark(@Line, ScaleToVcl(xm - wBright)); 1350 Line.SetX(ScaleToVcl(xm + wBright)); 1351 MakeDark(@Line, ScaleToVcl(Width - xm - wBright)); 1352 1352 end else begin 1353 1353 // Darken entire line 1354 Line.SetX( x0);1355 MakeDark(@Line, x1 - x0);1354 Line.SetX(0); 1355 MakeDark(@Line, ScaleToVcl(Width)); 1356 1356 end; 1357 Line.NextLine; 1357 1358 end; 1358 1359 FOutput.EndUpdate; … … 1576 1577 xm := x + (dx + 1) * xxt; 1577 1578 ym := y + (dy + 1) * yyt + yyt; 1578 ShadeOutside(FLeft, FTop, FRight , FBottom, xm, ym);1579 ShadeOutside(FLeft, FTop, FRight - FLeft, FBottom - FTop, xm, ym); 1579 1580 CityGrid(xm, ym, CityAllowClick); 1580 1581 for dy := -2 to ny + 1 do -
branches/highdpi/LocalPlayer/Term.pas
r210 r212 532 532 SmallScreen, GameOK, MapValid, skipped, idle: boolean; 533 533 534 SaveOption: array [0 ..nSaveOption - 1] of integer;535 MiniColors: array [0 .. 11, 0 ..1] of TColor;534 SaveOption: array [0..nSaveOption - 1] of integer; 535 MiniColors: array [0..fTerrain, 0..1] of TColor; 536 536 MainMap: TIsoMap; 537 537 CurrentMoveInfo: record AfterMovePaintRadius, AfterAttackExpeller: integer; … … 4077 4077 MiniPixel := PixelPointer(Mini); 4078 4078 PrevMiniPixel := PixelPointer(Mini); 4079 for y := 0 to G.ly- 1 do4080 begin 4081 for x := 0 to G.lx- 1 do4082 if MyMap[ x + G.lx * y] and fTerrain <> fUNKNOWN then4083 begin 4084 Loc := x + G.lx * y;4079 for y := 0 to ScaleToVcl(G.ly) - 1 do 4080 begin 4081 for x := 0 to ScaleToVcl(G.lx) - 1 do 4082 if MyMap[ScaleFromVcl(x) + G.lx * ScaleFromVcl(y)] and fTerrain <> fUNKNOWN then 4083 begin 4084 Loc := ScaleFromVcl(x) + G.lx * ScaleFromVcl(y); 4085 4085 for i := 0 to 1 do 4086 4086 begin 4087 xm := ((x - xwMini) * 2 + i + y and 1 - hw + G.lx * 5) mod (G.lx * 2); 4087 xm := ((x - ScaleToVcl(xwMini)) * 2 + i + y and 1 - ScaleToVcl(hw) + 4088 ScaleToVcl(G.lx) * 5) mod (ScaleToVcl(G.lx) * 2); 4088 4089 MiniPixel.SetXY(xm, y); 4089 4090 cm := MiniColors[MyMap[Loc] and fTerrain, i]; … … 5079 5080 dx := 0; 5080 5081 dy := 0; 5081 if Mouse.CursorPos.y < DpiScreen.height - PanelHeight then5082 if Mouse.CursorPos.x = 0 then5082 if DpiMouse.CursorPos.y < DpiScreen.height - PanelHeight then 5083 if DpiMouse.CursorPos.x = 0 then 5083 5084 dx := -speed // scroll left 5084 else if Mouse.CursorPos.x = DpiScreen.width - 1 then5085 else if DpiMouse.CursorPos.x = DpiScreen.width - 1 then 5085 5086 dx := speed; // scroll right 5086 if Mouse.CursorPos.y = 0 then5087 if DpiMouse.CursorPos.y = 0 then 5087 5088 dy := -speed // scroll up 5088 else if ( Mouse.CursorPos.y = DpiScreen.height - 1) and5089 ( Mouse.CursorPos.x >= TerrainBtn.Left + TerrainBtn.width) and5090 ( Mouse.CursorPos.x < xRightPanel + 10 - 8) then5089 else if (DpiMouse.CursorPos.y = DpiScreen.height - 1) and 5090 (DpiMouse.CursorPos.x >= TerrainBtn.Left + TerrainBtn.width) and 5091 (DpiMouse.CursorPos.x < xRightPanel + 10 - 8) then 5091 5092 dy := speed; // scroll down 5092 5093 if (dx <> 0) or (dy <> 0) then -
branches/highdpi/Packages/CevoComponents/DrawDlg.pas
r210 r212 128 128 {$IFDEF LINUX} 129 129 // HitTest is not supported under Linux GTK2 so use form inside move mechanizm 130 NewFormPos := ScreenToClient( Mouse.CursorPos);130 NewFormPos := ScreenToClient(DpiMouse.CursorPos); 131 131 if (NewFormPos.X >= 0) and (NewFormPos.X < Width) and 132 132 (NewFormPos.Y >= 0) and (NewFormPos.Y < Height) then begin 133 133 MoveMousePos := ClientToScreen(Point(X, Y)); 134 134 MoveFormPos := Point(Left, Top); 135 MousePosNew := Mouse.CursorPos;135 MousePosNew := DpiMouse.CursorPos; 136 136 // Activate move only if mouse position was not changed during inherited call 137 137 if (MousePosNew.X = MoveMousePos.X) and (MousePosNew.Y = MoveMousePos.Y) then begin -
branches/highdpi/Packages/DpiControls/UDpiControls.pas
r210 r212 38 38 property OnMouseUp; 39 39 property OnMouseMove; 40 property OnMouseWheel; 41 property OnMouseLeave; 42 property OnMouseEnter; 40 43 end; 41 44 … … 122 125 FLeft: Integer; 123 126 FOnChangeBounds: TNotifyEvent; 127 FOnMouseUp: TMouseEvent; 124 128 FOnMouseDown: TMouseEvent; 125 129 FOnMouseMove: TMouseMoveEvent; 126 FOnMouseUp: TMouseEvent; 130 FOnMouseEnter: TNotifyEvent; 131 FOnMouseLeave: TNotifyEvent; 127 132 FOnMouseWheel: TMouseWheelEvent; 128 133 FOnResize: TNotifyEvent; … … 161 166 procedure DoFormResize; 162 167 procedure DoChangeBounds; 168 procedure MouseDownHandler(Sender: TObject; Button: TMouseButton; Shift: TShiftState; 169 X, Y: Integer); virtual; 170 procedure MouseUpHandler(Sender: TObject; Button: TMouseButton; Shift: TShiftState; 171 X, Y: Integer); virtual; 172 procedure MouseMoveHandler(Sender: TObject; Shift: TShiftState; X, Y: Integer); virtual; 173 procedure MouseWheelHandler(Sender: TObject; Shift: TShiftState; 174 WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); virtual; 175 procedure MouseLeaveHandler(Sender: TObject); virtual; 176 procedure MouseEnterHandler(Sender: TObject); virtual; 163 177 protected 164 178 procedure UpdateBounds; virtual; … … 174 188 function GetVclControl: TControl; virtual; 175 189 procedure UpdateVclControl; virtual; 176 procedure MouseDownHandler(Sender: TObject; Button: TMouseButton; Shift: TShiftState;177 X, Y: Integer); virtual;178 procedure MouseUpHandler(Sender: TObject; Button: TMouseButton; Shift: TShiftState;179 X, Y: Integer); virtual;180 procedure MouseMoveHandler(Sender: TObject; Shift: TShiftState; X, Y: Integer); virtual;181 procedure MouseWheelHandler(Sender: TObject; Shift: TShiftState;182 WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); virtual;183 190 procedure MouseDown(Button: TMouseButton; Shift: TShiftState; 184 191 X, Y: Integer); virtual; … … 187 194 procedure MouseMove(Shift: TShiftState; X, Y: Integer); virtual; 188 195 procedure MouseLeave; virtual; 196 procedure MouseEnter; virtual; 189 197 public 190 198 function ScreenToClient(const APoint: TPoint): TPoint; virtual; … … 333 341 function GetVclGraphicControl: TGraphicControl; virtual; 334 342 procedure UpdateVclControl; override; 335 procedure UpdateVclControlPrivate; virtual;336 343 property OnPaint: TNotifyEvent read GetOnPaint write SetOnPaint; 337 344 public … … 668 675 669 676 TDpiPaintBox = class(TDpiGraphicControl) 670 private671 procedure UpdateVclControlPrivate; override;672 677 public 673 678 VclPaintBox: TPaintBox; … … 689 694 FForms: TDpiForms; 690 695 procedure AddForm(AForm: TDpiForm); 696 procedure RemoveForm(AForm: TDpiForm); 691 697 function GetActiveForm: TDpiForm; 692 698 function GetCursor: TCursor; … … 767 773 end; 768 774 775 { TDpiMouse } 776 777 // TMouse 778 TDpiMouse = class 779 private 780 function GetCursorPos: TPoint; 781 procedure SetCursorPos(AValue: TPoint); 782 public 783 property CursorPos: TPoint read GetCursorPos write SetCursorPos; 784 end; 785 769 786 var 770 787 DpiFormFileDesc: TDpiFormFileDesc; 771 788 DpiScreen: TDpiScreen; 772 789 DpiApplication: TDpiApplication; 790 DpiMouse: TDpiMouse; 773 791 774 792 procedure Register; … … 869 887 end; 870 888 889 { TDpiMouse } 890 891 function TDpiMouse.GetCursorPos: TPoint; 892 begin 893 Result := ScalePointFromVcl(Mouse.CursorPos); 894 end; 895 896 procedure TDpiMouse.SetCursorPos(AValue: TPoint); 897 begin 898 Mouse.CursorPos := ScalePointToVcl(AValue); 899 end; 900 871 901 { TDpiSizeConstraints } 872 902 … … 1549 1579 { TDpiPaintBox } 1550 1580 1551 procedure TDpiPaintBox.UpdateVclControlPrivate;1552 begin1553 VclPaintBox.OnPaint := @PaintHandler;1554 VclPaintBox.OnMouseDown := @MouseDownHandler;1555 VclPaintBox.OnMouseUp := @MouseUpHandler;1556 VclPaintBox.OnMouseMove := @MouseMoveHandler;1557 end;1558 1559 1581 function TDpiPaintBox.GetVclGraphicControl: TGraphicControl; 1560 1582 begin … … 1796 1818 begin 1797 1819 inherited; 1798 UpdateVclControlPrivate;1799 end;1800 1801 procedure TDpiGraphicControl.UpdateVclControlPrivate;1802 begin1803 1820 TGraphicControlEx(GetVclGraphicControl).OnPaint := @PaintHandler; 1804 TControlEx(GetVclControl).OnMouseDown := @MouseDownHandler;1805 TControlEx(GetVclControl).OnMouseUp := @MouseUpHandler;1806 TControlEx(GetVclControl).OnMouseMove := @MouseMoveHandler;1807 // Some VCL component event are not accessible on TGraphicControl level.1808 // Delegate this responsibility up1809 {1810 GetVclGraphicControl.OnPaint := @PaintHandler;1811 GetVclControl.OnMouseDown := @MouseDownHandler;1812 GetVclControl.OnMouseUp := @MouseUpHandler;1813 GetVclControl.OnMouseMove := @MouseMoveHandler;1814 }1815 // raise Exception.Create('Missing inicialization of private fields for ' + ClassName);1816 1821 end; 1817 1822 … … 2134 2139 end; 2135 2140 2141 procedure TDpiScreen.RemoveForm(AForm: TDpiForm); 2142 begin 2143 FForms.Remove(AForm); 2144 if AForm = FActiveForm then FActiveForm := nil; 2145 end; 2146 2136 2147 function TDpiScreen.GetActiveForm: TDpiForm; 2137 2148 begin … … 2161 2172 FForms := TDpiForms.Create; 2162 2173 FForms.FreeObjects := False; 2163 Dpi := 150;2174 Dpi := Round(96 * 2); //Screen.PixelsPerInch; 2164 2175 end; 2165 2176 … … 2214 2225 GetVclControl.OnResize := @VclFormResize; 2215 2226 GetVclControl.OnChangeBounds := @VclChangeBounds; 2227 TControlEx(GetVclControl).OnMouseDown := @MouseDownHandler; 2228 TControlEx(GetVclControl).OnMouseUp := @MouseUpHandler; 2229 TControlEx(GetVclControl).OnMouseMove := @MouseMoveHandler; 2230 TControlEx(GetVclControl).OnMouseEnter := @MouseEnterHandler; 2231 TControlEx(GetVclControl).OnMouseLeave := @MouseLeaveHandler; 2232 TControlEx(GetVclControl).OnMouseWheel := @MouseWheelHandler; 2216 2233 end; 2217 2234 … … 2244 2261 end; 2245 2262 2263 procedure TDpiControl.MouseLeaveHandler(Sender: TObject); 2264 begin 2265 MouseLeave; 2266 if Assigned(FOnMouseLeave) then FOnMouseLeave(Self); 2267 end; 2268 2269 procedure TDpiControl.MouseEnterHandler(Sender: TObject); 2270 begin 2271 MouseEnter; 2272 if Assigned(FOnMouseEnter) then FOnMouseEnter(Self); 2273 end; 2274 2246 2275 procedure TDpiControl.MouseDown(Button: TMouseButton; Shift: TShiftState; X, 2247 2276 Y: Integer); … … 2260 2289 procedure TDpiControl.MouseLeave; 2261 2290 begin 2262 2291 end; 2292 2293 procedure TDpiControl.MouseEnter; 2294 begin 2263 2295 end; 2264 2296 … … 2817 2849 begin 2818 2850 inherited; 2819 GetVclForm.OnMouseDown := @MouseDownHandler;2820 GetVclForm.OnMouseUp := @MouseUpHandler;2821 GetVclForm.OnMouseMove := @MouseMoveHandler;2822 2851 GetVclForm.OnActivate := @ActivateHandler; 2823 2852 GetVclForm.OnDeactivate := @DeactivateHandler; … … 2847 2876 // Init the component with an IDE resource 2848 2877 constructor TDpiForm.Create(TheOwner: TComponent); 2849 var2850 C: TComponent;2851 2878 begin 2852 2879 //inherited; … … 2855 2882 try 2856 2883 CreateNew(TheOwner, 1); // this calls BeginFormUpdate, which is ended in AfterConstruction 2857 // Self2858 C := FindGlobalComponent('TListDlg');2859 2884 if (ClassType <> TDpiForm) and not (csDesigning in ComponentState) then begin 2860 2885 if not InitResourceComponent(Self, TDataModule) then begin … … 2878 2903 begin 2879 2904 FreeAndNil(VclForm); 2905 DpiScreen.RemoveForm(Self); 2880 2906 end; 2881 2907 -
branches/highdpi/Start.pas
r210 r212 48 48 Bitmap: TDpiBitmap; { game world sample preview } 49 49 Size: TPoint; 50 Colors: array [0 .. 11, 0 ..1] of TColor;50 Colors: array [0..fTerrain, 0..1] of TColor; 51 51 Mode: TMiniMode; 52 52 procedure LoadFromLogFile(FileName: string; var LastTurn: Integer);
Note:
See TracChangeset
for help on using the changeset viewer.