/// <summary> /// Se produit lorsqu'une commande est entrée dans la console. /// </summary> /// <param name="sender"></param> void m_consoleInput_TextValidated(GuiTextInput sender) { /*if (sender.Text == "") * m_consoleInput.HasFocus = false;*/ m_consoleOutput.AppendLine(">> " + sender.Text); Server.GameServer.GetScene().GameInterpreter.Eval(sender.Text); sender.Text = ""; }
public MultiplayerConnectState() { Title = "Connect to Server"; AddGuiElement(_hostnameInput = new GuiTextInput() { Width = 200, Anchor = Alignment.MiddleCenter, PlaceHolder = "Server Address..." }); AddGuiElement(_connectButton = new GuiButton("Join Server", OnConnectButtonPressed) { Margin = new Thickness(5) }); AddGuiElement(_errorMessage = new GuiTextElement() { TextColor = TextColor.Red }); }
/// <summary> /// Charge les ressources dont a besoin la console. /// </summary> public void LoadContent() { int width = (int)GameClient.GetScreenSize().X; int screenHeight = (int)GameClient.GetScreenSize().Y; const int h1 = 75; const int h2 = 25; const int bar = 15; m_window = new GuiWindow(Manager); m_window.Location = new Point(0, (int)(screenHeight - 125)); m_window.Size = new Point(width, h1 + h2 + bar); m_window.Title = "Developer Console"; m_window.BackColor = new Color(0, 0, 0, 0); // Expand m_expandButton = new GuiButton(Manager); m_expandButton.Parent = m_window; m_expandButton.Location = new Point(m_window.Size.X - 15, 1); m_expandButton.Size = new Point(15, 15); m_expandButton.Title = "+"; // Console input m_consoleInput = new GuiTextInput(Manager); m_consoleInput.Parent = m_window; m_consoleInput.Location = new Point(0, bar + h1); m_consoleInput.Size = new Point(width, h2); m_consoleInput.TextValidated += m_consoleInput_TextValidated; m_consoleInput.Opacity = 200; // Console output m_consoleOutput = new GuiMultilineTextDisplay(Manager); m_consoleOutput.Parent = m_window; m_consoleOutput.Location = new Point(0, bar); m_consoleOutput.Size = new Point(width, h1); m_consoleOutput.Opacity = 200; m_expandButton.Clicked += m_expandButton_Clicked; Server.GameServer.GetScene().GameInterpreter.OnPuts = new PonyCarpetExtractor.Interpreter.PutsDelegate((string s) => { m_consoleOutput.AppendLine(s); m_consoleOutput.ScrollDown(); }); Server.GameServer.GetScene().GameInterpreter.OnError = new PonyCarpetExtractor.Interpreter.PutsDelegate((string s) => { m_consoleOutput.AppendLine("error: " + s); m_consoleOutput.ScrollDown(); }); }
private void Initialize() { base.HeaderTitle.Anchor = Alignment.MiddleCenter; base.HeaderTitle.FontStyle = FontStyle.Bold | FontStyle.DropShadow; Footer.ChildAnchor = Alignment.MiddleCenter; GuiTextElement t; Footer.AddChild(t = new GuiTextElement() { Text = "We are NOT in anyway or form affiliated with Mojang/Minecraft or Microsoft!", TextColor = TextColor.Yellow, Scale = 1f, FontStyle = FontStyle.DropShadow, Anchor = Alignment.MiddleCenter }); GuiTextElement info; Footer.AddChild(info = new GuiTextElement() { Text = "We will never collect/store or do anything with your data.", TextColor = TextColor.Yellow, Scale = 0.8f, FontStyle = FontStyle.DropShadow, Anchor = Alignment.MiddleCenter, Padding = new Thickness(0, 5, 0, 0) }); /* * "We will never collect/store or do anything with your data.\n" + * "You can read more about the authentication method we use on here: https://wiki.vg/Authentication" */ Body.BackgroundOverlay = new Color(Color.Black, 0.5f); Body.ChildAnchor = Alignment.MiddleCenter; var usernameRow = AddGuiRow(new GuiTextElement() { Text = "Username:"******"Username...", Margin = new Thickness(5), }); usernameRow.ChildAnchor = Alignment.MiddleCenter; var passwordRow = AddGuiRow(new GuiTextElement() { Text = "Password:"******"Password...", Margin = new Thickness(5), IsPasswordInput = true }); passwordRow.ChildAnchor = Alignment.MiddleCenter; var buttonRow = AddGuiRow(LoginButton = new GuiButton(OnLoginButtonPressed) { AccessKey = Keys.Enter, Text = "Login", Margin = new Thickness(5), Modern = false, Width = 100 }, new GuiButton(OnCancelButtonPressed) { AccessKey = Keys.Escape, TranslationKey = "gui.cancel", Margin = new Thickness(5), Modern = false, Width = 100 }); buttonRow.ChildAnchor = Alignment.MiddleCenter; AddGuiElement(ErrorMessage = new GuiTextElement() { TextColor = TextColor.Yellow }); Initialized(); }
public MultiplayerAddEditServerState(string serverType, string name, string address, Action <AddOrEditCallback> callbackAction, GuiPanoramaSkyBox skyBox) : base(callbackAction) { _serverTypeManager = GetService <ServerTypeManager>(); _skyBox = skyBox; Title = "Add Server"; TitleTranslationKey = "addServer.title"; base.HeaderTitle.Anchor = Alignment.MiddleCenter; base.HeaderTitle.FontStyle = FontStyle.Bold | FontStyle.DropShadow; Body.BackgroundOverlay = new Color(Color.Black, 0.5f); Body.ChildAnchor = Alignment.MiddleCenter; var usernameRow = AddGuiRow(new GuiTextElement() { Text = "Server Name:", TranslationKey = "addServer.enterName", Margin = new Thickness(0, 0, 5, 0) }, _nameInput = new GuiTextInput() { TabIndex = 1, Width = 200, PlaceHolder = "Name of the server", Margin = new Thickness(23, 5, 5, 5), }); usernameRow.ChildAnchor = Alignment.MiddleCenter; usernameRow.Orientation = Orientation.Horizontal; var hostnameRow = AddGuiRow(new GuiTextElement() { Text = "Server Address:", TranslationKey = "addServer.enterIp", Margin = new Thickness(0, 0, 5, 0) }, _hostnameInput = new GuiTextInput() { TabIndex = 2, Width = 200, PlaceHolder = "Hostname or IP", Margin = new Thickness(5), }); hostnameRow.ChildAnchor = Alignment.MiddleCenter; hostnameRow.Orientation = Orientation.Horizontal; var typeLabelRow = AddGuiRow(_serverTypeLabel = new GuiTextElement() { Text = "Server Type:", Margin = new Thickness(0, 0, 5, 0) }); typeLabelRow.ChildAnchor = Alignment.MiddleCenter; typeLabelRow.Orientation = Orientation.Horizontal; AddGuiRow(_serverTypeGroup = new GuiButtonGroup() { Orientation = Orientation.Horizontal, ChildAnchor = Alignment.MiddleCenter }); int tabIndex = 3; foreach (var type in _serverTypeManager.GetAll()) { if (_selectedImplementation == null) { _selectedImplementation = type; } GuiToggleButton element; _serverTypeGroup.AddChild( element = new GuiToggleButton(type.DisplayName) { Margin = new Thickness(5), Modern = true, Width = 50, Checked = serverType == type.Id, CheckedOutlineThickness = new Thickness(1), DisplayFormat = new ValueFormatter <bool>((val) => $"{type.DisplayName} {(val ? "[Active]" : "")}"), TabIndex = tabIndex++ }); element.ValueChanged += (sender, value) => { if (value) { _selectedImplementation = type; } }; } var buttonRow = AddGuiRow(_saveButton = new GuiButton(OnSaveButtonPressed) { AccessKey = Keys.Enter, TranslationKey = "addServer.add", Margin = new Thickness(5), Modern = false, Width = 100, TabIndex = 5 }, new GuiButton(OnCancelButtonPressed) { AccessKey = Keys.Escape, TranslationKey = "gui.cancel", Margin = new Thickness(5), Modern = false, Width = 100, TabIndex = 6 }); buttonRow.ChildAnchor = Alignment.MiddleCenter; AddGuiElement(_errorMessage = new GuiTextElement() { TextColor = TextColor.Red }); if (!string.IsNullOrWhiteSpace(name)) { _nameInput.Value = name; } if (!string.IsNullOrWhiteSpace(address)) { _hostnameInput.Value = address; } if (_entry != null) { //EnableButtonsFor(_entry.ServerType); } Background = new GuiTexture2D(_skyBox, TextureRepeatMode.Stretch); }
public CustomFormDialog(uint formId, BedrockFormManager parent, CustomForm form, InputManager inputManager) : base(formId, parent, inputManager) { Container.AddChild(new GuiTextElement() { Anchor = Alignment.TopCenter, Text = form.Title, FontStyle = FontStyle.Bold, Scale = 2f, TextColor = TextColor.White }); Form = form; GuiScrollableStackContainer stackContainer = new GuiScrollableStackContainer(); stackContainer.Orientation = Orientation.Vertical; stackContainer.Anchor = Alignment.Fill; stackContainer.ChildAnchor = Alignment.MiddleFill; var margin = new Thickness(5, 5); foreach (var element in form.Content) { switch (element) { case Label label: { stackContainer.AddChild(new GuiTextElement() { Text = label.Text, Margin = margin }); } break; case Input input: { GuiTextInput guiInput = new GuiTextInput() { Value = input.Value, PlaceHolder = input.Placeholder, Margin = margin }; guiInput.ValueChanged += (sender, s) => { input.Value = s; }; stackContainer.AddChild(guiInput); } break; case Toggle toggle: { GuiToggleButton guiToggle; stackContainer.AddChild(guiToggle = new GuiToggleButton(toggle.Text) { Margin = margin, Value = !toggle.Value }); guiToggle.DisplayFormat = new ValueFormatter <bool>((val) => { return($"{toggle.Text}: {val.ToString()}"); }); guiToggle.Value = toggle.Value; guiToggle.ValueChanged += (sender, b) => { toggle.Value = b; }; } break; case Slider slider: { GuiSlider guiSlider; stackContainer.AddChild(guiSlider = new GuiSlider() { Label = { Text = slider.Text }, Value = slider.Value, MaxValue = slider.Max, MinValue = slider.Min, StepInterval = slider.Step, Margin = margin }); guiSlider.ValueChanged += (sender, d) => { slider.Value = (float)d; }; } break; case StepSlider stepSlider: { stackContainer.AddChild(new GuiTextElement() { Text = "Unsupported stepslider", TextColor = TextColor.Red, Margin = margin }); } break; case Dropdown dropdown: { stackContainer.AddChild(new GuiTextElement() { Text = "Unsupported dropdown", TextColor = TextColor.Red, Margin = margin }); } break; } } SubmitButton = new GuiButton("Submit", SubmitPressed); stackContainer.AddChild(SubmitButton); Container.AddChild(stackContainer); }
public MultiplayerAddEditServerState(ServerType serverType, string name, string address, Action <SavedServerEntry> callbackAction, GuiPanoramaSkyBox skyBox) : base(callbackAction) { _savedServersStorage = GetService <IListStorageProvider <SavedServerEntry> >(); _skyBox = skyBox; Title = "Add Server"; TitleTranslationKey = "addServer.title"; base.HeaderTitle.Anchor = Alignment.MiddleCenter; base.HeaderTitle.FontStyle = FontStyle.Bold | FontStyle.DropShadow; Body.BackgroundOverlay = new Color(Color.Black, 0.5f); Body.ChildAnchor = Alignment.MiddleCenter; var usernameRow = AddGuiRow(new GuiTextElement() { Text = "Server Name:", TranslationKey = "addServer.enterName", Margin = new Thickness(0, 0, 5, 0) }, _nameInput = new GuiTextInput() { TabIndex = 1, Width = 200, PlaceHolder = "Name of the server", Margin = new Thickness(23, 5, 5, 5), }); usernameRow.ChildAnchor = Alignment.MiddleCenter; usernameRow.Orientation = Orientation.Horizontal; var hostnameRow = AddGuiRow(new GuiTextElement() { Text = "Server Address:", TranslationKey = "addServer.enterIp", Margin = new Thickness(0, 0, 5, 0) }, _hostnameInput = new GuiTextInput() { TabIndex = 2, Width = 200, PlaceHolder = "Hostname or IP", Margin = new Thickness(5), }); hostnameRow.ChildAnchor = Alignment.MiddleCenter; hostnameRow.Orientation = Orientation.Horizontal; var typeLabelRow = AddGuiRow(_serverTypeLabel = new GuiTextElement() { Text = "Server Type:", Margin = new Thickness(0, 0, 5, 0) }); typeLabelRow.ChildAnchor = Alignment.MiddleCenter; typeLabelRow.Orientation = Orientation.Horizontal; AddGuiRow(_serverTypeGroup = new GuiButtonGroup() { Orientation = Orientation.Horizontal, ChildAnchor = Alignment.MiddleCenter }); _serverTypeGroup.AddChild(_javaEditionButton = new GuiToggleButton("Java") { Margin = new Thickness(5), Modern = true, Width = 50, Checked = serverType == ServerType.Java, CheckedOutlineThickness = new Thickness(1), DisplayFormat = new ValueFormatter <bool>((val) => $"Java {(val ? "[Active]" : "")}"), TabIndex = 3 }); _serverTypeGroup.AddChild(_bedrockEditionButton = new GuiToggleButton("Bedrock") { Margin = new Thickness(5), Modern = true, Width = 50, Checked = serverType == ServerType.Bedrock, CheckedOutlineThickness = new Thickness(1), DisplayFormat = new ValueFormatter <bool>((val) => $"Bedrock {(val ? "[Active]" : "")}"), TabIndex = 4 }); // var portRow = AddGuiRow(); // portRow.ChildAnchor = Alignment.MiddleCenter; var buttonRow = AddGuiRow(_saveButton = new GuiButton(OnSaveButtonPressed) { AccessKey = Keys.Enter, TranslationKey = "addServer.add", Margin = new Thickness(5), Modern = false, Width = 100, TabIndex = 5 }, new GuiButton(OnCancelButtonPressed) { AccessKey = Keys.Escape, TranslationKey = "gui.cancel", Margin = new Thickness(5), Modern = false, Width = 100, TabIndex = 6 }); buttonRow.ChildAnchor = Alignment.MiddleCenter; AddGuiElement(_errorMessage = new GuiTextElement() { TextColor = TextColor.Red }); if (!string.IsNullOrWhiteSpace(name)) { _nameInput.Value = name; } if (!string.IsNullOrWhiteSpace(address)) { _hostnameInput.Value = address; } if (_entry != null) { //EnableButtonsFor(_entry.ServerType); } Background = new GuiTexture2D(_skyBox, TextureRepeatMode.Stretch); }
public CustomFormDialog(uint formId, BedrockFormManager parent, CustomForm form, InputManager inputManager) : base(formId, parent, inputManager) { Form = form; GuiScrollableStackContainer stackContainer = new GuiScrollableStackContainer(); stackContainer.Orientation = Orientation.Vertical; stackContainer.Anchor = Alignment.Fill; stackContainer.ChildAnchor = Alignment.MiddleFill; stackContainer.Background = Color.Black * 0.35f; var margin = new Thickness(5, 5); foreach (var element in form.Content) { switch (element) { case Label label: { stackContainer.AddChild(new GuiTextElement() { Text = label.Text, Margin = margin }); } break; case Input input: { GuiTextInput guiInput = new GuiTextInput() { Value = input.Value, PlaceHolder = !string.IsNullOrWhiteSpace(input.Placeholder) ? input.Placeholder : input.Text, Margin = margin }; guiInput.ValueChanged += (sender, s) => { input.Value = s; }; stackContainer.AddChild(guiInput); } break; case Toggle toggle: { GuiToggleButton guiToggle; stackContainer.AddChild(guiToggle = new GuiToggleButton(toggle.Text) { Margin = margin, Value = !toggle.Value }); guiToggle.DisplayFormat = new ValueFormatter <bool>((val) => { return($"{toggle.Text}: {val.ToString()}"); }); guiToggle.Value = toggle.Value; guiToggle.ValueChanged += (sender, b) => { toggle.Value = b; }; } break; case Slider slider: { GuiSlider guiSlider; stackContainer.AddChild(guiSlider = new GuiSlider() { Label = { Text = slider.Text }, Value = slider.Value, MaxValue = slider.Max, MinValue = slider.Min, StepInterval = slider.Step, Margin = margin }); guiSlider.ValueChanged += (sender, d) => { slider.Value = (float)d; }; } break; case StepSlider stepSlider: { stackContainer.AddChild(new GuiTextElement() { Text = "Unsupported stepslider", TextColor = TextColor.Red, Margin = margin }); } break; case Dropdown dropdown: { stackContainer.AddChild(new GuiTextElement() { Text = "Unsupported dropdown", TextColor = TextColor.Red, Margin = margin }); } break; } } SubmitButton = new GuiButton("Submit", SubmitPressed); stackContainer.AddChild(SubmitButton); 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; var bodyWrapper = new GuiContainer(); bodyWrapper.Anchor = Alignment.Fill; bodyWrapper.Padding = new Thickness(5, 0); bodyWrapper.AddChild(stackContainer); Container.AddChild(bodyWrapper); 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 = FixContrast(form.Title), TextColor = TextColor.White, Scale = 2f, FontStyle = FontStyle.DropShadow, Anchor = Alignment.BottomCenter, }); stackContainer.Margin = new Thickness(0, Header.Height, 0, 0); }