- Timestamp:
- May 16, 2024, 12:03:29 AM (7 months ago)
- Location:
- trunk/LocalPlayer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/TechTree.lfm
r470 r575 21 21 OnCreate = FormCreate 22 22 OnDestroy = FormDestroy 23 OnKeyUp = FormKeyUp 23 24 OnMouseDown = FormMouseDown 24 25 OnMouseMove = FormMouseMove -
trunk/LocalPlayer/TechTree.pas
r496 r575 17 17 procedure FormCreate(Sender: TObject); 18 18 procedure FormDestroy(Sender: TObject); 19 procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); 19 20 procedure FormPaint(Sender: TObject); 20 21 procedure FormShow(Sender: TObject); … … 26 27 procedure CloseBtnClick(Sender: TObject); 27 28 private 28 xOffset, yOffset, xDown, yDown: Integer; 29 Offset: TPoint; 30 Down: TPoint; 29 31 Image: TBitmap; 30 32 Dragging: Boolean; 33 procedure Move(Diff: TPoint); 31 34 end; 32 35 … … 80 83 end; 81 84 85 procedure TTechTreeDlg.FormKeyUp(Sender: TObject; var Key: Word; 86 Shift: TShiftState); 87 const 88 Diff = 50; 89 begin 90 case Key of 91 37: Move(Point(Diff, 0)); 92 38: Move(Point(0, Diff)); 93 39: Move(Point(-Diff, 0)); 94 40: Move(Point(0, -Diff)); 95 end; 96 end; 97 82 98 procedure TTechTreeDlg.FormPaint(Sender: TObject); 83 99 var … … 95 111 // texturize empty space 96 112 Brush.Color := $FFFFFF; 97 if xOffset> 0 then98 FillRectSeamless(Canvas, BlackBorder, BlackBorder, BlackBorder + xOffset,99 ClientHeight - BlackBorder, -BlackBorder - xOffset,100 -BlackBorder - yOffset, Paper);101 if xOffset+ Image.Width < ClientWidth - 2 * BlackBorder then102 FillRectSeamless(Canvas, BlackBorder + xOffset+ Image.Width, BlackBorder,113 if Offset.X > 0 then 114 FillRectSeamless(Canvas, BlackBorder, BlackBorder, BlackBorder + Offset.X, 115 ClientHeight - BlackBorder, -BlackBorder - Offset.X, 116 -BlackBorder - Offset.Y, Paper); 117 if Offset.X + Image.Width < ClientWidth - 2 * BlackBorder then 118 FillRectSeamless(Canvas, BlackBorder + Offset.X + Image.Width, BlackBorder, 103 119 ClientWidth - BlackBorder, ClientHeight - BlackBorder, 104 -BlackBorder - xOffset, -BlackBorder - yOffset, Paper);105 X := Max(BlackBorder, BlackBorder + xOffset);106 W := Min(BlackBorder + xOffset+ Image.Width, ClientWidth - BlackBorder);107 if yOffset> 0 then108 FillRectSeamless(Canvas, X, BlackBorder, W, BlackBorder + yOffset,109 -BlackBorder - xOffset, -BlackBorder - yOffset, Paper);110 if yOffset+ Image.Height < ClientHeight - 2 * BlackBorder then111 FillRectSeamless(Canvas, X, BlackBorder + yOffset+ Image.Height, W,112 ClientHeight - BlackBorder, -BlackBorder - xOffset,113 -BlackBorder - yOffset, Paper);114 end; 115 BitBltCanvas(Canvas, Max(BlackBorder, BlackBorder + xOffset),116 Max(BlackBorder, BlackBorder + yOffset),117 Min(Image.Width, Min(Image.Width + xOffset,118 Min(ClientWidth - 2 * BlackBorder, ClientWidth - 2 * BlackBorder - xOffset))119 ), Min(Image.Height, Min(Image.Height + yOffset,120 -BlackBorder - Offset.X, -BlackBorder - Offset.Y, Paper); 121 X := Max(BlackBorder, BlackBorder + Offset.X); 122 W := Min(BlackBorder + Offset.X + Image.Width, ClientWidth - BlackBorder); 123 if Offset.Y > 0 then 124 FillRectSeamless(Canvas, X, BlackBorder, W, BlackBorder + Offset.Y, 125 -BlackBorder - Offset.X, -BlackBorder - Offset.Y, Paper); 126 if Offset.Y + Image.Height < ClientHeight - 2 * BlackBorder then 127 FillRectSeamless(Canvas, X, BlackBorder + Offset.Y + Image.Height, W, 128 ClientHeight - BlackBorder, -BlackBorder - Offset.X, 129 -BlackBorder - Offset.Y, Paper); 130 end; 131 BitBltCanvas(Canvas, Max(BlackBorder, BlackBorder + Offset.X), 132 Max(BlackBorder, BlackBorder + Offset.Y), 133 Min(Image.Width, Min(Image.Width + Offset.X, 134 Min(ClientWidth - 2 * BlackBorder, ClientWidth - 2 * BlackBorder - Offset.X)) 135 ), Min(Image.Height, Min(Image.Height + Offset.Y, 120 136 Min(ClientHeight - 2 * BlackBorder, ClientHeight - 2 * BlackBorder - 121 yOffset))), Image.Canvas, Max(0, -xOffset),122 Max(0, - yOffset));137 Offset.Y))), Image.Canvas, Max(0, -Offset.X), 138 Max(0, -Offset.Y)); 123 139 end; 124 140 … … 179 195 CloseBtn.Left := Width - CloseBtn.Width - BlackBorder - 8; 180 196 CloseBtn.Top := BlackBorder + 8; 181 xOffset:= (ClientWidth - Image.Width + LeftBorder - RightBorder) div 2 -197 Offset.X := (ClientWidth - Image.Width + LeftBorder - RightBorder) div 2 - 182 198 BlackBorder; 183 yOffset:= ClientHeight - 2 * BlackBorder - Image.Height - BottomBorder;199 Offset.Y := ClientHeight - 2 * BlackBorder - Image.Height - BottomBorder; 184 200 end; 185 201 … … 190 206 begin 191 207 Dragging := True; 192 xDown := X; 193 yDown := Y; 208 Down := Point(X, Y); 194 209 end; 195 210 end; … … 206 221 if Dragging then 207 222 begin 208 xOffset := xOffset + X - xDown; 209 yOffset := yOffset + Y - yDown; 210 xDown := X; 211 yDown := Y; 212 213 if xOffset > LeftBorder then 214 xOffset := LeftBorder; 215 if xOffset < ClientWidth - 2 * BlackBorder - Image.Width - RightBorder then 216 xOffset := ClientWidth - 2 * BlackBorder - Image.Width - RightBorder; 217 if yOffset > TopBorder then 218 yOffset := TopBorder; 219 if yOffset < ClientHeight - 2 * BlackBorder - Image.Height - BottomBorder 220 then 221 yOffset := ClientHeight - 2 * BlackBorder - Image.Height - BottomBorder; 222 223 SmartInvalidate; 223 Move(Point(X - Down.X, Y - Down.Y)); 224 Down := Point(X, Y); 224 225 end; 225 226 end; … … 230 231 end; 231 232 233 procedure TTechTreeDlg.Move(Diff: TPoint); 234 begin 235 Offset := Offset + Diff; 236 237 if Offset.X > LeftBorder then 238 Offset.X := LeftBorder; 239 if Offset.X < ClientWidth - 2 * BlackBorder - Image.Width - RightBorder then 240 Offset.X := ClientWidth - 2 * BlackBorder - Image.Width - RightBorder; 241 if Offset.Y > TopBorder then 242 Offset.Y := TopBorder; 243 if Offset.Y < ClientHeight - 2 * BlackBorder - Image.Height - BottomBorder 244 then 245 Offset.Y := ClientHeight - 2 * BlackBorder - Image.Height - BottomBorder; 246 247 SmartInvalidate; 248 end; 249 232 250 end.
Note:
See TracChangeset
for help on using the changeset viewer.