public static void Main() { string launcherDataPath = GenerateCurrentPath(); // Make sure first, ~/.local/share/AM2RLauncher exists if (!Directory.Exists(launcherDataPath)) { Directory.CreateDirectory(launcherDataPath); } // Now, see if log4netConfig exists, if not write it again. if (!File.Exists(launcherDataPath + "/log4net.config")) { File.WriteAllText(launcherDataPath + "/log4net.config", Properties.Resources.log4netContents.Replace("${DATADIR}", launcherDataPath)); } // Configure logger XmlConfigurator.Configure(new FileInfo(launcherDataPath + "/log4net.config")); // if we're on debug, always set loglevel to debug #if DEBUG ((Logger)log.Logger).Level = log4net.Core.Level.Debug; #endif // Log distro and version (if it exists) if (File.Exists("/etc/os-release")) { string osRelease = File.ReadAllText("/etc/os-release"); Regex lineRegex = new Regex(".*=.*"); var results = lineRegex.Matches(osRelease).ToList(); var version = results.FirstOrDefault(x => x.Value.Contains("VERSION")); log.Info("Current Distro: " + results.FirstOrDefault(x => x.Value.Contains("NAME"))?.Value.Substring(5).Replace("\"", "") + (version == null ? "" : " " + version.Value.Substring(8).Replace("\"", ""))); } else { log.Error("Couldn't determine the currently running distro!"); } try { Application gtkLauncher = new Application(Eto.Platforms.Gtk); LauncherUpdater.Main(); gtkLauncher.UnhandledException += GTKLauncher_UnhandledException; gtkLauncher.Run(new MainForm()); } catch (Exception e) { log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.StackTrace); Console.WriteLine(Language.Text.UnhandledException + "\n" + e.Message + "\n*****Stack Trace*****\n\n" + e.StackTrace); Console.WriteLine("Check the logs at " + launcherDataPath + " for more info!"); } }
public static void Main() { string launcherDataPath = GenerateCurrentPath(); // Make sure first, that the path exists if (!Directory.Exists(launcherDataPath)) { Directory.CreateDirectory(launcherDataPath); } // Now, see if log4netConfig exists, if not write it again. if (!File.Exists(launcherDataPath + "/log4net.config")) { File.WriteAllText(launcherDataPath + "/log4net.config", Properties.Resources.log4netContents.Replace("${DATADIR}", launcherDataPath)); } // Configure logger XmlConfigurator.Configure(new FileInfo(launcherDataPath + "/log4net.config")); // if we're on debug, always set loglevel to debug #if DEBUG ((Logger)log.Logger).Level = log4net.Core.Level.Debug; #endif //Log Wine if (Core.Core.IsThisRunningFromWine) { log.Info("Currently running from WINE!"); } // Try catch in case it ever crashes before actually getting to the Eto application try { Application winLauncher = new Application(Eto.Platforms.WinForms); LauncherUpdater.Main(); winLauncher.UnhandledException += WinLauncher_UnhandledException; winLauncher.Run(new MainForm()); } catch (Exception e) { log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.StackTrace); System.Windows.Forms.MessageBox.Show(Language.Text.UnhandledException + "\n" + e.Message + "\n*****Stack Trace*****\n\n" + e.StackTrace, "Microsoft .NET Framework", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Thread.Sleep(500); if (File.Exists(Application.ExecutablePath + ".old")) { File.Delete(Application.ExecutablePath + ".old"); } var launcherUpdateInfo = LauncherUpdater.CheckForLauncherUpdate(); if (launcherUpdateInfo.UpdateAvailable) { MessageBox.Show(Localization.GetText("LauncherUpdate.Checked.Text"), Localization.GetText("LauncherUpdate.Checked.Title"), MessageBoxButtons.OK, MessageBoxIcon.Information); LauncherUpdater.UpdateLauncher(launcherUpdateInfo); Process.Start(Application.ExecutablePath); return; } Application.Run(new FormLauncher()); }
public static void Main() { string launcherDataPath = GenerateCurrentPath(); // Make sure first, ~/.local/share/AM2RLauncher exists if (!Directory.Exists(launcherDataPath)) { Directory.CreateDirectory(launcherDataPath); } // Now, see if log4netConfig exists, if not write it again. if (!File.Exists(launcherDataPath + "/log4net.config")) { File.WriteAllText(launcherDataPath + "/log4net.config", Properties.Resources.log4netContents.Replace("${DATADIR}", launcherDataPath)); } // Configure logger XmlConfigurator.Configure(new FileInfo(launcherDataPath + "/log4net.config")); // if we're on debug, always set loglevel to debug #if DEBUG ((Logger)log.Logger).Level = log4net.Core.Level.Debug; #endif try { Application macLauncher = new Application(Eto.Platforms.Mac64); LauncherUpdater.Main(); macLauncher.UnhandledException += MacLauncher_UnhandledException; macLauncher.Run(new MainForm()); } catch (Exception e) { log.Error("An unhandled exception has occurred: \n*****Stack Trace*****\n\n" + e.StackTrace); Console.WriteLine(Language.Text.UnhandledException + "\n" + e.Message + "\n*****Stack Trace*****\n\n" + e.StackTrace); Console.WriteLine("Check the logs at " + launcherDataPath + " for more info!"); } }
public LauncherNewsPage(LauncherUpdater updater) { InitializeComponent(); this.updater = updater; }
public NewsScreenPage(LauncherUpdater updater) { InitializeComponent(); this.updater = updater; }
public NewsScreenTabs(LauncherUpdater updater) { InitializeComponent(); LastTabName = OfficalTab.Name; launcherNewsPage = new LauncherNewsPage(updater); }
private void LauncherUpdate(object sender, DoWorkEventArgs e) { SetProgressBar(0); BackgroundWorker worker = (BackgroundWorker)sender; Version currentVersion = Versioning.LauncherVersion; Version latestVersion; SetTextStatus(App.resourceManager.GetString("lc_checking_new_version")); if (worker.CancellationPending) { e.Cancel = true; return; } try { String versionURI = $"{Settings.LauncherPatchesURL}{Settings.LauncherVersionFN}"; using (WebClientAuth wc = new WebClientAuth()) { latestVersion = Version.Parse(wc.DownloadString(versionURI)); } } catch (FormatException ex) { e.Cancel = true; MBError(String.Format("Server has invalid response for url `{0}` . {1}", $"{Settings.LauncherPatchesURL}{Settings.LauncherVersionFN}", ex.Message)); return; } catch (WebException ex) { if (ex.Message.Contains("timed out")) { MBError("Unable to retrieve latest version, request timed out."); } HttpWebResponse response = (HttpWebResponse)ex.Response; if (response == null) { MBError("Unable to retrieve latest version, no response."); } else { MBError(String.Format( "{0} \nResponse: {1} {2}", "Unable to retrieve latest version.", (int)response.StatusCode, response.StatusDescription )); } e.Cancel = true; return; } catch (KeyNotFoundException ex) { e.Cancel = true; MBError(ex.Message); MBError(ex.StackTrace); return; } if (worker.CancellationPending) { e.Cancel = true; return; } int versionDifference = currentVersion.CompareTo(latestVersion); if (versionDifference.Equals(-1)) { SetTextStatus(App.resourceManager.GetString("start_downloading")); WebClientAuth webClient = new WebClientAuth(); webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(LauncherWebClient_DownloadProgressChanged); webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(LauncherWebClient_DownloadFileCompleted); string tempLauncherFilename = Path.GetTempFileName(); Debug.WriteLine(tempLauncherFilename); string launcher_filename = "AyalaLauncher.exe"; string launcher_uri = Settings.LauncherPatchesURL + launcher_filename; launcherDownloadEvent.Reset(); try { webClient.DownloadFileAsync(new Uri(launcher_uri), tempLauncherFilename, launcher_filename); } catch (Exception ex) { e.Cancel = true; MBError(ex.Message + "\n" + ex.StackTrace); return; } launcherDownloadEvent.WaitOne(); if (launcherDownloadingException != null) { WebException webex = (WebException)launcherDownloadingException; HttpWebResponse response = (HttpWebResponse)webex.Response; e.Cancel = true; MBError(String.Format( "{0}\nMessage: {1}\nRequest: {2}\nResponse: {3}", App.resourceManager.GetString("cant_get_patch"), webex.Message, (response != null ? response.ResponseUri.ToString() : "null"), (response != null ? response.StatusDescription : "null") )); return; } try { LauncherUpdater.RenameRunningLauncher(); LauncherUpdater.CopyNewLauncher(tempLauncherFilename); } catch (Exception ex) { MBError(String.Format(App.resourceManager.GetString("unknown_exception"), ex.Message, ex.StackTrace)); e.Cancel = true; return; } finally { LauncherUpdater.RestartToNewLauncher(); } File.Delete(tempLauncherFilename); } }
public MainWindow() { try { // Wire any unhandled crashing exceptions to log before exiting AppDomain.CurrentDomain.UnhandledException += (sender, e) => { // Don't do any special logging side effects Utils.LogStraightToFile("Error."); Utils.LogStraightToFile(((Exception)e.ExceptionObject).ToString()); Environment.Exit(-1); }; Utils.Log($"Wabbajack Build - {ThisAssembly.Git.Sha}"); Utils.Log($"Running in {AbsolutePath.EntryPoint}"); var p = SystemParametersConstructor.Create(); Utils.Log($"Detected Windows Version: {p.WindowsVersion}"); if (!(p.WindowsVersion.Major >= 10 && p.WindowsVersion.Minor >= 0)) { Utils.Log( $"You are not running a recent version of Windows (version 10 or greater), Wabbajack is not supported on OS versions older than Windows 10."); } Utils.Log( $"System settings - ({p.SystemMemorySize.ToFileSizeString()} RAM) ({p.SystemPageSize.ToFileSizeString()} Page), Display: {p.ScreenWidth} x {p.ScreenHeight} ({p.VideoMemorySize.ToFileSizeString()} VRAM - VideoMemorySizeMb={p.EnbLEVRAMSize})"); if (p.SystemPageSize == 0) { Utils.Log("Pagefile is disabled! Consider increasing to 20000MB. A disabled pagefile can cause crashes and poor in-game performance."); } else if (p.SystemPageSize < 2e+10) { Utils.Log("Pagefile below recommended! Consider increasing to 20000MB. A suboptimal pagefile can cause crashes and poor in-game performance."); } Warmup(); var _ = LauncherUpdater.Run(); var(settings, loadedSettings) = MainSettings.TryLoadTypicalSettings().AsTask().Result; // Load settings if (CLIArguments.NoSettings || !loadedSettings) { _settings = new MainSettings { Version = Consts.SettingsVersion }; RunWhenLoaded(DefaultSettings); } else { _settings = settings; RunWhenLoaded(LoadSettings); } // Set datacontext _mwvm = new MainWindowVM(this, _settings); DataContext = _mwvm; // Bring window to the front if it isn't already this.Initialized += (s, e) => { this.Activate(); this.Topmost = true; this.Focus(); }; this.ContentRendered += (s, e) => { this.Topmost = false; }; } catch (Exception ex) { Utils.LogStraightToFile("Error"); Utils.LogStraightToFile(ex.ToString()); Environment.Exit(-1); } }