public override void RenderInteractiveElements(float deltaTime, double renderX, double renderY) { LineRectangled bounds = BoundsPerLine[0]; ElementBounds scibounds = ElementBounds.FixedSize((int)(bounds.Width / API.Config.RuntimeEnv.GUIScale), (int)(bounds.Height / API.Config.RuntimeEnv.GUIScale)); scibounds.ParentBounds = capi.Gui.WindowBounds; scibounds.CalcWorldBounds(); scibounds.absFixedX = renderX + bounds.X; scibounds.absFixedY = renderY + bounds.Y + offY; api.Render.PushScissor(scibounds, true); api.Render.RenderItemstackToGui( slot, renderX + bounds.X + bounds.Width * 0.5f + offX, renderY + bounds.Y + bounds.Height * 0.5f + offY, GuiElement.scaled(100), (float)size * 0.58f, ColorUtil.WhiteArgb, true, false, false); api.Render.PopScissor(); int relx = (int)(api.Input.MouseX - renderX); int rely = (int)(api.Input.MouseY - renderY); if (bounds.PointInside(relx, rely)) { RenderItemstackTooltip(slot, renderX + relx + offX, renderY + rely + offY, deltaTime); } }
public ItemstackComponentBase(ICoreClientAPI capi) : base(capi) { this.capi = capi; dummyInv = new DummyInventory(capi); dummyInv.OnAcquireTransitionSpeed = (transType, stack, mul) => { return(0); }; renderedTooltipSlot = new DummySlot(null, dummyInv); stackInfoBounds = ElementBounds .FixedSize(EnumDialogArea.None, GuiElementItemstackInfo.BoxWidth, 0) .WithFixedPadding(10) .WithFixedPosition(20, 40) ; parentBounds = ElementBounds.Fixed(0, 0, 1, 1); parentBounds.WithParent(ElementBounds.Empty); stackInfoBounds.WithParent(parentBounds); stackInfo = new GuiElementItemstackInfo(capi, stackInfoBounds, OnRequireInfoText); stackInfo.SetSourceSlot(renderedTooltipSlot); stackInfo.ComposeElements(null, null); stackInfo.RecompCheckIgnoredStackAttributes = GlobalConstants.IgnoredStackAttributes; }
public override void RenderInteractiveElements(float deltaTime, double renderX, double renderY) { LineRectangled bounds = BoundsPerLine[0]; ItemStack itemstack = Itemstacks[curItemIndex]; if ((secondsVisible -= deltaTime) <= 0) { secondsVisible = 1; curItemIndex = (curItemIndex + 1) % Itemstacks.Length; } slot.Itemstack = itemstack; ElementBounds scibounds = ElementBounds.FixedSize((int)(bounds.Width / RuntimeEnv.GUIScale), (int)(bounds.Height / RuntimeEnv.GUIScale)); scibounds.ParentBounds = capi.Gui.WindowBounds; scibounds.CalcWorldBounds(); scibounds.absFixedX = renderX + bounds.X; scibounds.absFixedY = renderY + bounds.Y; api.Render.PushScissor(scibounds); api.Render.RenderItemstackToGui(slot, renderX + bounds.X + bounds.Width * 0.5f, renderY + bounds.Y + bounds.Height * 0.5f, 100, (float)bounds.Width * 0.58f, ColorUtil.WhiteArgb, true, false, ShowStackSize); api.Render.PopScissor(); int relx = (int)(api.Input.MouseX - renderX); int rely = (int)(api.Input.MouseY - renderY); if (bounds.PointInside(relx, rely)) { RenderItemstackTooltip(slot, renderX + relx, renderY + rely, deltaTime); } }
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; }