private void SetupDialog() { try { IAsset maxEssences = capi.Assets.TryGet("alchemy:config/essences.json"); imageLocation = capi.Assets.TryGet("alchemy:textures/hud/alchemyhud.png").Location; if (maxEssences != null) { maxEssenceDic = maxEssences.ToObject <Dictionary <string, float> >(); } maxEssenceDic.Remove("recall"); maxEssenceDic.Remove("duration"); maxEssenceDic.Remove("health"); } catch (Exception e) { capi.World.Logger.Error("Failed loading potion effects for potion {0}. Will ignore. Exception: {1}", e); } ElementBounds textBounds = ElementBounds.Fixed(EnumDialogArea.RightBottom, 0, 0, 100, 100); CairoFont font = CairoFont.WhiteSmallText().WithLineHeightMultiplier(1.2); SingleComposer = capi.Gui.CreateCompo("inactive", textBounds) .AddDynamicCustomDraw(textBounds.ForkChild(), new DrawDelegateWithBounds(OnDraw), "potioninactive") .AddHoverText("shouldn't see this!", font, 400, textBounds.ForkChild(), "potionstatus") ; id = capi.World.RegisterGameTickListener(dt => UpdateText(), 100); }
public override void StartClientSide(ICoreClientAPI api) { capi = api; stackSizeFont = CairoFont.WhiteSmallText().WithFontSize((float)GuiStyle.DetailFontSize); stackSizeFont.FontWeight = FontWeight.Bold; stackSizeFont.Color = new double[] { 1, 1, 1, 1 }; stackSizeFont.StrokeColor = new double[] { 0, 0, 0, 1 }; stackSizeFont.StrokeWidth = RuntimeEnv.GUIScale + 0.25; litreTextTextures = new Dictionary <string, LoadedTexture>(); api.Settings.AddWatcher <float>("guiScale", (newvalue) => { stackSizeFont.StrokeWidth = newvalue + 0.25; foreach (var val in litreTextTextures) { val.Value.Dispose(); } litreTextTextures.Clear(); }); api.Event.LeaveWorld += Event_LeaveWorld; api.Event.LevelFinalize += Event_LevelFinalize; }
public virtual void ComposeEnvGui() { ElementBounds leftDlgBounds = Composers["playercharacter"].Bounds; CairoFont font = CairoFont.WhiteSmallText().WithLineHeightMultiplier(1.2); string envText = getEnvText(); int cntlines = 1 + Regex.Matches(envText, "\n").Count; double height = font.GetFontExtents().Height *font.LineHeightMultiplier *cntlines / RuntimeEnv.GUIScale; ElementBounds textBounds = ElementBounds.Fixed(0, 25, (int)(leftDlgBounds.InnerWidth / RuntimeEnv.GUIScale - 40), height); textBounds.Name = "textbounds"; ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding); bgBounds.Name = "bgbounds"; bgBounds.BothSizing = ElementSizing.FitToChildren; bgBounds.WithChildren(textBounds); ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.None).WithFixedPosition(leftDlgBounds.renderX / RuntimeEnv.GUIScale, leftDlgBounds.renderY / RuntimeEnv.GUIScale + leftDlgBounds.OuterHeight / RuntimeEnv.GUIScale + 10); dialogBounds.Name = "dialogbounds"; Composers["environment"] = capi.Gui .CreateCompo("environment", dialogBounds) .AddShadedDialogBG(bgBounds, true) .AddDialogTitleBar(Lang.Get("Environment"), () => dlg.OnTitleBarClose()) .BeginChildElements(bgBounds) .AddDynamicText(envText, font, textBounds, "dyntext") .EndChildElements() .Compose() ; }
public void Recompose(ICoreClientAPI capi) { Texture?.Dispose(); Texture = new TextTextureUtil(capi).GenTextTexture(Stack.GetName(), CairoFont.WhiteSmallText()); scissorBounds = ElementBounds.FixedSize(50, 50); scissorBounds.ParentBounds = capi.Gui.WindowBounds; }
private void ComposeDialog() { ElementBounds leftColumn = ElementBounds.Fixed(0, 28, 120, 25); ElementBounds rightColumn = leftColumn.RightCopy(); ElementBounds buttonRow = ElementBounds.Fixed(0, 28, 360, 25); ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding); bgBounds.BothSizing = ElementSizing.FitToChildren; bgBounds.WithChildren(leftColumn, rightColumn); ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog .WithAlignment(EnumDialogArea.CenterMiddle) .WithFixedAlignmentOffset(-GuiStyle.DialogToScreenPadding, 0); if (SingleComposer != null) { SingleComposer.Dispose(); } SingleComposer = capi.Gui .CreateCompo("worldmap-addwp", dialogBounds) .AddShadedDialogBG(bgBounds, false) .AddDialogTitleBar(Lang.Get("Add waypoint"), () => TryClose()) .BeginChildElements(bgBounds) .AddStaticText(Lang.Get("Name"), CairoFont.WhiteSmallText(), leftColumn = leftColumn.FlatCopy()) .AddTextInput(rightColumn = rightColumn.FlatCopy().WithFixedWidth(200), onNameChanged, CairoFont.TextInput(), "nameInput") .AddRichtext(Lang.Get("waypoint-color"), CairoFont.WhiteSmallText(), leftColumn = leftColumn.BelowCopy(0, 5)) .AddTextInput(rightColumn = rightColumn.BelowCopy(0, 5).WithFixedWidth(150), onColorChanged, CairoFont.TextInput(), "colorInput") .AddDynamicCustomDraw(rightColumn.FlatCopy().WithFixedWidth(30).WithFixedOffset(160, 0), onDrawColorRect, "colorRect") .AddStaticText(Lang.Get("Icon"), CairoFont.WhiteSmallText(), leftColumn = leftColumn.BelowCopy(0, 9)) .AddDropDown( new string[] { "circle", "bee", "cave", "home", "ladder", "pick", "rocks", "ruins", "spiral", "star1", "star2", "trader", "vessel" }, new string[] { "<icon name=\"wpCircle\">", "<icon name=\"wpBee\">", "<icon name=\"wpCave\">", "<icon name=\"wpHome\">", "<icon name=\"wpLadder\">", "<icon name=\"wpPick\">", "<icon name=\"wpRocks\">", "<icon name=\"wpRuins\">", "<icon name=\"wpSpiral\">", "<icon name=\"wpStar1\">", "<icon name=\"wpStar2\">", "<icon name=\"wpTrader\">", "<icon name=\"wpVessel\">" }, 0, onIconSelectionChanged, rightColumn = rightColumn.BelowCopy(0, 5).WithFixedWidth(60), CairoFont.WhiteSmallishText(), "iconInput" ) .AddStaticText(Lang.Get("Pinned"), CairoFont.WhiteSmallText(), leftColumn = leftColumn.BelowCopy(0, 9)) .AddSwitch(onPinnedToggled, rightColumn = rightColumn.BelowCopy(0, 5).WithFixedWidth(200), "pinnedSwitch") .AddSmallButton(Lang.Get("Cancel"), onCancel, buttonRow.FlatCopy().FixedUnder(leftColumn, 0).WithFixedWidth(100), EnumButtonStyle.Normal) .AddSmallButton(Lang.Get("Save"), onSave, buttonRow.FlatCopy().FixedUnder(leftColumn, 0).WithFixedWidth(100).WithAlignment(EnumDialogArea.RightFixed), EnumButtonStyle.Normal, key: "saveButton") .EndChildElements() .Compose() ; SingleComposer.GetButton("saveButton").Enabled = false; }
public void Init(ICoreClientAPI capi) { if (Text.Length < 255) { Text = Lang.Get(Text); } comps = VtmlUtil.Richtextify(capi, Text, CairoFont.WhiteSmallText().WithLineHeightMultiplier(1.2)); titleCached = Lang.Get(Title); }
public GuiElementSubtitleList(ICoreClientAPI capi, ElementBounds bounds) : base(capi, bounds) { textTexture = new LoadedTexture(capi); Font = CairoFont.WhiteSmallText(); textUtil = new TextDrawUtil(); for (int i = 0; i < MAX_SOUNDS; i++) { soundList[i] = new Sound(); } }
protected void SetupDialog() { _isSetup = true; var dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.RightBottom) .WithFixedAlignmentOffset(-GuiStyle.DialogToScreenPadding, -GuiStyle.DialogToScreenPadding); const int switchSize = 20; const int switchPadding = 10; var font = CairoFont.WhiteSmallText(); var switchBounds = ElementBounds.Fixed(210.0, GuiStyle.TitleBarHeight, switchSize, switchSize); var textBounds = ElementBounds.Fixed(0, GuiStyle.TitleBarHeight + 1.0, 200.0, switchSize); var advancedButtonBounds = ElementBounds.Fixed(240.0, GuiStyle.TitleBarHeight, 110.0, switchSize); var bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding); bgBounds.BothSizing = ElementSizing.FitToChildren; var composer = capi.Gui.CreateCompo("volumetricShadingConfigure", dialogBounds) .AddShadedDialogBG(bgBounds) .AddDialogTitleBar("Volumetric Shading Configuration", OnTitleBarCloseClicked) .BeginChildElements(bgBounds); foreach (var option in ConfigOptions) { composer.AddStaticText(option.Text, font, textBounds); if (option.Tooltip != null) { composer.AddHoverText(option.Tooltip, font, 250, textBounds.FlatCopy()); } if (option.SwitchKey != null) { composer.AddSwitch(option.ToggleAction, switchBounds, option.SwitchKey, switchSize); } if (option.AdvancedAction != null) { composer.AddSmallButton("Advanced...", option.AdvancedAction, advancedButtonBounds); } switchBounds = switchBounds.BelowCopy(fixedDeltaY: switchPadding); textBounds = textBounds.BelowCopy(fixedDeltaY: switchPadding); advancedButtonBounds = advancedButtonBounds.BelowCopy(fixedDeltaY: switchPadding); } SingleComposer = composer.EndChildElements().Compose(); }
protected void SetupDialog() { _isSetup = true; var dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.RightBottom) .WithFixedAlignmentOffset(-GuiStyle.DialogToScreenPadding, -GuiStyle.DialogToScreenPadding); const int switchSize = 20; const int switchPadding = 10; const double sliderWidth = 200.0; var font = CairoFont.WhiteSmallText(); var switchBounds = ElementBounds.Fixed(250, GuiStyle.TitleBarHeight, switchSize, switchSize); var textBounds = ElementBounds.Fixed(0, GuiStyle.TitleBarHeight + 1.0, 240.0, switchSize); var bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding); bgBounds.BothSizing = ElementSizing.FitToChildren; var composer = capi.Gui.CreateCompo(DialogKey, dialogBounds) .AddShadedDialogBG(bgBounds) .AddDialogTitleBar(DialogTitle, OnTitleBarCloseClicked) .BeginChildElements(bgBounds); foreach (var option in ConfigOptions) { composer.AddStaticText(option.Text, font, textBounds); if (option.Tooltip != null) { composer.AddHoverText(option.Tooltip, font, 260, textBounds); } if (option.SliderKey != null) { composer.AddSlider(option.SlideAction, switchBounds.FlatCopy().WithFixedWidth(sliderWidth), option.SliderKey); } else if (option.SwitchKey != null) { composer.AddSwitch(option.ToggleAction, switchBounds, option.SwitchKey, switchSize); } textBounds = textBounds.BelowCopy(fixedDeltaY: switchPadding); switchBounds = switchBounds.BelowCopy(fixedDeltaY: switchPadding); } SingleComposer = composer.EndChildElements().Compose(); foreach (var option in ConfigOptions.Where(option => option.SliderKey != null && !option.InstantSlider)) { SingleComposer.GetSlider(option.SliderKey).TriggerOnlyOnMouseUp(); } }
public override void OnOwnPlayerDataReceived() { base.OnOwnPlayerDataReceived(); ElementBounds textBounds = ElementBounds.Fixed(EnumDialogArea.LeftTop, 5, 5, 300, 256); double[] stroke = new double[] { 0, 0, 0, 1 }; SingleComposer = capi.Gui.CreateCompo("clock", textBounds) .AddDynamicText("", CairoFont.WhiteSmallText().WithStroke(stroke, 2), EnumTextOrientation.Justify, textBounds.ForkChild(), "clock") .Compose(); id = capi.World.RegisterGameTickListener(dt => UpdateText(), 100); }
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(); }
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 ); }
public override void RenderTo(ICoreClientAPI capi, double x, double y) { float size = (float)GuiElement.scaled(25); float pad = (float)GuiElement.scaled(10); int index = (int)((capi.ElapsedMilliseconds / 1000) % Stacks.Count); dummySlot.Itemstack = Stacks[index]; capi.Render.RenderItemstackToGui(dummySlot, x + pad + size / 2, y + size / 2, 100, size, ColorUtil.WhiteArgb, true, false, false); if (Texture == null) { Texture = new TextTextureUtil(capi).GenTextTexture(Name, CairoFont.WhiteSmallText()); } capi.Render.Render2DTexturePremultipliedAlpha( Texture.TextureId, (x + size + GuiElement.scaled(25)), y + size / 4 - 3, Texture.Width, Texture.Height, 50 ); }
public void OnShiftRightClick() { if (Api.Side == EnumAppSide.Client) { if (renameDlg == null) { renameDlg = new GuiDialogRenameTeleport("Rename", Pos, Api as ICoreClientAPI, CairoFont.WhiteSmallText()); } if (!renameDlg.IsOpened()) { renameDlg.TryOpen(); } } }
public GuiDialogRenameTeleport(string DialogTitle, BlockPos blockEntityPos, ICoreClientAPI capi, CairoFont font) : base(DialogTitle, capi) { this.font = font; this.blockEntityPos = blockEntityPos; if (blockEntityPos == null || TPNetManager.GetTeleport(blockEntityPos) == null) { capi.Logger.ModError("Unable to rename an unregistered teleport"); Dispose(); return; } ElementBounds elementBounds = ElementBounds.Fixed(0.0, 0.0, 150.0, 20.0); ElementBounds elementBounds2 = ElementBounds.Fixed(0.0, 15.0, 150.0, 25.0); ElementBounds elementBounds3 = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding); elementBounds3.BothSizing = ElementSizing.FitToChildren; ElementBounds bounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle).WithFixedAlignmentOffset(60.0 + GuiStyle.DialogToScreenPadding, GuiStyle.DialogToScreenPadding); float num3 = 250f; base.SingleComposer = capi.Gui.CreateCompo("blockentitytexteditordialog", bounds).AddShadedDialogBG(elementBounds3).AddDialogTitleBar(DialogTitle, OnTitleBarClose) .BeginChildElements(elementBounds3) .AddTextInput(elementBounds2 = elementBounds2.BelowCopy().WithFixedWidth(num3), null, CairoFont.WhiteSmallText(), "text") .AddSmallButton(Lang.Get("Cancel"), OnButtonCancel, elementBounds2 = elementBounds2.BelowCopy(0.0, 20.0).WithFixedSize(100.0, 20.0).WithAlignment(EnumDialogArea.LeftFixed) .WithFixedPadding(10.0, 2.0)) .AddSmallButton(Lang.Get("Save"), OnButtonSave, elementBounds2 = elementBounds2.FlatCopy().WithFixedSize(100.0, 20.0).WithAlignment(EnumDialogArea.RightFixed) .WithFixedPadding(10.0, 2.0)) .EndChildElements() .Compose(); base.SingleComposer.GetTextInput("text").SetValue(TPNetManager.GetTeleport(blockEntityPos).Name); }
public virtual void ComposeStatsGui() { ElementBounds leftDlgBounds = Composers["playercharacter"].Bounds; ElementBounds botDlgBounds = Composers["environment"].Bounds; ElementBounds leftColumnBounds = ElementBounds.Fixed(0, 25, 90, 20); ElementBounds rightColumnBounds = ElementBounds.Fixed(120, 30, 120, 8); ElementBounds leftColumnBoundsW = ElementBounds.Fixed(0, 0, 140, 20); ElementBounds rightColumnBoundsW = ElementBounds.Fixed(165, 0, 120, 20); EntityPlayer entity = capi.World.Player.Entity; double b = botDlgBounds.InnerHeight / RuntimeEnv.GUIScale + 10; ElementBounds bgBounds = ElementBounds .Fixed(0, 0, 130 + 100 + 5, leftDlgBounds.InnerHeight / RuntimeEnv.GUIScale - GuiStyle.ElementToDialogPadding - 20 + b) .WithFixedPadding(GuiStyle.ElementToDialogPadding) ; ElementBounds dialogBounds = bgBounds.ForkBoundingParent() .WithAlignment(EnumDialogArea.LeftMiddle) .WithFixedAlignmentOffset((leftDlgBounds.renderX + leftDlgBounds.OuterWidth + 10) / RuntimeEnv.GUIScale, b / 2) ; float?health = null; float?maxhealth = null; float?saturation = null; float?maxsaturation = null; getHealthSat(out health, out maxhealth, out saturation, out maxsaturation); float walkspeed = entity.Stats.GetBlended("walkspeed"); float healingEffectivness = entity.Stats.GetBlended("healingeffectivness"); float hungerRate = entity.Stats.GetBlended("hungerrate"); float rangedWeaponAcc = entity.Stats.GetBlended("rangedWeaponsAcc"); float rangedWeaponSpeed = entity.Stats.GetBlended("rangedWeaponsSpeed"); ITreeAttribute tempTree = entity.WatchedAttributes.GetTreeAttribute("bodyTemp"); float wetness = entity.WatchedAttributes.GetFloat("wetness"); string wetnessString = ""; if (wetness > 0.7) { wetnessString = Lang.Get("wetness_soakingwet"); } else if (wetness > 0.4) { wetnessString = Lang.Get("wetness_wet"); } else if (wetness > 0.1) { wetnessString = Lang.Get("wetness_slightlywet"); } Composers["playerstats"] = capi.Gui .CreateCompo("playerstats", dialogBounds) .AddShadedDialogBG(bgBounds, true) .AddDialogTitleBar(Lang.Get("Stats"), () => dlg.OnTitleBarClose()) .BeginChildElements(bgBounds) ; if (saturation != null) { Composers["playerstats"] .AddStaticText(Lang.Get("playerinfo-nutrition"), CairoFont.WhiteSmallText().WithWeight(Cairo.FontWeight.Bold), leftColumnBounds.WithFixedWidth(200)) .AddStaticText(Lang.Get("playerinfo-nutrition-Freeza"), CairoFont.WhiteDetailText(), leftColumnBounds = leftColumnBounds.BelowCopy().WithFixedWidth(90)) .AddStaticText(Lang.Get("playerinfo-nutrition-Vegita"), CairoFont.WhiteDetailText(), leftColumnBounds = leftColumnBounds.BelowCopy()) .AddStaticText(Lang.Get("playerinfo-nutrition-Krillin"), CairoFont.WhiteDetailText(), leftColumnBounds = leftColumnBounds.BelowCopy()) .AddStaticText(Lang.Get("playerinfo-nutrition-Cell"), CairoFont.WhiteDetailText(), leftColumnBounds = leftColumnBounds.BelowCopy()) .AddStaticText(Lang.Get("playerinfo-nutrition-Dairy"), CairoFont.WhiteDetailText(), leftColumnBounds = leftColumnBounds.BelowCopy()) .AddStatbar(rightColumnBounds = rightColumnBounds.BelowCopy(0, 16), GuiStyle.FoodBarColor, "fruitBar") .AddStatbar(rightColumnBounds = rightColumnBounds.BelowCopy(0, 12), GuiStyle.FoodBarColor, "vegetableBar") .AddStatbar(rightColumnBounds = rightColumnBounds.BelowCopy(0, 12), GuiStyle.FoodBarColor, "grainBar") .AddStatbar(rightColumnBounds = rightColumnBounds.BelowCopy(0, 12), GuiStyle.FoodBarColor, "proteinBar") .AddStatbar(rightColumnBounds = rightColumnBounds.BelowCopy(0, 12), GuiStyle.FoodBarColor, "dairyBar") ; leftColumnBoundsW = leftColumnBoundsW.FixedUnder(leftColumnBounds, -5); } Composers["playerstats"] .AddStaticText(Lang.Get("Physical"), CairoFont.WhiteSmallText().WithWeight(Cairo.FontWeight.Bold), leftColumnBoundsW.WithFixedWidth(200).WithFixedOffset(0, 23)) .Execute(() => { leftColumnBoundsW = leftColumnBoundsW.FlatCopy(); leftColumnBoundsW.fixedY += 5; }) ; if (health != null) { Composers["playerstats"] .AddStaticText(Lang.Get("Health Points"), CairoFont.WhiteDetailText(), leftColumnBoundsW = leftColumnBoundsW.BelowCopy()) .AddDynamicText(health + " / " + maxhealth, CairoFont.WhiteDetailText(), rightColumnBoundsW = rightColumnBoundsW.FlatCopy().WithFixedPosition(rightColumnBoundsW.fixedX, leftColumnBoundsW.fixedY).WithFixedHeight(30), "health") ; } if (saturation != null) { Composers["playerstats"] .AddStaticText(Lang.Get("Satiety"), CairoFont.WhiteDetailText(), leftColumnBoundsW = leftColumnBoundsW.BelowCopy()) .AddDynamicText((int)saturation + " / " + (int)maxsaturation, CairoFont.WhiteDetailText(), rightColumnBoundsW = rightColumnBoundsW.FlatCopy().WithFixedPosition(rightColumnBoundsW.fixedX, leftColumnBoundsW.fixedY), "satiety") ; } if (tempTree != null) { Composers["playerstats"] .AddStaticText(Lang.Get("Body Temperature"), CairoFont.WhiteDetailText(), leftColumnBoundsW = leftColumnBoundsW.BelowCopy()) .AddRichtext(tempTree == null ? "-" : getBodyTempText(tempTree), CairoFont.WhiteDetailText(), rightColumnBoundsW = rightColumnBoundsW.FlatCopy().WithFixedPosition(rightColumnBoundsW.fixedX, leftColumnBoundsW.fixedY), "bodytemp") ; } if (wetnessString.Length > 0) { Composers["playerstats"] .AddRichtext(wetnessString, CairoFont.WhiteDetailText(), leftColumnBoundsW = leftColumnBoundsW.BelowCopy()) ; } Composers["playerstats"] .AddStaticText(Lang.Get("Walk speed"), CairoFont.WhiteDetailText(), leftColumnBoundsW = leftColumnBoundsW.BelowCopy()) .AddDynamicText((int)Math.Round(100 * walkspeed) + "%", CairoFont.WhiteDetailText(), rightColumnBoundsW = rightColumnBoundsW.FlatCopy().WithFixedPosition(rightColumnBoundsW.fixedX, leftColumnBoundsW.fixedY), "walkspeed") .AddStaticText(Lang.Get("Healing effectivness"), CairoFont.WhiteDetailText(), leftColumnBoundsW = leftColumnBoundsW.BelowCopy()) .AddDynamicText((int)Math.Round(100 * healingEffectivness) + "%", CairoFont.WhiteDetailText(), rightColumnBoundsW = rightColumnBoundsW.FlatCopy().WithFixedPosition(rightColumnBoundsW.fixedX, leftColumnBoundsW.fixedY), "healeffectiveness") ; if (saturation != null) { Composers["playerstats"] .AddStaticText(Lang.Get("Hunger rate"), CairoFont.WhiteDetailText(), leftColumnBoundsW = leftColumnBoundsW.BelowCopy()) .AddDynamicText((int)Math.Round(100 * hungerRate) + "%", CairoFont.WhiteDetailText(), rightColumnBoundsW = rightColumnBoundsW.FlatCopy().WithFixedPosition(rightColumnBoundsW.fixedX, leftColumnBoundsW.fixedY), "hungerrate") ; } Composers["playerstats"] .AddStaticText(Lang.Get("Ranged Accuracy"), CairoFont.WhiteDetailText(), leftColumnBoundsW = leftColumnBoundsW.BelowCopy()) .AddDynamicText((int)Math.Round(100 * rangedWeaponAcc) + "%", CairoFont.WhiteDetailText(), rightColumnBoundsW = rightColumnBoundsW.FlatCopy().WithFixedPosition(rightColumnBoundsW.fixedX, leftColumnBoundsW.fixedY), "rangedweaponacc") .AddStaticText(Lang.Get("Ranged Charge Speed"), CairoFont.WhiteDetailText(), leftColumnBoundsW = leftColumnBoundsW.BelowCopy()) .AddDynamicText((int)Math.Round(100 * rangedWeaponSpeed) + "%", CairoFont.WhiteDetailText(), rightColumnBoundsW = rightColumnBoundsW.FlatCopy().WithFixedPosition(rightColumnBoundsW.fixedX, leftColumnBoundsW.fixedY), "rangedweaponchargespeed") .EndChildElements() .Compose() ; UpdateStatBars(); }
public void Init() { var descBounds = ElementBounds.Fixed(0, 30, 400, 80); ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding); bgBounds.BothSizing = ElementSizing.FitToChildren; dialogBounds = ElementStdBounds .AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle) .WithFixedAlignmentOffset(-GuiStyle.DialogToScreenPadding, 0); bgBounds.verticalSizing = ElementSizing.FitToChildren; bgBounds.horizontalSizing = ElementSizing.Fixed; bgBounds.fixedWidth = 300; #region Text var deliveryCosts = auctionSys.DeliveryCostsByDistance(traderEntity.Pos.XYZ, auction.SrcAuctioneerEntityPos); RichTextComponentBase[] stackComps = new RichTextComponentBase[] { new ItemstackTextComponent(capi, auction.ItemStack, 60, 10), new RichTextComponent(capi, auction.ItemStack.GetName() + "\r\n", CairoFont.WhiteSmallText()) }; stackComps = stackComps.Append(VtmlUtil.Richtextify(capi, auction.ItemStack.GetDescription(capi.World, new DummySlot(auction.ItemStack)), CairoFont.WhiteDetailText())); var font = CairoFont.WhiteDetailText(); double fl = font.UnscaledFontsize; ItemStack gearStack = auctionSys.SingleCurrencyStack; var deliveryCostComps = new RichTextComponentBase[] { new RichTextComponent(capi, Lang.Get("Delivery: {0}", deliveryCosts), font) { PaddingRight = 10, VerticalAlign = EnumVerticalAlign.Top }, new ItemstackTextComponent(capi, gearStack, fl * 2.5f, 0, EnumFloat.Inline) { VerticalAlign = EnumVerticalAlign.Top, offX = -GuiElement.scaled(fl * 0.5f), offY = -GuiElement.scaled(fl * 0.75f) } }; RichTextComponentBase[] totalCostComps = new RichTextComponentBase[] { new RichTextComponent(capi, Lang.Get("Total Cost: {0}", auction.Price + deliveryCosts), font) { PaddingRight = 10, VerticalAlign = EnumVerticalAlign.Top }, new ItemstackTextComponent(capi, gearStack, fl * 2.5f, 0, EnumFloat.Inline) { VerticalAlign = EnumVerticalAlign.Top, offX = -GuiElement.scaled(fl * 0.5f), offY = -GuiElement.scaled(fl * 0.75f) } }; #endregion Composers["confirmauctionpurchase"] = capi.Gui .CreateCompo("tradercreateauction-" + buyerEntity.EntityId, dialogBounds) .AddShadedDialogBG(bgBounds, true) .AddDialogTitleBar(Lang.Get("Purchase this item?"), OnCreateAuctionClose) .BeginChildElements(bgBounds) .AddRichtext(stackComps, descBounds, "itemstack") ; var ri = Composers["confirmauctionpurchase"].GetRichtext("itemstack"); ri.BeforeCalcBounds(); double y = Math.Max(110, descBounds.fixedHeight + 20); ElementBounds deliverySwitchBounds = ElementBounds.Fixed(0, y, 35, 25); ElementBounds deliveryTextBounds = ElementBounds.Fixed(0, y + 3, 250, 25).FixedRightOf(deliverySwitchBounds, 0); ElementBounds deliveryCostBounds = ElementBounds.Fixed(0, 0, 200, 30).FixedUnder(deliveryTextBounds, 20); ElementBounds totalCostBounds = ElementBounds.Fixed(0, 0, 150, 30).FixedUnder(deliveryCostBounds, 0); ElementBounds leftButton = ElementBounds.Fixed(EnumDialogArea.LeftFixed, 0, 0, 0, 0).WithFixedPadding(8, 5).FixedUnder(totalCostBounds, 15); ElementBounds rightButton = ElementBounds.Fixed(EnumDialogArea.RightFixed, 0, 0, 0, 0).WithFixedPadding(8, 5).FixedUnder(totalCostBounds, 15); Composers["confirmauctionpurchase"] .AddSwitch(onDeliveryModeChanged, deliverySwitchBounds, "delivery", 25) .AddStaticText(Lang.Get("Deliver to current trader"), CairoFont.WhiteSmallText(), deliveryTextBounds) .AddRichtext(deliveryCostComps, deliveryCostBounds, "deliveryCost") .AddRichtext(totalCostComps, totalCostBounds, "totalCost") .AddSmallButton(Lang.Get("Cancel"), OnCancel, leftButton) .AddSmallButton(Lang.Get("Purchase"), OnPurchase, rightButton, EnumButtonStyle.Normal, EnumTextOrientation.Left, "buysellButton") .EndChildElements() .Compose() ; Composers["confirmauctionpurchase"].GetSwitch("delivery").On = true; }
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), }); }
void ComposeDialog() { double elemToDlgPad = ElementGeometrics.ElementToDialogPadding; ElementBounds button = ElementBounds.Fixed(15, 40, 290, 30).WithFixedPadding(10, 2); ElementBounds dialogBounds = ElementBounds.Fixed(EnumDialogArea.LeftMiddle, 30, 0, 250, 500) .ForkBoundingParent(elemToDlgPad, elemToDlgPad, elemToDlgPad, elemToDlgPad) ; ClearComposers(); DialogComposers["loreList"] = capi.Gui .CreateCompo("loreList", dialogBounds, false) .AddDialogBG(ElementBounds.Fill) .AddDialogTitleBar("Journal Inventory", CloseIconPressed) ; for (int i = 0; i < journalitems.Count; i++) { int page = i; DialogComposers["loreList"].AddButton(journalitems[i].Title, () => { return(onClickItem(page)); }, button, CairoFont.WhiteSmallText(), EnumButtonStyle.None, EnumTextOrientation.Left, "button-" + i); DialogComposers["loreList"].GetButton("button-" + i).PlaySound = false; button = button.BelowCopy(); } DialogComposers["loreList"] .Compose() ; }
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(); }
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(); }
public GuiDialogSignPost(string DialogTitle, BlockPos blockEntityPos, string[] textByCardinalDirection, ICoreClientAPI capi, CairoFont signPostFont) : base(DialogTitle, capi) { this.signPostFont = signPostFont; this.blockEntityPos = blockEntityPos; ElementBounds line = ElementBounds.Fixed(0, 0, 150, 20); ElementBounds input = ElementBounds.Fixed(0, 15, 150, 25); // 2. Around all that is 10 pixel padding ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding); bgBounds.BothSizing = ElementSizing.FitToChildren; // 3. Finally Dialog ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.LeftTop) .WithFixedAlignmentOffset(60 + GuiStyle.DialogToScreenPadding, GuiStyle.DialogToScreenPadding); float inputLineY = 27; float textLineY = 32; float width = 250; SingleComposer = capi.Gui .CreateCompo("blockentitytexteditordialog", dialogBounds) .AddShadedDialogBG(bgBounds) .AddDialogTitleBar(DialogTitle, OnTitleBarClose) .BeginChildElements(bgBounds) .AddStaticText("North", CairoFont.WhiteDetailText(), line = line.BelowCopy(0, 0).WithFixedWidth(width)) .AddTextInput(input = input.BelowCopy(0, 0).WithFixedWidth(width), OnTextChangedDlg, CairoFont.WhiteSmallText(), "text0") .AddStaticText("Northeast", CairoFont.WhiteDetailText(), line = line.BelowCopy(0, textLineY).WithFixedWidth(width)) .AddTextInput(input = input.BelowCopy(0, inputLineY).WithFixedWidth(width), OnTextChangedDlg, CairoFont.WhiteSmallText(), "text1") .AddStaticText("East", CairoFont.WhiteDetailText(), line = line.BelowCopy(0, textLineY).WithFixedWidth(width)) .AddTextInput(input = input.BelowCopy(0, inputLineY).WithFixedWidth(width), OnTextChangedDlg, CairoFont.WhiteSmallText(), "text2") .AddStaticText("Southeast", CairoFont.WhiteDetailText(), line = line.BelowCopy(0, textLineY).WithFixedWidth(width)) .AddTextInput(input = input.BelowCopy(0, inputLineY).WithFixedWidth(width), OnTextChangedDlg, CairoFont.WhiteSmallText(), "text3") .AddStaticText("South", CairoFont.WhiteDetailText(), line = line.BelowCopy(0, textLineY).WithFixedWidth(width)) .AddTextInput(input = input.BelowCopy(0, inputLineY).WithFixedWidth(width), OnTextChangedDlg, CairoFont.WhiteSmallText(), "text4") .AddStaticText("Southwest", CairoFont.WhiteDetailText(), line = line.BelowCopy(0, textLineY).WithFixedWidth(width)) .AddTextInput(input = input.BelowCopy(0, inputLineY).WithFixedWidth(width), OnTextChangedDlg, CairoFont.WhiteSmallText(), "text5") .AddStaticText("West", CairoFont.WhiteDetailText(), line = line.BelowCopy(0, textLineY).WithFixedWidth(width)) .AddTextInput(input = input.BelowCopy(0, inputLineY).WithFixedWidth(width), OnTextChangedDlg, CairoFont.WhiteSmallText(), "text6") .AddStaticText("Northwest", CairoFont.WhiteDetailText(), line = line.BelowCopy(0, textLineY).WithFixedWidth(width)) .AddTextInput(input = input.BelowCopy(0, inputLineY).WithFixedWidth(width), OnTextChangedDlg, CairoFont.WhiteSmallText(), "text7") .AddSmallButton(Lang.Get("Cancel"), OnButtonCancel, input = input.BelowCopy(0, 20).WithFixedSize(100, 20).WithAlignment(EnumDialogArea.LeftFixed).WithFixedPadding(10, 2), EnumButtonStyle.Normal, EnumTextOrientation.Center) .AddSmallButton(Lang.Get("Save"), OnButtonSave, input = input.FlatCopy().WithFixedSize(100, 20).WithAlignment(EnumDialogArea.RightFixed).WithFixedPadding(10, 2), EnumButtonStyle.Normal, EnumTextOrientation.Center) .EndChildElements() .Compose() ; for (int i = 0; i < 8; i++) { GuiElementTextInput texinput = SingleComposer.GetTextInput("text" + i); texinput.SetValue(textByCardinalDirection[i]); } }
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 GuiDialogBlockEntityCommand(BlockPos BlockEntityPosition, string command, ICoreClientAPI capi) : base("Command block", BlockEntityPosition, capi) { double pad = GuiElementItemSlotGrid.unscaledSlotPadding; int spacing = 5; double size = GuiElementPassiveItemSlot.unscaledSlotSize + GuiElementItemSlotGrid.unscaledSlotPadding; double innerWidth = 300; // 1.2. Name and Hotkey double halfWidth = innerWidth / 2 - 5; // 1.3. Commands text ElementBounds commmandsBounds = ElementBounds.Fixed(0, 30, innerWidth, 30); // 1.3. Command textarea ElementBounds textAreaBounds = ElementBounds.Fixed(0, 0, innerWidth - 20, 200); // 1.3.2. Clipping bounds for textarea ElementBounds clippingBounds = ElementBounds.Fixed(0, 0, innerWidth - 20 - 1, 200 - 1).FixedUnder(commmandsBounds, spacing - 10); // 1.3.3 Scrollbar right of textarea ElementBounds scrollbarBounds = clippingBounds.CopyOffsetedSibling(clippingBounds.fixedWidth + 6, -1).WithFixedWidth(20).FixedGrow(0, 2); // 1.4. Clear Macro button ElementBounds cancelBounds = ElementBounds.FixedSize(0, 0).FixedUnder(clippingBounds, 6 + 2 * spacing).WithAlignment(EnumDialogArea.LeftFixed).WithFixedPadding(10, 2); ElementBounds saveBounds = ElementBounds.FixedSize(0, 0).FixedUnder(clippingBounds, 6 + 2 * spacing).WithAlignment(EnumDialogArea.RightFixed).WithFixedPadding(10, 2); // 2. Around all that is 10 pixel padding ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding); bgBounds.BothSizing = ElementSizing.FitToChildren; // 3. Finally Dialog ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.RightMiddle) .WithFixedAlignmentOffset(-GuiStyle.DialogToScreenPadding, 0); if (SingleComposer != null) { SingleComposer.Dispose(); } SingleComposer = capi.Gui .CreateCompo("commandeditordialog", dialogBounds) .AddShadedDialogBG(bgBounds) .AddDialogTitleBar("Command Editor", OnTitleBarClose) .BeginChildElements(bgBounds) .AddStaticText("Commands", CairoFont.WhiteSmallText(), commmandsBounds) .BeginClip(clippingBounds) .AddTextArea(textAreaBounds, OnCommandCodeChanged, CairoFont.TextInput().WithFontSize(16), "commands") .EndClip() .AddVerticalScrollbar(OnNewCmdScrollbarvalue, scrollbarBounds, "scrollbar") .AddSmallButton("Cancel", OnCancel, cancelBounds) .AddSmallButton("Save", OnSave, saveBounds) .EndChildElements() .Compose() ; SingleComposer.GetTextArea("commands").SetValue(command); SingleComposer.GetTextArea("commands").OnCursorMoved = OnTextAreaCursorMoved; SingleComposer.GetScrollbar("scrollbar").SetHeights( (float)textAreaBounds.fixedHeight - 1, (float)textAreaBounds.fixedHeight ); SingleComposer.UnfocusOwnElements(); }
private void ComposeDialog() { ElementBounds leftColumn = ElementBounds.Fixed(0, 28, 120, 25); ElementBounds rightColumn = leftColumn.RightCopy(); ElementBounds buttonRow = ElementBounds.Fixed(0, 28, 360, 25); ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding); bgBounds.BothSizing = ElementSizing.FitToChildren; bgBounds.WithChildren(leftColumn, rightColumn); ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog .WithAlignment(EnumDialogArea.CenterMiddle) .WithFixedAlignmentOffset(-GuiStyle.DialogToScreenPadding, 0); if (SingleComposer != null) { SingleComposer.Dispose(); } string[] names = new string[] { "circle", "bee", "cave", "home", "ladder", "pick", "rocks", "ruins", "spiral", "star1", "star2", "trader", "vessel" }; int index = names.IndexOf(waypoint.Icon); if (index < 0) { index = 0; } SingleComposer = capi.Gui .CreateCompo("worldmap-modwp", dialogBounds) .AddShadedDialogBG(bgBounds, false) .AddDialogTitleBar("Modify waypoint", () => TryClose()) .BeginChildElements(bgBounds) .AddRichtext("Color (<a href=\"https://www.99colors.net/dot-net-colors\">List</a>)", CairoFont.WhiteSmallText(), leftColumn = leftColumn.FlatCopy()) .AddTextInput(rightColumn = rightColumn.FlatCopy().WithFixedWidth(150), onColorChanged, CairoFont.TextInput(), "colorInput") .AddDynamicCustomDraw(rightColumn.FlatCopy().WithFixedWidth(30).WithFixedOffset(160, 0), onDrawColorRect, "colorRect") .AddStaticText("Name", CairoFont.WhiteSmallText(), leftColumn = leftColumn.BelowCopy(0, 5)) .AddTextInput(rightColumn = rightColumn.BelowCopy(0, 5).WithFixedWidth(200), onNameChanged, CairoFont.TextInput(), "nameInput") .AddStaticText("Icon", CairoFont.WhiteSmallText(), leftColumn = leftColumn.BelowCopy(0, 5)) .AddDropDown( names, new string[] { "<icon name=\"wpCircle\">", "<icon name=\"wpBee\">", "<icon name=\"wpCave\">", "<icon name=\"wpHome\">", "<icon name=\"wpLadder\">", "<icon name=\"wpPick\">", "<icon name=\"wpRocks\">", "<icon name=\"wpRuins\">", "<icon name=\"wpSpiral\">", "<icon name=\"wpStar1\">", "<icon name=\"wpStar2\">", "<icon name=\"wpTrader\">", "<icon name=\"wpVessel\">" }, index, onIconSelectionChanged, rightColumn = rightColumn.BelowCopy(0, 5).WithFixedWidth(60), CairoFont.WhiteSmallishText(), "iconInput" ) .AddSmallButton("Cancel", onCancel, buttonRow.FlatCopy().FixedUnder(leftColumn, 0).WithFixedWidth(100), EnumButtonStyle.Normal) .AddSmallButton("Delete", onDelete, buttonRow.FlatCopy().FixedUnder(leftColumn, 0).WithFixedWidth(100).WithAlignment(EnumDialogArea.CenterFixed), EnumButtonStyle.Normal) .AddSmallButton("Save", onSave, buttonRow.FlatCopy().FixedUnder(leftColumn, 0).WithFixedWidth(100).WithAlignment(EnumDialogArea.RightFixed), EnumButtonStyle.Normal, key: "saveButton") .EndChildElements() .Compose() ; var col = System.Drawing.Color.FromArgb(0, ColorUtil.ColorR(waypoint.Color), ColorUtil.ColorG(waypoint.Color), ColorUtil.ColorB(waypoint.Color)); if (col.IsKnownColor) { SingleComposer.GetTextInput("colorInput").SetValue(col.ToKnownColor().ToString().ToLowerInvariant()); } else { SingleComposer.GetTextInput("colorInput").SetValue(ColorUtil.Int2Hex(waypoint.Color)); } SingleComposer.GetTextInput("nameInput").SetValue(waypoint.Title); }
private void onDurationChanged(string code, bool selected) { int cost = code.ToInt(1) / auctionSys.DurationWeeksMul; Composers["tradercreateauction"].GetRichtext("depositText").SetNewText(Lang.Get("Deposit: {0}x", cost) + " " + gearIcon, CairoFont.WhiteSmallText()); }
public void Init() { var slotBounds = ElementBounds.Fixed(0, 30, 50, 50); ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding); bgBounds.BothSizing = ElementSizing.FitToChildren; dialogBounds = ElementStdBounds .AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle) .WithFixedAlignmentOffset(-GuiStyle.DialogToScreenPadding, 0); bgBounds.verticalSizing = ElementSizing.FitToChildren; bgBounds.horizontalSizing = ElementSizing.Fixed; bgBounds.fixedWidth = 300; 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 priceLabelBounds = ElementBounds.Fixed(0, 0, 250, 25).FixedUnder(slotBounds, 20); ElementBounds priceBounds = ElementBounds.Fixed(0, 0, 100, 30).FixedUnder(priceLabelBounds, 0); ElementBounds durationLabelBounds = ElementBounds.Fixed(0, 0, 250, 25).FixedUnder(priceBounds, 20); ElementBounds dropDownBounds = ElementBounds.Fixed(0, 0, 150, 25).FixedUnder(durationLabelBounds, 0); ElementBounds costLabelBounds = ElementBounds.Fixed(0, 0, 300, 25).FixedUnder(dropDownBounds, 20); ElementBounds cutLabelBounds = ElementBounds.Fixed(0, 0, 300, 25).FixedUnder(costLabelBounds, 0); int[] weeks = new int[] { 1, 2, 3, 4, 5 }; string[] codes = new string[5]; string[] values = new string[5]; for (int i = 0; i < weeks.Length; i++) { weeks[i] *= auctionSys.DurationWeeksMul; codes[i] = "" + weeks[i]; values[i] = weeks[i] == 1 ? Lang.Get("{0} week", weeks[i]) : Lang.Get("{0} weeks", weeks[i]); } Composers["tradercreateauction"] = capi.Gui .CreateCompo("tradercreateauction-" + owningEntity.EntityId, dialogBounds) .AddShadedDialogBG(bgBounds, true) .AddDialogTitleBar(Lang.Get("Create Auction"), OnCreateAuctionClose) .BeginChildElements(bgBounds) .AddItemSlotGrid(auctionSlotInv, (p) => { capi.Network.SendPacketClient(p); }, 1, null, slotBounds, "traderSellingSlots") .AddStaticText(Lang.Get("Price in rusty gears"), CairoFont.WhiteSmallText(), priceLabelBounds) .AddNumberInput(priceBounds, onPriceChanged, CairoFont.WhiteSmallText(), "price") .AddStaticText(Lang.Get("Duration"), CairoFont.WhiteSmallText(), durationLabelBounds) .AddDropDown(codes, values, 0, onDurationChanged, dropDownBounds, CairoFont.WhiteSmallText(), "duration") .AddRichtext(Lang.Get("Deposit: {0}", 1) + " " + gearIcon, CairoFont.WhiteSmallText(), costLabelBounds, "depositText") .AddRichtext(Lang.Get("Trader cut on sale (10%): {0}" + " " + gearIcon, 1), CairoFont.WhiteSmallText(), cutLabelBounds, "cutText") .AddSmallButton(Lang.Get("Cancel"), OnCancelAuctionClose, leftButton.FixedUnder(cutLabelBounds, 20).WithFixedPadding(8, 5)) .AddSmallButton(Lang.Get("Create Auction"), OnCreateAuctionConfirm, rightButton.FixedUnder(cutLabelBounds, 20).WithFixedPadding(8, 5), EnumButtonStyle.Normal, EnumTextOrientation.Left, "buysellButton") .EndChildElements() .Compose() ; Composers["tradercreateauction"].GetNumberInput("price").SetValue(lastPrice); }
private new void Recompose(ICoreClientAPI capi) { this.textTexture?.Dispose(); this.textTexture = new TextTextureUtil(capi).GenTextTexture(Lang.Get(this.Title), CairoFont.WhiteSmallText()); }
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; }; * }*/ }
private void onPriceChanged(string text) { int cost = Composers["tradercreateauction"].GetNumberInput("price").GetText().ToInt(1); float gearcut = cost * auctionSys.SalesCutRate + auctionSys.debtClient; Composers["tradercreateauction"].GetRichtext("cutText").SetNewText(Lang.Get("Trader cut on sale (10%): {0}" + " " + gearIcon, (int)gearcut), CairoFont.WhiteSmallText()); }