- Timestamp:
- May 17, 2024, 9:21:22 AM (7 months ago)
- Location:
- trunk/LocalPlayer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/TechTree.lfm
r575 r576 1 1 object TechTreeDlg: TTechTreeDlg 2 Cursor = 3 2 3 Left = 1162 4 Height = 482 5 Top = 481 3 6 Width = 611 4 Top = 4815 Height = 4826 Cursor = 37 7 BorderIcons = [] 8 8 BorderStyle = bsNone … … 19 19 Position = poDefault 20 20 Scaled = False 21 OnClose = FormClose 21 22 OnCreate = FormCreate 22 23 OnDestroy = FormDestroy 24 OnKeyDown = FormKeyDown 23 25 OnKeyUp = FormKeyUp 24 26 OnMouseDown = FormMouseDown … … 30 32 TextHeight = 16 31 33 object CloseBtn: TButtonB 34 Cursor = crArrow 32 35 Left = 568 36 Height = 25 33 37 Top = 16 34 38 Width = 25 35 Height = 2536 Cursor = crArrow37 39 Down = False 38 40 Permanent = False … … 40 42 ButtonIndex = 0 41 43 end 44 object TimerKeyPressed: TTimer 45 Enabled = False 46 Interval = 250 47 OnTimer = TimerKeyPressedTimer 48 Left = 177 49 Top = 180 50 end 42 51 end -
trunk/LocalPlayer/TechTree.pas
r575 r576 7 7 ScreenTools, LCLIntf, LCLType, SysUtils, Classes, ButtonB, DrawDlg, 8 8 {$IFDEF DPI}Dpi.Graphics, Dpi.Controls, Dpi.Forms{$ELSE} 9 Graphics, Controls, Forms{$ENDIF} ;9 Graphics, Controls, Forms{$ENDIF}, Controls, ExtCtrls, Forms; 10 10 11 11 type … … 15 15 TTechTreeDlg = class(TDrawDlg) 16 16 CloseBtn: TButtonB; 17 TimerKeyPressed: TTimer; 18 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 17 19 procedure FormCreate(Sender: TObject); 18 20 procedure FormDestroy(Sender: TObject); 21 procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 19 22 procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); 20 23 procedure FormPaint(Sender: TObject); … … 26 29 procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); 27 30 procedure CloseBtnClick(Sender: TObject); 31 procedure TimerKeyPressedTimer(Sender: TObject); 28 32 private 29 33 Offset: TPoint; … … 31 35 Image: TBitmap; 32 36 Dragging: Boolean; 37 LeftPressed: Boolean; 38 RightPressed: Boolean; 39 UpPressed: Boolean; 40 DownPressed: Boolean; 33 41 procedure Move(Diff: TPoint); 34 42 end; … … 58 66 function Min(A, B: Integer): Integer; 59 67 begin 60 if A < B then 61 Result := A 62 else 63 Result := B; 68 if A < B then Result := A 69 else Result := B; 64 70 end; 65 71 66 72 function Max(A, B: Integer): Integer; 67 73 begin 68 if A > B then 69 Result := A 70 else 71 Result := B; 74 if A > B then Result := A 75 else Result := B; 72 76 end; 73 77 … … 78 82 end; 79 83 84 procedure TTechTreeDlg.FormClose(Sender: TObject; var CloseAction: TCloseAction 85 ); 86 begin 87 TimerKeyPressed.Enabled := False; 88 RightPressed := False; 89 DownPressed := False; 90 LeftPressed := False; 91 UpPressed := False; 92 end; 93 80 94 procedure TTechTreeDlg.FormDestroy(Sender: TObject); 81 95 begin 82 96 FreeAndNil(Image); 97 end; 98 99 procedure TTechTreeDlg.FormKeyDown(Sender: TObject; var Key: Word; 100 Shift: TShiftState); 101 begin 102 case Key of 103 37: RightPressed := True; 104 38: DownPressed := True; 105 39: LeftPressed := True; 106 40: UpPressed := True; 107 end; 108 TimerKeyPressedTimer(nil); 109 TimerKeyPressed.Enabled := RightPressed or DownPressed or LeftPressed or UpPressed; 83 110 end; 84 111 85 112 procedure TTechTreeDlg.FormKeyUp(Sender: TObject; var Key: Word; 86 113 Shift: TShiftState); 87 const88 Diff = 50;89 114 begin 90 115 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; 116 37: RightPressed := False; 117 38: DownPressed := False; 118 39: LeftPressed := False; 119 40: UpPressed := False; 120 end; 121 TimerKeyPressed.Enabled := RightPressed or DownPressed or LeftPressed or UpPressed; 96 122 end; 97 123 … … 188 214 189 215 // Fit window to image, center image in window, center window to screen 190 NewWidth := Min(Screen.Width - 40, Image.Width + LeftBorder + RightBorder + 2 * BlackBorder); 191 NewHeight := Min(Screen.Height - 40, Image.Height + TopBorder + BottomBorder + 2 * BlackBorder); 216 NewWidth := Min(Screen.Width - 40, Image.Width + LeftBorder + RightBorder + 217 2 * BlackBorder); 218 NewHeight := Min(Screen.Height - 40, Image.Height + TopBorder + BottomBorder + 219 2 * BlackBorder); 192 220 BoundsRect := Bounds((Screen.Width - NewWidth) div 2, 193 (Screen.Height - NewHeight) div 2, 194 NewWidth, NewHeight); 221 (Screen.Height - NewHeight) div 2, NewWidth, NewHeight); 195 222 CloseBtn.Left := Width - CloseBtn.Width - BlackBorder - 8; 196 223 CloseBtn.Top := BlackBorder + 8; … … 229 256 begin 230 257 Close; 258 end; 259 260 procedure TTechTreeDlg.TimerKeyPressedTimer(Sender: TObject); 261 const 262 Diff = 50; 263 var 264 Change: TPoint; 265 begin 266 Change := Point(0, 0); 267 if RightPressed then Change.X := Change.X + Diff; 268 if LeftPressed then Change.X := Change.X - Diff; 269 if DownPressed then Change.Y := Change.Y + Diff; 270 if UpPressed then Change.Y := Change.Y - Diff; 271 272 if (Change.X <> 0) or (Change.Y <> 0) then Move(Change); 231 273 end; 232 274 … … 241 283 if Offset.Y > TopBorder then 242 284 Offset.Y := TopBorder; 243 if Offset.Y < ClientHeight - 2 * BlackBorder - Image.Height - BottomBorder 244 then 285 if Offset.Y < ClientHeight - 2 * BlackBorder - Image.Height - BottomBorder then 245 286 Offset.Y := ClientHeight - 2 * BlackBorder - Image.Height - BottomBorder; 246 287
Note:
See TracChangeset
for help on using the changeset viewer.