コード例 #1
0
        public override void RecreateControls(bool contructor)
        {
            base.RecreateControls(contructor);

            ProfilerShort.Begin("MyGuiScreenCubeBuilder.RecreateControls");

            m_gridBlocks.MouseOverIndexChanged += OnGridMouseOverIndexChanged;
            m_gridBlocks.ItemSelected          += OnSelectedItemChanged;

            m_blockInfoStyle = new MyGuiControlBlockInfo.MyControlBlockInfoStyle()
            {
                BlockNameLabelFont                   = MyFontEnum.White,
                EnableBlockTypeLabel                 = false,
                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                 = false,
            };

            m_blockInfoList = (MyGuiControlList)Controls.GetControlByName("BlockInfoPanel");
            if (m_blockInfoList == null)
            {
                Debug.Fail("Someone changed CubeBuilder.gsc file in Content folder? Please check");
            }


            ProfilerShort.End();
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        public override void RecreateControls(bool contructor)
        {
            base.RecreateControls(contructor);

            ProfilerShort.Begin("MyGuiScreenCubeBuilder.RecreateControls");

            m_gridBlocks.MouseOverIndexChanged += OnGridMouseOverIndexChanged;
            m_gridBlocks.ItemSelected          += OnSelectedItemChanged;

            m_blockInfoStyle = new MyGuiControlBlockInfo.MyControlBlockInfoStyle()
            {
                BlockNameLabelFont                   = MyFontEnum.White,
                EnableBlockTypeLabel                 = false,
                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                 = false,
            };

            m_rbGridSizeSmall = (MyGuiControlRadioButton)Controls.GetControlByName("GridSizeSmall");
            if (m_rbGridSizeSmall == null)
            {
                Debug.Fail("Someone changed CubeBuilder.gsc file in Content folder? Please check");
            }

            m_rbGridSizeSmall.HighlightType    = MyGuiControlHighlightType.NEVER;
            m_rbGridSizeSmall.SelectedChanged += OnGridSizeSmallSelected;

            m_rbGridSizeLarge = (MyGuiControlRadioButton)Controls.GetControlByName("GridSizeLarge");
            if (m_rbGridSizeLarge == null)
            {
                Debug.Fail("Someone changed CubeBuilder.gsc file in Content folder? Please check");
            }

            m_rbGridSizeLarge.HighlightType    = MyGuiControlHighlightType.NEVER;
            m_rbGridSizeLarge.SelectedChanged += OnGridSizeLargeSelected;

            m_rbGroupGridSize = new MyGuiControlRadioButtonGroup {
                m_rbGridSizeSmall, m_rbGridSizeLarge
            };
            if (MyCubeBuilder.Static != null)
            {
                m_rbGroupGridSize.SelectedIndex = MyCubeBuilder.Static.CubeBuilderState.CubeSizeMode == MyCubeSize.Small ? 0 : 1;
            }

            MyGuiControlLabel gridSizeLabel = (MyGuiControlLabel)Controls.GetControlByName("GridSizeHintLabel");

            gridSizeLabel.Text = string.Format(MyTexts.GetString(gridSizeLabel.TextEnum), MyGuiSandbox.GetKeyName(MyControlsSpace.CUBE_BUILDER_CUBESIZE_MODE));

            m_blockInfoList = (MyGuiControlList)Controls.GetControlByName("BlockInfoPanel");
            if (m_blockInfoList == null)
            {
                Debug.Fail("Someone changed CubeBuilder.gsc file in Content folder? Please check");
            }



            //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();
        }
コード例 #4
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);
        }
コード例 #5
0
        /// <summary>
        /// Generates list of block info controls from base block and its stages.
        /// </summary>
        /// <param name="blockDefinition">Definition of the block</param>
        /// <param name="blockInfoStyle">Block info style used in Block info control.</param>
        /// <returns>Array of block info controls.</returns>
        private MyGuiControlBase[] GenerateBlockInfos(MyCubeBlockDefinition blockDefinition, ref MyGuiControlBlockInfo.MyControlBlockInfoStyle blockInfoStyle)
        {
            int  blockCt        = blockDefinition.BlockStages != null ? blockDefinition.BlockStages.Length + 2 : 2;
            bool blockSizeLarge = blockDefinition.CubeSize == MyCubeSize.Large;

            MyGuiControlBase[] blockInfos = new MyGuiControlBase[blockCt];

            blockInfos[0] = GenerateSizeInfoLabel(blockSizeLarge);
            blockInfos[1] = CreateBlockInfoControl(blockDefinition, blockSizeLarge, ref blockInfoStyle);

            // No stages, just return base block info.
            if (blockCt == 1)
            {
                return(blockInfos);
            }

            for (int idx = 0; idx < blockCt - 2; idx++)
            {
                MyCubeBlockDefinition blockStageDefinition = null;
                bool result      = MyDefinitionManager.Static.TryGetDefinition(blockDefinition.BlockStages[idx], out blockStageDefinition);
                bool isAvailable = result && (blockStageDefinition.AvailableInSurvival || MySession.Static.CreativeMode);
                if (!isAvailable)
                {
                    continue;
                }

                blockInfos[idx + 2] = CreateBlockInfoControl(blockStageDefinition, blockSizeLarge, ref blockInfoStyle);
            }

            return(blockInfos);
        }
コード例 #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;

            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();
        }