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;
        }
Exemple #2
0
        public GuiDialogCarcassContents(InventoryGeneric inv, EntityAgent owningEntity, ICoreClientAPI capi) : base(capi)
        {
            this.inv          = inv;
            this.owningEntity = owningEntity;


            double pad = GuiElementItemSlotGrid.unscaledSlotPadding;

            int rows = (int)Math.Ceiling(inv.Count / 4f);

            ElementBounds slotBounds = ElementStdBounds.SlotGrid(EnumDialogArea.None, pad, 40 + pad, 4, rows).FixedGrow(2 * pad, 2 * pad);

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

            bgBounds.BothSizing = ElementSizing.FitToChildren;

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


            SingleComposer =
                capi.Gui
                .CreateCompo("carcasscontents" + owningEntity.EntityId, dialogBounds)
                .AddShadedDialogBG(bgBounds, true)
                .AddDialogTitleBar(Lang.Get("carcass-contents"), OnTitleBarClose)
                .BeginChildElements(bgBounds)
                .AddItemSlotGrid(inv, DoSendPacket, 4, slotBounds, "slots")
                .EndChildElements()
                .Compose()
            ;
        }
Exemple #3
0
        public override void OnOwnPlayerDataReceived()
        {
            ElementBounds statbarbounds = ElementStdBounds.Statbar(EnumDialogArea.CenterBottom, 347).WithFixedAlignmentOffset(-125, -44);

            statbarbounds.WithFixedHeight(9);

            ElementBounds parentBounds = statbarbounds.ForkBoundingParent();

            SingleComposer = capi.Gui.CreateCompo("airbar", parentBounds)
                             .AddStatbar(statbarbounds, new double[] { 0.2, 0.2, 0.2, 0.5 }, "background")
                             .AddStatbar(statbarbounds, new double[] { 255.0 / 66.0, 255.0 / 134.0, 255.0 / 244.0, 0.5 }, "airbar")
                             .Compose();
            SingleComposer.GetStatbar("background").SetMinMax(0, 1);

            statbar = SingleComposer.GetStatbar("airbar");
            statbar.SetMinMax(0, 1);
            statbar.SetLineInterval(1f / 16f);
            statbar.FlashTime = 4.0f;

            SingleComposer.ReCompose();

            capi.World.Player.Entity.WatchedAttributes.RegisterModifiedListener("health", () => UpdateGUI());

            base.OnOwnPlayerDataReceived();
        }
Exemple #4
0
        private void ComposeDialog()
        {
            int height        = 200;
            int tableWidth    = 150;
            int textAreaWidth = 200;
            int headerHeight  = 20;
            int labelWidth    = 60;

            var spacer = ElementStdBounds
                         .TitleBar();

            var tableBounds = Fixed(0, 0, tableWidth, height);

            var labelBounds = Fixed(0, 0, labelWidth, headerHeight);

            var nameInputBounds = Fixed(labelWidth, 0, textAreaWidth - labelWidth, headerHeight);

            var headerBounds = Fixed(0, 0, textAreaWidth, headerHeight)
                               .WithChildren(labelBounds, nameInputBounds);

            var textAreaBounds = Fixed(0, 0, textAreaWidth, height)
                                 .FixedUnder(headerBounds, HalfPadding);

            var textContainerBounds = Fill
                                      .WithSizing(ElementSizing.FitToChildren)
                                      .FixedRightOf(tableBounds, HalfPadding)
                                      .WithChildren(textAreaBounds, headerBounds);

            var bodyBounds = Fill
                             .WithSizing(ElementSizing.FitToChildren)
                             .FixedUnder(spacer)
                             .WithChildren(textContainerBounds, tableBounds);

            var bgBounds = Fill
                           .WithFixedPadding(ElementToDialogPadding)
                           .WithChildren(bodyBounds)
                           .WithSizing(ElementSizing.FitToChildren);

            var dialogBounds = ElementStdBounds
                               .AutosizedMainDialog
                               .WithAlignment(EnumDialogArea.CenterMiddle);

            SingleComposer = capi.Gui.CreateCompo("aliaseditor", dialogBounds)
                             .AddShadedDialogBG(bgBounds)
                             .AddDialogTitleBar("Alias Editor", () => TryClose())
                             .AddStaticText("Alias:", CairoFont.WhiteSmallishText(), labelBounds)
                             .AddTextInput(nameInputBounds, OnAliasNameChanged, CairoFont.TextInput(), "aliastextinput")
                             .AddTextArea(textAreaBounds, OnAliasTextChanged, CairoFont.TextInput(), "aliastextarea")
                             .AddCellList(tableBounds,
                                          (cell, elBounds) => new GuiElementCell(capi, cell, elBounds)
            {
                ShowModifyIcons = false
            },
                                          OnMouseDownOnCell, OnMouseDownOnCell,
                                          cellList, "aliascellarea")
                             .Compose();
            textArea         = SingleComposer.GetTextArea("aliastextarea");
            textArea.Enabled = false;
            textInput        = SingleComposer.GetTextInput("aliastextinput");
        }
Exemple #5
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();
        }
        void SetupDialog()
        {
            ItemSlot hoveredSlot = capi.World.Player.InventoryManager.CurrentHoveredSlot;

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

            ElementBounds quernBounds = ElementBounds.Fixed(0, 0, 250, 90);

            ElementBounds inputSlotBounds  = ElementStdBounds.SlotGrid(EnumDialogArea.None, 20, 30, 1, 1);
            ElementBounds outputSlotBounds = ElementStdBounds.SlotGrid(EnumDialogArea.None, 173, 30, 1, 1);

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

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

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

            ClearComposers();
            SingleComposer = capi.Gui
                             .CreateCompo("blockentitymillstone", dialogBounds, false)
                             .AddDialogBG(bgBounds)
                             .AddDialogTitleBar(DialogTitle, OnTitleBarClose)
                             .BeginChildElements(bgBounds)
                             .AddDynamicCustomDraw(quernBounds, OnBgDraw, "symbolDrawer")
                             .AddItemSlotGrid(inventory, SendInvPacket, 1, new int[] { 0 }, inputSlotBounds, "inputSlot")
                             .AddItemSlotGrid(inventory, SendInvPacket, 1, new int[] { 1 }, outputSlotBounds, "outputslot")
                             .EndChildElements()
                             .Compose()
            ;

            lastRedrawMs = capi.ElapsedMilliseconds;

            if (hoveredSlot != null)
            {
                SingleComposer.OnMouseMove(capi, new MouseEvent()
                {
                    X = capi.Input.MouseX, Y = capi.Input.MouseY
                });
            }
        }
Exemple #7
0
        internal void ComposeWindow()
        {
            ClearComposers();

            var         rows  = new[] { 0f, 1f, 1.5f, 2.5f, 3.0f };
            const float width = 500f;

            var guiComposer = Api.AsClientMain().GetField <GuiComposerManager>("GuiComposers")
                              .Create("wpex-settings", ElementStdBounds.AutosizedMainDialog)
                              .AddShadedDialogBG(ElementStdBounds.DialogBackground()
                                                 .WithFixedPadding(GuiStyle.ElementToDialogPadding, GuiStyle.ElementToDialogPadding), false)
                              .BeginChildElements();

            // Title.
            guiComposer.AddStaticText(LangEx.UI("SettingsWindow.Headers.Wpex"),
                                      CairoFont.WhiteSmallishText().WithFontSize(25f),
                                      EnumTextOrientation.Center,
                                      ElementStdBounds.MenuButton(rows[0])
                                      .WithFixedWidth(width));

            // Auto Translocator.
            guiComposer.AddStaticText(LangEx.UI("SettingsWindow.Labels.AutoTranslocator"), CairoFont.WhiteSmallishText(),
                                      ElementStdBounds.MenuButton(rows[1], EnumDialogArea.LeftTop).WithFixedWidth(330))
            .AddHoverText(LangEx.UI("SettingsWindow.Tooltips.AutoTranslocator"), CairoFont.WhiteSmallText(), 250,
                          ElementStdBounds.MenuButton(rows[1], EnumDialogArea.LeftTop).WithFixedWidth(250))
            .AddSwitch(AutoTranslocatorChanged,
                       ElementStdBounds.MenuButton(rows[1], EnumDialogArea.LeftTop).WithFixedOffset(350.0, 0), "AutoTranslocatorWaypoints");

            // Auto Trader
            guiComposer.AddStaticText(LangEx.UI("SettingsWindow.Labels.AutoTrader"), CairoFont.WhiteSmallishText(),
                                      ElementStdBounds.MenuButton(rows[2], EnumDialogArea.LeftTop).WithFixedWidth(330))
            .AddHoverText(LangEx.UI("SettingsWindow.Tooltips.AutoTrader"), CairoFont.WhiteSmallText(), 250,
                          ElementStdBounds.MenuButton(rows[2], EnumDialogArea.LeftTop).WithFixedWidth(250))
            .AddSwitch(AutoTraderChanged,
                       ElementStdBounds.MenuButton(rows[2], EnumDialogArea.LeftTop).WithFixedOffset(350.0, 0), "AutoTraderWaypoints");

            // Donate Button.
            guiComposer.AddButton(LangEx.UI("SettingsWindow.Labels.Donate"), OnDonateButton,
                                  ElementStdBounds.MenuButton(rows[3]).WithFixedWidth(width));

            // Back Button.
            guiComposer.AddButton(Lang.Get("pause-back2game"), OnBackToGame,
                                  ElementStdBounds.MenuButton(rows[4]).WithFixedWidth(width));

            guiComposer.GetSwitch("AutoTranslocatorWaypoints").On = Mod.Settings.AutoTranslocatorWaypoints;
            guiComposer.GetSwitch("AutoTraderWaypoints").On       = Mod.Settings.AutoTraderWaypoints;

            SingleComposer = guiComposer.EndChildElements().Compose();
        }
        public void ComposeBars()
        {
            double elemToDlgPad = GuiStyle.ElementToDialogPadding;
            float  width        = 850;

            ElementBounds bounds = new ElementBounds()
            {
                Alignment   = EnumDialogArea.CenterBottom,
                BothSizing  = ElementSizing.Fixed,
                fixedWidth  = width,
                fixedHeight = 100
            }.WithFixedAlignmentOffset(0, -1);

            ElementBounds bodyheatBounds  = StatbarBounds(EnumDialogArea.LeftTop, width * 0.41).WithFixedAlignmentOffset(-2, 7);
            ElementBounds thirstBarBounds = StatbarBounds(EnumDialogArea.RightTop, width * 0.41).WithFixedAlignmentOffset(-2, 7);

            ElementBounds horBarBounds = ElementStdBounds.SlotGrid(EnumDialogArea.CenterFixed, 0, 38, 10, 1);

            Composers["hudvitals"] =
                capi.Gui
                .CreateCompo("inventory-hudvitals", bounds.FlatCopy().FixedGrow(0, 10))
                .BeginChildElements(bounds)
                .AddStatbar(bodyheatBounds, GuiStyle.XPBarColor, "bodyheatstatbar")
                .AddInvStatbar(thirstBarBounds, GuiStyle.DialogBlueBgColor, "thirststatbar")
                .EndChildElements()
                .Compose();

            bodyheatBar = Composers["hudvitals"].GetStatbar("bodyheatstatbar");
            thirstBar   = Composers["hudvitals"].GetStatbar("thirststatbar");

            bodyheatBar.SetLineInterval((float)2);
            bodyheatBar.FlashTime = 2;
            bodyheatBar.SetMinMax((float)0, (float)12);
            bodyheatBar.ShowValueOnHover = false;


            thirstBar.SetLineInterval((float)100);
            thirstBar.FlashTime = 2;
            thirstBar.SetMinMax((float)0, (float)1500);

            if (entity != null)
            {
                this.UpdateBodyheat();
                this.UpdateThirst();

                TryOpen();
            }
        }
Exemple #9
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 #10
0
        void SetupDialog()
        {
            ItemSlot hoveredSlot = capi.World.Player.InventoryManager.CurrentHoveredSlot;

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

            ElementBounds mainBounds    = ElementBounds.Fixed(0, 0, 100, 50);
            ElementBounds iceBoundsLeft = ElementStdBounds.SlotGrid(EnumDialogArea.None, 0, 102, 1, 1);
            ElementBounds slotsBounds   = ElementStdBounds.SlotGrid(EnumDialogArea.None, 92, 102, 4, 1);

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

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

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


            ClearComposers();
            SingleComposer = capi.Gui
                             .CreateCompo("iceboxcomposer" + BlockEntityPosition, dialogBounds)
                             .AddShadedDialogBG(bgBounds)
                             .AddDialogTitleBar(DialogTitle, OnTitleBarClose)
                             .BeginChildElements(bgBounds)
                             .AddItemSlotGrid(Inventory, SendInvPacket, 1, new int[] { 0 }, iceBoundsLeft)
                             .AddItemSlotGrid(Inventory, SendInvPacket, 4, new int[] { 1, 2, 3, 4 }, slotsBounds)
                             .EndChildElements()
                             .Compose()
            ;

            if (hoveredSlot != null)
            {
                SingleComposer.OnMouseMove(new MouseEvent(capi.Input.MouseX, capi.Input.MouseY));
            }
        }
Exemple #11
0
        private void InitDialog()
        {
            ElementBounds slotBounds = ElementStdBounds.Slot(0, GuiStyle.TitleBarHeight);

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

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

            ElementBounds bgBounds = ElementStdBounds.DialogBackground();

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

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

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

            SingleComposer.GetScrollbar("scrollbar").SetHeights(
                (float)insetBounds.fixedHeight, (float)textBounds.fixedHeight
                );
        }
Exemple #12
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();
        }
        public void SetupDialog()
        {
            ItemSlot hoveredSlot = capi.World.Player.InventoryManager.CurrentHoveredSlot;

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

            ElementBounds quernBounds = ElementBounds.Fixed(0, 0, 400, 400);


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

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

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

            ClearComposers();
            SingleComposer = capi.Gui
                             .CreateCompo("BlockEntityTinkerTable" + BlockEntityPosition, dialogBounds)
                             .AddShadedDialogBG(bgBounds)
                             .AddDialogTitleBar(DialogTitle, OnTitleBarClose)
                             .BeginChildElements(bgBounds)
                             .AddItemSlotGrid(Inventory, SendInvPacket, 1, new int[] { 0 }, ElementStdBounds.SlotGrid(EnumDialogArea.CenterMiddle, 0, 0, 1, 1), "targetSlot")
            ;

            IModularItem item = Inventory[0].Itemstack?.Item as IModularItem;

            SlotDefinition[] slotdefs = item?.TinkerProps?.AvailableSlots;



            if (item != null && slotdefs != null)
            {
                var slots = item.GetSlots(Inventory[0].Itemstack);
                for (int i = 0; i < slotdefs.Length && i < Inventory.Count - 1; ++i)
                {
                    var       slotdef = slotdefs[i];
                    ItemStack stack   = slots[slotdef.SlotName];
                    int       invslot = i + 1;
                    if (stack == null)
                    {
                        stack = Inventory[invslot].Itemstack;
                    }
                    Inventory[invslot].Itemstack = stack;
                    SingleComposer = SingleComposer.AddItemSlotGrid(Inventory, SendInvPacket, 1, new int[] { invslot }, ElementStdBounds.SlotGrid(EnumDialogArea.CenterMiddle, slotdef.OffsetX, slotdef.OffsetY, 1, 1), "partSlot" + invslot.ToString());
                }
            }
            else if (Inventory[0].Itemstack?.Item == null && Inventory.Count >= 4)
            {
                SingleComposer = SingleComposer
                                 .AddItemSlotGrid(Inventory, SendInvPacket, 1, new int[] { 1 }, ElementStdBounds.SlotGrid(EnumDialogArea.CenterMiddle, 0, -90.0, 1, 1), "partSlot1");
                SingleComposer = SingleComposer
                                 .AddItemSlotGrid(Inventory, SendInvPacket, 1, new int[] { 3 }, ElementStdBounds.SlotGrid(EnumDialogArea.CenterMiddle, 0, 90.0, 1, 1), "partSlot2");
            }

            SingleComposer = SingleComposer.Compose();

            if (hoveredSlot != null)
            {
                SingleComposer.OnMouseMove(new MouseEvent(capi.Input.MouseX, capi.Input.MouseY));
            }
        }
Exemple #14
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();
        }
        void SetupDialog()
        {
            /*
             * double pad = GuiElementItemSlotGrid.unscaledSlotPadding;
             *
             * int rows = (int)Math.Ceiling(Inventory.Count / 2f); // row col number so 2,4,6,8
             *
             * ElementBounds barrelBoundsLeft = ElementBounds.Fixed(0, 30, 150, 200); // (0, 30, 150, 200);
             * ElementBounds barrelBoundsRight = ElementBounds.Fixed(0, 30, 150, 200); // (100, 30, 150, 200);
             *
             * ElementBounds slotBounds = ElementStdBounds.SlotGrid(EnumDialogArea.LeftFixed, pad, 20 + pad, 2, rows).FixedGrow(2 * pad, 1 * pad); // (EnumDialogArea.None, pad, 20 + pad, 2, rows).FixedGrow(2 * pad, 1 * pad);
             *
             * ElementBounds fullnessMeterBounds = ElementBounds.Fixed(150, 25, 40, 195); // X,Y Pos and Width, Heigth  // Good (200, 25, 40, 200)
             *
             * ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding, 10f);
             * 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)
             */

            double pad = GuiElementItemSlotGrid.unscaledSlotPadding;

            int rows = (int)Math.Ceiling(Inventory.Count / 2f);                                                                                 // row col number so 2,4,6,8

            ElementBounds barrelBoundsLeft  = ElementBounds.Fixed(0, 0, 150, 150);                                                              // (0, 30, 150, 200);
            ElementBounds barrelBoundsRight = ElementBounds.Fixed(0, 0, 150, 150);                                                              // (100, 30, 150, 200);

            ElementBounds slotBounds = ElementStdBounds.SlotGrid(EnumDialogArea.LeftFixed, pad, 20 + pad, 2, rows).FixedGrow(2 * pad, 1 * pad); // (EnumDialogArea.None, pad, 20 + pad, 2, rows).FixedGrow(2 * pad, 1 * pad);

            ElementBounds fullnessMeterBounds = ElementBounds.Fixed(150, 25, 40, 195);                                                          // X,Y Pos and Width, Heigth  // Good (200, 25, 40, 200)

            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding, 30f);

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

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

            ;

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



            SingleComposer = capi.Gui
                             .CreateCompo("blockentitysink" + BlockEntityPosition, dialogBounds)
                             .AddShadedDialogBG(bgBounds)
                             .AddDialogTitleBar(DialogTitle, OnTitleBarClose)
                             .BeginChildElements(bgBounds)
                             .AddItemSlotGrid(Inventory, SendInvPacket, 2, new int[] { 0, 2, 3, 4, 5, 6, 7, 8 }, slotBounds, "Slot") // ID Slots And Item Slot And Don't Use 1 it is being used by water.

                                                                                                                                     //.AddSmallButton("Empty", onEmptyClick, ElementBounds.Fixed(0, 140, 80, 25), EnumButtonStyle.Normal, EnumTextOrientation.Center)
                                                                                                                                     // .AddSmallButton("Fill", onFillClick, ElementBounds.Fixed(0, 100, 80, 25), EnumButtonStyle.Normal, EnumTextOrientation.Center)


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

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

                             .EndChildElements()
                             .Compose();
        }
        private void SetupDialog()
        {
            // title bar
            ElementBounds bgBounds     = ElementStdBounds.DialogBackground();
            ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithChild(bgBounds);

            SingleComposer = capi.Gui.CreateCompo("tailoring", dialogBounds)
                             .AddShadedDialogBG(bgBounds)
                             .AddDialogTitleBar("Tailoring", () => TryClose())
                             .BeginChildElements(bgBounds);
            ElementBounds titleBarBounds = ElementStdBounds.TitleBar();

            bgBounds.WithChild(titleBarBounds);

            // search text box
            ElementBounds searchBounds = ElementBounds.FixedSize(200, 30).FixedUnder(titleBarBounds);

            bgBounds.WithChild(searchBounds);
            SingleComposer.AddTextInput(searchBounds, (string newText) => {
                filterSearch = newText;
                FilterItems();
            }, CairoFont.WhiteSmallishText(), "search");
            SingleComposer.GetTextInput("search").SetPlaceHolderText("Search...");
            // SingleComposer.FocusElement(SingleComposer.GetTextInput("search").TabIndex);

            // prep for category dropdown
            string[]      characterDressTypeNames         = EnumCharacterDressType.GetNames(typeof(EnumCharacterDressType));
            List <string> filteredCharacterDressTypeNames = new List <string>();

            foreach (var characterDressTypeName in characterDressTypeNames)
            {
                if (categoryCount.ContainsKey(characterDressTypeName.ToLowerInvariant()))
                {
                    filteredCharacterDressTypeNames.Add(characterDressTypeName);
                }
            }
            string[] values = new string[filteredCharacterDressTypeNames.Count + 1];
            values[0] = "";
            filteredCharacterDressTypeNames.CopyTo(0, values, 1, filteredCharacterDressTypeNames.Count);
            string[] names = new string[filteredCharacterDressTypeNames.Count + 1];
            names[0] = "(Show all)";
            filteredCharacterDressTypeNames.CopyTo(0, names, 1, filteredCharacterDressTypeNames.Count);

            // category dropdown
            ElementBounds categoryDropdownBounds = ElementBounds.FixedSize(150, 30).FixedUnder(titleBarBounds).FixedRightOf(searchBounds, PADDING);

            bgBounds.WithChild(categoryDropdownBounds);
            SingleComposer.AddDropDown(values, names, 0, (value, selected) => {
                filterCategory = value;
                FilterItems();
            }, categoryDropdownBounds, "category");

            // stacklist
            ElementBounds stacklistBounds = ElementBounds.FixedSize(400, STACKLIST_HEIGHT).FixedUnder(searchBounds, PADDING);

            bgBounds.WithChild(stacklistBounds);
            ElementBounds clipBounds      = stacklistBounds.ForkBoundingParent();
            ElementBounds insetBounds     = stacklistBounds.FlatCopy().FixedGrow(6).WithFixedOffset(-3, -3);
            ElementBounds scrollbarBounds = insetBounds.CopyOffsetedSibling(3 + stacklistBounds.fixedWidth + 7).WithFixedWidth(20);

            SingleComposer
            .BeginClip(clipBounds)
            .AddInset(insetBounds, 3)
            .AddInteractiveElement(new GuiElementHandbookListWithTooltips(capi, stacklistBounds, (int index) => {
                OnSelectProduct((shownStacklistItems[index] as GuiHandbookItemStackPage).Stack);
            }, shownStacklistItems), "stacklist")
            .EndClip()
            .AddVerticalScrollbar((float value) => {
                GuiElementHandbookList stacklist = SingleComposer.GetHandbookStackList("stacklist");
                stacklist.insideBounds.fixedY    = 3 - value;
                stacklist.insideBounds.CalcWorldBounds();
            }, scrollbarBounds, "scrollbar")
            ;
            UpdateStacklistScrollbar();

            // costLabel
            ElementBounds costLabelBounds = ElementBounds.FixedSize(300, 80).FixedUnder(clipBounds, PADDING);

            bgBounds.WithChild(costLabelBounds);
            SingleComposer.AddDynamicText("", CairoFont.WhiteSmallText(), EnumTextOrientation.Left, costLabelBounds, "costLabel");

            // craftButton
            ElementBounds craftButtonBounds = ElementBounds
                                              .FixedSize(0, 0)
                                              .FixedUnder(clipBounds, PADDING)
                                              .WithAlignment(EnumDialogArea.RightFixed)
                                              .WithFixedPadding(20, 4)
                                              .WithFixedAlignmentOffset(-11, 1)
            ;

            bgBounds.WithChild(craftButtonBounds);
            SingleComposer.AddSmallButton("Craft", () => {
                OnCraftButtonClicked();
                return(true);
            }, craftButtonBounds, EnumButtonStyle.Normal, EnumTextOrientation.Center, "craftButton");
            var craftButton = SingleComposer.GetButton("craftButton");

            craftButton.Enabled = false;

            SingleComposer.EndChildElements(); // bgBounds
            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()
            ;
        }
        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();
        }
Exemple #19
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();
        }
        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;
        }
Exemple #21
0
        private void SetupDialog(int numSlots, int numInstalledUpgrades)
        {
            // title bar
            var bgBounds     = ElementStdBounds.DialogBackground();
            var dialogBounds = ElementStdBounds.AutosizedMainDialog.WithChild(bgBounds);

            int    searchCaretPos;
            string searchText;
            bool   searchHasFocus;

            if (SingleComposer == null)
            {
                SingleComposer = capi.Gui.CreateCompo("chardis", dialogBounds);
                searchCaretPos = 0;
                searchText     = "";
                searchHasFocus = true;
            }
            else
            {
                var oldSearch = SingleComposer.GetTextInput(SearchBoxKey);
                searchCaretPos = oldSearch?.CaretPosInLine ?? 0;
                searchText     = oldSearch?.GetText() ?? "";
                searchHasFocus = oldSearch?.HasFocus ?? true;
                SingleComposer.Clear(dialogBounds);
            }

            var numVisibleSlots = GetFilteredSlotCount();
            var rows            = (int)Math.Ceiling(numVisibleSlots / (double)GridColumns);

            SingleComposer
            .AddShadedDialogBG(bgBounds)
            .AddDialogTitleBar(Lang.Get("chardis:title"), () => TryClose())
            .BeginChildElements(bgBounds);
            var titleBarBounds = ElementStdBounds.TitleBar();

            bgBounds.WithChild(titleBarBounds);

            // search text box
            var searchBounds = ElementBounds.FixedSize(200, 30).FixedUnder(titleBarBounds).WithFixedOffset(-InsetSize, 0);

            bgBounds.WithChild(searchBounds);
            SingleComposer.AddInteractiveElement(new TextBox(capi, searchBounds, FilterItems, CairoFont.WhiteSmallishText()), SearchBoxKey);

            var searchBox = SingleComposer.GetTextInput(SearchBoxKey);

            searchBox.SetPlaceHolderText(Lang.Get("chardis:search-placeholder"));
            searchBox.LoadValue(searchText);
            searchBox.SetCaretPos(searchCaretPos);
            if (searchHasFocus)
            {
                SingleComposer.FocusElement(SingleComposer.GetTextInput(SearchBoxKey).TabIndex);
            }

            if (_upgradeSlot != null)
            {
                var countBounds = ElementBounds.FixedSize(32, 32).FixedUnder(titleBarBounds, 10).WithAlignment(EnumDialogArea.RightFixed);
                bgBounds.WithChild(countBounds);
                SingleComposer.AddInteractiveElement(new UpgradeSlot(capi, countBounds, _upgradeSlot));
            }

            // stacklist
            var stacklistBounds =
                ElementBounds.FixedSize(410, StackListHeight).FixedUnder(searchBounds, Padding);

            bgBounds.WithChild(stacklistBounds);
            var clipBounds      = stacklistBounds.ForkBoundingParent();
            var insetBounds     = stacklistBounds.FlatCopy().FixedGrow(6).WithFixedOffset(-3, -3);
            var scrollbarBounds =
                insetBounds.CopyOffsetedSibling(3 + stacklistBounds.fixedWidth + 7).WithFixedWidth(20);

            var pad        = GuiElementItemSlotGridBase.unscaledSlotPadding;
            var inv        = _chardisBlockEntity.Inventory;
            var slotBounds = ElementStdBounds.SlotGrid(EnumDialogArea.None, pad, 40 + pad, GridColumns, 1).FixedGrow(2 * pad, 0);

            SingleComposer
            .BeginClip(clipBounds)
            .AddInset(insetBounds, InsetSize)
            .AddItemSlotGrid(
                inv,
                DoSendPacket,
                GridColumns,
                slotBounds,
                StackListKey
                )
            .EndClip()
            ;

            var stacklist = SingleComposer.GetSlotGrid(StackListKey);

            SingleComposer.AddVerticalScrollbar(value =>
            {
                if (SingleComposer.GetSlotGrid(StackListKey).Bounds.fixedHeight > StackListHeight)
                {
                    stacklist.Bounds.fixedY = InsetSize - value;
                }
                else
                {
                    stacklist.Bounds.fixedY = 0;
                }
                stacklist.Bounds.CalcWorldBounds();
            }, scrollbarBounds, ScrollBarKey)
            ;

            stacklist.Bounds.fixedHeight = rows * (GuiElementPassiveItemSlot.unscaledSlotSize +
                                                   GuiElementItemSlotGridBase.unscaledSlotPadding);
            stacklist.Bounds.CalcWorldBounds();
            var scrollbar = SingleComposer.GetScrollbar(ScrollBarKey);

            scrollbar.SetHeights(
                StackListHeight,
                Math.Max(StackListHeight, (float)stacklist.Bounds.fixedHeight)
                );
            scrollbar.OnMouseWheel(capi, new MouseWheelEventArgs {
                deltaPrecise = 999999
            });                                // scroll to top hax

            SingleComposer.EndChildElements(); // bgBounds
            SingleComposer.Compose();
        }
        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);
            }
        }
        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 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; };
             * }*/
        }
        public GuiDialogTrader(InventoryTrader traderInventory, EntityAgent owningEntity, ICoreClientAPI capi) : base(capi)
        {
            this.traderInventory = traderInventory;
            this.owningEntity    = owningEntity;



            double pad = GuiElementItemSlotGrid.unscaledSlotPadding;

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

            ElementBounds rightBotSlotBounds = ElementStdBounds.SlotGrid(EnumDialogArea.None, pad + leftTopSlotBounds.fixedWidth + 20, 15 + pad, 4, 1).FixedGrow(2 * pad, 2 * pad).FixedUnder(rightTopSlotBounds, 5);
            ElementBounds leftBotSlotBounds  = ElementStdBounds.SlotGrid(EnumDialogArea.None, pad, 15 + pad, 4, 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(ElementGeometrics.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;



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

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

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


            SingleComposer =
                capi.Gui
                .CreateCompo("itemlootrandomizer", dialogBounds, false)
                .AddDialogBG(bgBounds, true)
                .AddDialogTitleBar(owningEntity.GetBehavior <EntityBehaviorNameTag>().DisplayName + " Has Wares, If You Have Coin", OnTitleBarClose)
                .BeginChildElements(bgBounds)
                .AddStaticText("You can Buy", CairoFont.WhiteDetailText(), ElementBounds.Fixed(pad, 20 + pad, 150, 25))
                .AddStaticText("You can Sell", CairoFont.WhiteDetailText(), ElementBounds.Fixed(leftTopSlotBounds.fixedWidth + pad + 20, 20 + pad, 150, 25))

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

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

                .AddStaticText("Your Selection", CairoFont.WhiteDetailText(), ElementBounds.Fixed(pad, 40 + 2 * pad + leftTopSlotBounds.fixedHeight, 150, 25))
                .AddStaticText("Your Offer", CairoFont.WhiteDetailText(), ElementBounds.Fixed(leftTopSlotBounds.fixedWidth + pad + 20, 40 + 2 * pad + leftTopSlotBounds.fixedHeight, 150, 25))

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

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


                .EndChildElements()
                .Compose()
            ;

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

            CalcAndUpdateAssetsDisplay();
        }