public override bool Update(bool hasFocus)
        {
            if (base.Update(hasFocus) == false)
            {
                return(false);
            }

            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyGuiScreenLoading::Update()");
            if (this.State == MyGuiScreenState.OPENED)
            {
                if (!m_loadFinished)
                {
                    MyHud.ScreenEffects.FadeScreen(0f, 0f);
                    MyAudio.Static.Mute = true;
                    MyAudio.Static.StopMusic();
                    MyAudio.Static.ChangeGlobalVolume(0, 0);
                    VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("LoadInBackgroundThread");

                    DrawLoading();

                    if (m_screenToLoad != null)
                    {
                        MySandboxGame.Log.WriteLine("RunLoadingAction - START");
                        RunLoad();
                        MySandboxGame.Log.WriteLine("RunLoadingAction - END");
                    }
                    if (m_screenToLoad != null)
                    {
                        //  Screen is loaded so now we can add it to other thread
                        MyScreenManager.AddScreenNow(m_screenToLoad);
                        m_screenToLoad.Update(false);
                    }

                    m_screenToLoad = null;

                    m_loadFinished = true;
                    m_wheel.ManualRotationUpdate = true;

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

            if (m_loadFinished && MySandboxGame.IsGameReady)
            {
                MyHud.ScreenEffects.FadeScreen(1f, 5f);
                if (!m_exceptionDuringLoad && OnScreenLoadingFinished != null)
                {
                    OnScreenLoadingFinished();
                    OnScreenLoadingFinished = null;
                }
                CloseScreenNow();
                DrawLoading();
            }

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

            return(true);
        }
        public static void LoadMultiplayerScenarioWorld(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession)
        {
            Debug.Assert(MySession.Static != null);

            MyLog.Default.WriteLine("LoadMultiplayerScenarioWorld() - Start");

            if (world.Checkpoint.BriefingVideo != null && world.Checkpoint.BriefingVideo.Length > 0)
            {
                MyGuiSandbox.OpenUrlWithFallback(world.Checkpoint.BriefingVideo, "Scenario briefing video", true);
            }

            if (!MySteamWorkshop.CheckLocalModsAllowed(world.Checkpoint.Mods, false))
            {
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                           messageText : MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer),
                                           buttonType : MyMessageBoxButtonsType.OK,
                                           callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { MyGuiScreenMainMenu.ReturnToMainMenu(); }));
                MyLog.Default.WriteLine("LoadMultiplayerScenarioWorld() - End");
                return;
            }

            MySteamWorkshop.DownloadModsAsync(world.Checkpoint.Mods,
                                              onFinishedCallback : delegate(bool success, string mismatchMods)
            {
                if (success)
                {
                    CheckMismatchmods(mismatchMods, callback : delegate(VRage.Game.ModAPI.ResultEnum val)
                    {
                        MyScreenManager.CloseAllScreensNowExcept(null);
                        MyGuiSandbox.Update(VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS);

                        MyGuiScreenGamePlay.StartLoading(delegate
                        {
                            MySession.Static.LoadMultiplayerWorld(world, multiplayerSession);
                            if (ScenarioWorldLoaded != null)
                            {
                                ScenarioWorldLoaded();
                            }
                        });
                    });
                }
                else
                {
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                               messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                               messageText : MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed),
                                               buttonType : MyMessageBoxButtonsType.OK,
                                               callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { MyGuiScreenMainMenu.ReturnToMainMenu(); }));
                }
                MyLog.Default.WriteLine("LoadMultiplayerScenarioWorld() - End");
            },
                                              onCancelledCallback : delegate()
            {
                MyGuiScreenMainMenu.UnloadAndExitToMenu();
            });
        }
Exemplo n.º 3
0
        private void StartNewSandbox()
        {
            MyLog.Default.WriteLine("StartNewSandbox - Start");

            GetSettingsFromControls();
            if (!MySteamWorkshop.CheckLocalModsAllowed(m_mods, m_settings.OnlineMode == MyOnlineModeEnum.OFFLINE))
            {
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(MySpaceTexts.DialogTextLocalModsDisabledInMultiplayer),
                                           buttonType: MyMessageBoxButtonsType.OK));
                MyLog.Default.WriteLine("LoadSession() - End");
                return;
            }

            MySteamWorkshop.DownloadModsAsync(m_mods, delegate(bool success)
            {
                if (success || (m_settings.OnlineMode == MyOnlineModeEnum.OFFLINE) && MySteamWorkshop.CanRunOffline(m_mods))
                {
                    MyScreenManager.RemoveAllScreensExcept(null);

                    if (AsteroidAmount < 0)
                    {
                        MyWorldGenerator.SetProceduralSettings(AsteroidAmount, m_settings);
                        m_asteroidAmount = 0;
                    }

                    MyAnalyticsHelper.SetEntry(MyGameEntryEnum.Custom);

                    MyGuiScreenGamePlay.StartLoading(delegate
                    {
                        MySession.Start(
                            m_nameTextbox.Text,
                            GetDescription(),
                            GetPassword(),
                            m_settings,
                            m_mods,
                            new MyWorldGenerator.Args()
                        {
                            AsteroidAmount = this.AsteroidAmount,
                            Scenario       = (m_scenarioTypesGroup.SelectedButton as MyGuiControlScenarioButton).Scenario
                        }
                            );
                    });
                }
                else
                {
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                               messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                                               messageText: MyTexts.Get(MySpaceTexts.DialogTextDownloadModsFailed),
                                               buttonType: MyMessageBoxButtonsType.OK));
                }
                MyLog.Default.WriteLine("StartNewSandbox - End");
            });
        }
        public static void LoadMultiplayerBattleWorld(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession)
        {
            MyLog.Default.WriteLine("LoadMultiplayerBattleWorld() - Start");

            Debug.Assert(MySession.Static != null);
            if (MySession.Static == null)
            {
                MyGuiScreenMainMenu.UnloadAndExitToMenu();
                return;
            }

            if (!MySteamWorkshop.CheckLocalModsAllowed(world.Checkpoint.Mods, false))
            {
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption : MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                                           messageText : MyTexts.Get(MySpaceTexts.DialogTextLocalModsDisabledInMultiplayer),
                                           buttonType : MyMessageBoxButtonsType.OK,
                                           callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { MyGuiScreenMainMenu.ReturnToMainMenu(); }));
                MyLog.Default.WriteLine("LoadMultiplayerBattleWorld() - End");
                return;
            }

            MySteamWorkshop.DownloadModsAsync(world.Checkpoint.Mods,
                                              onFinishedCallback : delegate(bool success)
            {
                if (success)
                {
                    MyScreenManager.CloseAllScreensNowExcept(null);
                    MyGuiSandbox.Update(MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS);

                    MyGuiScreenGamePlay.StartLoading(delegate
                    {
                        MySession.Static.LoadMultiplayerWorld(world, multiplayerSession);
                        Debug.Assert(MySession.Static.Battle);
                        if (BattleWorldLoaded != null)
                        {
                            BattleWorldLoaded();
                        }
                    });
                }
                else
                {
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                               messageCaption : MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                                               messageText : MyTexts.Get(MySpaceTexts.DialogTextDownloadModsFailed),
                                               buttonType : MyMessageBoxButtonsType.OK,
                                               callback : delegate(MyGuiScreenMessageBox.ResultEnum result) { MyGuiScreenMainMenu.ReturnToMainMenu(); }));
                }
                MyLog.Default.WriteLine("LoadMultiplayerBattleWorld() - End");
            },
                                              onCancelledCallback : delegate()
            {
                MyGuiScreenMainMenu.UnloadAndExitToMenu();
            });
        }
Exemplo n.º 5
0
        //  IMPORTANT: This method will be called in background thread so don't mess with main thread objects!!!
        public override void LoadContent()
        {
            MySandboxGame.Log.WriteLine("MyGuiScreenGamePlay.LoadContent - START");
            MySandboxGame.Log.IncreaseIndent();

            Static = this;
            base.LoadContent();

            MySandboxGame.IsUpdateReady = true;
            MySandboxGame.Log.DecreaseIndent();
            MySandboxGame.Log.WriteLine("MyGuiScreenGamePlay.LoadContent - END");
        }
Exemplo n.º 6
0
        public static void StartLoading(Action loadingAction)
        {
            var newGameplayScreen = new MyGuiScreenGamePlay();
            newGameplayScreen.OnLoadingAction += loadingAction;

            var loadScreen = new MyGuiScreenLoading(newGameplayScreen, MyGuiScreenGamePlay.Static);
            loadScreen.OnScreenLoadingFinished += delegate
            {
                MyModAPIHelper.OnSessionLoaded();
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.HUDScreen));
            };
            MyGuiSandbox.AddScreen(loadScreen);
        }
Exemplo n.º 7
0
        public static void LoadMultiplayerSession(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession)
        {
            MyLog.Default.WriteLine("LoadSession() - Start");

            if (!MySteamWorkshop.CheckLocalModsAllowed(world.Checkpoint.Mods, false))
            {
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer),
                                           buttonType: MyMessageBoxButtonsType.OK));
                MyLog.Default.WriteLine("LoadSession() - End");
                return;
            }

            MySteamWorkshop.DownloadModsAsync(world.Checkpoint.Mods,
                                              onFinishedCallback : delegate(bool success)
            {
                if (success)
                {
                    //Sandbox.Audio.MyAudio.Static.Mute = true;

                    MyScreenManager.CloseAllScreensNowExcept(null);
                    MyGuiSandbox.Update(VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS);

                    // May be called from gameplay, so we must make sure we unload the current game
                    if (MySession.Static != null)
                    {
                        MySession.Static.Unload();
                        MySession.Static = null;
                    }

                    MyGuiScreenGamePlay.StartLoading(delegate { MySession.LoadMultiplayer(world, multiplayerSession); });
                }
                else
                {
                    if (MyMultiplayer.Static != null)
                    {
                        MyMultiplayer.Static.Dispose();
                    }
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                               messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                               messageText: MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed),
                                               buttonType: MyMessageBoxButtonsType.OK));
                }
                MyLog.Default.WriteLine("LoadSession() - End");
            },
                                              onCancelledCallback : delegate()
            {
                multiplayerSession.Dispose();
            });
        }
Exemplo n.º 8
0
        public static void StartLoading(Action loadingAction)
        {
            var newGameplayScreen = new MyGuiScreenGamePlay();

            newGameplayScreen.OnLoadingAction += loadingAction;

            var loadScreen = new MyGuiScreenLoading(newGameplayScreen, MyGuiScreenGamePlay.Static);

            loadScreen.OnScreenLoadingFinished += delegate
            {
                MyModAPIHelper.OnSessionLoaded();
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.HUDScreen));
            };
            MyGuiSandbox.AddScreen(loadScreen);
        }
Exemplo n.º 9
0
        //  IMPORTANT: This method will be called in background thread so don't mess with main thread objects!!!
        //  UPDATE: called always when GDevice is disposed
        public override void UnloadContent()
        {
            MySandboxGame.Log.WriteLine("MyGuiScreenGamePlay.UnloadContent - START");
            MySandboxGame.Log.IncreaseIndent();

            base.UnloadContent();

            //  Do GC collect as last step. Reason is that after we loaded new level, a lot of garbage is created and we want to clear it now and not wait until GC decides so.
            GC.Collect();

            Static = null;

            MySandboxGame.Log.DecreaseIndent();
            MySandboxGame.Log.WriteLine("MyGuiScreenGamePlay.UnloadContent - END");
        }
Exemplo n.º 10
0
        // Start game with some default values
        public static void QuickstartSandbox(MyObjectBuilder_SessionSettings quickstartSettings, MyWorldGenerator.Args?quickstartArgs)
        {
            MyLog.Default.WriteLine("QuickstartSandbox - START");

            MyScreenManager.RemoveAllScreensExcept(null);

            MyGuiScreenGamePlay.StartLoading(delegate
            {
                var settings = (quickstartSettings != null) ? quickstartSettings : CreateBasicQuickStartSettings();
                var args     = (quickstartArgs != null) ? quickstartArgs.Value : CreateBasicQuickstartArgs();
                var mods     = new List <MyObjectBuilder_Checkpoint.ModItem>(0);
                MySession.Start("Created " + DateTime.Now.ToString("yyyy-MM-dd HH:mm"), "", "", settings, mods, args);
            });

            MyLog.Default.WriteLine("QuickstartSandbox - END");
        }
Exemplo n.º 11
0
        public MyGuiScreenGamePlay()
            : base(Vector2.Zero, null, null)
        {
            Static = this;

            DrawMouseCursor = false;
            m_closeOnEsc = false;
            m_drawEvenWithoutFocus = true;
            EnabledBackgroundFade = false;
            m_canShareInput = false;
            CanBeHidden = false;
            m_isAlwaysFirst = true;

            m_controlMenu = Activator.CreateInstance(MyPerGameSettings.ControlMenuInitializerType) as IMyControlMenuInitializer;

            MyGuiScreenCubeBuilder.ReinitializeBlockScrollbarPosition();
        }
Exemplo n.º 12
0
        public MyGuiScreenGamePlay()
            : base(Vector2.Zero, null, null)
        {
            Static = this;

            DrawMouseCursor        = false;
            m_closeOnEsc           = false;
            m_drawEvenWithoutFocus = true;
            EnabledBackgroundFade  = false;
            m_canShareInput        = false;
            CanBeHidden            = false;
            m_isAlwaysFirst        = true;

            m_controlMenu = Activator.CreateInstance(MyPerGameSettings.ControlMenuInitializerType) as IMyControlMenuInitializer;

            MyGuiScreenCubeBuilder.ReinitializeBlockScrollbarPosition();
        }
        public override void UnloadContent()
        {
            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyGuiScreenLoading::UnloadContent");
            //  This is just for case that whole application is quiting after Alt+F4 or something
            //  Don't try to unload content in that thread or something - we don't know in what state it is. Just abort it.

            if (m_backgroundScreenTexture != null)
            {
                VRageRender.MyRenderProxy.UnloadTexture(m_backgroundScreenTexture);
            }
            if (m_backgroundTextureFromConstructor != null)
            {
                VRageRender.MyRenderProxy.UnloadTexture(m_backgroundTextureFromConstructor);
            }
            if (m_backgroundScreenTexture != null)
            {
                VRageRender.MyRenderProxy.UnloadTexture(m_rotatingWheelTexture);
            }

            if (m_screenToLoad != null && !m_loadFinished && m_loadInDrawFinished)
            {
                //  Call unload because there might be running precalc threads and we need to stop them
                //m_screenToLoad.UnloadObjects();
                m_screenToLoad.UnloadContent();
                m_screenToLoad.UnloadData();

                //m_screenToLoad.UnloadData();
                m_screenToLoad = null;
            }


            if (m_screenToLoad != null && !m_loadInDrawFinished)
            {
                m_screenToLoad.UnloadContent();
            }

            VRageRender.MyRenderProxy.LimitMaxQueueSize = false;

            base.UnloadContent();

            System.Diagnostics.Debug.Assert(Static == this);
            Static = null;

            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
        }
        private void OnLoadException(Exception e, StringBuilder errorText, float heightMultiplier = 1.0f)
        {
            MySandboxGame.Log.WriteLine("ERROR: Loading screen failed");
            MySandboxGame.Log.WriteLine(e);
            m_screenToLoad = null;

            // GamePlayScreen might not have been unloaded, so check this here
            if (MyGuiScreenGamePlay.Static != null)
            {
                MyGuiScreenGamePlay.Static.UnloadData();
                MyGuiScreenGamePlay.Static.UnloadContent();
            }
            // Reset this to true so we have sounds
            MySandboxGame.IsUpdateReady    = true;
            MySandboxGame.AreClipmapsReady = true;

            try
            {
                MyGuiScreenMainMenu.UnloadAndExitToMenu();
            }
            catch (Exception ex)
            {
                MySession.Static = null;
                MySandboxGame.Log.WriteLine("ERROR: failed unload after exception in loading !");
                MySandboxGame.Log.WriteLine(ex);
            }

            var errorScreen = MyGuiSandbox.CreateMessageBox(
                messageText: errorText,
                messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError));

            var size = errorScreen.Size.Value;

            size.Y          *= heightMultiplier;
            errorScreen.Size = size;
            errorScreen.RecreateControls(false);

            MyGuiSandbox.AddScreen(errorScreen);
        }
Exemplo n.º 15
0
        public MyGuiScreenLoading(MyGuiScreenGamePlay screenToLoad, MyGuiScreenGamePlay screenToUnload, string textureFromConstructor, string customText = null)
            : base(Vector2.Zero, null, null)
        {
            MyLoadingPerformance.Instance.StartTiming();

            System.Diagnostics.Debug.Assert(Static == null);
            Static = this;

            m_screenToLoad = screenToLoad;
            m_screenToUnload = screenToUnload;
            m_closeOnEsc = false;
            DrawMouseCursor = false;
            m_loadInDrawFinished = false;
            m_drawEvenWithoutFocus = true;
            m_currentQuote = MyLoadingScreenQuote.GetRandomQuote();
            m_isFirstForUnload = true;

            // Has to be done because of HW Cursor
            MyGuiSandbox.SetMouseCursorVisibility(false);

            m_rotatingWheelTexture = MyGuiConstants.LOADING_TEXTURE_LOADING_SCREEN;
            m_backgroundTextureFromConstructor = textureFromConstructor;
            m_customTextFromConstructor = customText;

            m_loadFinished = false;

            //MyAudio.Static.Mute = true;

            if (m_screenToLoad != null)
            {
                MySandboxGame.IsUpdateReady = false;
                MySandboxGame.AreClipmapsReady = MySandboxGame.IsDedicated;
            }

            m_authorWithDash = new StringBuilder();

            RecreateControls(true);
        }
        public MyGuiScreenLoading(MyGuiScreenGamePlay screenToLoad, MyGuiScreenGamePlay screenToUnload, string textureFromConstructor, string customText = null)
            : base(Vector2.Zero, null, null)
        {
            MyLoadingPerformance.Instance.StartTiming();

            System.Diagnostics.Debug.Assert(Static == null);
            Static = this;

            m_screenToLoad         = screenToLoad;
            m_screenToUnload       = screenToUnload;
            m_closeOnEsc           = false;
            DrawMouseCursor        = false;
            m_loadInDrawFinished   = false;
            m_drawEvenWithoutFocus = true;
            m_currentQuote         = MyLoadingScreenQuote.GetRandomQuote();
            m_isFirstForUnload     = true;

            // Has to be done because of HW Cursor
            MyGuiSandbox.SetMouseCursorVisibility(false);

            m_rotatingWheelTexture             = MyGuiConstants.LOADING_TEXTURE_LOADING_SCREEN;
            m_backgroundTextureFromConstructor = textureFromConstructor;
            m_customTextFromConstructor        = customText;

            m_loadFinished = false;

            //MyAudio.Static.Mute = true;

            if (m_screenToLoad != null)
            {
                MySandboxGame.IsUpdateReady    = false;
                MySandboxGame.AreClipmapsReady = MySandboxGame.IsDedicated;
            }

            m_authorWithDash = new StringBuilder();

            RecreateControls(true);
        }
Exemplo n.º 17
0
        private void OnLoadException(Exception e, StringBuilder errorText, float heightMultiplier = 1.0f)
        {
            MySandboxGame.Log.WriteLine("ERROR: Loading screen failed");
            MySandboxGame.Log.WriteLine(e);
            m_screenToLoad = null;

            // GamePlayScreen might not have been unloaded, so check this here
            if (MyGuiScreenGamePlay.Static != null)
            {
                MyGuiScreenGamePlay.Static.UnloadData();
                MyGuiScreenGamePlay.Static.UnloadContent();
            }
            // Reset this to true so we have sounds
            MySandboxGame.IsUpdateReady = true;
            MySandboxGame.AreClipmapsReady = true;

            try
            {
                MySessionLoader.UnloadAndExitToMenu();
            }
            catch (Exception ex)
            {
                MySession.Static = null;
                MySandboxGame.Log.WriteLine("ERROR: failed unload after exception in loading !");
                MySandboxGame.Log.WriteLine(ex);
            }

            var errorScreen = MyGuiSandbox.CreateMessageBox(
                messageText: errorText,
                messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError));

            var size = errorScreen.Size.Value;
            size.Y *= heightMultiplier;
            errorScreen.Size = size;
            errorScreen.RecreateControls(false);

            MyGuiSandbox.AddScreen(errorScreen);
        }
Exemplo n.º 18
0
        public override bool Update(bool hasFocus)
        {
            if (base.Update(hasFocus) == false) return false;

            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyGuiScreenLoading::Update()");
            if (this.State == MyGuiScreenState.OPENED)
            {
                if (!m_loadFinished)
                {
                    MyAudio.Static.Mute = true;
                    MyAudio.Static.StopMusic();
                    MyAudio.Static.VolumeMusic = 0f;
                    MyAudio.Static.VolumeGame = 0f;
                    MyAudio.Static.VolumeHud = 0f;
                    VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("LoadInBackgroundThread");

                    DrawLoading();

                    if (m_screenToLoad != null)
                    {
                        MySandboxGame.Log.WriteLine("RunLoadingAction - START");
                        RunLoad();
                        MySandboxGame.Log.WriteLine("RunLoadingAction - END");
                    }
                    if (m_screenToLoad != null)
                    {
                        //  Screen is loaded so now we can add it to other thread
                        MyScreenManager.AddScreenNow(m_screenToLoad);
                        m_screenToLoad.Update(false);
                    }

                    m_screenToLoad = null;

                    m_loadFinished = true;
                    m_wheel.ManualRotationUpdate = true;

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

            if (m_loadFinished && MySandboxGame.IsGameReady)
            {
                if (!m_exceptionDuringLoad && OnScreenLoadingFinished != null)
                {
                    OnScreenLoadingFinished();
                    OnScreenLoadingFinished = null;
                }
                CloseScreenNow();
                DrawLoading();
            }

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

            return true;
        }
Exemplo n.º 19
0
        public override void UnloadContent()
        {
            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyGuiScreenLoading::UnloadContent");
            //  This is just for case that whole application is quiting after Alt+F4 or something
            //  Don't try to unload content in that thread or something - we don't know in what state it is. Just abort it.

            if (m_backgroundScreenTexture != null) VRageRender.MyRenderProxy.UnloadTexture(m_backgroundScreenTexture);
            if (m_backgroundTextureFromConstructor != null) VRageRender.MyRenderProxy.UnloadTexture(m_backgroundTextureFromConstructor);
            if (m_backgroundScreenTexture != null) VRageRender.MyRenderProxy.UnloadTexture(m_rotatingWheelTexture);

            if (m_screenToLoad != null && !m_loadFinished && m_loadInDrawFinished)
            {
                //  Call unload because there might be running precalc threads and we need to stop them
                //m_screenToLoad.UnloadObjects();
                m_screenToLoad.UnloadContent();
                m_screenToLoad.UnloadData();

                //m_screenToLoad.UnloadData();
                m_screenToLoad = null;
            }


            if (m_screenToLoad != null && !m_loadInDrawFinished)
            {
                m_screenToLoad.UnloadContent();
            }

            VRageRender.MyRenderProxy.LimitMaxQueueSize = false;

            base.UnloadContent();

            System.Diagnostics.Debug.Assert(Static == this);
            Static = null;

            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
        }
Exemplo n.º 20
0
 public MyGuiScreenLoading(MyGuiScreenGamePlay screenToLoad, MyGuiScreenGamePlay screenToUnload)
     : this(screenToLoad, screenToUnload, null)
 {
 }
 public MyGuiScreenLoading(MyGuiScreenGamePlay screenToLoad, MyGuiScreenGamePlay screenToUnload)
     : this(screenToLoad, screenToUnload, null)
 {
 }
Exemplo n.º 22
0
        //  IMPORTANT: This method will be called in background thread so don't mess with main thread objects!!!
        //  UPDATE: called always when GDevice is disposed
        public override void UnloadContent()
        {
            MySandboxGame.Log.WriteLine("MyGuiScreenGamePlay.UnloadContent - START");
            MySandboxGame.Log.IncreaseIndent();

            base.UnloadContent();

            MyXAudio2 audio = MyAudio.Static as MyXAudio2;
            if (audio != null)
            {
                MyEntity3DSoundEmitter.ClearEntityEmitters();
                audio.ClearSounds();
            }

            //  Do GC collect as last step. Reason is that after we loaded new level, a lot of garbage is created and we want to clear it now and not wait until GC decides so.
            GC.Collect();

            Static = null;

            MySandboxGame.Log.DecreaseIndent();
            MySandboxGame.Log.WriteLine("MyGuiScreenGamePlay.UnloadContent - END");
        }
Exemplo n.º 23
0
        //  IMPORTANT: This method will be called in background thread so don't mess with main thread objects!!!
        public override void LoadContent()
        {
            MySandboxGame.Log.WriteLine("MyGuiScreenGamePlay.LoadContent - START");
            MySandboxGame.Log.IncreaseIndent();

            Static = this;
            base.LoadContent();

            MySandboxGame.IsUpdateReady = true;
            MySandboxGame.Log.DecreaseIndent();
            MySandboxGame.Log.WriteLine("MyGuiScreenGamePlay.LoadContent - END");
        }
        public void LoadMission(string sessionPath, string name, string description, bool multiplayer)
        {
            MyLog.Default.WriteLine("LoadSession() - Start");
            MyLog.Default.WriteLine(sessionPath);

            ulong checkpointSizeInBytes;
            var   checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out checkpointSizeInBytes);

            checkpoint.Settings.OnlineMode       = (MyOnlineModeEnum)m_onlineMode.GetSelectedKey();
            checkpoint.Settings.MaxPlayers       = (short)m_maxPlayersSlider.Value;
            checkpoint.Settings.Scenario         = true;
            checkpoint.Settings.GameMode         = MyGameModeEnum.Survival;
            checkpoint.Settings.ScenarioEditMode = false;

            if (!MySession.IsCompatibleVersion(checkpoint))
            {
                MyLog.Default.WriteLine(MyTexts.Get(MySpaceTexts.DialogTextIncompatibleWorldVersion).ToString());
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(MySpaceTexts.DialogTextIncompatibleWorldVersion),
                                           buttonType: MyMessageBoxButtonsType.OK));
                MyLog.Default.WriteLine("LoadSession() - End");
                return;
            }

            if (!MySteamWorkshop.CheckLocalModsAllowed(checkpoint.Mods, checkpoint.Settings.OnlineMode == MyOnlineModeEnum.OFFLINE))
            {
                MyLog.Default.WriteLine(MyTexts.Get(MySpaceTexts.DialogTextLocalModsDisabledInMultiplayer).ToString());
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(MySpaceTexts.DialogTextLocalModsDisabledInMultiplayer),
                                           buttonType: MyMessageBoxButtonsType.OK));
                MyLog.Default.WriteLine("LoadSession() - End");
                return;
            }


            MySteamWorkshop.DownloadModsAsync(checkpoint.Mods, delegate(bool success)
            {
                if (success || (checkpoint.Settings.OnlineMode == MyOnlineModeEnum.OFFLINE) && MySteamWorkshop.CanRunOffline(checkpoint.Mods))
                {
                    //Sandbox.Audio.MyAudio.Static.Mute = true;

                    MyScreenManager.CloseAllScreensNowExcept(null);
                    MyGuiSandbox.Update(MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS);

                    // May be called from gameplay, so we must make sure we unload the current game
                    if (MySession.Static != null)
                    {
                        MySession.Static.Unload();
                        MySession.Static = null;
                    }

                    //seed 0 has special meaning - please randomize at mission start. New seed will be saved and game will run with it ever since.
                    //  if you use this, YOU CANNOT HAVE ANY PROCEDURAL ASTEROIDS ALREADY SAVED
                    if (checkpoint.Settings.ProceduralSeed == 0)
                    {
                        checkpoint.Settings.ProceduralSeed = MyRandom.Instance.Next();
                    }

                    MyGuiScreenGamePlay.StartLoading(delegate
                    {
                        checkpoint.Settings.Scenario = true;
                        MySession.LoadMission(sessionPath, checkpoint, checkpointSizeInBytes, name, description);
                    });
                }
                else
                {
                    MyLog.Default.WriteLine(MyTexts.Get(MySpaceTexts.DialogTextDownloadModsFailed).ToString());
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                               messageCaption : MyTexts.Get(MySpaceTexts.MessageBoxCaptionError),
                                               messageText : MyTexts.Get(MySpaceTexts.DialogTextDownloadModsFailed),
                                               buttonType : MyMessageBoxButtonsType.OK, callback : delegate(MyGuiScreenMessageBox.ResultEnum result)
                    {
                        if (MyFakes.QUICK_LAUNCH != null)
                        {
                            MyGuiScreenMainMenu.ReturnToMainMenu();
                        }
                    }));
                }
                MyLog.Default.WriteLine("LoadSession() - End");
            });
        }
Exemplo n.º 25
0
        public static void LoadSingleplayerSession(MyObjectBuilder_Checkpoint checkpoint, string sessionPath, ulong checkpointSizeInBytes)
        {
            if (!MySession.IsCompatibleVersion(checkpoint))
            {
                MyLog.Default.WriteLine(MyTexts.Get(MyCommonTexts.DialogTextIncompatibleWorldVersion).ToString());
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(MyCommonTexts.DialogTextIncompatibleWorldVersion),
                                           buttonType: MyMessageBoxButtonsType.OK));
                MyLog.Default.WriteLine("LoadSession() - End");
                return;
            }

            if (!MySteamWorkshop.CheckLocalModsAllowed(checkpoint.Mods, checkpoint.Settings.OnlineMode == MyOnlineModeEnum.OFFLINE))
            {
                MyLog.Default.WriteLine(MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer).ToString());
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer),
                                           buttonType: MyMessageBoxButtonsType.OK));
                MyLog.Default.WriteLine("LoadSession() - End");
                return;
            }


            MySteamWorkshop.DownloadModsAsync(checkpoint.Mods, delegate(bool success)
            {
                if (success || (checkpoint.Settings.OnlineMode == MyOnlineModeEnum.OFFLINE) && MySteamWorkshop.CanRunOffline(checkpoint.Mods))
                {
                    //Sandbox.Audio.MyAudio.Static.Mute = true;

                    MyScreenManager.CloseAllScreensNowExcept(null);
                    MyGuiSandbox.Update(VRage.Game.MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS);

                    // May be called from gameplay, so we must make sure we unload the current game
                    if (MySession.Static != null)
                    {
                        MySession.Static.Unload();
                        MySession.Static = null;
                    }
                    MyGuiScreenGamePlay.StartLoading(delegate
                    {
                        MyAnalyticsHelper.SetEntry(MyGameEntryEnum.Load);
                        MySession.Load(sessionPath, checkpoint, checkpointSizeInBytes);
                    });
                }
                else
                {
                    MyLog.Default.WriteLine(MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed).ToString());

                    if (MySteam.IsOnline)
                    {
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                   messageCaption : MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                                   messageText : MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed),
                                                   buttonType : MyMessageBoxButtonsType.OK, callback : delegate(MyGuiScreenMessageBox.ResultEnum result)
                        {
                            if (MyFakes.QUICK_LAUNCH != null)
                            {
                                MyGuiScreenMainMenu.ReturnToMainMenu();
                            }
                        }));
                    }
                    else
                    {
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                   messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                                   messageText: MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailedSteamOffline),
                                                   buttonType: MyMessageBoxButtonsType.OK));
                    }
                }
                MyLog.Default.WriteLine("LoadSession() - End");
            });
        }
Exemplo n.º 26
0
        //  IMPORTANT: This method will be called in background thread so don't mess with main thread objects!!!
        //  UPDATE: called always when GDevice is disposed
        public override void UnloadContent()
        {
            MySandboxGame.Log.WriteLine("MyGuiScreenGamePlay.UnloadContent - START");
            MySandboxGame.Log.IncreaseIndent();

            base.UnloadContent();

            //  Do GC collect as last step. Reason is that after we loaded new level, a lot of garbage is created and we want to clear it now and not wait until GC decides so.
            GC.Collect();

            Static = null;

            MySandboxGame.Log.DecreaseIndent();
            MySandboxGame.Log.WriteLine("MyGuiScreenGamePlay.UnloadContent - END");
        }
 private void OnPlayerControl(MyGuiControlButton obj)
 {
     m_attachCamera = 0;
     MySessionComponentAnimationSystem.Static.EntitySelectedForDebug = null; // reset debugging
     MyGuiScreenGamePlay.SetCameraController();
 }
Exemplo n.º 28
0
 private void OnPlayerControl(MyGuiControlButton obj)
 {
     m_attachCamera = 0;
     MyGuiScreenGamePlay.SetCameraController();
 }
Exemplo n.º 29
0
        public static void StartLoading(Action loadingAction, string customLoadingBackground = null, string customLoadingtext = null)
        {
            MyAnalyticsHelper.LoadingStarted();
            var newGameplayScreen = new MyGuiScreenGamePlay();
            newGameplayScreen.OnLoadingAction += loadingAction;

            var loadScreen = new MyGuiScreenLoading(newGameplayScreen, MyGuiScreenGamePlay.Static, customLoadingBackground, customLoadingtext);
            loadScreen.OnScreenLoadingFinished += delegate
            {
                MyModAPIHelper.OnSessionLoaded();
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.HUDScreen));
            };
            MyGuiSandbox.AddScreen(loadScreen);
        }