static void Main(string[] args)
        {
            if (!SetUpLoggingSystem())
            {
                UIHelper.ShowError("Could not set up logging system!");
            }
            if (!ConfigManager.SetupConfigSystem(Application.StartupPath + "\\plugins.config"))
            {
                UIHelper.ShowError("Could not set up config system! Make sure '" + Application.StartupPath + "\\plugins.config' exists.");
            }

            LoggingManager.SendMessage("Tool starting...");
            if (args.Length > 0)
            {
                var arguments = new StringBuilder();
                foreach (string arg in args)
                {
                    arguments.Append(' ');
                    arguments.Append(arg);
                }
                LoggingManager.SendMessage("Arguments: " + arguments);
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            AppDomain.CurrentDomain.UnhandledException += LogException;
            Application.ApplicationExit         += OnApplicationExit;
            ModManager.ApplicationExitRequested += ModManagerApplicationExitRequested;

            // determine last used directory
            string lastPath  = Properties.Settings.Default.sLastPath;
            string steamPath = null;

            if (string.IsNullOrEmpty(lastPath))
            {
                LoggingManager.SendMessage("Could not determine last used path, setting it to default path.");
                steamPath = MainManager.GetSteamPath();
                if (steamPath == null)
                {
                    AppEnd("User failed to provide a valid Steam path.");
                    return;
                }
                if (Directory.Exists(steamPath + GameConstants.RETRIBUTION_PATH_FROM_STEAM))
                {
                    lastPath = steamPath + GameConstants.RETRIBUTION_PATH_FROM_STEAM;
                }
                else if (Directory.Exists(steamPath + GameConstants.DOW2_PATH_FROM_STEAM))
                {
                    lastPath = steamPath + GameConstants.DOW2_PATH_FROM_STEAM;
                }
                else
                {
                    LoggingManager.SendWarning("Could neither find Retribution nor DoW2 directory; searched for " +
                                               steamPath + GameConstants.RETRIBUTION_PATH_FROM_STEAM + " and " +
                                               steamPath + GameConstants.DOW2_PATH_FROM_STEAM);
                    //AppEnd("Could neither find DoW2 nor Retribution");
                    lastPath = steamPath;
                }
            }
            ModManager.GameDirectory = lastPath;

            // get path to steam executable
            if (string.IsNullOrEmpty(Properties.Settings.Default.sSteamExecutable))
            {
                if (steamPath == null)
                {
                    steamPath = MainManager.GetSteamPath();
                    if (steamPath == null)
                    {
                        AppEnd("User failed to provide a valid Steam path.");
                        return;
                    }
                }
                Properties.Settings.Default.sSteamExecutable = steamPath + "\\steam.exe";
            }

            MainManager.SetAllowOpeningFilesTwice(Properties.Settings.Default.bAppAllowOpeningTwice);
            // create FrontEnd
            var mainDialog = new MainDialog();

            // load plugins
            // IMPORTANT: Create the FrontEnd BEFORE loading the plugins
            PluginManager.Path = Application.StartupPath + "\\plugins\\";
            PluginManager.LoadPlugins();
            PluginManager.LoadFileTypeSettings(Properties.Settings.Default.sFileTypes);

            if (string.IsNullOrEmpty(Properties.Settings.Default.sLanguage))
            {
                LoggingManager.SendMessage("No DoW2 language found, setting it to default (English)");
                MainManager.SetModLanguage("English");
            }
            else
            {
                MainManager.SetModLanguage(Properties.Settings.Default.sLanguage);
            }
            UCSManager.Init();

            mainDialog.HandleArgs(args);
            Application.Run(mainDialog);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            if (!SetUpLoggingSystem())
                 UIHelper.ShowError("Could not set up logging system!");
            if (!ConfigManager.SetupConfigSystem(Application.StartupPath + "\\plugins.config"))
                 UIHelper.ShowError("Could not set up config system! Make sure '" + Application.StartupPath + "\\plugins.config' exists.");

            LoggingManager.SendMessage("Tool starting...");
            if (args.Length > 0)
            {
                var arguments = new StringBuilder();
                foreach (string arg in args)
                {
                    arguments.Append(' ');
                    arguments.Append(arg);
                }
                LoggingManager.SendMessage("Arguments: " + arguments);
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            AppDomain.CurrentDomain.UnhandledException += LogException;
            Application.ApplicationExit += OnApplicationExit;
            ModManager.ApplicationExitRequested += ModManagerApplicationExitRequested;

            // determine last used directory
            string lastPath = Properties.Settings.Default.sLastPath;
            string steamPath = null;
            if (string.IsNullOrEmpty(lastPath))
            {
                LoggingManager.SendMessage("Could not determine last used path, setting it to default path.");
                steamPath = MainManager.GetSteamPath();
                if (steamPath == null)
                {
                    AppEnd("User failed to provide a valid Steam path.");
                    return;
                }
                if (Directory.Exists(steamPath + GameConstants.RETRIBUTION_PATH_FROM_STEAM))
                    lastPath = steamPath + GameConstants.RETRIBUTION_PATH_FROM_STEAM;
                else if (Directory.Exists(steamPath + GameConstants.DOW2_PATH_FROM_STEAM))
                    lastPath = steamPath + GameConstants.DOW2_PATH_FROM_STEAM;
                else
                {
                    LoggingManager.SendWarning("Could neither find Retribution nor DoW2 directory; searched for " +
                                               steamPath + GameConstants.RETRIBUTION_PATH_FROM_STEAM + " and " +
                                               steamPath + GameConstants.DOW2_PATH_FROM_STEAM);
                    //AppEnd("Could neither find DoW2 nor Retribution");
                    lastPath = steamPath;
                }
            }
            ModManager.GameDirectory = lastPath;

            // get path to steam executable
            if (string.IsNullOrEmpty(Properties.Settings.Default.sSteamExecutable))
            {
                if (steamPath == null)
                {
                    steamPath = MainManager.GetSteamPath();
                    if (steamPath == null)
                    {
                        AppEnd("User failed to provide a valid Steam path.");
                        return;
                    }
                }
                Properties.Settings.Default.sSteamExecutable = steamPath + "\\steam.exe";
            }

            MainManager.SetAllowOpeningFilesTwice(Properties.Settings.Default.bAppAllowOpeningTwice);
            // create FrontEnd
            var mainDialog = new MainDialog();

            // load plugins
            // IMPORTANT: Create the FrontEnd BEFORE loading the plugins
            PluginManager.Path = Application.StartupPath + "\\plugins\\";
            PluginManager.LoadPlugins();
            PluginManager.LoadFileTypeSettings(Properties.Settings.Default.sFileTypes);

            if (string.IsNullOrEmpty(Properties.Settings.Default.sLanguage))
            {
                LoggingManager.SendMessage("No DoW2 language found, setting it to default (English)");
                MainManager.SetModLanguage("English");
            }
            else
                MainManager.SetModLanguage(Properties.Settings.Default.sLanguage);
            UCSManager.Init();

            mainDialog.HandleArgs(args);
            Application.Run(mainDialog);
        }