/// <summary>
        /// Used in order to get material requirements from prefabs of the new station/ship and draw them to the hud
        /// </summary>
        void CreateToolTipForNewGrid(MyCubeSize size, bool isStatic)
        {
            bool isLarge = (size == MyCubeSize.Large);
            MyGuiControlBlockInfo usedInfo   = isLarge ? m_blockInfoLarge : m_blockInfoSmall;
            MyGuiControlBlockInfo unusedInfo = !isLarge ? m_blockInfoLarge : m_blockInfoSmall;
            string prefabName;

            MyDefinitionManager.Static.GetBaseBlockPrefabName(size, isStatic, MySession.Static.CreativeMode, out prefabName);
            if (prefabName == null)
            {
                return;
            }
            var gridBuilders = MyPrefabManager.Static.GetGridPrefab(prefabName);

            Debug.Assert(gridBuilders != null && gridBuilders.Length > 0);
            if (gridBuilders == null || gridBuilders.Length == 0)
            {
                return;
            }

            MyCubeBlockDefinition blockDefinition = MyDefinitionManager.Static.GetCubeBlockDefinition(gridBuilders[0].CubeBlocks[0].GetId());

            if (blockDefinition != null)
            {
                usedInfo.BlockInfo.LoadDefinition(blockDefinition);
                usedInfo.Visible = true;
            }
            else
            {
                usedInfo.Visible = false;
            }
            unusedInfo.Visible = false;
        }
Ejemplo n.º 2
0
        private MyGuiControlBlockInfo CreateBlockInfoControl(MyCubeBlockDefinition blockDefinition, bool blockSizeLarge, ref MyGuiControlBlockInfo.MyControlBlockInfoStyle blockInfoStyle)
        {
            MyGuiControlBlockInfo blockInfo = new MyGuiControlBlockInfo(blockInfoStyle, false, blockSizeLarge)
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                BlockInfo   = new MyHudBlockInfo(),
            };

            blockInfo.BlockInfo.LoadDefinition(blockDefinition);
            blockInfo.RecalculateSize();

            return(blockInfo);
        }
Ejemplo n.º 3
0
        public override void RecreateControls(bool contructor)
        {
            base.RecreateControls(contructor);

            ProfilerShort.Begin("MyGuiScreenCubeBuilder.RecreateControls");

            bool showRightControls = !(MySession.ControlledEntity is MyShipController) || MyToolbarComponent.GlobalBuilding;

            //Disable right buttons if current spectator is official spectator
            if (MySession.Static.SurvivalMode)
            {
                showRightControls &= !(MySession.IsCameraUserControlledSpectator() && !MyInput.Static.ENABLE_DEVELOPER_KEYS && MySession.Static.Settings.EnableSpectator);
            }

            m_smallShipButton                = (MyGuiControlButton)Controls.GetControlByName("ButtonSmall");
            m_smallShipButton.Visible        = showRightControls;
            m_smallShipButton.ButtonClicked += smallShipButton_OnButtonClick;

            m_largeShipButton                = (MyGuiControlButton)Controls.GetControlByName("ButtonLarge");
            m_largeShipButton.Visible        = showRightControls;
            m_largeShipButton.ButtonClicked += largeShipButton_OnButtonClick;

            m_stationButton                = (MyGuiControlButton)Controls.GetControlByName("ButtonStation");
            m_stationButton.Visible        = showRightControls;
            m_stationButton.ButtonClicked += stationButton_OnButtonClick;

            if (m_screenCubeGrid != null)
            {
                m_smallShipButton.Visible = false;
                m_stationButton.Visible   = false;
                m_largeShipButton.Visible = false;
            }

            m_blockInfoSmall                 = new MyGuiControlBlockInfo(false, false);
            m_blockInfoSmall.Visible         = false;
            m_blockInfoSmall.IsActiveControl = false;
            m_blockInfoSmall.BlockInfo       = new MyHudBlockInfo();
            m_blockInfoSmall.Position        = new Vector2(0.28f, -0.04f);
            m_blockInfoSmall.OriginAlign     = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            Controls.Add(m_blockInfoSmall);
            m_blockInfoLarge                 = new MyGuiControlBlockInfo(false, true);
            m_blockInfoLarge.Visible         = false;
            m_blockInfoLarge.IsActiveControl = false;
            m_blockInfoLarge.BlockInfo       = new MyHudBlockInfo();
            m_blockInfoLarge.Position        = new Vector2(0.28f, -0.06f);
            m_blockInfoLarge.OriginAlign     = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
            Controls.Add(m_blockInfoLarge);

            ProfilerShort.End();
        }
        public override void RecreateControls(bool contructor)
        {
            base.RecreateControls(contructor);

            ProfilerShort.Begin("MyGuiScreenCubeBuilder.RecreateControls");

            bool showRightControls = !(MySession.Static.ControlledEntity is MyShipController) || (MySession.Static.ControlledEntity is MyShipController && (MySession.Static.ControlledEntity as MyShipController).BuildingMode) || MyToolbarComponent.GlobalBuilding;

            //Disable right buttons if current spectator is official spectator
            if (MySession.Static.SurvivalMode)
            {
                showRightControls &= !(MySession.Static.IsCameraUserControlledSpectator() && !MyInput.Static.ENABLE_DEVELOPER_KEYS && MySession.Static.Settings.EnableSpectator);
            }

            m_smallShipButton                = (MyGuiControlButton)Controls.GetControlByName("ButtonSmall");
            m_smallShipButton.Visible        = showRightControls;
            m_smallShipButton.ButtonClicked += smallShipButton_OnButtonClick;

            m_largeShipButton                = (MyGuiControlButton)Controls.GetControlByName("ButtonLarge");
            m_largeShipButton.Visible        = showRightControls;
            m_largeShipButton.ButtonClicked += largeShipButton_OnButtonClick;

            m_stationButton                = (MyGuiControlButton)Controls.GetControlByName("ButtonStation");
            m_stationButton.Visible        = showRightControls;
            m_stationButton.ButtonClicked += stationButton_OnButtonClick;



            if (m_screenCubeGrid != null && !(MySession.Static.ControlledEntity is MyShipController && (MySession.Static.ControlledEntity as MyShipController).BuildingMode))
            {
                m_smallShipButton.Visible = false;
                m_stationButton.Visible   = false;
                m_largeShipButton.Visible = false;
                //m_goodAiBotButton.Visible = false;
            }

            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                    = MyCommonTexts.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_blockInfoSmall                 = new MyGuiControlBlockInfo(style, false, false);
            m_blockInfoSmall.Visible         = false;
            m_blockInfoSmall.IsActiveControl = false;
            m_blockInfoSmall.BlockInfo       = new MyHudBlockInfo();
            m_blockInfoSmall.Position        = new Vector2(0.28f, -0.04f);
            m_blockInfoSmall.OriginAlign     = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            Controls.Add(m_blockInfoSmall);
            m_blockInfoLarge                 = new MyGuiControlBlockInfo(style, false, true);
            m_blockInfoLarge.Visible         = false;
            m_blockInfoLarge.IsActiveControl = false;
            m_blockInfoLarge.BlockInfo       = new MyHudBlockInfo();
            m_blockInfoLarge.Position        = new Vector2(0.28f, -0.06f);
            m_blockInfoLarge.OriginAlign     = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
            Controls.Add(m_blockInfoLarge);

            ProfilerShort.End();
        }
Ejemplo n.º 5
0
        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();
        }
Ejemplo n.º 6
0
        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();
        }