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 override void GetBlockInfo(IPlayer forPlayer, StringBuilder dsc) { base.GetBlockInfo(forPlayer, dsc); if (Repaired) { dsc.AppendLine(TPNetManager.GetTeleport(Pos)?.Name); } }
private bool OnButtonSave() { GuiElementTextInput textInput = base.SingleComposer.GetTextInput("text"); TeleportData data = TPNetManager.GetTeleport(blockEntityPos); data.Name = textInput.GetText(); TPNetManager.SetTeleport(blockEntityPos, data); didSave = true; TryClose(); return(true); }
private bool OnClickItem(BlockPos targetPos) { var data = TPNetManager.GetTeleport(targetPos); if (data == null) { TryClose(); return(false); } TPNetManager.TeleportTo(targetPos.ToVec3d(), blockEntityPos?.ToVec3d()); double curr = capi.World.Player?.Entity?.WatchedAttributes.GetDouble("temporalStability") ?? 1; capi.World.Player?.Entity?.WatchedAttributes.SetDouble("temporalStability", Math.Max(0, (double)curr - 0.1)); TryClose(); return(true); }