public ModOneClickInstall(GBAPIItemDataBasic item, string url, int downloadID, int modID) { InitializeComponent(); this.url = url; this.item = item; this.modID = modID; this.downloadID = downloadID.ToString(); downloadURL = $"https://gamebanana.com/mmdl/{downloadID}"; cache = Path.Combine(Application.StartupPath, "cache"); lbl_Title.Text = item.ModName; Text = $"GameBanana 1-Click Install for {item.ModName}"; tb_Information.Text = $"Published by {item.OwnerName}\n\n{GBAPI.ProcessCredits(item.Credits)}"; if (item.Subtitle != string.Empty) { web_Description.DocumentText = $"<html><head><meta charset=\"UTF-8\"><style>{Properties.Resources.GBStyleSheetDark}</style></head><body><h1><center>{item.Subtitle}</center></h1><br>{item.Body}</body></html>"; } else { web_Description.DocumentText = $"<html><head><meta charset=\"UTF-8\"><style>{Properties.Resources.GBStyleSheetDark}</style></head><body>{item.Body}</body></html>"; } if (modID == 6666) { return; } if (item.ScreenshotURL != null) { try { WebRequest request = WebRequest.Create(item.ScreenshotURL); using (var response = request.GetResponse()) using (var stream = response.GetResponseStream()) { pic_Thumbnail.BackgroundImage = Image.FromStream(stream); pic_Thumbnail.BackgroundImageLayout = ImageLayout.Zoom; } } catch { pic_Thumbnail.BackgroundImage = Properties.Resources.Exception_Logo_Full_Colour; } } else { pic_Thumbnail.BackgroundImage = Properties.Resources.Exception_Logo_Full_Colour; } if (lbl_Title.Width >= (MinimumSize.Width - pic_Logo.Width)) { Width = lbl_Title.Width + 110; MinimumSize = new Size(Width, Height); } }
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 }