예제 #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
    private void GenerateContinueTooltip(MyObjectBuilder_LastSession lastSession, MyGuiControlButton button, Vector2 correction)
    {
        string           thumbnail        = GetThumbnail(lastSession);
        string           text             = ((!lastSession.IsOnline) ? $"{MyTexts.GetString(MyCommonTexts.ToolTipContinueGame)}{Environment.NewLine}{lastSession.GameName}" : $"{MyTexts.GetString(MyCommonTexts.ToolTipContinueGame)}{Environment.NewLine}{lastSession.GameName} - {lastSession.GetConnectionString()}");
        MyGuiControlBase myGuiControlBase = null;

        if (thumbnail != null)
        {
            MyRenderProxy.PreloadTextures(new List <string> {
                thumbnail
            }, TextureType.GUIWithoutPremultiplyAlpha);
        }
        myGuiControlBase          = CreateImageTooltip(thumbnail, text);
        myGuiControlBase.Visible  = false;
        myGuiControlBase.Position = button.Position + new Vector2(0.5f * button.Size.X, -1f * button.Size.Y) + correction;
        m_continueTooltipcontrol  = myGuiControlBase;
        Controls.Add(m_continueTooltipcontrol);
    }