diff --git a/AM2RLauncher/AM2RLauncher/Language/Text.Designer.cs b/AM2RLauncher/AM2RLauncher/Language/Text.Designer.cs
index 69e03ec..9344aa7 100644
--- a/AM2RLauncher/AM2RLauncher/Language/Text.Designer.cs
+++ b/AM2RLauncher/AM2RLauncher/Language/Text.Designer.cs
@@ -578,5 +578,11 @@ namespace AM2RLauncher.Language {
return ResourceManager.GetString("MatrixToolTip", resourceCulture);
}
}
+
+ public static string CreateShortcut {
+ get {
+ return ResourceManager.GetString("CreateShortcut", resourceCulture);
+ }
+ }
}
}
diff --git a/AM2RLauncher/AM2RLauncher/Language/Text.de.resx b/AM2RLauncher/AM2RLauncher/Language/Text.de.resx
index 94c0cb8..7b9b111 100644
--- a/AM2RLauncher/AM2RLauncher/Language/Text.de.resx
+++ b/AM2RLauncher/AM2RLauncher/Language/Text.de.resx
@@ -386,4 +386,7 @@ Bitte äußerste Vorsicht walten lassen.
Der offizielle AM2R Matrix Space
+
+ DESKTOPVERKNÜPFUNG ERTELLEN
+
\ No newline at end of file
diff --git a/AM2RLauncher/AM2RLauncher/Language/Text.es.resx b/AM2RLauncher/AM2RLauncher/Language/Text.es.resx
index 935b1bf..f4a51e4 100644
--- a/AM2RLauncher/AM2RLauncher/Language/Text.es.resx
+++ b/AM2RLauncher/AM2RLauncher/Language/Text.es.resx
@@ -386,4 +386,7 @@ Procede con cautela.
El Espacio Oficial de Matrix para AM2R
+
+ CREAR ACCESO DIRECTO EN EL ESCRITORIO
+
\ No newline at end of file
diff --git a/AM2RLauncher/AM2RLauncher/Language/Text.ja.resx b/AM2RLauncher/AM2RLauncher/Language/Text.ja.resx
index 6a65c4c..084b650 100644
--- a/AM2RLauncher/AM2RLauncher/Language/Text.ja.resx
+++ b/AM2RLauncher/AM2RLauncher/Language/Text.ja.resx
@@ -386,4 +386,7 @@
公式AM2Rマトリクススペース
+
+ ショートカットをデスクトップに作成
+
\ No newline at end of file
diff --git a/AM2RLauncher/AM2RLauncher/Language/Text.resx b/AM2RLauncher/AM2RLauncher/Language/Text.resx
index 0ea2444..25b0c47 100644
--- a/AM2RLauncher/AM2RLauncher/Language/Text.resx
+++ b/AM2RLauncher/AM2RLauncher/Language/Text.resx
@@ -388,4 +388,7 @@ Proceed with caution.
The Official AM2R Matrix Space
+
+ CREATE SHORTCUT ON DESKTOP
+
\ No newline at end of file
diff --git a/AM2RLauncher/AM2RLauncher/Language/Text.ru.resx b/AM2RLauncher/AM2RLauncher/Language/Text.ru.resx
index 636402a..683c377 100644
--- a/AM2RLauncher/AM2RLauncher/Language/Text.ru.resx
+++ b/AM2RLauncher/AM2RLauncher/Language/Text.ru.resx
@@ -386,4 +386,7 @@
Официальное Matrix-пространство по AM2R
+
+ СОЗДАТЬ ЯРЛЫК НА РАБОЧЕМ СТОЛЕ
+
\ No newline at end of file
diff --git a/AM2RLauncher/AM2RLauncher/Language/Text.zh-Hans.resx b/AM2RLauncher/AM2RLauncher/Language/Text.zh-Hans.resx
index 06a0a74..ca5b963 100644
--- a/AM2RLauncher/AM2RLauncher/Language/Text.zh-Hans.resx
+++ b/AM2RLauncher/AM2RLauncher/Language/Text.zh-Hans.resx
@@ -388,4 +388,7 @@
AM2R 官方 Matrix 空间
+
+ 创建桌面快捷方式
+
\ No newline at end of file
diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs
index be6ac7d..2db4038 100644
--- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs
+++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs
@@ -8,6 +8,7 @@ using System.ComponentModel;
using System.IO;
using System.IO.Compression;
using System.Linq;
+using System.Net;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
@@ -795,6 +796,71 @@ public partial class MainForm : Form
profileNotesTextArea.Text = Text.ProfileNotes + "\n" + profileList[modSettingsProfileDropDown.SelectedIndex].ProfileNotes;
}
+ ///
+ /// Creates a shortcut of the selected profile on the Desktop
+ ///
+ private void DesktopShortcutButtonClicked(object sender, EventArgs e)
+ {
+ ProfileXML profile = profileList[modSettingsProfileDropDown.SelectedIndex];
+ log.Info($"User wants to create a desktop shortcut for {profile.Name}.");
+
+ //TODO: warning if used on community updates
+
+ string desktopFolder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop, Environment.SpecialFolderOption.Create);
+ string shortcutFile = "";
+
+ if (OS.IsWindows)
+ {
+ //TODO: implement this
+ }
+ else if (OS.IsLinux)
+ {
+ shortcutFile = $"{desktopFolder}/{profile.Name}.desktop";
+
+ const string desktopEntryTemplate =
+ "[Desktop Entry]\n" +
+ "Type=Application\n" +
+ "Categories=Game\n" +
+ "Encoding=UTF-8\n" +
+ "Name=PROFILENAME\n" +
+ "Comment=PROFILEDESCRIPTION\n" +
+ "Exec=EXECUTABLE\n" +
+ "Icon=ICONPATH\n" +
+ "Terminal=false";
+
+ string desktopEntryText = desktopEntryTemplate;
+
+ // Replace values
+ desktopEntryText = desktopEntryText.Replace("PROFILENAME", $"{profile.Name}");
+ desktopEntryText = desktopEntryText.Replace("PROFILEDESCRIPTION", $"{profile.ProfileNotes}");
+ desktopEntryText = desktopEntryText.Replace("ICONPATH", $"{Core.PatchDataPath}/data/files_to_copy/icon.png");
+
+ string gameName;
+ #if !NOAPPIMAGE
+ gameName = "runner";
+ #else
+ gameName = "AM2R.AppImage";
+ #endif
+ if (OS.IsThisRunningFromFlatpak)
+ desktopEntryText = desktopEntryText.Replace("EXECUTABLE", $"flatpak run \"--command={Core.ProfilesPath}/{profile.Name}/{gameName}\" io.github.am2r_community_developers.AM2RLauncher");
+ else
+ desktopEntryText = desktopEntryText.Replace("EXECUTABLE", $"{Core.ProfilesPath}/{profile.Name}/{gameName}");
+
+ File.WriteAllText(shortcutFile, desktopEntryText);
+ }
+ else if (OS.IsMac)
+ {
+ throw new NotImplementedException("Creating Desktop Shortcuts on Mac has currently not been implemented!");
+ }
+ else
+ {
+ log.Error($"{OS.Name} has no way of creating shortcuts");
+ return;
+ }
+
+ CrossPlatformOperations.OpenFolderAndSelectFile(shortcutFile);
+ }
+
///
/// This opens the game files directory for the current profile.
///
diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs
index 5102202..b4fdd3f 100644
--- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs
+++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs
@@ -657,6 +657,18 @@ public partial class MainForm : Form
modSettingsProfileDropDown.DataStore = profileDropDown.DataStore; // It's actually more comfortable if it's outside, because of GTK shenanigans
modSettingsProfileDropDown.Bind(m => m.SelectedIndex, profileDropDown, p => p.SelectedIndex);
+ desktopShortcutButton = profileButton = new ColorButton
+ {
+ Text = Text.CreateShortcut,
+ Font = smallButtonFont,
+ Height = 30,
+ Width = 275,
+ TextColor = colorGreen,
+ BackgroundColor = colorBG,
+ FrameColor = colorGreen,
+ BackgroundColorHover = colorBGHover
+ };
+
profileButton = new ColorButton
{
Text = Text.OpenProfileFolder,
@@ -717,7 +729,7 @@ public partial class MainForm : Form
modSettingsLayout.BeginHorizontal();
modSettingsLayout.AddSpace();
- modSettingsLayout.AddColumn(null, addModButton, modSpacer, settingsProfileLabel, modSettingsProfileDropDown, profileButton, saveButton, updateModButton, deleteModButton, profileNotesTextArea, null);
+ modSettingsLayout.AddColumn(null, addModButton, modSpacer, settingsProfileLabel, modSettingsProfileDropDown, desktopShortcutButton, profileButton, saveButton, updateModButton, deleteModButton, profileNotesTextArea, null);
modSettingsLayout.AddSpace();
TabPage modSettingsPage = new TabPage
@@ -769,6 +781,7 @@ public partial class MainForm : Form
mirrorDropDown.SelectedIndexChanged += MirrorDropDownSelectedIndexChanged;
modSettingsLayout.LoadComplete += ProfileLayoutLoadComplete;
addModButton.Click += AddModButtonClicked;
+ desktopShortcutButton.Click += DesktopShortcutButtonClicked;
profileButton.Click += ProfileDataButtonClickEvent;
saveButton.Click += SaveButtonClickEvent;
modSettingsProfileDropDown.SelectedIndexChanged += ModSettingsProfileDropDownSelectedIndexChanged;
@@ -825,6 +838,8 @@ public partial class MainForm : Form
private readonly ColorButton apkButton;
/// A that is used to add mods.
private readonly ColorButton addModButton;
+ /// A that will create a desktop shortcut of the current profile.
+ private readonly ColorButton desktopShortcutButton;
/// A that will open the game files directory for the selected mod.
private readonly ColorButton profileButton;
/// A that will open the save directory for the selected mod.