protected override void OnInit(IGuiRenderer renderer) { Alex.Services.GetRequiredService <IEventDispatcher>().RegisterEvents(_tipPopupComponent); _bottomContainer.AddChild(_tipPopupComponent); _healthContainer.AddChild(_healthComponent); _healthContainer.AddChild(_hungerComponent); _healthAndHotbar.AddChild(_healthContainer); _healthAndHotbar.AddChild(_hotbar); _bottomContainer.AddRow( container => { // container.AutoSizeMode = AutoSizeMode.GrowAndShrink; container.Anchor = Alignment.BottomCenter; container.ChildAnchor = Alignment.FillCenter; container.AddChild(_healthAndHotbar); //container.AddChild(_hotbar); }); AddChild(_bottomContainer); AddChild(Chat); //AddChild(_hotbar); AddChild(new GuiCrosshair()); AddChild(Title); AddChild(Scoreboard); }
/// <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; }