public WarningLine(MySimpleProfiler.PerformanceWarning warning, MyGuiScreenPerformanceWarnings screen)
            {
                Parent = new MyGuiControlParent();
                m_name = new MyGuiControlLabel(text: Truncate(warning.Block.DisplayName), position: new Vector2(-0.43f, 0), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, font: VRage.Game.MyFontEnum.Red);
                m_description = new MyGuiControlLabel
                    (
                    text: String.IsNullOrEmpty(warning.Block.Description.String) ? MyTexts.GetString(MyCommonTexts.PerformanceWarningTooManyBlocks) : MyTexts.GetString(warning.Block.Description), 
                    position: new Vector2(-0.24f, 0), 
                    originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER
                    );
                m_separator = new MyGuiControlSeparatorList();
                Parent.Size = new Vector2(Parent.Size.X, m_description.Size.Y);
                m_separator.AddVertical(new Vector2(-0.25f, -Parent.Size.Y / 2 - 0.006f), Parent.Size.Y + 0.016f);
                m_separator.AddVertical(new Vector2(0.35f, -Parent.Size.Y / 2 - 0.006f), Parent.Size.Y + 0.016f);
                m_time = new MyGuiControlLabel(position: new Vector2(0.43f, 0), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER);

                switch (warning.Block.type)
                {
                    case MySimpleProfiler.MySimpleProfilingBlock.ProfilingBlockType.GRAPHICS:
                        screen.m_areaTitleGraphics.Warnings.Add(this);
                        break;
                    case MySimpleProfiler.MySimpleProfilingBlock.ProfilingBlockType.BLOCK:
                        screen.m_areaTitleBlocks.Warnings.Add(this);
                        break;
                    case MySimpleProfiler.MySimpleProfilingBlock.ProfilingBlockType.OTHER:
                        screen.m_areaTitleOther.Warnings.Add(this);
                        break;
                }
                this.Warning = warning;
            }
        private static void AddSeparator(MyGuiControlList list)
        {
            var separator = new MyGuiControlSeparatorList();
            separator.Size = new Vector2(1, 0.01f);
            separator.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
            separator.AddHorizontal(Vector2.Zero, 1);

            list.Controls.Add(separator);
        }
        internal MyGuiControlGenericFunctionalBlock(MyTerminalBlock[] blocks) :
            base(canHaveFocus: true,
                 allowFocusingElements: true,
                 isActiveControl: false)
        {
            this.m_currentBlocks = blocks;

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

            m_terminalControlList             = new MyGuiControlList();
            m_terminalControlList.VisualStyle = MyGuiControlListStyleEnum.Simple;
            m_terminalControlList.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP;
            m_terminalControlList.Position    = new Vector2(0.1f, 0.1f);
            Elements.Add(m_terminalControlList);

            m_blockPropertiesMultilineText = new MyGuiControlMultilineText(
                position: new Vector2(0.049f, -0.195f),
                size: new Vector2(0.39f, 0.635f),
                font: MyFontEnum.Blue,
                textScale: 0.85f,
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP
                );
            m_blockPropertiesMultilineText.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            m_blockPropertiesMultilineText.Text        = new StringBuilder();
            Elements.Add(m_blockPropertiesMultilineText);

            m_transferToCombobox = new MyGuiControlCombobox(
                Vector2.Zero,
                new Vector2(0.15f, 0.1f),
                null, null);
            m_transferToCombobox.ItemSelected += m_transferToCombobox_ItemSelected;
            Elements.Add(m_transferToCombobox);

            m_shareModeCombobox = new MyGuiControlCombobox(
                Vector2.Zero,
                new Vector2(0.25f, 0.1f),
                null, null);
            m_shareModeCombobox.ItemSelected += m_shareModeCombobox_ItemSelected;
            Elements.Add(m_shareModeCombobox);

            m_ownershipLabel = new MyGuiControlLabel(
                Vector2.Zero, null, MyTexts.GetString(MySpaceTexts.BlockOwner_Owner) + ":");
            Elements.Add(m_ownershipLabel);

            m_ownerLabel = new MyGuiControlLabel(
                Vector2.Zero, null, String.Empty);
            Elements.Add(m_ownerLabel);

            m_transferToLabel = new MyGuiControlLabel(
                Vector2.Zero, null, MyTexts.GetString(MySpaceTexts.BlockOwner_TransferTo));
            Elements.Add(m_transferToLabel);

            if (MySession.Static.CreativeMode)
            {
                var     topLeftRelative = Vector2.One * -0.5f;
                Vector2 leftColumnSize  = new Vector2(0.3f, 0.55f);
                var     position        = topLeftRelative + new Vector2(leftColumnSize.X + 0.503f, 0.42f);

                m_npcButton = new MyGuiControlButton(
                    position,
                    MyGuiControlButtonStyleEnum.Tiny,
                    new Vector2(0.1f, 0.1f),
                    null, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, MyTexts.GetString(MyCommonTexts.AddNewNPC), new StringBuilder("+"),
                    MyGuiConstants.DEFAULT_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_ACTIVE, true,
                    OnNewNpcClick, GuiSounds.MouseClick, 0.75f);
                Elements.Add(m_npcButton);
            }


            RecreateBlockControls();
            RecreateOwnershipControls();

            if (m_currentBlocks.Length > 0)
            {
                m_currentBlocks[0].PropertiesChanged += block_PropertiesChanged;
            }

            foreach (var block in m_currentBlocks)
            {
                block.OwnershipChanged  += block_OwnershipChanged;
                block.VisibilityChanged += block_VisibilityChanged;
            }

            Sync.Players.IdentitiesChanged += Players_IdentitiesChanged;

            UpdateDetailedInfo();

            Size = new Vector2(0.595f, 0.64f);
        }
		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);
		}
        protected virtual void BuildControls()
        {
            Vector2 buttonSize = MyGuiConstants.BACK_BUTTON_SIZE;
            Vector2 buttonsOrigin = m_size.Value / 2 - new Vector2(0.23f, 0.03f);

            if (m_isNewGame)
                AddCaption(MyCommonTexts.ScreenCaptionCustomWorld);
            else
                AddCaption(MyCommonTexts.ScreenCaptionEditSettings);

            int numControls = 0;

            var nameLabel = MakeLabel(MyCommonTexts.Name);
            var descriptionLabel = MakeLabel(MyCommonTexts.Description);
            var gameModeLabel = MakeLabel(MyCommonTexts.WorldSettings_GameMode);
            var onlineModeLabel = MakeLabel(MyCommonTexts.WorldSettings_OnlineMode);
            m_maxPlayersLabel = MakeLabel(MyCommonTexts.MaxPlayers);
            var environmentLabel = MakeLabel(MySpaceTexts.WorldSettings_EnvironmentHostility);
            var scenarioLabel = MakeLabel(MySpaceTexts.WorldSettings_Scenario);
            var soundModeLabel = MakeLabel(MySpaceTexts.WorldSettings_SoundMode);

            float width = 0.284375f + 0.025f;

            m_nameTextbox = new MyGuiControlTextbox(maxLength: MySession.MAX_NAME_LENGTH);
            m_descriptionTextbox = new MyGuiControlTextbox(maxLength: MySession.MAX_DESCRIPTION_LENGTH);
            m_onlineMode = new MyGuiControlCombobox(size: new Vector2(width, 0.04f));
            m_environment = new MyGuiControlCombobox(size: new Vector2(width, 0.04f));
            m_maxPlayersSlider = new MyGuiControlSlider(
                position: Vector2.Zero,
                width: m_onlineMode.Size.X,
                minValue: 2,
                maxValue: 16,
                labelText: new StringBuilder("{0}").ToString(),
                labelDecimalPlaces: 0,
                labelSpaceWidth: 0.05f,
                intValue: true
                );



            m_asteroidAmountLabel = MakeLabel(MySpaceTexts.Asteroid_Amount);
            m_asteroidAmountCombo = new MyGuiControlCombobox(size: new Vector2(width, 0.04f));

            m_asteroidAmountCombo.ItemSelected += m_asteroidAmountCombo_ItemSelected;
            m_soundModeCombo = new MyGuiControlCombobox(size: new Vector2(width, 0.04f));

            m_scenarioTypesList = new MyGuiControlList();

            // Ok/Cancel
            m_okButton = new MyGuiControlButton(position: buttonsOrigin - new Vector2(0.01f, 0f), size: buttonSize, text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM);
            m_cancelButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(0.01f, 0f), size: buttonSize, text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: OnCancelButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM);

            m_creativeModeButton = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Small, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MyCommonTexts.WorldSettings_GameModeCreative), onButtonClick: OnCreativeClick);
            m_creativeModeButton.SetToolTip(MySpaceTexts.ToolTipWorldSettingsModeCreative);
            m_survivalModeButton = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Small, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MyCommonTexts.WorldSettings_GameModeSurvival), onButtonClick: OnSurvivalClick);
            m_survivalModeButton.SetToolTip(MySpaceTexts.ToolTipWorldSettingsModeSurvival);

            m_onlineMode.ItemSelected += OnOnlineModeSelect;
            m_onlineMode.AddItem((int)MyOnlineModeEnum.OFFLINE, MyCommonTexts.WorldSettings_OnlineModeOffline);
            m_onlineMode.AddItem((int)MyOnlineModeEnum.PRIVATE, MyCommonTexts.WorldSettings_OnlineModePrivate);
            m_onlineMode.AddItem((int)MyOnlineModeEnum.FRIENDS, MyCommonTexts.WorldSettings_OnlineModeFriends);
            m_onlineMode.AddItem((int)MyOnlineModeEnum.PUBLIC, MyCommonTexts.WorldSettings_OnlineModePublic);

            m_environment.AddItem((int)MyEnvironmentHostilityEnum.SAFE, MySpaceTexts.WorldSettings_EnvironmentHostilitySafe);
            m_environment.AddItem((int)MyEnvironmentHostilityEnum.NORMAL, MySpaceTexts.WorldSettings_EnvironmentHostilityNormal);
            m_environment.AddItem((int)MyEnvironmentHostilityEnum.CATACLYSM, MySpaceTexts.WorldSettings_EnvironmentHostilityCataclysm);
            m_environment.AddItem((int)MyEnvironmentHostilityEnum.CATACLYSM_UNREAL, MySpaceTexts.WorldSettings_EnvironmentHostilityCataclysmUnreal);
            m_environment.ItemSelected += HostilityChanged;

            m_soundModeCombo.AddItem((int)MySoundModeEnum.Arcade, MySpaceTexts.WorldSettings_ArcadeSound);
            m_soundModeCombo.AddItem((int)MySoundModeEnum.Realistic, MySpaceTexts.WorldSettings_RealisticSound);

            if (m_isNewGame)
            {
                m_scenarioTypesGroup = new MyGuiControlRadioButtonGroup();
                m_scenarioTypesGroup.SelectedChanged += scenario_SelectedChanged;
                foreach (var scenario in MyDefinitionManager.Static.GetScenarioDefinitions())
                {
                    if (!scenario.Public && !MyFakes.ENABLE_NON_PUBLIC_SCENARIOS)
                        continue;

                    var button = new MyGuiControlScenarioButton(scenario);
                    m_scenarioTypesGroup.Add(button);
                    m_scenarioTypesList.Controls.Add(button);
                }
            }

            m_nameTextbox.SetToolTip(string.Format(MyTexts.GetString(MyCommonTexts.ToolTipWorldSettingsName), MySession.MIN_NAME_LENGTH, MySession.MAX_NAME_LENGTH));
            m_descriptionTextbox.SetToolTip(MyTexts.GetString(MyCommonTexts.ToolTipWorldSettingsDescription));
            m_environment.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsEnvironment));
            m_onlineMode.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsOnlineMode));
            m_maxPlayersSlider.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsMaxPlayer));
            m_asteroidAmountCombo.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsAsteroidAmount));
            m_soundModeCombo.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsSoundMode));

            m_nameTextbox.TextChanged += m_nameTextbox_TextChanged;
            m_soundModeCombo.ItemSelected += m_soundModeCombo_ItemSelected;

            var advanced = new MyGuiControlButton(highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Advanced), onButtonClick: OnAdvancedClick);

#if !XB1 // XB1_NOWORKSHOP
            var mods = new MyGuiControlButton(highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MyCommonTexts.WorldSettings_Mods), onButtonClick: OnModsClick);
#endif // !XB1

            m_worldGeneratorButton = new MyGuiControlButton(highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_WorldGenerator), onButtonClick: OnWorldGeneratorClick);

            // Add controls in pairs; label first, control second. They will be laid out automatically this way.
            Controls.Add(nameLabel);
            Controls.Add(m_nameTextbox);
            Controls.Add(descriptionLabel);
            Controls.Add(m_descriptionTextbox);

            Controls.Add(gameModeLabel);
            Controls.Add(m_creativeModeButton);

            if (MyFakes.ENABLE_NEW_SOUNDS)
            {
                Controls.Add(soundModeLabel);
                Controls.Add(m_soundModeCombo);
            }

            Controls.Add(onlineModeLabel);
            Controls.Add(m_onlineMode);
            Controls.Add(m_maxPlayersLabel);
            Controls.Add(m_maxPlayersSlider);

            if (MyFakes.ENABLE_METEOR_SHOWERS)
            {
                Controls.Add(environmentLabel);
                Controls.Add(m_environment);
            }

            if (m_isNewGame && MyFakes.ENABLE_PLANETS == false)
            {
                Controls.Add(m_asteroidAmountLabel);
                Controls.Add(m_asteroidAmountCombo);
            }

            var autoSaveLabel = MakeLabel(MyCommonTexts.WorldSettings_AutoSave);
            m_autoSave = new MyGuiControlCheckbox();
            m_autoSave.SetToolTip(new StringBuilder().AppendFormat(MyCommonTexts.ToolTipWorldSettingsAutoSave, MyObjectBuilder_SessionSettings.DEFAULT_AUTOSAVE_IN_MINUTES).ToString());
            Controls.Add(autoSaveLabel);
            Controls.Add(m_autoSave);

            var scenarioEditModeLabel = MakeLabel(MySpaceTexts.WorldSettings_ScenarioEditMode);
            m_scenarioEditMode = new MyGuiControlCheckbox();
            m_scenarioEditMode.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettings_ScenarioEditMode));

            Controls.Add(scenarioEditModeLabel);
            Controls.Add(m_scenarioEditMode);

#if !XB1 // XB1_NOWORKSHOP
            if (!MyFakes.XB1_PREVIEW)
                if (MyFakes.ENABLE_WORKSHOP_MODS)
                    Controls.Add(mods);
#endif // !XB1

            Controls.Add(advanced);

            if (m_isNewGame && MyFakes.ENABLE_PLANETS == true)
            {
                Controls.Add(m_worldGeneratorButton);
            }

            float labelSize = 0.20f;

            float MARGIN_TOP = 0.12f;
            float MARGIN_BOTTOM = 0.12f;
            float MARGIN_LEFT = m_isNewGame ? 0.315f : 0.08f;
            float MARGIN_RIGHT = m_isNewGame ? 0.075f : 0.045f;

            // Automatic layout.
            Vector2 originL, originC;
            Vector2 controlsDelta = new Vector2(0f, 0.052f);
            float rightColumnOffset;
            originL = -m_size.Value / 2 + new Vector2(MARGIN_LEFT, MARGIN_TOP);
            originC = originL + new Vector2(labelSize, 0f);
            rightColumnOffset = originC.X + m_onlineMode.Size.X - labelSize - 0.017f;

            foreach (var control in Controls)
            {
                control.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
                if (control is MyGuiControlLabel)
                    control.Position = originL + controlsDelta * numControls;
                else
                    control.Position = originC + controlsDelta * numControls++;
            }

            Controls.Add(m_survivalModeButton);
            m_survivalModeButton.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
            m_survivalModeButton.Position = m_creativeModeButton.Position + new Vector2(m_onlineMode.Size.X, 0);

            if (m_isNewGame)
            {
                Vector2 scenarioPosition = new Vector2(-0.375f, nameLabel.Position.Y);

                m_nameTextbox.Size = m_onlineMode.Size;
                m_descriptionTextbox.Size = m_nameTextbox.Size;

                scenarioLabel.Position = scenarioPosition;

                m_scenarioTypesList.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                m_scenarioTypesList.Position = scenarioLabel.Position + new Vector2(0, 0.02f);
                m_scenarioTypesList.Size = new Vector2(0.19f, m_size.Value.Y - MARGIN_BOTTOM - MARGIN_TOP);
                Controls.Add(scenarioLabel);
                Controls.Add(m_scenarioTypesList);

                MyGuiControlSeparatorList m_verticalLine = new MyGuiControlSeparatorList();
                Vector2 position = nameLabel.Position + new Vector2(-0.025f, -0.02f);
                m_verticalLine.AddVertical(position, m_size.Value.Y - MARGIN_BOTTOM - MARGIN_TOP + 0.04f);
                Controls.Add(m_verticalLine);
            }

            var pos2 = advanced.Position;
            //pos2.X = m_isNewGame ? 0.160f : 0.0f;
            pos2.X = Size.HasValue ? Size.Value.X / 2.0f - advanced.Size.X - MARGIN_RIGHT : 0.0f;
            advanced.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
            advanced.Position = pos2;

#if !XB1 // XB1_NOWORKSHOP
            mods.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
            mods.Position = advanced.Position - new Vector2(advanced.Size.X + 0.017f, 0);
#endif // !XB1

            m_worldGeneratorButton.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
            m_worldGeneratorButton.Position = advanced.Position - new Vector2(advanced.Size.X + 0.017f, -0.06f);

            if (MyFakes.XB1_PREVIEW)
            {
                var pos2p = m_worldGeneratorButton.Position;
                pos2p.X = Size.HasValue ? Size.Value.X / 2.0f - m_worldGeneratorButton.Size.X - MARGIN_RIGHT : 0.0f;
                m_worldGeneratorButton.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
                m_worldGeneratorButton.Position = pos2p;

                advanced.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
                if (m_isNewGame)
                {
                    advanced.Position = m_worldGeneratorButton.Position - new Vector2(m_worldGeneratorButton.Size.X + 0.017f, 0);
                }
                else
                {
                    advanced.Position = m_worldGeneratorButton.Position - new Vector2(m_worldGeneratorButton.Size.X + 0.017f, 0.008f);
                }
            }

            Controls.Add(m_okButton);
            Controls.Add(m_cancelButton);

            CloseButtonEnabled = true;
        }
        private void RecreateServerLimitInfo(MyGuiControlList list)
        {
            var identity = MySession.Static.Players.TryGetIdentity(MySession.Static.LocalPlayerId);
            int built;

            if (MySession.Static.MaxBlocksPerPlayer > 0 || MySession.Static.BlockTypeLimits.Keys.Count > 0)
            {
                MyGuiControlLabel totalBlocksLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.TerminalTab_Info_Overview), textScale: 1.3f);
                list.Controls.Add(totalBlocksLabel);
            }

            if (MySession.Static.MaxBlocksPerPlayer > 0)
            {
                MyGuiControlLabel totalBlocksLabel = new MyGuiControlLabel(text: String.Format("{0} {1}/{2} {3}", MyTexts.Get(MySpaceTexts.TerminalTab_Info_YouBuilt), identity.BlocksBuilt, MySession.Static.MaxBlocksPerPlayer + identity.BlockLimitModifier, MyTexts.Get(MySpaceTexts.TerminalTab_Info_BlocksLower)));
                list.Controls.Add(totalBlocksLabel);
            }
            foreach (var blockType in MySession.Static.BlockTypeLimits)
            {
                identity.BlockTypeBuilt.TryGetValue(blockType.Key, out built);
                var definition = Sandbox.Definitions.MyDefinitionManager.Static.TryGetDefinitionGroup(blockType.Key);
                if (definition == null)
                    continue;
                MyGuiControlLabel blockTypeLabel = new MyGuiControlLabel(text: String.Format("{0} {1}/{2} {3}", MyTexts.Get(MySpaceTexts.TerminalTab_Info_YouBuilt), built, MySession.Static.GetBlockTypeLimit(blockType.Key), definition.Any.DisplayNameText));
                list.Controls.Add(blockTypeLabel);
            }

            foreach (var grid in m_infoGrids)
            {
                grid.OnAuthorshipChanged -= grid_OnAuthorshipChanged;
            }

            m_infoGrids.Clear();
            identity.LockBlocksBuiltByGrid.AcquireExclusive();
            for (int i = 0; i < identity.BlocksBuiltByGrid.Count; i++)
            {
                var grid = identity.BlocksBuiltByGrid.ElementAt(i);
                MyGuiControlParent panel = new MyGuiControlParent();

                if (m_infoGrids.Count == 0)
                {
                    MyGuiControlSeparatorList infoSeparator = new MyGuiControlSeparatorList();
                    infoSeparator.AddHorizontal(new Vector2(-0.2f, -0.052f), 0.4f, width: 0.004f);
                    panel.Controls.Add(infoSeparator);
                }

                MyGuiControlLabel gridNameLabel = new MyGuiControlLabel(text: grid.Key.DisplayName, textScale: 0.9f);
                MyGuiControlLabel gridBlockCountLabel = new MyGuiControlLabel(text: String.Format("{0} {1}", grid.Value, MyTexts.Get(MySpaceTexts.TerminalTab_Info_BlocksLower)), textScale: 0.9f);
                MyGuiControlLabel assignLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.TerminalTab_Info_Assign), originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, textScale: 0.9f);
                MyGuiControlCombobox assignCombobox = new MyGuiControlCombobox(originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, size: new Vector2(0.11f, 0.008f));
                MyGuiControlSeparatorList lineSeparator = new MyGuiControlSeparatorList();

                gridNameLabel.Position = new Vector2(-0.15f, -0.025f);
                gridBlockCountLabel.Position = new Vector2(-0.15f, 0.000f);
                assignLabel.Position = new Vector2(0.035f, 0.025f);
                assignCombobox.Position = new Vector2(0.15f, 0.025f);

                assignCombobox.ItemSelected += delegate()
                {
                    assignCombobox_ItemSelected(grid.Key, m_playerIds[(int)assignCombobox.GetSelectedKey()]);
                };

                m_playerIds.Clear();
                foreach (var player in MySession.Static.Players.GetOnlinePlayers())
                {
                    if (MySession.Static.LocalHumanPlayer != player)
                    {
                        assignCombobox.AddItem(m_playerIds.Count, player.DisplayName);
                        m_playerIds.Add(player.Id);
                    }
                }
                lineSeparator.AddHorizontal(new Vector2(-0.15f, 0.05f), 0.3f, width: 0.002f);

                panel.Controls.Add(gridNameLabel);
                panel.Controls.Add(gridBlockCountLabel);
                panel.Controls.Add(assignLabel);
                panel.Controls.Add(assignCombobox);
                panel.Controls.Add(lineSeparator);

                if (MySession.Static.EnableRemoteBlockRemoval)
                {
                    MyGuiControlLabel deleteOwnedBlocksLabel = new MyGuiControlLabel(
                        text: MyTexts.GetString(MySpaceTexts.buttonRemove), 
                        originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, 
                        textScale: 0.9f);
                    MyGuiControlButton deleteOwnedBlocksButton = new MyGuiControlButton(
                        text: new StringBuilder("X"), 
                        onButtonClick: deleteOwnedBlocksButton_ButtonClicked, 
                        buttonIndex: m_infoGrids.Count, 
                        visualStyle: MyGuiControlButtonStyleEnum.SquareSmall, 
                        originAlign: VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER);
                    deleteOwnedBlocksLabel.Position = new Vector2(0.11f, -0.02f);
                    deleteOwnedBlocksButton.Position = new Vector2(0.15f, -0.02f);
                    panel.Controls.Add(deleteOwnedBlocksLabel);
                    panel.Controls.Add(deleteOwnedBlocksButton);
                }

                grid.Key.OnAuthorshipChanged += grid_OnAuthorshipChanged;

                m_infoGrids.Add(grid.Key);

                panel.Size = new Vector2(panel.Size.X, 0.09f);
                list.Controls.Add(panel);
            }
            identity.LockBlocksBuiltByGrid.ReleaseExclusive();
        }
        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();   
            }
        }
        private void CreateInfoPageControls(MyGuiControlTabPage infoPage)
        {
            infoPage.Name = "PageInfo";
            infoPage.TextEnum = MySpaceTexts.TerminalTab_Info;

            var list = new MyGuiControlList(new Vector2(-0.462f, -0.34f), new Vector2(0.35f, 0.69f));
            //var list = new MyGuiControlMultilineText( new Vector2(-0.462f, -0.34f), new Vector2(0.35f,0.69f), null, MyFontEnum.White, 1, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, new StringBuilder());
            list.Name = "InfoList";
            list.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            infoPage.Controls.Add(list);

            var convertBtn = new MyGuiControlButton();
            convertBtn.TextEnum = MySpaceTexts.TerminalTab_Info_ConvertButton;
            convertBtn.Name = "ConvertBtn";
            infoPage.Controls.Add(convertBtn);

            if (MyFakes.ENABLE_CENTER_OF_MASS)
            {
                var sep = new MyGuiControlSeparatorList();
                sep.AddVertical(new Vector2(0.14f, -0.34f), 0.7f, 0.002f);
                infoPage.Controls.Add(sep);

                var centerBtnLabel = new MyGuiControlLabel(new Vector2(0.15f, -0.32f), text: MyTexts.GetString(MySpaceTexts.TerminalTab_Info_ShowMassCenter));
                centerBtnLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
                infoPage.Controls.Add(centerBtnLabel);

                var centerBtn = new MyGuiControlCheckbox(new Vector2(0.45f, centerBtnLabel.Position.Y));
                centerBtn.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
                centerBtn.Name = "CenterBtn";
                infoPage.Controls.Add(centerBtn);

            }

            var showGravityGizmoBtnLabel = new MyGuiControlLabel(new Vector2(0.15f, -0.27f), text: MyTexts.GetString(MySpaceTexts.TerminalTab_Info_ShowGravityGizmo));
            showGravityGizmoBtnLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
            infoPage.Controls.Add(showGravityGizmoBtnLabel);

            var showGravityGizmoBtn = new MyGuiControlCheckbox(new Vector2(0.45f, showGravityGizmoBtnLabel.Position.Y));
            showGravityGizmoBtn.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
            showGravityGizmoBtn.Name = "ShowGravityGizmo";
            infoPage.Controls.Add(showGravityGizmoBtn);

            var showSenzorGizmoBtnLabel = new MyGuiControlLabel(new Vector2(0.15f, -0.22f), text: MyTexts.GetString(MySpaceTexts.TerminalTab_Info_ShowSenzorGizmo));
            showSenzorGizmoBtnLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
            infoPage.Controls.Add(showSenzorGizmoBtnLabel);

            var showSenzorGizmoBtn = new MyGuiControlCheckbox(new Vector2(0.45f, showSenzorGizmoBtnLabel.Position.Y));
            showSenzorGizmoBtn.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
            showSenzorGizmoBtn.Name = "ShowSenzorGizmo";
            infoPage.Controls.Add(showSenzorGizmoBtn);

            var showAntenaGizmoBtnLabel = new MyGuiControlLabel(new Vector2(0.15f, -0.17f), text: MyTexts.GetString(MySpaceTexts.TerminalTab_Info_ShowAntenaGizmo));
            showAntenaGizmoBtnLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
            infoPage.Controls.Add(showAntenaGizmoBtnLabel);

            var showAntenaGizmoBtn = new MyGuiControlCheckbox(new Vector2(0.45f, showAntenaGizmoBtnLabel.Position.Y));
            showAntenaGizmoBtn.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
            showAntenaGizmoBtn.Name = "ShowAntenaGizmo";
            infoPage.Controls.Add(showAntenaGizmoBtn);

            CreateAntennaSlider(infoPage, MyTexts.GetString(MySpaceTexts.TerminalTab_Info_FriendlyAntennaRange),"FriendAntennaRange",-0.13f);
            CreateAntennaSlider(infoPage, MyTexts.GetString(MySpaceTexts.TerminalTab_Info_EnemyAntennaRange), "EnemyAntennaRange", -0.01f);
            CreateAntennaSlider(infoPage, MyTexts.GetString(MySpaceTexts.TerminalTab_Info_OwnedAntennaRange), "OwnedAntennaRange", 0.11f);

            var pivotBtnLabel = new MyGuiControlLabel(new Vector2(0.15f, 0.23f), text: MyTexts.GetString(MySpaceTexts.TerminalTab_Info_PivotBtn));
            pivotBtnLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
            infoPage.Controls.Add(pivotBtnLabel);

            var pivotBtn = new MyGuiControlCheckbox(new Vector2(0.45f, pivotBtnLabel.Position.Y));
            pivotBtn.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
            pivotBtn.Name = "PivotBtn";
            infoPage.Controls.Add(pivotBtn);

            if (MyFakes.ENABLE_TERMINAL_PROPERTIES)
            {
                var nameLabel = new MyGuiControlLabel()
                {
                    Name = "RenameShipLabel",
                    Text = "Ship Name",
                    Position = new Vector2(0.15f, 0.26f)
                };
                var nameTextBox = new MyGuiControlTextbox()
                {
                    Name = "RenameShipText",
                    Position = new Vector2(0.25f, 0.3f),
                    Size = new Vector2(0.2f, 0.005f)
                };

                var renameButton = new MyGuiControlButton()
                {
                    Name = "RenameShipButton",
                    Position = new Vector2(0.38f, 0.3f),
                    Text = "Ok",
                    VisualStyle = MyGuiControlButtonStyleEnum.Tiny,
                };
                infoPage.Controls.Add(nameLabel);
                infoPage.Controls.Add(nameTextBox);
                infoPage.Controls.Add(renameButton);
            }

            var setDestructibleBlocksLabel = new MyGuiControlLabel(new Vector2(0.15f, 0.28f), text: MyTexts.GetString(MySpaceTexts.TerminalTab_Info_DestructibleBlocks));
            setDestructibleBlocksLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER;
            setDestructibleBlocksLabel.Visible = MySession.Static.Settings.ScenarioEditMode || MySession.Static.IsScenario;
            infoPage.Controls.Add(setDestructibleBlocksLabel);

            var setDestructibleBlocksBtn = new MyGuiControlCheckbox(new Vector2(0.45f, setDestructibleBlocksLabel.Position.Y), toolTip: MyTexts.GetString(MySpaceTexts.TerminalTab_Info_DestructibleBlocks_Tooltip));
            setDestructibleBlocksBtn.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER;
            setDestructibleBlocksBtn.Name = "SetDestructibleBlocks";
            infoPage.Controls.Add(setDestructibleBlocksBtn);
        }
        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);
        }
        internal MyGuiControlGenericFunctionalBlock(MyTerminalBlock[] blocks) :
            base(canHaveFocus: true,
                  allowFocusingElements: true,
                  isActiveControl: false)
        {
            this.m_currentBlocks = blocks;

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

            m_terminalControlList = new MyGuiControlList();
            m_terminalControlList.VisualStyle = MyGuiControlListStyleEnum.Simple;
            m_terminalControlList.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP;
            m_terminalControlList.Position = new Vector2(0.1f, 0.1f);
            Elements.Add(m_terminalControlList);

            m_blockPropertiesMultilineText = new MyGuiControlMultilineText(
                position: new Vector2(0.049f, -0.195f),
                size: new Vector2(0.39f, 0.635f),
                font: MyFontEnum.Blue,
                textScale: 0.85f,
                textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP
                );
            m_blockPropertiesMultilineText.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            m_blockPropertiesMultilineText.Text = new StringBuilder();
            Elements.Add(m_blockPropertiesMultilineText);

            m_transferToCombobox = new MyGuiControlCombobox(
                Vector2.Zero,
                new Vector2(0.15f, 0.1f),
                null, null);
            m_transferToCombobox.ItemSelected += m_transferToCombobox_ItemSelected;
            Elements.Add(m_transferToCombobox);

            m_shareModeCombobox = new MyGuiControlCombobox(
            Vector2.Zero,
            new Vector2(0.25f, 0.1f),
            null, null);
            m_shareModeCombobox.ItemSelected += m_shareModeCombobox_ItemSelected;
            Elements.Add(m_shareModeCombobox);

            m_ownershipLabel = new MyGuiControlLabel(
                Vector2.Zero, null, MyTexts.GetString(MySpaceTexts.BlockOwner_Owner) + ":");
            Elements.Add(m_ownershipLabel);

            m_ownerLabel = new MyGuiControlLabel(
                Vector2.Zero, null, String.Empty);
            Elements.Add(m_ownerLabel);

            m_transferToLabel = new MyGuiControlLabel(
                Vector2.Zero, null, MyTexts.GetString(MySpaceTexts.BlockOwner_TransferTo));
            Elements.Add(m_transferToLabel);

            if (MySession.Static.CreativeMode)
            {
                var topLeftRelative = Vector2.One * -0.5f;
                Vector2 leftColumnSize = new Vector2(0.3f, 0.55f);
                var position = topLeftRelative + new Vector2(leftColumnSize.X + 0.503f, 0.42f);

                m_npcButton = new MyGuiControlButton(
                    position,
                    MyGuiControlButtonStyleEnum.Tiny,
                    new Vector2(0.1f, 0.1f),
                    null, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, MyTexts.GetString(MyCommonTexts.AddNewNPC), new StringBuilder("+"),
                    MyGuiConstants.DEFAULT_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiControlHighlightType.WHEN_ACTIVE, true,
                    OnNewNpcClick, GuiSounds.MouseClick, 0.75f);
                Elements.Add(m_npcButton);
            }


            RecreateBlockControls();
            RecreateOwnershipControls();

            if (m_currentBlocks.Length > 0)
            {
                m_currentBlocks[0].PropertiesChanged += block_PropertiesChanged;
            }

            foreach (var block in m_currentBlocks)
            {
                block.OwnershipChanged += block_OwnershipChanged;
                block.VisibilityChanged += block_VisibilityChanged;
            }

            Sync.Players.IdentitiesChanged += Players_IdentitiesChanged;

            UpdateDetailedInfo();

            Size = new Vector2(0.595f, 0.64f);
        }
            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()); });
                }
            }
        private void InitCampaignList()
        {
            Vector2 originL = -m_size.Value / 2 + new Vector2(0.07f, MARGIN_TOP);

            m_campaignTypesGroup = new MyGuiControlRadioButtonGroup();
            m_campaignTypesGroup.SelectedChanged += CampaignSelectionChanged;

            m_campaignList = new MyGuiControlList
            {
              OriginAlign  = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
              Position = originL,
              Size = new Vector2(0.19f, m_size.Value.Y - 0.03f - MARGIN_TOP),
            };

            var separator = new MyGuiControlSeparatorList()
            {
                Size = new Vector2(0.03f, m_campaignList.Size.Y),
                OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                Position = m_campaignList.Position + new Vector2(m_campaignList.Size.X + 0.015f, 0f)
            };
            separator.AddVertical(new Vector2(0f, -m_campaignList.Size.Y/2), separator.Size.Y);

            Controls.Add(separator);
            Controls.Add(m_campaignList);
        }
        public void RecreateControls()
        {
            if (QuestInfo == null || Elements == null)
                return;
            Elements.Clear();

            Vector2 topleft = -this.Size / 2;
            Vector2 textOffset = new Vector2(0.015f, 0.015f);

            // Title
            MyGuiControlLabel title = new MyGuiControlLabel();
            title.Text = QuestInfo.QuestTitle;
            title.Position = topleft + textOffset;
            title.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            title.Visible = true;
            Elements.Add(title);

            // Pages
            if (QuestInfo.MaxPages != 0)
            {
                MyGuiControlLabel numbers = new MyGuiControlLabel();
                numbers.Text = QuestInfo.Page + "/" + QuestInfo.MaxPages;
                numbers.Position = topleft + Vector2.UnitX * this.Size - textOffset * new Vector2(1, -1);
                numbers.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP;
                Elements.Add(numbers);
            }

            // Separator
            MyGuiControlSeparatorList m_separator;
            m_separator = new MyGuiControlSeparatorList();
            m_separator.AddHorizontal(topleft + textOffset + new Vector2(0, 0.03f), this.Size.X - 2 * textOffset.X, 0.003f); // Title separator
            m_separator.Visible = true;
            Elements.Add(m_separator);

            // Details
            var rowOffset = new Vector2(0, 0.025f);
            string[] details = QuestInfo.GetQuestGetails();
            int idx = 0;
            for (int i = 0; i < details.Length; i++)
            {
                if (details[i] == null)
                    continue;
                MyGuiControlMultilineText textBox = new MyGuiControlMultilineText(
                    size: new Vector2(Size.X * 0.92f, rowOffset.Y * 5),
                    position: topleft + textOffset + new Vector2(0, 0.04f) + rowOffset * idx,
                    textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                    textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP,
                    //Debug purpose
                    //backgroundColor: Vector4.One,
                    //backgroundTexture: BackgroundTexture,
                    drawScrollbar: false
                    );
                textBox.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
                textBox.TextScale = 0.9f;
                textBox.AppendText(details[i]);
                textBox.Visible = true;
                idx += textBox.NumberOfRows;
                Elements.Add(textBox);
            }
        }