Exemplo n.º 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;
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
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
                );
        }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
0
        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();
        }