示例#1
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        private static void Main()
        {
            // Bind any unhandled exceptions in the main thread so that they are logged.
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            // Set correct working directory for compatibility with double-clicking
            Directory.SetCurrentDirectory(DirectoryHelpers.GetLocalLauncherDirectory());

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                Environment.SetEnvironmentVariable("GTK_EXE_PREFIX", Directory.GetCurrentDirectory());
                Environment.SetEnvironmentVariable("GTK_DATA_PREFIX", Directory.GetCurrentDirectory());
                Environment.SetEnvironmentVariable("GSETTINGS_SCHEMA_DIR", "share\\glib-2.0\\schemas\\");
            }
            Log.Info($"\n\n\n");
            Log.Info($"----------------------------------------------------------------------------");
            Log.Info($"Launching Youcanevent launcher {System.DateTime.Now}");
            Log.Info($"Launchpad v{LocalVersionService.GetLocalLauncherVersion()} starting...");

            var systemBitness  = Environment.Is64BitOperatingSystem ? "x64" : "x86";
            var processBitness = Environment.Is64BitProcess ? "64-bit" : "32-bit";

            Log.Info($"Current platform: {PlatformHelpers.GetCurrentPlatform()} ({systemBitness} platform, {processBitness} process)");

            Log.Info("Initializing UI...");

            // Bind any unhandled exceptions in the GTK UI so that they are logged.
            ExceptionManager.UnhandledException += OnGLibUnhandledException;

            // Run the GTK UI
            Gtk.Application.Init();

            var win = MainWindow.Create();

            win.Show();

            Timeout.Add
            (
                50,
                () =>
            {
                Task.Factory.StartNew
                (
                    () => win.InitializeAsync(),
                    CancellationToken.None,
                    TaskCreationOptions.DenyChildAttach,
                    TaskScheduler.FromCurrentSynchronizationContext()
                );
                return(false);
            }
            );

            Gtk.Application.Run();
        }
示例#2
0
        private static async Task Main()
        {
            // Bind any unhandled exceptions in the main thread so that they are logged.
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            log4net.Config.XmlConfigurator.Configure();

            Log.Info("----------------");
            Log.Info($"Launchpad v{LocalVersionService.GetLocalLauncherVersion()} starting...");
            Log.Info($"Current platform: {PlatformHelpers.GetCurrentPlatform()} ({(Environment.Is64BitOperatingSystem ? "x64" : "x86")})");

            // Set correct working directory for compatibility with double-clicking
            Directory.SetCurrentDirectory(DirectoryHelpers.GetLocalLauncherDirectory());

            Log.Info("Initializing UI...");

            // Bind any unhandled exceptions in the GTK UI so that they are logged.
            ExceptionManager.UnhandledException += OnGLibUnhandledException;

            // Run the GTK UI
            Gtk.Application.Init();
            SynchronizationContext.SetSynchronizationContext(new GLibSynchronizationContext());

            var win = new MainWindow();

            win.Show();

            Timeout.Add
            (
                50,
                () =>
            {
                win.InitializeAsync();
                return(false);
            }
            );

            Gtk.Application.Run();
        }
示例#3
0
        /// <summary>
        /// Handles switching between different functionalities depending on what is visible on the button to the user, such as
        /// * Installing
        /// * Updating
        /// * Repairing
        /// * Launching
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">Empty arguments.</param>
        private void OnMainButtonClicked(object sender, EventArgs e)
        {
            // Drop out if the current platform isn't available on the server
            if (!this.Checks.IsPlatformAvailable(this.Configuration.SystemTarget))
            {
                this.StatusLabel.Text =
                    LocalizationCatalog.GetString("The server does not provide the game for the selected platform.");
                this.MainProgressBar.Text = string.Empty;

                Log.Info
                (
                    $"The server does not provide files for platform \"{PlatformHelpers.GetCurrentPlatform()}\". " +
                    "A .provides file must be present in the platforms' root directory."
                );

                SetLauncherMode(ELauncherMode.Inactive, false);

                return;
            }

            // else, run the relevant function
            switch (this.Mode)
            {
            case ELauncherMode.Repair:
            {
                // Repair the game asynchronously
                SetLauncherMode(ELauncherMode.Repair, true);
                this.Game.VerifyGame();

                break;
            }

            case ELauncherMode.Install:
            {
                // Install the game asynchronously
                SetLauncherMode(ELauncherMode.Install, true);
                this.Game.InstallGame();

                break;
            }

            case ELauncherMode.Update:
            {
                if (this.Checks.IsLauncherOutdated())
                {
                    // Update the launcher asynchronously
                    SetLauncherMode(ELauncherMode.Update, true);
                    this.Launcher.UpdateLauncher();
                }
                else
                {
                    // Update the game asynchronously
                    SetLauncherMode(ELauncherMode.Update, true);
                    this.Game.UpdateGame();
                }

                break;
            }

            case ELauncherMode.Launch:
            {
                this.StatusLabel.Text     = LocalizationCatalog.GetString("Idle");
                this.MainProgressBar.Text = string.Empty;

                SetLauncherMode(ELauncherMode.Launch, true);
                this.Game.LaunchGame();

                break;
            }

            default:
            {
                Log.Warn("The main button was pressed with an invalid active mode. No functionality has been defined for this mode.");
                break;
            }
            }
        }
示例#4
0
        /// <summary>
        /// Initializes the UI of the launcher, performing varying checks against the patching server.
        /// </summary>
        /// <returns>A task that must be awaited.</returns>
        public Task InitializeAsync()
        {
            if (this.IsInitialized)
            {
                return(Task.CompletedTask);
            }

            // First of all, check if we can connect to the patching service.
            if (!this.Checks.CanPatch())
            {
                var dialog = new MessageDialog
                             (
                    this,
                    DialogFlags.Modal,
                    MessageType.Warning,
                    ButtonsType.Ok,
                    LocalizationCatalog.GetString("Failed to connect to the patch server. Please check your settings.")
                             );

                dialog.Run();

                dialog.Destroy();
                this.StatusLabel.Text         = LocalizationCatalog.GetString("Could not connect to server.");
                this.MenuRepairItem.Sensitive = false;
            }
            else
            {
                LoadBanner();

                LoadChangelog();

                // If we can connect, proceed with the rest of our checks.
                if (ChecksHandler.IsInitialStartup())
                {
                    DisplayInitialStartupDialog();
                }

                // If the launcher does not need an update at this point, we can continue checks for the game
                if (!this.Checks.IsLauncherOutdated())
                {
                    if (!this.Checks.IsPlatformAvailable(this.Configuration.SystemTarget))
                    {
                        Log.Info
                        (
                            $"The server does not provide files for platform \"{PlatformHelpers.GetCurrentPlatform()}\". " +
                            "A .provides file must be present in the platforms' root directory."
                        );

                        SetLauncherMode(ELauncherMode.Inactive, false);
                    }
                    else
                    {
                        if (!this.Checks.IsGameInstalled())
                        {
                            // If the game is not installed, offer to install it
                            Log.Info("The game has not yet been installed.");
                            SetLauncherMode(ELauncherMode.Install, false);

                            // Since the game has not yet been installed, disallow manual repairs
                            this.MenuRepairItem.Sensitive = false;

                            // and reinstalls
                            this.MenuReinstallItem.Sensitive = false;
                        }
                        else
                        {
                            // If the game is installed (which it should be at this point), check if it needs to be updated
                            if (this.Checks.IsGameOutdated())
                            {
                                // If it does, offer to update it
                                Log.Info("The game is outdated.");
                                SetLauncherMode(ELauncherMode.Update, false);
                            }
                            else
                            {
                                // All checks passed, so we can offer to launch the game.
                                Log.Info("All checks passed. Game can be launched.");
                                SetLauncherMode(ELauncherMode.Launch, false);
                            }
                        }
                    }
                }
                else
                {
                    // The launcher was outdated.
                    Log.Info($"The launcher is outdated. \n\tLocal version: {this.LocalVersionService.GetLocalLauncherVersion()}");
                    SetLauncherMode(ELauncherMode.Update, false);
                }
            }

            this.IsInitialized = true;
            return(Task.CompletedTask);
        }