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 override void OnOwnPlayerDataReceived() { base.OnOwnPlayerDataReceived(); ElementBounds radialRoot = ElementBounds.Fixed(EnumDialogArea.LeftMiddle, 0, 0, 25, 25); ElementBounds dialogBounds = radialRoot.CopyOffsetedSibling(0, 0, 200, 100); ElementBounds bgBounds = dialogBounds.CopyOffsetedSibling(); radialRoot = radialRoot.WithFixedOffset(165, 15); SingleComposer = capi.Gui.CreateCompo("claim", dialogBounds) .AddDialogTitleBar("Claims", () => TryClose(), CairoFont.WhiteSmallText()) .AddDialogBG(bgBounds) .AddTextToggleButtons(new string[] { "New", "Start", "End", "Add", "Cancel", "Save", "U", "D", "N", "S", "E", "W" }, CairoFont.ButtonText().WithFontSize(10), i => { int m = op ? -1 : 1; switch (i) { case 0: capi.SendChatMessage("/land claim new"); break; case 1: capi.SendChatMessage("/land claim start"); break; case 2: capi.SendChatMessage("/land claim end"); break; case 3: capi.SendChatMessage("/land claim add"); break; case 4: capi.SendChatMessage("/land claim cancel"); break; case 5: capi.SendChatMessage("/land claim save " + capi.World.Claims.All.Count); break; case 6: capi.SendChatMessage("/land claim gu " + m); break; case 7: capi.SendChatMessage("/land claim gd " + m); break; case 8: capi.SendChatMessage("/land claim gn " + m); break; case 9: capi.SendChatMessage("/land claim gs " + m); break; case 10: capi.SendChatMessage("/land claim ge " + m); break; case 11: capi.SendChatMessage("/land claim gw " + m); break; default: break; } capi.Event.RegisterCallback(dt => SingleComposer.GetToggleButton("buttons-" + i).On = false, 50); }, new ElementBounds[] { radialRoot.CopyOffsetedSibling(-150, -25, 25), radialRoot.CopyOffsetedSibling(-150, 0, 25), radialRoot.CopyOffsetedSibling(-150, 25, 25), radialRoot.CopyOffsetedSibling(-100, 0, 25), radialRoot.CopyOffsetedSibling(-100, -25, 25), radialRoot.CopyOffsetedSibling(-100, 25, 25), radialRoot.CopyOffsetedSibling(-50, -25), radialRoot.CopyOffsetedSibling(-50, 25), radialRoot.CopyOffsetedSibling(0, -25), radialRoot.CopyOffsetedSibling(0, 25), radialRoot.CopyOffsetedSibling(25, 0), radialRoot.CopyOffsetedSibling(-25, 0), radialRoot, }, "buttons") .AddToggleButton("OP", CairoFont.ButtonText().WithFontSize(10), b => { op = b; }, radialRoot) .Compose(); }
public override void OnOwnPlayerDataReceived() { base.OnOwnPlayerDataReceived(); config = capi.ModLoader.GetModSystem <ConfigLoader>().Config; ElementBounds dialogBounds = ElementBounds.Fixed(EnumDialogArea.LeftMiddle, 30, 0, 465, 500); ElementBounds bgBounds = ElementBounds.Fixed(EnumDialogArea.LeftMiddle, 0, -200, 465, 100); string[] colors; List <string> c = new List <string>() { "Random" }; string[] names = Enum.GetNames(typeof(KnownColor)); for (int i = 28; i < 166; i++) { c.Add(names[i]); } colors = c.ToArray(); config.SetColorIndex = config.SetColorIndex < 0 ? 0 : config.SetColorIndex; color = colors[config.SetColorIndex]; UpdateDropDown(colors, color); SingleComposer = capi.Gui.CreateCompo("waypointfrontend", dialogBounds) .AddDialogTitleBar("Waypoint Utils", VClose, CairoFont.WhiteSmallText()) .AddDialogBG(bgBounds) .AddTextInput(ElementBounds.Fixed(EnumDialogArea.LeftMiddle, 86.5, -200, 370, 20), OnTextChanged, null, "textinput") .AddDropDown(colors, colors, config.SetColorIndex, (newval, on) => { UpdateDropDown(colors, newval); capi.TriggerChatMessage(".wpcfg save"); capi.Event.RegisterCallback(dt => capi.ModLoader.GetModSystem <WaypointUtilSystem>().Update(), 100); }, ElementBounds.Fixed(EnumDialogArea.LeftMiddle, 250, -170, 125, 10), "dropdown") .AddTextToggleButtons(new string[] { "Create WP", "Purge Death Waypoints", "Toggle Floaty Waypoints", "Toggle Block Waypoints", "Toggle This Color" }, CairoFont.ButtonText().WithFontSize(10), i => { capi.Event.RegisterCallback(j => { SingleComposer.Dispose(); OnOwnPlayerDataReceived(); SingleComposer.Compose(); capi.TriggerChatMessage(".wpcfg save"); }, 100); switch (i) { case 0: CreateWaypoint(); break; case 1: capi.TriggerChatMessage(".wpcfg pdw"); break; case 2: capi.TriggerChatMessage(".wpcfg open"); break; case 3: capi.TriggerChatMessage(".wpcfg perblockwaypoints"); break; case 4: if (config.DisabledColors.Contains(intColor)) { config.DisabledColors.Remove(intColor); } else { config.DisabledColors.Add(intColor); } break; default: break; } capi.Event.RegisterCallback(dt => capi.ModLoader.GetModSystem <WaypointUtilSystem>().Update(), 100); }, new ElementBounds[] { ElementBounds.Fixed(EnumDialogArea.LeftMiddle, 5, -200, 80, 25), ElementBounds.Fixed(EnumDialogArea.LeftMiddle, 5, -170, 80, 35), ElementBounds.Fixed(EnumDialogArea.LeftMiddle, 85, -170, 80, 35), ElementBounds.Fixed(EnumDialogArea.LeftMiddle, 165, -170, 80, 35), ElementBounds.Fixed(EnumDialogArea.LeftMiddle, 380, -170, 80, 35), }); }