private void OnNewScrollbarvalueDetailPage(float value) { GuiElementRichtext richtextElem = detailViewGui.GetRichtext("richtext"); richtextElem.Bounds.fixedY = 3 - value; richtextElem.Bounds.CalcWorldBounds(); }
private void OnNewScrollbarvalueDetailPage(float value) { GuiElementRichtext richtextElem = detailViewGui.GetRichtext("richtext"); richtextElem.Bounds.fixedY = 3 - value; richtextElem.Bounds.CalcWorldBounds(); browseHistory.Peek().PosY = detailViewGui.GetScrollbar("scrollbar").CurrentYPosition; }
public AuctionCellEntry(ICoreClientAPI capi, ElementBounds bounds, Auction auction, Action <int> onClick) : base(capi, bounds) { iconSize = (float)scaled(unscaledIconSize); dummySlot = new DummySlot(auction.ItemStack); this.onClick = onClick; this.auction = auction; CairoFont font = CairoFont.WhiteDetailText(); double offY = (unScaledCellHeight - font.UnscaledFontsize) / 2; scissorBounds = ElementBounds.FixedSize(unscaledIconSize, unscaledIconSize).WithParent(Bounds); var stackNameTextBounds = ElementBounds.Fixed(0, offY, 270, 25).WithParent(Bounds).FixedRightOf(scissorBounds, 10); var priceTextBounds = ElementBounds.Fixed(0, offY, 75, 25).WithParent(Bounds).FixedRightOf(stackNameTextBounds, 10); var expireTextBounds = ElementBounds.Fixed(0, 0, 160, 25).WithParent(Bounds).FixedRightOf(priceTextBounds, 10); var sellerTextBounds = ElementBounds.Fixed(0, offY, 110, 25).WithParent(Bounds).FixedRightOf(expireTextBounds, 10); stackNameTextElem = new GuiElementRichtext(capi, VtmlUtil.Richtextify(capi, dummySlot.Itemstack.GetName(), font), stackNameTextBounds); double fl = font.UnscaledFontsize; ItemStack gearStack = capi.ModLoader.GetModSystem <ModSystemAuction>().SingleCurrencyStack; var comps = new RichTextComponentBase[] { new RichTextComponent(capi, "" + auction.Price, font) { PaddingRight = 10, VerticalAlign = EnumVerticalAlign.Top }, new ItemstackTextComponent(capi, gearStack, fl * 2.5f, 0, EnumFloat.Inline) { VerticalAlign = EnumVerticalAlign.Top, offX = -scaled(fl * 0.5f), offY = -scaled(fl * 0.75f) } }; priceTextElem = new GuiElementRichtext(capi, comps, priceTextBounds); expireTextElem = new GuiElementRichtext(capi, VtmlUtil.Richtextify(capi, prevExpireText = auction.GetExpireText(capi), font.Clone().WithFontSize(14)), expireTextBounds); expireTextElem.BeforeCalcBounds(); expireTextBounds.fixedY = 5 + (25 - expireTextElem.TotalHeight / RuntimeEnv.GUIScale) / 2; sellerTextElem = new GuiElementRichtext(capi, VtmlUtil.Richtextify(capi, auction.SellerName, font.Clone().WithOrientation(EnumTextOrientation.Right)), sellerTextBounds); hoverTexture = new LoadedTexture(capi); }
void initDetailGui() { ElementBounds textBounds = ElementBounds.Fixed(9, 45, 500, 30 + listHeight + 17); ElementBounds clipBounds = textBounds.ForkBoundingParent(); ElementBounds insetBounds = textBounds.FlatCopy().FixedGrow(6).WithFixedOffset(-3, -3); ElementBounds scrollbarBounds = clipBounds.CopyOffsetedSibling(textBounds.fixedWidth + 7, -6, 0, 6).WithFixedWidth(20); ElementBounds closeButtonBounds = ElementBounds .FixedSize(0, 0) .FixedUnder(clipBounds, 2 * 5 + 5) .WithAlignment(EnumDialogArea.RightFixed) .WithFixedPadding(20, 4) .WithFixedAlignmentOffset(-11, 1) ; ElementBounds backButtonBounds = ElementBounds .FixedSize(0, 0) .FixedUnder(clipBounds, 2 * 5 + 5) .WithAlignment(EnumDialogArea.LeftFixed) .WithFixedPadding(20, 4) .WithFixedAlignmentOffset(4, 1) ; ElementBounds overviewButtonBounds = ElementBounds .FixedSize(0, 0) .FixedUnder(clipBounds, 2 * 5 + 5) .WithAlignment(EnumDialogArea.CenterFixed) .WithFixedPadding(20, 4) .WithFixedAlignmentOffset(0, 1) ; ElementBounds bgBounds = insetBounds.ForkBoundingParent(5, 40, 36, 52).WithFixedPadding(GuiStyle.ElementToDialogPadding / 2); bgBounds.WithChildren(insetBounds, textBounds, scrollbarBounds, backButtonBounds, closeButtonBounds); BrowseHistoryElement curPage = browseHistory.Peek(); float posY = curPage.PosY; // 3. Finally Dialog ElementBounds dialogBounds = bgBounds.ForkBoundingParent().WithAlignment(EnumDialogArea.None).WithAlignment(EnumDialogArea.CenterFixed).WithFixedPosition(0, 70); //dialogBounds.Code = "dialogbounds"; RichTextComponentBase[] cmps = curPage.Page.GetPageText(capi, allstacks, OpenDetailPageFor); int curTab; ElementBounds tabBounds = ElementBounds.Fixed(-200, 35, 200, 545); detailViewGui?.Dispose(); detailViewGui = capi.Gui .CreateCompo("handbook-detail", dialogBounds) .AddShadedDialogBG(bgBounds, true) .AddDialogTitleBar(Lang.Get("Survival Handbook"), OnTitleBarClose) .AddVerticalTabs(genTabs(out curTab), tabBounds, OnDetailViewTabClicked, "verticalTabs") .BeginChildElements(bgBounds) .BeginClip(clipBounds) .AddInset(insetBounds, 3) .AddRichtext(cmps, textBounds, "richtext") .EndClip() .AddVerticalScrollbar(OnNewScrollbarvalueDetailPage, scrollbarBounds, "scrollbar") .AddSmallButton(Lang.Get("general-back"), OnButtonBack, backButtonBounds) .AddSmallButton(Lang.Get("handbook-overview"), OnButtonOverview, overviewButtonBounds) .AddSmallButton(Lang.Get("general-close"), OnButtonClose, closeButtonBounds) .EndChildElements() .Compose() ; GuiElementRichtext richtextelem = detailViewGui.GetRichtext("richtext"); detailViewGui.GetScrollbar("scrollbar").SetHeights( (float)listHeight, (float)richtextelem.Bounds.fixedHeight ); detailViewGui.GetScrollbar("scrollbar").CurrentYPosition = posY; OnNewScrollbarvalueDetailPage(posY); detailViewGui.GetVerticalTab("verticalTabs").SetValue(curTab, false); }