public void OnScenarioGameClick(MyGuiControlButton sender)
 {
     MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.ScenarioScreen));
 }
        protected override void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyTimerBlock>())
            {
                return;
            }
            base.CreateTerminalControls();
            var silent = new MyTerminalControlCheckbox <MyTimerBlock>("Silent", MySpaceTexts.BlockPropertyTitle_Silent, MySpaceTexts.ToolTipTimerBlock_Silent);

            silent.Getter = (x) => x.Silent;
            silent.Setter = (x, v) => x.Silent = v;
            silent.EnableAction();
            MyTerminalControlFactory.AddControl(silent);

            var slider = new MyTerminalControlSlider <MyTimerBlock>("TriggerDelay", MySpaceTexts.TerminalControlPanel_TimerDelay, MySpaceTexts.TerminalControlPanel_TimerDelay);

            slider.SetLogLimits(1, 60 * 60);
            slider.DefaultValue = 10;
            slider.Enabled      = (x) => !x.IsCountingDown;
            slider.Getter       = (x) => x.TriggerDelay;
            slider.Setter       = (x, v) => x.m_timerSync.Value = ((int)(Math.Round(v, 1) * 1000));
            slider.Writer       = (x, sb) => MyValueFormatter.AppendTimeExact(Math.Max(x.m_countdownMsStart, 1000) / 1000, sb);
            slider.EnableActions();
            MyTerminalControlFactory.AddControl(slider);

            var toolbarButton = new MyTerminalControlButton <MyTimerBlock>("OpenToolbar", MySpaceTexts.BlockPropertyTitle_TimerToolbarOpen, MySpaceTexts.BlockPropertyTitle_TimerToolbarOpen,
                                                                           delegate(MyTimerBlock self)
            {
                m_openedToolbars.Add(self.Toolbar);
                if (MyGuiScreenCubeBuilder.Static == null)
                {
                    m_shouldSetOtherToolbars          = true;
                    MyToolbarComponent.CurrentToolbar = self.Toolbar;
                    MyGuiScreenBase screen            = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.ToolbarConfigScreen, 0, self);
                    MyToolbarComponent.AutoUpdate     = false;
                    screen.Closed += (source) =>
                    {
                        MyToolbarComponent.AutoUpdate = true;
                        m_openedToolbars.Clear();
                    };
                    MyGuiSandbox.AddScreen(screen);
                }
            });

            MyTerminalControlFactory.AddControl(toolbarButton);

            var triggerButton = new MyTerminalControlButton <MyTimerBlock>("TriggerNow", MySpaceTexts.BlockPropertyTitle_TimerTrigger, MySpaceTexts.BlockPropertyTitle_TimerTrigger, (x) => x.OnTrigger());

            triggerButton.EnableAction();
            MyTerminalControlFactory.AddControl(triggerButton);

            var startButton = new MyTerminalControlButton <MyTimerBlock>("Start", MySpaceTexts.BlockPropertyTitle_TimerStart, MySpaceTexts.BlockPropertyTitle_TimerStart, (x) => x.StartBtn());

            startButton.EnableAction();
            MyTerminalControlFactory.AddControl(startButton);

            var stopButton = new MyTerminalControlButton <MyTimerBlock>("Stop", MySpaceTexts.BlockPropertyTitle_TimerStop, MySpaceTexts.BlockPropertyTitle_TimerStop, (x) => x.StopBtn());

            stopButton.EnableAction();
            MyTerminalControlFactory.AddControl(stopButton);
        }
示例#3
0
 private void OnSteamGuideClick(MyGuiControlButton sender)
 {
     MyGuiSandbox.OpenUrlWithFallback(MySteamConstants.URL_GUIDE_DEFAULT, "Steam Guide");
 }
示例#4
0
 private void OnBrowseWorkshopClick(MyGuiControlButton obj)
 {
     MyGuiSandbox.OpenUrlWithFallback(MySteamConstants.URL_BROWSE_WORKSHOP_SCENARIOS, "Steam Workshop");
 }
示例#5
0
 private void OnModsClick(object sender)
 {
     MyGuiSandbox.AddScreen(new MyGuiScreenMods(m_mods));
 }
示例#6
0
        private static void DownloadWorld(MyGuiScreenProgress progress, MyMultiplayerBase multiplayer)
        {
            if (progress.Text != null)
            {
                progress.Text.Clear();
                progress.Text.Append(MyTexts.Get(MySpaceTexts.MultiplayerStateConnectingToServer));
            }

            MyLog.Default.WriteLine("World requested");

            const float worldRequestTimeout = 40; // in seconds
            Stopwatch   worldRequestTime    = Stopwatch.StartNew();

            ulong serverId  = multiplayer.GetOwner();
            bool  connected = false;

            progress.Tick += () =>
            {
                P2PSessionState state = default(P2PSessionState);
                Peer2Peer.GetSessionState(multiplayer.ServerId, ref state);

                if (!connected && state.ConnectionActive)
                {
                    MyLog.Default.WriteLine("World requested - connection alive");
                    connected = true;
                    if (progress.Text != null)
                    {
                        progress.Text.Clear();
                        progress.Text.Append(MyTexts.Get(MySpaceTexts.MultiplayerStateWaitingForServer));
                    }
                }

                //progress.Text.Clear();
                //progress.Text.AppendLine("Connecting: " + state.Connecting);
                //progress.Text.AppendLine("ConnectionActive: " + state.ConnectionActive);
                //progress.Text.AppendLine("Relayed: " + state.UsingRelay);
                //progress.Text.AppendLine("Bytes queued: " + state.BytesQueuedForSend);
                //progress.Text.AppendLine("Packets queued: " + state.PacketsQueuedForSend);
                //progress.Text.AppendLine("Last session error: " + state.LastSessionError);
                //progress.Text.AppendLine("Original server: " + serverId);
                //progress.Text.AppendLine("Current server: " + multiplayer.Lobby.GetOwner());
                //progress.Text.AppendLine("Game version: " + multiplayer.AppVersion);

                if (serverId != multiplayer.GetOwner())
                {
                    MyLog.Default.WriteLine("World requested - failed, server changed");
                    progress.Cancel();
                    MyGuiSandbox.Show(MySpaceTexts.MultiplayerErrorServerHasLeft);
                    multiplayer.Dispose();
                }

                if (worldRequestTime.IsRunning && worldRequestTime.Elapsed.TotalSeconds > worldRequestTimeout)
                {
                    MyLog.Default.WriteLine("World requested - failed, server changed");
                    progress.Cancel();
                    MyGuiSandbox.Show(MySpaceTexts.MultiplaterJoin_ServerIsNotResponding);
                    multiplayer.Dispose();
                }
            };

            var downloadResult = multiplayer.DownloadWorld();

            downloadResult.ProgressChanged += (result) =>
            {
                worldRequestTime.Stop();
                OnDownloadProgressChanged(progress, result, multiplayer);
            };

            progress.ProgressCancelled += () =>
            {
                downloadResult.Cancel();
                multiplayer.Dispose();
                //var joinScreen = MyScreenManager.GetScreenWithFocus() as MyGuiScreenJoinGame;
                //if (joinScreen != null)
                //  joinScreen.ReloadList();
            };
        }
示例#7
0
        public bool TryNamingAnBlockOrFloatingObject()
        {
            var worldMatrix = MyAPIGateway.Session.Camera.WorldMatrix; // most accurate for player view.
            var position    = worldMatrix.Translation + worldMatrix.Forward * 0.5f;
            var ray         = new RayD(position, worldMatrix.Forward * 1000);

            var boundingSphere = new BoundingSphereD(worldMatrix.Translation, 30);
            var entites        = MyEntities.GetEntitiesInSphere(ref boundingSphere);

            List <MyPhysics.HitInfo> hits = new List <MyPhysics.HitInfo>();

            MyPhysics.CastRay(worldMatrix.Translation, worldMatrix.Translation + worldMatrix.Forward * 5, hits, 15);

            foreach (var hitInfo in hits)
            {
                var body = (MyPhysicsBody)hitInfo.HkHitInfo.Body.UserObject;
                if (body.Entity is MyFloatingObject)
                {
                    var rayEntity = (MyEntity)body.Entity;
                    NameDialog(rayEntity);
                    return(true);
                }
            }

            foreach (var entity in entites)
            {
                var cubeGrid = entity as MyCubeGrid;

                if (cubeGrid != null && ray.Intersects(entity.PositionComp.WorldAABB).HasValue)
                {
                    var hit = cubeGrid.RayCastBlocks(worldMatrix.Translation, worldMatrix.Translation + worldMatrix.Forward * 100);
                    if (hit.HasValue)
                    {
                        var block = cubeGrid.GetCubeBlock(hit.Value);

                        if (block.FatBlock != null)
                        {
                            var dialog = new ValueGetScreenWithCaption("Name block dialog: " + block.FatBlock.DefinitionDisplayNameText, block.FatBlock.Name ?? block.FatBlock.DefinitionDisplayNameText + " has no name.", delegate(string text)
                            {
                                MyEntity foundEntity;
                                if (MyEntities.TryGetEntityByName(text, out foundEntity))
                                {
                                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                               buttonType: MyMessageBoxButtonsType.OK,
                                                               messageText: new StringBuilder("Entity with same name already exits, please enter different name."),
                                                               messageCaption: new StringBuilder("Naming error")));
                                }
                                else
                                {
                                    block.FatBlock.Name = text;
                                    MyEntities.SetEntityName(block.FatBlock, true);

                                    return(true);
                                }

                                return(false);
                            });
                            MyGuiSandbox.AddScreen(dialog);
                            entites.Clear();
                            return(true);
                        }
                    }
                }
            }

            entites.Clear();
            return(false);
        }
 void HelpButtonClicked(MyGuiControlButton button)
 {
     MyGuiSandbox.OpenUrlWithFallback(MySteamConstants.URL_BROWSE_WORKSHOP_INGAMESCRIPTS_HELP, "Steam Workshop");
 }
        private bool TrySaveAs()
        {
            MyStringId?errorType = null;

            if (m_nameTextbox.Text.Length < 5)
            {
                errorType = MyCommonTexts.ErrorNameTooShort;
            }
            else if (m_nameTextbox.Text.Length > 128)
            {
                errorType = MyCommonTexts.ErrorNameTooLong;
            }


            if (m_existingSessionNames != null)
            {
                foreach (var name in m_existingSessionNames)
                {
                    if (name == m_nameTextbox.Text)
                    {
                        errorType = MyCommonTexts.ErrorNameAlreadyExists;
                    }
                }
            }

            if (errorType != null)
            {
                var messageBox = MyGuiSandbox.CreateMessageBox(
                    messageText: MyTexts.Get(errorType.Value),
                    messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError));
                messageBox.SkipTransition = true;
                messageBox.InstantClose   = false;
                MyGuiSandbox.AddScreen(messageBox);
                return(false);
            }

            if (m_fromMainMenu)
            {
                string name = MyUtils.StripInvalidChars(m_nameTextbox.Text);
                if (string.IsNullOrWhiteSpace(name))
                {
                    name = MyLocalCache.GetSessionSavesPath(name + MyUtils.GetRandomInt(int.MaxValue).ToString("########"), false, false);
                }
                MyAsyncSaving.Start(customName: name);
                MySession.Static.Name = m_nameTextbox.Text;
                this.CloseScreen();
                return(true);
            }

            m_copyFrom.SessionName = m_nameTextbox.Text;
            MyGuiSandbox.AddScreen(new MyGuiScreenProgressAsync(MyCommonTexts.SavingPleaseWait, null,
                                                                beginAction: () => new SaveResult(MyUtils.StripInvalidChars(m_nameTextbox.Text), m_sessionPath, m_copyFrom),
                                                                endAction: (result, screen) =>
            {
                screen.CloseScreen();
                this.CloseScreen();
                var handler = SaveAsConfirm;
                if (handler != null)
                {
                    handler();
                }
            }));
            return(true);
        }
        public override void UpdateBeforeSimulation()
        {
            base.UpdateBeforeSimulation();

            if (!(MySession.Static.IsScenario || MySession.Static.Settings.ScenarioEditMode))
            {
                return;
            }

            if (!Sync.IsServer)
            {
                return;
            }

            if (MySession.Static.OnlineMode == MyOnlineModeEnum.OFFLINE && GameState < MyState.Running)
            {
                if (GameState == MyState.Loaded)
                {
                    GameState           = MyState.Running;
                    ServerStartGameTime = DateTime.UtcNow;
                }
                return;
            }

            switch (GameState)
            {
            case MyState.Loaded:
                if (MySession.Static.OnlineMode != MyOnlineModeEnum.OFFLINE && MyMultiplayer.Static == null)
                {
                    if (MyFakes.XBOX_PREVIEW)
                    {
                        GameState = MyState.Running;
                    }
                    else
                    {
                        m_bootUpCount++;
                        if (m_bootUpCount > 100)    //because MyMultiplayer.Static is initialized later than this part of game
                        {
                            //network start failure - trying to save what we can :-)
                            MyPlayerCollection.RequestLocalRespawn();
                            GameState = MyState.Running;
                        }
                    }
                    return;
                }
                if (MySandboxGame.IsDedicated || MySession.Static.Settings.ScenarioEditMode)
                {
                    ServerPreparationStartTime             = DateTime.UtcNow;
                    MyMultiplayer.Static.ScenarioStartTime = ServerPreparationStartTime;
                    GameState = MyState.Running;
                    if (!MySandboxGame.IsDedicated)
                    {
                        StartScenario();
                    }
                    return;
                }
                if (MySession.Static.OnlineMode == MyOnlineModeEnum.OFFLINE || MyMultiplayer.Static != null)
                {
                    if (MyMultiplayer.Static != null)
                    {
                        MyMultiplayer.Static.Scenario         = true;
                        MyMultiplayer.Static.ScenarioBriefing = MySession.Static.GetWorld().Checkpoint.Briefing;
                    }
                    MyGuiScreenScenarioMpServer guiscreen = new MyGuiScreenScenarioMpServer();
                    guiscreen.Briefing = MySession.Static.GetWorld().Checkpoint.Briefing;
                    MyGuiSandbox.AddScreen(guiscreen);
                    m_playersReadyForBattle.Add(Sync.MyId);
                    GameState = MyState.JoinScreen;
                }
                break;

            case MyState.JoinScreen:
                break;

            case MyState.WaitingForClients:
                // Check timeout
                TimeSpan currenTime = MySession.Static.ElapsedPlayTime;
                if (AllPlayersReadyForBattle() || (LoadTimeout > 0 && currenTime - m_startBattlePreparationOnClients > TimeSpan.FromSeconds(LoadTimeout)))
                {
                    StartScenario();
                    foreach (var playerId in m_playersReadyForBattle)
                    {
                        if (playerId != Sync.MyId)
                        {
                            MySyncScenario.StartScenarioRequest(playerId, ServerStartGameTime.Ticks);
                        }
                    }
                }
                break;

            case MyState.Running:
                break;

            case MyState.Ending:
                if (EndAction != null && MySession.Static.ElapsedPlayTime - m_stateChangePlayTime > TimeSpan.FromSeconds(10))
                {
                    EndAction();
                }
                break;
            }
        }
        //loads next mission, SP only
        //id can be workshop ID or save name (in that case official scenarios are searched first, if not found, then user's saves)
        public static void LoadNextScenario(string id)
        {
            if (MySession.Static.OnlineMode != MyOnlineModeEnum.OFFLINE)
            {
                return;
            }
            MyAPIGateway.Utilities.ShowNotification(MyTexts.GetString(MySpaceTexts.NotificationNextScenarioWillLoad), 10000);
            ulong workshopID;

            if (ulong.TryParse(id, out workshopID))
            {
                //scenario from steam, without the user needing to subscribe it first:
                if (!MySteam.IsOnline)
                {
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                               messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextWorkshopDownloadFailed),
                                               messageCaption: MyTexts.Get(MyCommonTexts.ScreenCaptionWorkshop)));
                }
                else
                {
                    MySandboxGame.Log.WriteLine(string.Format("Querying details of file " + workshopID));

                    Action <bool, RemoteStorageGetPublishedFileDetailsResult> onGetDetailsCallResult = delegate(bool ioFailure, RemoteStorageGetPublishedFileDetailsResult data)
                    {
                        MySandboxGame.Log.WriteLine(string.Format("Obtained details: Id={4}; Result={0}; ugcHandle={1}; title='{2}'; tags='{3}'", data.Result, data.FileHandle, data.Title, data.Tags, data.PublishedFileId));
                        if (!ioFailure && data.Result == Result.OK && data.Tags.Length != 0)
                        {
                            m_newWorkshopMap.Title           = data.Title;
                            m_newWorkshopMap.PublishedFileId = data.PublishedFileId;
                            m_newWorkshopMap.Description     = data.Description;
                            m_newWorkshopMap.UGCHandle       = data.FileHandle;
                            m_newWorkshopMap.SteamIDOwner    = data.SteamIDOwner;
                            m_newWorkshopMap.TimeUpdated     = data.TimeUpdated;
                            m_newWorkshopMap.Tags            = data.Tags.Split(',');
                            Static.EndAction += EndActionLoadWorkshop;
                        }
                        else
                        {
                            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                       messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextWorkshopDownloadFailed),
                                                       messageCaption: MyTexts.Get(MyCommonTexts.ScreenCaptionWorkshop)));
                        }
                    };
                    MySteam.API.RemoteStorage.GetPublishedFileDetails(workshopID, 0, onGetDetailsCallResult);
                }
            }
            else
            {
                var contentDir = Path.Combine(MyFileSystem.ContentPath, "Missions", id);
                if (Directory.Exists(contentDir))
                {
                    m_newPath         = contentDir;
                    Static.EndAction += EndActionLoadLocal;
                    return;
                }
                var saveDir = Path.Combine(MyFileSystem.SavesPath, id);
                if (Directory.Exists(saveDir))
                {
                    m_newPath         = saveDir;
                    Static.EndAction += EndActionLoadLocal;
                    return;
                }
                //fail msg:
                StringBuilder error = new StringBuilder();
                error.AppendFormat(MyTexts.GetString(MySpaceTexts.MessageBoxTextScenarioNotFound), contentDir, saveDir);
                MyGuiScreenMessageBox mb = MyGuiSandbox.CreateMessageBox(messageText: error, messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError));
                MyGuiSandbox.AddScreen(mb);
            }
        }
示例#12
0
        void Matchmaking_LobbyChatUpdate(Lobby lobby, ulong changedUser, ulong makingChangeUser, ChatMemberStateChangeEnum stateChange)
        {
            //System.Diagnostics.Debug.Assert(MySession.Static != null);

            if (lobby.LobbyId == Lobby.LobbyId)
            {
                if (stateChange == ChatMemberStateChangeEnum.Entered)
                {
                    MySandboxGame.Log.WriteLineAndConsole("Player entered: " + MySteam.API.Friends.GetPersonaName(changedUser) + " (" + changedUser + ")");
                    MyTrace.Send(TraceWindow.Multiplayer, "Player entered");
                    Peer2Peer.AcceptSession(changedUser);

                    // When some clients connect at the same time then some of them can have already added clients
                    // (see function MySyncLayer.RegisterClientEvents which registers all Members in Lobby).
                    if (Sync.Clients == null || !Sync.Clients.HasClient(changedUser))
                    {
                        RaiseClientJoined(changedUser);
                    }

                    if (MySandboxGame.IsGameReady && changedUser != ServerId)
                    {
                        // Player is able to connect to the battle which already started - player is then kicked and we do not want to show connected message in HUD.
                        bool showMsg = true;
                        if (MyFakes.ENABLE_BATTLE_SYSTEM && MySession.Static != null && MySession.Static.Battle && !BattleCanBeJoined)
                        {
                            showMsg = false;
                        }

                        if (showMsg)
                        {
                            var playerJoined = new MyHudNotification(MyCommonTexts.NotificationClientConnected, 5000, level: MyNotificationLevel.Important);
                            playerJoined.SetTextFormatArguments(MySteam.API.Friends.GetPersonaName(changedUser));
                            MyHud.Notifications.Add(playerJoined);
                        }
                    }
                }
                else
                {
                    // Kicked client can be already removed from Clients
                    if (Sync.Clients == null || Sync.Clients.HasClient(changedUser))
                    {
                        RaiseClientLeft(changedUser, stateChange);
                    }

                    if (changedUser == ServerId)
                    {
                        MyTrace.Send(TraceWindow.Multiplayer, "Host left: " + stateChange.ToString());
                        RaiseHostLeft();

                        MySessionLoader.UnloadAndExitToMenu();
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                   messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                                   messageText: MyTexts.Get(MyCommonTexts.MultiplayerErrorServerHasLeft)));

                        // Set new server
                        //ServerId = Lobby.GetOwner();

                        //if (ServerId == Sync.MyId)
                        //{
                        //    Lobby.SetLobbyData(HostNameTag, Sync.MyName);
                        //}
                    }
                    else if (MySandboxGame.IsGameReady)
                    {
                        var playerLeft = new MyHudNotification(MyCommonTexts.NotificationClientDisconnected, 5000, level: MyNotificationLevel.Important);
                        playerLeft.SetTextFormatArguments(MySteam.API.Friends.GetPersonaName(changedUser));
                        MyHud.Notifications.Add(playerLeft);
                    }
                }
            }
        }
            public WarningArea(string name, bool graphicsButton)
            {
                Warnings = new List <WarningLine>();

                m_header          = new MyGuiControlParent();
                m_titleBackground = new MyGuiControlPanel(texture: @"Textures\GUI\Controls\item_highlight_dark.dds");
                m_title           = new MyGuiControlLabel(text: name);
                m_lastOccurence   = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.PerformanceWarningLastOccurrence), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER);
                m_separator       = new MyGuiControlSeparatorList();
                m_separator.AddHorizontal(new Vector2(-0.45f, 0.018f), 0.9f);

                m_title.Position         = new Vector2(-0.43f, 0f);
                m_lastOccurence.Position = new Vector2(0.43f, 0f);
                m_titleBackground.Size   = new Vector2(m_titleBackground.Size.X, 0.035f);
                m_header.Size            = new Vector2(m_header.Size.X, m_titleBackground.Size.Y);
                if (graphicsButton)
                {
                    m_graphicsButton = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.ScreenCaptionGraphicsOptions), onButtonClick: (sender) => { MyGuiSandbox.AddScreen(new MyGuiScreenOptionsGraphics()); });
                }
            }
示例#14
0
 //GUI
 public override void DisplayGUI()
 {
     MyGuiSandbox.AddScreen(new MyGuiScreenTriggerPositionLeft(this));
 }
 void OnOpenWorkshop(MyGuiControlButton button)
 {
     MyGuiSandbox.OpenUrlWithFallback(MySteamConstants.URL_BROWSE_WORKSHOP_INGAMESCRIPTS, "Steam Workshop");
 }
 private void OnCreateClicked(MyGuiControlButton sender)
 {
     MyGuiSandbox.AddScreen(new MyGuiScreenCreateOrEditFaction(ref m_userFaction));
 }
        void OnOpenInWorkshop(MyGuiControlButton button)
        {
            string url = string.Format("http://steamcommunity.com/sharedfiles/filedetails/?id={0}", m_selectedItem.SteamItem.PublishedFileId);

            MyGuiSandbox.OpenUrlWithFallback(url, "Steam Workshop");
        }
示例#18
0
 static void ShowMedicalScreen_Implementation()
 {
     MyGuiSandbox.AddScreen(new MyGuiScreenMedicals());
 }
示例#19
0
        private static void OnDownloadProgressChanged(MyGuiScreenProgress progress, MyDownloadWorldResult result, MyMultiplayerBase multiplayer)
        {
            switch (result.State)
            {
            case MyDownloadWorldStateEnum.Success:
                progress.CloseScreen();
                var world = multiplayer.ProcessWorldDownloadResult(result);
                if (MyFakes.ENABLE_BATTLE_SYSTEM && multiplayer.Battle)
                {
                    MyGuiScreenLoadSandbox.LoadMultiplayerBattleWorld(world, multiplayer);
                }
                else
                {
                    MyGuiScreenLoadSandbox.LoadMultiplayerSession(world, multiplayer);
                }
                break;

            case MyDownloadWorldStateEnum.InProgress:
                if (result.ReceivedBlockCount == 1)
                {
                    MyLog.Default.WriteLine("First world part received");
                }
                string percent   = (result.Progress * 100).ToString("0.");
                float  size      = result.ReceivedDatalength;
                string prefix    = MyUtils.FormatByteSizePrefix(ref size);
                string worldSize = size.ToString("0.") + " " + prefix + "B";
                if (progress.Text != null)
                {
                    progress.Text.Clear();
                }
                if (float.IsNaN(result.Progress))
                {
                    MyLog.Default.WriteLine("World requested - preemble received");
                    if (progress.Text != null)
                    {
                        progress.Text.Append(MyTexts.Get(MySpaceTexts.DialogWaitingForWorldData));
                    }
                }
                else
                {
                    if (progress.Text != null)
                    {
                        progress.Text.AppendFormat(MyTexts.GetString(MySpaceTexts.DialogTextDownloadingWorld), percent, worldSize);
                    }
                }
                break;

            case MyDownloadWorldStateEnum.WorldNotAvailable:
                MyLog.Default.WriteLine("World requested - world not available");
                progress.Cancel();
                MyGuiSandbox.Show(MySpaceTexts.DialogDownloadWorld_WorldDoesNotExists);
                multiplayer.Dispose();
                break;

            case MyDownloadWorldStateEnum.ConnectionFailed:
                MyLog.Default.WriteLine("World requested - connection failed");
                progress.Cancel();
                MyGuiSandbox.Show(MyTexts.AppendFormat(new StringBuilder(), MySpaceTexts.MultiplayerErrorConnectionFailed, result.ConnectionError));
                multiplayer.Dispose();
                break;

            case MyDownloadWorldStateEnum.DeserializationFailed:
            case MyDownloadWorldStateEnum.InvalidMessage:
                MyLog.Default.WriteLine("World requested - message invalid (wrong version?)");
                progress.Cancel();
                MyGuiSandbox.Show(MySpaceTexts.DialogTextDownloadWorldFailed);
                multiplayer.Dispose();
                break;

            default:
                throw new InvalidBranchException();
            }
        }
 private void ShowControlIsNotValidMessageBox()
 {
     MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                messageText: MyTexts.Get(MyCommonTexts.ControlIsNotValid),
                                messageCaption: MyTexts.Get(MyCommonTexts.CanNotAssignControl)));
 }
示例#21
0
        void OnPublishButtonClick(MyGuiControlButton sender)
        {
            var row = m_scenarioTable.SelectedRow;

            if (row == null)
            {
                return;
            }

            if (row.UserData == null)
            {
                return;
            }

            string      fullPath  = (string)(((Tuple <string, MyWorldInfo>)row.UserData).Item1);
            MyWorldInfo worldInfo = FindSave(m_scenarioTable.SelectedRow).Item2;
            //var mod = (MyObjectBuilder_Checkpoint.ModItem)row.UserData;
            //var nameSB = m_selectedRow.GetCell(1).Text;
            //var name = nameSB.ToString();

            MyStringId textQuestion, captionQuestion;

            if (worldInfo.WorkshopId != null)
            {
                textQuestion    = MySpaceTexts.MessageBoxTextDoYouWishToUpdateScenario;
                captionQuestion = MySpaceTexts.MessageBoxCaptionDoYouWishToUpdateScenario;
            }
            else
            {
                textQuestion    = MySpaceTexts.MessageBoxTextDoYouWishToPublishScenario;
                captionQuestion = MySpaceTexts.MessageBoxCaptionDoYouWishToPublishScenario;
            }

            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                       styleEnum : MyMessageBoxStyleEnum.Info,
                                       buttonType : MyMessageBoxButtonsType.YES_NO,
                                       messageText : MyTexts.Get(textQuestion),
                                       messageCaption : MyTexts.Get(captionQuestion),
                                       callback : delegate(MyGuiScreenMessageBox.ResultEnum val)
            {
                if (val == MyGuiScreenMessageBox.ResultEnum.YES)
                {
                    string[] inTags    = null;
                    var subscribedItem = GetSubscribedItem(worldInfo.WorkshopId);
                    if (subscribedItem != null)
                    {
                        inTags = subscribedItem.Tags;

                        if (subscribedItem.SteamIDOwner != Sync.MyId)
                        {
                            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                       messageText: MyTexts.Get(MyCommonTexts.MessageBoxTextPublishFailed_OwnerMismatchMod),//TODO rename
                                                       messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionModPublishFailed)));
                            return;
                        }
                    }

                    /*MyGuiSandbox.AddScreen(new MyGuiScreenWorkshopTags(MySteamWorkshop.WORKSHOP_SCENARIO_TAG, MySteamWorkshop.ScenarioCategories, inTags, delegate(MyGuiScreenMessageBox.ResultEnum tagsResult, string[] outTags)
                     * {
                     *  if (tagsResult == MyGuiScreenMessageBox.ResultEnum.YES)
                     *  {*/
                    MySteamWorkshop.PublishScenarioAsync(fullPath, worldInfo.SessionName, worldInfo.Description, worldInfo.WorkshopId, /*outTags,*/ SteamSDK.PublishedFileVisibility.Public, callbackOnFinished : delegate(bool success, Result result, ulong publishedFileId)           //TODO public visibility!!
                    {
                        if (success)
                        {
                            ulong dummy;
                            var checkpoint        = MyLocalCache.LoadCheckpoint(fullPath, out dummy);
                            worldInfo.WorkshopId  = publishedFileId;
                            checkpoint.WorkshopId = publishedFileId;
                            MyLocalCache.SaveCheckpoint(checkpoint, fullPath);

                            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                       styleEnum: MyMessageBoxStyleEnum.Info,
                                                       messageText: MyTexts.Get(MySpaceTexts.MessageBoxTextScenarioPublished),
                                                       messageCaption: MyTexts.Get(MySpaceTexts.MessageBoxCaptionScenarioPublished),
                                                       callback: (a) =>
                            {
                                MySteam.API.OpenOverlayUrl(string.Format("http://steamcommunity.com/sharedfiles/filedetails/?id={0}", publishedFileId));
                                FillList();
                            }));
                        }
                        else
                        {
                            MyStringId error;
                            switch (result)
                            {
                            case Result.AccessDenied:
                                error = MyCommonTexts.MessageBoxTextPublishFailed_AccessDenied;
                                break;

                            default:
                                error = MySpaceTexts.MessageBoxTextScenarioPublishFailed;
                                break;
                            }

                            MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                       messageText: MyTexts.Get(error),
                                                       messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionModPublishFailed)));
                        }
                    });            /*
                                    * }
                                    * }));*/
                }
            }));
        }
 //GUI
 public override void DisplayGUI()
 {
     MyGuiSandbox.AddScreen(new MyGuiScreenTriggerBlockDestroyed(this));
 }
示例#23
0
 private void OnWorldGeneratorClick(object sender)
 {
     WorldGenerator = new MyGuiScreenWorldGeneratorSettings(this);
     WorldGenerator.OnOkButtonClicked += WorldGenerator_OnOkButtonClicked;
     MyGuiSandbox.AddScreen(WorldGenerator);
 }
 public MyTestersInputComponent()
 {
     AddShortcut(MyKeys.Back, true, true, false, false, () => "Freeze cube builder gizmo", delegate { MyCubeBuilder.Static.FreezeGizmo = !MyCubeBuilder.Static.FreezeGizmo; return(true); });
     AddShortcut(MyKeys.NumPad0, false, false, false, false, () => "Add items to inventory (continuous)", delegate { AddItemsToInventory(0); return(true); });
     AddShortcut(MyKeys.NumPad1, true, false, false, false, () => "Add items to inventory", delegate { AddItemsToInventory(1); return(true); });
     AddShortcut(MyKeys.NumPad2, true, false, false, false, () => "Add components to inventory", delegate { AddItemsToInventory(2); return(true); });
     AddShortcut(MyKeys.NumPad3, true, false, false, false, () => "Fill inventory with iron", FillInventoryWithIron);
     AddShortcut(MyKeys.NumPad4, true, false, false, false, () => "Add to inventory dialog...", delegate { var dialog = new MyGuiScreenDialogInventoryCheat(); MyGuiSandbox.AddScreen(dialog); return(true); });
     AddShortcut(MyKeys.NumPad5, true, false, false, false, () => "Set container type", SetContainerType);
     AddShortcut(MyKeys.NumPad6, true, false, false, false, () => "Toggle debug draw", ToggleDebugDraw);
     AddShortcut(MyKeys.NumPad8, true, false, false, false, () => "Save the game", delegate { MyAsyncSaving.Start(); return(true); });
 }
示例#25
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(MyCommonTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(MyCommonTexts.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
                {
                    if (MySteam.IsOnline)
                    {
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                   messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                                   messageText: MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailed),
                                                   buttonType: MyMessageBoxButtonsType.OK));
                    }
                    else
                    {
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                                   messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                                   messageText: MyTexts.Get(MyCommonTexts.DialogTextDownloadModsFailedSteamOffline),
                                                   buttonType: MyMessageBoxButtonsType.OK));
                    }
                }
                MyLog.Default.WriteLine("StartNewSandbox - End");
            });
        }
示例#26
0
        void OnUserJoined(ref JoinResultMsg msg)
        {
            if (msg.JoinResult == JoinResult.OK)
            {
                if (OnJoin != null)
                {
                    OnJoin();
                    OnJoin         = null;
                    m_clientJoined = true;
                }
            }
            else if (msg.JoinResult == JoinResult.NotInGroup)
            {
                MyGuiScreenMainMenu.UnloadAndExitToMenu();
                Dispose();

                ulong  groupId   = Server.GetGameTagByPrefixUlong("groupId");
                string groupName = MySteam.API.Friends.GetClanName(groupId);

                var messageBox = MyGuiSandbox.CreateMessageBox(
                    messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                    messageText: new StringBuilder(string.Format(
                                                       MyTexts.GetString(MyCommonTexts.MultiplayerErrorNotInGroup), groupName)),
                    buttonType: MyMessageBoxButtonsType.YES_NO);
                messageBox.ResultCallback = delegate(MyGuiScreenMessageBox.ResultEnum result)
                {
                    if (result == MyGuiScreenMessageBox.ResultEnum.YES)
                    {
                        MySteam.API.OpenOverlayUser(groupId);
                    }
                    ;
                };
                MyGuiSandbox.AddScreen(messageBox);
            }
            else if (msg.JoinResult == JoinResult.BannedByAdmins)
            {
                MyGuiScreenMainMenu.UnloadAndExitToMenu();
                Dispose();

                ulong admin = msg.Admin;

                if (admin != 0)
                {
                    var messageBox = MyGuiSandbox.CreateMessageBox(
                        messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                        messageText: MyTexts.Get(MyCommonTexts.MultiplayerErrorBannedByAdminsWithDialog),
                        buttonType: MyMessageBoxButtonsType.YES_NO);
                    messageBox.ResultCallback = delegate(MyGuiScreenMessageBox.ResultEnum result)
                    {
                        if (result == MyGuiScreenMessageBox.ResultEnum.YES)
                        {
                            MySteam.API.OpenOverlayUser(admin);
                        }
                        ;
                    };
                    MyGuiSandbox.AddScreen(messageBox);
                }
                else
                {
                    MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                               messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                               messageText: MyTexts.Get(MyCommonTexts.MultiplayerErrorBannedByAdmins)));
                }
            }
            else
            {
                MyStringId resultText = MyCommonTexts.MultiplayerErrorConnectionFailed;

                switch (msg.JoinResult)
                {
                case JoinResult.AlreadyJoined:
                    resultText = MyCommonTexts.MultiplayerErrorAlreadyJoined;
                    break;

                case JoinResult.ServerFull:
                    resultText = MyCommonTexts.MultiplayerErrorServerFull;
                    break;

                case JoinResult.SteamServersOffline:
                    resultText = MyCommonTexts.MultiplayerErrorSteamServersOffline;
                    break;

                case JoinResult.TicketInvalid:
                    resultText = MyCommonTexts.MultiplayerErrorTicketInvalid;
                    break;

                case JoinResult.GroupIdInvalid:
                    resultText = MyCommonTexts.MultiplayerErrorGroupIdInvalid;
                    break;

                case JoinResult.TicketCanceled:
                    resultText = MyCommonTexts.MultiplayerErrorTicketCanceled;
                    break;

                case JoinResult.TicketAlreadyUsed:
                    resultText = MyCommonTexts.MultiplayerErrorTicketAlreadyUsed;
                    break;

                case JoinResult.LoggedInElseWhere:
                    resultText = MyCommonTexts.MultiplayerErrorLoggedInElseWhere;
                    break;

                case JoinResult.NoLicenseOrExpired:
                    resultText = MyCommonTexts.MultiplayerErrorNoLicenseOrExpired;
                    break;

                case JoinResult.UserNotConnected:
                    resultText = MyCommonTexts.MultiplayerErrorUserNotConnected;
                    break;

                case JoinResult.VACBanned:
                    resultText = MyCommonTexts.MultiplayerErrorVACBanned;
                    break;

                case JoinResult.VACCheckTimedOut:
                    resultText = MyCommonTexts.MultiplayerErrorVACCheckTimedOut;
                    break;

                default:
                    System.Diagnostics.Debug.Fail("Unknown JoinResult");
                    break;
                }

                Dispose();
                MyGuiScreenMainMenu.UnloadAndExitToMenu();
                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox(
                                           messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError),
                                           messageText: MyTexts.Get(resultText)));
                return;
            }
        }
        public void DrawTexts()
        {
            if (m_texts.GetAllocatedCount() <= 0)
            {
                return;
            }

            for (int i = 0; i < m_texts.GetAllocatedCount(); i++)
            {
                MyHudText text = m_texts.GetAllocatedItem(i);

                var font = text.Font;
                text.Position /= MyGuiManager.GetHudSize();
                var normalizedCoord = ConvertHudToNormalizedGuiPosition(ref text.Position);

                Vector2 textSize = MyGuiManager.MeasureString(font, text.GetStringBuilder(), MyGuiSandbox.GetDefaultTextScaleWithLanguage());
                textSize.X *= 0.9f;
                textSize.Y *= 0.7f;
                MyGuiScreenHudBase.DrawFog(ref normalizedCoord, ref textSize);

                MyGuiManager.DrawString(font, text.GetStringBuilder(), normalizedCoord, text.Scale, colorMask: text.Color, drawAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            }

            m_texts.ClearAllAllocated();
        }
示例#28
0
        protected void DrawGuiIndicators()
        {
            if (MyHud.MinimalHud)
            {
                return;
            }

            if (MyGuiScreenGamePlay.ActiveGameplayScreen != null)
            {
                return;
            }

            if (IsCubeSizeModesAvailable)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat(MyTexts.GetString(MySpaceTexts.CubeBuilder_CubeSizeModeChange), MyGuiSandbox.GetKeyName(MyControlsSpace.CUBE_BUILDER_CUBESIZE_MODE));
                Vector2 coords2D = new Vector2(0.5f, 0.13f);
                MyGuiManager.DrawString(MyFontEnum.White, sb, coords2D, 1.0f, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);

                coords2D = new Vector2(0.52f, 0.2f);
                float alphaValue         = CubeBuilderState.CubeSizeMode != MyCubeSize.Small ? 0.8f : 1.0f;
                Color premultipliedColor = new Color(alphaValue, alphaValue, alphaValue, alphaValue);
                MyRenderProxy.DrawSprite(MyGuiConstants.CB_SMALL_GRID_MODE, coords2D, Vector2.One, premultipliedColor, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0, Vector2.UnitX, 1.0f, null);

                coords2D           = new Vector2(0.48f, 0.2f);
                alphaValue         = CubeBuilderState.CubeSizeMode != MyCubeSize.Large ? 0.8f : 1.0f;
                premultipliedColor = new Color(alphaValue, alphaValue, alphaValue, alphaValue);
                MyRenderProxy.DrawSprite(MyGuiConstants.CB_LARGE_GRID_MODE, coords2D, Vector2.One, premultipliedColor, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0, Vector2.UnitX, 1.0f, null);
            }

            if (BuildInputValid)
            {
                Vector2 screenPos = new Vector2(0.5f, 0.1f);
                string  texture   = DynamicMode ? MyGuiConstants.CB_FREE_MODE_ICON : MyGuiConstants.CB_LCS_GRID_ICON;

                MyRenderProxy.DrawSprite(texture, screenPos, Vector2.One, Color.White, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0, Vector2.UnitX, 1.0f, null);
            }
        }
示例#29
0
 public override void Show()
 {
     MyGuiSandbox.OpenUrl("https://github.com/" + Id, UrlOpenMode.SteamOrExternalWithConfirm);
 }
 public void OnCustomGameClick(MyGuiControlButton sender)
 {
     MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.CustomWorldScreen));
 }