Exemplo n.º 1
0
        public static int Main(string[] args)
        {
            LegacyFilesystemReader.Register();

            // Back up the cwd before DesktopGameHost changes it
            var cwd = Environment.CurrentDirectory;

            using (DesktopGameHost host = Host.GetSuitableHost(@"osu", true))
            {
                if (!host.IsPrimaryInstance)
                {
                    var importer = new BeatmapImporter(host);
                    // Restore the cwd so relative paths given at the command line work correctly
                    Directory.SetCurrentDirectory(cwd);
                    foreach (var file in args)
                    {
                        Console.WriteLine(@"Importing {0}", file);
                        if (!importer.ImportAsync(Path.GetFullPath(file)).Wait(3000))
                        {
                            throw new TimeoutException(@"IPC took too long to send");
                        }
                    }
                }
                else
                {
                    Ruleset.Register(new OsuRuleset());
                    Ruleset.Register(new TaikoRuleset());
                    Ruleset.Register(new ManiaRuleset());
                    Ruleset.Register(new CatchRuleset());

                    host.Run(new OsuGameDesktop(args));
                }
                return(0);
            }
        }
Exemplo n.º 2
0
        public void TestImportOverIPC()
        {
            using (HeadlessGameHost host = new HeadlessGameHost("host", true))
                using (HeadlessGameHost client = new HeadlessGameHost("client", true))
                {
                    Assert.IsTrue(host.IsPrimaryInstance);
                    Assert.IsTrue(!client.IsPrimaryInstance);

                    var osu = loadOsu(host);

                    var temp = prepareTempCopy(osz_path);

                    Assert.IsTrue(File.Exists(temp));

                    var importer = new BeatmapImporter(client);
                    if (!importer.ImportAsync(temp).Wait(1000))
                    {
                        Assert.Fail(@"IPC took too long to send");
                    }

                    ensureLoaded(osu);

                    Assert.IsFalse(File.Exists(temp));
                }
        }