public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); Vector2 searchPosition = new Vector2(0f, SCREEN_SIZE.Y - 1.58f); float hiddenPartTop = (SCREEN_SIZE.Y - 1.0f) / 2.0f; var searchBoxLabel = MakeLabel("Search:", searchPosition + new Vector2(-0.175f, -0.015f), m_textScale); m_searchBox = new MyGuiControlTextbox(searchPosition); m_searchBox.Size = new Vector2(0.2f, 0.2f); m_searchClear = new MyGuiControlButton() { Position = searchPosition + new Vector2(0.077f, 0f), Size = new Vector2(0.045f, 0.05666667f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, VisualStyle = MyGuiControlButtonStyleEnum.Close }; m_searchClear.ButtonClicked += OnSearchClear; m_blueprintList.Position = new Vector2(0f, -0.03f); m_blueprintList.VisibleRowsCount = 17; m_blueprintList.MultiSelect = false; var caption = AddCaption("Blueprints screen", VRageMath.Color.White.ToVector4(), m_controlPadding + new Vector2(-HIDDEN_PART_RIGHT, hiddenPartTop)); Controls.Add(searchBoxLabel); Controls.Add(m_searchBox); Controls.Add(m_searchClear); Controls.Add(m_blueprintList); RefreshThumbnail(); Controls.Add(m_thumbnailImage); CreateButtons(); var texture = MyGuiConstants.LOADING_TEXTURE; m_wheel = new MyGuiControlRotatingWheel( searchPosition + new Vector2(0.127f, 0f), MyGuiConstants.ROTATING_WHEEL_COLOR, 0.28f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, texture, true, multipleSpinningWheels: MyPerGameSettings.GUI.MultipleSpinningWheels); Controls.Add(m_wheel); m_wheel.Visible = false; }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); Vector2 searchPosition = new Vector2(-0.025f, SCREEN_SIZE.Y - 1.59f); float hiddenPartTop = (SCREEN_SIZE.Y - 1.0f) / 2.0f; var searchBoxLabel = MakeLabel(MyTexts.GetString(MySpaceTexts.ScreenCubeBuilderBlockSearch), searchPosition + new Vector2(-0.129f, -0.015f), m_textScale); m_searchBox = new MyGuiControlTextbox(searchPosition); m_searchBox.Size = new Vector2(0.15f, 0.2f); m_searchClear = new MyGuiControlButton() { Position = searchPosition + new Vector2(0.078f, 0f), Size = new Vector2(0.045f, 0.05666667f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, VisualStyle = MyGuiControlButtonStyleEnum.Close }; m_searchClear.ButtonClicked += OnSearchClear; m_scriptList.Size -= new Vector2(0.1f, 0f); m_scriptList.Position = new Vector2(-0.015f, -0.07f); m_scriptList.VisibleRowsCount = 17; m_scriptList.MultiSelect = false; var caption = AddCaption(MyTexts.GetString(MySpaceTexts.ProgrammableBlock_ScriptsScreenTitle), VRageMath.Color.White.ToVector4(), m_controlPadding + new Vector2(-HIDDEN_PART_RIGHT, hiddenPartTop)); Controls.Add(searchBoxLabel); Controls.Add(m_searchBox); Controls.Add(m_searchClear); Controls.Add(m_scriptList); CreateButtons(); var texture = MyGuiConstants.LOADING_TEXTURE; m_wheel = new MyGuiControlRotatingWheel( searchPosition + new Vector2(0.123f, 0f), MyGuiConstants.ROTATING_WHEEL_COLOR, 0.28f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, texture, true, multipleSpinningWheels: MyPerGameSettings.GUI.MultipleSpinningWheels); Controls.Add(m_wheel); m_wheel.Visible = false; }
public MyGuiScreenSimpleProgress(MyTextsWrapperEnum caption, StringBuilder text) : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, new Vector2(0.4f, 0.4f)) { m_text = text; m_closeOnEsc = false; m_isTopMostScreen = true; AddCaption(caption, new Vector2(0f, 0.021f)); m_progressWheel = new MyGuiControlRotatingWheel(this, Vector2.Zero, MyGuiConstants.DEFAULT_CONTROL_FOREGROUND_COLOR.ToVector4(), 0.5f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyGuiManager.GetLoadingTexture()); Controls.Add(m_progressWheel); m_progressText = new MyGuiControlLabel(this, new Vector2(0f, 0.12f), null, m_text, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); Controls.Add(m_progressText); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); Vector2 loadingTextSize = MyGuiManager.MeasureString(m_font, MyTexts.Get(MyCommonTexts.LoadingPleaseWaitUppercase), MyGuiConstants.LOADING_PLEASE_WAIT_SCALE); m_wheel = new MyGuiControlRotatingWheel( MyGuiConstants.LOADING_PLEASE_WAIT_POSITION - new Vector2(0, 0.06f + loadingTextSize.Y), MyGuiConstants.ROTATING_WHEEL_COLOR, MyGuiConstants.ROTATING_WHEEL_DEFAULT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, m_rotatingWheelTexture, false, MyPerGameSettings.GUI.MultipleSpinningWheels); StringBuilder contents; if (!string.IsNullOrEmpty(m_customTextFromConstructor)) { contents = new StringBuilder(m_customTextFromConstructor); } else { contents = MyTexts.Get(m_currentQuote.Text); } m_quoteTextControl = new MyGuiControlMultilineText( position: Vector2.One * 0.5f, size: new Vector2(0.9f, 0.2f), backgroundColor: Vector4.One, font: m_font, textScale: 1.0f, textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM, contents: contents, drawScrollbar: false); m_quoteTextControl.BorderEnabled = false; m_quoteTextControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM; m_quoteTextControl.TextBoxAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM; Controls.Add(m_wheel); RefreshQuote(); }
public bool CreateSpawnMenu(float usableWidth, MyGuiControlParentTableLayout parentTable, MyPluginAdminMenu adminScreen) { m_parentScreen = adminScreen; if (m_fetchedStarSytem == null) { MyGuiControlRotatingWheel loadingWheel = new MyGuiControlRotatingWheel(position: Vector2.Zero); loadingWheel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER; adminScreen.Controls.Add(loadingWheel); MyStarSystemGenerator.Static.GetStarSystem(delegate(MyObjectBuilder_SystemData starSystem) { m_fetchedStarSytem = starSystem; adminScreen.ShouldRecreate = true; }); return(true); } MyGuiControlLabel label = new MyGuiControlLabel(null, null, "Parent objects"); parentTable.AddTableRow(label); m_parentObjectListBox = new MyGuiControlListbox(); m_parentObjectListBox.Add(new MyGuiControlListbox.Item(new System.Text.StringBuilder("System center"), userData: m_fetchedStarSytem.CenterObject)); m_parentObjectListBox.VisibleRowsCount = 8; m_parentObjectListBox.Size = new Vector2(usableWidth, m_parentObjectListBox.Size.Y); m_parentObjectListBox.SelectAllVisible(); m_parentObjectListBox.ItemsSelected += OnParentItemClicked; foreach (var obj in m_fetchedStarSytem.CenterObject.GetAllChildren()) { if (obj.Type == MySystemObjectType.PLANET || obj.Type == MySystemObjectType.MOON) { m_parentObjectListBox.Add(new MyGuiControlListbox.Item(new System.Text.StringBuilder(obj.DisplayName), userData: obj)); } } parentTable.AddTableRow(m_parentObjectListBox); parentTable.AddTableSeparator(); m_radiusSlider = new MyGuiControlClickableSlider(width: usableWidth - 0.1f, minValue: 0, maxValue: 1, labelSuffix: " km", showLabel: true); m_radiusSlider.Enabled = false; m_radiusSlider.ValueChanged += delegate { RenderSpherePreview(GetDataFromGui()); }; parentTable.AddTableRow(new MyGuiControlLabel(null, null, "Radius")); parentTable.AddTableRow(m_radiusSlider); m_widthSlider = new MyGuiControlClickableSlider(null, 0, 1, usableWidth - 0.1f, 0.5f, showLabel: true, labelSuffix: " km"); m_widthSlider.Enabled = false; m_widthSlider.ValueChanged += delegate { RenderSpherePreview(GetDataFromGui()); }; parentTable.AddTableRow(new MyGuiControlLabel(null, null, "Width")); parentTable.AddTableRow(m_widthSlider); m_asteroidSizesSlider = new MyGuiControlRangedSlider(32, 1024, 32, 1024, true, width: usableWidth - 0.1f, showLabel: true); m_asteroidSizesSlider.Enabled = false; parentTable.AddTableRow(new MyGuiControlLabel(null, null, "Asteroid size range")); parentTable.AddTableRow(m_asteroidSizesSlider); m_nameBox = new MyGuiControlTextbox(); m_nameBox.Size = new Vector2(usableWidth, m_nameBox.Size.Y); parentTable.AddTableRow(new MyGuiControlLabel(null, null, "Name")); parentTable.AddTableRow(m_nameBox); m_spawnButton = MyPluginGuiHelper.CreateDebugButton(usableWidth, "Spawn sphere", delegate { StringBuilder name = new StringBuilder(); m_nameBox.GetText(name); if (name.Length < 4) { MyPluginGuiHelper.DisplayError("Name must be at least 4 letters long", "Error"); return; } MySystemAsteroids instance; MyAsteroidSphereData data; GenerateData(out instance, out data); if (instance == null || data == null) { MyPluginGuiHelper.DisplayError("Could not generate asteroid sphere. No data found.", "Error"); return; } MyAsteroidSphereProvider.Static.AddInstance(instance, data, delegate(bool success) { if (!success) { MyPluginGuiHelper.DisplayError("Sphere could not be added, because an object with the same id already exists. This error should not occour, so please try again.", "Error"); } else { MyPluginGuiHelper.DisplayMessage("Sphere was created successfully.", "Success"); m_parentScreen.ForceFetchStarSystem = true; m_parentScreen.ShouldRecreate = true; } }); }); parentTable.AddTableSeparator(); parentTable.AddTableRow(m_spawnButton); return(true); }
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(); }
/// <summary> /// Builds the edit menu /// </summary> private void BuildEditMenu() { MyPluginLog.Debug("Adding edit menu"); if (m_fetchedStarSytem == null || ForceFetchStarSystem) { MyPluginLog.Debug("Fetching system data"); MyGuiControlRotatingWheel m_loadingWheel = new MyGuiControlRotatingWheel(position: Vector2.Zero); m_loadingWheel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER; Controls.Add(m_loadingWheel); MyStarSystemGenerator.Static.GetStarSystem(delegate(MyObjectBuilder_SystemData starSystem) { m_fetchedStarSytem = starSystem; m_selectedObject = null; ShouldRecreate = true; ForceFetchStarSystem = false; }); return; } var topCombo = GetCombo(); Vector2 start = topCombo.Position + new Vector2(0, MARGIN_VERT * 2 + GetCombo().Size.Y); Vector2 end = start + new Vector2(topCombo.Size.X, 0.8f - MARGIN_VERT); MyGuiControlLabel systemObjsLabel = new MyGuiControlLabel(null, null, "System Objects"); systemObjsLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; systemObjsLabel.Position = start; Controls.Add(systemObjsLabel); m_systemObjectsBox = new MyGuiControlListbox(); m_systemObjectsBox.VisibleRowsCount = 8; m_systemObjectsBox.Size = new Vector2(m_usableWidth, m_systemObjectsBox.Size.Y); m_systemObjectsBox.Position = start; m_systemObjectsBox.PositionY += systemObjsLabel.Size.Y + MARGIN_VERT; m_systemObjectsBox.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; foreach (var obj in m_fetchedStarSytem.GetAllObjects()) { if (obj.Type == MySystemObjectType.EMPTY) { continue; } m_systemObjectsBox.Add(new MyGuiControlListbox.Item(new System.Text.StringBuilder(obj.DisplayName), userData: obj)); } if (m_selectedObject != null) { m_systemObjectsBox.SelectByUserData(m_selectedObject); } m_systemObjectsBox.ItemsSelected += OnSystemObjectSelect; Controls.Add(m_systemObjectsBox); MyGuiControlSeparatorList sep = new MyGuiControlSeparatorList(); sep.AddHorizontal(new Vector2(m_systemObjectsBox.Position.X, m_systemObjectsBox.Position.Y + m_systemObjectsBox.Size.Y + MARGIN_VERT), m_usableWidth); BuildEditingSubMenu(); sep.AddHorizontal(new Vector2(m_scrollPane.Position.X - m_scrollPane.Size.X / 2, m_scrollPane.Position.Y + m_scrollPane.Size.Y), m_usableWidth); Controls.Add(sep); MyPluginLog.Debug("Added edit menu"); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); m_toolbarControl = new MyGuiControlToolbar(); m_toolbarControl.Position = new Vector2(0.5f, 0.99f); m_toolbarControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM; m_toolbarControl.IsActiveControl = false; Elements.Add(m_toolbarControl); m_textScale = MyGuiConstants.HUD_TEXT_SCALE * MyGuiManager.LanguageTextScale; var style = new MyGuiControlBlockInfo.MyControlBlockInfoStyle() { BlockNameLabelFont = MyFontEnum.White, EnableBlockTypeLabel = true, ComponentsLabelText = MySpaceTexts.HudBlockInfo_Components, ComponentsLabelFont = MyFontEnum.Blue, InstalledRequiredLabelText = MySpaceTexts.HudBlockInfo_Installed_Required, InstalledRequiredLabelFont = MyFontEnum.Blue, RequiredLabelText = MySpaceTexts.HudBlockInfo_Required, IntegrityLabelFont = MyFontEnum.White, IntegrityBackgroundColor = new Vector4(78 / 255.0f, 116 / 255.0f, 137 / 255.0f, 1.0f), IntegrityForegroundColor = new Vector4(0.5f, 0.1f, 0.1f, 1), IntegrityForegroundColorOverCritical = new Vector4(118 / 255.0f, 166 / 255.0f, 192 / 255.0f, 1.0f), LeftColumnBackgroundColor = new Vector4(46 / 255.0f, 76 / 255.0f, 94 / 255.0f, 1.0f), TitleBackgroundColor = new Vector4(72 / 255.0f, 109 / 255.0f, 130 / 255.0f, 1.0f), ComponentLineMissingFont = MyFontEnum.Red, ComponentLineAllMountedFont = MyFontEnum.White, ComponentLineAllInstalledFont = MyFontEnum.Blue, ComponentLineDefaultFont = MyFontEnum.White, ComponentLineDefaultColor = new Vector4(0.6f, 0.6f, 0.6f, 1f), ShowAvailableComponents = false, EnableBlockTypePanel = true, }; m_blockInfo = new MyGuiControlBlockInfo(style); m_blockInfo.IsActiveControl = false; Controls.Add(m_blockInfo); m_chatControl = new MyHudControlChat(MyHud.Chat, Vector2.Zero, new Vector2(0.4f, 0.25f)); Elements.Add(m_chatControl); m_cameraInfoMultilineControl = new MyGuiControlMultilineText( position: Vector2.Zero, size: new Vector2(0.4f, 0.25f), backgroundColor: null, font: MyFontEnum.White, textScale: 0.7f, textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM, contents: null, drawScrollbar: false, textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM); m_cameraInfoMultilineControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; Elements.Add(m_cameraInfoMultilineControl); m_rotatingWheelControl = new MyGuiControlRotatingWheel(position: new Vector2(0.5f, 0.85f)); Controls.Add(m_rotatingWheelControl); Vector2 buildModePosition = new Vector2(0.5f, 0.02f); buildModePosition = MyGuiScreenHudBase.ConvertHudToNormalizedGuiPosition(ref buildModePosition); m_buildModeLabel = new MyGuiControlLabel( position: buildModePosition, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, font: MyFontEnum.White, text: MyTexts.GetString(MySpaceTexts.Hud_BuildMode)); Controls.Add(m_buildModeLabel); m_relayNotification = new MyGuiControlLabel(new Vector2(1, 0), font: MyFontEnum.White, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP); m_relayNotification.TextEnum = MySpaceTexts.Multiplayer_IndirectConnection; m_relayNotification.Visible = false; Controls.Add(m_relayNotification); var offset = new Vector2(0, m_relayNotification.Size.Y); m_noMsgSentNotification = new MyGuiControlLabel(new Vector2(1, 0) + offset, font: MyFontEnum.Debug, text: MyTexts.GetString(MySpaceTexts.Multiplayer_LastMsg), originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP); m_noMsgSentNotification.Visible = false; Controls.Add(m_noMsgSentNotification); offset += new Vector2(0, m_noMsgSentNotification.Size.Y); m_noConnectionNotification = new MyGuiControlLabel(new Vector2(1, 0) + offset, font: MyFontEnum.Red, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP); m_noConnectionNotification.TextEnum = MySpaceTexts.Multiplayer_NoConnection; m_noConnectionNotification.Visible = false; Controls.Add(m_noConnectionNotification); MyHud.ReloadTexts(); }
public bool CreateSpawnMenu(float usableWidth, MyGuiControlParentTableLayout parentTable, MyPluginAdminMenu adminScreen) { m_parentScreen = adminScreen; m_offset = Vector3D.Zero; m_currentSelectedAsteroid = null; if (m_fetchedStarSytem == null) { MyGuiControlRotatingWheel m_loadingWheel = new MyGuiControlRotatingWheel(position: Vector2.Zero); m_loadingWheel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER; adminScreen.Controls.Add(m_loadingWheel); MyStarSystemGenerator.Static.GetStarSystem(delegate(MyObjectBuilder_SystemData starSystem) { m_fetchedStarSytem = starSystem; adminScreen.ShouldRecreate = true; }); return(true); } MyGuiControlLabel label = new MyGuiControlLabel(null, null, "Parent objects"); parentTable.AddTableRow(label); m_parentObjectListBox = new MyGuiControlListbox(); m_parentObjectListBox.Add(new MyGuiControlListbox.Item(new System.Text.StringBuilder("System center"), userData: m_fetchedStarSytem.CenterObject)); m_parentObjectListBox.VisibleRowsCount = 8; m_parentObjectListBox.Size = new Vector2(usableWidth, m_parentObjectListBox.Size.Y); m_parentObjectListBox.SelectAllVisible(); m_parentObjectListBox.ItemsSelected += OnParentItemClicked; foreach (var obj in m_fetchedStarSytem.CenterObject.GetAllChildren()) { if (obj.Type == MySystemObjectType.PLANET || obj.Type == MySystemObjectType.MOON) { m_parentObjectListBox.Add(new MyGuiControlListbox.Item(new System.Text.StringBuilder(obj.DisplayName), userData: obj)); } } parentTable.AddTableRow(m_parentObjectListBox); var row = new MyGuiControlParentTableLayout(2, false, Vector2.Zero); m_snapToParentCheck = new MyGuiControlCheckbox(); m_snapToParentCheck.IsChecked = m_snapToParent; m_snapToParentCheck.IsCheckedChanged += delegate { m_snapToParent = m_snapToParentCheck.IsChecked; m_zoomInButton.Enabled = m_snapToParent; }; row.AddTableRow(m_snapToParentCheck, new MyGuiControlLabel(null, null, "Snap camera to parent")); row.ApplyRows(); parentTable.AddTableRow(row); parentTable.AddTableSeparator(); GenerateRingSettingElements(usableWidth, parentTable); m_nameBox = new MyGuiControlTextbox(); m_nameBox.Size = new Vector2(usableWidth, m_nameBox.Size.Y); parentTable.AddTableRow(new MyGuiControlLabel(null, null, "Name")); parentTable.AddTableRow(m_nameBox); m_zoomInButton = MyPluginGuiHelper.CreateDebugButton(usableWidth, "Zoom to ring", delegate { if (m_snapToParent) { m_parentScreen.CameraLookAt(GenerateAsteroidRing().CenterPosition, new Vector3D(0, 0, (m_radiusSlider.Value + m_widthSlider.Value) * 2000)); } }); parentTable.AddTableRow(m_zoomInButton); m_offsetToCoordButton = MyPluginGuiHelper.CreateDebugButton(usableWidth, "Offset to coordinate", delegate { var coordMessage = new MyGuiScreenDialogCoordinate("Enter coordinate to offset the center of the ring from its parent"); coordMessage.OnConfirmed += delegate(Vector3D coord) { m_offset = coord; UpdateRingVisual(GenerateAsteroidRing()); }; MyGuiSandbox.AddScreen(coordMessage); }); parentTable.AddTableRow(m_offsetToCoordButton); m_spawnRingButton = MyPluginGuiHelper.CreateDebugButton(usableWidth, "Add ring", delegate { StringBuilder name = new StringBuilder(); m_nameBox.GetText(name); if (name.Length < 4) { MyPluginGuiHelper.DisplayError("Name must be at least 4 letters long", "Error"); return; } MySystemAsteroids instance; MyAsteroidRingData ring; GenerateAsteroidData(out ring, out instance); if (ring == null || instance == null) { MyPluginGuiHelper.DisplayError("Could not generate asteroid ring. No data found.", "Error"); return; } MyAsteroidRingProvider.Static.AddInstance(instance, ring, delegate(bool success) { if (!success) { MyPluginGuiHelper.DisplayError("Ring could not be added, because an object with the same id already exists. This error should not occour, so please try again.", "Error"); } else { MyPluginGuiHelper.DisplayMessage("Ring was created successfully.", "Success"); m_parentScreen.ForceFetchStarSystem = true; m_parentScreen.ShouldRecreate = true; } }); }); parentTable.AddTableRow(m_spawnRingButton); return(true); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); m_toolbarControl = new MyGuiControlToolbar(); m_toolbarControl.Position = new Vector2(0.5f, 0.99f); m_toolbarControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM; m_toolbarControl.IsActiveControl = false; Elements.Add(m_toolbarControl); m_textScale = MyGuiConstants.HUD_TEXT_SCALE * MyGuiManager.LanguageTextScale; m_blockInfo = new MyGuiControlBlockInfo(); m_blockInfo.IsActiveControl = false; Controls.Add(m_blockInfo); m_chatControl = new MyHudControlChat(Vector2.Zero, new Vector2(0.4f, 0.25f)); Elements.Add(m_chatControl); m_cameraInfoMultilineControl = new MyGuiControlMultilineText( position: Vector2.Zero, size: new Vector2(0.4f, 0.25f), backgroundColor: null, font: MyFontEnum.White, textScale: 0.7f, textAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM, contents: null, drawScrollbar: false, textBoxAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM); m_cameraInfoMultilineControl.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; Elements.Add(m_cameraInfoMultilineControl); m_rotatingWheelControl = new MyGuiControlRotatingWheel(position: new Vector2(0.5f, 0.85f)); Controls.Add(m_rotatingWheelControl); Vector2 buildModePosition = new Vector2(0.5f, 0.02f); buildModePosition = MyGuiScreenHudBase.ConvertHudToNormalizedGuiPosition(ref buildModePosition); m_buildModeLabel = new MyGuiControlLabel( position: buildModePosition, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, font: MyFontEnum.White, text: MyTexts.GetString(MySpaceTexts.Hud_BuildMode)); Controls.Add(m_buildModeLabel); m_relayNotification = new MyGuiControlLabel(new Vector2(1, 0), font: MyFontEnum.White, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP); m_relayNotification.TextEnum = MySpaceTexts.Multiplayer_IndirectConnection; m_relayNotification.Visible = false; Controls.Add(m_relayNotification); var offset = new Vector2(0, m_relayNotification.Size.Y); m_noMsgSentNotification = new MyGuiControlLabel(new Vector2(1, 0) + offset, font: MyFontEnum.Debug, text: MyTexts.GetString(MySpaceTexts.Multiplayer_LastMsg), originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP); m_noMsgSentNotification.Visible = false; Controls.Add(m_noMsgSentNotification); offset += new Vector2(0, m_noMsgSentNotification.Size.Y); m_noConnectionNotification = new MyGuiControlLabel(new Vector2(1, 0) + offset, font: MyFontEnum.Red, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP); m_noConnectionNotification.TextEnum = MySpaceTexts.Multiplayer_NoConnection; m_noConnectionNotification.Visible = false; Controls.Add(m_noConnectionNotification); MyHud.ReloadTexts(); }