public static void HandleSelectedObjectHighlight(MyHudSelectedObject selection, MyHudObjectHighlightStyleData?data)
        {
            if (selection.PreviousObject.Instance != null)
            {
                RemoveObjectHighlightInternal(ref selection.PreviousObject, true);
            }

            switch (selection.State)
            {
            case MyHudSelectedObjectState.VisibleStateSet:
            {
                if (selection.Visible && (selection.HighlightStyle == MyHudObjectHighlightStyle.HighlightStyle1 ||
                                          selection.VisibleRenderID != selection.CurrentObject.Instance.RenderObjectID))
                {
                    MyGuiScreenHudBase.DrawSelectedObjectHighlight(selection, data);
                }

                break;
            }

            case MyHudSelectedObjectState.MarkedForVisible:
            {
                MyGuiScreenHudBase.DrawSelectedObjectHighlight(selection, data);
                break;
            }

            case MyHudSelectedObjectState.MarkedForNotVisible:
            {
                MyGuiScreenHudBase.RemoveObjectHighlight(selection);
                break;
            }
            }
        }
        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();
        }
Beispiel #3
0
        public void DrawTexts()
        {
            if (m_texts.GetAllocatedCount() <= 0)
            {
                return;
            }

            for (int i = 0; i < m_texts.GetAllocatedCount(); i++)
            {
                MyHudText text = m_texts.GetAllocatedItem(i);
                if (text.GetStringBuilder().Length == 0)
                {
                    continue;
                }

                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;
                textSize   *= text.Scale;
                MyGuiScreenHudBase.DrawFog(ref normalizedCoord, ref textSize, text.Color.A / 255f, text.Alignement);

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

            m_texts.ClearAllAllocated();
        }
Beispiel #4
0
        private void DrawFog()
        {
            Vector2 notificationPosition = Position;

            for (int i = 0; i < m_textSizes.Count; i++)
            {
                var textSize = m_textSizes[i];
                MyGuiScreenHudBase.DrawFog(ref notificationPosition, ref textSize);
                notificationPosition.Y += textSize.Y;
            }
        }
        public override bool Update(bool hasFocus)
        {
            if (!base.Update(hasFocus))
            {
                return(false);
            }

            var normPos = m_position;

            normPos = MyGuiScreenHudBase.ConvertHudToNormalizedGuiPosition(ref normPos);
            m_chatTextbox.Position = new Vector2(0.15f, 0);
            return(true);
        }
        private void DrawBackgroundFog(Vector2 namesTopLeft, Vector2 valuesTopRight, bool topDown)
        {
            float lineOffset;
            int   startIdx, endIdx, step;

            if (topDown)
            {
                lineOffset = LineSpacing;
                startIdx   = 0;
                endIdx     = Count;
                step       = 1;
            }
            else
            {
                lineOffset = -LineSpacing;
                startIdx   = Count - 1;
                endIdx     = -1;
                step       = -1;
            }

            for (int i = startIdx; i != endIdx; i += step)
            {
                var item = m_items[i];
                if (!item.Visible)
                {
                    continue;
                }

                var center = new Vector2((namesTopLeft.X + valuesTopRight.X) * 0.5f,
                                         namesTopLeft.Y + 0.5f * lineOffset);
                var size = new Vector2(Math.Abs(namesTopLeft.X - valuesTopRight.X),
                                       LineSpacing);

                MyGuiScreenHudBase.DrawFog(ref center, ref size);

                namesTopLeft.Y   += lineOffset;
                valuesTopRight.Y += lineOffset;
            }
        }
Beispiel #7
0
        //  This method is called every update (but only if application has focus)
        public override void HandleUnhandledInput(bool receivedFocusInThisUpdate)
        {
            if (MyInput.Static.ENABLE_DEVELOPER_KEYS || (MySession.Static != null && MySession.Static.Settings.EnableSpectator) || (MyMultiplayer.Static != null && MySession.LocalHumanPlayer != null && MyMultiplayer.Static.IsAdmin(MySession.LocalHumanPlayer.Id.SteamId)))
            {
                //Set camera to player
                if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.SPECTATOR_NONE))
                {
                    if (MySession.ControlledEntity != null)
                    { //we already are controlling this object
                        if (MyFinalBuildConstants.IS_OFFICIAL)
                        {
                            SetCameraController();
                        }
                        else
                        {
                            var cameraController = MySession.GetCameraControllerEnum();
                            if (cameraController != MyCameraControllerEnum.Entity && cameraController != MyCameraControllerEnum.ThirdPersonSpectator)
                            {
                                SetCameraController();
                            }
                            else
                            {
                                var entities       = MyEntities.GetEntities().ToList();
                                int lastKnownIndex = entities.IndexOf(MySession.ControlledEntity.Entity);

                                var entitiesList = new List <MyEntity>();
                                if (lastKnownIndex + 1 < entities.Count)
                                {
                                    entitiesList.AddRange(entities.GetRange(lastKnownIndex + 1, entities.Count - lastKnownIndex - 1));
                                }

                                if (lastKnownIndex != -1)
                                {
                                    entitiesList.AddRange(entities.GetRange(0, lastKnownIndex + 1));
                                }

                                MyCharacter newControlledObject = null;

                                for (int i = 0; i < entitiesList.Count; i++)
                                {
                                    var character = entitiesList[i] as MyCharacter;
                                    if (character != null && !character.IsDead)
                                    {
                                        newControlledObject = character;
                                        break;
                                    }
                                }

                                if (MySession.LocalHumanPlayer != null && newControlledObject != null)
                                {
                                    MySession.LocalHumanPlayer.Controller.TakeControl(newControlledObject);
                                }
                            }

                            // We could have activated the cube builder in spectator, so deactivate it now
                            if (MyCubeBuilder.Static.IsActivated && !(MySession.ControlledEntity is MyCharacter))
                            {
                                MyCubeBuilder.Static.Deactivate();
                            }
                        }
                    }
                }

                //Set camera to following third person
                if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.SPECTATOR_DELTA))
                {
                    if (MySession.ControlledEntity != null)
                    {
                        MySession.SetCameraController(MyCameraControllerEnum.SpectatorDelta);
                    }
                }

                //Set camera to spectator
                if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.SPECTATOR_FREE))
                {
                    if (!MyFakes.ENABLE_BATTLE_SYSTEM || !MySession.Static.Battle || Sync.IsServer)
                    {
                        if (MySession.GetCameraControllerEnum() != MyCameraControllerEnum.Spectator)
                        {
                            MySession.SetCameraController(MyCameraControllerEnum.Spectator);
                        }
                        else if (MyInput.Static.IsAnyShiftKeyPressed())
                        {
                            MyFakes.ENABLE_DEVELOPER_SPECTATOR_CONTROLS = !MyFakes.ENABLE_DEVELOPER_SPECTATOR_CONTROLS;
                        }

                        if (MyInput.Static.IsAnyCtrlKeyPressed() && MySession.ControlledEntity != null)
                        {
                            MySpectator.Static.Position = (Vector3D)MySession.ControlledEntity.Entity.PositionComp.GetPosition() + MySpectator.Static.ThirdPersonCameraDelta;
                            MySpectator.Static.Target   = (Vector3D)MySession.ControlledEntity.Entity.PositionComp.GetPosition();
                        }
                    }
                }

                //Set camera to static spectator, non movable
                if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.SPECTATOR_STATIC))
                {
                    if (MySession.ControlledEntity != null)
                    {
                        MySession.SetCameraController(MyCameraControllerEnum.SpectatorFixed);

                        if (MyInput.Static.IsAnyCtrlKeyPressed())
                        {
                            MySpectator.Static.Position = (Vector3D)MySession.ControlledEntity.Entity.PositionComp.GetPosition() + MySpectator.Static.ThirdPersonCameraDelta;
                            MySpectator.Static.Target   = (Vector3D)MySession.ControlledEntity.Entity.PositionComp.GetPosition();
                        }
                    }
                }

                //Open console
                if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.CONSOLE) && MyInput.Static.IsAnyAltKeyPressed())
                {
                    MyGuiScreenConsole.Show();
                }
            }

            if (MyDefinitionErrors.ShouldShowModErrors)
            {
                MyDefinitionErrors.ShouldShowModErrors = false;
                MyGuiSandbox.ShowModErrors();
            }

            // Switch view - cockpit on/off, third person
            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.CAMERA_MODE) && CanSwitchCamera)
            {
                MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                SwitchCamera();
            }

            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.HELP_SCREEN))
            {
                if (MyInput.Static.IsAnyCtrlKeyPressed())
                {
                    switch (MySandboxGame.Config.DebugComponentsInfo)
                    {
                    case MyDebugComponent.MyDebugComponentInfoState.NoInfo:
                        MySandboxGame.Config.DebugComponentsInfo = MyDebugComponent.MyDebugComponentInfoState.EnabledInfo;
                        break;

                    case MyDebugComponent.MyDebugComponentInfoState.EnabledInfo:
                        MySandboxGame.Config.DebugComponentsInfo = MyDebugComponent.MyDebugComponentInfoState.FullInfo;
                        break;

                    case MyDebugComponent.MyDebugComponentInfoState.FullInfo:
                        MySandboxGame.Config.DebugComponentsInfo = MyDebugComponent.MyDebugComponentInfoState.NoInfo;
                        break;
                    }

                    MySandboxGame.Config.Save();
                }
                else
                if (MyGuiScreenGamePlay.ActiveGameplayScreen == null)
                {
                    MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
                    MyGuiSandbox.AddScreen(MyGuiScreenGamePlay.ActiveGameplayScreen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.HelpScreen));
                }
            }

            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.TOGGLE_HUD))
            {
                MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                MyHud.MinimalHud = !MyHud.MinimalHud;
            }

            if (MyPerGameSettings.SimplePlayerNames && MyInput.Static.IsNewGameControlPressed(MyControlsSpace.BROADCASTING))
            {
                MyHud.LocationMarkers.Visible = !MyHud.LocationMarkers.Visible;
            }

            var controlledObject        = MySession.ControlledEntity;
            var currentCameraController = MySession.Static.CameraController;

            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.MISSION_SETTINGS) && MyGuiScreenGamePlay.ActiveGameplayScreen == null &&
                MyPerGameSettings.Game == Sandbox.Game.GameEnum.SE_GAME &&
                MyFakes.ENABLE_MISSION_TRIGGERS &&
                MySession.Static.Settings.ScenarioEditMode)
            {
                MyGuiSandbox.AddScreen(new Sandbox.Game.Screens.MyGuiScreenMissionTriggers());
            }

            MyStringId context = controlledObject != null ? controlledObject.ControlContext : MySpaceBindingCreator.CX_BASE;

            bool handledByUseObject = false;

            if (MySession.ControlledEntity is VRage.Game.Entity.UseObject.IMyUseObject)
            {
                handledByUseObject = (MySession.ControlledEntity as VRage.Game.Entity.UseObject.IMyUseObject).HandleInput();
            }

            if (controlledObject != null && !handledByUseObject)
            {
                if (!MySandboxGame.IsPaused)
                {
                    if (context == MySpaceBindingCreator.CX_BUILD_MODE || context == MySpaceBindingCreator.CX_CHARACTER || context == MySpaceBindingCreator.CX_SPACESHIP)
                    {
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.PRIMARY_TOOL_ACTION, MyControlStateType.NEW_PRESSED))
                        {
                            if (MyToolbarComponent.CurrentToolbar.ShouldActivateSlot)
                            {
                                MyToolbarComponent.CurrentToolbar.ActivateStagedSelectedItem();
                            }
                            else
                            {
                                controlledObject.BeginShoot(MyShootActionEnum.PrimaryAction);
                            }
                        }

                        if (MyControllerHelper.IsControl(context, MyControlsSpace.PRIMARY_TOOL_ACTION, MyControlStateType.NEW_RELEASED))
                        {
                            controlledObject.EndShoot(MyShootActionEnum.PrimaryAction);
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.SECONDARY_TOOL_ACTION, MyControlStateType.NEW_PRESSED))
                        {
                            controlledObject.BeginShoot(MyShootActionEnum.SecondaryAction);
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.SECONDARY_TOOL_ACTION, MyControlStateType.NEW_RELEASED))
                        {
                            controlledObject.EndShoot(MyShootActionEnum.SecondaryAction);
                        }
                    }

                    if (context == MySpaceBindingCreator.CX_CHARACTER || context == MySpaceBindingCreator.CX_SPACESHIP)
                    {
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.USE, MyControlStateType.NEW_PRESSED))
                        {
                            // Key press
                            if (currentCameraController != null)
                            {
                                if (!currentCameraController.HandleUse())
                                {
                                    controlledObject.Use();
                                }
                            }
                            else
                            {
                                controlledObject.Use();
                            }
                        }
                        else if (MyControllerHelper.IsControl(context, MyControlsSpace.USE, MyControlStateType.PRESSED))
                        {
                            // Key not pressed this frame, holding from previous
                            controlledObject.UseContinues();
                        }
                        else if (MyControllerHelper.IsControl(context, MyControlsSpace.USE, MyControlStateType.NEW_RELEASED))
                        {
                            controlledObject.UseFinished();
                        }

                        //Temp fix until spectators are implemented as entities
                        //Prevents controlled object from getting input while spectator mode is enabled
                        if (!(MySession.Static.CameraController is MySpectatorCameraController && MySpectatorCameraController.Static.SpectatorCameraMovement == MySpectatorCameraMovementEnum.UserControlled))
                        {
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.CROUCH, MyControlStateType.NEW_PRESSED))
                            {
                                controlledObject.Crouch();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.CROUCH, MyControlStateType.PRESSED))
                            {
                                controlledObject.Down();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.SPRINT, MyControlStateType.PRESSED))
                            {
                                controlledObject.Sprint();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.JUMP, MyControlStateType.NEW_PRESSED))
                            {
                                controlledObject.Jump();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.JUMP, MyControlStateType.PRESSED))
                            {
                                controlledObject.Up();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.SWITCH_WALK, MyControlStateType.NEW_PRESSED))
                            {
                                controlledObject.SwitchWalk();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.BROADCASTING, MyControlStateType.NEW_PRESSED))
                            {
                                controlledObject.SwitchBroadcasting();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.HELMET, MyControlStateType.NEW_PRESSED))
                            {
                                controlledObject.SwitchHelmet();
                            }
                        }

                        if (MyControllerHelper.IsControl(context, MyControlsSpace.DAMPING, MyControlStateType.NEW_PRESSED))
                        {
                            MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                            controlledObject.SwitchDamping();
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.THRUSTS, MyControlStateType.NEW_PRESSED))
                        {
                            MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                            controlledObject.SwitchThrusts();
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.HEADLIGHTS, MyControlStateType.NEW_PRESSED))
                        {
                            MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                            controlledObject.SwitchLights();
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.TOGGLE_REACTORS, MyControlStateType.NEW_PRESSED))
                        {
                            MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                            controlledObject.SwitchReactors();
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.LANDING_GEAR, MyControlStateType.NEW_PRESSED))
                        {
                            MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                            controlledObject.SwitchLeadingGears();
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.SUICIDE, MyControlStateType.NEW_PRESSED))
                        {
                            controlledObject.Die();
                        }
                        if ((controlledObject as MyCockpit) != null && MyControllerHelper.IsControl(context, MyControlsSpace.CUBE_COLOR_CHANGE, MyControlStateType.NEW_PRESSED))
                        {
                            (controlledObject as MyCockpit).SwitchWeaponMode();
                        }
                    }
                }
                if (MyControllerHelper.IsControl(context, MyControlsSpace.TERMINAL, MyControlStateType.NEW_PRESSED) && MyGuiScreenGamePlay.ActiveGameplayScreen == null)
                {
                    MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                    controlledObject.ShowTerminal();
                }

                if (MyControllerHelper.IsControl(context, MyControlsSpace.INVENTORY, MyControlStateType.NEW_PRESSED) && MyGuiScreenGamePlay.ActiveGameplayScreen == null)
                {
                    MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                    controlledObject.ShowInventory();
                }

                if (MyControllerHelper.IsControl(context, MyControlsSpace.CONTROL_MENU, MyControlStateType.NEW_PRESSED) && MyGuiScreenGamePlay.ActiveGameplayScreen == null)
                {
                    MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                    m_controlMenu.OpenControlMenu(controlledObject);
                }

                if (!MyCompilationSymbols.RenderProfiling && MyControllerHelper.IsControl(context, MyControlsSpace.CHAT_SCREEN, MyControlStateType.NEW_PRESSED))
                {
                    if (MyGuiScreenChat.Static == null)
                    {
                        Vector2 chatPos = new Vector2(0.01f, 0.84f);
                        chatPos = MyGuiScreenHudBase.ConvertHudToNormalizedGuiPosition(ref chatPos);
                        MyGuiScreenChat chatScreen = new MyGuiScreenChat(chatPos);
                        MyGuiSandbox.AddScreen(chatScreen);
                    }
                }

                if (MyPerGameSettings.VoiceChatEnabled)
                {
                    if (MyControllerHelper.IsControl(context, MyControlsSpace.VOICE_CHAT, MyControlStateType.NEW_PRESSED))
                    {
                        MyVoiceChatSessionComponent.Static.StartRecording();
                    }
                    //else if (MyControllerHelper.IsControl(context, MyControlsSpace.VOICE_CHAT, MyControlStateType.NEW_RELEASED))
                    // TODO: If other key was pressed during VOIP, NEW_RELEASED will return false even if this key was pressed, is this correct? We don't store key states?
                    else if (MyVoiceChatSessionComponent.Static.IsRecording && !MyControllerHelper.IsControl(context, MyControlsSpace.VOICE_CHAT, MyControlStateType.PRESSED))
                    {
                        MyVoiceChatSessionComponent.Static.StopRecording();
                    }
                }
            }

            MoveAndRotatePlayerOrCamera();

            // Quick save or quick load.
            if (MyInput.Static.IsNewKeyPressed(MyKeys.F5))
            {
                if (!MySession.Static.IsScenario)
                {
                    MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
                    var currentSession = MySession.Static.CurrentPath;

                    if (MyInput.Static.IsAnyShiftKeyPressed())
                    {
                        if (MySession.Static.ClientCanSave || Sync.IsServer)
                        {
                            if (!MyAsyncSaving.InProgress)
                            {
                                var messageBox = MyGuiSandbox.CreateMessageBox(
                                    buttonType : MyMessageBoxButtonsType.YES_NO,
                                    messageText : MyTexts.Get(MySpaceTexts.MessageBoxTextAreYouSureYouWantToQuickSave),
                                    messageCaption : MyTexts.Get(MySpaceTexts.MessageBoxCaptionPleaseConfirm),
                                    callback : delegate(MyGuiScreenMessageBox.ResultEnum callbackReturn)
                                {
                                    if (callbackReturn == MyGuiScreenMessageBox.ResultEnum.YES)
                                    {
                                        MyAsyncSaving.Start(() => MySector.ResetEyeAdaptation = true);    //black screen after save
                                    }
                                });
                                messageBox.SkipTransition      = true;
                                messageBox.CloseBeforeCallback = true;
                                MyGuiSandbox.AddScreen(messageBox);
                            }
                        }
                        else
                        {
                            MyHud.Notifications.Add(MyNotificationSingletons.ClientCannotSave);
                        }
                    }
                    else if (Sync.IsServer)
                    {
                        ShowLoadMessageBox(currentSession);
                    }
                    else
                    {
                        // Is multiplayer client, reconnect
                        ShowReconnectMessageBox();
                    }
                }
            }

            //  Launch main menu
            if (MyInput.Static.IsNewKeyPressed(MyKeys.Escape) ||
                MyControllerHelper.IsControl(context, MyControlsGUI.MAIN_MENU, MyControlStateType.NEW_PRESSED))
            {
                MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);

                //Allow changing video options from game in DX version
                MyGuiScreenMainMenu.AddMainMenu();
            }

            if (MyInput.Static.IsNewKeyPressed(MyKeys.F3))
            {
                if (Sync.MultiplayerActive)
                {
                    MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
                    MyGuiSandbox.AddScreen(new MyGuiScreenPlayers());
                }
                else
                {
                    MyHud.Notifications.Add(MyNotificationSingletons.MultiplayerDisabled);
                }
            }

            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.BUILD_SCREEN) && MyGuiScreenGamePlay.ActiveGameplayScreen == null)
            {
                if (MyGuiScreenCubeBuilder.Static == null && (MySession.ControlledEntity is MyShipController || MySession.ControlledEntity is MyCharacter))
                {
                    int offset = 0;
                    if (MyInput.Static.IsAnyShiftKeyPressed())
                    {
                        offset += 6;
                    }
                    if (MyInput.Static.IsAnyCtrlKeyPressed())
                    {
                        offset += 12;
                    }
                    MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
                    MyGuiSandbox.AddScreen(
                        MyGuiScreenGamePlay.ActiveGameplayScreen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.ToolbarConfigScreen,
                                                                                             offset,
                                                                                             MySession.ControlledEntity as MyShipController)
                        );
                }
            }

            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.PAUSE_GAME))
            {
                MySandboxGame.UserPauseToggle();
            }

            if (MySession.Static != null)
            {
                if (MyInput.Static.IsNewKeyPressed(MyKeys.F10))
                {
                    if (MyPerGameSettings.GUI.VoxelMapEditingScreen != null && MySession.Static.CreativeMode && MyInput.Static.IsAnyShiftKeyPressed())
                    { // Shift+F10
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.VoxelMapEditingScreen));
                    }
                    else
                    { // F10
                        if (MyFakes.ENABLE_BATTLE_SYSTEM && MySession.Static.Battle)
                        {
                            if (MyPerGameSettings.GUI.BattleBlueprintScreen != null)
                            {
                                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.BattleBlueprintScreen));
                            }
                            else
                            {
                                Debug.Fail("No battle blueprint screen");
                            }
                        }
                        else
                        {
                            MyGuiSandbox.AddScreen(new MyGuiBlueprintScreen(MyCubeBuilder.Static.Clipboard));
                        }
                    }
                }
            }

            // F11, mod debug
            if (MyInput.Static.IsNewKeyPressed(MyKeys.F11) && !MyInput.Static.IsAnyShiftKeyPressed() && !MyInput.Static.IsAnyCtrlKeyPressed())
            {
                MyDX9Gui.SwitchModDebugScreen();
            }
        }
 public MyHudMarkerRender(MyGuiScreenHudBase hudScreen) : base(hudScreen)
 {
 }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            m_toolbarControl                 = new MyGuiControlToolbar();
            m_toolbarControl.Position        = new Vector2(0.5f, 0.99f);
            m_toolbarControl.OriginAlign     = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM;
            m_toolbarControl.IsActiveControl = false;
            Elements.Add(m_toolbarControl);
            m_textScale = MyGuiConstants.HUD_TEXT_SCALE * MyGuiManager.LanguageTextScale;

            var style = new MyGuiControlBlockInfo.MyControlBlockInfoStyle()
            {
                BlockNameLabelFont                   = MyFontEnum.White,
                EnableBlockTypeLabel                 = true,
                ComponentsLabelText                  = MySpaceTexts.HudBlockInfo_Components,
                ComponentsLabelFont                  = MyFontEnum.Blue,
                InstalledRequiredLabelText           = MySpaceTexts.HudBlockInfo_Installed_Required,
                InstalledRequiredLabelFont           = MyFontEnum.Blue,
                RequiredLabelText                    = MySpaceTexts.HudBlockInfo_Required,
                IntegrityLabelFont                   = MyFontEnum.White,
                IntegrityBackgroundColor             = new Vector4(78 / 255.0f, 116 / 255.0f, 137 / 255.0f, 1.0f),
                IntegrityForegroundColor             = new Vector4(0.5f, 0.1f, 0.1f, 1),
                IntegrityForegroundColorOverCritical = new Vector4(118 / 255.0f, 166 / 255.0f, 192 / 255.0f, 1.0f),
                LeftColumnBackgroundColor            = new Vector4(46 / 255.0f, 76 / 255.0f, 94 / 255.0f, 1.0f),
                TitleBackgroundColor                 = new Vector4(72 / 255.0f, 109 / 255.0f, 130 / 255.0f, 1.0f),
                ComponentLineMissingFont             = MyFontEnum.Red,
                ComponentLineAllMountedFont          = MyFontEnum.White,
                ComponentLineAllInstalledFont        = MyFontEnum.Blue,
                ComponentLineDefaultFont             = MyFontEnum.White,
                ComponentLineDefaultColor            = new Vector4(0.6f, 0.6f, 0.6f, 1f),
                ShowAvailableComponents              = false,
                EnableBlockTypePanel                 = true,
            };

            m_blockInfo = new MyGuiControlBlockInfo(style);
            m_blockInfo.IsActiveControl = false;
            Controls.Add(m_blockInfo);

            m_chatControl = new MyHudControlChat(MyHud.Chat, Vector2.Zero, new Vector2(0.4f, 0.25f));
            Elements.Add(m_chatControl);

            m_cameraInfoMultilineControl = new MyGuiControlMultilineText(
                position: Vector2.Zero,
                size: new Vector2(0.4f, 0.25f),
                backgroundColor: null,
                font: MyFontEnum.White,
                textScale: 0.7f,
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM,
                contents: null,
                drawScrollbar: false,
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);
            m_cameraInfoMultilineControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
            Elements.Add(m_cameraInfoMultilineControl);

            m_rotatingWheelControl = new MyGuiControlRotatingWheel(position: new Vector2(0.5f, 0.85f));

            Controls.Add(m_rotatingWheelControl);

            Vector2 buildModePosition = new Vector2(0.5f, 0.02f);

            buildModePosition = MyGuiScreenHudBase.ConvertHudToNormalizedGuiPosition(ref buildModePosition);
            m_buildModeLabel  = new MyGuiControlLabel(
                position: buildModePosition,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                font: MyFontEnum.White,
                text: MyTexts.GetString(MySpaceTexts.Hud_BuildMode));
            Controls.Add(m_buildModeLabel);

            m_relayNotification          = new MyGuiControlLabel(new Vector2(1, 0), font: MyFontEnum.White, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);
            m_relayNotification.TextEnum = MySpaceTexts.Multiplayer_IndirectConnection;
            m_relayNotification.Visible  = false;
            Controls.Add(m_relayNotification);
            var offset = new Vector2(0, m_relayNotification.Size.Y);

            m_noMsgSentNotification         = new MyGuiControlLabel(new Vector2(1, 0) + offset, font: MyFontEnum.Debug, text: MyTexts.GetString(MySpaceTexts.Multiplayer_LastMsg), originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);
            m_noMsgSentNotification.Visible = false;
            Controls.Add(m_noMsgSentNotification);
            offset += new Vector2(0, m_noMsgSentNotification.Size.Y);
            m_noConnectionNotification          = new MyGuiControlLabel(new Vector2(1, 0) + offset, font: MyFontEnum.Red, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);
            m_noConnectionNotification.TextEnum = MySpaceTexts.Multiplayer_NoConnection;
            m_noConnectionNotification.Visible  = false;
            Controls.Add(m_noConnectionNotification);
            MyHud.ReloadTexts();
        }
        public override bool Draw()
        {
            if (m_transitionAlpha < 1.0f)
            {
                return(false);
            }

            if (MyInput.Static.IsNewKeyPressed(MyKeys.J) && MyFakes.ENABLE_OBJECTIVE_LINE)
            {
                MyHud.ObjectiveLine.AdvanceObjective();
            }

            m_toolbarControl.Visible = !MyHud.MinimalHud;

            Vector2 position = new Vector2(0.99f, 0.8f);

            position = ConvertHudToNormalizedGuiPosition(ref position);
            if (MyVideoSettingsManager.IsTripleHead())
            {
                position.X += 1.0f;
            }

            // TODO: refactor this
            m_blockInfo.Visible     = MyHud.BlockInfo.Visible && !MyHud.MinimalHud;
            m_blockInfo.BlockInfo   = m_blockInfo.Visible ? MyHud.BlockInfo : null;
            m_blockInfo.Position    = position;
            m_blockInfo.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;

            m_rotatingWheelControl.Visible = MyHud.RotatingWheelVisible && !MyHud.MinimalHud;

            if (!base.Draw())
            {
                return(false);
            }

            var bgPos = new Vector2(0.01f, 0.85f);

            bgPos = MyGuiScreenHudBase.ConvertHudToNormalizedGuiPosition(ref bgPos);
            m_chatControl.Position  = bgPos + new Vector2(0.15f, 0);
            m_chatControl.TextScale = 0.9f;

            bgPos = new Vector2(0.03f, 0.1f);
            bgPos = MyGuiScreenHudBase.ConvertHudToNormalizedGuiPosition(ref bgPos);
            m_cameraInfoMultilineControl.Position  = bgPos;
            m_cameraInfoMultilineControl.TextScale = 0.9f;

            if (MyHud.Crosshair.Visible && MySandboxGame.Config.ShowCrosshair)
            {
                DrawCrosshair(m_atlas, GetTextureCoord(MyHud.Crosshair.TextureEnum), MyHud.Crosshair);
            }

            MyHud.Notifications.Draw();

            m_buildModeLabel.Visible = !MyHud.MinimalHud && MyHud.IsBuildMode;

            if (MyHud.ShipInfo.Visible && !MyHud.MinimalHud)
            {
                DrawShipInfo(MyHud.ShipInfo);
            }

            if (MyHud.CharacterInfo.Visible && !MyHud.MinimalHud)
            {
                DrawSuitInfo(MyHud.CharacterInfo);
            }

            if (MyHud.ObjectiveLine.Visible && !MyHud.MinimalHud && MyFakes.ENABLE_OBJECTIVE_LINE)
            {
                DrawObjectiveLine(MyHud.ObjectiveLine);
            }

            MyHud.BlockInfo.Visible = false;
            m_blockInfo.BlockInfo   = null;

            if (MyHud.GravityIndicator.Visible && !MyHud.MinimalHud)
            {
                DrawGravityIndicator(MyHud.GravityIndicator, MyHud.CharacterInfo);
            }

            if (MyHud.ConsumerGroupInfo.Visible && !MyHud.MinimalHud)
            {
                DrawPowerGroupInfo(MyHud.ConsumerGroupInfo);
            }

            if (MyHud.SelectedObjectHighlight.Visible && MyFakes.ENABLE_USE_OBJECT_HIGHLIGHT)
            {
                DrawSelectedObjectHighlight(m_atlas, GetTextureCoord(MyHudTexturesEnum.corner), MyHud.SelectedObjectHighlight);
            }

            if (MyHud.LocationMarkers.Visible && !MyHud.MinimalHud)
            {
                m_markerRender.DrawLocationMarkers(MyHud.LocationMarkers);
            }

            if (MyHud.GpsMarkers.Visible && !MyHud.MinimalHud && MyFakes.ENABLE_GPS)
            {
                DrawGpsMarkers(MyHud.GpsMarkers);
            }

            if (MyHud.ButtonPanelMarkers.Visible && !MyHud.MinimalHud)
            {
                DrawButtonPanelMarkers(MyHud.ButtonPanelMarkers);
            }

            if (MyHud.OreMarkers.Visible && !MyHud.MinimalHud)
            {
                DrawOreMarkers(MyHud.OreMarkers);
            }

            if (MyHud.LargeTurretTargets.Visible && !MyHud.MinimalHud)
            {
                DrawLargeTurretTargets(MyHud.LargeTurretTargets);
            }

            if (!MyHud.MinimalHud)
            {
                DrawWorldBorderIndicator(MyHud.WorldBorderChecker);
            }

            if (MyHud.HackingMarkers.Visible && !MyHud.MinimalHud)
            {
                DrawHackingMarkers(MyHud.HackingMarkers);
            }

            //m_chatControl.Visible = !MyHud.MinimalHud;

            if (!MyHud.MinimalHud)
            {
                DrawCameraInfo(MyHud.CameraInfo);
            }

            ProfilerShort.Begin("Draw netgraph");
            if (MyFakes.ENABLE_NETGRAPH && MyHud.IsNetgraphVisible)
            {
                DrawNetgraph(MyHud.Netgraph);
            }
            ProfilerShort.End();
            //if (Sync.MultiplayerActive)
            DrawMultiplayerNotifications();

            if (!MyHud.MinimalHud && MyHud.VoiceChat.Visible)
            {
                DrawVoiceChat(MyHud.VoiceChat);
            }

            return(true);
        }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            m_toolbarControl                 = new MyGuiControlToolbar();
            m_toolbarControl.Position        = new Vector2(0.5f, 0.99f);
            m_toolbarControl.OriginAlign     = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM;
            m_toolbarControl.IsActiveControl = false;
            Elements.Add(m_toolbarControl);
            m_textScale = MyGuiConstants.HUD_TEXT_SCALE * MyGuiManager.LanguageTextScale;

            m_blockInfo = new MyGuiControlBlockInfo();
            m_blockInfo.IsActiveControl = false;
            Controls.Add(m_blockInfo);

            m_chatControl = new MyHudControlChat(Vector2.Zero, new Vector2(0.4f, 0.25f));
            Elements.Add(m_chatControl);

            m_cameraInfoMultilineControl = new MyGuiControlMultilineText(
                position: Vector2.Zero,
                size: new Vector2(0.4f, 0.25f),
                backgroundColor: null,
                font: MyFontEnum.White,
                textScale: 0.7f,
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM,
                contents: null,
                drawScrollbar: false,
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);
            m_cameraInfoMultilineControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
            Elements.Add(m_cameraInfoMultilineControl);

            m_rotatingWheelControl = new MyGuiControlRotatingWheel(position: new Vector2(0.5f, 0.85f));

            Controls.Add(m_rotatingWheelControl);

            Vector2 buildModePosition = new Vector2(0.5f, 0.02f);

            buildModePosition = MyGuiScreenHudBase.ConvertHudToNormalizedGuiPosition(ref buildModePosition);
            m_buildModeLabel  = new MyGuiControlLabel(
                position: buildModePosition,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                font: MyFontEnum.White,
                text: MyTexts.GetString(MySpaceTexts.Hud_BuildMode));
            Controls.Add(m_buildModeLabel);

            m_relayNotification          = new MyGuiControlLabel(new Vector2(1, 0), font: MyFontEnum.White, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);
            m_relayNotification.TextEnum = MySpaceTexts.Multiplayer_IndirectConnection;
            m_relayNotification.Visible  = false;
            Controls.Add(m_relayNotification);
            var offset = new Vector2(0, m_relayNotification.Size.Y);

            m_noMsgSentNotification         = new MyGuiControlLabel(new Vector2(1, 0) + offset, font: MyFontEnum.Debug, text: MyTexts.GetString(MySpaceTexts.Multiplayer_LastMsg), originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);
            m_noMsgSentNotification.Visible = false;
            Controls.Add(m_noMsgSentNotification);
            offset += new Vector2(0, m_noMsgSentNotification.Size.Y);
            m_noConnectionNotification          = new MyGuiControlLabel(new Vector2(1, 0) + offset, font: MyFontEnum.Red, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP);
            m_noConnectionNotification.TextEnum = MySpaceTexts.Multiplayer_NoConnection;
            m_noConnectionNotification.Visible  = false;
            Controls.Add(m_noConnectionNotification);
            MyHud.ReloadTexts();
        }