Exemplo n.º 1
0
        public bool Load(string[] args)
        {
            // Fetch the game version and store, so it can be retrieved during crash if the toolbox makes it this far.
            Version gameVersion = SpaceEngineersConsts.GetSEVersion();
            bool    newVersion  = GlobalSettings.Default.SEVersion != gameVersion;

            GlobalSettings.Default.SEVersion = gameVersion;

            // Test the Space Engineers version to make sure users are using an version that is new enough for SEToolbox to run with!
            // This is usually because a user has not updated a manual install of a Dedicated Server, or their Steam did not update properly.
            if (GlobalSettings.Default.SEVersion < GlobalSettings.GetAppVersion(true))
            {
                MessageBox.Show(string.Format(Res.DialogOldSEVersionMessage, SpaceEngineersConsts.GetSEVersion(), GlobalSettings.Default.SEBinPath, GlobalSettings.GetAppVersion()), Res.DialogOldSEVersionTitle, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                Application.Current.Shutdown();
                return(false);
            }

            // the /B argument indicates the SEToolboxUpdate had started SEToolbox after fetching updated game binaries.
            if (newVersion && args.Any(a => a.Equals("/B", StringComparison.OrdinalIgnoreCase) || a.Equals("-B", StringComparison.OrdinalIgnoreCase)))
            {
                // Reset the counter used to indicate if the game binaries have updated.
                GlobalSettings.Default.TimesStartedLastGameUpdate = null;
            }

            //string loadWorld = null;

            //foreach (var arg in args)
            //{
            //    if (arg.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0 && !File.Exists(arg))
            //        continue;

            //    string file = Path.GetFileName(arg);
            //    if (file.Equals("Sandbox.sbc", StringComparison.InvariantCultureIgnoreCase)
            //        || file.Equals("SANDBOX_0_0_0_.sbs", StringComparison.InvariantCultureIgnoreCase))
            //        loadWorld = Path.GetDirectoryName(arg);
            //}

            // Force pre-loading of any Space Engineers resources.
            SpaceEngineersCore.LoadDefinitions();

            // Load the Space Engineers assemblies, or dependant classes after this point.
            var explorerModel = new ExplorerModel();

            if (args.Any(a => a.ToUpper() == "/WR" || a.ToUpper() == "-WR"))
            {
                ResourceReportModel.GenerateOfflineReport(explorerModel, args);
                Application.Current.Shutdown();
                return(false);
            }

            var eViewModel = new ExplorerViewModel(explorerModel);
            var eWindow    = new WindowExplorer(eViewModel);

            //if (allowClose)
            //{
            eViewModel.CloseRequested += (sender, e) =>
            {
                SaveSettings(eWindow);
                Application.Current.Shutdown();
            };
            //}
            eWindow.Loaded += (sender, e) =>
            {
                Splasher.CloseSplash();

                double left   = GlobalSettings.Default.WindowLeft ?? eWindow.Left;
                double top    = GlobalSettings.Default.WindowTop ?? eWindow.Top;
                double width  = GlobalSettings.Default.WindowWidth ?? eWindow.Width;
                double height = GlobalSettings.Default.WindowHeight ?? eWindow.Height;

                System.Drawing.Rectangle windowRect = new System.Drawing.Rectangle((int)left, (int)top, (int)width, (int)height);
                bool isInsideDesktop = false;

                foreach (System.Windows.Forms.Screen screen in System.Windows.Forms.Screen.AllScreens)
                {
                    try
                    {
                        isInsideDesktop |= screen.Bounds.IntersectsWith(windowRect);
                    }
                    catch
                    {
                        // some virtual screens have been know to cause issues.
                    }
                }
                if (isInsideDesktop)
                {
                    eWindow.Left   = left;
                    eWindow.Top    = top;
                    eWindow.Width  = width;
                    eWindow.Height = height;
                    if (GlobalSettings.Default.WindowState.HasValue)
                    {
                        eWindow.WindowState = GlobalSettings.Default.WindowState.Value;
                    }
                }
            };

            if (!GlobalSettings.Default.TimesStartedTotal.HasValue)
            {
                GlobalSettings.Default.TimesStartedTotal = 0;
            }
            GlobalSettings.Default.TimesStartedTotal++;
            if (!GlobalSettings.Default.TimesStartedLastReset.HasValue)
            {
                GlobalSettings.Default.TimesStartedLastReset = 0;
            }
            GlobalSettings.Default.TimesStartedLastReset++;
            if (!GlobalSettings.Default.TimesStartedLastGameUpdate.HasValue)
            {
                GlobalSettings.Default.TimesStartedLastGameUpdate = 0;
            }
            GlobalSettings.Default.TimesStartedLastGameUpdate++;
            GlobalSettings.Default.Save();

            eWindow.ShowDialog();

            return(true);
        }
Exemplo n.º 2
0
        public bool Load(string[] args)
        {
            // Fetch the game version and store, so it can be retrieved during crash if the toolbox makes it this far.
            GlobalSettings.Default.SEVersion = SpaceEngineersConsts.GetSEVersion();

            // Test the Space Engineers version to make sure users are using an version that is new enough for SEToolbox to run with!
            // This is usually because a user has not updated a manual install of a Dedicated Server, or their Steam did not update properly.
            if (GlobalSettings.Default.SEVersion < GlobalSettings.GetAppVersion(true))
            {
                MessageBox.Show(string.Format(Res.DialogOldSEVersionMessage, SpaceEngineersConsts.GetSEVersion(), GlobalSettings.Default.SEBinPath, GlobalSettings.GetAppVersion()), Res.DialogOldSEVersionTitle, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                Application.Current.Shutdown();
                return(false);
            }

            //string loadWorld = null;

            //foreach (var arg in args)
            //{
            //    if (arg.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0 && !File.Exists(arg))
            //        continue;

            //    string file = Path.GetFileName(arg);
            //    if (file.Equals("Sandbox.sbc", StringComparison.InvariantCultureIgnoreCase)
            //        || file.Equals("SANDBOX_0_0_0_.sbs", StringComparison.InvariantCultureIgnoreCase))
            //        loadWorld = Path.GetDirectoryName(arg);
            //}

            // Force pre-loading of any Space Engineers resources.
            SpaceEngineersCore.LoadDefinitions();

            // Load the Space Engineers assemblies, or dependant classes after this point.
            var explorerModel = new ExplorerModel();

            if (args.Any(a => a.ToUpper() == "/WR" || a.ToUpper() == "-WR"))
            {
                ResourceReportModel.GenerateOfflineReport(explorerModel, args);
                Application.Current.Shutdown();
                return(false);
            }

            var eViewModel = new ExplorerViewModel(explorerModel);
            var eWindow    = new WindowExplorer(eViewModel);

            //if (allowClose)
            //{
            eViewModel.CloseRequested += (sender, e) =>
            {
                SaveSettings(eWindow);
                Application.Current.Shutdown();
            };
            //}
            eWindow.Loaded += (sender, e) =>
            {
                Splasher.CloseSplash();
                if (GlobalSettings.Default.WindowLeft.HasValue)
                {
                    eWindow.Left = GlobalSettings.Default.WindowLeft.Value;
                }
                if (GlobalSettings.Default.WindowTop.HasValue)
                {
                    eWindow.Top = GlobalSettings.Default.WindowTop.Value;
                }
                if (GlobalSettings.Default.WindowWidth.HasValue)
                {
                    eWindow.Width = GlobalSettings.Default.WindowWidth.Value;
                }
                if (GlobalSettings.Default.WindowHeight.HasValue)
                {
                    eWindow.Height = GlobalSettings.Default.WindowHeight.Value;
                }
                if (GlobalSettings.Default.WindowState.HasValue)
                {
                    eWindow.WindowState = GlobalSettings.Default.WindowState.Value;
                }
            };
            eWindow.ShowDialog();

            return(true);
        }
Exemplo n.º 3
0
        public bool Load(string[] args)
        {
            // Fetch the game version and store, so it can be retrieved during crash if the toolbox makes it this far.
            Version gameVersion = SpaceEngineersConsts.GetSEVersion();
            bool    newVersion  = GlobalSettings.Default.SEVersion != gameVersion;

            GlobalSettings.Default.SEVersion = gameVersion;

            // Test the Space Engineers version to make sure users are using an version that is new enough for SEToolbox to run with!
            // This is usually because a user has not updated a manual install of a Dedicated Server, or their Steam did not update properly.
            if (GlobalSettings.Default.SEVersion < GlobalSettings.GetAppVersion(true))
            {
                MessageBox.Show(string.Format(Res.DialogOldSEVersionMessage, SpaceEngineersConsts.GetSEVersion(), GlobalSettings.Default.SEBinPath, GlobalSettings.GetAppVersion()), Res.DialogOldSEVersionTitle, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                Application.Current.Shutdown();
                return(false);
            }

            // the /B argument indicates the SEToolboxUpdate had started SEToolbox after fetching updated game binaries.
            if (newVersion && args.Any(a => a.Equals("/B", StringComparison.OrdinalIgnoreCase) || a.Equals("-B", StringComparison.OrdinalIgnoreCase)))
            {
                // Reset the counter used to indicate if the game binaries have updated.
                GlobalSettings.Default.TimesStartedLastGameUpdate = null;
            }

            // Force pre-loading of any Space Engineers resources.
            SpaceEngineersCore.LoadDefinitions();

            // Load the Space Engineers assemblies, or dependant classes after this point.
            var explorerModel = new ExplorerModel();

            if (args.Any(a => a.ToUpper() == "/WR" || a.ToUpper() == "-WR"))
            {
                ResourceReportModel.GenerateOfflineReport(explorerModel, args);
                Application.Current.Shutdown();
                return(false);
            }

            var eViewModel = new ExplorerViewModel(explorerModel);
            var eWindow    = new WindowExplorer(eViewModel);

            //if (allowClose)
            //{
            eViewModel.CloseRequested += (sender, e) =>
            {
                SaveSettings(eWindow);
                Application.Current.Shutdown();
            };
            //}
            eWindow.Loaded += (sender, e) =>
            {
                Splasher.CloseSplash();
                if (GlobalSettings.Default.WindowLeft.HasValue)
                {
                    eWindow.Left = GlobalSettings.Default.WindowLeft.Value;
                }
                if (GlobalSettings.Default.WindowTop.HasValue)
                {
                    eWindow.Top = GlobalSettings.Default.WindowTop.Value;
                }
                if (GlobalSettings.Default.WindowWidth.HasValue)
                {
                    eWindow.Width = GlobalSettings.Default.WindowWidth.Value;
                }
                if (GlobalSettings.Default.WindowHeight.HasValue)
                {
                    eWindow.Height = GlobalSettings.Default.WindowHeight.Value;
                }
                if (GlobalSettings.Default.WindowState.HasValue)
                {
                    eWindow.WindowState = GlobalSettings.Default.WindowState.Value;
                }
            };

            if (!GlobalSettings.Default.TimesStartedTotal.HasValue)
            {
                GlobalSettings.Default.TimesStartedTotal = 0;
            }
            GlobalSettings.Default.TimesStartedTotal++;
            if (!GlobalSettings.Default.TimesStartedLastReset.HasValue)
            {
                GlobalSettings.Default.TimesStartedLastReset = 0;
            }
            GlobalSettings.Default.TimesStartedLastReset++;
            if (!GlobalSettings.Default.TimesStartedLastGameUpdate.HasValue)
            {
                GlobalSettings.Default.TimesStartedLastGameUpdate = 0;
            }
            GlobalSettings.Default.TimesStartedLastGameUpdate++;
            GlobalSettings.Default.Save();

            eWindow.ShowDialog();

            return(true);
        }