示例#1
0
        private static void startup(string[] args)
        {
            //we can use the argument as the full path if it contains folders.
            //this is faster but not always available.
            string path = args[0].Trim('"');

            if (path.IndexOf(Path.DirectorySeparatorChar) >= 0)
            {
                fullPath = path;
            }

            if (args.Length > 1)
            {
                if (handleArgs(ref args))
                {
                    return;
                }
            }

            bool hasTournamentConfig = File.Exists(Tournament.CONFIG_FILENAME);
            bool hasDrawingsConfig   = File.Exists(Drawings.CONFIG_FILENAME);

            string fileArgs = args.Length > 1 ? string.Join(@" ", args, 1, args.Length - 1) : null;

            bool allowMultipleInstances = fileArgs != null || AllowMultipleInstances || hasTournamentConfig;

            try
            {
                try
                {
                    if (!allowMultipleInstances)
                    {
                        //attempt a wake-up if an existing osu! client is running.
                        InterProcessOsu osu = IPC.GetRunningOsu();
                        if (osu != null && osu.WakeUp())
                        {
                            return;
                        }
                    }
                }
                catch { }

                using (SingleInstance instance = new SingleInstance(ClientGuid, allowMultipleInstances ? -1 : 5000))
                {
                    try
                    {
                        if (!instance.IsFirstInstance && fileArgs != null)
                        {
                            IPC.HandleArguments(fileArgs);
                            return;
                        }

                        runGame(fileArgs, hasTournamentConfig && !GameBase.Tournament, hasDrawingsConfig);
                    }
                    catch (BadImageFormatException e)
                    {
                        handleBadImageFormat(e);
                    }
#if !DEBUG
                    catch { }
#endif
                }
            }
            catch (TooManyInstancesException)
            {
            }

            exitOrRestart();
        }