コード例 #1
0
 private void JoinServer(MyObjectBuilder_LastSession mySession)
 {
     try
     {
         MyGuiScreenProgress prog = new MyGuiScreenProgress(MyTexts.Get(MyCommonTexts.DialogTextCheckServerStatus));
         MyGuiSandbox.AddScreen(prog);
         MyGameService.OnPingServerResponded       += OnPingSuccess;
         MyGameService.OnPingServerFailedToRespond += OnPingFailure;
         MyGameService.PingServer(mySession.GetConnectionString());
         void OnPingFailure(object sender, object data)
         {
             MyGuiSandbox.RemoveScreen(prog);
             MySandboxGame.Static.ServerFailedToRespond(sender, data);
             MyGameService.OnPingServerResponded       -= OnPingSuccess;
             MyGameService.OnPingServerFailedToRespond -= OnPingFailure;
         }
         void OnPingSuccess(object sender, MyGameServerItem item)
         {
             MyGuiSandbox.RemoveScreen(prog);
             MySandboxGame.Static.ServerResponded(sender, item);
             MyGameService.OnPingServerResponded       -= OnPingSuccess;
             MyGameService.OnPingServerFailedToRespond -= OnPingFailure;
         }
     }
     catch (Exception ex)
     {
         MyLog.Default.WriteLine(ex);
         MyGuiSandbox.Show(MyTexts.Get(MyCommonTexts.MultiplayerJoinIPError), MyCommonTexts.MessageBoxCaptionError);
     }
 }
コード例 #2
0
 public void RemoveScreen(MyGuiScreenBase screen)
 {
     Scheduler.AddScheduledCallback(dt =>
     {
         screen.CloseScreenNow();
         MyGuiSandbox.RemoveScreen(screen);
     }, 0);
     _screens.Remove(screen);
 }
コード例 #3
0
 public override bool Update(bool hasFocus)
 {
     if (CloseWindow && m_wasDrawn)
     {
         MyGuiSandbox.RemoveScreen(m_currentServerSaveScreen);
         MyGuiSandbox.RemoveScreen(this);
     }
     return(true);
 }
コード例 #4
0
 private void StartScenario()
 {
     if (Sync.IsServer)
     {
         ServerStartGameTime = DateTime.UtcNow;
     }
     if (m_waitingScreen != null)
     {
         MyGuiSandbox.RemoveScreen(m_waitingScreen);
         m_waitingScreen = null;
     }
     GameState         = MyState.Running;
     m_startBattleTime = MySession.Static.ElapsedPlayTime;
     MyPlayerCollection.RequestLocalRespawn();
 }
コード例 #5
0
        protected override void OnUnload()
        {
            base.OnUnload();
            if (_screen != null)
            {
                RemoveScreen(_screen);
                _screen = null;
            }

            if (_ctx != null && _ctx.InStack)
                _ctx.Pop();

            foreach (var screen in _screens)
            {
                screen.CloseScreenNow();
                MyGuiSandbox.RemoveScreen(screen);
            }
            _screens.Clear();
        }