private void ShowSettings() { _keyboardListener.ClearEvent(); var panel = new Panel(new Vector2(650, 650), PanelSkin.Fancy); panel.AddChild(new Header("Paramètres du jeu")); panel.AddChild(new HorizontalLine()); var settingsPanel = new Panel(new Vector2(600, 100), PanelSkin.None, Anchor.Auto); settingsPanel.AddChild(new Paragraph("Volume audio")); settingsPanel.AddChild(new Slider(0, 100).Apply((ref Slider slider) => { slider.Value = (PCGame.SoundVolume * 100f).Round(); slider.OnValueChange += entity => PCGame.SoundVolume = ((Slider)entity).Value / 100f; })); panel.AddChild(settingsPanel); var settingsKeysPanel = new Panel(new Vector2(600, 350), PanelSkin.None, Anchor.Auto) { PanelOverflowBehavior = PanelOverflowBehavior.VerticalScroll }; foreach (GameKeys.GKeys gk in Enum.GetValues(typeof(GameKeys.GKeys))) { var(description, key) = GameKeys.GetKey(gk); settingsKeysPanel.AddChild(new Paragraph(description)); var btn = new Button(key.ToString()) { ToggleMode = true, OnClick = entity => { foreach (var child in settingsKeysPanel.GetChildren()) { if (!ReferenceEquals(child, entity) && child is Button b) { b.Checked = false; } } } }; _keyboardListener.OnKeyPressedEventArg += k => { if (btn.Checked) { GameKeys.SetKey(gk, k); btn.ButtonParagraph.Text = k.ToString(); } }; settingsKeysPanel.AddChild(btn); } panel.AddChild(settingsKeysPanel); panel.AddChild(new Button("Fermer").Apply((ref Button btn) => btn.OnClick = entity => panel.RemoveFromParent())); UserInterface.Active.AddEntity(panel); } }