Ejemplo n.º 1
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);
                }

                StringWriter LogWriter = new StringWriter();

                bool bResult = false;
                try
                {
                    bResult = SyncAndRunApplication(Args, InstanceMutex, LogWriter);
                }
                catch (Exception Ex)
                {
                    LogWriter.WriteLine(Ex.ToString());
                }

                if (!bResult)
                {
                    UpdateErrorWindow ErrorWindow = new UpdateErrorWindow(LogWriter.ToString());
                    ErrorWindow.ShowDialog();
                    return(2);
                }
            }

            return(0);
        }
Ejemplo n.º 2
0
        static int Main(string[] Args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            bool bFirstInstance;

            using (Mutex InstanceMutex = new Mutex(true, "UnrealGameSyncRunning", out bFirstInstance))
            {
                if (!bFirstInstance)
                {
                    MessageBox.Show("UnrealGameSync is already running. Please close any existing instances.");
                    return(1);
                }

                StringWriter LogWriter = new StringWriter();

                bool bResult = false;
                try
                {
                    bResult = SyncAndRunApplication(Args, InstanceMutex, LogWriter);
                }
                catch (Exception Ex)
                {
                    LogWriter.WriteLine(Ex.ToString());
                }

                if (!bResult)
                {
                    UpdateErrorWindow ErrorWindow = new UpdateErrorWindow(LogWriter.ToString());
                    ErrorWindow.ShowDialog();
                    return(2);
                }
            }

            return(0);
        }
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)
				{
					MessageBox.Show("UnrealGameSync is already running. Please close any existing instances.");
					return 1;
				}

				StringWriter LogWriter = new StringWriter();

				bool bResult = false;
				try
				{
					bResult = SyncAndRunApplication(Args, InstanceMutex, LogWriter);
				}
				catch(Exception Ex)
				{
					LogWriter.WriteLine(Ex.ToString());
				}

				if(!bResult)
				{
					UpdateErrorWindow ErrorWindow = new UpdateErrorWindow(LogWriter.ToString());
					ErrorWindow.ShowDialog();
					return 2;
				}
			}

			return 0;
		}
Ejemplo n.º 4
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);
                }

                string Server    = null;
                string DepotPath = DefaultDepotPath;

                ReadSettings(ref Server, ref DepotPath);

                for (;;)
                {
                    StringWriter LogWriter = new StringWriter();
                    LogWriter.WriteLine("Attempting to sync UnrealGameSync...");

                    if (!String.IsNullOrEmpty(DepotPath))
                    {
                        try
                        {
                            if (SyncAndRunApplication(Args, InstanceMutex, PerforceFileName, Server, DepotPath, LogWriter))
                            {
                                break;
                            }
                        }
                        catch (Exception Ex)
                        {
                            LogWriter.WriteLine(Ex.ToString());
                        }
                    }

                    string DefaultServer = null;
                    if (String.IsNullOrEmpty(Server))
                    {
                        List <string> Lines = new List <string>();
                        RunPerforceCommand(PerforceFileName, "set P4PORT", Lines, new StringWriter());

                        if (Lines.Count >= 1 && Lines[0].StartsWith("P4PORT="))
                        {
                            DefaultServer = Lines[0].Substring(7).Split(' ')[0];
                            Server        = DefaultServer;
                        }
                    }

                    UpdateErrorWindow ErrorWindow = new UpdateErrorWindow(LogWriter.ToString(), Server, DepotPath);
                    if (ErrorWindow.ShowDialog() != DialogResult.OK)
                    {
                        return(2);
                    }

                    Server    = (DefaultServer != null && String.Equals(ErrorWindow.Server, DefaultServer, StringComparison.InvariantCultureIgnoreCase))? null : ErrorWindow.Server;
                    DepotPath = ErrorWindow.DepotPath;

                    SaveSettings(Server, DepotPath);
                }
            }
            return(0);
        }