public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphFormat valueFormat) { var buf = block.textBuffer; // Fill builder.Add(MyTexts.TrySubstitute("Gas"), nameFormat); builder.Add(": ", nameFormat); builder.Add($"{Fill:G6} / {Capacity:G6} L ", valueFormat); buf.Clear(); buf.Append('('); buf.Append(Math.Round(FillRatio * 100d, 2)); buf.Append("%)\n"); builder.Add(buf, nameFormat); // Stockpile status builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertyTitle_Stockpile), nameFormat); builder.Add(": ", nameFormat); builder.Add(Stockpile ? MyTexts.GetString(MySpaceTexts.HudInfoOn) : MyTexts.GetString(MySpaceTexts.HudInfoOff), valueFormat); builder.Add("\n"); // Auto refil enabled/disabled builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertyTitle_AutoRefill), nameFormat); builder.Add(": ", nameFormat); builder.Add(AutoRefillBottles ? MyTexts.GetString(MySpaceTexts.HudInfoOn) : MyTexts.GetString(MySpaceTexts.HudInfoOff), valueFormat); builder.Add("\n"); }
/// <summary> /// Updates the position of the right character. /// </summary> private float UpdateCharOffset(Line line, int right, int left, Vector2 pos, float xAlign) { char ch = line.Chars[right]; FormattedGlyph formattedGlyph = line.FormattedGlyphs[right]; IFontStyle fontStyle = FontManager.GetFontStyle(formattedGlyph.format.StyleIndex); float textSize = formattedGlyph.format.TextSize, formatScale = textSize * fontStyle.FontScale, // Quick fix for CJK characters in Space Engineers font data cjkOffset = (formattedGlyph.format.StyleIndex.X == 0 && ch >= 0x4E00) ? (-4f * textSize) : 0f; // Kerning adjustment if (left >= 0) { GlyphFormat leftFmt = line.FormattedGlyphs[left].format, rightFmt = formattedGlyph.format; if (leftFmt.StyleIndex == rightFmt.StyleIndex && leftFmt.TextSize == rightFmt.TextSize) { pos.X += fontStyle.GetKerningAdjustment(line.Chars[left], ch) * formatScale; } } GlyphLocData locData = line.LocData[right]; line.SetOffsetAt(right, new Vector2() { X = pos.X + locData.bbSize.X * .5f + (formattedGlyph.glyph.leftSideBearing * formatScale) + xAlign, Y = pos.Y - (locData.bbSize.Y * .5f) + (fontStyle.BaseLine * formatScale) + cjkOffset }); return(pos.X + locData.chSize.X); }
public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphFormat valueFormat) { var buf = block.textBuffer; builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertiesText_Effectiveness), nameFormat); builder.Add(" ", nameFormat); buf.Clear(); buf.Append(Math.Round(ThrustEffectiveness * 100f, 2)); buf.Append("%\n"); builder.Add(buf, valueFormat); builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertyTitle_ThrustOverride), nameFormat); builder.Add(": ", nameFormat); if (Override > 0f) { buf.Clear(); TerminalUtilities.GetForceDisplay(Override * ThrustEffectiveness, buf); buf.Append('\n'); builder.Add(buf, valueFormat); } else { builder.Add(MyTexts.TrySubstitute("Disabled"), valueFormat); } }
/// <summary> /// Applies glyph formatting to a range of characters. /// </summary> /// <param name="start">Position of the first character being formatted.</param> /// <param name="end">Position of the last character being formatted.</param> public virtual void SetFormatting(Vector2I start, Vector2I end, GlyphFormat formatting, bool onlyChangeColor) { if (lines.Count > 0) { if (end.X > start.X) { lines[start.X].SetFormatting(start.Y, lines[start.X].Count - 1, formatting, onlyChangeColor); for (int x = start.X + 1; x < end.X; x++) { lines[x].SetFormatting(formatting, onlyChangeColor); } lines[start.X].SetFormatting(0, end.Y, formatting, onlyChangeColor); } else { lines[start.X].SetFormatting(start.Y, end.Y, formatting, onlyChangeColor); } for (int n = start.X; n <= end.X; n++) { lines[n].UpdateSize(); } } }
public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphFormat valueFormat) { var buf = block.textBuffer; // Current charge builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertiesText_StoredPower), nameFormat); buf.Clear(); TerminalUtilities.GetPowerDisplay(Charge, buf); buf.Append('h'); builder.Add(buf, valueFormat); // pct buf.Clear(); buf.Append(" ("); buf.AppendFormat("{0:F1}", (Charge / Capacity) * 100f); buf.Append("%)\n"); builder.Add(buf, nameFormat); builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertiesText_MaxStoredPower), nameFormat); buf.Clear(); TerminalUtilities.GetPowerDisplay(Capacity, buf); buf.Append("h\n"); builder.Add(buf, valueFormat); builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertyTitle_ChargeMode), nameFormat); builder.Add(": ", nameFormat); buf.Clear(); buf.Append(GetLocalizedChargeMode()); buf.Append('\n'); builder.Add(buf, valueFormat); }
public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphFormat valueFormat) { builder.Add(MyTexts.TrySubstitute("Detected"), nameFormat); builder.Add(": ", nameFormat); builder.Add(MyTexts.TrySubstitute(IsEntityDetected.ToString()), valueFormat); }
/// <summary> /// Determines whether or not two given <see cref="GlyphFormat"/>s share the same configuration. /// </summary> public bool Equals(GlyphFormat format) { return(Data.Item1 == format.Data.Item1 && Data.Item2 == format.Data.Item2 && Data.Item3 == format.Data.Item3 && Data.Item4 == format.Data.Item4); }
protected void SetData(IList <RichStringMembers> text) { for (int n = 0; n < text.Count; n++) { GlyphFormatMembers format = text[n].Item2, empty = GlyphFormat.Empty.Data; bool formatEmpty = format.Item1 == empty.Item1 && format.Item2 == empty.Item2 && format.Item3 == empty.Item3 && format.Item4 == empty.Item4; if (formatEmpty) { text[n] = new RichStringMembers(text[n].Item1, Format.Data); } else if (n == 0) { Format = new GlyphFormat(text[0].Item2); } } lastTextData = text as List <RichStringMembers>; if (!GetIsTextEqual(lastTextData)) { Clear(); formatter.Append(text); AfterFullTextUpdate(); } }
public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphFormat valueFormat) { builder.Add(MyTexts.GetString(MySpaceTexts.TerminalTab_Info_ShipName), nameFormat); builder.Add(" ", nameFormat); builder.Add(GridName ?? MyTexts.TrySubstitute("None"), valueFormat); builder.Add("\n", valueFormat); if (GridName != null) { var buf = block.textBuffer; builder.Add(MyTexts.GetString(MySpaceTexts.TerminalTab_Info_Blocks), nameFormat); builder.Add(" ", nameFormat); buf.Clear(); buf.Append(BlocksBuilt); buf.Append(" / "); buf.Append(TotalBlocks); builder.Add(buf, valueFormat); buf.Clear(); buf.Append(" ("); buf.AppendFormat("{0:G5}", PctComplete); buf.Append("%)\n"); builder.Add(buf, nameFormat); } }
public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphFormat valueFormat) { var buf = block.textBuffer; // Jump status builder.Add(MyTexts.GetString(MySpaceTexts.TerminalStatus), nameFormat); builder.Add(": ", nameFormat); builder.Add(GetLocalizedDriveStatus(), valueFormat); builder.Add("\n", valueFormat); // Stored power builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertiesText_StoredPower), nameFormat); buf.Clear(); TerminalUtilities.GetPowerDisplay(Charge, buf); buf.Append('h'); builder.Add(buf, valueFormat); // pct buf.Clear(); buf.Append(" ("); buf.Append(Math.Round(Charge / Capacity * 100f, 1)); buf.Append("%)\n"); builder.Add(buf, nameFormat); // Power capacity builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertiesText_MaxStoredPower), nameFormat); buf.Clear(); TerminalUtilities.GetPowerDisplay(Capacity, buf); buf.Append("h\n"); builder.Add(buf, valueFormat); }
public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphFormat valueFormat) { // Laser range builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertyTitle_LaserRange), nameFormat); builder.Add(": ", nameFormat); var buf = block.textBuffer; buf.Clear(); if (Range < 1E8) { TerminalUtilities.GetDistanceDisplay(Range, buf); } else { buf.Append(MyTexts.GetString(MySpaceTexts.ScreenTerminal_Infinite)); } buf.Append('\n'); builder.Add(buf, valueFormat); // Antenna status builder.Add(MyTexts.GetString(MySpaceTexts.TerminalStatus), nameFormat); builder.Add(": ", nameFormat); builder.Add(GetLocalizedAntennaStatus(), valueFormat); builder.Add("\n", valueFormat); }
/// <summary> /// Updates formatting based on input from the toolbar controls /// </summary> private void UpdateFormat(object sender, EventArgs args) { if (sizeList.Selection != null && fontList.Selection != null) { float textSize = sizeList.Selection.AssocMember; IFontMin font = fontList.Selection.AssocMember; FontStyles style = FontStyles.Regular; // Bolding requires a separate set of texture atlases, and as such, isn't always // available boldToggle.Enabled = font.IsStyleDefined(FontStyles.Bold); if (boldToggle.Selected) { style |= FontStyles.Bold; } // Underlining and italics are render as effects and are available // for every font if (underlineToggle.Selected) { style |= FontStyles.Underline; } if (italicToggle.Selected) { style |= FontStyles.Italic; } _format = new GlyphFormat(_format.Color, _format.Alignment, textSize, font.GetStyleIndex(style)); FormatChanged?.Invoke(); } }
/// <summary> /// Retrieves range of characters in the line specified and adds them to the list /// given. /// </summary> public void GetRangeString(List <RichStringMembers> text, int start, int end) { StringBuilder sb; RichStringMembers lastString = default(RichStringMembers); if (text.Count > 0) { lastString = text[text.Count - 1]; } for (int ch = start; ch <= end; ch++) { GlyphFormat format = formattedGlyphs[ch].format; GlyphFormatMembers lastFormat = lastString.Item2; bool formatEqual = lastString.Item1 != null && lastFormat.Item1 == format.Data.Item1 && lastFormat.Item2 == format.Data.Item2 && lastFormat.Item3 == format.Data.Item3 && lastFormat.Item4 == format.Data.Item4; sb = formatEqual ? lastString.Item1 : builder.sbPool.Get(); sb.Append(chars[ch]); var nextString = new RichStringMembers(sb, format.Data); if (lastString.Item1 != nextString.Item1) { text.Add(nextString); } lastString = nextString; } }
/// <summary> /// Sets the formatting for the given range of characters in the line /// </summary> public void SetFormatting(int start, int end, GlyphFormat format, bool onlyChangeColor) { Vector4 bbColor = QuadBoard.GetQuadBoardColor(format.Data.Item4); for (int n = start; n <= end; n++) { if (onlyChangeColor) { var quadBoard = glyphBoards[n]; quadBoard.bbColor = bbColor; glyphBoards[n] = quadBoard; formattedGlyphs[n] = new FormattedGlyph(formattedGlyphs[n].glyph, format); } else if (!formattedGlyphs[n].format.Equals(format)) { IFontStyle fontStyle = FontManager.GetFontStyle(format.Data.Item3); float scale = format.Data.Item2 * fontStyle.FontScale; Glyph glyph = fontStyle[chars[n]]; Vector2 glyphSize = new Vector2(glyph.advanceWidth, fontStyle.Height) * scale; formattedGlyphs[n] = new FormattedGlyph(glyph, format); locData[n] = new GlyphLocData(glyph.MatFrame.Material.size * scale, glyphSize); glyphBoards[n] = glyph.GetQuadBoard(format, bbColor); } } }
public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphFormat valueFormat) { // Broadcast name builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertiesTitle_HudText), nameFormat); builder.Add(": ", nameFormat); builder.Add(HudText, valueFormat); builder.Add("\n", valueFormat); // Broadcast Radius builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertyTitle_BroadcastRadius), nameFormat); builder.Add(": ", nameFormat); block.textBuffer.Clear(); TerminalUtilities.GetDistanceDisplay(Range, block.textBuffer); block.textBuffer.Append('\n'); builder.Add(block.textBuffer, valueFormat); // Broadcasting enabled/disabled builder.Add(MyTexts.GetString(MySpaceTexts.HudInfoBroadcasting), nameFormat); builder.Add(": ", nameFormat); builder.Add(IsBroadcasting ? MyTexts.GetString(MySpaceTexts.HudInfoOn) : MyTexts.GetString(MySpaceTexts.HudInfoOff), valueFormat); builder.Add("\n", valueFormat); }
public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphFormat valueFormat) { builder.Add(MyTexts.GetString(MySpaceTexts.TerminalStatus), nameFormat); builder.Add(": ", nameFormat); builder.Add(GetLocalizedStatus(), valueFormat); builder.Add("\n", valueFormat); }
public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphFormat valueFormat) { builder.Add(MyTexts.GetString(MySpaceTexts.DisplayName_BlueprintClass_Ammo), nameFormat); builder.Add(": ", nameFormat); builder.Add(AmmoName, valueFormat); builder.Add("\n", valueFormat); }
protected void SetHighlightFormat(int index) { lastSelection = hudChain[index]; ITextBoard textBoard = lastSelection.Element.TextBoard; lastFormat = textBoard.Format; textBoard.SetFormatting(textBoard.Format.WithColor(FocusTextColor)); }
public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphFormat valueFormat) { builder.Add(MyTexts.GetString(MySpaceTexts.TerminalControlPanel_RunArgument), nameFormat); builder.Add(": ", nameFormat); builder.Add(Argument ?? "", valueFormat); builder.Add("\n", valueFormat); }
public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphFormat valueFormat) { builder.Add(MyTexts.TrySubstitute(block.SubtypeId.UsesSubtype(TBlockSubtypes.Suspension) ? "Wheel" : "Head"), nameFormat); builder.Add(": ", nameFormat); builder.Add(GetLocalizedAttachStatus(), valueFormat); builder.Add("\n", valueFormat); }
/// <summary> /// Changes the formatting of the entire text to the given format. /// </summary> public void SetFormatting(GlyphFormat format) { Format = format; if (lines.Count > 0 && lines[lines.Count - 1].Count > 0) { SetFormattingData(Vector2I.Zero, new Vector2I(lines.Count - 1, lines[lines.Count - 1].Count - 1), format.Data); } }
public Renderer GetRenderer(GlyphFormat format) { if (disposed) { throw new ObjectDisposedException("Library", "Cannot access a disposed object."); } return(new Renderer(FT.FT_Get_Renderer(Reference, format))); }
/// <summary> /// Appends a summary of the block's current configuration /// </summary> public void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphFormat valueFormat) { foreach (SubtypeAccessorBase subtype in SubtypeAccessors) { if (subtype != null) { subtype.GetSummary(builder, nameFormat, valueFormat); } } }
public QuadBoard GetQuadBoard(GlyphFormat format, Vector4 bbColor) { return(new QuadBoard { textureID = matFrame.Material.TextureID, texCoords = texCoords, bbColor = bbColor, skewRatio = ((FontStyles)format.Data.Item3.Y & FontStyles.Italic) > 0 ? .4f : 0f }); }
public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphFormat valueFormat) { if (IsPowerSink || IsPowerProducer) // not functional, but powered { var buf = block.textBuffer; if (functionalBlock != null) // functional w/ measurable power input/output { builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertyTitle_GyroPower), nameFormat); builder.Add(": ", nameFormat); // Functional status (on/off) builder.Add(MyTexts.GetString(Enabled.Value ? MySpaceTexts.SwitchText_On : MySpaceTexts.SwitchText_Off), valueFormat); builder.Add(" ", valueFormat); // Power input/output buf.Clear(); buf.Append('('); GetPowerDisplay(Input, Output, buf); buf.Append(")\n"); builder.Add(buf, nameFormat); } else // not functional { builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertyTitle_GyroPower), nameFormat); builder.Add(": ", nameFormat); buf.Clear(); GetPowerDisplay(Input, Output, buf); buf.Append('\n'); builder.Add(buf, valueFormat); } // Max in/out builder.Add(MyTexts.TrySubstitute("Max Power"), nameFormat); builder.Add(": ", nameFormat); buf.Clear(); GetPowerDisplay(MaxInput, MaxOutput, buf); buf.Append('\n'); builder.Add(buf, valueFormat); } else if (functionalBlock != null) // not a sink or producer, but functional { builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertyTitle_GyroPower), nameFormat); builder.Add(": ", nameFormat); // Functional status (on/off) builder.Add(MyTexts.GetString(Enabled.Value ? MySpaceTexts.SwitchText_On : MySpaceTexts.SwitchText_Off), valueFormat); builder.Add(" \n", valueFormat); } }
public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphFormat valueFormat) { var buf = block.textBuffer; // Acceleration due to gravity builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertyTitle_GravityAcceleration), nameFormat); builder.Add(": ", nameFormat); buf.Clear(); buf.AppendFormat("{0:G4}", Acceleration); buf.Append(" m/s²\n"); builder.Add(buf, valueFormat); if (IsSpherical) { // Field radius builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertyTitle_GravityFieldRadius), nameFormat); builder.Add(": ", nameFormat); buf.Clear(); TerminalUtilities.GetDistanceDisplay(Radius, buf); buf.Append('\n'); builder.Add(buf, valueFormat); } else { // Field width builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertyTitle_GravityFieldWidth), nameFormat); builder.Add(": ", nameFormat); buf.Clear(); TerminalUtilities.GetDistanceDisplay(FieldSize.X, buf); buf.Append('\n'); builder.Add(buf, valueFormat); // Field height builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertyTitle_GravityFieldHeight), nameFormat); builder.Add(": ", nameFormat); buf.Clear(); TerminalUtilities.GetDistanceDisplay(FieldSize.Y, buf); buf.Append('\n'); builder.Add(buf, valueFormat); // Field depth builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertyTitle_GravityFieldDepth), nameFormat); builder.Add(": ", nameFormat); buf.Clear(); TerminalUtilities.GetDistanceDisplay(FieldSize.Z, buf); buf.Append('\n'); builder.Add(buf, valueFormat); } }
public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphFormat valueFormat) { // Detector range builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertyTitle_OreDetectorRange), nameFormat); builder.Add(": ", nameFormat); block.textBuffer.Clear(); TerminalUtilities.GetDistanceDisplay(Range, block.textBuffer); block.textBuffer.Append('\n'); builder.Add(block.textBuffer, valueFormat); }
public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphFormat valueFormat) { // Targeting radius builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertyTitle_LargeTurretRadius), nameFormat); builder.Add(": ", nameFormat); block.textBuffer.Clear(); TerminalUtilities.GetDistanceDisplay(Range, block.textBuffer); block.textBuffer.Append('\n'); builder.Add(block.textBuffer, valueFormat); }
public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphFormat valueFormat) { builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertyTitle_GyroPower), nameFormat); builder.Add(": ", nameFormat); builder.Add($"{(Power * 100f).Round(2)}%\n", valueFormat); builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertyTitle_GyroOverride), nameFormat); builder.Add(": ", nameFormat); builder.Add(Override ? MyTexts.GetString(MySpaceTexts.HudInfoOn) : MyTexts.GetString(MySpaceTexts.HudInfoOff), valueFormat); builder.Add("\n", valueFormat); }
public override void GetSummary(RichText builder, GlyphFormat nameFormat, GlyphFormat valueFormat) { if (subtype.IsAttached) { builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertyTitle_MotorLock), nameFormat); builder.Add(": ", nameFormat); builder.Add(RotorLock ? MyTexts.GetString(MySpaceTexts.HudInfoOn) : MyTexts.GetString(MySpaceTexts.HudInfoOff), valueFormat); builder.Add("\n", valueFormat); builder.Add(MyTexts.GetString(MySpaceTexts.BlockPropertiesText_MotorCurrentAngle), nameFormat); builder.Add($"{Angle.RadiansToDegrees():F2}°\n", valueFormat); } }
public Renderer GetRenderer(GlyphFormat format) { if (disposed) throw new ObjectDisposedException("Library", "Cannot access a disposed object."); return new Renderer(FT.FT_Get_Renderer(Reference, format)); }
internal static extern IntPtr FT_Get_Renderer(IntPtr library, GlyphFormat format);