Ejemplo n.º 1
0
        public MyGuiControlProgressBar(Vector2?position                        = null,
                                       Vector2?size                            = null,
                                       Color?progressBarColor                  = null,
                                       MyGuiDrawAlignEnum originAlign          = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                                       MyGuiCompositeTexture backgroundTexture = null,
                                       bool isHorizontal                       = true,
                                       bool potentialBarEnabled                = true)
            : base(position: position,
                   size: size,
                   backgroundTexture: backgroundTexture,
                   originAlign: originAlign,
                   colorMask: null,
                   toolTip: null)
        {
            ProgressColor        = (progressBarColor.HasValue ? progressBarColor.Value : DEFAULT_PROGRESS_COLOR);
            IsHorizontal         = isHorizontal;
            m_progressForeground = new MyGuiControlPanel(position: new Vector2(-Size.X / 2.0f, 0.0f),
                                                         originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                                                         backgroundColor: ProgressColor);
            m_progressForeground.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;

            m_potentialBar = new MyGuiControlPanel(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                                                   size: new Vector2(0f, Size.Y));
            m_potentialBar.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;
            m_potentialBar.ColorMask         = new Vector4(ProgressColor, 0.7f);
            m_potentialBar.Visible           = false;
            m_potentialBar.Enabled           = potentialBarEnabled;

            Elements.Add(m_potentialBar);
            Elements.Add(m_progressForeground);
        }
		public MyGuiControlProgressBar(	Vector2? position = null,
										Vector2? size = null,
										Color? progressBarColor = null,
										MyGuiDrawAlignEnum originAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
										MyGuiCompositeTexture backgroundTexture = null,
										bool isHorizontal = true,
										bool potentialBarEnabled = true)
            : base( position: position,
                    size: size,
					backgroundTexture: backgroundTexture,
					originAlign: originAlign,
                    colorMask: null,
                    toolTip: null)
        {
            ProgressColor = (progressBarColor.HasValue ? progressBarColor.Value : DEFAULT_PROGRESS_COLOR);
			IsHorizontal = isHorizontal;
			m_progressForeground = new MyGuiControlPanel(	position: new Vector2(-Size.X/2.0f, 0.0f),
															originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
															backgroundColor: ProgressColor);
			m_progressForeground.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;

			m_potentialBar = new MyGuiControlPanel(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
													size: new Vector2(0f, Size.Y));
			m_potentialBar.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;
			m_potentialBar.ColorMask = new Vector4(ProgressColor, 0.7f);
			m_potentialBar.Visible = false;
			m_potentialBar.Enabled = potentialBarEnabled;

			Elements.Add(m_potentialBar);
			Elements.Add(m_progressForeground);
        }
Ejemplo n.º 3
0
            public ComponentLineControl(Vector2 size, float iconSize)
                : base(size: size, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP)
            {
                var m_iconSize  = new Vector2(iconSize) * new Vector2(0.75f, 1);
                var middleLeft  = new Vector2(-this.Size.X / 2, 0);
                var middleRight = new Vector2(this.Size.X / 2, 0);
                var iconPos     = middleLeft - new Vector2(0, m_iconSize.Y / 2);

                //IconPanel = new MyGuiControlPanel();
                //IconPanelBackground = new MyGuiControlPanel();
                IconImage         = new MyGuiControlImage();
                IconPanelProgress = new MyGuiControlPanel();
                NameLabel         = new MyGuiControlLabel(text: String.Empty);
                NumbersLabel      = new MyGuiControlLabel(text: String.Empty);

                //IconPanel.Size = m_iconSize;
                //IconPanel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                //IconPanel.Position = iconPos;

                //IconPanelBackground.Size = m_iconSize;
                //IconPanelBackground.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                //IconPanelBackground.Position = iconPos;
                //IconPanelBackground.BackgroundTexture = new MyGuiCompositeTexture(MyGuiConstants.TEXTURE_HUD_BG_MEDIUM_DEFAULT.Texture);

                IconImage.Size              = m_iconSize;
                IconImage.OriginAlign       = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                IconImage.Position          = iconPos;
                IconImage.BackgroundTexture = new MyGuiCompositeTexture(MyGuiConstants.TEXTURE_HUD_BG_MEDIUM_DEFAULT.Texture);

                IconPanelProgress.Size              = m_iconSize;
                IconPanelProgress.OriginAlign       = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                IconPanelProgress.Position          = iconPos;
                IconPanelProgress.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;
                float gray = 0.1f;

                IconPanelProgress.ColorMask = new Vector4(gray, gray, gray, 0.5f);

                NameLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
                NameLabel.Position    = middleLeft + new Vector2(m_iconSize.X + 0.01225f, 0);

                NameLabel.AutoEllipsis = true;

                NumbersLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
                NumbersLabel.Position    = middleRight + new Vector2(-0.033f, 0); //topRight + new Vector2(-0.02f, 0.004f);

                //Elements.Add(IconPanelBackground);
                //Elements.Add(IconPanel);
                Elements.Add(IconImage);
                Elements.Add(IconPanelProgress);
                Elements.Add(NameLabel);
                Elements.Add(NumbersLabel);
            }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            var align = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
            var logoPanel = new MyGuiControlPanel(
                position: MyGuiManager.ComputeFullscreenGuiCoordinate(align, 54, 84),
                size: MyGuiConstants.TEXTURE_KEEN_LOGO.MinSizeGui,
                originAlign: align
                );
            logoPanel.BackgroundTexture = MyGuiConstants.TEXTURE_KEEN_LOGO;
            Controls.Add(logoPanel);
        }
            public ComponentLineControl(Vector2 size, float iconSize)
                : base(size: size, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP)
            {
                var m_iconSize = new Vector2(iconSize) * new Vector2(0.75f, 1);
                var middleLeft = new Vector2(-this.Size.X / 2, 0);
                var middleRight = new Vector2(this.Size.X / 2, 0);
                var iconPos = middleLeft - new Vector2(0, m_iconSize.Y / 2);

                //IconPanel = new MyGuiControlPanel();
                //IconPanelBackground = new MyGuiControlPanel();
                IconImage = new MyGuiControlImage();
                IconPanelProgress = new MyGuiControlPanel();
                NameLabel = new MyGuiControlLabel(text: String.Empty);
                NumbersLabel = new MyGuiControlLabel(text: String.Empty);
                
                //IconPanel.Size = m_iconSize;
                //IconPanel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                //IconPanel.Position = iconPos;

                //IconPanelBackground.Size = m_iconSize;
                //IconPanelBackground.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                //IconPanelBackground.Position = iconPos;
                //IconPanelBackground.BackgroundTexture = new MyGuiCompositeTexture(MyGuiConstants.TEXTURE_HUD_BG_MEDIUM_DEFAULT.Texture);

                IconImage.Size = m_iconSize;
                IconImage.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                IconImage.Position = iconPos;
                IconImage.BackgroundTexture = new MyGuiCompositeTexture(MyGuiConstants.TEXTURE_HUD_BG_MEDIUM_DEFAULT.Texture);

                IconPanelProgress.Size = m_iconSize;
                IconPanelProgress.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                IconPanelProgress.Position = iconPos;
                IconPanelProgress.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;
                float gray = 0.1f;
                IconPanelProgress.ColorMask = new Vector4(gray, gray, gray, 0.5f);

                NameLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
                NameLabel.Position = middleLeft + new Vector2(m_iconSize.X + 0.01225f, 0);

                NameLabel.AutoEllipsis = true;

                NumbersLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
                NumbersLabel.Position = middleRight + new Vector2(-0.033f, 0); //topRight + new Vector2(-0.02f, 0.004f);

                //Elements.Add(IconPanelBackground);
                //Elements.Add(IconPanel);
                Elements.Add(IconImage);
                Elements.Add(IconPanelProgress);
                Elements.Add(NameLabel);
                Elements.Add(NumbersLabel);
            }
 public MyGuiControlScenarioButton(MyScenarioDefinition scenario):
     base(key: MyDefinitionManager.Static.GetScenarioDefinitions().IndexOf(scenario))
 {
     VisualStyle = MyGuiControlRadioButtonStyleEnum.ScenarioButton;
     OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
     Scenario = scenario;
     m_titleLabel = new MyGuiControlLabel(text: scenario.DisplayNameText, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
     m_previewPanel = new MyGuiControlPanel(texture: scenario.Icon, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
     MyGuiSizedTexture image = new MyGuiSizedTexture() { SizePx = new Vector2(229f, 128f), };
     m_previewPanel.Size = image.SizeGui;
     m_previewPanel.BorderEnabled = true;
     m_previewPanel.BorderColor = MyGuiConstants.THEMED_GUI_LINE_COLOR.ToVector4();
     SetToolTip(scenario.DescriptionText);
     Size = new Vector2(Math.Max(m_titleLabel.Size.X, m_previewPanel.Size.X),
                        m_titleLabel.Size.Y + m_previewPanel.Size.Y);
     Elements.Add(m_titleLabel);
     Elements.Add(m_previewPanel);
 }
		public MyGuiControlProgressBar(	Vector2? position = null, Vector2? size = null, Color? progressBarColor = null,
										MyGuiDrawAlignEnum originAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiCompositeTexture backgroundTexture = null, bool isHorizontal = true)
            : base( position: position,
                    size: size,
					backgroundTexture: backgroundTexture,
					originAlign: originAlign,
                    colorMask: null,
                    toolTip: null)
        {
            ProgressColor = (progressBarColor.HasValue ? progressBarColor.Value : DEFAULT_PROGRESS_COLOR);
			IsHorizontal = isHorizontal;
			var pixelHorizontal = 1.1f/MyGuiManager.GetFullscreenRectangle().Width;
			var pixelVertical = 1.1f / MyGuiManager.GetFullscreenRectangle().Height;
			m_progressForeground = new MyGuiControlPanel(	position: new Vector2(-Size.X/2.0f + pixelHorizontal, 0.0f),
															originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
															backgroundColor: ProgressColor);
			m_progressForeground.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;
			Elements.Add(m_progressForeground);
        }
        public MyGuiControlProgressBar(Vector2?position = null, Vector2?size = null, Color?progressBarColor = null,
                                       MyGuiDrawAlignEnum originAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiCompositeTexture backgroundTexture = null, bool isHorizontal = true)
            : base(position: position,
                   size: size,
                   backgroundTexture: backgroundTexture,
                   originAlign: originAlign,
                   colorMask: null,
                   toolTip: null)
        {
            ProgressColor = (progressBarColor.HasValue ? progressBarColor.Value : DEFAULT_PROGRESS_COLOR);
            IsHorizontal  = isHorizontal;
            var pixelHorizontal = 1.1f / MyGuiManager.GetFullscreenRectangle().Width;
            var pixelVertical   = 1.1f / MyGuiManager.GetFullscreenRectangle().Height;

            m_progressForeground = new MyGuiControlPanel(position: new Vector2(-Size.X / 2.0f + pixelHorizontal, 0.0f),
                                                         originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                                                         backgroundColor: ProgressColor);
            m_progressForeground.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;
            Elements.Add(m_progressForeground);
        }
            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()); });
                }
            }
		public MyGuiControlBlockInfo(MyControlBlockInfoStyle style, bool progressMode = true, bool largeBlockInfo = true)
			: base(backgroundTexture: new MyGuiCompositeTexture(MyGuiConstants.TEXTURE_HUD_BG_LARGE_DEFAULT.Texture))
		{
			m_style = style;
			m_progressMode = progressMode;

			m_leftColumnBackground = new MyGuiControlPanel(backgroundColor: Color.Red.ToVector4());
			m_leftColumnBackground.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
			Elements.Add(m_leftColumnBackground);

			m_titleBackground = new MyGuiControlPanel(backgroundColor: Color.Red.ToVector4());
			m_titleBackground.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
			Elements.Add(m_titleBackground);

			if (m_progressMode)
			{
				m_integrityBackground = new MyGuiControlPanel(backgroundColor: Color.Red.ToVector4());
				m_integrityBackground.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
				Elements.Add(m_integrityBackground);

				m_integrityForeground = new MyGuiControlPanel(backgroundColor: Color.Red.ToVector4());
				m_integrityForeground.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
				Elements.Add(m_integrityForeground);

				m_integrityCriticalLine = new MyGuiControlPanel(backgroundColor: Color.Red.ToVector4());
				m_integrityCriticalLine.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
				Elements.Add(m_integrityCriticalLine);
			}

            //m_blockIconPanelBackground = new MyGuiControlPanel();
            //m_blockIconPanelBackground.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            //m_blockIconPanelBackground.BackgroundTexture = new MyGuiCompositeTexture(MyGuiConstants.TEXTURE_HUD_BG_MEDIUM_DEFAULT.Texture);
            //m_blockIconPanelBackground.Size = m_progressMode ? new Vector2(0.088f) : new Vector2(0.04f);
            //m_blockIconPanelBackground.Size *= new Vector2(0.75f, 1);
            //Elements.Add(m_blockIconPanelBackground);

            //m_blockIconPanel = new MyGuiControlPanel();
            //m_blockIconPanel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            //m_blockIconPanel.Size = m_progressMode ? new Vector2(0.088f) : new Vector2(0.04f);
            //m_blockIconPanel.Size *= new Vector2(0.75f, 1);
            //Elements.Add(m_blockIconPanel);

            m_blockIconImage = new MyGuiControlImage();
            m_blockIconImage.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            m_blockIconImage.BackgroundTexture = new MyGuiCompositeTexture(MyGuiConstants.TEXTURE_HUD_BG_MEDIUM_DEFAULT.Texture);
            m_blockIconImage.Size = m_progressMode ? new Vector2(0.088f) : new Vector2(0.04f);
            m_blockIconImage.Size *= new Vector2(0.75f, 1);
            Elements.Add(m_blockIconImage);

			m_blockTypePanelBackground = new MyGuiControlPanel();
			m_blockTypePanelBackground.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
			m_blockTypePanelBackground.BackgroundTexture = new MyGuiCompositeTexture(MyGuiConstants.TEXTURE_HUD_BG_MEDIUM_DEFAULT.Texture);
			m_blockTypePanelBackground.Size = m_progressMode ? new Vector2(0.088f) : new Vector2(0.04f);
			m_blockTypePanelBackground.Size *= new Vector2(0.75f, 1);
			Elements.Add(m_blockTypePanelBackground);

			m_blockTypePanel = new MyGuiControlPanel();
			m_blockTypePanel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
			m_blockTypePanel.Size = m_progressMode ? new Vector2(0.088f) : new Vector2(0.04f);
			m_blockTypePanel.Size *= new Vector2(0.75f, 1);
			m_blockTypePanel.BackgroundTexture = new MyGuiCompositeTexture(largeBlockInfo ? @"Textures\GUI\Icons\Cubes\LargeBlock.dds" : @"Textures\GUI\Icons\Cubes\SmallBlock.dds");
			Elements.Add(m_blockTypePanel);

			m_blockNameLabel = new MyGuiControlLabel(text: String.Empty);
			m_blockNameLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
			m_blockNameLabel.TextScale = 1 * baseScale;
			m_blockNameLabel.Font = m_style.BlockNameLabelFont;
			m_blockNameLabel.AutoEllipsis = true;
			Elements.Add(m_blockNameLabel);

			String blockTypeLabelText = String.Empty;
			if (style.EnableBlockTypeLabel)
				blockTypeLabelText = MyTexts.GetString(largeBlockInfo ? MySpaceTexts.HudBlockInfo_LargeShip_Station : MySpaceTexts.HudBlockInfo_SmallShip);
			m_blockTypeLabel = new MyGuiControlLabel(text: blockTypeLabelText);
			m_blockTypeLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
			m_blockTypeLabel.TextScale = 1 * baseScale;
			m_blockTypeLabel.Font = MyFontEnum.White;
			Elements.Add(m_blockTypeLabel);

			m_componentsLabel = new MyGuiControlLabel(text: MyTexts.GetString(m_style.ComponentsLabelText));
			m_componentsLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
			m_componentsLabel.TextScale = m_smallerFontSize * baseScale;
			m_componentsLabel.Font = m_style.ComponentsLabelFont;
			Elements.Add(m_componentsLabel);

			m_installedRequiredLabel = new MyGuiControlLabel(text: MyTexts.GetString(m_style.InstalledRequiredLabelText));
			m_installedRequiredLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
			m_installedRequiredLabel.TextScale = m_smallerFontSize * baseScale;
			m_installedRequiredLabel.Font = m_style.InstalledRequiredLabelFont;
			Elements.Add(m_installedRequiredLabel);

            m_blockBuiltByLabel = new MyGuiControlLabel(text: String.Empty);
            m_blockBuiltByLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
            m_blockBuiltByLabel.TextScale = m_smallerFontSize * baseScale;
            m_blockBuiltByLabel.Font = m_style.InstalledRequiredLabelFont;
            Elements.Add(m_blockBuiltByLabel);

			if (m_progressMode)
			{
				m_integrityLabel = new MyGuiControlLabel(text: String.Empty);
				m_integrityLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM;
				m_integrityLabel.Font = m_style.IntegrityLabelFont;
				m_integrityLabel.TextScale = 0.75f * baseScale;
				Elements.Add(m_integrityLabel);
			}

			m_separator = new MyGuiControlSeparatorList();
			Elements.Add(m_separator);

			EnsureLineControls(m_componentLines.Capacity);
			Size = m_progressMode ? new Vector2(0.325f, 0.4f) : new Vector2(0.22f, 0.4f);
		}
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            Vector2 cbOffset = new Vector2(-0.05f, 0.0f);
            Vector2 controlPadding = new Vector2(0.02f, 0.02f); // X: Left & Right, Y: Bottom & Top
            Vector2 multilinePadding = new Vector2(0.008f, 0.005f); // X: Left, Y: Bottom & Top

            float textScale = 0.8f;
            float separatorSize = 0.02f;
            float usableWidth = SCREEN_SIZE.X - HIDDEN_PART_RIGHT - controlPadding.X * 2;
            float hiddenPartTop = (SCREEN_SIZE.Y - 1.0f) / 2.0f;

            m_currentPosition = -m_size.Value / 2.0f;
            m_currentPosition += controlPadding;
            m_currentPosition.Y += hiddenPartTop;
            m_scale = textScale;

            var caption = AddCaption(MyCommonTexts.ScreenDebugOfficial_Caption, Color.White.ToVector4(), controlPadding + new Vector2(-HIDDEN_PART_RIGHT, hiddenPartTop));
            m_currentPosition.Y += MyGuiConstants.SCREEN_CAPTION_DELTA_Y * 2.0f;

            AddCheckBox(MyCommonTexts.ScreenDebugOfficial_EnableDebugDraw, () => MyDebugDrawSettings.ENABLE_DEBUG_DRAW, (bool b) => MyDebugDrawSettings.ENABLE_DEBUG_DRAW = b, color: Color.White.ToVector4(), checkBoxOffset: cbOffset);

            m_currentPosition.Y += separatorSize;

            AddCheckBox(MyCommonTexts.ScreenDebugOfficial_ModelDummies, () => MyDebugDrawSettings.DEBUG_DRAW_MODEL_DUMMIES, (bool b) => MyDebugDrawSettings.DEBUG_DRAW_MODEL_DUMMIES = b, color: Color.White.ToVector4(), checkBoxOffset: cbOffset);
            AddCheckBox(MyCommonTexts.ScreenDebugOfficial_MountPoints, () => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS, (bool b) => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS = b, color: Color.White.ToVector4(), checkBoxOffset: cbOffset);
            AddCheckBox(MyCommonTexts.ScreenDebugOfficial_PhysicsPrimitives, () => MyDebugDrawSettings.DEBUG_DRAW_PHYSICS_SHAPES, (bool b) => { MyDebugDrawSettings.DEBUG_DRAW_PHYSICS |= b; MyDebugDrawSettings.DEBUG_DRAW_PHYSICS_SHAPES = b; }, color: Color.White.ToVector4(), checkBoxOffset: cbOffset);

            m_currentPosition.Y += separatorSize;

            CreateDebugButton(usableWidth, MyCommonTexts.ScreenDebugOfficial_ReloadTextures, ReloadTextures);
            CreateDebugButton(usableWidth, MyCommonTexts.ScreenDebugOfficial_ReloadModels, ReloadModels);
            CreateDebugButton(usableWidth, MyCommonTexts.ScreenDebugOfficial_SavePrefab, SavePrefab, MyCubeBuilder.Static != null ? MyCubeBuilder.Static.Clipboard.HasCopiedGrids() : false, MyCommonTexts.ToolTipSaveShip);

            // Don't enable the SE bot debugging in official builds yet
            if (MyPerGameSettings.Game == GameEnum.ME_GAME || !MyFinalBuildConstants.IS_OFFICIAL)
                CreateDebugButton(usableWidth, MyCommonTexts.ScreenDebugOfficial_BotSettings, OpenBotsScreen);

            AddSubcaption(MyTexts.GetString(MyCommonTexts.ScreenDebugOfficial_ErrorLogCaption), Color.White.ToVector4(), new Vector2(-HIDDEN_PART_RIGHT, 0.0f));

            CreateDebugButton(usableWidth, MyCommonTexts.ScreenDebugOfficial_OpenErrorLog, CreateErrorLogScreen);
            CreateDebugButton(usableWidth, MyCommonTexts.ScreenDebugOfficial_CopyErrorLogToClipboard, CopyErrorLogToClipboard);

            m_currentPosition.Y += separatorSize;

            Vector2 textboxSize = (MyGuiManager.GetMaxMouseCoord() / 2.0f) - m_currentPosition;
            textboxSize.X = usableWidth;
            textboxSize.Y -= controlPadding.Y;
            m_currentPosition.X += multilinePadding.X / 2.0f;

            // Because multiline text does not allow padding
            var textBackground = new MyGuiControlPanel(m_currentPosition - multilinePadding, textboxSize + new Vector2(multilinePadding.X, multilinePadding.Y * 2.0f), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            textBackground.BackgroundTexture = MyGuiConstants.TEXTURE_SCROLLABLE_LIST;
            Controls.Add(textBackground);

            var text = AddMultilineText(size: textboxSize);

            if (MyDefinitionErrors.GetErrors().Count() == 0)
            {
                text.AppendText(MyTexts.Get(MyCommonTexts.ScreenDebugOfficial_NoErrorText));
            }
            else
            {
                var errors = MyDefinitionErrors.GetErrors();
                var errorDictionary = new Dictionary<string, Tuple<int, TErrorSeverity>>();

                // Count the number of most severe error per mod
                // Errors are already sorted by severity, so the first one per mod is the most severe
                foreach (var error in errors)
                {
                    var modName = error.ModName ?? "Local Content";

                    if (errorDictionary.ContainsKey(modName))
                    {
                        if (errorDictionary[modName].Item2 == error.Severity)
                        {
                            var info = errorDictionary[modName];
                            errorDictionary[modName] = new Tuple<int, TErrorSeverity>(info.Item1 + 1, info.Item2);
                        }
                    }
                    else
                    {
                        errorDictionary[modName] = new Tuple<int, TErrorSeverity>(1, error.Severity);
                    }
                }

                // Convert to list and sort to make sure most severe is displayed first
                var errorList = new List<Tuple<string, int, TErrorSeverity>>();
                foreach (var entry in errorDictionary)
                {
                    errorList.Add(new Tuple<string, int, TErrorSeverity>(entry.Key, entry.Value.Item1, entry.Value.Item2));
                }

                Comparison<Tuple<string, int, TErrorSeverity>> comp = (e1, e2) => e2.Item3 - e1.Item3;
                errorList.Sort(comp);

                foreach (var error in errorList)
                {
                    var errorText = new StringBuilder();
                    errorText.Append(error.Item1);
                    errorText.Append(" [");
                    if (error.Item3 == TErrorSeverity.Critical)
                    {
                        errorText.Append(MyDefinitionErrors.Error.GetSeverityName(error.Item3, false));
                        errorText.Append("]");
                    }
                    else
                    {
                        errorText.Append(error.Item2.ToString());
                        errorText.Append(" ");
                        errorText.Append(MyDefinitionErrors.Error.GetSeverityName(error.Item3, error.Item2 != 1));
                        errorText.Append("]");
                    }
                    text.AppendText(errorText, text.Font, text.TextScaleWithLanguage, MyDefinitionErrors.Error.GetSeverityColor(error.Item3).ToVector4());
                    text.AppendLine();
                }
            }
        }
Ejemplo n.º 12
0
        //  Because only main menu's controla depends on fullscreen pixel coordinates (not normalized), after we change
        //  screen resolution we need to recreate controls too. Otherwise they will be still on old/bad positions, and
        //  for example when changing from 1920x1200 to 800x600 they would be out of screen
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);


            // Enable background fade when we're in game, but in main menu we disable it.
            var buttonSize = MyGuiControlButton.GetVisualStyle(MyGuiControlButtonStyleEnum.Default).NormalTexture.MinSizeGui;
            Vector2 leftButtonPositionOrigin = MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM) + new Vector2(buttonSize.X / 2f, 0f);
            Vector2 rightButtonPositionOrigin = MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM) + new Vector2(-buttonSize.X / 2f, 0f);

            // In main menu
            if (MyGuiScreenGamePlay.Static == null)
            {
                EnabledBackgroundFade = false;
                // Left main menu part

                var a = MyGuiManager.GetSafeFullscreenRectangle();
                var fullScreenSize = new Vector2(a.Width / (a.Height * (4 / 3f)), 1f);

                // New Game
                // Load world
                // Join world
                // Workshop
                //
                // Options
                // Help
                // Credits
                // Exit to windows
                int buttonIndex = MyPerGameSettings.MultiplayerEnabled ? 9 : 8;
                Controls.Add(MakeButton(leftButtonPositionOrigin - (buttonIndex--) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA - MyGuiConstants.MENU_BUTTONS_POSITION_DELTA / 2, MyCommonTexts.ScreenMenuButtonContinueGame, OnContinueGameClicked));
                Controls.Add(MakeButton(leftButtonPositionOrigin - (buttonIndex--) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonCampaign, OnClickNewGame));
                Controls.Add(MakeButton(leftButtonPositionOrigin - (buttonIndex--) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonLoadGame, OnClickLoad));
                if (MyPerGameSettings.MultiplayerEnabled)
                    Controls.Add(MakeButton(leftButtonPositionOrigin - (buttonIndex--) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonJoinGame, OnJoinWorld));
                Controls.Add(MakeButton(leftButtonPositionOrigin - (buttonIndex--) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonCustomGame, OnCustomGameClicked));
                --buttonIndex;
                //Controls.Add(MakeButton(leftButtonPositionOrigin - (buttonIndex--) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonSubscribedWorlds, OnClickSubscribedWorlds, MyCommonTexts.ToolTipMenuSubscribedWorlds));
                Controls.Add(MakeButton(leftButtonPositionOrigin - (buttonIndex--) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonOptions, OnClickOptions));
                Controls.Add(MakeButton(leftButtonPositionOrigin - (buttonIndex--) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonHelp, OnClickHelp));
                Controls.Add(MakeButton(leftButtonPositionOrigin - (buttonIndex--) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonCredits, OnClickCredits));
                Controls.Add(MakeButton(leftButtonPositionOrigin - (buttonIndex--) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonExitToWindows, OnClickExitToWindows));

                Vector2 textRightTopPosition = MyGuiManager.GetScreenTextRightTopPosition();
                Vector2 position = textRightTopPosition + 8f * MyGuiConstants.CONTROLS_DELTA + new Vector2(-.1f, .06f);
            }
            else // In-game
            {
                MyAnalyticsHelper.ReportActivityStart(null, "show_main_menu", string.Empty, "gui", string.Empty);

                EnabledBackgroundFade = true;
                int buttonRowIndex = Sync.MultiplayerActive ? 6 : 5;

                // Save
                // Load button (only on dev)
                //
                // Options
                // Help
                // Exit to main menu
                var saveButton = MakeButton(leftButtonPositionOrigin - ((float)(--buttonRowIndex)) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonSave, OnClickSaveWorld);
                var saveAsButton = MakeButton(leftButtonPositionOrigin - ((float)(--buttonRowIndex)) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.LoadScreenButtonSaveAs, OnClickSaveAs);

                if (!Sync.IsServer || (MySession.Static.Battle))
                {
                    saveButton.Enabled = false;
                    saveButton.ShowTooltipWhenDisabled = true;
                    saveButton.SetToolTip(MyCommonTexts.NotificationClientCannotSave);

                    saveAsButton.Enabled = false;
                    saveButton.ShowTooltipWhenDisabled = true;
                    saveButton.SetToolTip(MyCommonTexts.NotificationClientCannotSave);
                }

                Controls.Add(saveButton);
                Controls.Add(saveAsButton);

                //               --buttonRowIndex; // empty line
                if (Sync.MultiplayerActive)
                    Controls.Add(MakeButton(leftButtonPositionOrigin - ((float)(--buttonRowIndex)) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonPlayers, OnClickPlayers));
                Controls.Add(MakeButton(leftButtonPositionOrigin - ((float)(--buttonRowIndex)) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonOptions, OnClickOptions));
                Controls.Add(MakeButton(leftButtonPositionOrigin - ((float)(--buttonRowIndex)) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonHelp, OnClickHelp));
                Controls.Add(MakeButton(leftButtonPositionOrigin - ((float)(--buttonRowIndex)) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonExitToMainMenu, OnExitToMainMenuClick));
            }

            var logoPanel = new MyGuiControlPanel(
                position: MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, 54, 84),
                size: MyGuiConstants.TEXTURE_KEEN_LOGO.MinSizeGui,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP
                );
            logoPanel.BackgroundTexture = MyGuiConstants.TEXTURE_KEEN_LOGO;
            Controls.Add(logoPanel);

            // Recommend button
            Vector2 pos = rightButtonPositionOrigin - 8f * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA;
            Controls.Add(MakeButton(pos, MyCommonTexts.ScreenMenuButtonRecommend, OnClickRecommend));
            m_newsControl = new MyGuiControlNews()
            {
                Position = MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM) - 7f * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA,
                Size = new Vector2(0.4f, 0.28f),
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP,
            };
            Controls.Add(m_newsControl);

            var webButton = MakeButton(
                MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM, 70),
                MySpaceTexts.Blank, OnClickGameWeb);
            webButton.Text = MyPerGameSettings.GameWebUrl;
            webButton.VisualStyle = MyGuiControlButtonStyleEnum.UrlText;
            Controls.Add(webButton);

            var reportButton = MakeButton(
                new Vector2(m_newsControl.Position.X, m_newsControl.Position.Y + m_newsControl.Size.Y),
                //MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM, 140,80),
                MyCommonTexts.ReportBug, OnClickReportBug);
            reportButton.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
            reportButton.VisualStyle = MyGuiControlButtonStyleEnum.UrlText;
            Controls.Add(reportButton);

            CheckLowMemSwitchToLow();
        }
Ejemplo n.º 13
0
        public MyGuiControlNews():
            base(isActiveControl: true,
            canHaveFocus: false,
            allowFocusingElements: true)
        {
            m_news = new List<MyNewsEntry>();

            m_labelTitle = new MyGuiControlLabel(
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP) {
                Name = "Title"
            };
            m_labelDate = new MyGuiControlLabel(
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP) {
                Name = "Date"
            };
            m_separator = new MyGuiControlSeparatorList() {
                Name = "Separator",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER
            };
            m_textNewsEntry = new MyGuiControlMultilineText(
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.85f,
                drawScrollbar: true)
            {
                Name = "NewsEntry",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
            };
            m_textNewsEntry.OnLinkClicked += OnLinkClicked;
            m_bottomPanel = new MyGuiControlPanel()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM,
                BackgroundTexture = MyGuiConstants.TEXTURE_NEWS_PAGING_BACKGROUND,
                Name = "BottomPanel",
            };
            m_labelPages = new MyGuiControlLabel(
                text: new StringBuilder("{0}/{1}  ").ToString(),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM) {
                Name = "Pages"
            };
            m_buttonPrev = new MyGuiControlButton(
                visualStyle: MyGuiControlButtonStyleEnum.ArrowLeft,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM,
                onButtonClick: (b) => UpdateCurrentEntryIndex(-1)) {
                Name = "Previous"
            };
            m_buttonNext = new MyGuiControlButton(
                visualStyle: MyGuiControlButtonStyleEnum.ArrowRight,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM,
                onButtonClick: (b) => UpdateCurrentEntryIndex(+1)) {
                Name = "Next"
            };
            m_textError = new MyGuiControlMultilineText(
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                font: MyFontEnum.Red) {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                Name = "Error"
            };
            m_backgroundPanel = new MyGuiControlCompositePanel()
            {
                ColorMask = new Vector4(1f, 1f, 1f, 0.69f),
                BackgroundTexture = MyGuiConstants.TEXTURE_NEWS_BACKGROUND
            };

            m_wheelLoading = new MyGuiControlRotatingWheel(multipleSpinningWheels: MyPerGameSettings.GUI.MultipleSpinningWheels);

            Elements.Add(m_backgroundPanel);
            Elements.Add(m_labelTitle);
            Elements.Add(m_labelDate);
            Elements.Add(m_separator);
            Elements.Add(m_textNewsEntry);
            Elements.Add(m_bottomPanel);
            Elements.Add(m_labelPages);
            Elements.Add(m_buttonPrev);
            Elements.Add(m_buttonNext);
            Elements.Add(m_textError);
            Elements.Add(m_wheelLoading);

            if (false)
            {
                m_textNewsEntry.BorderEnabled = true;
                m_labelPages.BorderEnabled = true;
                m_bottomPanel.BorderEnabled = true;
                m_buttonPrev.BorderEnabled = true;
                m_buttonNext.BorderEnabled = true;
                m_textError.BorderEnabled = true;
                m_wheelLoading.BorderEnabled = true;
            }

            RefreshState();
            UpdatePositionsAndSizes();
            RefreshShownEntry();

            try
            {
                m_newsSerializer = new XmlSerializer(typeof(MyNews));
            }
            finally
            {
                DownloadNews();   
            }
        }
Ejemplo n.º 14
0
        private void CreateChatPageControls(MyGuiControlTabPage chatPage)
        {
            chatPage.Name = "PageComms";
            chatPage.TextEnum = MySpaceTexts.TerminalTab_Chat;

            float left = -0.4625f;
            float right = -left;
            
            float top = -0.34f;

            int rowCount = 11;

            float width = 0.35f;
            //defined based on row count
            float height = 0;

            float margin = 0.02f;

            var playerLabel = new MyGuiControlLabel()
            {
                Position = new Vector2(left, top),
                Name = "PlayerLabel",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Text = MyTexts.GetString(MyCommonTexts.ScreenCaptionPlayers)
            };
            chatPage.Controls.Add(playerLabel);

            top += playerLabel.GetTextSize().Y + 0.01f;

            var playerList = new MyGuiControlListbox()
            {
                Position = new Vector2(left, top),
                Size = new Vector2(width, 0f),
                Name = "PlayerListbox",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                VisibleRowsCount = rowCount
            };
            chatPage.Controls.Add(playerList);

            height = playerList.ItemSize.Y * rowCount;
            top += height + margin;
            rowCount = 4;

            var factionLabel = new MyGuiControlLabel()
            {
                Position = new Vector2(left, top),
                Name = "PlayerLabel",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Text = MyTexts.GetString(MyCommonTexts.Factions)
            };
            chatPage.Controls.Add(factionLabel);

            top += playerLabel.GetTextSize().Y + 0.01f;

            var factionsList = new MyGuiControlListbox()
            {
                Position = new Vector2(left, top),
                Size = new Vector2(width, 0f),
                Name = "FactionListbox",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                VisibleRowsCount = rowCount
            };
            chatPage.Controls.Add(factionsList);

            top = -0.34f;
            width = 0.6f;
            height = 0.515f;
            margin = 0.038f;

            var chatboxPanel = new MyGuiControlPanel()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP,
                Position = new Vector2(right, top),
                Size = new Vector2(width, height),
                BackgroundTexture = MyGuiConstants.TEXTURE_RECTANGLE_NEUTRAL,
            };

            chatPage.Controls.Add(chatboxPanel);

            var chatHistory = new MyGuiControlMultilineText(
                position: new Vector2(right, top + 0.005f),
                size: new Vector2(width - 0.01f, height - 0.01f),
                backgroundColor: null,
                font: MyFontEnum.Blue,
                textScale: 0.95f,
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                contents: null);
            chatHistory.Name = "ChatHistory";
            chatHistory.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
            chatHistory.TextBoxAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            chatPage.Controls.Add(chatHistory);

            top += height + margin;
            height = 0.05f;
            var chatbox = new MyGuiControlTextbox()
            {
                Position = new Vector2(right, top),
                Size = new Vector2(width, height),
                Name = "Chatbox",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER
            };

            chatPage.Controls.Add(chatbox);

            width = 0.75f;
            top += height + margin;
            height = 0.05f;
            var sendButton = new MyGuiControlButton()
            {
                Position = new Vector2(right, top),
                Text = "Send",
                Name = "SendButton",
                Size = new Vector2(width, height),
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER,
            };

            chatPage.Controls.Add(sendButton);
        }
        protected virtual void BuildControls()
        {
            AddCaption(ScreenCaption);

            // side menu
            {
                var nameLabel = MakeLabel(MyCommonTexts.Name);
                var descriptionLabel = MakeLabel(MyCommonTexts.Description);

                m_nameTextbox = new MyGuiControlTextbox(maxLength: MySession.MAX_NAME_LENGTH);
                m_nameTextbox.Enabled = false;
                m_descriptionTextbox = new MyGuiControlTextbox(maxLength: MySession.MAX_DESCRIPTION_LENGTH);
                m_descriptionTextbox.Enabled = false;

                Vector2 originL;
                Vector2 controlsDelta = new Vector2(0f, 0.052f);
                originL = -m_size.Value / 2 + new Vector2(MARGIN_LEFT, MARGIN_TOP);

                var screenSize = m_size.Value;
                var layoutSize = screenSize / 2 - originL;
                var columnWidthLabel = layoutSize.X * 0.25f;
                var columnWidthControl = layoutSize.X - columnWidthLabel;
                var rowHeight = 0.052f;
                layoutSize.Y = rowHeight * 5;

                m_sideMenuLayout = new MyLayoutTable(this, originL, layoutSize);
                m_sideMenuLayout.SetColumnWidthsNormalized(columnWidthLabel, columnWidthControl);
                m_sideMenuLayout.SetRowHeightsNormalized(rowHeight, rowHeight, rowHeight, rowHeight, rowHeight);
                
                m_sideMenuLayout.Add(nameLabel, MyAlignH.Left, MyAlignV.Top, 0, 0);
                m_sideMenuLayout.Add(m_nameTextbox, MyAlignH.Left, MyAlignV.Top, 0, 1);
                m_sideMenuLayout.Add(descriptionLabel, MyAlignH.Left, MyAlignV.Top, 1, 0);
                m_sideMenuLayout.Add(m_descriptionTextbox, MyAlignH.Left, MyAlignV.Top, 1, 1);
            }

            // briefing
            {
                var briefingPanel = new MyGuiControlPanel()
                {
                    Name = "BriefingPanel",
                    Position = new Vector2(-0.02f, -0.12f),
                    Size = new Vector2(0.43f, 0.422f),
                    OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                    BackgroundTexture = MyGuiConstants.TEXTURE_SCROLLABLE_LIST
                };
                Controls.Add(briefingPanel);

                m_descriptionBox = new MyGuiControlMultilineText(
                    selectable: false,
                    font: MyFontEnum.Blue)
                {
                    Name = "BriefingMultilineText",
                    Position = new Vector2(-0.009f, -0.115f),
                    Size = new Vector2(0.419f, 0.412f),
                    OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                    TextAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                    TextBoxAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                };
                Controls.Add(m_descriptionBox);
            }

            // buttons
            {
                int buttonRowCount = 2;
                int buttonColumnCount = 4;
                Vector2 buttonSize = new Vector2(300f / 1600f, 70f / 1200f);
                Vector2 buttonsOrigin = m_size.Value / 2 - new Vector2(0.83f, 0.16f);
                Vector2 buttonOffset = new Vector2(0.01f, 0.01f);
                Vector2 buttonLayoutSize = new Vector2((buttonSize.X + buttonOffset.X) * (buttonColumnCount), (buttonSize.Y + buttonOffset.Y) * (buttonRowCount));
                m_buttonsLayout = new MyLayoutTable(this, buttonsOrigin, buttonLayoutSize);

                float[] columnWidths = Enumerable.Repeat(buttonSize.X + buttonOffset.X, buttonColumnCount).ToArray();
                m_buttonsLayout.SetColumnWidthsNormalized(columnWidths);
                float[] rowHeights = Enumerable.Repeat(buttonSize.Y + buttonOffset.Y, buttonRowCount).ToArray();
                m_buttonsLayout.SetRowHeightsNormalized(rowHeights);

                m_okButton = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OnOkButtonClick);
                m_cancelButton = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: OnCancelButtonClick);

                m_buttonsLayout.Add(m_okButton, MyAlignH.Left, MyAlignV.Top, 1, 2);
                m_buttonsLayout.Add(m_cancelButton, MyAlignH.Left, MyAlignV.Top, 1, 3);
            }

            // left menu
            {
                m_scenarioTable = CreateScenarioTable();
                Controls.Add(m_scenarioTable);
            }
        }
Ejemplo n.º 16
0
        private void CreateFactionsPageControls(MyGuiControlTabPage page)
        {
            page.Name = "PageFactions";
            page.TextEnum = MySpaceTexts.TerminalTab_Factions;

            var left = -0.462f;
            var top = -0.34f;
            var spacingH = 0.0045f;
            var spacingV = 0.01f;
            var buttonSize = new Vector2(0.29f, 0.052f);
            var smallerBtn = new Vector2(0.13f, 0.04f);

            var factionsComposite = new MyGuiControlCompositePanel()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Position = new Vector2(left, top),
                Size = new Vector2(0.4f, 0.69f),
                Name = "Factions"
            };
            left += spacingH;
            top += spacingV;

            var factionsPanel = new MyGuiControlPanel()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Position = new Vector2(left, top),
                Size = new Vector2(factionsComposite.Size.X - 0.01f, 0.035f),
                BackgroundTexture = MyGuiConstants.TEXTURE_HIGHLIGHT_DARK
            };

            var factionsLabel = new MyGuiControlLabel(
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                position: new Vector2(left + spacingH, top),
                size: factionsPanel.Size - new Vector2(0.01f, 0.01f),
                text: MyTexts.GetString(MySpaceTexts.TerminalTab_Factions)
            );
            top += factionsLabel.Size.Y + spacingV;

            var factionsTable = new MyGuiControlTable()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Position = new Vector2(left, top),
                Size = new Vector2(factionsPanel.Size.X, 0.15f),
                Name = "FactionsTable",
                ColumnsCount = 3,
                VisibleRowsCount = 14,
            };
            factionsTable.SetCustomColumnWidths(new float[] { 0.16f, 0.75f, 0.09f });
            factionsTable.SetColumnName(0, MyTexts.Get(MyCommonTexts.Tag));
            factionsTable.SetColumnName(1, MyTexts.Get(MyCommonTexts.Name));
            top += factionsTable.Size.Y + spacingV;

            var createBtn      = new MyGuiControlButton(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left, top)) { Name = "buttonCreate" };
            var joinBtn        = new MyGuiControlButton(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left, top + buttonSize.Y + spacingV)) { Name = "buttonJoin" };
            var joinCancelBtn  = new MyGuiControlButton(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left, top + buttonSize.Y + spacingV)) { Name = "buttonCancelJoin" };
            var leaveBtn       = new MyGuiControlButton(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left, top + buttonSize.Y + spacingV)) { Name = "buttonLeave" };
            var sendPeaceBtn   = new MyGuiControlButton(originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, position: new Vector2(-0.065f, top)) { Name = "buttonSendPeace" };
            var cancelPeaceBtn = new MyGuiControlButton(originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, position: new Vector2(-0.065f, top)) { Name = "buttonCancelPeace" };
            var acceptPeaceBtn = new MyGuiControlButton(originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, position: new Vector2(-0.065f, top)) { Name = "buttonAcceptPeace" };
            var enemyBtn       = new MyGuiControlButton(originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, position: new Vector2(-0.065f, top + buttonSize.Y + spacingV)) { Name = "buttonEnemy" };

            page.Controls.Add(factionsComposite);
            page.Controls.Add(factionsPanel);
            page.Controls.Add(factionsLabel);
            page.Controls.Add(factionsTable);
            page.Controls.Add(createBtn);
            page.Controls.Add(joinBtn);
            page.Controls.Add(joinCancelBtn);
            page.Controls.Add(leaveBtn);
            page.Controls.Add(sendPeaceBtn);
            page.Controls.Add(cancelPeaceBtn);
            page.Controls.Add(acceptPeaceBtn);
            page.Controls.Add(enemyBtn);

            // Do the right side
            // reset left / top
            left = -0.0475f;
            top = -0.34f;

            var factionComposite = new MyGuiControlCompositePanel()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Position = new Vector2(-0.05f, top),
                Size = new Vector2(0.5f, 0.69f),
                Name = "compositeFaction"
            };
            left += spacingH;
            top += spacingV;

            var factionNamePanel = new MyGuiControlPanel()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Position = new Vector2(left, top),
                Size = new Vector2(factionComposite.Size.X - 0.012f, 0.035f),
                BackgroundTexture = MyGuiConstants.TEXTURE_HIGHLIGHT_DARK,
                Name = "panelFactionName"
            };

            var factionName = new MyGuiControlLabel(
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                position: new Vector2(left + spacingH, top),
                size: factionNamePanel.Size - new Vector2(0.01f, 0.01f)
            ) { Name = "labelFactionName" };
            top += factionsLabel.Size.Y + (2f * spacingV);
            var size = factionNamePanel.Size - new Vector2(0.14f, 0.01f);

            var factionDescLabel = new MyGuiControlLabel(
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                position: new Vector2(left, top),
                size: factionNamePanel.Size - new Vector2(0.01f, 0.01f)
            ) { Name = "labelFactionDesc" };
            top += factionDescLabel.Size.Y + spacingV;

            var factionDesc = new MyGuiControlMultilineText(
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                textScale: MyGuiConstants.TOOL_TIP_TEXT_SCALE,
                position: new Vector2(left, top),
                size: new Vector2(size.X, 0.08f)
            )
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Name = "textFactionDesc",
            };
            top += factionDesc.Size.Y + 2f * spacingV;

            var factionPrivateLabel = new MyGuiControlLabel(
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                position: new Vector2(left, top),
                size: factionNamePanel.Size - new Vector2(0.01f, 0.01f)
            ) { Name = "labelFactionPrivate" };
            top += factionPrivateLabel.Size.Y + spacingV;

            var factionPrivate = new MyGuiControlMultilineText(
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                textScale: MyGuiConstants.TOOL_TIP_TEXT_SCALE,
                position: new Vector2(left, top),
                size: new Vector2(size.X, 0.08f)
            )
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Name = "textFactionPrivate",
            };
            top += factionDesc.Size.Y + 0.0275f;

            var labelFactionMembers = new MyGuiControlLabel(
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                position: new Vector2(left, top),
                size: factionNamePanel.Size - new Vector2(0.01f, 0.01f)
            ) { Name = "labelFactionMembers" };


            var checkAcceptEveryone = new MyGuiControlCheckbox(
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER,
                position: new Vector2(factionNamePanel.Position.X + factionNamePanel.Size.X, top + spacingV)
            ) { Name = "checkFactionMembersAcceptEveryone" };

            var labelAcceptEveryone = new MyGuiControlLabel(
             originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP,
             position: new Vector2(checkAcceptEveryone.Position.X - checkAcceptEveryone.Size.X - spacingH, top),
             size: labelFactionMembers.Size - new Vector2(0.01f, 0.01f)
         ) { Name = "labelFactionMembersAcceptEveryone" };


            var labelAcceptPeace = new MyGuiControlLabel(
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                position: new Vector2((17 * spacingH), top),
                size: labelFactionMembers.Size - new Vector2(0.01f, 0.01f)
            ) { Name = "labelFactionMembersAcceptPeace" };

            var checkAcceptPeace = new MyGuiControlCheckbox(
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                position: new Vector2((47 * spacingH), top + spacingV)
            ) { Name = "checkFactionMembersAcceptPeace" };



            top += factionPrivateLabel.Size.Y + spacingV;

            var membersTable = new MyGuiControlTable()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Position = new Vector2(left, top),
                Size = new Vector2(size.X, 0.15f),
                Name = "tableMembers",
                ColumnsCount = 2,
                VisibleRowsCount = 8,
                HeaderVisible = false
            };
            membersTable.SetCustomColumnWidths(new float[] { 0.7f, 0.3f });
            membersTable.SetColumnName(0, MyTexts.Get(MyCommonTexts.Name));
            membersTable.SetColumnName(1, MyTexts.Get(MyCommonTexts.Status));

            var btnSpacing = smallerBtn.Y + spacingV;
            var editBtn = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Rectangular, size: smallerBtn, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left + membersTable.Size.X + spacingV, factionDesc.Position.Y)) { Name = "buttonEdit" };
            var promBtn = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Rectangular, size: smallerBtn, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left + membersTable.Size.X + spacingV, membersTable.Position.Y)) { Name = "buttonPromote" };
            var kickBtn = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Rectangular, size: smallerBtn, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left + membersTable.Size.X + spacingV, membersTable.Position.Y + btnSpacing)) { Name = "buttonKick" };
            var acceptJoin = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Rectangular, size: smallerBtn, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left + membersTable.Size.X + spacingV, membersTable.Position.Y + 2f * btnSpacing)) { Name = "buttonAcceptJoin" };
            var demote = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Rectangular, size: smallerBtn, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left + membersTable.Size.X + spacingV, membersTable.Position.Y + 3f * btnSpacing)) { Name = "buttonDemote" };
            //var acceptPeace = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Rectangular, size: smallerBtn, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,    position: new Vector2(left + membersTable.Size.X + spacingV, membersTable.Position.Y + 2f * btnSpacing)) { Name = "buttonAcceptPeace" };
            var addNpcToFaction = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Rectangular, size: smallerBtn, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left + membersTable.Size.X + spacingV, membersTable.Position.Y + 4f * btnSpacing)) { Name = "buttonAddNpc" };

            page.Controls.Add(factionComposite);
            page.Controls.Add(factionNamePanel);
            page.Controls.Add(factionName);
            page.Controls.Add(factionDescLabel);
            page.Controls.Add(factionDesc);
            page.Controls.Add(factionPrivateLabel);
            page.Controls.Add(factionPrivate);
            page.Controls.Add(labelFactionMembers);
            page.Controls.Add(labelAcceptEveryone);
            page.Controls.Add(labelAcceptPeace);
            page.Controls.Add(checkAcceptEveryone);
            page.Controls.Add(checkAcceptPeace);
            page.Controls.Add(membersTable);

            page.Controls.Add(editBtn);
            page.Controls.Add(promBtn);
            page.Controls.Add(kickBtn);
            page.Controls.Add(demote);
            page.Controls.Add(acceptJoin);
            page.Controls.Add(addNpcToFaction);
        }
Ejemplo n.º 17
0
        private void CreateProductionPageControls(MyGuiControlTabPage productionPage)
        {
            productionPage.Name = "PageProduction";
            productionPage.TextEnum = MySpaceTexts.TerminalTab_Production;

            float columnSpacing = 0.03f;
            float controlSpacing = 0.01f;
            float smallBackgroundPanelHeight = 0.05f;
            float largeBackgroundPanelHeight = 0.08f;

            var assemblersCombobox = new MyGuiControlCombobox(
                position: -0.5f * productionPage.Size + new Vector2(0f, controlSpacing))
                {
                    OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                    Name = "AssemblersCombobox"
                };

            var blueprintsBackgroundPanel = new MyGuiControlPanel(
                position: assemblersCombobox.Position + new Vector2(0f, assemblersCombobox.Size.Y + controlSpacing),
                size: new Vector2(1f, largeBackgroundPanelHeight),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP)
                {
                    BackgroundTexture = MyGuiConstants.TEXTURE_RECTANGLE_DARK,
                    Name = "BlueprintsBackgroundPanel",
                };

            var blueprintsLabel = new MyGuiControlLabel(
                position: blueprintsBackgroundPanel.Position + new Vector2(controlSpacing, controlSpacing),
                text: MyTexts.GetString(MySpaceTexts.ScreenTerminalProduction_Blueprints),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP)
                {
                    Name = "BlueprintsLabel"
                };
            var blueprintsGrid = new MyGuiControlGrid()
            {
                VisualStyle = MyGuiControlGridStyleEnum.Toolbar,
                RowsCount = MyTerminalProductionController.BLUEPRINT_GRID_ROWS,
                ColumnsCount = 4,
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP
            };

            var blueprintsScrollableArea = new MyGuiControlScrollablePanel(
                scrolledControl: blueprintsGrid)
                {
                    Name = "BlueprintsScrollableArea",
                    ScrollbarVEnabled = true,
                    Position = blueprintsBackgroundPanel.Position + new Vector2(0f, blueprintsBackgroundPanel.Size.Y),
                    OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                    BackgroundTexture = MyGuiConstants.TEXTURE_SCROLLABLE_LIST,
                    Size = new Vector2(blueprintsBackgroundPanel.Size.X, 0.5f),
                    ScrolledAreaPadding = new MyGuiBorderThickness(0.005f),
                };
            blueprintsScrollableArea.FitSizeToScrolledControl();
            assemblersCombobox.Size = new Vector2(blueprintsScrollableArea.Size.X, assemblersCombobox.Size.Y);
            blueprintsBackgroundPanel.Size = new Vector2(blueprintsScrollableArea.Size.X, largeBackgroundPanelHeight);
            blueprintsGrid.RowsCount = 20;

            productionPage.Controls.Add(assemblersCombobox);
            productionPage.Controls.Add(blueprintsBackgroundPanel);
            productionPage.Controls.Add(blueprintsLabel);
            productionPage.Controls.Add(blueprintsScrollableArea);

            var materialsBackgroundPanel = new MyGuiControlPanel(
                position: blueprintsBackgroundPanel.Position + new Vector2(blueprintsBackgroundPanel.Size.X + columnSpacing, 0f),
                size: new Vector2(blueprintsBackgroundPanel.Size.X, smallBackgroundPanelHeight),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP)
                {
                    BackgroundTexture = MyGuiConstants.TEXTURE_RECTANGLE_DARK
                };

            var materialsLabel = new MyGuiControlLabel(
                position: materialsBackgroundPanel.Position + new Vector2(controlSpacing, controlSpacing),
                text: MyTexts.GetString(MySpaceTexts.ScreenTerminalProduction_StoredMaterials),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP
            );

            var materialsList = new MyGuiControlComponentList()
            {
                Position = materialsBackgroundPanel.Position + new Vector2(0f, materialsBackgroundPanel.Size.Y),
                Size = new Vector2(materialsBackgroundPanel.Size.X, blueprintsBackgroundPanel.Size.Y + blueprintsScrollableArea.Size.Y - materialsBackgroundPanel.Size.Y),
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                BackgroundTexture = MyGuiConstants.TEXTURE_RECTANGLE_NEUTRAL,
                Name = "MaterialsList",
            };

            productionPage.Controls.Add(materialsBackgroundPanel);
            productionPage.Controls.Add(materialsLabel);
            productionPage.Controls.Add(materialsList);

            var assemblingButton = new MyGuiControlRadioButton(
                position: materialsBackgroundPanel.Position + new Vector2(materialsBackgroundPanel.Size.X + columnSpacing, 0f),
                size: new Vector2(200f, 48f) / MyGuiConstants.GUI_OPTIMAL_SIZE)
                {
                    OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                    Icon = MyGuiConstants.TEXTURE_BUTTON_ICON_COMPONENT,
                    IconOriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                    TextAlignment = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER,
                    Text = MyTexts.Get(MySpaceTexts.ScreenTerminalProduction_AssemblingButton),
                    Name = "AssemblingButton",
                };
            assemblingButton.SetToolTip(MySpaceTexts.ToolTipTerminalProduction_AssemblingMode);

            var disassemblingButton = new MyGuiControlRadioButton(
                position: assemblingButton.Position + new Vector2(assemblingButton.Size.X + controlSpacing, 0f),
                size: new Vector2(238f, 48f) / MyGuiConstants.GUI_OPTIMAL_SIZE)
                {
                    OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                    Icon = MyGuiConstants.TEXTURE_BUTTON_ICON_DISASSEMBLY,
                    IconOriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                    TextAlignment = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER,
                    Text = MyTexts.Get(MySpaceTexts.ScreenTerminalProduction_DisassemblingButton),
                    Name = "DisassemblingButton",
                };
            disassemblingButton.SetToolTip(MySpaceTexts.ToolTipTerminalProduction_DisassemblingMode);

            var queueBackgroundPanel = new MyGuiControlCompositePanel()
            {
                Position = assemblingButton.Position + new Vector2(0f, assemblingButton.Size.Y + controlSpacing),
                Size = new Vector2(0.4f, largeBackgroundPanelHeight),
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                BackgroundTexture = MyGuiConstants.TEXTURE_RECTANGLE_DARK,
            };
            var queueLabel = new MyGuiControlLabel(
                position: queueBackgroundPanel.Position + new Vector2(controlSpacing, controlSpacing),
                text: MyTexts.GetString(MySpaceTexts.ScreenTerminalProduction_ProductionQueue),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP
            );
            var queueGrid = new MyGuiControlGrid()
            {
                VisualStyle = MyGuiControlGridStyleEnum.Toolbar,
                RowsCount = 2,
                ColumnsCount = 6,
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP
            };
            var queueScrollableArea = new MyGuiControlScrollablePanel(
                scrolledControl: queueGrid)
                {
                    Name = "QueueScrollableArea",
                    ScrollbarVEnabled = true,
                    Position = queueBackgroundPanel.Position + new Vector2(0f, queueBackgroundPanel.Size.Y),
                    OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                    BackgroundTexture = MyGuiConstants.TEXTURE_SCROLLABLE_LIST,
                    ScrolledAreaPadding = new MyGuiBorderThickness(0.005f),
                };
            queueScrollableArea.FitSizeToScrolledControl();
            queueGrid.RowsCount = 10;
            queueBackgroundPanel.Size = new Vector2(queueScrollableArea.Size.X, queueBackgroundPanel.Size.Y);

            var repeatCheckbox = new MyGuiControlCheckbox(
                position: queueBackgroundPanel.Position + new Vector2(queueBackgroundPanel.Size.X - controlSpacing, controlSpacing),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP,
                toolTip: MyTexts.GetString(MySpaceTexts.ToolTipTerminalProduction_RepeatMode),
                visualStyle: MyGuiControlCheckboxStyleEnum.Repeat)
                {
                    Name = "RepeatCheckbox",
                };

            var slaveCheckbox = new MyGuiControlCheckbox(
                position: queueBackgroundPanel.Position + new Vector2(queueBackgroundPanel.Size.X - 0.1f - controlSpacing, controlSpacing),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP,
                toolTip: MyTexts.GetString(MySpaceTexts.ToolTipTerminalProduction_SlaveMode),
                visualStyle: MyGuiControlCheckboxStyleEnum.Slave)
            {
                Name = "SlaveCheckbox",
            };

            var inventoryBackgroundPanel = new MyGuiControlCompositePanel()
            {
                Position = queueScrollableArea.Position + new Vector2(0f, queueScrollableArea.Size.Y + controlSpacing),
                Size = new Vector2(0.4f, largeBackgroundPanelHeight),
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                BackgroundTexture = MyGuiConstants.TEXTURE_RECTANGLE_DARK,
            };
            var inventoryLabel = new MyGuiControlLabel(
                position: inventoryBackgroundPanel.Position + new Vector2(controlSpacing, controlSpacing),
                text: MyTexts.GetString(MySpaceTexts.ScreenTerminalProduction_Inventory),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP
            );
            var inventoryGrid = new MyGuiControlGrid()
            {
                VisualStyle = MyGuiControlGridStyleEnum.Toolbar,
                RowsCount = 3,
                ColumnsCount = 6,
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP
            };
            var inventoryScrollableArea = new MyGuiControlScrollablePanel(
                scrolledControl: inventoryGrid)
                {
                    Name = "InventoryScrollableArea",
                    ScrollbarVEnabled = true,
                    Position = inventoryBackgroundPanel.Position + new Vector2(0f, inventoryBackgroundPanel.Size.Y),
                    OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                    BackgroundTexture = MyGuiConstants.TEXTURE_SCROLLABLE_LIST,
                    ScrolledAreaPadding = new MyGuiBorderThickness(0.005f),
                };
            inventoryScrollableArea.FitSizeToScrolledControl();
            inventoryGrid.RowsCount = 10;
            inventoryBackgroundPanel.Size = new Vector2(inventoryScrollableArea.Size.X, inventoryBackgroundPanel.Size.Y);
            var disassembleAllButton = new MyGuiControlButton(
                position: inventoryBackgroundPanel.Position + new Vector2(inventoryBackgroundPanel.Size.X - controlSpacing, controlSpacing),
                size: new Vector2(220f, 40f) / MyGuiConstants.GUI_OPTIMAL_SIZE,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP,
                text: MyTexts.Get(MySpaceTexts.ScreenTerminalProduction_DisassembleAllButton),
                visualStyle: MyGuiControlButtonStyleEnum.Rectangular,
                toolTip: MyTexts.GetString(MySpaceTexts.ToolTipTerminalProduction_DisassembleAll))
                {
                    Name = "DisassembleAllButton",
                };

            var inventoryButton = new MyGuiControlButton(
                position: inventoryScrollableArea.Position + new Vector2(0f, inventoryScrollableArea.Size.Y + controlSpacing),
                visualStyle: MyGuiControlButtonStyleEnum.Rectangular,
                size: new Vector2(214f, 48f) / MyGuiConstants.GUI_OPTIMAL_SIZE,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                text: MyTexts.Get(MySpaceTexts.ScreenTerminalProduction_InventoryButton))
                {
                    Name = "InventoryButton",
                };

            var controlPanelButton = new MyGuiControlButton(
                position: inventoryButton.Position + new Vector2(inventoryButton.Size.X + controlSpacing, 0f),
                visualStyle: MyGuiControlButtonStyleEnum.Rectangular,
                size: inventoryButton.Size,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                text: MyTexts.Get(MySpaceTexts.ScreenTerminalProduction_ControlPanelButton))
                {
                    Name = "ControlPanelButton",
                };

            productionPage.Controls.Add(assemblingButton);
            productionPage.Controls.Add(disassemblingButton);
            productionPage.Controls.Add(queueBackgroundPanel);
            productionPage.Controls.Add(queueLabel);
            productionPage.Controls.Add(repeatCheckbox);
            productionPage.Controls.Add(slaveCheckbox);
            productionPage.Controls.Add(queueScrollableArea);
            productionPage.Controls.Add(inventoryBackgroundPanel);
            productionPage.Controls.Add(inventoryLabel);
            productionPage.Controls.Add(disassembleAllButton);
            productionPage.Controls.Add(inventoryScrollableArea);
            productionPage.Controls.Add(inventoryButton);
            productionPage.Controls.Add(controlPanelButton);
        }
Ejemplo n.º 18
0
        private void RecreateControls(bool contructor)
        {
            m_toolbarItemsGrid = new MyGuiControlGrid()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM,
                VisualStyle = MyGuiControlGridStyleEnum.Toolbar,
                ColumnsCount = MyToolbarComponent.CurrentToolbar.SlotCount + 1,
                RowsCount = 1
            };
            m_toolbarItemsGrid.ItemDoubleClicked += grid_ItemDoubleClicked;
            m_toolbarItemsGrid.ItemClickedWithoutDoubleClick += grid_ItemClicked;

            m_selectedItemLabel = new MyGuiControlLabel();
            m_colorVariantPanel = new MyGuiControlPanel(size: new Vector2(0.1f, 0.025f));
            m_colorVariantPanel.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;

            m_contextMenu = new MyGuiControlContextMenu();
            m_contextMenu.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
            m_contextMenu.Deactivate();
            m_contextMenu.ItemClicked += contextMenu_ItemClicked;

            Elements.Add(m_colorVariantPanel);
            Elements.Add(m_selectedItemLabel);
            Elements.Add(m_toolbarItemsGrid);
            Elements.Add(m_contextMenu);

            m_colorVariantPanel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
            m_selectedItemLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
            m_toolbarItemsGrid.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM;
            m_contextMenu.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;

            RefreshInternals();
        }
Ejemplo n.º 19
0
        public MyGuiControlBlockInfo(MyControlBlockInfoStyle style, bool progressMode = true, bool largeBlockInfo = true)
            : base(backgroundTexture: new MyGuiCompositeTexture(MyGuiConstants.TEXTURE_HUD_BG_LARGE_DEFAULT.Texture))
        {
            m_style        = style;
            m_progressMode = progressMode;

            m_leftColumnBackground             = new MyGuiControlPanel(backgroundColor: Color.Red.ToVector4());
            m_leftColumnBackground.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            Elements.Add(m_leftColumnBackground);

            m_titleBackground             = new MyGuiControlPanel(backgroundColor: Color.Red.ToVector4());
            m_titleBackground.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            Elements.Add(m_titleBackground);

            if (m_progressMode)
            {
                m_integrityBackground             = new MyGuiControlPanel(backgroundColor: Color.Red.ToVector4());
                m_integrityBackground.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
                Elements.Add(m_integrityBackground);

                m_integrityForeground             = new MyGuiControlPanel(backgroundColor: Color.Red.ToVector4());
                m_integrityForeground.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
                Elements.Add(m_integrityForeground);

                m_integrityCriticalLine             = new MyGuiControlPanel(backgroundColor: Color.Red.ToVector4());
                m_integrityCriticalLine.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
                Elements.Add(m_integrityCriticalLine);
            }

            m_blockIconPanelBackground                   = new MyGuiControlPanel();
            m_blockIconPanelBackground.OriginAlign       = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            m_blockIconPanelBackground.BackgroundTexture = new MyGuiCompositeTexture(MyGuiConstants.TEXTURE_HUD_BG_MEDIUM_DEFAULT.Texture);
            m_blockIconPanelBackground.Size              = m_progressMode ? new Vector2(0.088f) : new Vector2(0.04f);
            m_blockIconPanelBackground.Size             *= new Vector2(0.75f, 1);
            Elements.Add(m_blockIconPanelBackground);

            m_blockIconPanel             = new MyGuiControlPanel();
            m_blockIconPanel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            m_blockIconPanel.Size        = m_progressMode ? new Vector2(0.088f) : new Vector2(0.04f);
            m_blockIconPanel.Size       *= new Vector2(0.75f, 1);
            Elements.Add(m_blockIconPanel);

            m_blockTypePanelBackground                   = new MyGuiControlPanel();
            m_blockTypePanelBackground.OriginAlign       = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
            m_blockTypePanelBackground.BackgroundTexture = new MyGuiCompositeTexture(MyGuiConstants.TEXTURE_HUD_BG_MEDIUM_DEFAULT.Texture);
            m_blockTypePanelBackground.Size              = m_progressMode ? new Vector2(0.088f) : new Vector2(0.04f);
            m_blockTypePanelBackground.Size             *= new Vector2(0.75f, 1);
            Elements.Add(m_blockTypePanelBackground);

            m_blockTypePanel                   = new MyGuiControlPanel();
            m_blockTypePanel.OriginAlign       = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
            m_blockTypePanel.Size              = m_progressMode ? new Vector2(0.088f) : new Vector2(0.04f);
            m_blockTypePanel.Size             *= new Vector2(0.75f, 1);
            m_blockTypePanel.BackgroundTexture = new MyGuiCompositeTexture(largeBlockInfo ? @"Textures\GUI\Icons\Cubes\LargeBlock.dds" : @"Textures\GUI\Icons\Cubes\SmallBlock.dds");
            Elements.Add(m_blockTypePanel);

            m_blockNameLabel              = new MyGuiControlLabel(text: String.Empty);
            m_blockNameLabel.OriginAlign  = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            m_blockNameLabel.TextScale    = 1 * baseScale;
            m_blockNameLabel.Font         = m_style.BlockNameLabelFont;
            m_blockNameLabel.AutoEllipsis = true;
            Elements.Add(m_blockNameLabel);

            String blockTypeLabelText = String.Empty;

            if (style.EnableBlockTypeLabel)
            {
                blockTypeLabelText = MyTexts.GetString(largeBlockInfo ? MySpaceTexts.HudBlockInfo_LargeShip_Station : MySpaceTexts.HudBlockInfo_SmallShip);
            }
            m_blockTypeLabel             = new MyGuiControlLabel(text: blockTypeLabelText);
            m_blockTypeLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            m_blockTypeLabel.TextScale   = 1 * baseScale;
            m_blockTypeLabel.Font        = MyFontEnum.White;
            Elements.Add(m_blockTypeLabel);

            m_componentsLabel             = new MyGuiControlLabel(text: MyTexts.GetString(m_style.ComponentsLabelText));
            m_componentsLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            m_componentsLabel.TextScale   = m_smallerFontSize * baseScale;
            m_componentsLabel.Font        = m_style.ComponentsLabelFont;
            Elements.Add(m_componentsLabel);

            m_installedRequiredLabel             = new MyGuiControlLabel(text: MyTexts.GetString(m_style.InstalledRequiredLabelText));
            m_installedRequiredLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
            m_installedRequiredLabel.TextScale   = m_smallerFontSize * baseScale;
            m_installedRequiredLabel.Font        = m_style.InstalledRequiredLabelFont;
            Elements.Add(m_installedRequiredLabel);

            if (m_progressMode)
            {
                m_integrityLabel             = new MyGuiControlLabel(text: String.Empty);
                m_integrityLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM;
                m_integrityLabel.Font        = m_style.IntegrityLabelFont;
                m_integrityLabel.TextScale   = 0.75f * baseScale;
                Elements.Add(m_integrityLabel);
            }

            m_separator = new MyGuiControlSeparatorList();
            Elements.Add(m_separator);

            EnsureLineControls(m_componentLines.Capacity);
            Size = m_progressMode ? new Vector2(0.325f, 0.4f) : new Vector2(0.22f, 0.4f);
        }
Ejemplo n.º 20
0
			public void RecreateControls()
			{
				Elements.Clear();

				var guiTextScale = (float)Math.Pow(1.2f, m_stat.StatDefinition.GuiDef.HeightMultiplier - 1.0f);
				var guiArrowScale = (float)Math.Pow(1.3f, m_stat.StatDefinition.GuiDef.HeightMultiplier - 1.0f) / m_stat.StatDefinition.GuiDef.HeightMultiplier;
				var textScale = MyGuiConstants.HUD_TEXT_SCALE*0.6f*guiTextScale;
				var barLength = 0.0875f;
				var arrowIconSize = new Vector2(Size.Y * 1.5f, Size.Y) * 0.5f * guiArrowScale;
				var leftTextWidth = 0.16f;
				var textHeightOffset = -0.1f;

				var leftTextOffset = -1.0f / 2.0f + leftTextWidth;
				var barOffset = leftTextOffset + 0.025f;
				var arrowIconOffset = barOffset + barLength/Size.X + 0.05f;
				var rightTextOffset = arrowIconOffset + arrowIconSize.X + 0.035f;

				m_statNameLabel = new MyGuiControlLabel(position: Size * new Vector2(leftTextOffset, textHeightOffset),
														text: m_stat.StatId.ToString(),
														textScale: textScale,
														size: new Vector2(leftTextWidth*Size.X, 1.0f),
														originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER);
				Elements.Add(m_statNameLabel);

				var vecColor = m_stat.StatDefinition.GuiDef.Color;
				var barColor = new Color(vecColor.X, vecColor.Y, vecColor.Z);

				m_progressBar = new MyGuiControlProgressBar(position: Size * new Vector2(barOffset, 0.0f),
															originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
															size: new Vector2(barLength, Size.Y),
															backgroundTexture: new MyGuiCompositeTexture(MyGuiConstants.TEXTURE_HUD_STAT_BAR_BG.Texture),
															progressBarColor: barColor);
				if (m_stat != null)
					m_progressBar.Value = m_stat.CurrentRatio;
				Elements.Add(m_progressBar);

				m_effectArrow = new MyGuiControlPanel(	position: Size * new Vector2(arrowIconOffset, 0.0f),
														originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
														size: arrowIconSize,
														texture: MyGuiConstants.TEXTURE_HUD_STAT_EFFECT_ARROW_UP.Texture);
				Elements.Add(m_effectArrow);

				StringBuilder statText = new StringBuilder();
				statText.AppendDecimal((int)m_stat.Value, 0);
				statText.Append("/");
				statText.AppendDecimal(m_stat.MaxValue, 0);
				m_statValueLabel = new MyGuiControlLabel(position: Size * new Vector2(rightTextOffset, textHeightOffset),
														text: statText.ToString(),
														textScale: textScale,
														originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
				Elements.Add(m_statValueLabel);
			}
Ejemplo n.º 21
0
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            AddCaption("Color picker");

            

            m_hueSlider = new MyGuiControlSlider(
                position: new Vector2(x / 1600f, (y + 50) / 1200f),
                width: 0.25f,
                minValue: 0,
                maxValue: 360,
                labelText: String.Empty,
                labelDecimalPlaces: 0,
                labelSpaceWidth: 50 / 1200f,
                intValue: true,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                visualStyle: MyGuiControlSliderStyleEnum.Hue
                );
            m_saturationSlider  = new MyGuiControlSlider(
                position: new Vector2(x / 1600f, (y + 150) / 1200f),
                width: 0.25f,
                minValue: -100,
                maxValue: 100,
                defaultValue: 0,
                labelText: String.Empty,
                labelDecimalPlaces: 0,
                labelSpaceWidth: 50/1200f,
                intValue: true,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER
                );
            m_valueSlider = new MyGuiControlSlider(
                position: new Vector2(x / 1600f, (y + 250) / 1200f),
                width: 0.25f,
                minValue: -100,
                maxValue: 100,
                defaultValue: 0,
                labelText: String.Empty,
                labelDecimalPlaces: 0,
                labelSpaceWidth: 50 / 1200f,
                intValue: true,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER
                );

            m_hueSlider.ValueChanged += OnValueChange;
            m_saturationSlider.ValueChanged += OnValueChange;
            m_valueSlider.ValueChanged += OnValueChange;

            m_hueLabel = new MyGuiControlLabel(position: new Vector2(100 / 1600f, y / 1200f), text: String.Empty, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            m_saturationLabel = new MyGuiControlLabel(position: new Vector2(100 / 1600f, (y + 100) / 1200f), text: String.Empty, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            m_valueLabel = new MyGuiControlLabel(position: new Vector2(100 / 1600f, (y + 200) / 1200f), text: String.Empty, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);



            Controls.Add(new MyGuiControlLabel(position: new Vector2(x / 1600f, y / 1200f), text: "Hue:", originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));
            Controls.Add(m_hueLabel);
            Controls.Add(m_hueSlider);
            Controls.Add(new MyGuiControlLabel(position: new Vector2(x / 1600f, (y + 100) / 1200f), text: "Saturation:", originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));
            Controls.Add(m_saturationLabel);
            Controls.Add(m_saturationSlider);
            Controls.Add(new MyGuiControlLabel(position: new Vector2(x / 1600f, (y + 200) / 1200f), text: "Value:", originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));
            Controls.Add(m_valueLabel);
            Controls.Add(m_valueSlider);
            Controls.Add(new MyGuiControlButton(
                size: new Vector2(100f, 0.1f),
				position: new Vector2(0 / 1600f, (y + 285 + (MyPlayer.BuildColorSlotCount / 7 + 1) * 36) / 1200f),
                text: new StringBuilder("Defaults"),
                onButtonClick: OnDefaultsClick));
            Controls.Add(new MyGuiControlButton(
                size: new Vector2 (100f,0.1f),
				position: new Vector2(0 / 1600f, (y + 360 + (MyPlayer.BuildColorSlotCount / 7 + 1) * 36) / 1200f),
                text: new StringBuilder("OK"),
                onButtonClick: OnOkClick));
            Controls.Add(new MyGuiControlButton(
				position: new Vector2(0 / 1600f, (y + 435 + (MyPlayer.BuildColorSlotCount / 7 + 1) * 36) / 1200f),
                text: new StringBuilder("Cancel"),
                onButtonClick: OnCancelClick));
            
            Color c = Color.White;
            int j = 0;
            m_highlightControlPanel = new MyGuiControlPanel(
                size: new Vector2(0.03f, 0.03f),
				position: new Vector2(((x + defColCol) / 1600f) + (MyPlayer.SelectedColorSlot % 7) * 0.03f, (y + defColLine) / 1200f + (MyPlayer.SelectedColorSlot / 7) * 0.03f));
            m_highlightControlPanel.ColorMask = c.ToVector4();
            m_highlightControlPanel.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;
            Controls.Add(m_highlightControlPanel);
            int tmpx = MyPlayer.BuildColorSlotCount;
			for (int i = 0; i < MyPlayer.BuildColorSlotCount; )
            {
                MyGuiControlPanel tmpPanel = new MyGuiControlPanel(
                size: new Vector2(0.025f, 0.025f),
                position: new Vector2(((x + defColCol) / 1600f) + (i % 7) * 0.03f, (y + defColLine) / 1200f + j * 0.03f));
                tmpPanel.ColorMask = (prev(MyPlayer.ColorSlots.ItemAt(i))).HSVtoColor().ToVector4();
                tmpPanel.BackgroundTexture = MyGuiConstants.TEXTURE_GUI_BLANK;
                m_colorPaletteControlsList.Add(tmpPanel);
                Controls.Add(tmpPanel);
                i++;
                if (i % 7 == 0)
                    j++;
            }
        }
Ejemplo n.º 22
0
        private void CreateControlPanelPageControls(MyGuiControlTabPage page)
        {
            page.Name      = "PageControlPanel";
            page.TextEnum  = MySpaceTexts.ControlPanel;
            page.TextScale = 0.9f;

            var functionalBlockSearch = new MyGuiControlTextbox()
            {
                Position = new Vector2(-0.4625f, -0.325f),
                Size = new Vector2(0.255f, 0.052f),
                Name = "FunctionalBlockSearch",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER
            };

            var functionalBlockSearchClear = new MyGuiControlButton()
            {
                Position = new Vector2(-0.232f, -0.325f),
                Size = new Vector2(0.045f, 0.05666667f),
                Name = "FunctionalBlockSearchClear",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                VisualStyle = MyGuiControlButtonStyleEnum.Close,
                ActivateOnMouseRelease = true
            };

            var functionalBlockListbox = new MyGuiControlListbox()
            {
                Position = new Vector2(-0.4625f, 0.0225f),
                Size = new Vector2(0.29f, 0.5f),
                Name = "FunctionalBlockListbox",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                VisibleRowsCount = 16
            };

            var control = new MyGuiControlCompositePanel()
            {
                Position = new Vector2(-0.1525f, 0f),
                Size = new Vector2(0.615f, 0.7125f),
                Name = "Control",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                InnerHeight = 0.685f
            };

            var selectedBlockNamePanel = new MyGuiControlPanel()
            {
                Position = new Vector2(-0.1425f, -0.32f),
                Size = new Vector2(0.595f, 0.035f),
                Name = "SelectedBlockNamePanel",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                BackgroundTexture = MyGuiConstants.TEXTURE_HIGHLIGHT_DARK
            };

            var blockNameLabel = new MyGuiControlLabel()
            {
                Position = new Vector2(-0.1325f, -0.322f),
                Size = new Vector2(0.0470270254f, 0.0266666654f),
                Name = "BlockNameLabel",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                TextEnum = MySpaceTexts.Afterburner
            };

            var groupTitleLabel = new MyGuiControlLabel()
            {
                Position = new Vector2(0.17f, -0.27f),
                Size = new Vector2(0.0470270254f, 0.0266666654f),
                Name = "GroupTitleLabel",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                TextEnum = MySpaceTexts.Terminal_GroupTitle
            };

            var groupName = new MyGuiControlTextbox()
            {
                Position = new Vector2(0.165f, -0.23f),
                Size = new Vector2(0.29f, 0.052f),
                Name = "GroupName",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER
            };

            var groupSave = new MyGuiControlButton()
            {
                Position = new Vector2(0.2f, -0.17f),
                Name = "GroupSave",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                TextEnum = MySpaceTexts.TerminalButton_GroupSave
            };

            var groupDelete = new MyGuiControlButton()
            {
                Position = new Vector2(0.4f, -0.17f),
                Size = new Vector2(0.045f, 0.05666667f),
                Name = "GroupDelete",
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER,
                VisualStyle = MyGuiControlButtonStyleEnum.Close
            };


            var showAll = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.SquareSmall,
                position: new Vector2(-0.205f, -0.345f),
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                buttonScale:0.5f)
                {
                    Name = "ShowAll",
                };

                 
            page.Controls.Add(functionalBlockSearch);
            page.Controls.Add(functionalBlockSearchClear);
            page.Controls.Add(functionalBlockListbox);
            page.Controls.Add(control);
            page.Controls.Add(selectedBlockNamePanel);
            page.Controls.Add(blockNameLabel);
            page.Controls.Add(groupTitleLabel);
            page.Controls.Add(groupName);
            page.Controls.Add(groupSave);
            page.Controls.Add(showAll);
            page.Controls.Add(groupDelete);
        }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            var left       = -0.23f;
            var top        = -0.23f;
            var spacingV   =  0.045f;
            var buttonSize = new Vector2(0.29f, 0.052f);

            var composite = new MyGuiControlCompositePanel()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Position = new Vector2(left, top),
                Size = new Vector2(0.46f, 0.46f)
            };
            left += 0.005f;
            top  += 0.007f;

            var panel = new MyGuiControlPanel()
            {
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Position = new Vector2(left, top),
                Size = new Vector2(0.451f, 0.038f),
                BackgroundTexture = MyGuiConstants.TEXTURE_HIGHLIGHT_DARK
            };
            left += 0.005f;
            top  += 0.003f;

            // LABELS
            var headerText = MyTexts.GetString((m_editFaction == null) ? MySpaceTexts.TerminalTab_Factions_CreateFaction : MySpaceTexts.TerminalTab_Factions_EditFaction);
            var headerLabel = new MyGuiControlLabel(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, size: buttonSize, position: new Vector2(left, top), text: headerText);
            top += 0.01f;
            var shortcutLabel = new MyGuiControlLabel(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, size: buttonSize, position: new Vector2(left, top + spacingV), text: MyTexts.GetString(MySpaceTexts.TerminalTab_Factions_CreateFactionTag));
            var nameLabel = new MyGuiControlLabel(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, size: buttonSize, position: new Vector2(left, top + 2f * spacingV), text: MyTexts.GetString(MySpaceTexts.TerminalTab_Factions_CreateFactionName));
            var descLabel = new MyGuiControlLabel(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, size: buttonSize, position: new Vector2(left, top + 3f * spacingV), text: MyTexts.GetString(MySpaceTexts.TerminalTab_Factions_CreateFactionDescription));
            var secretLabel = new MyGuiControlLabel(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, size: buttonSize, position: new Vector2(left, top + 4f * spacingV), text: MyTexts.GetString(MySpaceTexts.TerminalTab_Factions_CreateFactionPrivateInfo));

            shortcutLabel.SetToolTip(MySpaceTexts.TerminalTab_Factions_CreateFactionTagToolTip);
            secretLabel.SetToolTip(MySpaceTexts.TerminalTab_Factions_CreateFactionPrivateInfoToolTip);

            Controls.Add(composite);
            Controls.Add(panel);
            Controls.Add(headerLabel);
            Controls.Add(shortcutLabel);
            Controls.Add(nameLabel);
            Controls.Add(descLabel);
            Controls.Add(secretLabel);

            // INPUTS
            var iLeft =  0.06f;
            var iTop  = -0.15f;

            m_shortcut = new MyGuiControlTextbox(position: new Vector2(iLeft, iTop),                 maxLength: 3,   defaultText: (m_editFaction != null) ? m_editFaction.Tag : "");
            m_name     = new MyGuiControlTextbox(position: new Vector2(iLeft, iTop + spacingV),      maxLength: 64,  defaultText: (m_editFaction != null) ? m_editFaction.Name : "");
            m_desc     = new MyGuiControlTextbox(position: new Vector2(iLeft, iTop + 2f * spacingV), maxLength: 512, defaultText: (m_editFaction != null) ? m_editFaction.Description : "");
            m_privInfo = new MyGuiControlTextbox(position: new Vector2(iLeft, iTop + 3f * spacingV), maxLength: 512, defaultText: (m_editFaction != null) ? m_editFaction.PrivateInfo : "");

            m_shortcut.SetToolTip(MySpaceTexts.TerminalTab_Factions_CreateFactionTagToolTip);
            m_privInfo.SetToolTip(MySpaceTexts.TerminalTab_Factions_CreateFactionPrivateInfoToolTip);

            Controls.Add(m_shortcut);
            Controls.Add(m_name);
            Controls.Add(m_desc);
            Controls.Add(m_privInfo);

            // BUTTONS
            top  -= 0.003f;

            Controls.Add(new MyGuiControlButton(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM, size: buttonSize, position: new Vector2(left, -top), text: MyTexts.Get(MySpaceTexts.Ok), onButtonClick: OnOkClick));
            Controls.Add(new MyGuiControlButton(originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM, size: buttonSize, position: new Vector2(-left, -top), text: MyTexts.Get(MySpaceTexts.Cancel), onButtonClick: OnCancelClick));
        }