diff --git a/src/IntelOrca.OpenLauncher.Core/Shell.cs b/src/IntelOrca.OpenLauncher.Core/Shell.cs
index cad7d88..4bcd06a 100644
--- a/src/IntelOrca.OpenLauncher.Core/Shell.cs
+++ b/src/IntelOrca.OpenLauncher.Core/Shell.cs
@@ -18,6 +18,26 @@ public void StartProcess(string name, params string[] args)
Process.Start(psi);
}
+ public void OpenDirectory(string path)
+ {
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ {
+ Process.Start(new ProcessStartInfo(path) { UseShellExecute = true });
+ }
+ else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ {
+ StartProcess("open", path);
+ }
+ else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ {
+ StartProcess("xdg-open", path);
+ }
+ else
+ {
+ throw new PlatformNotSupportedException();
+ }
+ }
+
public int RunProcess(string name, params string[] args)
{
var psi = new ProcessStartInfo(name);
diff --git a/src/openlauncher/MainWindow.axaml b/src/openlauncher/MainWindow.axaml
index 268a24e..0cc9eef 100644
--- a/src/openlauncher/MainWindow.axaml
+++ b/src/openlauncher/MainWindow.axaml
@@ -77,11 +77,26 @@
Padding="4">
-
+
+
+
+
+
+
+
+
+
@@ -101,6 +116,7 @@
Value="0.5" />
diff --git a/src/openlauncher/MainWindow.axaml.cs b/src/openlauncher/MainWindow.axaml.cs
index c5e049a..18670f7 100644
--- a/src/openlauncher/MainWindow.axaml.cs
+++ b/src/openlauncher/MainWindow.axaml.cs
@@ -30,6 +30,9 @@ public MainWindow()
{
InitializeComponent();
+ openInstallFolderMenuItem.Header = GetOpenInstallFolderText();
+ ToolTip.SetPlacement(playButton, PlacementMode.Bottom);
+
if (!Design.IsDesignMode)
{
downloadProgress.IsVisible = false;
@@ -229,6 +232,26 @@ private async void playButton_Click(object sender, RoutedEventArgs e)
}
}
+ private void playMenuButton_Click(object sender, RoutedEventArgs e)
+ {
+ playMenu.Open(playSplitButton);
+ }
+
+ private void openInstallFolderMenuItem_Click(object sender, RoutedEventArgs e)
+ {
+ if (_selectedMenuItem == null)
+ return;
+
+ try
+ {
+ new Shell().OpenDirectory(_selectedMenuItem.Game!.BinPath);
+ }
+ catch (Exception ex)
+ {
+ ShowError(string.Format(StringResources.FailedToOpenInstallFolder, _selectedMenuItem.Game!.Name), ex);
+ }
+ }
+
private async Task RefreshInstalledVersionAsync()
{
if (_selectedMenuItem == null)
@@ -253,8 +276,18 @@ private async Task RefreshInstalledVersionAsync()
if (!_isBusy)
{
playButton.IsEnabled = installService.CanLaunch();
+ playMenuButton.IsEnabled = CanOpenInstallFolder();
}
- ToolTip.SetTip(playButton, installService.ExecutablePath);
+ ToolTip.SetTip(playButton, new ToolTip
+ {
+ MaxWidth = double.PositiveInfinity,
+ Content = new TextBlock
+ {
+ Text = installService.ExecutablePath,
+ TextWrapping = Avalonia.Media.TextWrapping.NoWrap
+ }
+ });
+ ToolTip.SetHorizontalOffset(playButton, -playSplitButton.Bounds.Width);
}
}
@@ -403,15 +436,31 @@ private void SetAllInteractionEnabled(bool value)
if (value)
{
playButton.IsEnabled = _selectedMenuItem?.InstallService.CanLaunch() ?? false;
+ playMenuButton.IsEnabled = CanOpenInstallFolder();
downloadButton.IsEnabled = buildsAvailable && !AutoUpdateEnabled();
versionDropdown.IsEnabled = !AutoUpdateEnabled();
}
else
{
playButton.IsEnabled = value;
+ playMenuButton.IsEnabled = value;
downloadButton.IsEnabled = value;
}
}
+
+ private bool CanOpenInstallFolder()
+ {
+ return _selectedMenuItem != null && Directory.Exists(_selectedMenuItem.Game!.BinPath);
+ }
+
+ private static string GetOpenInstallFolderText()
+ {
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ return StringResources.OpenInFileExplorer;
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ return StringResources.OpenInFinder;
+ return StringResources.OpenInFileManager;
+ }
private bool AutoUpdateEnabled()
{
diff --git a/src/openlauncher/Properties/Resources.Designer.cs b/src/openlauncher/Properties/Resources.Designer.cs
index a24021a..838fc8c 100644
--- a/src/openlauncher/Properties/Resources.Designer.cs
+++ b/src/openlauncher/Properties/Resources.Designer.cs
@@ -116,6 +116,26 @@ public static string FailedToLaunchGame {
return ResourceManager.GetString("FailedToLaunchGame", resourceCulture);
}
}
+ public static string OpenInFileExplorer {
+ get {
+ return ResourceManager.GetString("OpenInFileExplorer", resourceCulture);
+ }
+ }
+ public static string OpenInFileManager {
+ get {
+ return ResourceManager.GetString("OpenInFileManager", resourceCulture);
+ }
+ }
+ public static string OpenInFinder {
+ get {
+ return ResourceManager.GetString("OpenInFinder", resourceCulture);
+ }
+ }
+ public static string FailedToOpenInstallFolder {
+ get {
+ return ResourceManager.GetString("FailedToOpenInstallFolder", resourceCulture);
+ }
+ }
public static string DownloadBuildFailedTitle {
get {
diff --git a/src/openlauncher/Properties/Resources.resx b/src/openlauncher/Properties/Resources.resx
index 6823e99..7d6bcb6 100644
--- a/src/openlauncher/Properties/Resources.resx
+++ b/src/openlauncher/Properties/Resources.resx
@@ -36,6 +36,18 @@
Failed to launch {0}
+
+ Open in File Explorer
+
+
+ Open in File Manager
+
+
+ Open in Finder
+
+
+ Failed to open the installation folder for {0}
+
Failed to download build