Exemplo n.º 1
0
        private void InitDialog()
        {
            ElementBounds slotBounds = ElementStdBounds.Slot(0, GuiStyle.TitleBarHeight);

            ElementBounds textBounds     = ElementBounds.Fixed(slotBounds.fixedWidth + 13, (int)GuiStyle.TitleBarHeight + 3, 300, 300);
            ElementBounds clippingBounds = textBounds.ForkBoundingParent();
            ElementBounds insetBounds    = textBounds.FlatCopy().FixedGrow(6).WithFixedOffset(-3, -3);

            ElementBounds scrollbarBounds = insetBounds
                                            .CopyOffsetedSibling(insetBounds.fixedWidth + 3.0)
                                            .WithFixedWidth(GuiElementScrollbar.DefaultScrollbarWidth)
                                            .WithFixedPadding(GuiElementScrollbar.DeafultScrollbarPadding);

            ElementBounds bgBounds = ElementStdBounds.DialogBackground();

            // Temporally fix scrollbar without bg
            bgBounds.BothSizing  = ElementSizing.Fixed;
            bgBounds.fixedWidth  = 388;
            bgBounds.fixedHeight = 340;

            SingleComposer = capi.Gui
                             .CreateCompo(ConstantsCore.ModId + "-cage-bait-dlg", ElementStdBounds.AutosizedMainDialog)
                             .AddShadedDialogBG(bgBounds, true)
                             .AddDialogTitleBar(DialogTitle, () => TryClose())
                             .BeginChildElements(bgBounds)
                             .AddItemSlotGrid(inventory, SendInvPacket, 1, slotBounds, "slot")
                             .BeginClip(clippingBounds)
                             .AddInset(insetBounds, 3)
                             .AddDynamicText("", CairoFont.WhiteSmallText().WithOrientation(EnumTextOrientation.Left), textBounds, "text")
                             .EndClip()
                             .AddVerticalScrollbar(OnNewScrollbarvalue, scrollbarBounds, "scrollbar")
                             .EndChildElements()
                             .Compose()
            ;

            SingleComposer.GetDynamicText("text").AutoHeight();
            UpdateText();

            SingleComposer.GetScrollbar("scrollbar").SetHeights(
                (float)insetBounds.fixedHeight, (float)textBounds.fixedHeight
                );
        }