1+ using System . Diagnostics ;
12using Intersect . Async ;
23using Intersect . Client . Core ;
34using Intersect . Client . Framework . Content ;
5+ using Intersect . Client . Framework . GenericClasses ;
46using Intersect . Client . Framework . Graphics ;
57using Intersect . Client . Framework . Gwen ;
68using Intersect . Client . Framework . Gwen . Control ;
79using Intersect . Client . Framework . Gwen . Control . Data ;
810using Intersect . Client . Framework . Gwen . Control . Layout ;
911using Intersect . Client . Framework . Gwen . Control . Utility ;
12+ using Intersect . Client . Framework . Input ;
1013using Intersect . Client . General ;
1114using Intersect . Client . Localization ;
1215using Intersect . Client . Maps ;
@@ -21,6 +24,7 @@ internal sealed partial class DebugWindow : Window
2124 private readonly GameFont ? _defaultFont ;
2225 private bool _wasParentDrawDebugOutlinesEnabled ;
2326 private bool _drawDebugOutlinesEnabled ;
27+ private bool _viewClickedNodeInDebugger ;
2428 private ComponentStateFilters _componentStateFilters = ComponentStateFilters . IncludeMouseInputDisabled ;
2529
2630 public DebugWindow ( Base parent ) : base ( parent , Strings . Debug . Title , false , nameof ( DebugWindow ) )
@@ -42,6 +46,7 @@ public DebugWindow(Base parent) : base(parent, Strings.Debug.Title, false, nameo
4246 CheckboxDrawDebugOutlines = CreateInfoCheckboxDrawDebugOutlines ( TabInfo . Page ) ;
4347 CheckboxEnableLayoutHotReloading = CreateInfoCheckboxEnableLayoutHotReloading ( TabInfo . Page ) ;
4448 CheckboxIncludeTextNodesInHover = CreateInfoCheckboxIncludeTextNodesInHover ( TabInfo . Page ) ;
49+ CheckboxViewClickedComponentInDebugger = CreateInfoCheckboxViewClickedNodeInDebugger ( TabInfo . Page ) ;
4550 ButtonShutdownServer = CreateInfoButtonShutdownServer ( TabInfo . Page ) ;
4651 ButtonShutdownServerAndExit = CreateInfoButtonShutdownServerAndExit ( TabInfo . Page ) ;
4752 TableDebugStats = CreateInfoTableDebugStats ( TabInfo . Page ) ;
@@ -147,6 +152,8 @@ private Button CreateAssetsButtonReloadAsset(Table table, SearchableTree assetLi
147152
148153 private LabeledCheckBox CheckboxIncludeTextNodesInHover { get ; }
149154
155+ private LabeledCheckBox CheckboxViewClickedComponentInDebugger { get ; }
156+
150157 private Button ButtonShutdownServer { get ; }
151158
152159 private Button ButtonShutdownServerAndExit { get ; }
@@ -273,6 +280,68 @@ private LabeledCheckBox CreateInfoCheckboxIncludeTextNodesInHover(Base parent)
273280 return checkbox ;
274281 }
275282
283+ private LabeledCheckBox CreateInfoCheckboxViewClickedNodeInDebugger ( Base parent )
284+ {
285+ var checkbox = new LabeledCheckBox ( parent , nameof ( CheckboxViewClickedComponentInDebugger ) )
286+ {
287+ Dock = Pos . Top ,
288+ Font = _defaultFont ,
289+ IsChecked = _viewClickedNodeInDebugger ,
290+ Text = Strings . Debug . ViewClickedNodeInDebugger ,
291+ } ;
292+
293+ checkbox . CheckChanged += ( _ , _ ) =>
294+ {
295+ _viewClickedNodeInDebugger = ! _viewClickedNodeInDebugger ;
296+ if ( _viewClickedNodeInDebugger )
297+ {
298+ AddIntercepts ( ) ;
299+ }
300+ else
301+ {
302+ RemoveIntercepts ( ) ;
303+ }
304+ } ;
305+
306+ return checkbox ;
307+ }
308+
309+ private void AddIntercepts ( )
310+ {
311+ Input . MouseDownIntercept += MouseDownIntercept ;
312+ Input . MouseUpIntercept += MouseUpIntercept ;
313+ }
314+
315+ private void RemoveIntercepts ( )
316+ {
317+ Input . MouseDownIntercept -= MouseDownIntercept ;
318+ Input . MouseUpIntercept -= MouseUpIntercept ;
319+ }
320+
321+ private bool MouseDownIntercept ( Keys modifier , MouseButton mouseButton )
322+ {
323+ if ( IsVisible && _viewClickedNodeInDebugger )
324+ {
325+ return true ;
326+ }
327+
328+ RemoveIntercepts ( ) ;
329+ return false ;
330+ }
331+
332+ private bool MouseUpIntercept ( Keys modifier , MouseButton mouseButton )
333+ {
334+ if ( ! IsVisible || ! _viewClickedNodeInDebugger )
335+ {
336+ RemoveIntercepts ( ) ;
337+ return false ;
338+ }
339+
340+ var node = GetNodeUnderCursor ( ) ;
341+ Debugger . Break ( ) ;
342+ return true ;
343+ }
344+
276345 private Button CreateInfoButtonShutdownServer ( Base parent )
277346 {
278347 var button = new Button ( parent , nameof ( ButtonShutdownServer ) )
@@ -452,6 +521,8 @@ private Table CreateInfoTableDebugStats(Base parent)
452521 return table ;
453522 }
454523
524+ private Base ? GetNodeUnderCursor ( ) => Interface . FindComponentUnderCursor ( _componentStateFilters ) ;
525+
455526 private partial class ControlUnderCursorProvider : ITableDataProvider
456527 {
457528 private readonly DebugWindow _owner ;
@@ -494,7 +565,7 @@ private async Task WaitForOwnerVisible(CancellationToken cancellationToken)
494565 cancellationToken . ThrowIfCancellationRequested ( ) ;
495566 }
496567
497- private Base ? CreateValue ( Task _ ) => Interface . FindComponentUnderCursor ( _owner . _componentStateFilters ) ;
568+ private Base ? CreateValue ( Task _ ) => _owner . GetNodeUnderCursor ( ) ;
498569
499570 private void HandleValue ( Base ? component )
500571 {
0 commit comments