diff --git a/Editor/App/ProgramWindows.cs b/Editor/App/ProgramWindows.cs index 013b7e221..dd37a2c89 100644 --- a/Editor/App/ProgramWindows.cs +++ b/Editor/App/ProgramWindows.cs @@ -21,6 +21,7 @@ internal static class ProgramWindows private static Device _device; private static DeviceContext _deviceContext; private static Factory _factory; + public static string ActiveGpu { get; private set; } = "Unknown"; internal static void SetMainWindowSize(int width, int height) { @@ -74,7 +75,7 @@ internal static void InitializeMainWindow(string version, out Device device) "Ok... /:"); Environment.Exit(0); } - + var adapterFound = false; for (var i = 0; i < factory.GetAdapterCount(); i++) { @@ -112,16 +113,17 @@ internal static void InitializeMainWindow(string version, out Device device) if (adapterFound) break; } - + // Fallback logic remains the same if (selectedAdapterIndex == -1) { selectedAdapterIndex = 0; Log.Info("Falling back to first available adapter"); } - + var selectedAdapter = factory.GetAdapter1(selectedAdapterIndex); - + ActiveGpu = selectedAdapter.Description.Description; + // Create Device and SwapChain with the selected adapter Device.CreateWithSwapChain(selectedAdapter, // Pass the selected adapter DeviceCreationFlags.Debug, @@ -305,18 +307,18 @@ public static void RebuildUiCopyTextureIfRequired() // Create a shader resource-compatible texture var textureDesc = new Texture2DDescription - { - Width = Main.SwapChain.Description.ModeDescription.Width, - Height = Main.SwapChain.Description.ModeDescription.Height, - MipLevels = 1, - ArraySize = 1, - Format = Main.SwapChain.Description.ModeDescription.Format, - SampleDescription = new SampleDescription(1, 0), - Usage = ResourceUsage.Default, - BindFlags = BindFlags.ShaderResource, - CpuAccessFlags = CpuAccessFlags.None, - OptionFlags = ResourceOptionFlags.None - }; + { + Width = Main.SwapChain.Description.ModeDescription.Width, + Height = Main.SwapChain.Description.ModeDescription.Height, + MipLevels = 1, + ArraySize = 1, + Format = Main.SwapChain.Description.ModeDescription.Format, + SampleDescription = new SampleDescription(1, 0), + Usage = ResourceUsage.Default, + BindFlags = BindFlags.ShaderResource, + CpuAccessFlags = CpuAccessFlags.None, + OptionFlags = ResourceOptionFlags.None + }; if (_uiCopyTexture is { IsDisposed: false }) _uiCopyTexture.Dispose(); diff --git a/Editor/Gui/Dialog/AboutDialog.cs b/Editor/Gui/Dialog/AboutDialog.cs index b285d4214..2ddae5c1e 100644 --- a/Editor/Gui/Dialog/AboutDialog.cs +++ b/Editor/Gui/Dialog/AboutDialog.cs @@ -7,6 +7,9 @@ using ImGuiNET; using T3.Editor.Gui.Styling; using T3.Editor.Gui.UiHelpers; +using T3.Editor.App; +using System.Windows.Forms; + namespace T3.Editor.Gui.Dialog; @@ -19,22 +22,58 @@ internal void Draw() if (BeginDialog("About TiXL")) { FormInputs.AddSectionHeader("TiXL"); - ImGui.TextColored(new Vector4(1.0f, 0.2f, 0.55f, 1.0f), "v " + Program.VersionText); - FormInputs.AddVerticalSpace(5); + ImGui.SameLine(); + ImGui.PushStyleColor(ImGuiCol.Text, UiColors.TextMuted.Rgba); + + FormInputs.AddSectionHeader("v." + Program.VersionText); + ImGui.PopStyleColor(); + ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, mySpacing); + ImGui.TextColored(UiColors.TextMuted, $"{dateTime}"); +#if DEBUG + ImGui.TextColored(UiColors.TextMuted, "IDE:"); + ImGui.SameLine(); + ImGui.Text($"{ideName}"); +#endif + + ImGui.TextColored(UiColors.TextMuted, $"App language:"); + ImGui.SameLine(); + ImGui.Text($"{appLanguage}"); + ImGui.PopStyleVar(); + FormInputs.AddVerticalSpace(1); ImGui.Separator(); FormInputs.AddSectionHeader("System Information"); - if (string.IsNullOrEmpty(_systemInfo)) - { - UpdateSystemInfo(); // Populate system info if not already done - } - - FormInputs.AddVerticalSpace(5); - ImGui.TextWrapped(_systemInfo); - FormInputs.AddVerticalSpace(5); + //FormInputs.AddVerticalSpace(0); + ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, mySpacing); + ImGui.TextColored(UiColors.TextMuted, "OS:" ); + ImGui.SameLine(); + ImGui.Text($"{operatingSystemInfo}"); + ImGui.TextColored(UiColors.TextMuted, "System language:"); + ImGui.SameLine(); + ImGui.Text($"{systemLanguage}"); + ImGui.TextColored(UiColors.TextMuted, "Keyboard layout:"); + ImGui.SameLine(); + ImGui.Text($"{keyboardLayout}"); + FormInputs.AddVerticalSpace(8); + ImGui.TextColored(UiColors.TextMuted, ".NET Runtime:"); + ImGui.SameLine(); + ImGui.Text($"{dotNetRuntime}"); + ImGui.TextColored(UiColors.TextMuted, ".NET SDK:"); + ImGui.SameLine(); + ImGui.Text($"{dotNetSdk}"); + + FormInputs.AddVerticalSpace(8); + + ImGui.TextColored(UiColors.TextMuted, "Graphics processing unit(s):"); + ImGui.Text($"{gpuInformation}"); + FormInputs.AddVerticalSpace(8); + ImGui.Separator(); + ImGui.PopStyleVar(); + + FormInputs.AddVerticalSpace(5); if (ImGui.Button("Copy System Information")) { UpdateSystemInfo(); // Update system info and copy to clipboard @@ -61,11 +100,15 @@ private void UpdateSystemInfo() { var systemInfo = new StringBuilder(); - systemInfo.AppendLine($"Date: {DateTime.Now}"); + systemInfo.AppendLine($"{dateTime}"); systemInfo.AppendLine($"TiXL version: {Program.VersionText}"); - systemInfo.AppendLine($"Language: {GetAppLanguage()}"); + #if DEBUG + systemInfo.AppendLine($"IDE: {GetIdeName()}"); + #endif + systemInfo.AppendLine($"App language: {GetAppLanguage()}"); systemInfo.AppendLine($"OS: {GetOperatingSystemInfo()}"); systemInfo.AppendLine($"System language: {GetSystemLanguage()}"); + systemInfo.AppendLine($"Keyboard Layout: {GetKeyboardLayout()}"); systemInfo.AppendLine($".NET runtime: {GetDotNetRuntimeVersion()}"); systemInfo.AppendLine($".NET SDK: {GetDotNetSdkVersion()}"); systemInfo.AppendLine($"GPU: {GetGpuInformation()}"); @@ -91,7 +134,20 @@ private static string GetSystemLanguage() try { var currentCulture = CultureInfo.CurrentUICulture; - return $"{currentCulture.EnglishName}\nKeyboard layout:{currentCulture.KeyboardLayoutId} ({currentCulture.Parent}) "; + return currentCulture.EnglishName; + } + catch (Exception) + { + return "Unknown"; + } + } + + private static string GetKeyboardLayout() + { + try + { + var currentInputLanguage = InputLanguage.CurrentInputLanguage; + return $"{currentInputLanguage.Culture.Name}"; } catch (Exception) { @@ -145,23 +201,31 @@ private static string GetDotNetSdkVersion() return "Not found"; } - private static string GetGpuInformation() + private static string GetGpuInformation(string infoType = "both") { var gpuList = new List(); + var activeGpu = ProgramWindows.ActiveGpu; try { using (var searcher = new ManagementObjectSearcher("SELECT * FROM Win32_VideoController")) { - - foreach (var searchResult in searcher.Get()) + foreach (ManagementObject obj in searcher.Get()) { - if (searchResult is not ManagementObject obj) - continue; var name = obj["Name"]?.ToString() ?? "Unknown"; + if (name == activeGpu) + name += " (Active)"; + var driverVersion = obj["DriverVersion"]?.ToString() ?? "Unknown"; - var gpuDetails = $"{name}\nDriver version: {driverVersion}"; + + string gpuDetails = infoType.ToLower() switch + { + "name" => name, + "driver" => driverVersion, + _ => $"{name}\nDriver version: {driverVersion}" // Default/both case + }; + gpuList.Add(gpuDetails); } } @@ -175,8 +239,58 @@ private static string GetGpuInformation() return "Unknown"; } - + + private static string GetIdeName() + { + try + { + // Get the current process + var currentProcess = Process.GetCurrentProcess(); + + // Use WMI to find the parent process + var query = $"SELECT ParentProcessId FROM Win32_Process WHERE ProcessId = {currentProcess.Id}"; + using var searcher = new ManagementObjectSearcher(query); + var result = searcher.Get().Cast().FirstOrDefault(); + + if (result != null) + { + var parentProcessId = Convert.ToInt32(result["ParentProcessId"]); + using var parentProcess = Process.GetProcessById(parentProcessId); + var processName = parentProcess.ProcessName.ToLower(); + + // Map common IDE process names to user-friendly names + return processName switch + { + "devenv" => "Visual Studio", + "vsdebugconsole" => "Visual Studio", + "rider64" => "JetBrains Rider", + "vshost" => "Visual Studio (Debug Host)", + "msvsmon" => "Visual Studio Remote Debugger", + _ => parentProcess.ProcessName // Fallback to the raw process name + }; + } + } + catch (Exception e) + { + Log.Warning($"Failed to get IDE name: {e.Message}"); + } + + return "Unknown"; + } + private static readonly string ideName = GetIdeName(); + private static readonly string appLanguage = GetAppLanguage(); + private static readonly string dateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + + private static readonly string operatingSystemInfo = GetOperatingSystemInfo(); + private static readonly string systemLanguage = GetSystemLanguage(); + private static readonly string keyboardLayout = GetKeyboardLayout(); + private static readonly string dotNetRuntime = GetDotNetRuntimeVersion(); + private static readonly string dotNetSdk = GetDotNetSdkVersion(); + private static readonly string gpuInformation = GetGpuInformation(); + private string _systemInfo = string.Empty; + private static readonly Vector2 mySpacing = new (6.0f, 3.0f); + } \ No newline at end of file