예제 #1
0
        public void MakeAdjustments(float deltaTime)
        {
            pos.Y += deltaTime / 1.5;
            var dynText = SingleComposer.GetDynamicText("text");

            Vec3d projectedPos = MatrixToolsd.Project(pos, capi.Render.PerspectiveProjectionMat, capi.Render.PerspectiveViewMat, capi.Render.FrameWidth, capi.Render.FrameHeight);

            if (projectedPos.Z < 0)
            {
                dynText.SetNewText("");
            }

            SingleComposer.Bounds.absFixedX = projectedPos.X - SingleComposer.Bounds.OuterWidth / 2;
            SingleComposer.Bounds.absFixedY = capi.Render.FrameHeight - projectedPos.Y - SingleComposer.Bounds.OuterHeight;

            dynText.Font = font.WithColor(new double[] { color[0], color[1], color[2], expiryTime / 2.0 }).WithStroke(new double[] { 0.0, 0.0, 0.0, expiryTime / 2.0 }, 1.0);
            dynText.RecomposeText();

            expiryTime -= deltaTime;
            if (expiryTime < 0)
            {
                TryClose();
                Dispose();
            }
        }
        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();
        }
예제 #3
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);
            }
        }
예제 #4
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);
 }