//implementation without RegularExpressions public static void ParseText(string text, ref MyGuiControlMultilineText label) { try { var substrings = text.Split(']'); foreach (var substring in substrings) { var textAndMarkup = substring.Split('['); if (textAndMarkup.Length == 2) { label.AppendText(textAndMarkup[0]); var indexOfSpace = textAndMarkup[1].IndexOf(' '); if (indexOfSpace != -1) { label.AppendLink(textAndMarkup[1].Substring(0, indexOfSpace), textAndMarkup[1].Substring(indexOfSpace + 1)); } else { System.Diagnostics.Debug.Assert(false); label.AppendText(textAndMarkup[1]); } } else { label.AppendText(substring); } } } catch { } }
protected void RefreshTextField() { if (m_textField == null) { return; } var displayName = m_blueprintName; if (displayName.Length > 25) { displayName = displayName.Substring(0, 25) + "..."; } m_textField.Clear(); m_textField.AppendText("Name: " + displayName); m_textField.AppendLine(); var type = m_loadedPrefab.ShipBlueprints[0].CubeGrids[0].GridSizeEnum.ToString(); if (m_loadedPrefab.ShipBlueprints[0].CubeGrids[0].IsStatic && type == "Large") { m_textField.AppendText("Type: " + "Station"); } else { m_textField.AppendText("Type: " + type + " Ship"); } m_textField.AppendLine(); m_textField.AppendText("Number of blocks: " + GetNumberOfBlocks()); m_textField.AppendLine(); m_textField.AppendText("Author: " + m_loadedPrefab.ShipBlueprints[0].DisplayName); m_textField.AppendLine(); }
/// <summary> /// Generates multiline text control indicating that block is not available. /// </summary> /// <param name="blockSizeLarge">Is block size large.</param> /// <returns>Multiline text control with block not available info.</returns> private MyGuiControlMultilineText GenerateSizeNotAvailableText(bool blockSizeLarge) { MyGuiControlMultilineText textControl = new MyGuiControlMultilineText(size: new Vector2(0.2f, 0.1f), font: MyFontEnum.Red, showTextShadow: true, textAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); string blockTypeLabelText = MyTexts.GetString(!blockSizeLarge ? MySpaceTexts.HudBlockInfo_LargeShip_Station : MySpaceTexts.HudBlockInfo_SmallShip); textControl.AppendText(string.Format(MyTexts.GetString(MySpaceTexts.BlockSize_NotAvailable), blockTypeLabelText)); return(textControl); }
protected void RefreshTextField() { if (m_textField == null) { return; } var displayName = m_selectedItem.ScriptName; if (displayName.Length > 25) { displayName = displayName.Substring(0, 25) + "..."; } m_textField.Clear(); m_textField.AppendText("Name: " + displayName); m_textField.AppendLine(); m_textField.AppendText("Type: IngameScript"); }
public override bool Draw() { Havok.HkBaseSystem.GetMemoryStatistics(m_buffer); m_havokStatsMultiline.Clear(); m_havokStatsMultiline.AppendText(m_buffer); m_buffer.Clear(); return(base.Draw()); }
protected void RefreshTextField() { if (m_textField == null) { return; } var displayName = m_blueprintName; if (displayName.Length > 25) { displayName = displayName.Substring(0, 25) + "..."; } m_textField.Clear(); m_textField.AppendText("Name: " + displayName);//zxc translate m_textField.AppendLine(); MyCubeSize type = m_loadedPrefab.ShipBlueprints[0].CubeGrids[0].GridSizeEnum; m_textField.AppendText(MyTexts.GetString(MyCommonTexts.BlockPropertiesText_Type)); if (m_loadedPrefab.ShipBlueprints[0].CubeGrids[0].IsStatic && type == MyCubeSize.Large) { m_textField.AppendText(MyTexts.GetString(MyCommonTexts.DetailStaticGrid)); } else { if (type == MyCubeSize.Small) { m_textField.AppendText(MyTexts.GetString(MyCommonTexts.DetailSmallGrid)); } else { m_textField.AppendText(MyTexts.GetString(MyCommonTexts.DetailLargeGrid)); } } m_textField.AppendLine(); m_textField.AppendText("Number of blocks: " + GetNumberOfBlocks());//zxc translate m_textField.AppendLine(); if (MyFakes.ENABLE_BATTLE_SYSTEM) { int battlePoints = GetNumberOfBattlePoints(); if (battlePoints != 0) { m_textField.AppendText("Castle siege points: " + battlePoints);//zxc translate m_textField.AppendLine(); } } m_textField.AppendText("Author: " + m_loadedPrefab.ShipBlueprints[0].DisplayName);//zxc translate m_textField.AppendLine(); }
public void UpdateChat(MyHudChat chat) { if (MyHud.Chat.Dirty) { m_chatMultilineControl.Clear(); foreach (var message in MyHud.Chat.MessagesQueue) { bool isMe = Sandbox.Engine.Networking.MySteam.UserName == message.Item1; m_chatMultilineControl.AppendText(new StringBuilder(message.Item1), isMe ? MyFontEnum.Blue : MyFontEnum.White, m_chatMultilineControl.TextScale, Vector4.One); m_chatMultilineControl.AppendText(new StringBuilder(": ")); m_chatMultilineControl.AppendText(new StringBuilder(message.Item2)); m_chatMultilineControl.AppendLine(); } MyHud.Chat.Dirty = false; } //m_chatMultilineControl.BackgroundTexture }
protected void RefreshDescriptionField() { if (m_descriptionField == null) { return; } m_descriptionField.Clear(); if (m_selectedItem.Description != null) { m_descriptionField.AppendText(m_selectedItem.Description); } }
public virtual void GetDescriptionText(MyGuiControlMultilineText textbox) { textbox.Visible = true; textbox.Clear(); if (string.IsNullOrEmpty(Description)) { if (string.IsNullOrEmpty(Tooltip)) { textbox.AppendText("No description"); } else { textbox.AppendText(CapLength(Tooltip, 1000)); } return; } else { string text = CapLength(Description, 1000); int textStart = 0; foreach (Match m in Regex.Matches(text, @"https?:\/\/(www\.)?[\w-.]{2,256}\.[a-z]{2,4}\b[\w-.@:%\+~#?&//=]*")) { int textLen = m.Index - textStart; if (textLen > 0) { textbox.AppendText(text.Substring(textStart, textLen)); } textbox.AppendLink(m.Value, m.Value); textStart = m.Index + m.Length; } if (textStart < text.Length) { textbox.AppendText(text.Substring(textStart)); } } }
protected void RefreshDescriptionField() { if (m_descriptionField == null) { return; } m_descriptionField.Clear(); var description = m_loadedPrefab.ShipBlueprints[0].Description; if (description != null) { m_descriptionField.AppendText(description); } }
public void Draw(MyGuiControlMultilineText control) { if (Visible) { if (IsDirty) { control.Clear(); control.AppendText(CameraName); control.AppendLine(); control.AppendText(ShipName); IsDirty = false; } } else { if (IsDirty) { control.Clear(); IsDirty = false; } } }
private MultilineData ComputeLineDataFromString(string value) { MultilineData ret; ret.data = value; MyGuiControlMultilineText textBox = new MyGuiControlMultilineText(size: new Vector2(QuestlogSize.X * 0.92f, 1), drawScrollbar: false); textBox.Visible = false; textBox.TextScale = 0.9f; textBox.AppendText(value); ret.lines = textBox.NumberOfRows; return(ret); }
public static void ParseText(string text, ref MyGuiControlMultilineText label) { try { var texts = m_splitRegex.Split(text); var matches = m_splitRegex.Matches(text); for (int i = 0; i < matches.Count || i < texts.Length; i++) { if (i < texts.Length) { label.AppendText(m_stringCache.Clear().Append(texts[i])); } if (i < matches.Count) { ParseMarkup(label, matches[i].Value); } } } catch { } }
public void AppendTextToDescription(string text, Vector4 color, MyFontEnum font = MyFontEnum.White, float scale = 1.0f) { m_description += text; m_descriptionBox.AppendText(text, font, scale, color); }
public MyGuiScreenMission(MyMission missionBase, bool canDecline = true) : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, new Vector2(0.75f, 0.75f)) { Debug.Assert(missionBase != null); m_mission = missionBase; m_backgroundTexture = MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\BackgroundScreen\\MissionAcceptBackground", flags: TextureFlags.IgnoreQuality); m_size = new Vector2(1010 / 1600f, 855 / 1200f); // Title var titleLabel = new MyGuiControlLabel( this, new Vector2(0, -0.3052f), null, MyTextsWrapperEnum.Mission, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.SCREEN_CAPTION_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); // append mission name to the title of the screen titleLabel.UpdateParams(new[] { missionBase.Name }); Controls.Add(titleLabel); // mission description on the left Controls.Add(new MyGuiControlLabel( this, new Vector2(-m_size.Value.X / 4.5f, -0.2501f), null, MyTextsWrapperEnum.Description, MyGuiConstants.LABEL_TEXT_COLOR, .8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)); var multiLineText = new MyGuiControlMultilineText( this, new Vector2(-m_size.Value.X / 4.5f - 28 / 1600f, -0.0167f), new Vector2(370 / 1600f, 489 / 1200f), null, MyGuiManager.GetFontMinerWarsBlue(), .66f, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, m_mission.DescriptionTemp, false, true); Controls.Add(multiLineText); multiLineText.ScrollbarOffset = 71 / 1600f; // mission objectives (submissions) on the right Controls.Add(new MyGuiControlLabel( this, new Vector2(m_size.Value.X / 4.5f, -0.2501f), null, MyTextsWrapperEnum.Objectives, MyGuiConstants.LABEL_TEXT_COLOR, .8f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)); var objectives = new StringBuilder(); foreach (MyObjective t in m_mission.Objectives) { objectives.Append("- "); objectives.Append(t.DescriptionTemp.ToString()); objectives.AppendLine("\n"); //objectives.AppendLine(); } var textControl = new MyGuiControlMultilineText( this, new Vector2(m_size.Value.X / 4.5f - 28 / 1600f, -0.0167f), new Vector2(370 / 1600f, 489 / 1200f), null, MyGuiManager.GetFontMinerWarsBlue(), .66f, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, objectives, false, true) { ScrollbarOffset = 64 / 1600f }; Controls.Add(textControl); textControl.Clear(); textControl.AppendText(objectives); var okButton = new MyGuiControlButton(this, new Vector2(-0.1379f, 0.2489f), MyGuiConstants.OK_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetInventoryScreenButtonTexture(), null, null, MyTextsWrapperEnum.Accept, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnAccept_Click, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(okButton); // decline button if (canDecline) { var declineButton = new MyGuiControlButton(this, new Vector2(0.1379f, 0.2489f), MyGuiConstants.OK_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetInventoryScreenButtonTexture(), null, null, MyTextsWrapperEnum.Decline, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnDecline_Click, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(declineButton); } else { m_closeOnEsc = canDecline; } }
private void RefreshPlayerChatHistory(MyIdentity playerIdentity) { m_chatHistory.Clear(); var history = MyChatSystem.GetChatHistory(MySession.Static.LocalPlayerId); var playerId = playerIdentity.IdentityId; MyPlayerChatHistory playerChat; if (history.PlayerChatHistory.TryGetValue(playerId, out playerChat)) { var chat = playerChat.Chat; foreach (var text in chat) { var identity = MySession.Static.Players.TryGetIdentity(text.IdentityId); if (identity == null) { continue; } bool isPlayer = identity.IdentityId == MySession.Static.LocalPlayerId; m_chatHistory.AppendText(identity.DisplayName, isPlayer ? MyFontEnum.DarkBlue : MyFontEnum.Blue, m_chatHistory.TextScale, Vector4.One); if (!text.Sent) { m_tempStringBuilder.Clear(); m_tempStringBuilder.Append(" ("); m_tempStringBuilder.Append(MyTexts.GetString(MySpaceTexts.TerminalTab_Chat_Pending)); m_tempStringBuilder.Append(")"); m_chatHistory.AppendText(m_tempStringBuilder, MyFontEnum.Red, m_chatHistory.TextScale, Vector4.One); } m_chatHistory.AppendText(": ", isPlayer ? MyFontEnum.DarkBlue : MyFontEnum.Blue, m_chatHistory.TextScale, Vector4.One); m_chatHistory.AppendText(text.Text, MyFontEnum.White, m_chatHistory.TextScale, Vector4.One); m_chatHistory.AppendLine(); } } m_factionList.SelectedItems.Clear(); m_chatHistory.ScrollbarOffset = 1.0f; }
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); } }