예제 #1
0
        public override void RenderInteractiveElements(float deltaTime)
        {
            if (curSlot?.Itemstack == null || !readyToRender)
            {
                return;
            }

            api.Render.Render2DTexturePremultipliedAlpha(texture.TextureId, Bounds, 1000);

            titleElement.RenderInteractiveElements(deltaTime);
            descriptionElement.RenderInteractiveElements(deltaTime);

            double offset = (int)scaled(30 + ItemStackSize / 2);

            api.Render.PushScissor(scissorBounds);

            api.Render.RenderItemstackToGui(
                curSlot,
                (int)Bounds.renderX + offset,
                (int)Bounds.renderY + offset + (int)scaled(MarginTop),
                1000 + scaled(GuiElementPassiveItemSlot.unscaledItemSize) * 2,
                (float)scaled(ItemStackSize),
                ColorUtil.WhiteArgb,
                true,
                true,
                false
                );

            api.Render.PopScissor();
        }
예제 #2
0
        public override void RenderInteractiveElements(float deltaTime)
        {
            if (text == null || text.Length == 0)
            {
                return;
            }

            if (api.Render.ScissorStack.Count > 0)
            {
                api.Render.GlScissorFlag(false);
            }

            int mouseX = api.Input.MouseX;
            int mouseY = api.Input.MouseY;

            isnowshown = false;

            if ((autoDisplay && IsPositionInside(mouseX, mouseY)) || visible)
            {
                isnowshown = true;
                // Compose on demand only
                if (hoverTexture.TextureId == 0 && !hoverTexture.Disposed)
                {
                    Recompose();
                }

                int pad = (int)scaled(padding);

                double x = Bounds.renderX;
                double y = Bounds.renderY;

                if (followMouse)
                {
                    x = mouseX + 10;
                    y = mouseY + 15;
                }

                if (x + hoverWidth > api.Render.FrameWidth)
                {
                    x -= (x + hoverWidth) - api.Render.FrameWidth;
                }

                if (y + hoverHeight > api.Render.FrameHeight)
                {
                    y -= (y + hoverHeight) - api.Render.FrameHeight;
                }

                api.Render.Render2DTexture(hoverTexture.TextureId, (int)x + (int)Bounds.absPaddingX, (int)y + (int)Bounds.absPaddingY, (int)hoverWidth + 1, (int)hoverHeight + 1, zPosition, RenderColor);

                Bounds.renderOffsetX           = x - Bounds.renderX + pad;
                Bounds.renderOffsetY           = y - Bounds.renderY + pad;
                descriptionElement.RenderColor = rendercolor;
                descriptionElement.RenderAsPremultipliedAlpha = RenderAsPremultipliedAlpha;
                descriptionElement.RenderInteractiveElements(deltaTime);
                Bounds.renderOffsetX = 0;
                Bounds.renderOffsetY = 0;
            }

            if (api.Render.ScissorStack.Count > 0)
            {
                api.Render.GlScissorFlag(true);
            }
        }