Beispiel #1
0
        private static void CheckDx11AndJoin(MyObjectBuilder_World world, MyMultiplayerBase multiplayer)
        {
            bool needsDx11 = world.Checkpoint.RequiresDX >= 11;

            if (!needsDx11 || MySandboxGame.IsDirectX11)
            {
                if (multiplayer.Battle)
                {
                    if (multiplayer.BattleCanBeJoined)
                    {
                        MySessionLoader.LoadMultiplayerBattleWorld(world, multiplayer);
                    }
                    else
                    {
                        MyLog.Default.WriteLine("World downloaded but battle game ended");
                        MySessionLoader.UnloadAndExitToMenu();
                        MyGuiSandbox.Show(MyCommonTexts.MultiplayerErrorSessionEnded);
                        multiplayer.Dispose();
                    }
                }
                else if (multiplayer.Scenario)
                {
                    MySessionLoader.LoadMultiplayerScenarioWorld(world, multiplayer);
                }
                else
                {
                    MySessionLoader.LoadMultiplayerSession(world, multiplayer);
                }
            }
            else
            {
                HandleDx11Needed();
            }
        }
 public void OnMessageBoxAdapterChangeCallback(MyGuiScreenMessageBox.ResultEnum callbackReturn)
 {
     if (callbackReturn == MyGuiScreenMessageBox.ResultEnum.YES)
     {
         MySessionLoader.ExitGame();
     }
 }
        protected override void OnClientBan(ref MyControlBanClientMsg data, ulong sender)
        {
            if (data.BannedClient == Sync.MyId && data.Banned == true)
            {
                // We don't want to send disconnect message because the clients will disconnect the client automatically upon receiving on the MyControlBanClientMsg
                m_clientJoined = false;

                Dispose();
                MySessionLoader.UnloadAndExitToMenu();
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionKicked),
                                           messageText: MyTexts.Get(MyCommonTexts.MessageBoxTextYouHaveBeenBanned)));
            }
            else
            {
                if (data.Banned)
                {
                    AddBannedClient(data.BannedClient);
                }
                else
                {
                    RemoveBannedClient(data.BannedClient);
                }

                if (m_members.Contains(data.BannedClient) && data.Banned == true)
                {
                    RaiseClientLeft(data.BannedClient, ChatMemberStateChangeEnum.Banned);
                }
            }
        }
Beispiel #4
0
 protected override void OnClientBan(ref MyControlBanClientMsg data, ulong sender)
 {
     if ((data.BannedClient == Sync.MyId) && data.Banned)
     {
         MySessionLoader.UnloadAndExitToMenu();
         StringBuilder messageCaption = MyTexts.Get(MyCommonTexts.MessageBoxCaptionKicked);
         MyStringId?   okButtonText   = null;
         okButtonText = null;
         okButtonText = null;
         okButtonText = null;
         Vector2?size = null;
         MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, MyTexts.Get(MyCommonTexts.MessageBoxTextYouHaveBeenBanned), messageCaption, okButtonText, okButtonText, okButtonText, okButtonText, null, 0, MyGuiScreenMessageBox.ResultEnum.YES, true, size));
     }
     else
     {
         if (data.Banned)
         {
             base.AddBannedClient(data.BannedClient);
         }
         else
         {
             base.RemoveBannedClient(data.BannedClient);
         }
         if (this.m_members.Contains(data.BannedClient) && data.Banned)
         {
             base.RaiseClientLeft(data.BannedClient, MyChatMemberStateChangeEnum.Banned);
         }
     }
 }
Beispiel #5
0
        public void SendPlayerData(string clientName)
        {
            uint num;
            uint num2;
            ConnectedClientDataMsg msg = new ConnectedClientDataMsg {
                SteamID          = Sync.MyId,
                Name             = clientName,
                Join             = true,
                ExperimentalMode = this.ExperimentalMode
            };

            byte[] buffer = new byte[0x400];
            if (MyGameService.GetAuthSessionTicket(out num2, buffer, out num))
            {
                msg.Token = new byte[num];
                Array.Copy(buffer, msg.Token, (long)num);
                base.ReplicationLayer.SendClientConnected(ref msg);
            }
            else
            {
                MySessionLoader.UnloadAndExitToMenu();
                StringBuilder messageCaption = MyTexts.Get(MyCommonTexts.MessageBoxCaptionError);
                MyStringId?   okButtonText   = null;
                okButtonText = null;
                okButtonText = null;
                okButtonText = null;
                Vector2?size = null;
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, MyTexts.Get(MyCommonTexts.MultiplayerErrorConnectionFailed), messageCaption, okButtonText, okButtonText, okButtonText, okButtonText, null, 0, MyGuiScreenMessageBox.ResultEnum.YES, true, size));
            }
        }
        public void SendPlayerData(string clientName)
        {
            ConnectedClientDataMsg msg = new ConnectedClientDataMsg();

            msg.SteamID = Sync.MyId;
            msg.Name    = clientName;
            msg.Join    = true;

            var  buffer = new byte[1024];
            uint length;
            uint ticketHandle; // TODO: Store handle and end auth session on end

            if (!MySteam.API.GetAuthSessionTicket(out ticketHandle, buffer, out length))
            {
                MySessionLoader.UnloadAndExitToMenu();
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(MyCommonTexts.MultiplayerErrorConnectionFailed)));
                return;
            }

            msg.Token = new byte[length];
            Array.Copy(buffer, msg.Token, length);

            ReplicationLayer.SendClientConnected(ref msg);
        }
Beispiel #7
0
        private void StartNewSandbox()
        {
            MyLog.Default.WriteLine("StartNewSandbox - Start");

            GetSettingsFromControls();

            // Load the checkpoint
            ulong checkpointSizeInBytes;
            var   sesionPath = m_scenarioTypesGroup.SelectedButton.UserData as string;

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

            if (checkpoint == null)
            {
                return;
            }

            GetSettingsFromControls();
            checkpoint.Settings    = m_settings;
            checkpoint.SessionName = m_nameTextbox.Text;
            checkpoint.Password    = GetPassword();
            checkpoint.Description = GetDescription();
            checkpoint.Mods        = m_mods;

            SetupWorldGeneratorSettings(checkpoint);

            MySessionLoader.LoadSingleplayerSession(
                checkpoint,
                sesionPath,
                checkpointSizeInBytes,
                () =>
            {
                MySession.Static.Save(Path.Combine(MyFileSystem.SavesPath, checkpoint.SessionName.Replace(':', '-')));
            });
        }
Beispiel #8
0
#pragma warning restore 649

        private void DoLoadSession(string sessionPath)
        {
            if (!Path.IsPathRooted(sessionPath))
            {
                sessionPath = Path.Combine(MyFileSystem.SavesPath, sessionPath);
            }

            if (!Sandbox.Engine.Platform.Game.IsDedicated)
            {
                MySessionLoader.LoadSingleplayerSession(sessionPath);
                return;
            }
            ulong checkpointSize;
            MyObjectBuilder_Checkpoint checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out checkpointSize);

            if (MySession.IsCompatibleVersion(checkpoint))
            {
                if (MySteamWorkshop.DownloadWorldModsBlocking(checkpoint.Mods).Success)
                {
                    // MySpaceAnalytics.Instance.SetEntry(MyGameEntryEnum.Load);
                    MySession.Load(sessionPath, checkpoint, checkpointSize);
                    _hostServerForSession(MySession.Static, MyMultiplayer.Static);
                }
                else
                {
                    MyLog.Default.WriteLineAndConsole("Unable to download mods");
                }
            }
            else
            {
                MyLog.Default.WriteLineAndConsole(MyTexts.Get(MyCommonTexts.DialogTextIncompatibleWorldVersion)
                                                  .ToString());
            }
        }
        private void OnExitToMainMenuClick(MyGuiControlButton sender)
        {
            if (!Sync.IsServer)
            {
                MySessionLoader.UnloadAndExitToMenu();
                return;
            }

            this.CanBeHidden = false;
            MyGuiScreenMessageBox messageBox;

            if (MyCampaignManager.Static.IsCampaignRunning)
            {
                messageBox = MyGuiSandbox.CreateMessageBox(
                    buttonType: MyMessageBoxButtonsType.YES_NO,
                    messageText: MyTexts.Get(MyCommonTexts.MessageBoxTextCampaignBeforeExit),
                    messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionExit),
                    callback: OnExitToMainMenuFromCampaignMessageBoxCallback);
            }
            else
            {
                messageBox = MyGuiSandbox.CreateMessageBox(
                    buttonType: MyMessageBoxButtonsType.YES_NO_CANCEL,
                    messageText: MyTexts.Get(MyCommonTexts.MessageBoxTextSaveChangesBeforeExit),
                    messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionExit),
                    callback: OnExitToMainMenuMessageBoxCallback);
            }
            messageBox.SkipTransition = true;
            messageBox.InstantClose   = false;
            MyGuiSandbox.AddScreen(messageBox);
        }
Beispiel #10
0
        public static void JoinGame(GameServerItem server)
        {
            MyAnalyticsHelper.SetEntry(MyGameEntryEnum.Join);
            if (server.ServerVersion != MyFinalBuildConstants.APP_VERSION)
            {
                var sb = new StringBuilder();
                sb.AppendFormat(MyTexts.GetString(MyCommonTexts.MultiplayerError_IncorrectVersion), MyFinalBuildConstants.APP_VERSION, server.ServerVersion);
                MyGuiSandbox.Show(sb, MyCommonTexts.MessageBoxCaptionError);
                return;
            }
            if (MyFakes.ENABLE_MP_DATA_HASHES)
            {
                var serverHash = server.GetGameTagByPrefix("datahash");
                if (serverHash != "" && serverHash != MyDataIntegrityChecker.GetHashBase64())
                {
                    MyGuiSandbox.Show(MyCommonTexts.MultiplayerError_DifferentData);
                    MySandboxGame.Log.WriteLine("Different game data when connecting to server. Local hash: " + MyDataIntegrityChecker.GetHashBase64() + ", server hash: " + serverHash);
                    return;
                }
            }

            UInt32 unixTimestamp = (UInt32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

            SteamAPI.Instance.AddFavoriteGame(server.AppID, System.Net.IPAddressExtensions.ToIPv4NetworkOrder(server.NetAdr.Address), (UInt16)server.NetAdr.Port, (UInt16)server.NetAdr.Port, FavoriteEnum.History, unixTimestamp);

            MyMultiplayerClient multiplayer = new MyMultiplayerClient(server, new MySyncLayer(new MyTransportLayer(MyMultiplayer.GameEventChannel)));

            MyMultiplayer.Static = multiplayer;
            MyMultiplayer.Static.SyncLayer.AutoRegisterGameEvents = false;
            MyMultiplayer.Static.SyncLayer.RegisterGameEvents();

            multiplayer.SendPlayerData(MySteam.UserName);

            string        gamemode = server.GetGameTagByPrefix("gamemode");
            StringBuilder text     = MyTexts.Get(MyCommonTexts.DialogTextJoiningWorld);

            MyGuiScreenProgress progress = new MyGuiScreenProgress(text, MyCommonTexts.Cancel);

            MyGuiSandbox.AddScreen(progress);
            progress.ProgressCancelled += () =>
            {
                multiplayer.Dispose();
                MySessionLoader.UnloadAndExitToMenu();
                if (MyMultiplayer.Static != null)
                {
                    MyMultiplayer.Static.Dispose();
                }
            };

            multiplayer.OnJoin += delegate
            {
                MyJoinGameHelper.OnJoin(progress, SteamSDK.Result.OK, new LobbyEnterInfo()
                {
                    EnterState = LobbyEnterResponseEnum.Success
                }, multiplayer);
            };

            VRage.Profiler.MyRenderProfiler.GetProfilerFromServer = MyMultiplayer.Static.DownloadProfiler;
        }
 public static void UnloadAndRestart()
 {
     MySessionLoader.Unload();
     MySandboxGame.Config.ControllerDefaultOnStart = MyInput.Static.IsJoystickLastUsed;
     MySandboxGame.Config.Save();
     MyScreenManager.CloseAllScreensNowExcept(null);
     Restart();
 }
Beispiel #12
0
        // unregisters callbacks and runs new mission when the session is being unloaded.
        public void LoadNextCampaignMission()
        {
            // Only server can switch missions
            if (MyMultiplayer.Static != null && !MyMultiplayer.Static.IsServer)
            {
                return;
            }

            // Save inventories
            SavePlayersInventories();

            var savePath   = MySession.Static.CurrentPath;
            var folderName = Path.GetDirectoryName(savePath.Replace(MyFileSystem.SavesPath + "\\", ""));

            // Campaign is finished
            if (m_runningCampaignSM.Finished)
            {
                // Disconnect and close clients
                CallCloseOnClients();
                // Return to main menu
                MySessionLoader.UnloadAndExitToMenu();

                // Call event OnCampaignFinished
                MyCampaignManager.Static.NotifyCampaignFinished();

                // Start Credits when the vanilla game ends.
                if (MyCampaignManager.Static.ActiveCampaign.IsVanilla)
                {
                    MyScreenManager.AddScreen(new MyGuiScreenGameCredits());
                }

                return;
            }

            // Load new level if campaign mode is still active
            // In case of exit to main menu
            UpdateStateMachine();

            // Check the state data
            var currentCampaignNode = m_runningCampaignSM.CurrentNode as MyCampaignStateMachineNode;

            Debug.Assert(currentCampaignNode != null);
            var sessionPathToLoad = currentCampaignNode.SavePath;

            Debug.Assert(!string.IsNullOrEmpty(sessionPathToLoad), "ERROR: Missing campaign world file!");

            // Reconnect clients to new session
            CallReconnectOnClients();

            // Load new session and add this session component to it
            MyCampaignManager.Static.LoadSessionFromActiveCampaign(sessionPathToLoad, () =>
            {
                // Recycle this component
                MySession.Static.RegisterComponent(this, MyUpdateOrder.NoUpdate, 555);
                LoadPlayersInventories();
            }, folderName
                                                                   );
        }
Beispiel #13
0
 public void Connect(string address)
 {
     MySessionLoader.UnloadAndExitToMenu();
     MyGameService.OnPingServerResponded       -= ServerResponded;
     MyGameService.OnPingServerFailedToRespond -= ServerFailedToRespond;
     MyGameService.OnPingServerResponded       += ServerResponded;
     MyGameService.OnPingServerFailedToRespond += ServerFailedToRespond;
     MyGameService.PingServer(address);
 }
Beispiel #14
0
 public void Update()
 {
     if (_firstInit)
     {
         _firstInit              = false;
         MySession.AfterLoading += MySession_AfterLoading;
         MySessionLoader.LoadInventoryScene();
     }
 }
        void MyMultiplayerClient_HostLeft()
        {
            m_clientJoined = false;
            CloseSession();

            MySessionLoader.UnloadAndExitToMenu();
            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                       messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                       messageText: MyTexts.Get(MyCommonTexts.MultiplayerErrorServerHasLeft)));
        }
Beispiel #16
0
 public override void UpdateAfterSimulation()
 {
     if (Enabled && MySandboxGame.IsGameReady && MySession.Static != null && MySession.Static.ElapsedPlayTime.TotalSeconds > 5)
     {
         GC.Collect(2, GCCollectionMode.Forced);
         MySandboxGame.Log.WriteLine(String.Format("RELOAD TEST, Game GC: {0} B", GC.GetTotalMemory(false).ToString("##,#")));
         MySandboxGame.Log.WriteLine(String.Format("RELOAD TEST, Game WS: {0} B", Process.GetCurrentProcess().PrivateMemorySize64.ToString("##,#")));
         MySessionLoader.UnloadAndExitToMenu();
     }
 }
        public override bool Update(bool hasFocus)
        {
            if (!hasFocus)
            {
                return(base.Update(hasFocus));
            }

            if (m_childScreenLaunched && hasFocus)
            {
                CloseScreenNow();
            }

            if (m_childScreenLaunched)
            {
                return(base.Update(hasFocus));
            }

            if (MyInput.Static.IsKeyPress(MyKeys.Escape))
            {
                MySessionLoader.UnloadAndExitToMenu();
                return(base.Update(hasFocus));
            }

            switch (m_quickLaunchType)
            {
            case MyQuickLaunchType.LAST_SANDBOX:
            {
                var lastSessionPath = MyLocalCache.GetLastSessionPath();
                if (lastSessionPath != null && System.IO.Directory.Exists(lastSessionPath))
                {
                    MySessionLoader.LoadSingleplayerSession(lastSessionPath);
                }
                else
                {
                    MySandboxGame.AfterLogos();
                }
                m_childScreenLaunched = true;
            }
            break;

            case MyQuickLaunchType.NEW_SANDBOX:
            {
                QuickstartSandbox(null, null);
                m_childScreenLaunched = true;
            }
            break;

            default:
            {
                throw new InvalidBranchException();
            }
            }

            return(base.Update(hasFocus));
        }
Beispiel #18
0
        public static void DoReload()
        {
            GC.Collect(2, GCCollectionMode.Forced);
            MySandboxGame.Log.WriteLine(String.Format("RELOAD TEST, Menu GC: {0} B", GC.GetTotalMemory(false).ToString("##,#")));
            MySandboxGame.Log.WriteLine(String.Format("RELOAD TEST, Menu WS: {0} B", Process.GetCurrentProcess().PrivateMemorySize64.ToString("##,#")));
            var session = MyLocalCache.GetAvailableWorldInfos().OrderByDescending(s => s.Item2.LastLoadTime).FirstOrDefault();

            if (session != null)
            {
                MySessionLoader.LoadSingleplayerSession(session.Item1);
            }
        }
    public static void DoReload()
    {
        GC.Collect(2, GCCollectionMode.Forced);
        MySandboxGame.Log.WriteLine(string.Format("RELOAD TEST, Menu GC: {0} B", GC.GetTotalMemory(forceFullCollection: false).ToString("##,#")));
        MySandboxGame.Log.WriteLine(string.Format("RELOAD TEST, Menu WS: {0} B", Process.GetCurrentProcess().PrivateMemorySize64.ToString("##,#")));
        Tuple <string, MyWorldInfo> tuple = Enumerable.FirstOrDefault(Enumerable.OrderByDescending(MyLocalCache.GetAvailableWorldInfos(), (Tuple <string, MyWorldInfo> s) => s.Item2.LastSaveTime));

        if (tuple != null)
        {
            MySessionLoader.LoadSingleplayerSession(tuple.Item1);
        }
    }
Beispiel #20
0
        private static void LoadMission(CheckpointData data)
        {
            var checkpoint = data.Checkpoint;

            MySteamWorkshop.DownloadModsAsync(checkpoint.Mods, delegate(bool success, string mismatchMods)
            {
                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);

                    MySessionLoader.CheckMismatchmods(mismatchMods, callback : delegate(VRage.Game.ModAPI.ResultEnum val)
                    {
                        // 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();
                        }

                        MySessionLoader.StartLoading(delegate
                        {
                            checkpoint.Settings.Scenario = true;
                            MySession.LoadMission(data.SessionPath, checkpoint, data.CheckpointSize, data.PersistentEditMode);
                        });
                    });
                }
                else
                {
                    MyLog.Default.WriteLine(MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed).ToString());
                    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)
                        {
                            MySessionLoader.UnloadAndExitToMenu();
                        }
                    }));
                }
                MyLog.Default.WriteLine("LoadSession() - End");
            });
        }
Beispiel #21
0
 private void Matchmaking_LobbyChatUpdate(IMyLobby lobby, ulong changedUser, ulong makingChangeUser, MyChatMemberStateChangeEnum stateChange)
 {
     if (lobby.LobbyId == this.m_lobby.LobbyId)
     {
         if (stateChange == MyChatMemberStateChangeEnum.Entered)
         {
             object[] objArray1 = new object[] { "Player entered: ", MyGameService.GetPersonaName(changedUser), " (", changedUser, ")" };
             MySandboxGame.Log.WriteLineAndConsole(string.Concat(objArray1));
             MyGameService.Peer2Peer.AcceptSession(changedUser);
             if ((Sync.Clients == null) || !Sync.Clients.HasClient(changedUser))
             {
                 base.RaiseClientJoined(changedUser);
                 if (this.Scenario && (changedUser != Sync.MyId))
                 {
                     base.SendAllMembersDataToClient(changedUser);
                 }
             }
             if (MySandboxGame.IsGameReady && (changedUser != base.ServerId))
             {
                 MyHudNotification notification = new MyHudNotification(MyCommonTexts.NotificationClientConnected, 0x1388, "Blue", MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0, MyNotificationLevel.Important);
                 object[]          arguments    = new object[] { MyGameService.GetPersonaName(changedUser) };
                 notification.SetTextFormatArguments(arguments);
                 MyHud.Notifications.Add(notification);
             }
         }
         else
         {
             if ((Sync.Clients == null) || Sync.Clients.HasClient(changedUser))
             {
                 base.RaiseClientLeft(changedUser, stateChange);
             }
             if (changedUser == base.ServerId)
             {
                 base.RaiseHostLeft();
                 MySessionLoader.UnloadAndExitToMenu();
                 StringBuilder messageCaption = MyTexts.Get(MyCommonTexts.MessageBoxCaptionError);
                 MyStringId?   okButtonText   = null;
                 okButtonText = null;
                 okButtonText = null;
                 okButtonText = null;
                 Vector2?size = null;
                 MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, MyTexts.Get(MyCommonTexts.MultiplayerErrorServerHasLeft), messageCaption, okButtonText, okButtonText, okButtonText, okButtonText, null, 0, MyGuiScreenMessageBox.ResultEnum.YES, true, size));
             }
             else if (MySandboxGame.IsGameReady)
             {
                 MyHudNotification notification = new MyHudNotification(MyCommonTexts.NotificationClientDisconnected, 0x1388, "Blue", MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0, MyNotificationLevel.Important);
                 object[]          arguments    = new object[] { MyGameService.GetPersonaName(changedUser) };
                 notification.SetTextFormatArguments(arguments);
                 MyHud.Notifications.Add(notification);
             }
         }
     }
 }
Beispiel #22
0
        private static bool LoadMultiplayerSession(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession)
        {
            MyLog.Default.WriteLine("LoadSession() - Start");
            if (!MyWorkshop.CheckLocalModsAllowed(world.Checkpoint.Mods, allowLocalMods: false))
            {
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.DialogTextLocalModsDisabledInMultiplayer)));
                MyLog.Default.WriteLine("LoadSession() - End");
                return(false);
            }
            MyWorkshop.DownloadModsAsync(world.Checkpoint.Mods, delegate(bool success)
            {
                if (success)
                {
                    MyScreenManager.CloseAllScreensNowExcept(null);
                    MyGuiSandbox.Update(16);
                    if (MySession.Static != null)
                    {
                        MySession.Static.Unload();
                        MySession.Static = null;
                    }

                    string CustomBackgroundImage = null;
                    GetCustomLoadingScreenPath(world.Checkpoint.Mods, out CustomBackgroundImage);

                    MySessionLoader.StartLoading(delegate
                    {
                        LoadMultiplayer.Invoke(null, new object[] { world, multiplayerSession });
                        //MySession.LoadMultiplayer(world, multiplayerSession);
                    }, null, CustomBackgroundImage, null);
                }
                else
                {
                    multiplayerSession.Dispose();
                    MySessionLoader.UnloadAndExitToMenu();
                    if (MyGameService.IsOnline)
                    {
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed)));
                    }
                    else
                    {
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(MyMessageBoxStyleEnum.Error, MyMessageBoxButtonsType.OK, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: new StringBuilder(string.Format(MyTexts.GetString(MyCommonTexts.DialogTextDownloadModsFailedSteamOffline), MySession.GameServiceName))));
                    }
                }
                MyLog.Default.WriteLine("LoadSession() - End");
            }, delegate
            {
                multiplayerSession.Dispose();
                MySessionLoader.UnloadAndExitToMenu();
            });

            return(false);
        }
Beispiel #23
0
 private void OnExitToMainMenuFromCampaignMessageBoxCallback(MyGuiScreenMessageBox.ResultEnum callbackReturn)
 {
     if (callbackReturn == MyGuiScreenMessageBox.ResultEnum.YES)
     {
         MyAudio.Static.Mute = true;
         MyAudio.Static.StopMusic();
         MySessionLoader.UnloadAndExitToMenu();
     }
     else
     {
         base.CanBeHidden = true;
     }
 }
Beispiel #24
0
        protected override void OnClosed()
        {
            MySyncScenario.PlayerReadyToStartScenario -= MySyncScenario_PlayerReady;
            MySyncScenario.TimeoutReceived            -= MySyncScenario_SetTimeout;
            MySyncScenario.CanJoinRunningReceived     -= MySyncScenario_SetCanJoinRunning;
            m_canJoinRunning.IsCheckedChanged         -= OnJoinRunningChecked;

            m_readyPlayers.Clear();
            base.OnClosed();
            if (Cancelled)
            {
                MySessionLoader.UnloadAndExitToMenu();
            }
        }
Beispiel #25
0
            public void JoinServer(string address)
            {
                if (MySandboxGame.IsDedicated && IsServer)
                {
                    return;
                }

                System.Net.IPEndPoint endpoint;
                if (System.Net.IPAddressExtensions.TryParseEndpoint(address, out endpoint))
                {
                    MySessionLoader.UnloadAndExitToMenu();
                    MySandboxGame.Services.SteamService.SteamAPI.PingServer(System.Net.IPAddressExtensions.ToIPv4NetworkOrder(endpoint.Address), (ushort)endpoint.Port);
                }
            }
 private void OnSuccess(string sessionPath)
 {
     if (m_currentButton == m_copyButton)
     {
         var loadScreen = new MyGuiScreenLoadSandbox();
         MyGuiSandbox.AddScreen(new MyGuiScreenLoadSandbox());
         // TODO: FIx whatever I broke here
         //loadScreen.SelectSteamWorld(sessionPath);
     }
     else if (m_currentButton == m_loadButton)
     {
         MySessionLoader.LoadSingleplayerSession(sessionPath);
     }
     m_currentButton = null;
 }
        private void StartNewSandbox()
        {
            MyLog.Default.WriteLine("StartNewSandbox - Start");

            GetSettingsFromControls();
            MySessionLoader.StartNewSession(
                m_nameTextbox.Text,
                m_settings,
                m_mods,
                (m_scenarioTypesGroup.SelectedButton as MyGuiControlScenarioButton).Scenario,
                AsteroidAmount,
                GetDescription(),
                GetPassword()
                );
        }
        private void QuickstartScenario(string scenarioName)
        {
            string path        = "CustomWorlds";
            string sessionPath = Path.Combine(MyFileSystem.ContentPath, path, scenarioName);
            ulong  sizeInBytes;
            MyObjectBuilder_Checkpoint checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out sizeInBytes);

            if (checkpoint != null)
            {
                MySessionLoader.LoadSingleplayerSession(checkpoint, sessionPath, sizeInBytes, delegate
                {
                    MyAsyncSaving.Start(null, Path.Combine(MyFileSystem.SavesPath, checkpoint.SessionName.Replace(':', '-')));
                });
            }
        }
        private void OnExitToMainMenuFromCampaignMessageBoxCallback(MyGuiScreenMessageBox.ResultEnum callbackReturn)
        {
            switch (callbackReturn)
            {
            case MyGuiScreenMessageBox.ResultEnum.YES:
                MyAudio.Static.Mute = true;
                MyAudio.Static.StopMusic();
                MySessionLoader.UnloadAndExitToMenu();
                break;

            default:
                this.CanBeHidden = true;
                break;
            }
        }
        public static string Connect(List <string> args)
        {
            if (args.Count < 1)
            {
                return("Not enough arguments!");
            }

            try
            {
                string[] array = args[0].Trim().Split(new char[]
                {
                    ':'
                });
                ushort num;
                if (array.Length < 2)
                {
                    num = 27016;
                }
                else
                {
                    num = ushort.Parse(array[1]);
                }
                IPAddress[] hostAddresses = Dns.GetHostAddresses(array[0]);

                StringBuilder text = MyTexts.Get(MyCommonTexts.DialogTextJoiningWorld);
                m_progressScreen = new MyGuiScreenProgress(text, new MyStringId?(MyCommonTexts.Cancel), false, true);
                MyGuiSandbox.AddScreen(m_progressScreen);
                m_progressScreen.ProgressCancelled += delegate
                {
                    CloseHandlers();
                    MySessionLoader.UnloadAndExitToMenu();
                };
                MyGameService.OnPingServerResponded       += new EventHandler <MyGameServerItem>(ServerResponded);
                MyGameService.OnPingServerFailedToRespond += new EventHandler(ServerFailedToRespond);
                MyGameService.PingServer(hostAddresses[0].ToIPv4NetworkOrder(), num);

                MyGameService.OnPingServerResponded       += new EventHandler <MyGameServerItem>(ServerResponded);
                MyGameService.OnPingServerFailedToRespond += new EventHandler(ServerFailedToRespond);
                MyGameService.PingServer(hostAddresses[0].ToIPv4NetworkOrder(), num);
            }
            catch (Exception ex)
            {
                MyGuiSandbox.Show(MyTexts.Get(MyCommonTexts.MultiplayerJoinIPError), MyCommonTexts.MessageBoxCaptionError, MyMessageBoxStyleEnum.Error);
            }

            return("Attempting to join server: ");
        }