Exemple #1
0
        void SetupDialog()
        {
            int           rows            = (int)Math.Ceiling(skillItems.Count / 5f);
            int           cols            = Math.Min(skillItems.Count, 5);
            double        size            = GuiElementPassiveItemSlot.unscaledSlotSize + GuiElementItemSlotGrid.unscaledSlotPadding;
            double        innerWidth      = Math.Max(300, cols * size);
            ElementBounds skillGridBounds = ElementBounds.Fixed(0, 30, innerWidth, rows * size);

            ElementBounds textBounds = ElementBounds.Fixed(0, rows * size + 50, innerWidth, 33);

            SingleComposer =
                capi.Gui
                .CreateCompo("toolmodeselect", ElementStdBounds.AutosizedMainDialog, false)
                .AddDialogTitleBar("Select Recipe", OnTitleBarClose)
                .AddDialogBG(ElementStdBounds.DialogBackground(), false, ElementGeometrics.TitleBarHeight - 1)
                .BeginChildElements()
                .AddSkillItemGrid(skillItems, cols, rows, OnSlotClick, skillGridBounds, "skillitemgrid")
                .AddDynamicText("", CairoFont.WhiteSmallishText(), EnumTextOrientation.Left, textBounds, 1, "name")
                .AddDynamicText("", CairoFont.WhiteDetailText(), EnumTextOrientation.Left, textBounds.BelowCopy(0, 10, 0, 0), 1, "desc")
                .EndChildElements()
                .Compose()
            ;

            SingleComposer.GetSkillItemGrid("skillitemgrid").OnSlotOver = OnSlotOver;
        }
        void SetupDialog()
        {
            int cnt = Math.Max(1, skillItems.Count);

            int cols = Math.Min(cnt, 7);

            int rows = (int)Math.Ceiling(cnt / (float)cols);

            double        size            = GuiElementPassiveItemSlot.unscaledSlotSize + GuiElementItemSlotGrid.unscaledSlotPadding;
            double        innerWidth      = Math.Max(300, cols * size);
            ElementBounds skillGridBounds = ElementBounds.Fixed(0, 30, innerWidth, rows * size);

            ElementBounds textBounds = ElementBounds.Fixed(0, rows * size + 50, innerWidth, 33);

            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;


            SingleComposer =
                capi.Gui
                .CreateCompo("toolmodeselect" + blockEntityPos, ElementStdBounds.AutosizedMainDialog)
                .AddShadedDialogBG(bgBounds, true)
                .AddDialogTitleBar(Lang.Get("Select Recipe"), OnTitleBarClose)
                .BeginChildElements(bgBounds)
                .AddSkillItemGrid(skillItems, cols, rows, OnSlotClick, skillGridBounds, "skillitemgrid")
                .AddDynamicText("", CairoFont.WhiteSmallishText(), textBounds, "name")
                .AddDynamicText("", CairoFont.WhiteDetailText(), textBounds.BelowCopy(0, 10, 0, 0), "desc")
                .EndChildElements()
                .Compose()
            ;

            SingleComposer.GetSkillItemGrid("skillitemgrid").OnSlotOver = OnSlotOver;
        }
Exemple #3
0
        public HudElementFloatyDamage(ICoreClientAPI capi, double damage, Vec3d pos) : base(capi)
        {
            this.pos = pos.Clone();

            ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialogAtPos(0.0);
            ElementBounds textBounds   = ElementBounds.Fixed(EnumDialogArea.CenterMiddle, 0, 0, 250, 50);

            font = CairoFont.WhiteDetailText();

            color      = new double[4];
            color[3]   = 1.0;
            color[0]   = damage > 0 ? 1.0 : 0.0;
            color[1]   = damage > 0 ? 0.0 : 1.0;
            font.Color = color;

            string dmg = Math.Abs(damage).ToString("F3");

            font = font.WithStroke(new double[] { 0.0, 0.0, 0.0, 1.0 }, 1.0).WithWeight(Cairo.FontWeight.Bold).WithFontSize(15);

            SingleComposer = capi.Gui
                             .CreateCompo("floatyDmg" + damage + capi.Gui.OpenedGuis.Count + 1 + GetHashCode(), dialogBounds)
                             .AddDynamicText(dmg, font, EnumTextOrientation.Center, textBounds, "text")
                             .Compose();

            SingleComposer.Bounds.Alignment    = EnumDialogArea.None;
            SingleComposer.Bounds.fixedOffsetX = 0;
            SingleComposer.Bounds.fixedOffsetY = 0;
            SingleComposer.Bounds.absMarginX   = 0;
            SingleComposer.Bounds.absMarginY   = 0;
            MakeAdjustments(0);
            TryOpen();
        }
Exemple #4
0
        private bool OnPrevPage()
        {
            CairoFont font = CairoFont.WhiteDetailText().WithFontSize(17).WithLineHeightMultiplier(1.15f);

            page = Math.Max(0, page - 1);
            Composers["loreItem"].GetRichtext("page").SetNewText(pages[page], font);
            Composers["loreItem"].GetDynamicText("currentpage").SetNewText((page + 1) + " / " + pages.Length);
            return(true);
        }
        public GuiDialogLogViewer(string text, ICoreClientAPI capi) : base("Log Viewer", capi)
        {
            ElementBounds topTextBounds = ElementBounds.Fixed(ElementGeometrics.ElementToDialogPadding, 40, 900, 30);

            ElementBounds logtextBounds = ElementBounds.Fixed(0, 0, 900, 300).FixedUnder(topTextBounds, 5);

            // Clipping bounds for textarea
            ElementBounds clippingBounds = logtextBounds.ForkBoundingParent();

            ElementBounds insetBounds = logtextBounds.FlatCopy().FixedGrow(6).WithAddedFixedPosition(-3, -3);

            ElementBounds scrollbarBounds = insetBounds.CopyOffsetedSibling(logtextBounds.fixedWidth + 7).WithFixedWidth(20);

            ElementBounds closeButtonBounds = ElementBounds
                                              .FixedSize(0, 0)
                                              .FixedUnder(clippingBounds, 2 * 5)
                                              .WithAlignment(EnumDialogArea.RightFixed)
                                              .WithFixedPadding(20, 4)
            ;


            // 2. Around all that is 10 pixel padding
            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(ElementGeometrics.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;
            bgBounds.WithChildren(insetBounds, clippingBounds, scrollbarBounds, closeButtonBounds);

            // 3. Finally Dialog
            ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle);


            SingleComposer = capi.Gui
                             .CreateCompo("blockentitytexteditordialog", dialogBounds, false)
                             .AddDialogBG(bgBounds, true)
                             .AddDialogTitleBar(DialogTitle, OnTitleBarClose)
                             .AddStaticText("The following warnings and errors were reported during startup:", CairoFont.WhiteDetailText(), topTextBounds)
                             .BeginChildElements(bgBounds)
                             .BeginClip(clippingBounds)
                             .AddInset(insetBounds, 3)
                             .AddDynamicText("", CairoFont.WhiteDetailText(), EnumTextOrientation.Left, logtextBounds, 1, "text")
                             .EndClip()
                             .AddVerticalScrollbar(OnNewScrollbarvalue, scrollbarBounds, "scrollbar")
                             .AddSmallButton("Close", OnButtonClose, closeButtonBounds)
                             .EndChildElements()
                             .Compose()
            ;

            GuiElementDynamicText logtextElem = SingleComposer.GetDynamicText("text");

            logtextElem.AutoHeight();
            logtextElem.SetNewText(text);

            SingleComposer.GetScrollbar("scrollbar").SetHeights(
                (float)300, (float)logtextBounds.fixedHeight
                );
        }
Exemple #6
0
        void SetupDialog()
        {
            ElementBounds barrelBoundsLeft  = ElementBounds.Fixed(0, 30, 150, 200);
            ElementBounds barrelBoundsRight = ElementBounds.Fixed(170, 30, 150, 200);

            inputSlotBounds              = ElementStdBounds.SlotGrid(EnumDialogArea.None, 0, 30, 1, 1);
            inputSlotBounds.fixedHeight += 10;

            double top = inputSlotBounds.fixedHeight + inputSlotBounds.fixedY;


            ElementBounds fullnessMeterBounds = ElementBounds.Fixed(100, 30, 40, 200);

            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;
            bgBounds.WithChildren(barrelBoundsLeft, barrelBoundsRight);

            // 3. Finally Dialog
            ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog
                                         .WithFixedAlignmentOffset(IsRight(screenPos) ? -GuiStyle.DialogToScreenPadding : GuiStyle.DialogToScreenPadding, 0)
                                         .WithAlignment(IsRight(screenPos) ? EnumDialogArea.RightMiddle : EnumDialogArea.LeftMiddle)
            ;

            if (!capi.Settings.Bool["immersiveMouseMode"])
            {
                //dialogBounds.fixedOffsetY += (barrelBoundsLeft.fixedHeight + 65);
            }



            SingleComposer = capi.Gui
                             .CreateCompo("blockentitybarrel" + BlockEntityPosition, dialogBounds)
                             .AddShadedDialogBG(bgBounds)
                             .AddDialogTitleBar(DialogTitle, OnTitleBarClose)
                             .BeginChildElements(bgBounds)
                             .AddItemSlotGrid(Inventory, SendInvPacket, 1, new int[] { 0 }, inputSlotBounds, "inputSlot")
                             .AddSmallButton("Seal", onSealClick, ElementBounds.Fixed(0, 100, 80, 25), EnumButtonStyle.Normal, EnumTextOrientation.Center)
                             //.AddSmallButton("Empty", onEmptyClick, ElementBounds.Fixed(0, 140, 80, 25), EnumButtonStyle.Normal, EnumTextOrientation.Center)

                             .AddInset(fullnessMeterBounds.ForkBoundingParent(2, 2, 2, 2), 2)
                             .AddDynamicCustomDraw(fullnessMeterBounds, fullnessMeterDraw, "liquidBar")

                             .AddDynamicText(getContentsText(), CairoFont.WhiteDetailText(), EnumTextOrientation.Left, barrelBoundsRight, "contentText")

                             .EndChildElements()
                             .Compose();
        }
Exemple #7
0
        private bool onClickItem(int page)
        {
            currentLoreItemIndex = page;
            this.page            = 0;

            CairoFont     font     = CairoFont.WhiteDetailText().WithFontSize(17).WithLineHeightMultiplier(1.15f);
            TextDrawUtil  prober   = new TextDrawUtil();
            StringBuilder fulltext = new StringBuilder();

            JournalEntry entry = journalitems[currentLoreItemIndex];

            for (int p = 0; p < entry.Chapters.Count; p++)
            {
                if (p > 0)
                {
                    fulltext.AppendLine();
                }
                fulltext.Append(Lang.Get(entry.Chapters[p].Text));
            }

            pages = Paginate(fulltext.ToString(), font, GuiElement.scaled(629), GuiElement.scaled(450));


            double elemToDlgPad = GuiStyle.ElementToDialogPadding;

            ElementBounds textBounds   = ElementBounds.Fixed(0, 0, 630, 450);
            ElementBounds dialogBounds = textBounds.ForkBoundingParent(elemToDlgPad, elemToDlgPad + 20, elemToDlgPad, elemToDlgPad + 30).WithAlignment(EnumDialogArea.LeftMiddle);

            dialogBounds.fixedX = 350;


            Composers["loreItem"] =
                capi.Gui
                .CreateCompo("loreItem", dialogBounds)
                .AddShadedDialogBG(ElementBounds.Fill, true)
                .AddDialogTitleBar(Lang.Get(journalitems[page].Title), CloseIconPressedLoreItem)
                .AddRichtext(pages[0], font, textBounds, "page")
                .AddDynamicText("1 / " + pages.Length, CairoFont.WhiteSmallishText().WithOrientation(EnumTextOrientation.Center), ElementBounds.Fixed(250, 500, 100, 30), "currentpage")
                .AddButton(Lang.Get("Previous Page"), OnPrevPage, ElementBounds.Fixed(17, 500, 100, 23).WithFixedPadding(10, 4), CairoFont.WhiteSmallishText())
                .AddButton(Lang.Get("Next Page"), OnNextPage, ElementBounds.Fixed(520, 500, 100, 23).WithFixedPadding(10, 4), CairoFont.WhiteSmallishText())
                .Compose()
            ;

            return(true);
        }
        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);
        }
Exemple #9
0
        private bool onClickItem(int i)
        {
            currentLoreItemIndex = i;
            page = 0;

            CairoFont      font     = CairoFont.WhiteDetailText().WithFontSize(17);
            TextSizeProber prober   = new TextSizeProber();
            StringBuilder  fulltext = new StringBuilder();

            for (int p = 0; p < journalitems[currentLoreItemIndex].Pieces.Length; p++)
            {
                if (p > 0)
                {
                    fulltext.AppendLine();
                }
                fulltext.Append(journalitems[currentLoreItemIndex].Pieces[p]);
            }

            pages = Paginate(fulltext, font, GuiElement.scaled(629), GuiElement.scaled(450), 1.15);


            double elemToDlgPad = ElementGeometrics.ElementToDialogPadding;

            ElementBounds textBounds   = ElementBounds.Fixed(0, 0, 630, 450);
            ElementBounds dialogBounds = textBounds.ForkBoundingParent(elemToDlgPad, elemToDlgPad + 20, elemToDlgPad, elemToDlgPad + 30).WithAlignment(EnumDialogArea.LeftMiddle);

            dialogBounds.fixedX = 350;


            DialogComposers["loreItem"] =
                capi.Gui
                .CreateCompo("loreItem", dialogBounds, false)
                .AddDialogBG(ElementBounds.Fill, true)
                .AddDialogTitleBar(journalitems[i].Title, CloseIconPressedLoreItem)
                .AddDynamicText(pages[0], font, EnumTextOrientation.Left, textBounds, 1.15f, "page")
                .AddDynamicText("1 / " + pages.Length, CairoFont.WhiteSmallishText(), EnumTextOrientation.Center, ElementBounds.Fixed(250, 500, 100, 30), 1, "currentpage")
                .AddButton("Previous Page", OnPrevPage, ElementBounds.Fixed(17, 500, 100, 23).WithFixedPadding(10, 4), CairoFont.WhiteSmallishText())
                .AddButton("Next Page", OnNextPage, ElementBounds.Fixed(520, 500, 100, 23).WithFixedPadding(10, 4), CairoFont.WhiteSmallishText())
                .Compose()
            ;

            return(true);
        }
        private void UpdateStats()
        {
            EntityPlayer entity = capi.World.Player.Entity;
            GuiComposer  compo  = Composers["playerstats"];

            if (compo == null || !IsOpened())
            {
                return;
            }

            float?health;
            float?maxhealth;
            float?saturation;
            float?maxsaturation;

            getHealthSat(out health, out maxhealth, out saturation, out maxsaturation);

            float walkspeed           = entity.Stats.GetBlended("walkspeed");
            float healingEffectivness = entity.Stats.GetBlended("healingeffectivness");
            float hungerRate          = entity.Stats.GetBlended("hungerrate");
            float rangedWeaponAcc     = entity.Stats.GetBlended("rangedWeaponsAcc");
            float rangedWeaponSpeed   = entity.Stats.GetBlended("rangedWeaponsSpeed");


            if (health != null)
            {
                compo.GetDynamicText("health").SetNewText((health + " / " + maxhealth));
            }
            if (saturation != null)
            {
                compo.GetDynamicText("satiety").SetNewText((int)saturation + " / " + (int)maxsaturation);
            }

            compo.GetDynamicText("walkspeed").SetNewText((int)Math.Round(100 * walkspeed) + "%");
            compo.GetDynamicText("healeffectiveness").SetNewText((int)Math.Round(100 * healingEffectivness) + "%");
            compo.GetDynamicText("hungerrate")?.SetNewText((int)Math.Round(100 * hungerRate) + "%");
            compo.GetDynamicText("rangedweaponacc").SetNewText((int)Math.Round(100 * rangedWeaponAcc) + "%");
            compo.GetDynamicText("rangedweaponchargespeed").SetNewText((int)Math.Round(100 * rangedWeaponSpeed) + "%");

            ITreeAttribute tempTree = entity.WatchedAttributes.GetTreeAttribute("bodyTemp");

            compo.GetRichtext("bodytemp").SetNewText(getBodyTempText(tempTree), CairoFont.WhiteDetailText());
        }
Exemple #11
0
        void SetupDialog()
        {
            ElementBounds cauldBoundsLeft  = ElementBounds.Fixed(0, 30, 200, 400);
            ElementBounds cauldBoundsRight = ElementBounds.Fixed(150, 30, 200, 400);

            ingredSlotBounds              = ElementStdBounds.SlotGrid(EnumDialogArea.None, 0, 30 + 45, 5, 1);
            ingredSlotBounds.fixedHeight += 10;


            ElementBounds fullnessMeterBounds  = ElementBounds.Fixed(320, 30, 40, 200);
            ElementBounds liquidOutMeterBounds = ElementBounds.Fixed(320, 230, 40, 45);

            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;
            bgBounds.WithChildren(cauldBoundsLeft, cauldBoundsRight);

            // 3. Finally Dialog
            ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog
                                         .WithFixedAlignmentOffset(IsRight(screenPos) ? -GuiStyle.DialogToScreenPadding : GuiStyle.DialogToScreenPadding, 0)
                                         .WithAlignment(IsRight(screenPos) ? EnumDialogArea.RightMiddle : EnumDialogArea.LeftMiddle)
            ;

            ClearComposers();
            SingleComposer = capi.Gui
                             .CreateCompo("blockentitycauld" + BlockEntityPosition, dialogBounds)
                             .AddShadedDialogBG(bgBounds)
                             .AddDialogTitleBar(DialogTitle, OnTitleBarClose)
                             .BeginChildElements(bgBounds)
                             .AddItemSlotGrid(Inventory, SendInvPacket, 5, new int[] { 0, 1, 2, 3, 4 }, ingredSlotBounds, "ingredSlots")
                             .AddItemSlotGrid(Inventory, SendInvPacket, 1, new int[] { 5 }, liquidOutMeterBounds, "liquidSlotOut")
                             .AddSmallButton("Mix", onMixClick, ElementBounds.Fixed(0, 30, 130, 25), EnumButtonStyle.Normal, EnumTextOrientation.Center)

                             .AddInset(fullnessMeterBounds.ForkBoundingParent(2, 2, 2, 2), 2)
                             .AddDynamicCustomDraw(fullnessMeterBounds, fullnessMeterDraw, "liquidBar")

                             .AddDynamicText(getContentsText(), CairoFont.WhiteDetailText(), ElementBounds.Fixed(0, 130, 200, 400), "contentText")

                             .EndChildElements()
                             .Compose();
        }
Exemple #12
0
        private void SetupDialog()
        {
            // Auto-sized dialog at the center of the screen
            ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle);

            // Just a simple 300x300 pixel box
            ElementBounds textBounds = ElementBounds.Fixed(0, 40, 400, 120);

            // Background boundaries. Again, just make it fit it's child elements, then add the text as a child element
            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;
            bgBounds.WithChildren(textBounds);

            SingleComposer = capi.Gui.CreateCompo("popUpDialog", dialogBounds)
                             .AddShadedDialogBG(bgBounds)
                             .AddDialogTitleBar("Success!", OnTitleBarCloseClicked)
                             .AddStaticText(@"This is sample popup from the second mod. 
                You can edit this string in VS Code, rebuild (CTRL+SHIFT+B). 
                Then ingame just press U to load mod again 
                and then O to see updated string", CairoFont.WhiteDetailText(), textBounds)
                             .Compose()
            ;
        }
        public GuiDialogItemStackRandomizer(float totalChance, ICoreClientAPI capi) : base("Item Stack Randomizer", capi)
        {
            double pad = GuiElementItemSlotGrid.unscaledSlotPadding;

            ElementBounds chanceInputBounds = ElementBounds.Fixed(0, 70, 60, 30);

            ElementBounds leftButton  = ElementBounds.Fixed(EnumDialogArea.LeftFixed, 0, 0, 0, 0).WithFixedPadding(10, 1);
            ElementBounds rightButton = ElementBounds.Fixed(EnumDialogArea.RightFixed, 0, 0, 0, 0).WithFixedPadding(10, 1);

            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;


            ElementBounds dialogBounds = ElementStdBounds
                                         .AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle)
                                         .WithFixedAlignmentOffset(GuiStyle.DialogToScreenPadding, 0);


            SingleComposer = capi.Gui
                             .CreateCompo("itemstackrandomizer", dialogBounds)
                             .AddShadedDialogBG(bgBounds, true)
                             .AddDialogTitleBar("Item Stack Randomizer", OnTitleBarClose)
                             .BeginChildElements(bgBounds)
                             .AddStaticText("Chance for any loot to appear:", CairoFont.WhiteDetailText(), ElementBounds.Fixed(0, 30, 250, 30))
                             .AddNumberInput(chanceInputBounds = chanceInputBounds.FlatCopy(), null, CairoFont.WhiteDetailText(), "chance")
                             .AddButton("Close", OnCloseClicked, leftButton.FixedUnder(chanceInputBounds, 25))
                             .AddButton("Save", OnSaveClicked, rightButton.FixedUnder(chanceInputBounds, 25))


                             .EndChildElements()
                             .Compose()
            ;

            SingleComposer.GetNumberInput("chance").SetValue("" + (totalChance * 100));
        }
        public virtual void ComposeStatsGui()
        {
            ElementBounds leftDlgBounds = Composers["playercharacter"].Bounds;
            ElementBounds botDlgBounds  = Composers["environment"].Bounds;

            ElementBounds leftColumnBounds  = ElementBounds.Fixed(0, 25, 90, 20);
            ElementBounds rightColumnBounds = ElementBounds.Fixed(120, 30, 120, 8);

            ElementBounds leftColumnBoundsW  = ElementBounds.Fixed(0, 0, 140, 20);
            ElementBounds rightColumnBoundsW = ElementBounds.Fixed(165, 0, 120, 20);

            EntityPlayer entity = capi.World.Player.Entity;


            double b = botDlgBounds.InnerHeight / RuntimeEnv.GUIScale + 10;

            ElementBounds bgBounds = ElementBounds
                                     .Fixed(0, 0, 130 + 100 + 5, leftDlgBounds.InnerHeight / RuntimeEnv.GUIScale - GuiStyle.ElementToDialogPadding - 20 + b)
                                     .WithFixedPadding(GuiStyle.ElementToDialogPadding)
            ;


            ElementBounds dialogBounds =
                bgBounds.ForkBoundingParent()
                .WithAlignment(EnumDialogArea.LeftMiddle)
                .WithFixedAlignmentOffset((leftDlgBounds.renderX + leftDlgBounds.OuterWidth + 10) / RuntimeEnv.GUIScale, b / 2)
            ;

            float?health        = null;
            float?maxhealth     = null;
            float?saturation    = null;
            float?maxsaturation = null;

            getHealthSat(out health, out maxhealth, out saturation, out maxsaturation);

            float          walkspeed           = entity.Stats.GetBlended("walkspeed");
            float          healingEffectivness = entity.Stats.GetBlended("healingeffectivness");
            float          hungerRate          = entity.Stats.GetBlended("hungerrate");
            float          rangedWeaponAcc     = entity.Stats.GetBlended("rangedWeaponsAcc");
            float          rangedWeaponSpeed   = entity.Stats.GetBlended("rangedWeaponsSpeed");
            ITreeAttribute tempTree            = entity.WatchedAttributes.GetTreeAttribute("bodyTemp");

            float  wetness       = entity.WatchedAttributes.GetFloat("wetness");
            string wetnessString = "";

            if (wetness > 0.7)
            {
                wetnessString = Lang.Get("wetness_soakingwet");
            }
            else if (wetness > 0.4)
            {
                wetnessString = Lang.Get("wetness_wet");
            }
            else if (wetness > 0.1)
            {
                wetnessString = Lang.Get("wetness_slightlywet");
            }


            Composers["playerstats"] = capi.Gui
                                       .CreateCompo("playerstats", dialogBounds)
                                       .AddShadedDialogBG(bgBounds, true)
                                       .AddDialogTitleBar(Lang.Get("Stats"), () => dlg.OnTitleBarClose())
                                       .BeginChildElements(bgBounds)
            ;

            if (saturation != null)
            {
                Composers["playerstats"]
                .AddStaticText(Lang.Get("playerinfo-nutrition"), CairoFont.WhiteSmallText().WithWeight(Cairo.FontWeight.Bold), leftColumnBounds.WithFixedWidth(200))
                .AddStaticText(Lang.Get("playerinfo-nutrition-Freeza"), CairoFont.WhiteDetailText(), leftColumnBounds  = leftColumnBounds.BelowCopy().WithFixedWidth(90))
                .AddStaticText(Lang.Get("playerinfo-nutrition-Vegita"), CairoFont.WhiteDetailText(), leftColumnBounds  = leftColumnBounds.BelowCopy())
                .AddStaticText(Lang.Get("playerinfo-nutrition-Krillin"), CairoFont.WhiteDetailText(), leftColumnBounds = leftColumnBounds.BelowCopy())
                .AddStaticText(Lang.Get("playerinfo-nutrition-Cell"), CairoFont.WhiteDetailText(), leftColumnBounds    = leftColumnBounds.BelowCopy())
                .AddStaticText(Lang.Get("playerinfo-nutrition-Dairy"), CairoFont.WhiteDetailText(), leftColumnBounds   = leftColumnBounds.BelowCopy())

                .AddStatbar(rightColumnBounds = rightColumnBounds.BelowCopy(0, 16), GuiStyle.FoodBarColor, "fruitBar")
                .AddStatbar(rightColumnBounds = rightColumnBounds.BelowCopy(0, 12), GuiStyle.FoodBarColor, "vegetableBar")
                .AddStatbar(rightColumnBounds = rightColumnBounds.BelowCopy(0, 12), GuiStyle.FoodBarColor, "grainBar")
                .AddStatbar(rightColumnBounds = rightColumnBounds.BelowCopy(0, 12), GuiStyle.FoodBarColor, "proteinBar")
                .AddStatbar(rightColumnBounds = rightColumnBounds.BelowCopy(0, 12), GuiStyle.FoodBarColor, "dairyBar")
                ;

                leftColumnBoundsW = leftColumnBoundsW.FixedUnder(leftColumnBounds, -5);
            }

            Composers["playerstats"]
            .AddStaticText(Lang.Get("Physical"), CairoFont.WhiteSmallText().WithWeight(Cairo.FontWeight.Bold), leftColumnBoundsW.WithFixedWidth(200).WithFixedOffset(0, 23))
            .Execute(() => {
                leftColumnBoundsW         = leftColumnBoundsW.FlatCopy();
                leftColumnBoundsW.fixedY += 5;
            })
            ;

            if (health != null)
            {
                Composers["playerstats"]
                .AddStaticText(Lang.Get("Health Points"), CairoFont.WhiteDetailText(), leftColumnBoundsW    = leftColumnBoundsW.BelowCopy())
                .AddDynamicText(health + " / " + maxhealth, CairoFont.WhiteDetailText(), rightColumnBoundsW = rightColumnBoundsW.FlatCopy().WithFixedPosition(rightColumnBoundsW.fixedX, leftColumnBoundsW.fixedY).WithFixedHeight(30), "health")
                ;
            }

            if (saturation != null)
            {
                Composers["playerstats"]
                .AddStaticText(Lang.Get("Satiety"), CairoFont.WhiteDetailText(), leftColumnBoundsW = leftColumnBoundsW.BelowCopy())
                .AddDynamicText((int)saturation + " / " + (int)maxsaturation, CairoFont.WhiteDetailText(), rightColumnBoundsW = rightColumnBoundsW.FlatCopy().WithFixedPosition(rightColumnBoundsW.fixedX, leftColumnBoundsW.fixedY), "satiety")
                ;
            }

            if (tempTree != null)
            {
                Composers["playerstats"]
                .AddStaticText(Lang.Get("Body Temperature"), CairoFont.WhiteDetailText(), leftColumnBoundsW = leftColumnBoundsW.BelowCopy())
                .AddRichtext(tempTree == null ? "-" : getBodyTempText(tempTree), CairoFont.WhiteDetailText(), rightColumnBoundsW = rightColumnBoundsW.FlatCopy().WithFixedPosition(rightColumnBoundsW.fixedX, leftColumnBoundsW.fixedY), "bodytemp")
                ;
            }

            if (wetnessString.Length > 0)
            {
                Composers["playerstats"]
                .AddRichtext(wetnessString, CairoFont.WhiteDetailText(), leftColumnBoundsW = leftColumnBoundsW.BelowCopy())
                ;
            }

            Composers["playerstats"]
            .AddStaticText(Lang.Get("Walk speed"), CairoFont.WhiteDetailText(), leftColumnBoundsW = leftColumnBoundsW.BelowCopy())
            .AddDynamicText((int)Math.Round(100 * walkspeed) + "%", CairoFont.WhiteDetailText(), rightColumnBoundsW = rightColumnBoundsW.FlatCopy().WithFixedPosition(rightColumnBoundsW.fixedX, leftColumnBoundsW.fixedY), "walkspeed")

            .AddStaticText(Lang.Get("Healing effectivness"), CairoFont.WhiteDetailText(), leftColumnBoundsW = leftColumnBoundsW.BelowCopy())
            .AddDynamicText((int)Math.Round(100 * healingEffectivness) + "%", CairoFont.WhiteDetailText(), rightColumnBoundsW = rightColumnBoundsW.FlatCopy().WithFixedPosition(rightColumnBoundsW.fixedX, leftColumnBoundsW.fixedY), "healeffectiveness")
            ;

            if (saturation != null)
            {
                Composers["playerstats"]
                .AddStaticText(Lang.Get("Hunger rate"), CairoFont.WhiteDetailText(), leftColumnBoundsW = leftColumnBoundsW.BelowCopy())
                .AddDynamicText((int)Math.Round(100 * hungerRate) + "%", CairoFont.WhiteDetailText(), rightColumnBoundsW = rightColumnBoundsW.FlatCopy().WithFixedPosition(rightColumnBoundsW.fixedX, leftColumnBoundsW.fixedY), "hungerrate")
                ;
            }

            Composers["playerstats"]
            .AddStaticText(Lang.Get("Ranged Accuracy"), CairoFont.WhiteDetailText(), leftColumnBoundsW = leftColumnBoundsW.BelowCopy())
            .AddDynamicText((int)Math.Round(100 * rangedWeaponAcc) + "%", CairoFont.WhiteDetailText(), rightColumnBoundsW = rightColumnBoundsW.FlatCopy().WithFixedPosition(rightColumnBoundsW.fixedX, leftColumnBoundsW.fixedY), "rangedweaponacc")

            .AddStaticText(Lang.Get("Ranged Charge Speed"), CairoFont.WhiteDetailText(), leftColumnBoundsW = leftColumnBoundsW.BelowCopy())
            .AddDynamicText((int)Math.Round(100 * rangedWeaponSpeed) + "%", CairoFont.WhiteDetailText(), rightColumnBoundsW = rightColumnBoundsW.FlatCopy().WithFixedPosition(rightColumnBoundsW.fixedX, leftColumnBoundsW.fixedY), "rangedweaponchargespeed")

            .EndChildElements()
            .Compose()
            ;

            UpdateStatBars();
        }
Exemple #15
0
        void SetupDialog()
        {
            ItemSlot hoveredSlot = capi.World.Player.InventoryManager.CurrentHoveredSlot;

            if (hoveredSlot != null && hoveredSlot.Inventory == inventory)
            {
                capi.Input.TriggerOnMouseLeaveSlot(hoveredSlot);
            }
            else
            {
                hoveredSlot = null;
            }

            string newOutputText           = attributes.GetString("outputText", "");        // inventory.GetOutputText();
            bool   newHaveCookingContainer = attributes.GetInt("haveCookingContainer") > 0; //inventory.HaveCookingContainer;

            GuiElementDynamicText outputTextElem;

            if (haveCookingContainer == newHaveCookingContainer && SingleComposer != null)
            {
                outputTextElem = SingleComposer.GetDynamicText("outputText");
                outputTextElem.SetNewText(newOutputText, true);
                SingleComposer.GetCustomDraw("symbolDrawer").Redraw();

                haveCookingContainer = newHaveCookingContainer;
                currentOutputText    = newOutputText;

                outputTextElem.Bounds.fixedOffsetY = 0;

                if (outputTextElem.QuantityTextLines > 2)
                {
                    outputTextElem.Bounds.fixedOffsetY = -outputTextElem.Font.GetFontExtents().Height;
                }
                outputTextElem.Bounds.CalcWorldBounds();

                //Console.WriteLine("new text is now " + newOutputText + ", lines = " + outputTextElem.QuantityTextLines);

                return;
            }

            //ClearComposers();


            haveCookingContainer = newHaveCookingContainer;
            currentOutputText    = newOutputText;

            int qCookingSlots = attributes.GetInt("quantityCookingSlots");

            ElementBounds stoveBounds = ElementBounds.Fixed(0, 0, 250, 250);

            cookingSlotsSlotBounds              = ElementStdBounds.SlotGrid(EnumDialogArea.None, 20, 30 + 45, 4, qCookingSlots / 4);
            cookingSlotsSlotBounds.fixedHeight += 10;

            double top = cookingSlotsSlotBounds.fixedHeight + cookingSlotsSlotBounds.fixedY;

            ElementBounds inputSlotBounds  = ElementStdBounds.SlotGrid(EnumDialogArea.None, 20, top, 1, 1);
            ElementBounds fuelSlotBounds   = ElementStdBounds.SlotGrid(EnumDialogArea.None, 20, 120 + top, 1, 1);
            ElementBounds outputSlotBounds = ElementStdBounds.SlotGrid(EnumDialogArea.None, 173, top, 1, 1);

            // 2. Around all that is 10 pixel padding
            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(ElementGeometrics.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;
            bgBounds.WithChildren(stoveBounds);

            // 3. Finally Dialog
            ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.RightMiddle)
                                         .WithFixedAlignmentOffset(-ElementGeometrics.DialogToScreenPadding, 0);


            int openedFirepits = 0;

            foreach (var val in capi.OpenedGuis)
            {
                if (val is GuiDialogBlockEntityFirepit)
                {
                    openedFirepits++;
                }
            }

            if (!capi.Settings.Bool["floatyGuis"])
            {
                //   if (openedFirepits % 3 == 1) dialogBounds.fixedOffsetY -= stoveBounds.fixedHeight + 100;
                //if (openedFirepits % 3 == 2) dialogBounds.fixedOffsetY += stoveBounds.fixedHeight + 100;
            }


            int[] cookingSlotIds = new int[qCookingSlots];
            for (int i = 0; i < qCookingSlots; i++)
            {
                cookingSlotIds[i] = 3 + i;
            }

            SingleComposer = capi.Gui
                             .CreateCompo("blockentitystove" + blockEntityPos, dialogBounds, false)
                             .AddDialogBG(bgBounds)
                             .AddDialogTitleBar(DialogTitle, OnTitleBarClose)
                             .BeginChildElements(bgBounds)
                             .AddDynamicCustomDraw(stoveBounds, OnBgDraw, "symbolDrawer")
                             .AddDynamicText("", CairoFont.WhiteDetailText(), EnumTextOrientation.Left, ElementBounds.Fixed(15, 30, 235, 45), 1, "outputText")
                             .AddIf(haveCookingContainer)
                             .AddItemSlotGrid(inventory, SendInvPacket, 4, cookingSlotIds, cookingSlotsSlotBounds, "ingredientSlots")
                             .EndIf()
                             .AddItemSlotGrid(inventory, SendInvPacket, 1, new int[] { 0 }, fuelSlotBounds, "fuelslot")
                             .AddDynamicText("", CairoFont.WhiteDetailText(), EnumTextOrientation.Left, fuelSlotBounds.RightCopy(20, 15), 1, "fueltemp")
                             .AddItemSlotGrid(inventory, SendInvPacket, 1, new int[] { 1 }, inputSlotBounds, "oreslot")
                             .AddDynamicText("", CairoFont.WhiteDetailText(), EnumTextOrientation.Left, inputSlotBounds.RightCopy(30, 15), 1, "oretemp")

                             .AddItemSlotGrid(inventory, SendInvPacket, 1, new int[] { 2 }, outputSlotBounds, "outputslot")
                             .EndChildElements()
                             .Compose()
            ;

            lastRedrawMs = capi.ElapsedMilliseconds;

            if (hoveredSlot != null)
            {
                SingleComposer.OnMouseMove(capi, new MouseEvent()
                {
                    X = capi.Input.MouseX, Y = capi.Input.MouseY
                });
            }

            outputTextElem = SingleComposer.GetDynamicText("outputText");
            outputTextElem.SetNewText(currentOutputText, true);
            outputTextElem.Bounds.fixedOffsetY = 0;

            if (outputTextElem.QuantityTextLines > 2)
            {
                outputTextElem.Bounds.fixedOffsetY = -outputTextElem.Font.GetFontExtents().Height;
            }
            outputTextElem.Bounds.CalcWorldBounds();
        }
        public void OnRenderInteractiveElements(ICoreClientAPI api, float deltaTime)
        {
            if (!composed)
            {
                Recompose();
            }

            accum1Sec += deltaTime;
            if (accum1Sec > 1)
            {
                var expireText = auction.GetExpireText(api);
                if (expireText != prevExpireText)
                {
                    expireTextElem.Components = VtmlUtil.Richtextify(api, expireText, CairoFont.WhiteDetailText().WithFontSize(14));
                    expireTextElem.RecomposeText();
                    prevExpireText = expireText;
                }
            }

            if (scissorBounds.InnerWidth <= 0 || scissorBounds.InnerHeight <= 0)
            {
                return;
            }

            // 1. Itemstack
            api.Render.PushScissor(scissorBounds, true);
            api.Render.RenderItemstackToGui(dummySlot, scissorBounds.renderX + iconSize / 2, scissorBounds.renderY + iconSize / 2, 100, iconSize * 0.55f, ColorUtil.WhiteArgb, true, false, true);
            api.Render.PopScissor();
            api.Render.Render2DTexturePremultipliedAlpha(hoverTexture.TextureId, scissorBounds.renderX, scissorBounds.renderY, scissorBounds.OuterWidth, scissorBounds.OuterHeight);

            // 2. ItemStack name, price and expire
            stackNameTextElem.RenderInteractiveElements(deltaTime);
            priceTextElem.RenderInteractiveElements(deltaTime);
            expireTextElem.RenderInteractiveElements(deltaTime);
            MouseOverCursor = expireTextElem.MouseOverCursor;

            sellerTextElem.RenderInteractiveElements(deltaTime);



            // 5. Hover overlay
            int   dx  = api.Input.MouseX;
            int   dy  = api.Input.MouseY;
            Vec2d pos = Bounds.PositionInside(dx, dy);

            if (Selected || (pos != null && IsPositionInside(api.Input.MouseX, api.Input.MouseY)))
            {
                api.Render.Render2DTexturePremultipliedAlpha(hoverTexture.TextureId, Bounds.absX, Bounds.absY, Bounds.OuterWidth, Bounds.OuterHeight);
                if (Selected)
                {
                    api.Render.Render2DTexturePremultipliedAlpha(hoverTexture.TextureId, Bounds.absX, Bounds.absY, Bounds.OuterWidth, Bounds.OuterHeight);
                }
            }
        }
Exemple #17
0
        public void Init()
        {
            var descBounds = ElementBounds.Fixed(0, 30, 400, 80);

            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;
            dialogBounds        = ElementStdBounds
                                  .AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle)
                                  .WithFixedAlignmentOffset(-GuiStyle.DialogToScreenPadding, 0);

            bgBounds.verticalSizing   = ElementSizing.FitToChildren;
            bgBounds.horizontalSizing = ElementSizing.Fixed;
            bgBounds.fixedWidth       = 300;


            #region Text
            var deliveryCosts = auctionSys.DeliveryCostsByDistance(traderEntity.Pos.XYZ, auction.SrcAuctioneerEntityPos);

            RichTextComponentBase[] stackComps = new RichTextComponentBase[] {
                new ItemstackTextComponent(capi, auction.ItemStack, 60, 10),
                new RichTextComponent(capi, auction.ItemStack.GetName() + "\r\n", CairoFont.WhiteSmallText())
            };

            stackComps = stackComps.Append(VtmlUtil.Richtextify(capi, auction.ItemStack.GetDescription(capi.World, new DummySlot(auction.ItemStack)), CairoFont.WhiteDetailText()));


            var       font              = CairoFont.WhiteDetailText();
            double    fl                = font.UnscaledFontsize;
            ItemStack gearStack         = auctionSys.SingleCurrencyStack;
            var       deliveryCostComps = new RichTextComponentBase[] {
                new RichTextComponent(capi, Lang.Get("Delivery: {0}", deliveryCosts), font)
                {
                    PaddingRight = 10, VerticalAlign = EnumVerticalAlign.Top
                },
                new ItemstackTextComponent(capi, gearStack, fl * 2.5f, 0, EnumFloat.Inline)
                {
                    VerticalAlign = EnumVerticalAlign.Top, offX = -GuiElement.scaled(fl * 0.5f), offY = -GuiElement.scaled(fl * 0.75f)
                }
            };



            RichTextComponentBase[] totalCostComps = new RichTextComponentBase[]
            {
                new RichTextComponent(capi, Lang.Get("Total Cost: {0}", auction.Price + deliveryCosts), font)
                {
                    PaddingRight = 10, VerticalAlign = EnumVerticalAlign.Top
                },
                new ItemstackTextComponent(capi, gearStack, fl * 2.5f, 0, EnumFloat.Inline)
                {
                    VerticalAlign = EnumVerticalAlign.Top, offX = -GuiElement.scaled(fl * 0.5f), offY = -GuiElement.scaled(fl * 0.75f)
                }
            };
            #endregion



            Composers["confirmauctionpurchase"] = capi.Gui
                                                  .CreateCompo("tradercreateauction-" + buyerEntity.EntityId, dialogBounds)
                                                  .AddShadedDialogBG(bgBounds, true)
                                                  .AddDialogTitleBar(Lang.Get("Purchase this item?"), OnCreateAuctionClose)
                                                  .BeginChildElements(bgBounds)
                                                  .AddRichtext(stackComps, descBounds, "itemstack")
            ;

            var ri = Composers["confirmauctionpurchase"].GetRichtext("itemstack");
            ri.BeforeCalcBounds();

            double y = Math.Max(110, descBounds.fixedHeight + 20);

            ElementBounds deliverySwitchBounds = ElementBounds.Fixed(0, y, 35, 25);
            ElementBounds deliveryTextBounds   = ElementBounds.Fixed(0, y + 3, 250, 25).FixedRightOf(deliverySwitchBounds, 0);


            ElementBounds deliveryCostBounds = ElementBounds.Fixed(0, 0, 200, 30).FixedUnder(deliveryTextBounds, 20);
            ElementBounds totalCostBounds    = ElementBounds.Fixed(0, 0, 150, 30).FixedUnder(deliveryCostBounds, 0);

            ElementBounds leftButton  = ElementBounds.Fixed(EnumDialogArea.LeftFixed, 0, 0, 0, 0).WithFixedPadding(8, 5).FixedUnder(totalCostBounds, 15);
            ElementBounds rightButton = ElementBounds.Fixed(EnumDialogArea.RightFixed, 0, 0, 0, 0).WithFixedPadding(8, 5).FixedUnder(totalCostBounds, 15);


            Composers["confirmauctionpurchase"]
            .AddSwitch(onDeliveryModeChanged, deliverySwitchBounds, "delivery", 25)
            .AddStaticText(Lang.Get("Deliver to current trader"), CairoFont.WhiteSmallText(), deliveryTextBounds)


            .AddRichtext(deliveryCostComps, deliveryCostBounds, "deliveryCost")
            .AddRichtext(totalCostComps, totalCostBounds, "totalCost")

            .AddSmallButton(Lang.Get("Cancel"), OnCancel, leftButton)
            .AddSmallButton(Lang.Get("Purchase"), OnPurchase, rightButton, EnumButtonStyle.Normal, EnumTextOrientation.Left, "buysellButton")
            .EndChildElements()
            .Compose()
            ;

            Composers["confirmauctionpurchase"].GetSwitch("delivery").On = true;
        }
Exemple #18
0
        public GuiDialogSignPost(string DialogTitle, BlockPos blockEntityPos, string[] textByCardinalDirection, ICoreClientAPI capi, CairoFont signPostFont) : base(DialogTitle, capi)
        {
            this.signPostFont   = signPostFont;
            this.blockEntityPos = blockEntityPos;

            ElementBounds line  = ElementBounds.Fixed(0, 0, 150, 20);
            ElementBounds input = ElementBounds.Fixed(0, 15, 150, 25);

            // 2. Around all that is 10 pixel padding
            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;

            // 3. Finally Dialog
            ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.LeftTop)
                                         .WithFixedAlignmentOffset(60 + GuiStyle.DialogToScreenPadding, GuiStyle.DialogToScreenPadding);


            float inputLineY = 27;
            float textLineY  = 32;
            float width      = 250;

            SingleComposer = capi.Gui
                             .CreateCompo("blockentitytexteditordialog", dialogBounds)
                             .AddShadedDialogBG(bgBounds)
                             .AddDialogTitleBar(DialogTitle, OnTitleBarClose)
                             .BeginChildElements(bgBounds)

                             .AddStaticText("North", CairoFont.WhiteDetailText(), line = line.BelowCopy(0, 0).WithFixedWidth(width))
                             .AddTextInput(input = input.BelowCopy(0, 0).WithFixedWidth(width), OnTextChangedDlg, CairoFont.WhiteSmallText(), "text0")

                             .AddStaticText("Northeast", CairoFont.WhiteDetailText(), line = line.BelowCopy(0, textLineY).WithFixedWidth(width))
                             .AddTextInput(input = input.BelowCopy(0, inputLineY).WithFixedWidth(width), OnTextChangedDlg, CairoFont.WhiteSmallText(), "text1")

                             .AddStaticText("East", CairoFont.WhiteDetailText(), line = line.BelowCopy(0, textLineY).WithFixedWidth(width))
                             .AddTextInput(input = input.BelowCopy(0, inputLineY).WithFixedWidth(width), OnTextChangedDlg, CairoFont.WhiteSmallText(), "text2")

                             .AddStaticText("Southeast", CairoFont.WhiteDetailText(), line = line.BelowCopy(0, textLineY).WithFixedWidth(width))
                             .AddTextInput(input = input.BelowCopy(0, inputLineY).WithFixedWidth(width), OnTextChangedDlg, CairoFont.WhiteSmallText(), "text3")

                             .AddStaticText("South", CairoFont.WhiteDetailText(), line = line.BelowCopy(0, textLineY).WithFixedWidth(width))
                             .AddTextInput(input = input.BelowCopy(0, inputLineY).WithFixedWidth(width), OnTextChangedDlg, CairoFont.WhiteSmallText(), "text4")

                             .AddStaticText("Southwest", CairoFont.WhiteDetailText(), line = line.BelowCopy(0, textLineY).WithFixedWidth(width))
                             .AddTextInput(input = input.BelowCopy(0, inputLineY).WithFixedWidth(width), OnTextChangedDlg, CairoFont.WhiteSmallText(), "text5")

                             .AddStaticText("West", CairoFont.WhiteDetailText(), line = line.BelowCopy(0, textLineY).WithFixedWidth(width))
                             .AddTextInput(input = input.BelowCopy(0, inputLineY).WithFixedWidth(width), OnTextChangedDlg, CairoFont.WhiteSmallText(), "text6")

                             .AddStaticText("Northwest", CairoFont.WhiteDetailText(), line = line.BelowCopy(0, textLineY).WithFixedWidth(width))
                             .AddTextInput(input = input.BelowCopy(0, inputLineY).WithFixedWidth(width), OnTextChangedDlg, CairoFont.WhiteSmallText(), "text7")

                             .AddSmallButton(Lang.Get("Cancel"), OnButtonCancel, input = input.BelowCopy(0, 20).WithFixedSize(100, 20).WithAlignment(EnumDialogArea.LeftFixed).WithFixedPadding(10, 2), EnumButtonStyle.Normal, EnumTextOrientation.Center)
                             .AddSmallButton(Lang.Get("Save"), OnButtonSave, input     = input.FlatCopy().WithFixedSize(100, 20).WithAlignment(EnumDialogArea.RightFixed).WithFixedPadding(10, 2), EnumButtonStyle.Normal, EnumTextOrientation.Center)
                             .EndChildElements()
                             .Compose()
            ;

            for (int i = 0; i < 8; i++)
            {
                GuiElementTextInput texinput = SingleComposer.GetTextInput("text" + i);
                texinput.SetValue(textByCardinalDirection[i]);
            }
        }
        private void ComposeDialog()
        {
            ElementBounds mapBounds = ElementBounds.Fixed(0, 28, 1200, 800);
            ElementBounds layerList = mapBounds.RightCopy().WithFixedSize(1, 350);

            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(3);

            bgBounds.BothSizing = ElementSizing.FitToChildren;
            bgBounds.WithChildren(mapBounds, layerList);

            ElementBounds dialogBounds =
                ElementStdBounds.AutosizedMainDialog
                .WithAlignment(EnumDialogArea.CenterMiddle)
                .WithFixedAlignmentOffset(-GuiStyle.DialogToScreenPadding, 0);

            if (dialogType == EnumDialogType.HUD)
            {
                mapBounds = ElementBounds.Fixed(0, 0, 250, 250);

                bgBounds            = ElementBounds.Fill.WithFixedPadding(2);
                bgBounds.BothSizing = ElementSizing.FitToChildren;
                bgBounds.WithChildren(mapBounds);

                dialogBounds =
                    ElementStdBounds.AutosizedMainDialog
                    .WithAlignment(EnumDialogArea.RightTop)
                    .WithFixedAlignmentOffset(-GuiStyle.DialogToScreenPadding, GuiStyle.DialogToScreenPadding);
            }

            Vec3d centerPos = capi.World.Player.Entity.Pos.XYZ;

            if (SingleComposer != null)
            {
                SingleComposer.Dispose();
            }

            SingleComposer = capi.Gui
                             .CreateCompo("worldmap", dialogBounds)
                             .AddShadedDialogBG(bgBounds, false)
                             .AddIf(dialogType == EnumDialogType.Dialog)
                             .AddDialogTitleBar("World Map", OnTitleBarClose)
                             .AddInset(mapBounds, 2)
                             .EndIf()
                             .BeginChildElements(bgBounds)
                             .AddHoverText("", CairoFont.WhiteDetailText(), 350, mapBounds.FlatCopy(), "hoverText")
                             .AddInteractiveElement(new GuiElementMap(mapComponents, centerPos, capi, mapBounds), "mapElem")
                             .EndChildElements()
                             .Compose()
            ;
            SingleComposer.OnRecomposed += SingleComposer_OnRecomposed;

            mapElem = SingleComposer.GetElement("mapElem") as GuiElementMap;

            mapElem.viewChanged = viewChanged;
            mapElem.ZoomAdd(1, 0.5f, 0.5f);


            hoverTextElem = SingleComposer.GetHoverText("hoverText");
            hoverTextElem.SetAutoWidth(true);

            if (listenerId != 0)
            {
                capi.Event.UnregisterGameTickListener(listenerId);
            }

            listenerId = capi.Event.RegisterGameTickListener(
                (dt) => {
                mapElem.EnsureMapFullyLoaded();
                if (requireRecompose)
                {
                    TryClose();
                    TryOpen();
                    requireRecompose = false;
                }
            }
                , 100);
        }
        public void Compose()
        {
            var tabs = new GuiTab[] { new GuiTab()
                                      {
                                          Name = Lang.Get("Local goods"), DataInt = 0
                                      }, new GuiTab()
                                      {
                                          Name = Lang.Get("Auction house"), DataInt = 1
                                      }, new GuiTab()
                                      {
                                          Name = Lang.Get("Your Auctions"), DataInt = 2
                                      } };
            var tabBounds = ElementBounds.Fixed(0, -24, 500, 25);
            var tabFont   = CairoFont.WhiteDetailText();

            if (!auctionHouseEnabled)
            {
                tabs = new GuiTab[] { new GuiTab()
                                      {
                                          Name = Lang.Get("Local goods"), DataInt = 0
                                      } };
            }


            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;
            ElementBounds dialogBounds = ElementStdBounds
                                         .AutosizedMainDialog.WithAlignment(EnumDialogArea.RightMiddle)
                                         .WithFixedAlignmentOffset(-GuiStyle.DialogToScreenPadding, 0);


            ElementBounds leftButton  = ElementBounds.Fixed(EnumDialogArea.LeftFixed, 0, 0, 0, 0).WithFixedPadding(8, 5);
            ElementBounds rightButton = ElementBounds.Fixed(EnumDialogArea.RightFixed, 0, 0, 0, 0).WithFixedPadding(8, 5);


            string traderName = owningEntity.GetBehavior <EntityBehaviorNameTag>().DisplayName;
            string dlgTitle   = Lang.Get("tradingwindow-" + owningEntity.Code.Path, traderName);

            if (curTab > 0)
            {
                dlgTitle = Lang.Get("tradertabtitle-" + curTab);
            }

            SingleComposer =
                capi.Gui
                .CreateCompo("traderdialog-" + owningEntity.EntityId, dialogBounds)
                .AddShadedDialogBG(bgBounds, true)
                .AddDialogTitleBar(dlgTitle, OnTitleBarClose)
                .AddHorizontalTabs(tabs, tabBounds, OnTabClicked, tabFont, tabFont.Clone().WithColor(GuiStyle.ActiveButtonTextColor), "tabs")
                .BeginChildElements(bgBounds)
            ;

            SingleComposer.GetHorizontalTabs("tabs").activeElement = curTab;

            if (curTab == 0)
            {
                double pad = GuiElementItemSlotGrid.unscaledSlotPadding;

                ElementBounds leftTopSlotBounds  = ElementStdBounds.SlotGrid(EnumDialogArea.None, pad, 70 + pad, cols, rows).FixedGrow(2 * pad, 2 * pad);
                ElementBounds rightTopSlotBounds = ElementStdBounds.SlotGrid(EnumDialogArea.None, pad + leftTopSlotBounds.fixedWidth + 20, 70 + pad, cols, rows).FixedGrow(2 * pad, 2 * pad);

                ElementBounds rightBotSlotBounds = ElementStdBounds
                                                   .SlotGrid(EnumDialogArea.None, pad + leftTopSlotBounds.fixedWidth + 20, 15 + pad, cols, 1)
                                                   .FixedGrow(2 * pad, 2 * pad)
                                                   .FixedUnder(rightTopSlotBounds, 5)
                ;

                ElementBounds leftBotSlotBounds = ElementStdBounds
                                                  .SlotGrid(EnumDialogArea.None, pad, 15 + pad, cols, 1)
                                                  .FixedGrow(2 * pad, 2 * pad)
                                                  .FixedUnder(leftTopSlotBounds, 5)
                ;

                ElementBounds costTextBounds  = ElementBounds.Fixed(pad, 85 + 2 * pad + leftTopSlotBounds.fixedHeight + leftBotSlotBounds.fixedHeight, 200, 25);
                ElementBounds offerTextBounds = ElementBounds.Fixed(leftTopSlotBounds.fixedWidth + pad + 20, 85 + 2 * pad + leftTopSlotBounds.fixedHeight + leftBotSlotBounds.fixedHeight, 200, 25);

                ElementBounds traderMoneyBounds = offerTextBounds.FlatCopy().WithFixedOffset(0, offerTextBounds.fixedHeight);
                ElementBounds playerMoneyBounds = costTextBounds.FlatCopy().WithFixedOffset(0, costTextBounds.fixedHeight);


                double daysLeft       = (owningEntity as EntityTrader).NextRefreshTotalDays();
                string daysLeftString = daysLeft < 1 ? Lang.Get("Delievery of new goods in less than 1 day") : Lang.Get("Delievery of new goods in {0} days", (int)daysLeft);

                CairoFont deliveryTextFont = CairoFont.WhiteDetailText();
                deliveryTextFont.Color[3] *= 0.7;

                SingleComposer
                .AddStaticText(daysLeftString, deliveryTextFont, ElementBounds.Fixed(pad, 20 + pad, 500, 25))

                .AddStaticText(Lang.Get("You can Buy"), CairoFont.WhiteDetailText(), ElementBounds.Fixed(pad, 50 + pad, 200, 25))
                .AddStaticText(Lang.Get("You can Sell"), CairoFont.WhiteDetailText(), ElementBounds.Fixed(leftTopSlotBounds.fixedWidth + pad + 20, 50 + pad, 200, 25))

                .AddItemSlotGrid(traderInventory, DoSendPacket, cols, (new int[rows * cols]).Fill(i => i), leftTopSlotBounds, "traderSellingSlots")
                .AddItemSlotGrid(traderInventory, DoSendPacket, cols, (new int[cols]).Fill(i => rows * cols + i), leftBotSlotBounds, "playerBuyingSlots")

                .AddItemSlotGrid(traderInventory, DoSendPacket, cols, (new int[rows * cols]).Fill(i => rows * cols + cols + i), rightTopSlotBounds, "traderBuyingSlots")
                .AddItemSlotGrid(traderInventory, DoSendPacket, cols, (new int[cols]).Fill(i => rows * cols + cols + rows * cols + i), rightBotSlotBounds, "playerSellingSlots")

                .AddStaticText(Lang.Get("trader-yourselection"), CairoFont.WhiteDetailText(), ElementBounds.Fixed(pad, 70 + 2 * pad + leftTopSlotBounds.fixedHeight, 150, 25))
                .AddStaticText(Lang.Get("trader-youroffer"), CairoFont.WhiteDetailText(), ElementBounds.Fixed(leftTopSlotBounds.fixedWidth + pad + 20, 70 + 2 * pad + leftTopSlotBounds.fixedHeight, 150, 25))

                // Cost
                .AddDynamicText("", CairoFont.WhiteDetailText(), costTextBounds, "costText")
                // Player money
                .AddDynamicText("", CairoFont.WhiteDetailText(), playerMoneyBounds, "playerMoneyText")
                // Offer
                .AddDynamicText("", CairoFont.WhiteDetailText(), offerTextBounds, "gainText")
                // Trader money
                .AddDynamicText("", CairoFont.WhiteDetailText(), traderMoneyBounds, "traderMoneyText")

                .AddSmallButton(Lang.Get("Goodbye!"), OnByeClicked, leftButton.FixedUnder(playerMoneyBounds, 20))
                .AddSmallButton(Lang.Get("Buy / Sell"), OnBuySellClicked, rightButton.FixedUnder(traderMoneyBounds, 20), EnumButtonStyle.Normal, EnumTextOrientation.Left, "buysellButton")

                .EndChildElements()
                .Compose()
                ;

                SingleComposer.GetButton("buysellButton").Enabled = false;
                CalcAndUpdateAssetsDisplay();
                return;
            }

            double        listHeight      = 377;
            ElementBounds stackListBounds = ElementBounds.Fixed(0, 25, 700, listHeight); //.FixedUnder(searchFieldBounds, 5);

            clipBounds = stackListBounds.ForkBoundingParent();
            ElementBounds insetBounds = stackListBounds.FlatCopy().FixedGrow(3).WithFixedOffset(0, 0);

            ElementBounds scrollbarBounds = insetBounds.CopyOffsetedSibling(3 + stackListBounds.fixedWidth + 7).WithFixedWidth(20);

            if (curTab == 1)
            {
                auctions = auctionSys.activeAuctions;

                SingleComposer
                .BeginClip(clipBounds)
                .AddInset(insetBounds, 3)
                .AddCellList(stackListBounds, createCell, auctionSys.activeAuctions, "stacklist")
                .EndClip()
                .AddVerticalScrollbar(OnNewScrollbarValue, scrollbarBounds, "scrollbar")

                .AddSmallButton(Lang.Get("Goodbye!"), OnByeClicked, leftButton.FixedUnder(clipBounds, 20))
                .AddSmallButton(Lang.Get("Buy"), OnBuyAuctionClicked, rightButton.FixedUnder(clipBounds, 20), EnumButtonStyle.Normal, EnumTextOrientation.Left, "buyauction")
                ;
            }

            if (curTab == 2)
            {
                auctions = auctionSys.ownAuctions;

                ElementBounds button    = ElementBounds.Fixed(EnumDialogArea.RightFixed, 0, 0, 0, 0).WithFixedPadding(8, 5);
                string        placeStr  = Lang.Get("Place Auction");
                string        cancelStr = Lang.Get("Cancel Auction");

                double placelen  = CairoFont.ButtonText().GetTextExtents(placeStr).Width / RuntimeEnv.GUIScale;
                double cancellen = CairoFont.ButtonText().GetTextExtents(cancelStr).Width / RuntimeEnv.GUIScale;

                SingleComposer
                .BeginClip(clipBounds)
                .AddInset(insetBounds, 3)
                .AddCellList(stackListBounds, createCell, auctionSys.ownAuctions, "stacklist")
                .EndClip()
                .AddVerticalScrollbar(OnNewScrollbarValue, scrollbarBounds, "scrollbar")

                .AddSmallButton(Lang.Get("Goodbye!"), OnByeClicked, leftButton.FixedUnder(clipBounds, 20))
                .AddSmallButton(Lang.Get("Place Auction"), OnCreateAuction, rightButton.FixedUnder(clipBounds, 20), EnumButtonStyle.Normal, EnumTextOrientation.Left, "placeAuction")
                .AddSmallButton(cancelStr, OnCancelAuction, button.FlatCopy().FixedUnder(clipBounds, 20).WithFixedAlignmentOffset(-placelen, 0), EnumButtonStyle.Normal, EnumTextOrientation.Center, "cancelAuction")
                .AddSmallButton(Lang.Get("Collect Funds"), OnCollectFunds, button.FlatCopy().FixedUnder(clipBounds, 20).WithFixedAlignmentOffset(-placelen, 0), EnumButtonStyle.Normal, EnumTextOrientation.Center, "collectFunds")
                .AddSmallButton(Lang.Get("Retrieve Items"), OnRetrieveItems, button.FixedUnder(clipBounds, 20).WithFixedAlignmentOffset(-placelen, 0), EnumButtonStyle.Normal, EnumTextOrientation.Center, "retrieveItems")
                ;
            }

            if (curTab == 1 || curTab == 2)
            {
                selectedElem = null;
                listElem     = SingleComposer.GetCellList <Auction>("stacklist");
                listElem.BeforeCalcBounds();
                listElem.UnscaledCellVerPadding = 0;
                listElem.unscaledCellSpacing    = 5;
                SingleComposer.EndChildElements().Compose();

                updateScrollbarBounds();


                didClickAuctionElem(-1);
            }
        }
Exemple #21
0
        void SetupDialog()
        {
            ItemSlot hoveredSlot = capi.World.Player.InventoryManager.CurrentHoveredSlot;

            if (hoveredSlot != null && hoveredSlot.Inventory?.InventoryID != Inventory?.InventoryID)
            {
                //capi.Input.TriggerOnMouseLeaveSlot(hoveredSlot); - wtf is this for?
                hoveredSlot = null;
            }



            string newOutputText           = Attributes.GetString("outputText", "");
            bool   newHaveCookingContainer = Attributes.GetInt("haveCookingContainer") > 0;

            GuiElementDynamicText outputTextElem;

            if (haveCookingContainer == newHaveCookingContainer && SingleComposer != null)
            {
                outputTextElem = SingleComposer.GetDynamicText("outputText");
                outputTextElem.SetNewText(newOutputText, true);
                SingleComposer.GetCustomDraw("symbolDrawer").Redraw();

                haveCookingContainer = newHaveCookingContainer;
                currentOutputText    = newOutputText;

                outputTextElem.Bounds.fixedOffsetY = 0;

                if (outputTextElem.QuantityTextLines > 2)
                {
                    outputTextElem.Bounds.fixedOffsetY = -outputTextElem.Font.GetFontExtents().Height / RuntimeEnv.GUIScale * 0.65;
                }

                outputTextElem.Bounds.CalcWorldBounds();

                return;
            }


            haveCookingContainer = newHaveCookingContainer;
            currentOutputText    = newOutputText;

            int qCookingSlots = Attributes.GetInt("quantityCookingSlots");

            ElementBounds stoveBounds = ElementBounds.Fixed(0, 0, 210, 250);

            cookingSlotsSlotBounds              = ElementStdBounds.SlotGrid(EnumDialogArea.None, 0, 30 + 45, 4, qCookingSlots / 4);
            cookingSlotsSlotBounds.fixedHeight += 10;

            double top = cookingSlotsSlotBounds.fixedHeight + cookingSlotsSlotBounds.fixedY;

            ElementBounds inputSlotBounds  = ElementStdBounds.SlotGrid(EnumDialogArea.None, 0, top, 1, 1);
            ElementBounds fuelSlotBounds   = ElementStdBounds.SlotGrid(EnumDialogArea.None, 0, 110 + top, 1, 1);
            ElementBounds outputSlotBounds = ElementStdBounds.SlotGrid(EnumDialogArea.None, 153, top, 1, 1);

            // 2. Around all that is 10 pixel padding
            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;
            bgBounds.WithChildren(stoveBounds);

            // 3. Finally Dialog
            ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog
                                         .WithFixedAlignmentOffset(IsRight(screenPos) ? -GuiStyle.DialogToScreenPadding : GuiStyle.DialogToScreenPadding, 0)
                                         .WithAlignment(IsRight(screenPos) ? EnumDialogArea.RightMiddle : EnumDialogArea.LeftMiddle)
            ;


            if (!capi.Settings.Bool["immersiveMouseMode"])
            {
                dialogBounds.fixedOffsetY += (stoveBounds.fixedHeight + 65 + (haveCookingContainer ? 25 : 0)) * YOffsetMul(screenPos);
            }


            int[] cookingSlotIds = new int[qCookingSlots];
            for (int i = 0; i < qCookingSlots; i++)
            {
                cookingSlotIds[i] = 3 + i;
            }

            SingleComposer = capi.Gui
                             .CreateCompo("blockentitystove" + BlockEntityPosition, dialogBounds)
                             .AddShadedDialogBG(bgBounds)
                             .AddDialogTitleBar(DialogTitle, OnTitleBarClose)
                             .BeginChildElements(bgBounds)
                             .AddDynamicCustomDraw(stoveBounds, OnBgDraw, "symbolDrawer")
                             .AddDynamicText("", CairoFont.WhiteDetailText(), EnumTextOrientation.Left, ElementBounds.Fixed(0, 30, 210, 45), "outputText")
                             .AddIf(haveCookingContainer)
                             .AddItemSlotGrid(Inventory, SendInvPacket, 4, cookingSlotIds, cookingSlotsSlotBounds, "ingredientSlots")
                             .EndIf()
                             .AddItemSlotGrid(Inventory, SendInvPacket, 1, new int[] { 0 }, fuelSlotBounds, "fuelslot")
                             .AddDynamicText("", CairoFont.WhiteDetailText(), EnumTextOrientation.Left, fuelSlotBounds.RightCopy(17, 16).WithFixedSize(60, 30), "fueltemp")
                             .AddItemSlotGrid(Inventory, SendInvPacket, 1, new int[] { 1 }, inputSlotBounds, "oreslot")
                             .AddDynamicText("", CairoFont.WhiteDetailText(), EnumTextOrientation.Left, inputSlotBounds.RightCopy(23, 16).WithFixedSize(60, 30), "oretemp")

                             .AddItemSlotGrid(Inventory, SendInvPacket, 1, new int[] { 2 }, outputSlotBounds, "outputslot")
                             .EndChildElements()
                             .Compose();

            lastRedrawMs = capi.ElapsedMilliseconds;

            if (hoveredSlot != null)
            {
                SingleComposer.OnMouseMove(new MouseEvent(capi.Input.MouseX, capi.Input.MouseY));
            }

            outputTextElem = SingleComposer.GetDynamicText("outputText");
            outputTextElem.SetNewText(currentOutputText, true);
            outputTextElem.Bounds.fixedOffsetY = 0;

            if (outputTextElem.QuantityTextLines > 2)
            {
                outputTextElem.Bounds.fixedOffsetY = -outputTextElem.Font.GetFontExtents().Height / RuntimeEnv.GUIScale * 0.65;
            }
            outputTextElem.Bounds.CalcWorldBounds();
        }
        private void Compose()
        {
            ClearComposers();

            ElementBounds creatureTextBounds = ElementBounds.Fixed(0, 30, 300, 25);

            ElementBounds dropDownBounds = ElementBounds.Fixed(0, 0, 300, 28).FixedUnder(creatureTextBounds, 0);


            ElementBounds areaTextBounds = ElementBounds.Fixed(0, 30, 300, 25).FixedUnder(dropDownBounds, 0);

            ElementBounds closeButtonBounds = ElementBounds
                                              .FixedSize(0, 0)
                                              .WithAlignment(EnumDialogArea.LeftFixed)
                                              .WithFixedPadding(20, 4)
            ;

            ElementBounds saveButtonBounds = ElementBounds
                                             .FixedSize(0, 0)
                                             .WithAlignment(EnumDialogArea.RightFixed)
                                             .WithFixedPadding(20, 4)
            ;


            // 2. Around all that is 10 pixel padding
            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(ElementGeometrics.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;
            bgBounds.WithChildren(dropDownBounds, creatureTextBounds, closeButtonBounds, saveButtonBounds);

            // 3. Finally Dialog
            ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle);

            List <string> entityCodes = new List <string>();
            List <string> entityNames = new List <string>();

            entityCodes.Add("");
            entityNames.Add("-");

            foreach (EntityProperties type in capi.World.EntityTypes)
            {
                entityCodes.Add(type.Code.ToString());
                entityNames.Add(Lang.Get("item-creature-" + type.Code.Path));
            }


            ElementBounds tmpBoundsDim1;
            ElementBounds tmpBoundsDim2;
            ElementBounds tmpBoundsDim3;

            SingleComposer = capi.Gui
                             .CreateCompo("spawnwerconfig", dialogBounds, false)
                             .AddDialogBG(bgBounds, true)
                             .AddDialogTitleBar(DialogTitle, OnTitleBarClose)
                             .AddStaticText("Entity to spawn", CairoFont.WhiteDetailText(), creatureTextBounds)
                             .AddDropDown(entityCodes.ToArray(), entityNames.ToArray(), 0, didSelectEntity, dropDownBounds, "entityCode")

                             .AddStaticText("Spawn area dimensions", CairoFont.WhiteDetailText(), tmpBoundsDim1 = dropDownBounds.BelowCopy(0, 10))
                             .AddStaticText("X1", CairoFont.WhiteDetailText(), tmpBoundsDim1 = tmpBoundsDim1.BelowCopy(0, 7).WithFixedSize(20, 29))
                             .AddNumberInput(tmpBoundsDim1 = tmpBoundsDim1.RightCopy(5, -7).WithFixedSize(60, 29), OnDimensionsChanged, CairoFont.WhiteDetailText(), "x1")
                             .AddStaticText("Y1", CairoFont.WhiteDetailText(), tmpBoundsDim1 = tmpBoundsDim1.RightCopy(10, 7).WithFixedSize(20, 29))
                             .AddNumberInput(tmpBoundsDim1 = tmpBoundsDim1.RightCopy(5, -7).WithFixedSize(60, 29), OnDimensionsChanged, CairoFont.WhiteDetailText(), "y1")
                             .AddStaticText("Z1", CairoFont.WhiteDetailText(), tmpBoundsDim1 = tmpBoundsDim1.RightCopy(10, 7).WithFixedSize(20, 29))
                             .AddNumberInput(tmpBoundsDim1 = tmpBoundsDim1.RightCopy(5, -7).WithFixedSize(60, 29), OnDimensionsChanged, CairoFont.WhiteDetailText(), "z1")

                             .AddStaticText("X2", CairoFont.WhiteDetailText(), tmpBoundsDim2 = dropDownBounds.FlatCopy().WithFixedSize(20, 29).FixedUnder(tmpBoundsDim1, -40))
                             .AddNumberInput(tmpBoundsDim2 = tmpBoundsDim2.RightCopy(5, -7).WithFixedSize(60, 29), OnDimensionsChanged, CairoFont.WhiteDetailText(), "x2")
                             .AddStaticText("Y2", CairoFont.WhiteDetailText(), tmpBoundsDim2 = tmpBoundsDim2.RightCopy(10, 7).WithFixedSize(20, 29))
                             .AddNumberInput(tmpBoundsDim2 = tmpBoundsDim2.RightCopy(5, -7).WithFixedSize(60, 29), OnDimensionsChanged, CairoFont.WhiteDetailText(), "y2")
                             .AddStaticText("Z2", CairoFont.WhiteDetailText(), tmpBoundsDim2 = tmpBoundsDim2.RightCopy(10, 7).WithFixedSize(20, 29))
                             .AddNumberInput(tmpBoundsDim2 = tmpBoundsDim2.RightCopy(5, -7).WithFixedSize(60, 29), OnDimensionsChanged, CairoFont.WhiteDetailText(), "z2")

                             .AddStaticText("Interval (ingame hours)", CairoFont.WhiteDetailText(), tmpBoundsDim3 = dropDownBounds.FlatCopy().WithFixedSize(300, 30).FixedUnder(tmpBoundsDim2, -40))
                             .AddNumberInput(tmpBoundsDim3 = tmpBoundsDim3.BelowCopy(0, -10).WithFixedSize(100, 29), OnIntervalChanged, CairoFont.WhiteDetailText(), "interval")

                             .AddStaticText("Max concurrent entities to spawn", CairoFont.WhiteDetailText(), tmpBoundsDim3 = tmpBoundsDim3.BelowCopy(0, 10).WithFixedSize(300, 30))
                             .AddNumberInput(tmpBoundsDim3 = tmpBoundsDim3.BelowCopy(0, -10).WithFixedSize(100, 29), OnMaxChanged, CairoFont.WhiteDetailText(), "maxentities")


                             .AddSmallButton("Close", OnButtonClose, closeButtonBounds.FixedUnder(tmpBoundsDim3, 20))
                             .AddSmallButton("Save", OnButtonSave, saveButtonBounds.FixedUnder(tmpBoundsDim3, 20))
                             .Compose()
            ;

            UpdateFromServer(this.spawnerData);
        }
        public GuiDialogItemLootRandomizer(ItemStack[] stacks, float[] chances, ICoreClientAPI capi) : base("Item Loot Randomizer", capi)
        {
            double pad = GuiElementItemSlotGrid.unscaledSlotPadding;

            ElementBounds slotBounds = ElementStdBounds.SlotGrid(EnumDialogArea.None, pad, 45 + pad, 10, 1).FixedGrow(2 * pad, 2 * pad);

            ElementBounds chanceInputBounds = ElementBounds.Fixed(3, 0, 48, 30).FixedUnder(slotBounds, -4);

            ElementBounds leftButton       = ElementBounds.Fixed(EnumDialogArea.LeftFixed, 0, 0, 0, 0).WithFixedPadding(10, 1);
            ElementBounds chanceTextBounds = ElementBounds.Fixed(EnumDialogArea.CenterFixed, 0, 0, 150, 30).WithFixedPadding(10, 1);
            ElementBounds rightButton      = ElementBounds.Fixed(EnumDialogArea.RightFixed, 0, 0, 0, 0).WithFixedPadding(10, 1);

            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(ElementGeometrics.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;

            inv = new InventoryGeneric(10, "lootrandomizer-1", capi, null);
            for (int i = 0; i < 10; i++)
            {
                inv.GetSlot(i).Itemstack = stacks[i];
            }

            ElementBounds dialogBounds = ElementStdBounds
                                         .AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle)
                                         .WithFixedAlignmentOffset(ElementGeometrics.DialogToScreenPadding, 0);

            float  totalChance = chances.Sum();
            string text        = "Total chance: " + (int)totalChance + "%";

            SingleComposer = capi.Gui
                             .CreateCompo("itemlootrandomizer", dialogBounds, false)
                             .AddDialogBG(bgBounds, true)
                             .AddDialogTitleBar("Item Loot Randomizer", OnTitleBarClose)
                             .BeginChildElements(bgBounds)
                             .AddItemSlotGrid(inv, SendInvPacket, 10, slotBounds, "slots")
                             .AddNumberInput(chanceInputBounds = chanceInputBounds.FlatCopy(), (t) => OnTextChanced(0), CairoFont.WhiteDetailText(), "chance1")
                             .AddNumberInput(chanceInputBounds = chanceInputBounds.RightCopy(3), (t) => OnTextChanced(1), CairoFont.WhiteDetailText(), "chance2")
                             .AddNumberInput(chanceInputBounds = chanceInputBounds.RightCopy(3), (t) => OnTextChanced(2), CairoFont.WhiteDetailText(), "chance3")
                             .AddNumberInput(chanceInputBounds = chanceInputBounds.RightCopy(3), (t) => OnTextChanced(3), CairoFont.WhiteDetailText(), "chance4")
                             .AddNumberInput(chanceInputBounds = chanceInputBounds.RightCopy(3), (t) => OnTextChanced(4), CairoFont.WhiteDetailText(), "chance5")
                             .AddNumberInput(chanceInputBounds = chanceInputBounds.RightCopy(3), (t) => OnTextChanced(5), CairoFont.WhiteDetailText(), "chance6")
                             .AddNumberInput(chanceInputBounds = chanceInputBounds.RightCopy(3), (t) => OnTextChanced(6), CairoFont.WhiteDetailText(), "chance7")
                             .AddNumberInput(chanceInputBounds = chanceInputBounds.RightCopy(3), (t) => OnTextChanced(7), CairoFont.WhiteDetailText(), "chance8")
                             .AddNumberInput(chanceInputBounds = chanceInputBounds.RightCopy(3), (t) => OnTextChanced(8), CairoFont.WhiteDetailText(), "chance9")
                             .AddNumberInput(chanceInputBounds = chanceInputBounds.RightCopy(3), (t) => OnTextChanced(9), CairoFont.WhiteDetailText(), "chance10")

                             .AddButton("Close", OnCloseClicked, leftButton.FixedUnder(chanceInputBounds, 25))
                             .AddDynamicText(text, CairoFont.WhiteDetailText(), EnumTextOrientation.Left, chanceTextBounds.FixedUnder(chanceInputBounds, 25), 1, "totalchance")
                             .AddButton("Save", OnSaveClicked, rightButton.FixedUnder(chanceInputBounds, 25))


                             .EndChildElements()
                             .Compose()
            ;

            for (int i = 0; i < 10; i++)
            {
                GuiElementNumberInput inp = SingleComposer.GetNumberInput("chance" + (i + 1));
                inp.SetValue("" + chances[i]);
            }



            SingleComposer.GetSlotGrid("slots").CanClickSlot = OnCanClickSlot;
        }
        void changeClass(int dir)
        {
            currentClassIndex = GameMath.Mod(currentClassIndex + dir, modSys.characterClasses.Count);

            CharacterClass chclass = modSys.characterClasses[currentClassIndex];

            Composers["createcharacter"].GetDynamicText("className").SetNewText(Lang.Get("characterclass-" + chclass.Code));

            StringBuilder fulldesc   = new StringBuilder();
            StringBuilder attributes = new StringBuilder();

            fulldesc.AppendLine(Lang.Get("characterdesc-" + chclass.Code));
            fulldesc.AppendLine();
            fulldesc.AppendLine(Lang.Get("traits-title"));

            var chartraits = chclass.Traits.Select(code => modSys.TraitsByCode[code]).OrderBy(trait => (int)trait.Type);

            foreach (var trait in chartraits)
            {
                attributes.Clear();
                foreach (var val in trait.Attributes)
                {
                    if (attributes.Length > 0)
                    {
                        attributes.Append(", ");
                    }
                    attributes.Append(Lang.Get(string.Format(GlobalConstants.DefaultCultureInfo, "charattribute-{0}-{1}", val.Key, val.Value)));
                }

                if (attributes.Length > 0)
                {
                    fulldesc.AppendLine(Lang.Get("traitwithattributes", Lang.Get("trait-" + trait.Code), attributes));
                }
                else
                {
                    string desc = Lang.GetIfExists("traitdesc-" + trait.Code);
                    if (desc != null)
                    {
                        fulldesc.AppendLine(Lang.Get("traitwithattributes", Lang.Get("trait-" + trait.Code), desc));
                    }
                    else
                    {
                        fulldesc.AppendLine(Lang.Get("trait-" + trait.Code));
                    }
                }
            }

            if (chclass.Traits.Length == 0)
            {
                fulldesc.AppendLine("No positive or negative traits");
            }

            Composers["createcharacter"].GetRichtext("characterDesc").SetNewText(fulldesc.ToString(), CairoFont.WhiteDetailText());

            modSys.setCharacterClass(capi.World.Player.Entity, chclass.Code, true);

            var essr = capi.World.Player.Entity.Properties.Client.Renderer as EntitySkinnableShapeRenderer;

            essr.TesselateShape();
        }
        private void SetupDialog()
        {
            var availableTeleports = TPNetManager.GetAvailableTeleports(capi.World.Player);

            ElementBounds[] buttons = new ElementBounds[availableTeleports?.Count() > 0 ? availableTeleports.Count() : 1];

            buttons[0] = ElementBounds.Fixed(0, 0, 300, 40);
            for (int i = 1; i < buttons.Length; i++)
            {
                buttons[i] = buttons[i - 1].BelowCopy(0, 1);
            }


            ElementBounds listBounds = ElementBounds.Fixed(0, 0, 302, 400).WithFixedPadding(1);

            listBounds.BothSizing = ElementSizing.Fixed;

            ElementBounds clipBounds  = listBounds.ForkBoundingParent();
            ElementBounds insetBounds = listBounds.FlatCopy().FixedGrow(6).WithFixedOffset(-3, -3);

            ElementBounds scrollbarBounds = ElementStdBounds.VerticalScrollbar(insetBounds);


            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding).WithFixedOffset(0, GuiStyle.TitleBarHeight);

            bgBounds.BothSizing = ElementSizing.FitToChildren;
            bgBounds.WithChildren(insetBounds, scrollbarBounds);


            ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog;


            SingleComposer = capi.Gui
                             .CreateCompo("teleport-dialog", dialogBounds)
                             .AddDialogTitleBar(DialogTitle, CloseIconPressed)
                             .AddDialogBG(bgBounds, false)
                             .BeginChildElements(bgBounds)
            ;

            if (availableTeleports == null || availableTeleports.Count() == 0)
            {
                SingleComposer
                .AddStaticText(
                    Lang.Get("No available teleports"),
                    CairoFont.WhiteSmallText(),
                    buttons[0])
                .EndChildElements()
                .Compose()
                ;
                return;
            }

            SingleComposer
            .BeginClip(clipBounds)
            .AddInset(insetBounds, 3)
            .AddContainer(listBounds, "stacklist")
            .EndClip()
            .AddHoverText("", CairoFont.WhiteDetailText(), 300, listBounds.FlatCopy(), "hovertext")
            .AddVerticalScrollbar(OnNewScrollbarValue, scrollbarBounds, "scrollbar")
            .EndChildElements()
            ;

            var hoverTextElem = SingleComposer.GetHoverText("hovertext");

            hoverTextElem.SetAutoWidth(true);

            var stacklist = SingleComposer.GetContainer("stacklist");

            for (int i = 0; i < buttons.Length; i++)
            {
                var tp = availableTeleports.ElementAt(i);
                if (tp.Value.Name == null)
                {
                    tp.Value.Name = "null";
                }

                bool playerLowStability = capi.World.Player?.Entity?.GetBehavior <EntityBehaviorTemporalStabilityAffected>()?.OwnStability < 0.2;
                bool nowStormActive     = capi.ModLoader.GetModSystem <SystemTemporalStability>().StormData.nowStormActive;

                var font = CairoFont.WhiteSmallText();

                stacklist.Add(new GuiElementTextButtonExt(capi,
                                                          (nowStormActive || playerLowStability) ? tp.Value.Name.Shuffle() : tp.Value.Name,
                                                          tp.Key,
                                                          tp.Value.Available ? font : font.WithColor(ColorUtil.Hex2Doubles("#c91a1a")),
                                                          CairoFont.WhiteSmallText(),
                                                          () => OnClickItem(tp.Key),
                                                          buttons[i],
                                                          EnumButtonStyle.Normal
                                                          ));

                if (tp.Key == blockEntityPos)
                {
                    (stacklist.Elements.Last() as GuiElementTextButtonExt).Enabled = false;
                }
            }

            SingleComposer.GetScrollbar("scrollbar").SetHeights(
                (float)Math.Min(listBounds.fixedHeight, (buttons.Last().fixedHeight + buttons.Last().fixedY)),
                (float)(buttons.Last().fixedHeight + buttons.Last().fixedY)
                );
            //SingleComposer.GetScrollbar("scrollbar").ScrollToBottom();
            //SingleComposer.GetScrollbar("scrollbar").CurrentYPosition = 0;
            SingleComposer.Compose();
        }
        protected virtual void ComposeGuis()
        {
            double pad      = GuiElementItemSlotGrid.unscaledSlotPadding;
            double slotsize = GuiElementPassiveItemSlot.unscaledSlotSize;

            ElementBounds leftPrevButtonBounds = ElementBounds.Fixed(75, 120 + pad + 52, 19, 19).WithFixedPadding(2);
            ElementBounds leftNextButtonBounds = ElementBounds.Fixed(75, 120 + pad + 52, 19, 19).WithFixedPadding(2).FixedRightOf(leftPrevButtonBounds, 6);
            ElementBounds textBounds           = ElementBounds.Fixed(0, 120 + pad + 52, 19, 19).WithFixedPadding(2);

            ElementBounds humanButtonBounds = ElementBounds.Fixed(0, pad + 52, 19, 19).WithFixedPadding(2);
            ElementBounds dwarfButtonBounds = ElementBounds.Fixed(0, pad + 52, 19, 19).WithFixedPadding(2).FixedRightOf(humanButtonBounds, 40);

            ElementBounds maleButtonBounds   = ElementBounds.Fixed(0, 57 + pad + 52, 19, 19).WithFixedPadding(2);
            ElementBounds femaleButtonBounds = ElementBounds.Fixed(0, 57 + pad + 52, 19, 19).WithFixedPadding(2).FixedRightOf(maleButtonBounds, 30);

            ElementBounds titleTextBounds = ElementBounds.Fixed(0, pad + 20, 19, 19).WithFixedPadding(2);

            characterInv = capi.World.Player.InventoryManager.GetOwnInventory(GlobalConstants.characterInvClassName);
            ElementBounds leftSlotBounds = ElementStdBounds.SlotGrid(EnumDialogArea.None, pad, 20 + pad, 1, 6).FixedGrow(2 * pad, 2 * pad);

            insetSlotBounds = ElementBounds.Fixed(pad + 65 + 65, pad + 20 + 2, 300 - 60, leftSlotBounds.fixedHeight - 2 * pad - 4);

            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;


            ElementBounds dialogBounds = ElementStdBounds
                                         .AutosizedMainDialog.WithAlignment(EnumDialogArea.None)
                                         .WithFixedAlignmentOffset(GuiStyle.DialogToScreenPadding, 0);


            ClearComposers();
            SingleComposer = capi.Gui
                             .CreateCompo("playercharacter", dialogBounds)
                             .AddDialogBG(bgBounds, true)
                             //.AddDialogTitleBar(capi.World.Player.PlayerName, OnTitleBarClose)
                             .BeginChildElements(bgBounds)

                             // Race
                             .AddStaticTextAutoBoxSize("Race:", CairoFont.WhiteSmallishText(), EnumTextOrientation.Right, titleTextBounds.FlatCopy())
                             .AddSmallButton("Human", () => ButtonClickRace("human"), humanButtonBounds.FlatCopy())
                             .AddSmallButton("Dwarf", () => ButtonClickRace("dwarf"), dwarfButtonBounds.FlatCopy())

                             // Sex
                             .AddStaticTextAutoBoxSize("Sex:", CairoFont.WhiteSmallishText(), EnumTextOrientation.Right, titleTextBounds = titleTextBounds.BelowCopy(0, 35))
                             .AddSmallButton("Male", () => ButtonClickSex("male"), maleButtonBounds.FlatCopy())
                             .AddSmallButton("Female", () => ButtonClickSex("female"), femaleButtonBounds.FlatCopy())

                             .AddStaticTextAutoBoxSize("Appearance:", CairoFont.WhiteSmallishText(), EnumTextOrientation.Right, titleTextBounds = titleTextBounds.BelowCopy(0, 35))

                             // Skin Color
                             .AddIconButton("left", (on) => OnPrevious("skincolor"), leftPrevButtonBounds.FlatCopy())
                             .AddIconButton("right", (on) => OnNext("skincolor"), leftNextButtonBounds.FlatCopy())
                             .AddStaticTextAutoBoxSize("Skin color:", CairoFont.WhiteDetailText(), EnumTextOrientation.Right, textBounds.FlatCopy())

                             // Eye Color
                             .AddIconButton("left", (on) => OnPrevious("eyecolor"), leftPrevButtonBounds = leftPrevButtonBounds.BelowCopy(0, 5))
                             .AddIconButton("right", (on) => OnNext("eyecolor"), leftNextButtonBounds    = leftNextButtonBounds.BelowCopy(0, 5))
                             .AddStaticTextAutoBoxSize("Eye color:", CairoFont.WhiteDetailText(), EnumTextOrientation.Right, textBounds = textBounds.BelowCopy(0, 5))

                             // Hair Color
                             .AddIconButton("left", (on) => OnPrevious("haircolor"), leftPrevButtonBounds = leftPrevButtonBounds.BelowCopy(0, 5))
                             .AddIconButton("right", (on) => OnNext("haircolor"), leftNextButtonBounds    = leftNextButtonBounds.BelowCopy(0, 5))
                             .AddStaticTextAutoBoxSize("Hair color:", CairoFont.WhiteDetailText(), EnumTextOrientation.Right, textBounds = textBounds.BelowCopy(0, 7))

                             // Hair Type
                             .AddIconButton("left", (on) => OnPrevious("hairtype"), leftPrevButtonBounds = leftPrevButtonBounds.BelowCopy(0, 5))
                             .AddIconButton("right", (on) => OnNext("hairtype"), leftNextButtonBounds    = leftNextButtonBounds.BelowCopy(0, 5))
                             .AddStaticTextAutoBoxSize("Hair type:", CairoFont.WhiteDetailText(), EnumTextOrientation.Right, textBounds = textBounds.BelowCopy(0, 7))

                             // Facial Hair
                             .AddIconButton("left", (on) => OnPrevious("facialhair"), leftPrevButtonBounds = leftPrevButtonBounds.BelowCopy(0, 5))
                             .AddIconButton("right", (on) => OnNext("facialhair"), leftNextButtonBounds    = leftNextButtonBounds.BelowCopy(0, 5))
                             .AddStaticTextAutoBoxSize("Facial hair:", CairoFont.WhiteDetailText(), EnumTextOrientation.Right, textBounds = textBounds.BelowCopy(0, 7))

                             .AddSmallButton("Confirm", () => TryClose(), textBounds = textBounds.BelowCopy(0, 7))

                             //.AddItemSlotGrid(characterInv, SendInvPacket, 1, new int[] { 0, 1, 2, 11, 3, 4 }, leftSlotBounds, "leftSlots")
                             .AddInset(insetSlotBounds, 2)
                             //.AddItemSlotGrid(characterInv, SendInvPacket, 1, new int[] { 6, 7, 8, 10, 5, 9 }, rightSlotBounds, "rightSlots")
                             .EndChildElements()
                             .Compose()
            ;
        }
        protected void ComposeGuis()
        {
            double pad      = GuiElementItemSlotGridBase.unscaledSlotPadding;
            double slotsize = GuiElementPassiveItemSlot.unscaledSlotSize;

            characterInv = capi.World.Player.InventoryManager.GetOwnInventory(GlobalConstants.characterInvClassName);

            ElementBounds tabBounds = ElementBounds.Fixed(0, -25, 450, 25);

            double ypos = 20 + pad;

            ElementBounds bgBounds = ElementBounds.FixedSize(717, 433).WithFixedPadding(GuiStyle.ElementToDialogPadding);

            ElementBounds dialogBounds = ElementBounds.FixedSize(757, 473).WithAlignment(EnumDialogArea.CenterMiddle)
                                         .WithFixedAlignmentOffset(GuiStyle.DialogToScreenPadding, 0);


            GuiTab[] tabs = new GuiTab[] {
                new GuiTab()
                {
                    Name = "Skin", DataInt = 0
                },
                new GuiTab()
                {
                    Name = "Class", DataInt = 1
                },
                //  new GuiTab() { Name = "Outfit", DataInt = 2 }
            };

            Composers["createcharacter"] =
                capi.Gui
                .CreateCompo("createcharacter", dialogBounds)
                .AddShadedDialogBG(bgBounds, true)
                .AddDialogTitleBar(curTab == 0 ? Lang.Get("Customize Skin") : (curTab == 1 ? Lang.Get("Select character class") : Lang.Get("Select your outfit")), OnTitleBarClose)
                .AddHorizontalTabs(tabs, tabBounds, onTabClicked, CairoFont.WhiteSmallText(), CairoFont.WhiteSmallText().WithWeight(Cairo.FontWeight.Bold), "tabs")
                .BeginChildElements(bgBounds)
            ;

            capi.World.Player.Entity.hideClothing = false;

            if (curTab == 0)
            {
                var skinMod = capi.World.Player.Entity.GetBehavior <EntityBehaviorExtraSkinnable>();

                capi.World.Player.Entity.hideClothing = charNaked;
                var essr = capi.World.Player.Entity.Properties.Client.Renderer as EntitySkinnableShapeRenderer;
                essr.TesselateShape();

                CairoFont smallfont     = CairoFont.WhiteSmallText();
                var       tExt          = smallfont.GetTextExtents(Lang.Get("Show dressed"));
                int       colorIconSize = 22;

                ElementBounds leftSlotBounds = ElementStdBounds.SlotGrid(EnumDialogArea.None, 0, ypos, 4, rows).FixedGrow(2 * pad, 2 * pad);
                insetSlotBounds = ElementBounds.Fixed(0, ypos + 2, 265, leftSlotBounds.fixedHeight - 2 * pad + 10).FixedRightOf(leftSlotBounds, 10);
                ElementBounds rightSlotBounds    = ElementStdBounds.SlotGrid(EnumDialogArea.None, 0, ypos, 1, rows).FixedGrow(2 * pad, 2 * pad).FixedRightOf(insetSlotBounds, 10);
                ElementBounds toggleButtonBounds = ElementBounds.Fixed(
                    (int)insetSlotBounds.fixedX + insetSlotBounds.fixedWidth / 2 - tExt.Width / RuntimeEnv.GUIScale / 2 - 12,
                    0,
                    tExt.Width / RuntimeEnv.GUIScale,
                    tExt.Height / RuntimeEnv.GUIScale
                    )
                                                   .FixedUnder(insetSlotBounds, 4).WithAlignment(EnumDialogArea.LeftFixed).WithFixedPadding(12, 6)
                ;

                ElementBounds bounds     = null;
                ElementBounds prevbounds = null;

                double leftX = 0;

                foreach (var skinpart in skinMod.AvailableSkinParts)
                {
                    bounds = ElementBounds.Fixed(leftX, (prevbounds == null || prevbounds.fixedY == 0) ? -10 : prevbounds.fixedY + 8, colorIconSize, colorIconSize);

                    string code = skinpart.Code;

                    AppliedSkinnablePartVariant appliedVar = skinMod.AppliedSkinParts.FirstOrDefault(sp => sp.PartCode == code);


                    if (skinpart.Type == EnumSkinnableType.Texture && !skinpart.UseDropDown)
                    {
                        int   selectedIndex = 0;
                        int[] colors        = new int[skinpart.Variants.Length];

                        for (int i = 0; i < skinpart.Variants.Length; i++)
                        {
                            colors[i] = skinpart.Variants[i].Color;

                            if (appliedVar?.Code == skinpart.Variants[i].Code)
                            {
                                selectedIndex = i;
                            }
                        }

                        Composers["createcharacter"].AddStaticText(Lang.Get("skinpart-" + code), CairoFont.WhiteSmallText(), bounds   = bounds.BelowCopy(0, 10).WithFixedSize(210, 22));
                        Composers["createcharacter"].AddColorListPicker(colors, (index) => onToggleSkinPartColor(code, index), bounds = bounds.BelowCopy(0, 0).WithFixedSize(colorIconSize, colorIconSize), 180, "picker-" + code);
                        Composers["createcharacter"].ColorListPickerSetValue("picker-" + code, selectedIndex);
                    }
                    else
                    {
                        int selectedIndex = 0;

                        string[] names  = new string[skinpart.Variants.Length];
                        string[] values = new string[skinpart.Variants.Length];

                        for (int i = 0; i < skinpart.Variants.Length; i++)
                        {
                            names[i]  = Lang.Get("skinpart-" + code + "-" + skinpart.Variants[i].Code);
                            values[i] = skinpart.Variants[i].Code;

                            //Console.WriteLine("\"" + names[i] + "\": \"" + skinpart.Variants[i].Code + "\",");

                            if (appliedVar?.Code == values[i])
                            {
                                selectedIndex = i;
                            }
                        }


                        Composers["createcharacter"].AddStaticText(Lang.Get("skinpart-" + code), CairoFont.WhiteSmallText(), bounds = bounds.BelowCopy(0, 10).WithFixedSize(210, 22));
                        Composers["createcharacter"].AddDropDown(values, names, selectedIndex, (variantcode, selected) => onToggleSkinPartColor(code, variantcode), bounds = bounds.BelowCopy(0, 0).WithFixedSize(200, 25), "dropdown-" + code);
                    }

                    prevbounds = bounds.FlatCopy();

                    if (skinpart.Colbreak)
                    {
                        leftX             = insetSlotBounds.fixedX + insetSlotBounds.fixedWidth + 22;
                        prevbounds.fixedY = 0;
                    }
                }



                Composers["createcharacter"]
                .AddInset(insetSlotBounds, 2)
                .AddToggleButton(Lang.Get("Show dressed"), smallfont, OnToggleDressOnOff, toggleButtonBounds, "showdressedtoggle")
                .AddSmallButton(Lang.Get("Randomize"), OnRandomizeSkin, ElementBounds.Fixed(0, 0).FixedUnder(rightSlotBounds, 16).WithAlignment(EnumDialogArea.LeftFixed).WithFixedPadding(12, 6), EnumButtonStyle.Normal, EnumTextOrientation.Center)
                .AddSmallButton(Lang.Get("Confirm Skin"), OnNext, ElementBounds.Fixed(0, 0).FixedUnder(rightSlotBounds, 16).WithAlignment(EnumDialogArea.RightFixed).WithFixedPadding(12, 6), EnumButtonStyle.Normal, EnumTextOrientation.Center)
                ;

                Composers["createcharacter"].GetToggleButton("showdressedtoggle").SetValue(!charNaked);
            }

            if (curTab == 1)
            {
                var essr = capi.World.Player.Entity.Properties.Client.Renderer as EntitySkinnableShapeRenderer;
                essr.TesselateShape();

                ypos -= 10;
                ElementBounds leftSlotBounds = ElementStdBounds.SlotGrid(EnumDialogArea.None, 0, ypos, 0, rows).FixedGrow(2 * pad, 2 * pad);
                insetSlotBounds = ElementBounds.Fixed(0, ypos + 25, 190, leftSlotBounds.fixedHeight - 2 * pad + 8 + 25).FixedRightOf(leftSlotBounds, 10);
                ElementBounds rightSlotBounds = ElementStdBounds.SlotGrid(EnumDialogArea.None, 0, ypos, 1, rows).FixedGrow(2 * pad, 2 * pad).FixedRightOf(insetSlotBounds, 10);

                ElementBounds prevButtonBounds = ElementBounds.Fixed(0, ypos + 25, 35, slotsize - 4).WithFixedPadding(2).FixedRightOf(insetSlotBounds, 20);
                ElementBounds centerTextBounds = ElementBounds.Fixed(0, ypos + 25, 200, slotsize - 4 - 8).FixedRightOf(prevButtonBounds, 20);

                ElementBounds charclasssInset = centerTextBounds.ForkBoundingParent(4, 4, 4, 4);

                ElementBounds nextButtonBounds = ElementBounds.Fixed(0, ypos + 25, 35, slotsize - 4).WithFixedPadding(2).FixedRightOf(charclasssInset, 20);

                CairoFont font = CairoFont.WhiteMediumText();
                centerTextBounds.fixedY += (centerTextBounds.fixedHeight - font.GetFontExtents().Height / RuntimeEnv.GUIScale) / 2;

                ElementBounds charTextBounds = ElementBounds.Fixed(0, 0, 480, 100).FixedUnder(prevButtonBounds, 20).FixedRightOf(insetSlotBounds, 20);

                Composers["createcharacter"]
                .AddInset(insetSlotBounds, 2)

                .AddIconButton("left", (on) => changeClass(-1), prevButtonBounds.FlatCopy())
                .AddInset(charclasssInset, 2)
                .AddDynamicText("Commoner", font, EnumTextOrientation.Center, centerTextBounds, "className")
                .AddIconButton("right", (on) => changeClass(1), nextButtonBounds.FlatCopy())

                .AddRichtext("", CairoFont.WhiteDetailText(), charTextBounds, "characterDesc")
                .AddSmallButton(Lang.Get("Confirm Class"), OnConfirm, ElementBounds.Fixed(0, 0).FixedUnder(rightSlotBounds, 26).WithAlignment(EnumDialogArea.RightFixed).WithFixedPadding(12, 6), EnumButtonStyle.Normal, EnumTextOrientation.Center)
                ;

                changeClass(0);
            }

            /*if (curTab == 2) {
             *
             *  ElementBounds leftPrevButtonBounds = ElementBounds.Fixed(0, ypos + 52, 19, slotsize - 4).WithFixedPadding(2);
             *  ElementBounds leftNextButtonBounds = ElementBounds.Fixed(0, ypos + 52, 19, slotsize - 4).WithFixedPadding(2).FixedRightOf(leftPrevButtonBounds, 6);
             *
             *  ElementBounds leftSlotBounds = ElementStdBounds.SlotGrid(EnumDialogArea.None, 0, ypos, 1, rows).FixedGrow(2 * pad, 2 * pad).FixedRightOf(leftNextButtonBounds, 8);
             *  insetSlotBounds = ElementBounds.Fixed(0, ypos + 25, 220, leftSlotBounds.fixedHeight - 2 * pad - 4 + 25).FixedRightOf(leftSlotBounds, 10);
             *  ElementBounds rightSlotBounds = ElementStdBounds.SlotGrid(EnumDialogArea.None, 0, ypos, 1, rows).FixedGrow(2 * pad, 2 * pad).FixedRightOf(insetSlotBounds, 10);
             *
             *  ElementBounds rightPrevButtonBounds = ElementBounds.Fixed(20, ypos + 1, 19, slotsize - 4).WithFixedPadding(2).FixedRightOf(rightSlotBounds, 6);
             *  ElementBounds rightNextButtonBounds = ElementBounds.Fixed(20, ypos + 1, 19, slotsize - 4).WithFixedPadding(2).FixedRightOf(rightPrevButtonBounds, 6);
             *
             *
             *
             *  Composers["createcharacter"]
             *      .AddItemSlotGrid(characterInv, SendInvPacket, 1, new int[] { 0, 1, 2, 11, 3, 4 }, leftSlotBounds, "leftSlots")
             *
             *          // Shoulder
             *          .AddIconButton("left", (on) => OnPrevious(1), leftPrevButtonBounds.FlatCopy())
             *          .AddIconButton("right", (on) => OnNext(1), leftNextButtonBounds.FlatCopy())
             *
             *          // Upper body
             *          .AddIconButton("left", (on) => OnPrevious(2), leftPrevButtonBounds = leftPrevButtonBounds.BelowCopy(0, 3))
             *          .AddIconButton("right", (on) => OnNext(2), leftNextButtonBounds = leftNextButtonBounds.BelowCopy(0, 3))
             *
             *          // Trousers
             *          .AddIconButton("left", (on) => OnPrevious(3), leftPrevButtonBounds = leftPrevButtonBounds.BelowCopy(0, 3).BelowCopy(0, 3))
             *          .AddIconButton("right", (on) => OnNext(3), leftNextButtonBounds = leftNextButtonBounds.BelowCopy(0, 3).BelowCopy(0, 3))
             *
             *          // Shoes
             *          .AddIconButton("left", (on) => OnPrevious(4), leftPrevButtonBounds = leftPrevButtonBounds.BelowCopy(0, 3))
             *          .AddIconButton("right", (on) => OnNext(4), leftNextButtonBounds = leftNextButtonBounds.BelowCopy(0, 3))
             *
             *          // Gloves (on the right)
             *          //  .AddIconButton("left", (on) => OnPrevious(5), rightPrevButtonBounds = rightPrevButtonBounds.BelowCopy(0, 3).BelowCopy(0, 3).BelowCopy(0, 3).BelowCopy(0, 3))
             *          // .AddIconButton("right", (on) => OnNext(5), rightNextButtonBounds = rightNextButtonBounds.BelowCopy(0, 3).BelowCopy(0, 3).BelowCopy(0, 3).BelowCopy(0, 3))
             *
             *          .AddInset(insetSlotBounds, 2)
             *          //.AddItemSlotGrid(characterInv, SendInvPacket, 1, new int[] { 6, 7, 8, 10, 5, 9 }, rightSlotBounds, "rightSlots")
             *
             *          .AddSmallButton(Lang.Get("Randomize"), OnRandomizeClothes, ElementBounds.Fixed(0, 0).FixedUnder(rightSlotBounds, 20).WithAlignment(EnumDialogArea.LeftFixed).WithFixedPadding(10, 4), EnumButtonStyle.Normal, EnumTextOrientation.Center)
             *          .AddSmallButton(Lang.Get("Confirm Selection"), OnConfirm, ElementBounds.Fixed(0, 0).FixedUnder(rightSlotBounds, 20).WithAlignment(EnumDialogArea.RightFixed).WithFixedPadding(10, 4), EnumButtonStyle.Normal, EnumTextOrientation.Center)
             *
             *      .EndChildElements()
             *  ;
             * }*/


            var tabElem = Composers["createcharacter"].GetHorizontalTabs("tabs");

            tabElem.unscaledTabSpacing = 20;
            tabElem.unscaledTabPadding = 10;
            tabElem.activeElement      = curTab;

            Composers["createcharacter"].Compose();


            /*if (curTab == 2)
             * {
             *  Composers["createcharacter"].GetSlotGrid("leftSlots").CanClickSlot = (slotid) => { return false; };
             *  //Composers["createcharacter"].GetSlotGrid("rightSlots").CanClickSlot = (slotid) => { return false; };
             * }*/
        }
Exemple #28
0
        public void SetupDialog(BEEAssembler bea)
        {
            ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle);

            // Just a simple 300x100 pixel box with 40 pixels top spacing for the title bar
            ElementBounds textBounds = ElementBounds.Fixed(0, 40, 600, 600);

            // Background boundaries. Again, just make it fit it's child elements, then add the text as a child element
            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;
            bgBounds.WithChildren(textBounds);
            string guicomponame = bea.Pos.ToString() + "Assembler";
            string statustext   = "";
            string alertred     = "<font color=\"#ffbbaa\">";//<font <color=\"#ffdddd\">>";

            if (!bea.IsPowered)
            {
                statustext += alertred;
            }
            else if (bea.DeviceState == BEEBaseDevice.enDeviceState.MATERIALHOLD)
            {
                statustext += alertred;
            }
            else if (bea.DeviceState == BEEBaseDevice.enDeviceState.RUNNING)
            {
                statustext += "<font color=\"#aaff55\">";
            }
            else
            {
                statustext += "<font>";
            }
            statustext += "<strong>STATUS: " + bea.Status + "</strong></font><br><br>";
            statustext += "Making <strong>" + bea.FG.ToUpper() + "</strong><br><br>";
            statustext += "Requires <strong>" + bea.RM + "</strong>";
            if (bea.Materials.Length > 0 && bea.DeviceState == BEEBaseDevice.enDeviceState.MATERIALHOLD)
            {
                statustext += " of material ";
                statustext += "<font><strong>";

                for (int c = 0; c < bea.Materials.Length; c++)
                {
                    if (c == bea.Materials.Length - 1)
                    {
                        statustext += ", or ";
                    }
                    else if (c != 0)
                    {
                        statustext += ", ";
                    }

                    statustext += bea.Materials[c];
                }
                statustext += ".</font></strong>";
            }
            SingleComposer = capi.Gui.CreateCompo(guicomponame, dialogBounds)
                             .AddShadedDialogBG(bgBounds)
                             .AddDialogTitleBar("Metal Press Status", OnTitleBarCloseClicked)
                             .AddRichtext(statustext, CairoFont.WhiteDetailText(), textBounds)

                             .Compose()
            ;
        }
Exemple #29
0
        private GuiComposer ComposeDialog(EnumDialogType dlgType)
        {
            GuiComposer compo;

            ElementBounds mapBounds = ElementBounds.Fixed(0, 28, mapWidth, mapHeight);
            ElementBounds layerList = mapBounds.RightCopy().WithFixedSize(1, 350);

            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(3);

            bgBounds.BothSizing = ElementSizing.FitToChildren;
            bgBounds.WithChildren(mapBounds, layerList);

            ElementBounds dialogBounds =
                ElementStdBounds.AutosizedMainDialog
                .WithAlignment(EnumDialogArea.CenterMiddle)
                .WithFixedAlignmentOffset(-GuiStyle.DialogToScreenPadding, 0);

            if (dlgType == EnumDialogType.HUD)
            {
                mapBounds = ElementBounds.Fixed(0, 0, 250, 250);

                bgBounds            = ElementBounds.Fill.WithFixedPadding(2);
                bgBounds.BothSizing = ElementSizing.FitToChildren;
                bgBounds.WithChildren(mapBounds);

                dialogBounds =
                    ElementStdBounds.AutosizedMainDialog
                    .WithAlignment(EnumDialogArea.RightTop)
                    .WithFixedAlignmentOffset(-GuiStyle.DialogToScreenPadding, GuiStyle.DialogToScreenPadding);

                compo = hudDialog;
            }
            else
            {
                compo = fullDialog;
            }

            Cuboidd beforeBounds = null;

            if (compo != null)
            {
                beforeBounds = (compo.GetElement("mapElem") as GuiElementMap)?.CurrentBlockViewBounds;
                compo.Dispose();
            }

            compo = capi.Gui
                    .CreateCompo("worldmap" + dlgType, dialogBounds)
                    .AddShadedDialogBG(bgBounds, false)
                    .AddIf(dlgType == EnumDialogType.Dialog)
                    .AddDialogTitleBar("World Map", OnTitleBarClose)
                    .AddInset(mapBounds, 2)
                    .EndIf()
                    .BeginChildElements(bgBounds)
                    .AddHoverText("", CairoFont.WhiteDetailText(), 350, mapBounds.FlatCopy(), "hoverText")
                    .AddInteractiveElement(new GuiElementMap(capi.ModLoader.GetModSystem <WorldMapManager>().MapLayers, capi, mapBounds, dlgType == EnumDialogType.HUD), "mapElem")
                    .EndChildElements()
                    .Compose()
            ;

            compo.OnRecomposed += SingleComposer_OnRecomposed;

            GuiElementMap mapElem = compo.GetElement("mapElem") as GuiElementMap;

            if (beforeBounds != null)
            {
                mapElem.chunkViewBoundsBefore = beforeBounds.ToCuboidi().Div(capi.World.BlockAccessor.ChunkSize);
            }
            mapElem.viewChanged = viewChanged;
            mapElem.ZoomAdd(1, 0.5f, 0.5f);



            var hoverTextElem = compo.GetHoverText("hoverText");

            hoverTextElem.SetAutoWidth(true);

            if (listenerId == 0)
            {
                listenerId = capi.Event.RegisterGameTickListener(
                    (dt) =>
                {
                    if (!IsOpened())
                    {
                        return;
                    }

                    GuiElementMap singlec = SingleComposer.GetElement("mapElem") as GuiElementMap;
                    singlec?.EnsureMapFullyLoaded();

                    if (requireRecompose)
                    {
                        var dlgtype = dialogType;
                        capi.ModLoader.GetModSystem <WorldMapManager>().ToggleMap(dlgtype);
                        capi.ModLoader.GetModSystem <WorldMapManager>().ToggleMap(dlgtype);
                        requireRecompose = false;
                    }
                }
                    , 100);
            }

            capi.World.FrameProfiler.Mark("composeworldmap");
            return(compo);
        }
        public GuiDialogTrader(InventoryTrader traderInventory, EntityAgent owningEntity, ICoreClientAPI capi, int rows = 4, int cols = 4) : base(capi)
        {
            this.traderInventory = traderInventory;
            this.owningEntity    = owningEntity;

            double pad = GuiElementItemSlotGrid.unscaledSlotPadding;

            ElementBounds leftTopSlotBounds  = ElementStdBounds.SlotGrid(EnumDialogArea.None, pad, 70 + pad, cols, rows).FixedGrow(2 * pad, 2 * pad);
            ElementBounds rightTopSlotBounds = ElementStdBounds.SlotGrid(EnumDialogArea.None, pad + leftTopSlotBounds.fixedWidth + 20, 70 + pad, cols, rows).FixedGrow(2 * pad, 2 * pad);

            ElementBounds rightBotSlotBounds = ElementStdBounds
                                               .SlotGrid(EnumDialogArea.None, pad + leftTopSlotBounds.fixedWidth + 20, 15 + pad, cols, 1)
                                               .FixedGrow(2 * pad, 2 * pad)
                                               .FixedUnder(rightTopSlotBounds, 5)
            ;

            ElementBounds leftBotSlotBounds = ElementStdBounds
                                              .SlotGrid(EnumDialogArea.None, pad, 15 + pad, cols, 1)
                                              .FixedGrow(2 * pad, 2 * pad)
                                              .FixedUnder(leftTopSlotBounds, 5)
            ;

            //ElementBounds chanceInputBounds = ElementBounds.Fixed(3, 0, 48, 30).FixedUnder(l, -4);

            ElementBounds leftButton  = ElementBounds.Fixed(EnumDialogArea.LeftFixed, 0, 0, 0, 0).WithFixedPadding(10, 1);
            ElementBounds rightButton = ElementBounds.Fixed(EnumDialogArea.RightFixed, 0, 0, 0, 0).WithFixedPadding(10, 1);

            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;



            ElementBounds costTextBounds  = ElementBounds.Fixed(pad, 85 + 2 * pad + leftTopSlotBounds.fixedHeight + leftBotSlotBounds.fixedHeight, 150, 25);
            ElementBounds offerTextBounds = ElementBounds.Fixed(leftTopSlotBounds.fixedWidth + pad + 20, 85 + 2 * pad + leftTopSlotBounds.fixedHeight + leftBotSlotBounds.fixedHeight, 150, 25);

            ElementBounds traderMoneyBounds = offerTextBounds.FlatCopy().WithFixedOffset(0, offerTextBounds.fixedHeight);
            ElementBounds playerMoneyBounds = costTextBounds.FlatCopy().WithFixedOffset(0, costTextBounds.fixedHeight);

            ElementBounds dialogBounds = ElementStdBounds
                                         .AutosizedMainDialog.WithAlignment(EnumDialogArea.RightMiddle)
                                         .WithFixedAlignmentOffset(-GuiStyle.DialogToScreenPadding, 0);

            string traderName = owningEntity.GetBehavior <EntityBehaviorNameTag>().DisplayName;

            double daysLeft       = 14 - (capi.World.Calendar.TotalDays - owningEntity.WatchedAttributes.GetDouble("lastRefreshTotalDays", 0));
            string daysLeftString = daysLeft < 1 ? Lang.Get("Delievery of new goods in less than 1 day") : Lang.Get("Delievery of new goods in {0} days", (int)daysLeft);

            CairoFont deliveryTextFont = CairoFont.WhiteDetailText();

            deliveryTextFont.Color[3] *= 0.7;

            SingleComposer =
                capi.Gui
                .CreateCompo("traderdialog-" + owningEntity.Code.Path, dialogBounds)
                .AddShadedDialogBG(bgBounds, true)
                .AddDialogTitleBar(Lang.Get("tradingwindow-" + owningEntity.Code.Path, traderName), OnTitleBarClose)
                .BeginChildElements(bgBounds)
                .AddStaticText(daysLeftString, deliveryTextFont, ElementBounds.Fixed(pad, 20 + pad, 300, 25))

                .AddStaticText(Lang.Get("You can Buy"), CairoFont.WhiteDetailText(), ElementBounds.Fixed(pad, 50 + pad, 150, 25))
                .AddStaticText(Lang.Get("You can Sell"), CairoFont.WhiteDetailText(), ElementBounds.Fixed(leftTopSlotBounds.fixedWidth + pad + 20, 50 + pad, 150, 25))

                .AddItemSlotGrid(traderInventory, DoSendPacket, cols, (new int[rows * cols]).Fill(i => i), leftTopSlotBounds, "traderSellingSlots")
                .AddItemSlotGrid(traderInventory, DoSendPacket, cols, (new int[cols]).Fill(i => rows * cols + i), leftBotSlotBounds, "playerBuyingSlots")

                .AddItemSlotGrid(traderInventory, DoSendPacket, cols, (new int[rows * cols]).Fill(i => rows * cols + cols + i), rightTopSlotBounds, "traderBuyingSlots")
                .AddItemSlotGrid(traderInventory, DoSendPacket, cols, (new int[cols]).Fill(i => rows * cols + cols + rows * cols + i), rightBotSlotBounds, "playerSellingSlots")

                .AddStaticText(Lang.Get("trader-yourselection"), CairoFont.WhiteDetailText(), ElementBounds.Fixed(pad, 70 + 2 * pad + leftTopSlotBounds.fixedHeight, 150, 25))
                .AddStaticText(Lang.Get("trader-youroffer"), CairoFont.WhiteDetailText(), ElementBounds.Fixed(leftTopSlotBounds.fixedWidth + pad + 20, 70 + 2 * pad + leftTopSlotBounds.fixedHeight, 150, 25))

                // Cost
                .AddDynamicText("", CairoFont.WhiteDetailText(), EnumTextOrientation.Left, costTextBounds, "costText")
                // Player money
                .AddDynamicText("", CairoFont.WhiteDetailText(), EnumTextOrientation.Left, playerMoneyBounds, "playerMoneyText")
                // Offer
                .AddDynamicText("", CairoFont.WhiteDetailText(), EnumTextOrientation.Left, offerTextBounds, "gainText")
                // Trader money
                .AddDynamicText("", CairoFont.WhiteDetailText(), EnumTextOrientation.Left, traderMoneyBounds, "traderMoneyText")

                .AddSmallButton(Lang.Get("Goodbye!"), OnByeClicked, leftButton.FixedUnder(playerMoneyBounds, 20).WithFixedPadding(8, 5))
                .AddSmallButton(Lang.Get("Buy / Sell"), OnBuySellClicked, rightButton.FixedUnder(traderMoneyBounds, 20).WithFixedPadding(8, 5), EnumButtonStyle.Normal, EnumTextOrientation.Left, "buysellButton")


                .EndChildElements()
                .Compose()
            ;

            SingleComposer.GetButton("buysellButton").Enabled = false;

            CalcAndUpdateAssetsDisplay();
        }