示例#1
0
        /// <summary>
        /// Calls <see cref="ContentManager.LoadArchives"/> and displays error messages if something went wrong.
        /// </summary>
        /// <returns><c>true</c> if all archives were loaded successfully; <c>false</c> if something went wrong.</returns>
        private static bool LoadArchives()
        {
            try
            {
                ContentManager.LoadArchives();
            }
            #region Error handling
            catch (IOException ex)
            {
                Log.Error(ex);
                ContentManager.CloseArchives();
                Msg.Inform(null, Resources.FailedReadArchives + Environment.NewLine + ex.Message, MsgSeverity.Error);
                return(false);
            }
            catch (UnauthorizedAccessException ex)
            {
                Log.Error(ex);
                ContentManager.CloseArchives();
                Msg.Inform(null, Resources.FailedReadArchives + Environment.NewLine + ex.Message, MsgSeverity.Error);
                return(false);
            }
            #endregion

            return(true);
        }
示例#2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ContentManager.LoadArchives();
            using (var game = new Game()) game.Run();
            ContentManager.CloseArchives();
        }
示例#3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ContentManager.LoadArchives();
            Application.Run(new MainForm());
            ContentManager.CloseArchives();
        }
示例#4
0
        private static void Main(string[] args)
        {
            WindowsUtils.SetCurrentProcessAppID(Application.CompanyName + "." + GeneralSettings.AppNameShort);

            Application.EnableVisualStyles();
            ErrorReportForm.SetupMonitoring(new Uri("http://omegaengine.de/error-report/?app=" + GeneralSettings.AppNameShort));

#if !DEBUG
            // Prevent multiple instances from running simultaneously
            if (AppMutex.Create(GeneralSettings.AppName))
            {
                Msg.Inform(null, Resources.AlreadyRunning, MsgSeverity.Warn);
                return;
            }
#endif

            Args = new Arguments(args);

            Settings.LoadCurrent();
            UpdateLocale();
            Settings.SaveCurrent();

            // Show additional warning before actually starting the game
            if (Args.Contains("launchWarn") && !Args.Contains("benchmark"))
            {
                if (!Msg.OkCancel(null, Resources.ReadyToLaunch, MsgSeverity.Info, Resources.ReadyToLaunchContinue))
                {
                    return;
                }
            }

            // Handle benchmark mode
            if (Args.Contains("benchmark"))
            {
                if (!Msg.OkCancel(null, Resources.BenchmarkInfo, MsgSeverity.Info, Resources.BenchmarkInfoContinue))
                {
                    return;
                }
                ConfigureSettingsForBenchmark();
            }

            if (!DetermineContentDirs())
            {
                return;
            }
            if (!LoadArchives())
            {
                return;
            }
            using (var game = new Game())
                game.Run();
            ContentManager.CloseArchives();
        }
示例#5
0
        private static void Main(string[] args)
        {
            Application.EnableVisualStyles();

            Args = new Arguments(args);

            UpdateLocale();

            // The user might want to come back here multiple times, in order to switch the mod
            while (Restart)
            {
                Restart = false;

                // Ask user to select mod, cancel if an exception occurred
                Application.Run(new ModSelectorForm(allowEditMain: true));

                // Exit if the user didn't select anything
                if (ContentManager.ModDir == null && !ModInfo.MainGame)
                {
                    break;
                }

                // Load the archives, run the main editor, cancel if an exception occurred, always unload the archives
                if (!LoadArchives())
                {
                    break;
                }
                try
                {
                    Application.Run(new MainForm());
                }
                finally
                {
                    ContentManager.CloseArchives();
                }

                // Prepare for next selection
                ModInfo.MainGame      = false;
                ContentManager.ModDir = null;

                // After the MainForm has closed a lot of garbage will be left in Generation 2.
                // We should run Garbage Collection now, so we don't keep on wasting a large chunk of memory.
                GC.Collect();
            }
        }
示例#6
0
        /// <summary>
        /// Calls <see cref="ContentManager.LoadArchives"/> and displays error messages if something went wrong.
        /// </summary>
        /// <returns><see langword="true"/> if all archives were loaded successfully; <see langword="false"/> if something went wrong.</returns>
        private static bool LoadArchives()
        {
            try
            {
                ContentManager.LoadArchives();
            }
            #region Error handling
            catch (IOException)
            {
                ContentManager.CloseArchives();
                Msg.Inform(null, Resources.FailedReadArchives, MsgSeverity.Error);
                return(false);
            }
            catch (UnauthorizedAccessException)
            {
                ContentManager.CloseArchives();
                Msg.Inform(null, Resources.FailedReadArchives, MsgSeverity.Error);
                return(false);
            }
            #endregion

            return(true);
        }
示例#7
0
        private static void Main(string[] args)
        {
            WindowsUtils.SetCurrentProcessAppID(Application.CompanyName + "." + GeneralSettings.AppNameShort + ".AlphaEditor");
            ModInfo.FileExt = "." + GeneralSettings.AppNameShort + "Mod";

            Application.EnableVisualStyles();
            ErrorReportForm.SetupMonitoring(new Uri("http://omegaengine.de/error-report/?app=" + GeneralSettings.AppNameShort));

            // Allow setup to detect running instances
            AppMutex.Create(GeneralSettings.AppName + " Editor");

            Args = new Arguments(args);

            Settings.LoadCurrent();
            UpdateLocale();
            Settings.SaveCurrent();

            if (!DetermineContentDirs())
            {
                return;
            }

            if (Settings.Current.Editor.ShowWelcomeMessage)
            {
                Restart = false; // Will be set to true again, if the user clicks "Continue"
                Application.Run(new WelcomeForm());
            }

            // The user might want to come back here multiple times, in order to switch the mod
            while (Restart)
            {
                Restart = false;

                // Ask user to select mod, cancel if an exception occurred
                Application.Run(new ModSelectorForm(Settings.Current.Editor.EditBase, Settings.Current.Editor.RecentMods));

                // Exit if the user didn't select anything
                if (ContentManager.ModDir == null && !ModInfo.MainGame)
                {
                    break;
                }

                // Load the archives, run the main editor, cancel if an exception occurred, always unload the archives
                if (!LoadArchives())
                {
                    break;
                }
                try
                {
                    Application.Run(new MainForm());
                }
                finally
                {
                    ContentManager.CloseArchives();
                }

                // Prepare for next selection
                ModInfo.MainGame      = false;
                ContentManager.ModDir = null;

                // After the MainForm has closed a lot of garbage will be left in Generation 2.
                // We should run Garbage Collection now, so we don't keep on wasting a large chunk of memory.
                GC.Collect();
            }
        }