public PlayingHud(Alex game, Player player, TitleComponent titleComponent) : base() { Title = titleComponent; Alex = game; Player = player; Player.OnInventoryChanged += OnInventoryChanged; Anchor = Alignment.Fill; Padding = Thickness.One; _playerController = player.Controller; InputManager.AddListener(new MouseInputListener(InputManager.PlayerIndex)); _healthAndHotbar = new GuiStackContainer() { Orientation = Orientation.Vertical, ChildAnchor = Alignment.Fill }; _bottomContainer = new GuiMultiStackContainer(); _bottomContainer.ChildAnchor = Alignment.BottomFill; _bottomContainer.Anchor = Alignment.BottomCenter; _bottomContainer.AutoSizeMode = AutoSizeMode.GrowAndShrink; _bottomContainer.Orientation = Orientation.Vertical; //BottomContainer. _hotbar = new GuiItemHotbar(player.Inventory); _hotbar.Anchor = Alignment.BottomCenter; _hotbar.Padding = Thickness.Zero; Chat = new ChatComponent(); Chat.Enabled = false; Chat.Anchor = Alignment.BottomLeft; _healthContainer = new GuiContainer(); _healthContainer.Anchor = Alignment.Fill; _healthContainer.Margin = new Thickness(0, 0, 0, 1); _healthComponent = new HealthComponent(player); _healthComponent.Anchor = Alignment.TopLeft; _hungerComponent = new HungerComponent(player); _hungerComponent.Anchor = Alignment.TopRight; _tipPopupComponent = new TipPopupComponent(); _tipPopupComponent.Anchor = Alignment.BottomCenter; _tipPopupComponent.AutoSizeMode = AutoSizeMode.GrowAndShrink; Scoreboard = new ScoreboardView(); Scoreboard.Anchor = Alignment.MiddleRight; }
/// <inheritdoc /> public ModalFormDialog(uint formId, BedrockFormManager parent, ModalForm form, InputManager inputManager) : base( formId, parent, inputManager) { Background = Color.Transparent; var width = 356; var height = width; ContentContainer.Width = ContentContainer.MinWidth = ContentContainer.MaxWidth = width; ContentContainer.Height = ContentContainer.MinHeight = ContentContainer.MaxHeight = height; SetFixedSize(width, height); ContentContainer.AutoSizeMode = AutoSizeMode.None; Container.Anchor = Alignment.MiddleCenter; Container.AddChild(Footer = new GuiMultiStackContainer(row => { row.Anchor = Alignment.BottomFill; //row.Orientation = Orientation.Horizontal; row.ChildAnchor = Alignment.BottomFill; //row.Margin = new Thickness(3); row.Width = 356; row.MaxWidth = 356; }) { Height = 24, Orientation = Orientation.Vertical, Anchor = Alignment.BottomFill, ChildAnchor = Alignment.BottomCenter, Background = Color.Black * 0.5f }); Footer.AddRow(row => { row.AddChild(new GuiButton(form.Button1, () => { var packet = McpeModalFormResponse.CreateObject(); packet.formId = formId; packet.data = "true"; //JsonConvert.SerializeObject(idx) parent.SendResponse(packet); parent.Hide(formId); }) { Enabled = true, }); row.AddChild(new GuiButton(form.Button2, () => { var packet = McpeModalFormResponse.CreateObject(); packet.formId = formId; packet.data = "false"; //JsonConvert.SerializeObject(idx) parent.SendResponse(packet); parent.Hide(formId); }) { Enabled = true }); }); Container.AddChild(Body = new GuiStackContainer() { //Margin = new Thickness(0, Header.Height, 0, Footer.Height), //AutoSizeMode = AutoSizeMode.None, //Height = 100, //MaxHeight = 100, Orientation = Orientation.Vertical, Anchor = Alignment.Fill, ChildAnchor = Alignment.MiddleCenter, Background = Color.Black * 0.35f //HorizontalScrollMode = ScrollMode.Hidden }); var text = form.Content; var newString = ""; // char[] help = new[] { '.', '?', '!' }; for (int i = 0; i < text.Length - 1; i++) { var c = text[i]; newString += c; if (c == '.' || c == '?' || c == '!') { //newString += "\n"; Body.AddChild(new GuiTextElement(newString)); /*row.AddChild(new GuiTextElement(form.Content) * { * Wrap = true, * MaxWidth = 320 * });*/ newString = ""; if (i != text.Length - 1 && text[i + 1] == ' ') { i++; } } } if (newString.Length > 0) { Body.AddChild(new GuiTextElement(newString)); } Container.AddChild(Header = new GuiStackContainer() { Anchor = Alignment.TopFill, ChildAnchor = Alignment.BottomCenter, Height = 32, Padding = new Thickness(3), Background = Color.Black * 0.5f }); Header.AddChild(new GuiTextElement() { Text = form.Title, TextColor = TextColor.White, Scale = 2f, FontStyle = FontStyle.DropShadow, Anchor = Alignment.BottomCenter, }); Body.Margin = new Thickness(0, Header.Height, 0, Footer.Height); // Body.MaxHeight = Body.Height = height - 64; }