protected void OnDebugInfoChanged() { bool showDebuginfo = capi.Settings.Bool["showEntityDebugInfo"]; if (showDebuginfo && !entity.DebugAttributes.AllDirty && !entity.DebugAttributes.PartialDirty && debugTagTexture != null) return; if (debugTagTexture != null) { // Don't refresh if player is more than 10 blocks away, so its less laggy if (showDebuginfo && capi.World.Player.Entity.Pos.SquareDistanceTo(entity.Pos) > 15 * 15 && debugTagTexture.Width > 10) { return; } debugTagTexture.Dispose(); debugTagTexture = null; } if (!showDebuginfo) return; StringBuilder text = new StringBuilder(); foreach (KeyValuePair<string, IAttribute> val in entity.DebugAttributes) { text.AppendLine(val.Key +": " + val.Value.ToString()); } debugTagTexture = capi.Gui.TextTexture.GenUnscaledTextTexture( text.ToString(), new CairoFont(20, GuiStyle.StandardFontName, ColorUtil.WhiteArgbDouble), new TextBackground() { FillColor = GuiStyle.DialogDefaultBgColor, Padding = 3, Radius = GuiStyle.ElementBGRadius } ); lastDebugInfoChangeMs = entity.World.ElapsedMilliseconds; }
public void Recompose(ICoreClientAPI capi) { Texture?.Dispose(); Texture = new TextTextureUtil(capi).GenTextTexture(Stack.GetName(), CairoFont.WhiteSmallText()); scissorBounds = ElementBounds.FixedSize(50, 50); scissorBounds.ParentBounds = capi.Gui.WindowBounds; }
public virtual void SetNewText(string[] textByCardinal, int color) { this.textByCardinal = textByCardinal; font.WithColor(ColorUtil.ToRGBADoubles(color)); font.UnscaledFontsize = fontSize / RuntimeEnv.GUIScale; int lines = 0; for (int i = 0; i < textByCardinal.Length; i++) { if (textByCardinal[i].Length > 0) { lines++; } } if (lines == 0) { loadedTexture?.Dispose(); loadedTexture = null; return; } ImageSurface surface = new ImageSurface(Format.Argb32, TextWidth, TextHeight * lines); Context ctx = new Context(surface); font.SetupContext(ctx); int line = 0; for (int i = 0; i < textByCardinal.Length; i++) { if (textByCardinal[i].Length > 0) { double linewidth = font.GetTextExtents(textByCardinal[i]).Width; ctx.MoveTo((TextWidth - linewidth) / 2, line * TextHeight + ctx.FontExtents.Ascent); ctx.ShowText(textByCardinal[i]); line++; } } if (loadedTexture == null) { loadedTexture = new LoadedTexture(api); } api.Gui.LoadOrUpdateCairoTexture(surface, true, ref loadedTexture); surface.Dispose(); ctx.Dispose(); genMesh(); }
public virtual void SetNewText(string text, int color) { font.WithColor(ColorUtil.ToRGBADoubles(color)); loadedTexture?.Dispose(); loadedTexture = null; if (text.Length > 0) { font.UnscaledFontsize = fontSize / RuntimeEnv.GUIScale; loadedTexture = api.Gui.TextTexture.GenTextTexture(text, font, TextWidth, TextHeight, null, EnumTextOrientation.Center, false); } }
protected void OnNameChanged() { var bh = entity.GetBehavior<EntityBehaviorNameTag>(); if (nameTagRenderHandler == null || bh == null) return; if (nameTagTexture != null) { nameTagTexture.Dispose(); nameTagTexture = null; } renderRange = bh.RenderRange; showNameTagOnlyWhenTargeted = bh.ShowOnlyWhenTargeted; nameTagTexture = nameTagRenderHandler.Invoke(capi, entity); }
protected void OnNameChanged() { if (nameTagRenderHandler == null) { return; } if (nameTagTexture != null) { nameTagTexture.Dispose(); nameTagTexture = null; } int?range = entity.GetBehavior <EntityBehaviorNameTag>()?.RenderRange; renderRange = range == null ? 999 : (int)range; showNameTagOnlyWhenTargeted = entity.GetBehavior <EntityBehaviorNameTag>()?.ShowOnlyWhenTargeted == true; nameTagTexture = nameTagRenderHandler.Invoke(capi, entity); }
public override void Dispose() { base.Dispose(); hoverOverlayTexture.Dispose(); foreach (var val in Elements) { val.Dispose(); } }
public override void Dispose() { foreach (var val in MapComps) { val.Value?.Dispose(); } ownTexture?.Dispose(); ownTexture = null; otherTexture?.Dispose(); otherTexture = null; }
private void OnDebugInfoChanged() { bool showDebuginfo = capi.Settings.Bool["showEntityDebugInfo"]; if (showDebuginfo && !entity.DebugAttributes.AllDirty && !entity.DebugAttributes.PartialDirty && debugTagTexture != null) { return; } if (debugTagTexture != null) { debugTagTexture.Dispose(); debugTagTexture = null; } if (!showDebuginfo) { return; } StringBuilder text = new StringBuilder(); foreach (KeyValuePair <string, IAttribute> val in entity.DebugAttributes) { text.AppendLine(val.Key + ": " + val.Value.ToString()); } debugTagTexture = capi.Gui.Text.GenUnscaledTextTexture( text.ToString(), capi.Render.GetFont(20, ElementGeometrics.StandardFontName, ColorUtil.WhiteArgbDouble), new TextBackground() { color = ElementGeometrics.DialogDefaultBgColor, padding = 3, radius = ElementGeometrics.ElementBGRadius } ); lastDebugInfoChangeMs = entity.World.ElapsedMilliseconds; }
private void OnNameChanged() { if (nameTagTexture != null) { nameTagTexture.Dispose(); nameTagTexture = null; } string name = GetNameTagName(); if (name != null) { nameTagTexture = capi.Gui.Text.GenUnscaledTextTexture( name, capi.Render.GetFont(30, ElementGeometrics.StandardFontName, ColorUtil.WhiteArgbDouble), new TextBackground() { color = ElementGeometrics.DialogLightBgColor, padding = 3, radius = ElementGeometrics.ElementBGRadius } ); } }
public override void OnMapClosedClient() { foreach (var val in MapComps) { val.Value?.Dispose(); } ownTexture.Dispose(); ownTexture = null; otherTexture.Dispose(); otherTexture = null; MapComps.Clear(); }
internal void SetNewText(string text) { loadedTexture?.Dispose(); loadedTexture = api.Gui.Text.GenTextTexture(text, font, TextWidth, TextHeight, null, EnumTextOrientation.Center, 0.9f); }
public virtual void SetNewText(string text, int color) { font.WithColor(ColorUtil.ToRGBADoubles(color)); loadedTexture?.Dispose(); loadedTexture = api.Gui.TextTexture.GenTextTexture(text, font, TextWidth, TextHeight, null, EnumTextOrientation.Center); }
public override void Dispose() { Texture?.Dispose(); Texture = null; }
public override void Dispose() { base.Dispose(); Texture.Dispose(); }
public static void DisposeStatic() { tmpTexture?.Dispose(); tmpTexture = null; }
public void ActuallyDispose() { Texture.Dispose(); }
public void Dispose() { capi.Render.DeleteMesh(quadRef); exitHelpTexture?.Dispose(); eyeShaderProg.Dispose(); }
public override void Dispose() { textTexture?.Dispose(); }
public override void OnMapClosedClient() { texture?.Dispose(); texture = null; }