Skip to content

Commit 7d9a5a6

Browse files
committed
Merge branch 'featureMain/AboutDialog'
2 parents 4884809 + a39feb7 commit 7d9a5a6

File tree

2 files changed

+152
-36
lines changed

2 files changed

+152
-36
lines changed

Editor/App/ProgramWindows.cs

+18-16
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ internal static class ProgramWindows
2121
private static Device _device;
2222
private static DeviceContext _deviceContext;
2323
private static Factory _factory;
24+
public static string ActiveGpu { get; private set; } = "Unknown";
2425

2526
internal static void SetMainWindowSize(int width, int height)
2627
{
@@ -74,7 +75,7 @@ internal static void InitializeMainWindow(string version, out Device device)
7475
"Ok... /:");
7576
Environment.Exit(0);
7677
}
77-
78+
7879
var adapterFound = false;
7980
for (var i = 0; i < factory.GetAdapterCount(); i++)
8081
{
@@ -112,16 +113,17 @@ internal static void InitializeMainWindow(string version, out Device device)
112113
if (adapterFound)
113114
break;
114115
}
115-
116+
116117
// Fallback logic remains the same
117118
if (selectedAdapterIndex == -1)
118119
{
119120
selectedAdapterIndex = 0;
120121
Log.Info("Falling back to first available adapter");
121122
}
122-
123+
123124
var selectedAdapter = factory.GetAdapter1(selectedAdapterIndex);
124-
125+
ActiveGpu = selectedAdapter.Description.Description;
126+
125127
// Create Device and SwapChain with the selected adapter
126128
Device.CreateWithSwapChain(selectedAdapter, // Pass the selected adapter
127129
DeviceCreationFlags.Debug,
@@ -305,18 +307,18 @@ public static void RebuildUiCopyTextureIfRequired()
305307

306308
// Create a shader resource-compatible texture
307309
var textureDesc = new Texture2DDescription
308-
{
309-
Width = Main.SwapChain.Description.ModeDescription.Width,
310-
Height = Main.SwapChain.Description.ModeDescription.Height,
311-
MipLevels = 1,
312-
ArraySize = 1,
313-
Format = Main.SwapChain.Description.ModeDescription.Format,
314-
SampleDescription = new SampleDescription(1, 0),
315-
Usage = ResourceUsage.Default,
316-
BindFlags = BindFlags.ShaderResource,
317-
CpuAccessFlags = CpuAccessFlags.None,
318-
OptionFlags = ResourceOptionFlags.None
319-
};
310+
{
311+
Width = Main.SwapChain.Description.ModeDescription.Width,
312+
Height = Main.SwapChain.Description.ModeDescription.Height,
313+
MipLevels = 1,
314+
ArraySize = 1,
315+
Format = Main.SwapChain.Description.ModeDescription.Format,
316+
SampleDescription = new SampleDescription(1, 0),
317+
Usage = ResourceUsage.Default,
318+
BindFlags = BindFlags.ShaderResource,
319+
CpuAccessFlags = CpuAccessFlags.None,
320+
OptionFlags = ResourceOptionFlags.None
321+
};
320322

321323
if (_uiCopyTexture is { IsDisposed: false })
322324
_uiCopyTexture.Dispose();

Editor/Gui/Dialog/AboutDialog.cs

+134-20
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
using ImGuiNET;
88
using T3.Editor.Gui.Styling;
99
using T3.Editor.Gui.UiHelpers;
10+
using T3.Editor.App;
11+
using System.Windows.Forms;
12+
1013

1114
namespace T3.Editor.Gui.Dialog;
1215

@@ -19,22 +22,58 @@ internal void Draw()
1922
if (BeginDialog("About TiXL"))
2023
{
2124
FormInputs.AddSectionHeader("TiXL");
22-
ImGui.TextColored(new Vector4(1.0f, 0.2f, 0.55f, 1.0f), "v " + Program.VersionText);
23-
FormInputs.AddVerticalSpace(5);
25+
ImGui.SameLine();
26+
ImGui.PushStyleColor(ImGuiCol.Text, UiColors.TextMuted.Rgba);
27+
28+
FormInputs.AddSectionHeader("v." + Program.VersionText);
29+
ImGui.PopStyleColor();
30+
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, mySpacing);
31+
ImGui.TextColored(UiColors.TextMuted, $"{dateTime}");
32+
#if DEBUG
33+
ImGui.TextColored(UiColors.TextMuted, "IDE:");
34+
ImGui.SameLine();
35+
ImGui.Text($"{ideName}");
36+
#endif
37+
38+
ImGui.TextColored(UiColors.TextMuted, $"App language:");
39+
ImGui.SameLine();
40+
ImGui.Text($"{appLanguage}");
41+
ImGui.PopStyleVar();
42+
FormInputs.AddVerticalSpace(1);
2443
ImGui.Separator();
2544

2645
FormInputs.AddSectionHeader("System Information");
2746

28-
if (string.IsNullOrEmpty(_systemInfo))
29-
{
30-
UpdateSystemInfo(); // Populate system info if not already done
31-
}
32-
33-
FormInputs.AddVerticalSpace(5);
34-
ImGui.TextWrapped(_systemInfo);
35-
FormInputs.AddVerticalSpace(5);
47+
//FormInputs.AddVerticalSpace(0);
48+
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, mySpacing);
49+
ImGui.TextColored(UiColors.TextMuted, "OS:" );
50+
ImGui.SameLine();
51+
ImGui.Text($"{operatingSystemInfo}");
52+
ImGui.TextColored(UiColors.TextMuted, "System language:");
53+
ImGui.SameLine();
54+
ImGui.Text($"{systemLanguage}");
55+
ImGui.TextColored(UiColors.TextMuted, "Keyboard layout:");
56+
ImGui.SameLine();
57+
ImGui.Text($"{keyboardLayout}");
3658

59+
FormInputs.AddVerticalSpace(8);
3760

61+
ImGui.TextColored(UiColors.TextMuted, ".NET Runtime:");
62+
ImGui.SameLine();
63+
ImGui.Text($"{dotNetRuntime}");
64+
ImGui.TextColored(UiColors.TextMuted, ".NET SDK:");
65+
ImGui.SameLine();
66+
ImGui.Text($"{dotNetSdk}");
67+
68+
FormInputs.AddVerticalSpace(8);
69+
70+
ImGui.TextColored(UiColors.TextMuted, "Graphics processing unit(s):");
71+
ImGui.Text($"{gpuInformation}");
72+
FormInputs.AddVerticalSpace(8);
73+
ImGui.Separator();
74+
ImGui.PopStyleVar();
75+
76+
FormInputs.AddVerticalSpace(5);
3877
if (ImGui.Button("Copy System Information"))
3978
{
4079
UpdateSystemInfo(); // Update system info and copy to clipboard
@@ -61,11 +100,15 @@ private void UpdateSystemInfo()
61100
{
62101
var systemInfo = new StringBuilder();
63102

64-
systemInfo.AppendLine($"Date: {DateTime.Now}");
103+
systemInfo.AppendLine($"{dateTime}");
65104
systemInfo.AppendLine($"TiXL version: {Program.VersionText}");
66-
systemInfo.AppendLine($"Language: {GetAppLanguage()}");
105+
#if DEBUG
106+
systemInfo.AppendLine($"IDE: {GetIdeName()}");
107+
#endif
108+
systemInfo.AppendLine($"App language: {GetAppLanguage()}");
67109
systemInfo.AppendLine($"OS: {GetOperatingSystemInfo()}");
68110
systemInfo.AppendLine($"System language: {GetSystemLanguage()}");
111+
systemInfo.AppendLine($"Keyboard Layout: {GetKeyboardLayout()}");
69112
systemInfo.AppendLine($".NET runtime: {GetDotNetRuntimeVersion()}");
70113
systemInfo.AppendLine($".NET SDK: {GetDotNetSdkVersion()}");
71114
systemInfo.AppendLine($"GPU: {GetGpuInformation()}");
@@ -91,7 +134,20 @@ private static string GetSystemLanguage()
91134
try
92135
{
93136
var currentCulture = CultureInfo.CurrentUICulture;
94-
return $"{currentCulture.EnglishName}\nKeyboard layout:{currentCulture.KeyboardLayoutId} ({currentCulture.Parent}) ";
137+
return currentCulture.EnglishName;
138+
}
139+
catch (Exception)
140+
{
141+
return "Unknown";
142+
}
143+
}
144+
145+
private static string GetKeyboardLayout()
146+
{
147+
try
148+
{
149+
var currentInputLanguage = InputLanguage.CurrentInputLanguage;
150+
return $"{currentInputLanguage.Culture.Name}";
95151
}
96152
catch (Exception)
97153
{
@@ -145,23 +201,31 @@ private static string GetDotNetSdkVersion()
145201
return "Not found";
146202
}
147203

148-
private static string GetGpuInformation()
204+
private static string GetGpuInformation(string infoType = "both")
149205
{
150206
var gpuList = new List<string>();
207+
var activeGpu = ProgramWindows.ActiveGpu;
151208

152209
try
153210
{
154211
using (var searcher = new ManagementObjectSearcher("SELECT * FROM Win32_VideoController"))
155212
{
156-
157-
foreach (var searchResult in searcher.Get())
213+
foreach (ManagementObject obj in searcher.Get())
158214
{
159-
if (searchResult is not ManagementObject obj)
160-
continue;
161215

162216
var name = obj["Name"]?.ToString() ?? "Unknown";
217+
if (name == activeGpu)
218+
name += " (Active)";
219+
163220
var driverVersion = obj["DriverVersion"]?.ToString() ?? "Unknown";
164-
var gpuDetails = $"{name}\nDriver version: {driverVersion}";
221+
222+
string gpuDetails = infoType.ToLower() switch
223+
{
224+
"name" => name,
225+
"driver" => driverVersion,
226+
_ => $"{name}\nDriver version: {driverVersion}" // Default/both case
227+
};
228+
165229
gpuList.Add(gpuDetails);
166230
}
167231
}
@@ -175,8 +239,58 @@ private static string GetGpuInformation()
175239

176240
return "Unknown";
177241
}
178-
242+
243+
private static string GetIdeName()
244+
{
245+
try
246+
{
247+
// Get the current process
248+
var currentProcess = Process.GetCurrentProcess();
249+
250+
// Use WMI to find the parent process
251+
var query = $"SELECT ParentProcessId FROM Win32_Process WHERE ProcessId = {currentProcess.Id}";
252+
using var searcher = new ManagementObjectSearcher(query);
253+
var result = searcher.Get().Cast<ManagementObject>().FirstOrDefault();
254+
255+
if (result != null)
256+
{
257+
var parentProcessId = Convert.ToInt32(result["ParentProcessId"]);
258+
using var parentProcess = Process.GetProcessById(parentProcessId);
259+
var processName = parentProcess.ProcessName.ToLower();
260+
261+
// Map common IDE process names to user-friendly names
262+
return processName switch
263+
{
264+
"devenv" => "Visual Studio",
265+
"vsdebugconsole" => "Visual Studio",
266+
"rider64" => "JetBrains Rider",
267+
"vshost" => "Visual Studio (Debug Host)",
268+
"msvsmon" => "Visual Studio Remote Debugger",
269+
_ => parentProcess.ProcessName // Fallback to the raw process name
270+
};
271+
}
272+
}
273+
catch (Exception e)
274+
{
275+
Log.Warning($"Failed to get IDE name: {e.Message}");
276+
}
277+
278+
return "Unknown";
279+
}
280+
private static readonly string ideName = GetIdeName();
281+
private static readonly string appLanguage = GetAppLanguage();
282+
private static readonly string dateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
283+
284+
private static readonly string operatingSystemInfo = GetOperatingSystemInfo();
285+
private static readonly string systemLanguage = GetSystemLanguage();
286+
private static readonly string keyboardLayout = GetKeyboardLayout();
287+
private static readonly string dotNetRuntime = GetDotNetRuntimeVersion();
288+
private static readonly string dotNetSdk = GetDotNetSdkVersion();
289+
private static readonly string gpuInformation = GetGpuInformation();
290+
179291
private string _systemInfo = string.Empty;
180292

293+
private static readonly Vector2 mySpacing = new (6.0f, 3.0f);
294+
181295

182296
}

0 commit comments

Comments
 (0)