public static void DownloadGameBananaItem(string arg) { // GameBanana Download Protocol if (arg.ToLower().StartsWith(@"hedgemmgens:") || arg.ToLower().StartsWith(@"hedgemmlw:") || arg.ToLower().StartsWith(@"hedgemmforces:")) { string url = arg; if (url.ToLower().StartsWith(@"hedgemmgens:")) { url = url.Substring(12); } if (url.ToLower().StartsWith(@"hedgemmlw:")) { url = url.Substring(10); } if (url.ToLower().StartsWith(@"hedgemmforces:")) { url = url.Substring(14); } // TODO: string itemType = url.Split(',')[1]; int itemID = 0; if (!int.TryParse(url.Split(',')[2], out itemID)) { MessageBox.Show("Given ItemID is not in a number format or is out of interger range!"); } url = url.Substring(0, url.IndexOf(",")); if (!IsURL(url)) { MessageBox.Show("Link Given is not a URL!"); return; } var item = new GBAPIItemDataBasic(itemType, itemID); if (GBAPI.RequestItemData(item)) { var window = new GameBananaModDownloadWindow(item, url); window.ShowDialog(); } } }
static void Main(string[] args) { #region Write required pre-requisites to the Tools directory if (!Directory.Exists($"{ApplicationData}\\Unleash\\Tools\\")) { Directory.CreateDirectory($"{ApplicationData}\\Unleash\\Tools\\"); } if (!Directory.Exists($"{ApplicationData}\\Unleash\\Tools\\Scripts\\")) { Directory.CreateDirectory($"{ApplicationData}\\Unleash\\Tools\\Scripts\\"); } if (!File.Exists(_7Zip)) { File.WriteAllBytes(_7Zip, Properties.Resources._7z); } if (!File.Exists(quickbms)) { File.WriteAllBytes(quickbms, Properties.Resources.quickbms); } if (!File.Exists(xcompress_file)) { File.WriteAllBytes(xcompress_file, Properties.Resources.xcompress_file); } if (!File.Exists(arcsys)) { File.WriteAllBytes(arcsys, Properties.Resources.arcsys); } #endregion Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); #if !DEBUG try { #endif // Ensure application can't be run more than once if ((Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location)).Count() > 1) == false) { if (args.Length > 0) { if (args[0] == "-banana") { string[] getIDs = args[1].Remove(0, 42).Split(','); // Split URL string modType = string.Empty; int downloadID = 0; int modID = 0; int i = 0; //Get IDs from URL foreach (string item in getIDs) { if (i == 0) { int.TryParse(item, out downloadID); { i++; } } else if (i == 1) { modType = item; i++; } else if (i == 2) { int.TryParse(item, out modID); { i++; } } } var mod = new GBAPIItemDataBasic(modType, modID); if (GBAPI.RequestItemData(mod)) { new ModOneClickInstall(mod, args[1], downloadID, modID).ShowDialog(); // Load 1-Click Installer Application.Run(new UnifyEnvironment()); // Load everything after } } } else { // Load everything Application.Run(new UnifyEnvironment()); } // If application is running, just load the 1-Click Installer only } else if (args.Length > 0) { if (args[0] == "-banana") { string[] getIDs = args[1].Remove(0, 42).Split(','); // Split URL string modType = string.Empty; int downloadID = 0; int modID = 0; int i = 0; //Get IDs from URL foreach (string item in getIDs) { if (i == 0) { int.TryParse(item, out downloadID); { i++; } } else if (i == 1) { modType = item; i++; } else if (i == 2) { int.TryParse(item, out modID); { i++; } } } var mod = new GBAPIItemDataBasic(modType, modID); if (GBAPI.RequestItemData(mod)) { new ModOneClickInstall(mod, args[1], downloadID, modID).ShowDialog(); } } } #if !DEBUG } catch (Exception ex) { DialogResult confirmation = UnifyMessenger.UnifyMessage.ShowDialog($"Failed to load your settings... Please report this error immediately!\n\n{ex.ToString()}\n\n" + "Click OK to reset Unleashed Mod Manager.", "Settings failed", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); if (confirmation == DialogResult.OK) { Program.Reset(); // Reset settings } else { Process.GetCurrentProcess().Kill(); // Quit immediately } } #endif }