/// <summary>
 /// Creates a new converter for a new table
 /// </summary>
 /// <param name="sourceContainer">Source table container</param>
 /// <param name="fileName">File name of the file being imported</param>
 /// <param name="options">Optional convert options</param>
 public VpxSceneConverter(FileTableContainer sourceContainer, string fileName = "", ConvertOptions options = null)
 {
     _sourceContainer = sourceContainer;
     _sourceTable     = sourceContainer.Table;
     _patcher         = PatcherManager.GetPatcher();
     _patcher?.Set(sourceContainer, fileName, this, this);
     _options = options ?? new ConvertOptions();
 }
예제 #2
0
        private void SetupDropdownItems()
        {
            ddSetKnownType.Items.Clear();

            var manager = new PatcherManager();

            ddSetKnownType.Items.AddRange(manager
                                          .GetAllPatchers(Activator.RepositoryLocator.CatalogueRepository.MEF)
                                          .Select(p => p.Name)
                                          .ToArray());
        }
예제 #3
0
        private static void RunGame()
        {
            Logger.Log(LogLevel.Info, "Patching is complete. Launching the game...");

            if (!Configuration.GameExecutableName.IsNullOrWhiteSpace())
            {
                Logger.Log("Starting main process");

                Process.Start(Configuration.Executable, Configuration.ExecArgs);

                Logger.Log(
                    $"Searching for process {Configuration.GameExecutableName}. Press CTRL+C to stop and close UULauncher...");

                Process[] processes;
                do
                {
                    processes = Process.GetProcessesByName(Configuration.GameExecutableName);
                } while (processes.Length == 0);

                Logger.Log(LogLevel.Info, "Found process! Binding...");
                GameProcess = Process.GetProcessById(processes[0].Id);
                Logger.Log(LogLevel.Info, "Done!");
            }
            else
            {
                GameProcess = Process.Start(Configuration.Executable, Configuration.ExecArgs);

                if (GameProcess == null)
                {
                    Logger.Log(LogLevel.Error, "The process could not be started. Exiting...");
                    Environment.Exit(-1);
                }
                Logger.Log(LogLevel.Info, "Game process launched!");
            }
            ConsoleUtils.SetConsoleCtrlHandler(HandleConsoleCtrl, true);
            Logger.StopTime();
            Logger.Log(LogLevel.Warning,
                       "NOTE: DO NOT close this window while the game is running. UULauncher will perform clean-up after the game is closed.");
            IntPtr consoleHandle = ConsoleUtils.GetConsoleWindow();

            if (Configuration.HideWhileGameRuns)
            {
                ConsoleUtils.ShowWindow(consoleHandle, ConsoleUtils.SW_HIDE);
            }

            GameProcess.WaitForExit();
            if (Configuration.HideWhileGameRuns)
            {
                ConsoleUtils.ShowWindow(consoleHandle, ConsoleUtils.SW_SHOW);
            }
            Logger.Log(LogLevel.Info, "Game exited");
            PatcherManager.RunRestoreAssemblies();
        }
예제 #4
0
        public static void Main(string[] args)
        {
            Logger.Init();
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine(LOGO);
            Console.ForegroundColor = ConsoleColor.Gray;
            string name =
                $"{new string(' ', 30)} Launcher v. {Version.Major}.{Version.Minor}.{Version.Build} (Revision {Version.Revision})";

            Console.WriteLine(name);
#if GIT
            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.WriteLine($"{new string(' ', name.Length - VersionInfo.Length)}{VersionInfo}");
            Console.ForegroundColor = ConsoleColor.Gray;
#endif
            Console.WriteLine();
            Console.WriteLine($"Started on {DateTime.Now.ToString("F", CultureInfo.InvariantCulture)}");
            Logger.StartTime();
            configFilePath = Configuration.DEFAULT_CONFIG_NAME;
            if (args.Length > 0)
            {
                ParseArguments(args);
            }
            if (configFilePath == Configuration.DEFAULT_CONFIG_NAME && !File.Exists(Configuration.DEFAULT_CONFIG_NAME))
            {
                DialogResult result = MessageBox.Show("No default configuration file found. Create one?",
                                                      "Create configuration file?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (result == DialogResult.Yes)
                {
                    Configuration.CreateDefaultConfiguration();
                    ShowInfo("Configuration file created.",
                             $"Created configuration file {Configuration.DEFAULT_CONFIG_NAME}. Edit it before running {ProcessName}.exe again.");
                    Environment.Exit(0);
                }
                else
                {
                    Logger.Log(LogLevel.Error, $"No configuration file specified! Use {ProcessName}.exe -h for help.");
                    Environment.Exit(-1);
                }
            }
            Configuration.ParseConfig(configFilePath);
            Logger.Log(LogLevel.Info, $"Loaded configuration file from {configFilePath}");

            Assert(() => PatcherManager.LoadPatchers(), "An error occurred while loading patchers!");
            Assert(() => PatcherManager.RunPatchers(), "An error occurred while running patchers!");
            Assert(() => RunGame(), "An error occurred when running the game!");

            Logger.LogWriter.Close();
            Logger.LogWriter.Dispose();
        }
예제 #5
0
        private static bool HandleConsoleCtrl(int eventType)
        {
            switch (eventType)
            {
            case ConsoleUtils.CTRL_C_EVENT:
            case ConsoleUtils.CTRL_BREAK_EVENT:
            case ConsoleUtils.CTRL_CLOSE_EVENT:
                Logger.Log(LogLevel.Warning, "UULauncher has been closed suddenly! Closing game...");
                GameProcess.Kill();
                PatcherManager.RunRestoreAssemblies();
                break;
            }

            return(true);
        }