Ejemplo n.º 1
0
        private void ConnectBtn_Click(object sender, EventArgs e)
        {
            // Update the settings
            string ServerAndPort = ServerTextBox.Text.Trim();

            if (ServerAndPort.Length == 0)
            {
                ServerAndPort = null;
            }

            string UserName = UserNameTextBox.Text.Trim();

            if (UserName.Length == 0)
            {
                UserName = null;
            }

            string DepotPath = DepotPathTextBox.Text.Trim();

            if (DepotPath.Length == 0)
            {
                DepotPath = null;
            }

            Program.SaveSettings(ServerAndPort, UserName, DepotPath);

            // Create the task for connecting to this server
            StringWriter           Log             = new StringWriter();
            SyncAndRunPerforceTask SyncApplication = new SyncAndRunPerforceTask((Perforce, LogWriter) => SyncAndRun(Perforce, DepotPath, UseUnstableBuildCheckBox.Checked, LogWriter));

            // Attempt to sync through a modal dialog
            string          ErrorMessage;
            ModalTaskResult Result = PerforceModalTask.Execute(this, null, ServerAndPort, UserName, SyncApplication, "Updating", "Checking for updates, please wait...", Log, out ErrorMessage);

            if (Result == ModalTaskResult.Succeeded)
            {
                Program.SaveSettings(ServerAndPort, UserName, DepotPath);
                DialogResult = DialogResult.OK;
                Close();
            }

            if (ErrorMessage != null)
            {
                PromptLabel.Text = ErrorMessage;
            }

            LogText            = Log.ToString();
            ViewLogBtn.Visible = true;
        }
Ejemplo n.º 2
0
        public bool Run(out string ErrorMessage)
        {
            if (!PerforceModalTask.TryGetServerSettings(null, ref ServerAndPort, ref UserName, LogWriter))
            {
                ErrorMessage = "Unable to get Perforce settings.";
                return(false);
            }

            PerforceConnection Perforce = new PerforceConnection(UserName, null, ServerAndPort);

            if (!SyncAndRun(Perforce, LogWriter))
            {
                ErrorMessage = "Unable to sync and run application.";
                return(false);
            }

            ErrorMessage = null;
            return(true);
        }
Ejemplo n.º 3
0
        static int Main(string[] Args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            bool bFirstInstance;

            using (Mutex InstanceMutex = new Mutex(true, "UnrealGameSyncRunning", out bFirstInstance))
            {
                if (!bFirstInstance)
                {
                    using (EventWaitHandle ActivateEvent = new EventWaitHandle(false, EventResetMode.AutoReset, "ActivateUnrealGameSync"))
                    {
                        ActivateEvent.Set();
                    }
                    return(0);
                }

                // Try to find Perforce in the path
                string PerforceFileName = null;
                foreach (string PathDirectoryName in (Environment.GetEnvironmentVariable("PATH") ?? "").Split(new char[] { Path.PathSeparator }, StringSplitOptions.RemoveEmptyEntries))
                {
                    try
                    {
                        string PossibleFileName = Path.Combine(PathDirectoryName, "p4.exe");
                        if (File.Exists(PossibleFileName))
                        {
                            PerforceFileName = PossibleFileName;
                            break;
                        }
                    }
                    catch { }
                }

                // If it doesn't exist, don't continue
                if (PerforceFileName == null)
                {
                    MessageBox.Show("UnrealGameSync requires the Perforce command-line tools. Please download and install from http://www.perforce.com/.");
                    return(1);
                }

                // Figure out if we should sync the unstable build by default
                bool bUnstable = Args.Contains("-unstable", StringComparer.InvariantCultureIgnoreCase);

                // Read the settings
                string ServerAndPort = null;
                string UserName      = null;
                string DepotPath     = DeploymentSettings.DefaultDepotPath;
                Utility.ReadGlobalPerforceSettings(ref ServerAndPort, ref UserName, ref DepotPath);

                // If the shift key is held down, immediately show the settings window
                if ((Control.ModifierKeys & Keys.Shift) != 0)
                {
                    // Show the settings window immediately
                    SettingsWindow UpdateError = new SettingsWindow(null, null, ServerAndPort, UserName, DepotPath, bUnstable, (Perforce, DepotParam, bUnstableParam, LogWriter) => SyncAndRun(Perforce, DepotParam, bUnstableParam, Args, InstanceMutex, LogWriter));
                    if (UpdateError.ShowDialog() == DialogResult.OK)
                    {
                        return(0);
                    }
                }
                else
                {
                    // Try to do a sync with the current settings first
                    StringWriter           Log             = new StringWriter();
                    SyncAndRunPerforceTask SyncApplication = new SyncAndRunPerforceTask((Perforce, LogWriter) => SyncAndRun(Perforce, DepotPath, bUnstable, Args, InstanceMutex, LogWriter));

                    string ErrorMessage;
                    if (PerforceModalTask.Execute(null, new PerforceConnection(UserName, null, ServerAndPort), SyncApplication, "Updating", "Checking for updates, please wait...", Log, out ErrorMessage) == ModalTaskResult.Succeeded)
                    {
                        return(0);
                    }

                    SettingsWindow UpdateError = new SettingsWindow("Unable to update UnrealGameSync from Perforce. Verify that your connection settings are correct.", Log.ToString(), ServerAndPort, UserName, DepotPath, bUnstable, (Perforce, DepotParam, bUnstableParam, LogWriter) => SyncAndRun(Perforce, DepotParam, bUnstableParam, Args, InstanceMutex, LogWriter));
                    if (UpdateError.ShowDialog() == DialogResult.OK)
                    {
                        return(0);
                    }
                }
            }
            return(1);
        }