Ejemplo n.º 1
0
        private static void 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{Config.GetLocalLauncherVersion()} starting...");
            Log.Info($"Current platform: {ConfigHandler.GetCurrentPlatform()} ({(Environment.Is64BitOperatingSystem ? "x64" : "x86")})");

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

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

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

            // Run the GTK UI
            Gtk.Application.Init();
            MainWindow win = new MainWindow();

            win.Show();
            win.Initialize();
            Gtk.Application.Run();
        }
Ejemplo n.º 2
0
        private static void Main()
        {
            // Bind any unhandled exceptions in the main thread so that they are logged.
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

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

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

            if (ChecksHandler.IsRunningOnUnix())
            {
                Log.Info("Initializing GTK UI.");
                RunUnixInterface();
            }
            else
            {
                Log.Info("Initializing WinForms UI.");
                RunWindowsInterface();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates the update script on disk.
        /// </summary>
        /// <returns>ProcessStartInfo for the update script.</returns>
        private static ProcessStartInfo CreateUpdateScript()
        {
            try
            {
                //maintain the executable name if it was renamed to something other than 'Launchpad'
                string fullName       = Assembly.GetEntryAssembly().Location;
                string executableName = Path.GetFileName(fullName);                 // should be "Launchpad", unless the user has renamed it

                if (ChecksHandler.IsRunningOnUnix())
                {
                    //creating a .sh script
                    string scriptPath = String.Format(@"{0}launchpadupdate.sh",
                                                      ConfigHandler.GetTempDir());


                    FileStream updateScript = File.Create(scriptPath);
                    TextWriter tw           = new StreamWriter(updateScript);

                    //write commands to the script
                    //wait five seconds, then copy the new executable
                    string copyCom = String.Format("cp -rf {0} {1}",
                                                   ConfigHandler.GetTempDir() + "launchpad/*",
                                                   ConfigHandler.GetLocalDir());

                    string delCom = String.Format("rm -rf {0}",
                                                  ConfigHandler.GetTempDir() + "launchpad");

                    string dirCom    = String.Format("cd {0}", ConfigHandler.GetLocalDir());
                    string launchCom = String.Format(@"nohup ./{0} &", executableName);
                    tw.WriteLine(@"#!/bin/sh");
                    tw.WriteLine("sleep 5");
                    tw.WriteLine(copyCom);
                    tw.WriteLine(delCom);
                    tw.WriteLine(dirCom);
                    tw.WriteLine("chmod +x " + executableName);
                    tw.WriteLine(launchCom);
                    tw.Close();

                    UnixHandler.MakeExecutable(scriptPath);


                    //Now create some ProcessStartInfo for this script
                    ProcessStartInfo updateShellProcess = new ProcessStartInfo();

                    updateShellProcess.FileName               = scriptPath;
                    updateShellProcess.UseShellExecute        = false;
                    updateShellProcess.RedirectStandardOutput = false;
                    updateShellProcess.WindowStyle            = ProcessWindowStyle.Hidden;

                    return(updateShellProcess);
                }
                else
                {
                    //creating a .bat script
                    string scriptPath = String.Format(@"{0}launchpadupdate.bat",
                                                      ConfigHandler.GetTempDir());

                    FileStream updateScript = File.Create(scriptPath);

                    TextWriter tw = new StreamWriter(updateScript);

                    //write commands to the script
                    //wait three seconds, then copy the new executable
                    tw.WriteLine(String.Format(@"timeout 3 & xcopy /e /s /y ""{0}\launchpad"" ""{1}"" && rmdir /s /q {0}\launchpad",
                                               ConfigHandler.GetTempDir(),
                                               ConfigHandler.GetLocalDir()));

                    //then start the new executable
                    tw.WriteLine(String.Format(@"start {0}", executableName));
                    tw.Close();

                    ProcessStartInfo updateBatchProcess = new ProcessStartInfo();

                    updateBatchProcess.FileName               = scriptPath;
                    updateBatchProcess.UseShellExecute        = true;
                    updateBatchProcess.RedirectStandardOutput = false;
                    updateBatchProcess.WindowStyle            = ProcessWindowStyle.Hidden;

                    return(updateBatchProcess);
                }
            }
            catch (IOException ioex)
            {
                Console.WriteLine("IOException in CreateUpdateScript(): " + ioex.Message);

                return(null);
            }
        }
Ejemplo n.º 4
0
        public MainForm()
        {
            InitializeComponent();

            Config.Initialize();

            MessageLabel.Text          = LocalizationCatalog.GetString("idleString");
            downloadProgressLabel.Text = String.Empty;

            //set the window text to match the game name
            this.Text = "Launchpad - " + Config.GetGameName();

            //first of all, check if we can connect to the FTP server.
            if (!Checks.CanConnectToFTP())
            {
                MessageBox.Show(
                    this,
                    LocalizationCatalog.GetString("ftpConnectionFailureMessage"),
                    LocalizationCatalog.GetString("ftpConnectionFailureString"),
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error,
                    MessageBoxDefaultButton.Button1);

                MessageLabel.Text     = LocalizationCatalog.GetString("ftpConnectionFailureString");
                PrimaryButton.Text    = ":(";
                PrimaryButton.Enabled = false;
            }
            else
            {
                //if we can connect, proceed with the rest of our checks.
                if (ChecksHandler.IsInitialStartup())
                {
                    DialogResult shouldInstallHere = MessageBox.Show(
                        this,
                        String.Format(
                            LocalizationCatalog.GetString("initialStartupMessage"), ConfigHandler.GetLocalDir()),
                        LocalizationCatalog.GetString("infoTitle"),
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question,
                        MessageBoxDefaultButton.Button1);

                    if (shouldInstallHere == DialogResult.Yes)
                    {
                        //yes, install here
                        ConfigHandler.CreateUpdateCookie();
                    }
                    else
                    {
                        //no, don't install here
                        Environment.Exit(2);
                    }
                }


                if (bSendAnonStats)
                {
                    StatsHandler.SendUsageStats();
                }
                else
                {
                    Stream iconStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Launchpad.Launcher.Resources.RocketIcon.ico");
                    if (iconStream != null)
                    {
                        NotifyIcon noUsageStatsNotification = new NotifyIcon();
                        noUsageStatsNotification.Icon    = new System.Drawing.Icon(iconStream);
                        noUsageStatsNotification.Visible = true;

                        noUsageStatsNotification.BalloonTipTitle = LocalizationCatalog.GetString("infoTitle");
                        noUsageStatsNotification.BalloonTipText  = LocalizationCatalog.GetString("usageTitle");

                        noUsageStatsNotification.ShowBalloonTip(10000);
                    }
                }

                //load the changelog from the server
                Launcher.ChangelogDownloadFinished += OnChangelogDownloadFinished;
                Launcher.LoadChangelog();

                //Does the launcher need an update?
                if (!Checks.IsLauncherOutdated())
                {
                    if (Checks.IsManifestOutdated())
                    {
                        Launcher.DownloadManifest();
                    }

                    if (!Checks.IsGameInstalled())
                    {
                        SetLauncherMode(ELauncherMode.Install, false);
                    }
                    else
                    {
                        if (Checks.IsGameOutdated())
                        {
                            SetLauncherMode(ELauncherMode.Update, false);
                        }
                        else
                        {
                            SetLauncherMode(ELauncherMode.Launch, false);
                        }
                    }
                }
                else
                {
                    SetLauncherMode(ELauncherMode.Update, false);
                }
            }
        }
Ejemplo n.º 5
0
        public MainWindow() :
            base(WindowType.Toplevel)
        {
            //initialize localization
            Mono.Unix.Catalog.Init("Launchpad", "./locale");

            //Initialize the config files and check values.
            Config.Initialize();

            //Initialize the GTK UI
            this.Build();

            //set the window title
            Title = "Launchpad - " + Config.GetGameName();

            // Configure the WebView for our changelog
            Browser.SetSizeRequest(290, 300);

            scrolledwindow2.Add(Browser);
            scrolledwindow2.ShowAll();

            MessageLabel.Text = Mono.Unix.Catalog.GetString("Idle");

            //First of all, check if we can connect to the FTP server.
            if (!Checks.CanConnectToFTP())
            {
                MessageDialog dialog = new MessageDialog(
                    null,
                    DialogFlags.Modal,
                    MessageType.Warning,
                    ButtonsType.Ok,
                    Mono.Unix.Catalog.GetString("Failed to connect to the FTP server. Please check your FTP settings."));

                dialog.Run();
                dialog.Destroy();
                MessageLabel.Text = Mono.Unix.Catalog.GetString("Could not connect to server.");
            }
            else
            {
                //if we can connect, proceed with the rest of our checks.
                if (ChecksHandler.IsInitialStartup())
                {
                    MessageDialog shouldInstallHereDialog = new MessageDialog(
                        null,
                        DialogFlags.Modal,
                        MessageType.Question,
                        ButtonsType.OkCancel,
                        String.Format(Mono.Unix.Catalog.GetString(
                                          "This appears to be the first time you're starting the launcher.\n" +
                                          "Is this the location where you would like to install the game?" +
                                          "\n\n{0}"), ConfigHandler.GetLocalDir()
                                      ));

                    if (shouldInstallHereDialog.Run() == (int)ResponseType.Ok)
                    {
                        shouldInstallHereDialog.Destroy();
                        //yes, install here
                        Console.WriteLine("Installing in current directory.");
                        ConfigHandler.CreateUpdateCookie();
                    }
                    else
                    {
                        shouldInstallHereDialog.Destroy();
                        //no, don't install here
                        Console.WriteLine("Exiting...");
                        Environment.Exit(0);
                    }
                }

                if (bSendAnonStats)
                {
                    StatsHandler.SendUsageStats();
                }
                else
                {
                    Notification noUsageStatsNotification = new Notification();

                    noUsageStatsNotification.IconName = Stock.DialogWarning;
                    noUsageStatsNotification.Urgency  = Urgency.Normal;
                    noUsageStatsNotification.Summary  = Mono.Unix.Catalog.GetString("Launchpad - Warning");
                    noUsageStatsNotification.Body     = Mono.Unix.Catalog.GetString("Anonymous useage stats are not enabled.");

                    noUsageStatsNotification.Show();
                }


                //Start loading the changelog asynchronously
                Launcher.ChangelogDownloadFinished += OnChangelogDownloadFinished;
                Launcher.LoadChangelog();

                //if the launcher does not need an update at this point, we can continue checks for the game
                if (!Checks.IsLauncherOutdated())
                {
                    if (Checks.IsManifestOutdated())
                    {
                        Launcher.DownloadManifest();
                    }

                    if (!Checks.IsGameInstalled())
                    {
                        //if the game is not installed, offer to install it
                        Console.WriteLine("Not installed.");
                        SetLauncherMode(ELauncherMode.Install, false);
                    }
                    else
                    {
                        //if the game is installed (which it should be at this point), check if it needs to be updated
                        if (Checks.IsGameOutdated())
                        {
                            //if it does, offer to update it
                            Console.WriteLine("Game is outdated or not installed");
                            SetLauncherMode(ELauncherMode.Update, false);
                        }
                        else
                        {
                            //if not, enable launching the game
                            SetLauncherMode(ELauncherMode.Launch, false);
                        }
                    }
                }
                else
                {
                    //the launcher was outdated.
                    SetLauncherMode(ELauncherMode.Update, false);
                }
            }
        }