mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-12-23 04:05:46 +00:00
Create Desktop Shortcut fixes (#5852)
* remove duplicate basePath arg, add --fullscreen arg * Changing FriendlyName to set "Ryujinx" text * Fix GetArgsString using the base path * Change desktop path to the Applications folder when creating shortcut on Mac Co-authored-by: Nicko Anastassiu <134955950+nickoanastassiu@users.noreply.github.com> * Move Create Shortcut button to top of context menu --------- Co-authored-by: TSR Berry <20988865+TSRBerry@users.noreply.github.com> Co-authored-by: Nicko Anastassiu <134955950+nickoanastassiu@users.noreply.github.com>
This commit is contained in:
parent
7e6342e44d
commit
55557525b1
3 changed files with 14 additions and 17 deletions
|
@ -12,6 +12,11 @@
|
||||||
Click="ToggleFavorite_Click"
|
Click="ToggleFavorite_Click"
|
||||||
Header="{locale:Locale GameListContextMenuToggleFavorite}"
|
Header="{locale:Locale GameListContextMenuToggleFavorite}"
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuToggleFavoriteToolTip}" />
|
ToolTip.Tip="{locale:Locale GameListContextMenuToggleFavoriteToolTip}" />
|
||||||
|
<MenuItem
|
||||||
|
Click="CreateApplicationShortcut_Click"
|
||||||
|
Header="{locale:Locale GameListContextMenuCreateShortcut}"
|
||||||
|
IsEnabled="{Binding CreateShortcutEnabled}"
|
||||||
|
ToolTip.Tip="{locale:Locale GameListContextMenuCreateShortcutToolTip}" />
|
||||||
<Separator />
|
<Separator />
|
||||||
<MenuItem
|
<MenuItem
|
||||||
Click="OpenUserSaveDirectory_Click"
|
Click="OpenUserSaveDirectory_Click"
|
||||||
|
@ -82,9 +87,4 @@
|
||||||
Header="{locale:Locale GameListContextMenuExtractDataLogo}"
|
Header="{locale:Locale GameListContextMenuExtractDataLogo}"
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuExtractDataLogoToolTip}" />
|
ToolTip.Tip="{locale:Locale GameListContextMenuExtractDataLogoToolTip}" />
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem
|
|
||||||
Click="CreateApplicationShortcut_Click"
|
|
||||||
Header="{locale:Locale GameListContextMenuCreateShortcut}"
|
|
||||||
IsEnabled="{Binding CreateShortcutEnabled}"
|
|
||||||
ToolTip.Tip="{locale:Locale GameListContextMenuCreateShortcutToolTip}" />
|
|
||||||
</MenuFlyout>
|
</MenuFlyout>
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace Ryujinx.Ui.Common.Helper
|
||||||
graphic.DrawImage(image, 0, 0, 128, 128);
|
graphic.DrawImage(image, 0, 0, 128, 128);
|
||||||
SaveBitmapAsIcon(bitmap, iconPath);
|
SaveBitmapAsIcon(bitmap, iconPath);
|
||||||
|
|
||||||
var shortcut = Shortcut.CreateShortcut(basePath, GetArgsString(basePath, applicationFilePath), iconPath, 0);
|
var shortcut = Shortcut.CreateShortcut(basePath, GetArgsString(applicationFilePath), iconPath, 0);
|
||||||
shortcut.StringData.NameString = cleanedAppName;
|
shortcut.StringData.NameString = cleanedAppName;
|
||||||
shortcut.WriteToFile(Path.Combine(desktopPath, cleanedAppName + ".lnk"));
|
shortcut.WriteToFile(Path.Combine(desktopPath, cleanedAppName + ".lnk"));
|
||||||
}
|
}
|
||||||
|
@ -46,16 +46,16 @@ namespace Ryujinx.Ui.Common.Helper
|
||||||
image.SaveAsPng(iconPath);
|
image.SaveAsPng(iconPath);
|
||||||
|
|
||||||
using StreamWriter outputFile = new(Path.Combine(desktopPath, cleanedAppName + ".desktop"));
|
using StreamWriter outputFile = new(Path.Combine(desktopPath, cleanedAppName + ".desktop"));
|
||||||
outputFile.Write(desktopFile, cleanedAppName, iconPath, GetArgsString(basePath, applicationFilePath));
|
outputFile.Write(desktopFile, cleanedAppName, iconPath, $"{basePath} {GetArgsString(applicationFilePath)}");
|
||||||
}
|
}
|
||||||
|
|
||||||
[SupportedOSPlatform("macos")]
|
[SupportedOSPlatform("macos")]
|
||||||
private static void CreateShortcutMacos(string appFilePath, byte[] iconData, string desktopPath, string cleanedAppName)
|
private static void CreateShortcutMacos(string appFilePath, byte[] iconData, string desktopPath, string cleanedAppName)
|
||||||
{
|
{
|
||||||
string basePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AppDomain.CurrentDomain.FriendlyName);
|
string basePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Ryujinx");
|
||||||
var plistFile = EmbeddedResources.ReadAllText("Ryujinx.Ui.Common/shortcut-template.plist");
|
var plistFile = EmbeddedResources.ReadAllText("Ryujinx.Ui.Common/shortcut-template.plist");
|
||||||
// Macos .App folder
|
// Macos .App folder
|
||||||
string contentFolderPath = Path.Combine(desktopPath, cleanedAppName + ".app", "Contents");
|
string contentFolderPath = Path.Combine("/Applications", cleanedAppName + ".app", "Contents");
|
||||||
string scriptFolderPath = Path.Combine(contentFolderPath, "MacOS");
|
string scriptFolderPath = Path.Combine(contentFolderPath, "MacOS");
|
||||||
|
|
||||||
if (!Directory.Exists(scriptFolderPath))
|
if (!Directory.Exists(scriptFolderPath))
|
||||||
|
@ -69,7 +69,7 @@ namespace Ryujinx.Ui.Common.Helper
|
||||||
using StreamWriter scriptFile = new(scriptPath);
|
using StreamWriter scriptFile = new(scriptPath);
|
||||||
|
|
||||||
scriptFile.WriteLine("#!/bin/sh");
|
scriptFile.WriteLine("#!/bin/sh");
|
||||||
scriptFile.WriteLine(GetArgsString(basePath, appFilePath));
|
scriptFile.WriteLine($"{basePath} {GetArgsString(appFilePath)}");
|
||||||
|
|
||||||
// Set execute permission
|
// Set execute permission
|
||||||
FileInfo fileInfo = new(scriptPath);
|
FileInfo fileInfo = new(scriptPath);
|
||||||
|
@ -125,13 +125,10 @@ namespace Ryujinx.Ui.Common.Helper
|
||||||
throw new NotImplementedException("Shortcut support has not been implemented yet for this OS.");
|
throw new NotImplementedException("Shortcut support has not been implemented yet for this OS.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetArgsString(string basePath, string appFilePath)
|
private static string GetArgsString(string appFilePath)
|
||||||
{
|
{
|
||||||
// args are first defined as a list, for easier adjustments in the future
|
// args are first defined as a list, for easier adjustments in the future
|
||||||
var argsList = new List<string>
|
var argsList = new List<string>();
|
||||||
{
|
|
||||||
basePath,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(CommandLineState.BaseDirPathArg))
|
if (!string.IsNullOrEmpty(CommandLineState.BaseDirPathArg))
|
||||||
{
|
{
|
||||||
|
@ -141,7 +138,6 @@ namespace Ryujinx.Ui.Common.Helper
|
||||||
|
|
||||||
argsList.Add($"\"{appFilePath}\"");
|
argsList.Add($"\"{appFilePath}\"");
|
||||||
|
|
||||||
|
|
||||||
return String.Join(" ", argsList);
|
return String.Join(" ", argsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -211,6 +211,8 @@ namespace Ryujinx.Ui.Widgets
|
||||||
_manageSubMenu.Append(_openPtcDirMenuItem);
|
_manageSubMenu.Append(_openPtcDirMenuItem);
|
||||||
_manageSubMenu.Append(_openShaderCacheDirMenuItem);
|
_manageSubMenu.Append(_openShaderCacheDirMenuItem);
|
||||||
|
|
||||||
|
Add(_createShortcutMenuItem);
|
||||||
|
Add(new SeparatorMenuItem());
|
||||||
Add(_openSaveUserDirMenuItem);
|
Add(_openSaveUserDirMenuItem);
|
||||||
Add(_openSaveDeviceDirMenuItem);
|
Add(_openSaveDeviceDirMenuItem);
|
||||||
Add(_openSaveBcatDirMenuItem);
|
Add(_openSaveBcatDirMenuItem);
|
||||||
|
@ -223,7 +225,6 @@ namespace Ryujinx.Ui.Widgets
|
||||||
Add(new SeparatorMenuItem());
|
Add(new SeparatorMenuItem());
|
||||||
Add(_manageCacheMenuItem);
|
Add(_manageCacheMenuItem);
|
||||||
Add(_extractMenuItem);
|
Add(_extractMenuItem);
|
||||||
Add(_createShortcutMenuItem);
|
|
||||||
|
|
||||||
ShowAll();
|
ShowAll();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue