mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Better names for found Rider installs + context menu for copy/open path
This commit is contained in:
@@ -123,12 +123,14 @@ class RiderInstallInfo
|
||||
public String Path ~ delete _;
|
||||
public RiderVersion Version;
|
||||
public RiderInstallType InstallType;
|
||||
public String Name ~ delete _;
|
||||
|
||||
public this(StringView path, RiderVersion version, RiderInstallType installType)
|
||||
public this(StringView path, RiderVersion version, RiderInstallType installType, StringView name)
|
||||
{
|
||||
Path = new String(path);
|
||||
Version = version;
|
||||
InstallType = installType;
|
||||
Name = new String(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,7 +368,7 @@ static class RiderPathLocator
|
||||
}
|
||||
|
||||
/// Reads the version of a Rider installation out of its "product-info.json".
|
||||
protected static RiderVersion ParseProductInfoJson(StringView productInfoJsonPath)
|
||||
protected static RiderVersion ParseProductInfoJson(StringView productInfoJsonPath, String outName, String outVersion)
|
||||
{
|
||||
StructuredData data = scope .();
|
||||
if (data.Load(productInfoJsonPath) case .Err)
|
||||
@@ -374,6 +376,9 @@ static class RiderPathLocator
|
||||
|
||||
String buildNumber = scope .();
|
||||
data.GetString("buildNumber", buildNumber);
|
||||
|
||||
data.GetString("name", outName);
|
||||
data.GetString("version", outVersion);
|
||||
|
||||
return RiderVersion.Parse(buildNumber);
|
||||
}
|
||||
|
||||
@@ -33,11 +33,19 @@ extension RiderPathLocator
|
||||
|
||||
RiderVersion version = .();
|
||||
|
||||
String installName = scope .();
|
||||
String installVersion = scope .();
|
||||
|
||||
String productInfoPath = scope .();
|
||||
Path.Combine(productInfoPath, riderDirectory, "product-info.json");
|
||||
|
||||
if (File.Exists(productInfoPath))
|
||||
version = ParseProductInfoJson(productInfoPath);
|
||||
version = ParseProductInfoJson(productInfoPath, installName, installVersion);
|
||||
else
|
||||
{
|
||||
installName.Set("Rider");
|
||||
version.ToString(installVersion..Clear());
|
||||
}
|
||||
|
||||
if (!version.IsInitialized)
|
||||
{
|
||||
@@ -49,7 +57,7 @@ extension RiderPathLocator
|
||||
version = RiderVersion.Parse(directoryName);
|
||||
}
|
||||
|
||||
return new RiderInstallInfo(riderExePath, version, installType);
|
||||
return new RiderInstallInfo(riderExePath, version, installType, scope $"{installName} {installVersion}");
|
||||
}
|
||||
|
||||
public static override void CollectAllPaths(List<RiderInstallInfo> outInstalls)
|
||||
|
||||
@@ -183,7 +183,7 @@ class DetectIDEsBackgroundTask : BackgroundTask
|
||||
ide.IsAutoDetected = true;
|
||||
ide.Ide = .Rider;
|
||||
ide.Path = install.Path;
|
||||
ide.Name = scope $"Rider {install.Version}";
|
||||
ide.Name = install.Name;
|
||||
|
||||
installations.Add(ide);
|
||||
}
|
||||
|
||||
@@ -290,6 +290,9 @@ class ScriptSettings
|
||||
{
|
||||
for (let ide in installations)
|
||||
{
|
||||
// Make sure entries have unique IDs, even if two IDEs have the same name.
|
||||
ImGui.PushID(ide.Path.ToScopeCStr!());
|
||||
|
||||
if (ImGui.Selectable(ide.Name.ToScopeCStr!()) && ActiveIde != ide)
|
||||
{
|
||||
_activeIdePath.Set(ide.Path);
|
||||
@@ -297,6 +300,27 @@ class ScriptSettings
|
||||
}
|
||||
|
||||
ImGui.AttachTooltip(ide.Path);
|
||||
|
||||
// Context menu when right-clicking the entry.
|
||||
if (ImGui.BeginPopupContextItem())
|
||||
{
|
||||
if (ImGui.MenuItem("Copy path"))
|
||||
{
|
||||
ImGui.SetClipboardText(ide.Path.ToScopeCStr!());
|
||||
}
|
||||
|
||||
if (ImGui.MenuItem("Show in file browser..."))
|
||||
{
|
||||
if (Path.OpenFolderAndSelectItem(ide.Path) case .Err)
|
||||
{
|
||||
Log.EngineLogger.Error("Failed to show path in file browser.");
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
|
||||
ImGui.PopID();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user