Esempio n. 1
0
 private static void CleanupSandbox()
 {
     m_steamService.Dispose();
     m_spacegame.Dispose();
     m_steamService = null;
     m_spacegame    = null;
 }
Esempio n. 2
0
        //  Main method
        static void Main(string[] args)
        {
            SpaceEngineersGame.SetupBasicGameInfo();

            m_startup = new MyCommonProgramStartup(args);
            if (m_startup.PerformReporting()) return;
            m_startup.PerformAutoconnect();
            if (!m_startup.CheckSingleInstance()) return;
            var appDataPath = m_startup.GetAppDataPath();
            MyInitializer.InvokeBeforeRun(AppId, MyPerGameSettings.BasicGameInfo.ApplicationName, appDataPath);
            MyInitializer.InitCheckSum();
            m_startup.InitSplashScreen();
            if (!m_startup.Check64Bit()) return;

            m_startup.DetectSharpDxLeaksBeforeRun();
            using (MySteamService steamService = new MySteamService(MySandboxGame.IsDedicated, AppId))
            {
                m_renderer = null;
                SpaceEngineersGame.SetupPerGameSettings();
                SpaceEngineersGame.SetupRender();

                try
                {
                    InitializeRender();
                }
                catch(MyRenderException ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }

                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyProgram.Init");

                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MySteam.Init()");
                if (!m_startup.CheckSteamRunning(steamService)) return;
                VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();

                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("new MySandboxGame()");

                VRageGameServices services = new VRageGameServices(steamService);

                if (!MySandboxGame.IsDedicated)
                    MyFileSystem.InitUserSpecific(steamService.UserId.ToString());

                using (SpaceEngineersGame game = new SpaceEngineersGame(services, args))
                {
                    VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
                    VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
                    game.Run(disposeSplashScreen: m_startup.DisposeSplashScreen);
                }
            }
            m_startup.DetectSharpDxLeaksAfterRun();

#if PROFILING
            MyPerformanceTimer.WriteToLog();
#endif
            MyInitializer.InvokeAfterRun();
        }
Esempio n. 3
0
        public bool CheckSteamRunning(MySteamService steamService)
        {
            if (!MySandboxGame.IsDedicated)
            {
                if (steamService.IsActive)
                {
                    steamService.SetNotificationPosition(MySteamService.NotificationPosition.TopLeft);

                    MySandboxGame.Log.WriteLineAndConsole("Steam.IsActive: " + steamService.IsActive);
                    MySandboxGame.Log.WriteLineAndConsole("Steam.IsOnline: " + steamService.IsOnline);
                    MySandboxGame.Log.WriteLineAndConsole("Steam.OwnsGame: " + steamService.OwnsGame);
                    MySandboxGame.Log.WriteLineAndConsole("Steam.UserId: " + steamService.UserId);
                    MySandboxGame.Log.WriteLineAndConsole("Steam.UserName: "******"[n/a]");
                    MySandboxGame.Log.WriteLineAndConsole("Steam.Branch: " + steamService.BranchName ?? "[n/a]");
#if !XB1
                    MySandboxGame.Log.WriteLineAndConsole("Build date: " + MySandboxGame.BuildDateTime.ToString("yyyy-MM-dd hh:mm", CultureInfo.InvariantCulture));
                    MySandboxGame.Log.WriteLineAndConsole("Build version: " + MySandboxGame.BuildVersion.ToString());
#else // XB1
                    MySandboxGame.Log.WriteLineAndConsole("Build date: N/A (XB1 TODO?)");
                    MySandboxGame.Log.WriteLineAndConsole("Build version: N/A (XB1 TODO?)");
#endif // XB1
                }
                else if (MyFinalBuildConstants.IS_OFFICIAL) //We dont need Steam only in VS
                {
                    if (!(steamService.IsActive && steamService.OwnsGame))
                    {
                        if (MyFakes.ENABLE_RUN_WITHOUT_STEAM == false)
                        {
#if !XB1
                            MessageBoxWrapper("Steam is not running!", "Please run this game from Steam." + MyEnvironment.NewLine + "(restart Steam if already running)");
#else // XB1
                            System.Diagnostics.Debug.Assert(false, "XB1 TODO?");
#endif // XB1
                            return(false);
                        }
                    }
                }
                else
                {
#if !XB1
                    // At the moment in some cases we can't really distinguish if Steam is
                    // active but the user doesn't own the game
                    MessageBoxWrapper("Steam is not running!", "Game might be unstable when run without Steam\n"
                                      + "or when the game is not present in the user's library!\n"
                                      + "FOR DEBUG: Set MyFakes.ENABLE_RUN_WITHOUT_STEAM to true");
#endif // !XB1
                }
            }

            return(true);
        }
Esempio n. 4
0
        static void RunInternal(string[] args)
        {
            using (MySteamService steamService = new MySteamService(MySandboxGame.IsDedicated, AppId))
            {
                IMyRender renderer = null;

                if (MySandboxGame.IsDedicated)
                {
                    renderer = new MyNullRender();
                }
                else if (!MyFakes.ENABLE_DX11_RENDERER)
                {
                    renderer = new MyDX9Render();
                }
                else if (MyFakes.ENABLE_DX11_RENDERER)
                {
                    renderer = new MyDX11Render();
                }

                VRageRender.MyRenderProxy.Initialize(renderer);

                VRageRender.MyRenderProxy.IS_OFFICIAL = MyFinalBuildConstants.IS_OFFICIAL;
                VRageRender.MyRenderProxy.GetRenderProfiler().SetAutocommit(false);
                VRageRender.MyRenderProxy.GetRenderProfiler().InitMemoryHack("MainEntryPoint");
                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyProgram.Init");
                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MySteam.Init()");

                if (!MySandboxGame.IsDedicated)
                {
                    if (steamService.IsActive)
                    {
                        steamService.SetNotificationPosition(MySteamService.NotificationPosition.TopLeft);

                        MySandboxGame.Log.WriteLineAndConsole("Steam.IsActive: " + steamService.IsActive);
                        MySandboxGame.Log.WriteLineAndConsole("Steam.IsOnline: " + steamService.IsOnline);
                        MySandboxGame.Log.WriteLineAndConsole("Steam.OwnsGame: " + steamService.OwnsGame);
                        MySandboxGame.Log.WriteLineAndConsole("Steam.UserId: " + steamService.UserId);
                        MySandboxGame.Log.WriteLineAndConsole("Steam.UserName: "******"[n/a]");
                        MySandboxGame.Log.WriteLineAndConsole("Steam.Branch: " + steamService.BranchName ?? "[n/a]");
                        MySandboxGame.Log.WriteLineAndConsole("Build date: " + MySandboxGame.BuildDateTime.ToString("yyyy-MM-dd hh:mm", CultureInfo.InvariantCulture));
                        MySandboxGame.Log.WriteLineAndConsole("Build version: " + MySandboxGame.BuildVersion.ToString());
                    }
                    else if (MyFinalBuildConstants.IS_OFFICIAL) //We dont need Steam only in VS 
                    {
                        if (!(steamService.IsActive && steamService.OwnsGame))
                        {
                            MessageBoxWrapper("Steam is not running!", "Please run this game from Steam." + Environment.NewLine + "(restart Steam if already running)");
                            return;
                        }
                    }
                    else
                    {
                        if (!(steamService.IsActive && steamService.OwnsGame))
                        {
                            MessageBoxWrapper("Steam is not running!", "Game might be unstable when run without Steam!");
                        }
                    }
                }

                VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();

                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("new MySandboxGame()");

                SpaceEngineersGame.SetupPerGameSettings();

                VRageGameServices services = new VRageGameServices(steamService);

                if (!MySandboxGame.IsDedicated)
                    MyFileSystem.InitUserSpecific(steamService.UserId.ToString());

                using (MySandboxGame game = new MySandboxGame(services, args))
                {
                    VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
                    VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
                    game.Run(disposeSplashScreen: DisposeSplashScreen);
                }
            }
        }
        public bool CheckSteamRunning(MySteamService steamService)
        {
            if (!MySandboxGame.IsDedicated)
            {
                if (steamService.IsActive)
                {
                    steamService.SetNotificationPosition(MySteamService.NotificationPosition.TopLeft);

                    MySandboxGame.Log.WriteLineAndConsole("Steam.IsActive: " + steamService.IsActive);
                    MySandboxGame.Log.WriteLineAndConsole("Steam.IsOnline: " + steamService.IsOnline);
                    MySandboxGame.Log.WriteLineAndConsole("Steam.OwnsGame: " + steamService.OwnsGame);
                    MySandboxGame.Log.WriteLineAndConsole("Steam.UserId: " + steamService.UserId);
                    MySandboxGame.Log.WriteLineAndConsole("Steam.UserName: "******"[n/a]");
                    MySandboxGame.Log.WriteLineAndConsole("Steam.Branch: " + steamService.BranchName ?? "[n/a]");
#if !XB1
                    MySandboxGame.Log.WriteLineAndConsole("Build date: " + MySandboxGame.BuildDateTime.ToString("yyyy-MM-dd hh:mm", CultureInfo.InvariantCulture));
                    MySandboxGame.Log.WriteLineAndConsole("Build version: " + MySandboxGame.BuildVersion.ToString());
#else // XB1
                    MySandboxGame.Log.WriteLineAndConsole("Build date: N/A (XB1 TODO?)");
                    MySandboxGame.Log.WriteLineAndConsole("Build version: N/A (XB1 TODO?)");
#endif // XB1
                }
                else if (MyFinalBuildConstants.IS_OFFICIAL) //We dont need Steam only in VS 
                {
                    if (!(steamService.IsActive && steamService.OwnsGame))
                    {
                        if (MyFakes.ENABLE_RUN_WITHOUT_STEAM == false)
                        {
#if !XB1
                            MessageBoxWrapper("Steam is not running!", "Please run this game from Steam." + MyEnvironment.NewLine + "(restart Steam if already running)");
#else // XB1
                            System.Diagnostics.Debug.Assert(false, "XB1 TODO?");
#endif // XB1
                            return false;
                        }
                    }
                }
                else
                {
#if !XB1
                    // At the moment in some cases we can't really distinguish if Steam is
                    // active but the user doesn't own the game
                    MessageBoxWrapper("Steam is not running!", "Game might be unstable when run without Steam\n"
                        + "or when the game is not present in the user's library!\n"
                        + "FOR DEBUG: Set MyFakes.ENABLE_RUN_WITHOUT_STEAM to true");
#endif // !XB1
                }
            }

            return true;
        }
 public VRageGameServices(MySteamService steam)
 {
     SteamService = steam;
 }
Esempio n. 7
0
        // This is mostly copied from MyProgram.Main(), with UI stripped out.
        private static void InitSandbox(string instancepath)
        {
            MyFakes.ENABLE_INFINARIO = false;

            if (m_spacegame != null)
            {
                m_spacegame.Exit();
            }

            SpaceEngineersGame.SetupBasicGameInfo();
            m_startup = new MyCommonProgramStartup(new string[] { });

            var appDataPath = m_startup.GetAppDataPath();

            MyInitializer.InvokeBeforeRun(AppId_SE, MyPerGameSettings.BasicGameInfo.ApplicationName + "ModTool", appDataPath);
            MyInitializer.InitCheckSum();

            if (!m_startup.Check64Bit())
            {
                return;
            }

            m_steamService = new MySteamService(MySandboxGame.IsDedicated, AppId_SE);
            SpaceEngineersGame.SetupPerGameSettings();


            if (System.Diagnostics.Debugger.IsAttached)
            {
                m_startup.CheckSteamRunning(m_steamService);        // Just give the warning message box when debugging, ignore for release
            }
            VRageGameServices services = new VRageGameServices(m_steamService);

            if (!MySandboxGame.IsDedicated)
            {
                MyFileSystem.InitUserSpecific(m_steamService.UserId.ToString());
            }

            try
            {
                // NOTE: an assert may be thrown in debug, about missing Tutorials.sbx. Ignore it.
                m_spacegame = new SpaceEngineersGame(services, null);

                // Initializing the workshop means the categories are available
                var initWorkshopMethod = typeof(SpaceEngineersGame).GetMethod("InitSteamWorkshop", BindingFlags.NonPublic | BindingFlags.Instance);
                MyDebug.AssertDebug(initWorkshopMethod != null);

                if (initWorkshopMethod != null)
                {
                    var parameters = initWorkshopMethod.GetParameters();
                    MyDebug.AssertDebug(parameters.Count() == 0);
                }

                if (initWorkshopMethod != null)
                {
                    initWorkshopMethod.Invoke(m_spacegame, null);
                }
                else
                {
                    MySandboxGame.Log.WriteLineAndConsole(string.Format(Constants.ERROR_Reflection, "InitSteamWorkshop"));
                }
            }
            catch (Exception ex)
            {
                // This shouldn't fail, but don't stop even if it does
                MySandboxGame.Log.WriteLineAndConsole("An exception occured, ignoring: " + ex.Message);
            }
        }