11using System . Diagnostics ;
22using Intersect . Client . Core ;
33using Intersect . Client . Framework . Content ;
4- using Intersect . Client . Framework . File_Management ;
54using Intersect . Client . Framework . GenericClasses ;
65using Intersect . Client . Framework . Graphics ;
76using Intersect . Client . Framework . Gwen ;
1514using Intersect . Client . Interface . Debugging . Providers ;
1615using Intersect . Client . Localization ;
1716using Intersect . Client . Maps ;
18- using Intersect . Client . MonoGame . NativeInterop . OpenGL ;
1917using Intersect . Framework . Reflection ;
18+ using Intersect . Framework . SystemInformation ;
2019using Intersect . IO . Files ;
2120using static Intersect . Client . Framework . File_Management . GameContentManager ;
2221
@@ -59,9 +58,34 @@ public DebugWindow(Base parent) : base(parent, Strings.Debug.Title, false, nameo
5958 AssetsList = CreateAssetsList ( TabAssets . Page ) ;
6059 AssetsButtonReloadAsset = CreateAssetsButtonReloadAsset ( AssetsToolsTable , AssetsList ) ;
6160
62- TabGPU = Tabs . AddPage ( Strings . Debug . TabLabelGPU , nameof ( TabGPU ) ) ;
63- GPUStatisticsTable = CreateGPUStatisticsTable ( TabGPU . Page ) ;
64- GPUAllocationsTable = CreateGPUAllocationsTable ( TabGPU . Page ) ;
61+ TabSystem = Tabs . AddPage ( Strings . Debug . TabLabelSystem , nameof ( TabSystem ) ) ;
62+ _ = new Label ( TabSystem . Page , name : "HeaderSectionSystemStatistics" )
63+ {
64+ Dock = Pos . Top ,
65+ Font = _defaultFont ,
66+ Text = Strings . Debug . SectionSystemStatistics ,
67+ TextAlign = Pos . CenterH ,
68+ TextColorOverride = new Color ( r : 191 , g : 255 , b : 191 ) ,
69+ } ;
70+ SystemStatisticsTable = CreateSystemStatisticsTable ( TabSystem . Page ) ;
71+ _ = new Label ( TabSystem . Page , name : "HeaderSectionGPUStatistics" )
72+ {
73+ Dock = Pos . Top ,
74+ Font = _defaultFont ,
75+ Text = Strings . Debug . SectionGPUStatistics ,
76+ TextAlign = Pos . CenterH ,
77+ TextColorOverride = new Color ( r : 191 , g : 255 , b : 191 ) ,
78+ } ;
79+ GPUStatisticsTable = CreateGPUStatisticsTable ( TabSystem . Page ) ;
80+ _ = new Label ( TabSystem . Page , name : "HeaderSectionGPUAllocations" )
81+ {
82+ Dock = Pos . Top ,
83+ Font = _defaultFont ,
84+ Text = Strings . Debug . SectionGPUAllocations ,
85+ TextAlign = Pos . CenterH ,
86+ TextColorOverride = new Color ( r : 191 , g : 255 , b : 191 ) ,
87+ } ;
88+ GPUAllocationsTable = CreateGPUAllocationsTable ( TabSystem . Page ) ;
6589
6690 AssetsToolsTable . SizeToChildren ( ) ;
6791 }
@@ -76,6 +100,8 @@ protected override void Dispose(bool disposing)
76100
77101 private Table GPUStatisticsTable { get ; }
78102
103+ private Table SystemStatisticsTable { get ; }
104+
79105 private Table GPUAllocationsTable { get ; }
80106
81107 private Table CreateGPUAllocationsTable ( Base parent )
@@ -130,6 +156,11 @@ private Table CreateGPUAllocationsTable(Base parent)
130156 return table ;
131157 }
132158
159+ private static void ResizeTableHeightToChildrenOnSizeChanged ( Base sender , ValueChangedEventArgs < Point > args )
160+ {
161+ sender . SizeToChildren ( resizeX : false , resizeY : true , recursive : true ) ;
162+ }
163+
133164 private static void ResizeTableToChildrenOnSizeChanged ( Base sender , ValueChangedEventArgs < Point > args )
134165 {
135166 sender . SizeToChildren ( resizeX : args . Value . X > args . OldValue . X , resizeY : true , recursive : true ) ;
@@ -253,17 +284,17 @@ private static void CopyAssetNameToClipboardOnNameCellClicked(Base sender, Mouse
253284 return node ? . UserData is IGameTexture gameTexture ? gameTexture . Name : null ;
254285 }
255286
256-
257287 private Table CreateGPUStatisticsTable ( Base parent )
258288 {
259- ScrollControl gpuStatisticsScroller = new ( parent , nameof ( gpuStatisticsScroller ) )
289+ ScrollControl scroller = new ( parent , nameof ( scroller ) )
260290 {
261- Dock = Pos . Fill ,
291+ Dock = Pos . Top ,
292+ MinimumSize = new Point ( 0 , 100 ) ,
262293 } ;
263294
264- gpuStatisticsScroller . VerticalScrollBar . BaseNudgeAmount *= 2 ;
295+ scroller . VerticalScrollBar . BaseNudgeAmount *= 2 ;
265296
266- var table = new Table ( gpuStatisticsScroller , nameof ( GPUStatisticsTable ) )
297+ var table = new Table ( scroller , nameof ( SystemStatisticsTable ) )
267298 {
268299 AutoSizeToContentHeightOnChildResize = true ,
269300 AutoSizeToContentWidthOnChildResize = true ,
@@ -273,9 +304,16 @@ private Table CreateGPUStatisticsTable(Base parent)
273304 Dock = Pos . Fill ,
274305 Font = _defaultFont ,
275306 } ;
276- table . SizeChanged += ResizeTableToChildrenOnSizeChanged ;
307+ table . SizeChanged += ( sender , args ) =>
308+ {
309+ ResizeTableHeightToChildrenOnSizeChanged ( sender , args ) ;
310+ var minimumSize = new Point (
311+ 0 ,
312+ table . OuterHeight + scroller . InnerPanelPadding . Top + scroller . InnerPanelPadding . Bottom
313+ ) ;
314+ scroller . MinimumSize = minimumSize ;
315+ } ;
277316
278- _ = table . AddRow ( Strings . Debug . SectionGPUStatistics , columnCount : 2 , name : "SectionGPU" , columnIndex : 1 ) ;
279317 table . AddRow ( Strings . Debug . Fps , name : "FPSRow" ) . Listen ( 1 , new DelegateDataProvider < int > ( ( ) => Graphics . Renderer . Fps ) , NoValue ) ;
280318 // table.AddRow(Strings.Debug.Draws, name: "DrawsRow").Listen(1, new DelegateDataProvider<int>(() => Graphics.DrawCalls), NoValue);
281319
@@ -284,33 +322,54 @@ private Table CreateGPUStatisticsTable(Base parent)
284322 table . AddRow ( Strings . Debug . LightsDrawn , name : "LightsDrawnRow" ) . Listen ( 1 , new DelegateDataProvider < int > ( ( ) => Graphics . LightsDrawn ) , NoValue ) ;
285323 table . AddRow ( Strings . Debug . InterfaceObjects , name : "InterfaceObjectsRow" ) . Listen ( 1 , new DelegateDataProvider < int ? > ( ( ) => Interface . CurrentInterface ? . NodeCount , delayMilliseconds : 1000 ) , NoValue ) ;
286324
287-
288325 table . AddRow ( Strings . Debug . RenderTargetAllocations , name : "GPURenderTargetAllocations" ) . Listen ( 1 , new DelegateDataProvider < ulong > ( ( ) => Graphics . Renderer . RenderTargetAllocations ) , NoValue ) ;
289326 table . AddRow ( Strings . Debug . TextureAllocations , name : "GPUTextureAllocations" ) . Listen ( 1 , new DelegateDataProvider < ulong > ( ( ) => Graphics . Renderer . TextureAllocations ) , NoValue ) ;
290327 table . AddRow ( Strings . Debug . TextureCount , name : "GPUTextureCount" ) . Listen ( 1 , new DelegateDataProvider < ulong > ( ( ) => Graphics . Renderer . TextureCount ) , NoValue ) ;
291328
292- table . AddRow ( Strings . Debug . FreeVRAM , name : "GPUFreeVRAM" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( Graphics . Renderer . AvailableMemory ) ) , NoValue ) ;
293- table . AddRow ( Strings . Debug . TotalVRAM , name : "GPUTotalVRAM" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( Graphics . Renderer . TotalMemory ) ) , NoValue ) ;
329+ table . AddRow ( Strings . Debug . FreeVRAM , name : "GPUFreeVRAM" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( PlatformStatistics . AvailableGPUMemory ) ) , NoValue ) ;
330+ table . AddRow ( Strings . Debug . TotalVRAM , name : "GPUTotalVRAM" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( PlatformStatistics . TotalGPUMemory ) ) , NoValue ) ;
294331
295- table . AddRow ( Strings . Debug . RenderBufferVRAMFree , name : "GPUVRAMRenderBuffers" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( GL . AvailableRenderBufferMemory ) ) , NoValue ) ;
296- table . AddRow ( Strings . Debug . TextureVRAMFree , name : "GPUVRAMTextures" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( GL . AvailableTextureMemory ) ) , NoValue ) ;
297- table . AddRow ( Strings . Debug . VBOVRAMFree , name : "GPUVRAMVBOs" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( GL . AvailableVBOMemory ) ) , NoValue ) ;
332+ table . PreLayout . Enqueue ( t => t . SizeToChildren ( recursive : true ) , table ) ;
298333
299- var rows = table . Children . OfType < TableRow > ( ) . ToArray ( ) ;
300- foreach ( var row in rows )
334+ return table ;
335+ }
336+
337+ private Table CreateSystemStatisticsTable ( Base parent )
338+ {
339+ ScrollControl scroller = new ( parent , nameof ( scroller ) )
301340 {
302- if ( row . Name . StartsWith ( "Section" ) && row . GetCellContents ( 1 ) is Label titleLabel )
303- {
304- titleLabel . Padding = titleLabel . Padding with { Top = 8 } ;
305- }
341+ Dock = Pos . Top ,
342+ } ;
306343
307- if ( row . GetCellContents ( 0 ) is not Label label )
308- {
309- continue ;
310- }
344+ scroller . VerticalScrollBar . BaseNudgeAmount *= 2 ;
311345
312- label . TextAlign = Pos . Right | Pos . CenterV ;
313- }
346+ var table = new Table ( scroller , nameof ( SystemStatisticsTable ) )
347+ {
348+ AutoSizeToContentHeightOnChildResize = true ,
349+ AutoSizeToContentWidthOnChildResize = true ,
350+ CellSpacing = new Point ( 8 , 2 ) ,
351+ ColumnCount = 2 ,
352+ ColumnWidths = [ 180 , null ] ,
353+ Dock = Pos . Top ,
354+ Font = _defaultFont ,
355+ } ;
356+ table . SizeChanged += ( sender , args ) =>
357+ {
358+ ResizeTableHeightToChildrenOnSizeChanged ( sender , args ) ;
359+ var minimumSize = new Point (
360+ 0 ,
361+ table . OuterHeight + scroller . InnerPanelPadding . Top + scroller . InnerPanelPadding . Bottom
362+ ) ;
363+ scroller . MinimumSize = minimumSize ;
364+ } ;
365+
366+ table . AddRow ( Strings . Debug . FreeVirtualRAM , name : "RAMFreeVirtual" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( PlatformStatistics . AvailableSystemMemory ) ) , NoValue ) ;
367+ table . AddRow ( Strings . Debug . TotalVirtualRAM , name : "RAMTotalVirtual" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( PlatformStatistics . TotalSystemMemory ) ) , NoValue ) ;
368+
369+ table . AddRow ( Strings . Debug . FreePhysicalRAM , name : "RAMFreePhysical" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( PlatformStatistics . AvailablePhysicalMemory ) ) , NoValue ) ;
370+ table . AddRow ( Strings . Debug . TotalPhysicalRAM , name : "RAMTotalPhysical" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( PlatformStatistics . TotalPhysicalMemory ) ) , NoValue ) ;
371+
372+ table . PreLayout . Enqueue ( t => t . SizeToChildren ( recursive : true ) , table ) ;
314373
315374 return table ;
316375 }
@@ -400,7 +459,7 @@ private void AssetListOnSelectionChanged(Base @base, EventArgs eventArgs)
400459
401460 private TabButton TabAssets { get ; }
402461
403- private TabButton TabGPU { get ; }
462+ private TabButton TabSystem { get ; }
404463
405464 private SearchableTree AssetsList { get ; }
406465
@@ -424,9 +483,6 @@ private void AssetListOnSelectionChanged(Base @base, EventArgs eventArgs)
424483
425484 protected override void EnsureInitialized ( )
426485 {
427- TableDebugStats . SizeToChildren ( ) ;
428-
429- // LoadJsonUi(UI.Debug, Graphics.Renderer?.GetResolutionString());
430486 }
431487
432488 protected override void OnAttached ( Base parent )
@@ -677,20 +733,30 @@ private Table CreateInfoTableDebugStats(Base parent)
677733 table . AddRow ( Strings . Debug . LightsDrawn , name : "LightsDrawnRow" ) . Listen ( 1 , new DelegateDataProvider < int > ( ( ) => Graphics . LightsDrawn ) , NoValue ) ;
678734 table . AddRow ( Strings . Debug . InterfaceObjects , name : "InterfaceObjectsRow" ) . Listen ( 1 , new DelegateDataProvider < int ? > ( ( ) => Interface . CurrentInterface ? . NodeCount , delayMilliseconds : 1000 ) , NoValue ) ;
679735
680- _ = table . AddRow ( Strings . Debug . SectionGPUStatistics , columnCount : 2 , name : "SectionGPU" , columnIndex : 1 ) ;
736+ var rowSectionGPU = table . AddRow ( Strings . Debug . SectionGPUStatistics , columnCount : 2 , name : "SectionGPU" , columnIndex : 0 ) ;
737+ if ( rowSectionGPU . GetCellContents ( 0 ) is Label labelSectionGPU )
738+ {
739+ labelSectionGPU . TextColorOverride = new Color ( r : 191 , g : 255 , b : 191 ) ;
740+ }
681741
682742 table . AddRow ( Strings . Debug . RenderTargetAllocations , name : "GPURenderTargetAllocations" ) . Listen ( 1 , new DelegateDataProvider < ulong > ( ( ) => Graphics . Renderer . RenderTargetAllocations ) , NoValue ) ;
683743 table . AddRow ( Strings . Debug . TextureAllocations , name : "GPUTextureAllocations" ) . Listen ( 1 , new DelegateDataProvider < ulong > ( ( ) => Graphics . Renderer . TextureAllocations ) , NoValue ) ;
684744 table . AddRow ( Strings . Debug . TextureCount , name : "GPUTextureCount" ) . Listen ( 1 , new DelegateDataProvider < ulong > ( ( ) => Graphics . Renderer . TextureCount ) , NoValue ) ;
685745
686- table . AddRow ( Strings . Debug . FreeVRAM , name : "GPUFreeVRAM" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( Graphics . Renderer . AvailableMemory ) ) , NoValue ) ;
687- table . AddRow ( Strings . Debug . TotalVRAM , name : "GPUTotalVRAM" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( Graphics . Renderer . TotalMemory ) ) , NoValue ) ;
746+ table . AddRow ( Strings . Debug . FreeVRAM , name : "GPUFreeVRAM" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( PlatformStatistics . AvailableGPUMemory ) ) , NoValue ) ;
747+ table . AddRow ( Strings . Debug . TotalVRAM , name : "GPUTotalVRAM" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( PlatformStatistics . TotalGPUMemory ) ) , NoValue ) ;
688748
689- table . AddRow ( Strings . Debug . RenderBufferVRAMFree , name : "GPUVRAMRenderBuffers" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( GL . AvailableRenderBufferMemory ) ) , NoValue ) ;
690- table . AddRow ( Strings . Debug . TextureVRAMFree , name : "GPUVRAMTextures" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( GL . AvailableTextureMemory ) ) , NoValue ) ;
691- table . AddRow ( Strings . Debug . VBOVRAMFree , name : "GPUVRAMVBOs" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( GL . AvailableVBOMemory ) ) , NoValue ) ;
749+ table . AddRow ( Strings . Debug . FreeVirtualRAM , name : "RAMFreeVirtual" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( PlatformStatistics . AvailableSystemMemory ) ) , NoValue ) ;
750+ table . AddRow ( Strings . Debug . TotalVirtualRAM , name : "RAMTotalVirtual" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( PlatformStatistics . TotalSystemMemory ) ) , NoValue ) ;
692751
693- // _ = table.AddRow(Strings.Debug.ControlUnderCursor, columnCount: 2, name: "SectionUI", columnIndex: 1);
752+ table . AddRow ( Strings . Debug . FreePhysicalRAM , name : "RAMFreePhysical" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( PlatformStatistics . AvailablePhysicalMemory ) ) , NoValue ) ;
753+ table . AddRow ( Strings . Debug . TotalPhysicalRAM , name : "RAMTotalPhysical" ) . Listen ( 1 , new DelegateDataProvider < string > ( ( ) => FileSystemHelper . FormatSize ( PlatformStatistics . TotalPhysicalMemory ) ) , NoValue ) ;
754+
755+ var rowSectionUI = table . AddRow ( Strings . Debug . ControlUnderCursor , columnCount : 2 , name : "SectionUI" , columnIndex : 0 ) ;
756+ if ( rowSectionUI . GetCellContents ( 0 ) is Label labelSectionUI )
757+ {
758+ labelSectionUI . TextColorOverride = new Color ( r : 191 , g : 255 , b : 191 ) ;
759+ }
694760
695761 table . AddRow ( Strings . Internals . Type , name : "TypeRow" ) . Listen ( 1 , _nodeUnderCursorProvider , ( node , _ ) => node ? . GetType ( ) . GetName ( ) , Strings . Internals . NotApplicable ) ;
696762 table . AddRow ( Strings . Internals . Name , name : "NameRow" ) . Listen ( 1 , _nodeUnderCursorProvider , ( node , _ ) => node ? . ParentQualifiedName , NoValue ) ;
0 commit comments