Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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();
        }
Esempio n. 4
0
        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);
            }
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        public override void Dispose()
        {
            base.Dispose();
            hoverOverlayTexture.Dispose();

            foreach (var val in Elements)
            {
                val.Dispose();
            }
        }
Esempio n. 8
0
        public override void Dispose()
        {
            foreach (var val in MapComps)
            {
                val.Value?.Dispose();
            }

            ownTexture?.Dispose();
            ownTexture = null;
            otherTexture?.Dispose();
            otherTexture = null;
        }
Esempio n. 9
0
        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;
        }
Esempio n. 10
0
        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
                }
                    );
            }
        }
Esempio n. 11
0
        public override void OnMapClosedClient()
        {
            foreach (var val in MapComps)
            {
                val.Value?.Dispose();
            }

            ownTexture.Dispose();
            ownTexture = null;
            otherTexture.Dispose();
            otherTexture = null;

            MapComps.Clear();
        }
Esempio n. 12
0
 internal void SetNewText(string text)
 {
     loadedTexture?.Dispose();
     loadedTexture = api.Gui.Text.GenTextTexture(text, font, TextWidth, TextHeight, null, EnumTextOrientation.Center, 0.9f);
 }
Esempio n. 13
0
 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);
 }
Esempio n. 14
0
 public override void Dispose()
 {
     Texture?.Dispose(); Texture = null;
 }
Esempio n. 15
0
 public override void Dispose()
 {
     base.Dispose();
     Texture.Dispose();
 }
 public static void DisposeStatic()
 {
     tmpTexture?.Dispose();
     tmpTexture = null;
 }
 public void ActuallyDispose()
 {
     Texture.Dispose();
 }
Esempio n. 18
0
 public void Dispose()
 {
     capi.Render.DeleteMesh(quadRef);
     exitHelpTexture?.Dispose();
     eyeShaderProg.Dispose();
 }
Esempio n. 19
0
 public override void Dispose()
 {
     textTexture?.Dispose();
 }
Esempio n. 20
0
 public override void OnMapClosedClient()
 {
     texture?.Dispose();
     texture = null;
 }