예제 #1
0
    public static void Main(string[] args)
    {
        if (!Debugger.IsAttached)
        {
            AppDomain.CurrentDomain.UnhandledException += ReportUnhandledException;
        }

        var commandLineParser = new CommandLineApplication(false);
        var archiveOption     = commandLineParser.Option("--content", "content directory", CommandOptionType.SingleValue);

        commandLineParser.Execute(args);

        string contentPath;

        if (archiveOption.HasValue())
        {
            contentPath = archiveOption.Value();
        }
        else
        {
            contentPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "content");
        }

        var contentDir = new DirectoryInfo(contentPath);

        List <IArchiveDirectory> contentArchiveDirs = new List <IArchiveDirectory>();

        foreach (var archiveDir in contentDir.GetDirectories())
        {
            contentArchiveDirs.Add(UnpackedArchiveDirectory.Make(archiveDir));
        }
        foreach (var archiveFile in contentDir.GetFiles("*.archive"))
        {
            var archive = new PackedArchive(archiveFile);
            contentArchiveDirs.Add(archive.Root);
        }

        var unionedArchiveDir = UnionArchiveDirectory.Join("content", contentArchiveDirs);

        LeakTracking.Setup();

        string title = Application.ProductName + " " + Application.ProductVersion;

        try {
            using (VRApp app = new VRApp(unionedArchiveDir, title)) {
                app.Run();
            }
        } catch (VRInitException e) {
            string text = String.Join("\n\n",
                                      String.Format("OpenVR initialization failed: {0}", e.Message),
                                      "Please make sure SteamVR is installed and running, and VR headset is connected.");
            string caption = "OpenVR Initialization Error";

            MessageBox.Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        LeakTracking.Finish();
    }
예제 #2
0
    public static void Main(string[] args)
    {
        if (!Debugger.IsAttached)
        {
            AppDomain.CurrentDomain.UnhandledException += ReportUnhandledException;
        }

        var commandLineParser = new CommandLineApplication(false);
        var archiveOption     = commandLineParser.Option("--data", "path to archive file or directory", CommandOptionType.SingleValue);

        commandLineParser.Execute(args);

        string archivePath;

        if (archiveOption.HasValue())
        {
            archivePath = archiveOption.Value();
        }
        else
        {
            archivePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "data.archive");
        }

        IArchiveDirectory dataDir;

        var archiveAsDirectory = new DirectoryInfo(archivePath);

        if (archiveAsDirectory.Exists)
        {
            dataDir = UnpackedArchiveDirectory.Make(archiveAsDirectory);
        }
        else
        {
            var archive = new PackedArchive(new FileInfo(archivePath));
            dataDir = archive.Root;
        }

        LeakTracking.Setup();

        string title = Application.ProductName + " " + Application.ProductVersion;

        try {
            using (VRApp app = new VRApp(dataDir, title)) {
                app.Run();
            }
        } catch (VRInitException e) {
            string text = String.Join("\n\n",
                                      String.Format("OpenVR initialization failed: {0}", e.Message),
                                      "Please make sure SteamVR is installed and running, and VR headset is connected.");
            string caption = "OpenVR Initialization Error";

            MessageBox.Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        LeakTracking.Finish();
    }