public static IEnumerable <T> FindAllByName <T>(this GuiTab Tab, string Name) where T : class { return(findAllByNameTemplate <T>(Name, Tab.FindAllByName)); }
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 static T FindById <T>(this GuiTab Tab, string Id) where T : class { return(findByIdTemplate <T>(Id, Tab.FindById)); }
private void OnDetailViewTabClicked(int t1, GuiTab t2) { browseHistory.Clear(); OnTabClicked(t1, t2); }
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); } }
public static T FindByName <T>(this GuiTab Tab, string Name) where T : class { return(findByNameTemplate <T>(Name, Tab.FindByName)); }
public static T FindChildByProperty <T>(this GuiTab Tab, Func <T, bool> Property = null) where T : class { return(findChildByPropertyTemplate <T>(Tab.Children, Property)); }
public static T FindByNameEx <T>(this GuiTab Tab, string Name, int TypeId) where T : class { return(findByNameExTemplate <T>(Name, TypeId, Tab.FindByNameEx)); }
void initOverviewGui() { ElementBounds searchFieldBounds = ElementBounds.Fixed(GuiStyle.ElementToDialogPadding - 2, 45, 300, 30); ElementBounds stackListBounds = ElementBounds.Fixed(0, 0, 400, listHeight).FixedUnder(searchFieldBounds, 5); ElementBounds clipBounds = stackListBounds.ForkBoundingParent(); ElementBounds insetBounds = stackListBounds.FlatCopy().FixedGrow(6).WithFixedOffset(-3, -3); ElementBounds scrollbarBounds = insetBounds.CopyOffsetedSibling(3 + stackListBounds.fixedWidth + 7).WithFixedWidth(20); ElementBounds closeButtonBounds = ElementBounds .FixedSize(0, 0) .FixedUnder(clipBounds, 2 * 5 + 8) .WithAlignment(EnumDialogArea.RightFixed) .WithFixedPadding(20, 4) .WithFixedAlignmentOffset(2, 0) ; // 2. Around all that is 10 pixel padding ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding); bgBounds.BothSizing = ElementSizing.FitToChildren; bgBounds.WithChildren(insetBounds, stackListBounds, scrollbarBounds, closeButtonBounds); // 3. Finally Dialog ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle); ElementBounds tabBounds = ElementBounds.Fixed(-130, 35, 130, 545); GuiTab[] tabs = new GuiTab[2]; tabs[0] = new GuiTab() { DataInt = 0, Name = Lang.Get("Blocks and Items"), }; tabs[1] = new GuiTab() { DataInt = 1, Name = Lang.Get("Crafting mechanics") }; overviewGui = capi.Gui .CreateCompo("handbook-overview", dialogBounds) .AddShadedDialogBG(bgBounds, true) .AddDialogTitleBar(Lang.Get("Survival Handbook"), OnTitleBarClose) //.AddVerticalTabs(tabs, tabBounds, OnTabClicked, "verticalTabs") .AddTextInput(searchFieldBounds, FilterItemsBySearchText, CairoFont.WhiteSmallishText(), "searchField") .BeginChildElements(bgBounds) .BeginClip(clipBounds) .AddInset(insetBounds, 3) .AddHandbookStackList(stackListBounds, onLeftClickListElement, listElements, "stacklist") .EndClip() .AddVerticalScrollbar(OnNewScrollbarvalueOverviewPage, scrollbarBounds, "scrollbar") .AddSmallButton(Lang.Get("Close Handbook"), OnButtonClose, closeButtonBounds) .EndChildElements() .Compose() ; overviewGui.GetScrollbar("scrollbar").SetHeights( (float)listHeight, (float)overviewGui.GetHandbookStackList("stacklist").insideBounds.fixedHeight ); }
private void OnTabClicked(int index, GuiTab tab) { }
public static IEnumerable <T> FindDescendantsByProperty <T>(this GuiTab Tab, Func <T, bool> Property = null) where T : class { return(findDescendantsByPropertyTemplate <T>(Tab.Children, Property)); }