Exemple #1
0
        /// <summary>
        /// Gets the remote game version.
        /// </summary>
        /// <returns>The remote game version.</returns>
        public Version GetRemoteGameVersion(bool bUseSystemTarget)
        {
            string remoteVersionPath = "";

            if (bUseSystemTarget)
            {
                remoteVersionPath = String.Format("{0}/game/{1}/bin/GameVersion.txt",
                                                  Config.GetFTPUrl(),
                                                  Config.GetSystemTarget());
            }
            else
            {
                remoteVersionPath = String.Format("{0}/game/bin/GameVersion.txt",
                                                  Config.GetFTPUrl());
            }
            string remoteVersion = ReadFTPFile(remoteVersionPath);

            if (!string.IsNullOrEmpty(remoteVersion))
            {
                return(Version.Parse(remoteVersion));
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
        /// <summary>
        /// Sends the usage stats to the official launchpad server.
        /// </summary>
        static public void SendUsageStats()
        {
            WebRequest sendStatsRequest = null;

            try
            {
                string baseURL      = "http://directorate.asuscomm.com/launchpad/stats.php?";
                string formattedURL = String.Format(baseURL + "guid={0}&launcherVersion={1}&gameName={2}&systemType={3}&officialUpdates={4}",
                                                    Config.GetGUID(),
                                                    Config.GetLocalLauncherVersion(),
                                                    Config.GetGameName(),
                                                    Config.GetSystemTarget().ToString(),
                                                    Config.GetDoOfficialUpdates().ToString()
                                                    );


                sendStatsRequest = WebRequest.Create(formattedURL);
                sendStatsRequest.GetResponse();
            }
            catch (WebException wex)
            {
                Console.WriteLine("WebException in SendUsageStats(): " + wex.Message);
            }
            finally
            {
                sendStatsRequest.Abort();
            }
        }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Launchpad.SettingsDialog"/> class.
        /// </summary>
        public SettingsDialog()
        {
            this.Build();
            //fill in Local settings
            GameName_entry.Text = Config.GetGameName();

            combobox_SystemTarget.Active = (int)Config.GetSystemTarget();

            //fill in remote settings
            FTPURL_entry.Text      = Config.GetBaseFTPUrl();
            FTPUsername_entry.Text = Config.GetFTPUsername();
            FTPPassword_entry.Text = Config.GetFTPPassword();

            progressbar3.Text  = Mono.Unix.Catalog.GetString("Idle");
            buttonOk.Label     = Mono.Unix.Catalog.GetString("OK");
            buttonCancel.Label = Mono.Unix.Catalog.GetString("Cancel");
        }
Exemple #4
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 mainButton_Click(object sender, EventArgs e)
        {
            switch (Mode)
            {
            case ELauncherMode.Repair:
            {
                //bind events for UI updating
                Game.ProgressChanged    += OnGameDownloadProgressChanged;
                Game.GameRepairFinished += OnRepairFinished;
                Game.GameDownloadFailed += OnGameDownloadFailed;

                if (Checks.DoesServerProvidePlatform(Config.GetSystemTarget()))
                {
                    //repair the game asynchronously
                    Game.RepairGame();
                    SetLauncherMode(ELauncherMode.Repair, true);
                }
                else
                {
                    //whoops, the server doesn't provide the game for the platform we requested (usually the on we're running on)
                    //alert the user and revert back to the default install mode
                    Stream iconStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Launchpad.Launcher.Resources.RocketIcon.ico");
                    if (iconStream != null)
                    {
                        NotifyIcon platformNotProvidedNotification = new NotifyIcon();
                        platformNotProvidedNotification.Icon    = new System.Drawing.Icon(iconStream);
                        platformNotProvidedNotification.Visible = true;

                        platformNotProvidedNotification.BalloonTipTitle = LocalizationCatalog.GetString("noPlatformTitle");
                        platformNotProvidedNotification.BalloonTipText  = LocalizationCatalog.GetString("noPlatformMessage");

                        platformNotProvidedNotification.ShowBalloonTip(10000);
                    }

                    SetLauncherMode(ELauncherMode.Install, false);
                }
                break;
            }

            case ELauncherMode.Install:
            {
                //bind events for UI updating
                Game.ProgressChanged      += OnGameDownloadProgressChanged;
                Game.GameDownloadFinished += OnGameDownloadFinished;
                Game.GameDownloadFailed   += OnGameDownloadFailed;

                if (Checks.DoesServerProvidePlatform(Config.GetSystemTarget()))
                {
                    //install the game asynchronously
                    MessageLabel.Text = LocalizationCatalog.GetString("installingLabel");
                    SetLauncherMode(ELauncherMode.Install, true);
                    Game.InstallGame();
                }
                else
                {
                    //whoops, the server doesn't provide the game for the platform we requested (usually the on we're running on)
                    //alert the user and revert back to the default install mode
                    Stream iconStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Launchpad.Launcher.Resources.RocketIcon.ico");
                    if (iconStream != null)
                    {
                        NotifyIcon platformNotProvidedNotification = new NotifyIcon();
                        platformNotProvidedNotification.Icon    = new System.Drawing.Icon(iconStream);
                        platformNotProvidedNotification.Visible = true;

                        platformNotProvidedNotification.BalloonTipTitle = LocalizationCatalog.GetString("noPlatformTitle");
                        platformNotProvidedNotification.BalloonTipText  = LocalizationCatalog.GetString("noPlatformMessage");

                        platformNotProvidedNotification.ShowBalloonTip(10000);
                    }

                    MessageLabel.Text = LocalizationCatalog.GetString("noPlatformMessage");

                    SetLauncherMode(ELauncherMode.Install, false);
                }

                break;
            }

            case ELauncherMode.Update:
            {
                //bind events for UI updating
                Game.ProgressChanged      += OnGameDownloadProgressChanged;
                Game.GameDownloadFinished += OnGameDownloadFinished;
                Game.GameDownloadFailed   += OnGameDownloadFailed;

                if (Checks.IsLauncherOutdated())
                {
                    //update the launcher synchronously.
                    SetLauncherMode(ELauncherMode.Update, true);
                    Launcher.UpdateLauncher();
                }
                else
                {
                    if (Checks.DoesServerProvidePlatform(Config.GetSystemTarget()))
                    {
                        //update the game asynchronously
                        SetLauncherMode(ELauncherMode.Update, true);
                        Game.UpdateGame();
                    }
                    else
                    {
                        //whoops, the server doesn't provide the game for the platform we requested (usually the on we're running on)
                        //alert the user and revert back to the default install mode
                        Stream iconStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Launchpad.Launcher.Resources.RocketIcon.ico");
                        if (iconStream != null)
                        {
                            NotifyIcon platformNotProvidedNotification = new NotifyIcon();
                            platformNotProvidedNotification.Icon    = new System.Drawing.Icon(iconStream);
                            platformNotProvidedNotification.Visible = true;

                            platformNotProvidedNotification.BalloonTipTitle = LocalizationCatalog.GetString("noPlatformTitle");
                            platformNotProvidedNotification.BalloonTipText  = LocalizationCatalog.GetString("noPlatformMessage");

                            platformNotProvidedNotification.ShowBalloonTip(10000);
                        }

                        SetLauncherMode(ELauncherMode.Install, false);
                    }
                }

                break;
            }

            case ELauncherMode.Launch:
            {
                Game.GameLaunchFailed += OnGameLaunchFailed;
                Game.GameExited       += OnGameExited;

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

                break;
            }

            default:
            {
                Console.WriteLine("No functionality for this mode.");
                break;
            }
            }
        }
Exemple #5
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>
        protected void OnPrimaryButtonClicked(object sender, EventArgs e)
        {
            switch (Mode)
            {
            case ELauncherMode.Repair:
            {
                //bind events for UI updating
                Game.ProgressChanged    += OnGameDownloadProgressChanged;
                Game.GameRepairFinished += OnRepairFinished;
                Game.GameDownloadFailed += OnGameDownloadFailed;

                if (Checks.DoesServerProvidePlatform(Config.GetSystemTarget()))
                {
                    //install the game asynchronously
                    SetLauncherMode(ELauncherMode.Repair, true);
                    Game.RepairGame();
                }
                else
                {
                    Notification noProvide = new Notification();
                    noProvide.IconName = Stock.DialogError;
                    noProvide.Summary  = Mono.Unix.Catalog.GetString("Launchpad - Platform not provided!");
                    noProvide.Body     = Mono.Unix.Catalog.GetString("The server does not provide the game for the selected platform.");
                    noProvide.Show();

                    SetLauncherMode(ELauncherMode.Install, false);
                }
                break;
            }

            case ELauncherMode.Install:
            {
                //bind events for UI updating
                Game.ProgressChanged      += OnGameDownloadProgressChanged;
                Game.GameDownloadFinished += OnGameDownloadFinished;
                Game.GameDownloadFailed   += OnGameDownloadFailed;

                //check for a .provides file in the platform directory on the server
                //if there is none, the server does not provide a game for that platform
                if (Checks.DoesServerProvidePlatform(Config.GetSystemTarget()))
                {
                    //install the game asynchronously
                    SetLauncherMode(ELauncherMode.Install, true);
                    Game.InstallGame();
                }
                else
                {
                    Notification noProvide = new Notification();
                    noProvide.IconName = Stock.DialogError;
                    noProvide.Summary  = Mono.Unix.Catalog.GetString("Launchpad - Platform not provided!");
                    noProvide.Body     = Mono.Unix.Catalog.GetString("The server does not provide the game for the selected platform.");
                    noProvide.Show();

                    SetLauncherMode(ELauncherMode.Install, false);
                }
                break;
            }

            case ELauncherMode.Update:
            {
                if (Checks.IsLauncherOutdated())
                {
                    SetLauncherMode(ELauncherMode.Update, true);
                    Launcher.UpdateLauncher();
                }
                else
                {
                    //bind events for UI updating
                    Game.GameDownloadFinished += OnGameDownloadFinished;
                    Game.ProgressChanged      += OnGameDownloadProgressChanged;
                    Game.GameDownloadFailed   += OnGameDownloadFailed;

                    //update the game asynchronously
                    if (Checks.DoesServerProvidePlatform(Config.GetSystemTarget()))
                    {
                        //install the game asynchronously
                        SetLauncherMode(ELauncherMode.Update, true);
                        Game.UpdateGame();
                    }
                    else
                    {
                        Notification noProvide = new Notification();
                        noProvide.IconName = Stock.DialogError;
                        noProvide.Summary  = Mono.Unix.Catalog.GetString("Launchpad - Platform not provided!");
                        noProvide.Body     = Mono.Unix.Catalog.GetString("The server does not provide the game for the selected platform.");
                        noProvide.Show();

                        SetLauncherMode(ELauncherMode.Install, false);
                    }
                }
                break;
            }

            case ELauncherMode.Launch:
            {
                Game.GameLaunchFailed += OnGameLaunchFailed;
                Game.GameExited       += OnGameExited;

                //events such as LaunchFailed can fire before this has finished
                //thus, we set the mode before the actual launching of the game.
                SetLauncherMode(ELauncherMode.Launch, true);
                Game.LaunchGame();

                break;
            }

            default:
            {
                Console.WriteLine("No functionality for this mode.");
                break;
            }
            }
        }