/// <inheritdoc /> /// <summary> /// </summary> /// <param name="dialog"></param> public DrawableModifierSpeed(ModifiersDialog dialog) : base(dialog, new ModSpeed(ModIdentifier.Speed05X)) { RateChanger = new HorizontalSelector(Speeds, new ScalableVector2(200, 32), Fonts.Exo2SemiBold, 13, UserInterface.HorizontalSelectorLeft, UserInterface.HorizontalSelectorRight, new ScalableVector2(32, 32), 0, OnSelected, GetSelectedIndex()) { Parent = this, Alignment = Alignment.MidRight, X = -54, UsePreviousSpriteBatchOptions = true, ButtonSelectLeft = { UsePreviousSpriteBatchOptions = true }, ButtonSelectRight = { UsePreviousSpriteBatchOptions = true }, SelectedItemText = { UsePreviousSpriteBatchOptions = true } }; NotFreeRateButton = new ImageButton(UserInterface.BlankBox, (sender, args) => { if (OnlineManager.CurrentGame != null && !OnlineManager.CurrentGame.FreeModType.HasFlag(MultiplayerFreeModType.Rate)) { NotificationManager.Show(NotificationLevel.Error, "Free Rate is not enabled for this match!"); } }) { Parent = this, Size = Size, Tint = Color.Black, Alpha = 0.75f, UsePreviousSpriteBatchOptions = true }; }
/// <inheritdoc /> /// <summary> /// </summary> /// <param name="dialog"></param> /// <param name="name"></param> /// <param name="bindable"></param> public SettingsBool(SettingsDialog dialog, string name, Bindable <bool> bindable) : base(dialog, name) { Bindable = bindable; Selector = new HorizontalSelector(new List <string> { "No", "Yes", }, new ScalableVector2(200, 26), Fonts.Exo2Medium, 13, FontAwesome.Get(FontAwesomeIcon.fa_chevron_pointing_to_the_left), FontAwesome.Get(FontAwesomeIcon.fa_right_chevron), new ScalableVector2(30, 22), 5, OnSelectorChanged, Convert.ToInt32(Bindable.Value)) { Parent = this, Alignment = Alignment.MidRight, Tint = Color.Transparent, SelectedItemText = { Tint = Color.White, UsePreviousSpriteBatchOptions = true }, ButtonSelectLeft = { UsePreviousSpriteBatchOptions = true }, ButtonSelectRight = { UsePreviousSpriteBatchOptions = true } }; Selector.X -= 68; Bindable.ValueChanged += OnBindableValueChanged; }
/// <inheritdoc /> /// <summary> /// </summary> /// <param name="screen"></param> public TestEasingAnimationsScreenView(Screen screen) : base(screen) { GreenBox = new Sprite() { Parent = Container, Size = new ScalableVector2(75, 75), Alignment = Alignment.MidLeft, Tint = Color.LimeGreen, Animations = { new Animation(AnimationProperty.X, Easing.InQuad, 0, WindowManager.VirtualScreen.X, 3000) } }; // Create the horizontal selector EasingSelection = new HorizontalSelector(Enum.GetNames(typeof(Easing)).ToList(), new ScalableVector2(300, 45), FontManager.GetWobbleFont("exo2-semibold"), 24, Textures.LeftButtonSquare, Textures.RightButtonSquare, new ScalableVector2(45, 45), 10, // Create the method that'll be called when a new option is selected. (val, index) => { // Clear all existing transformations GreenBox.Animations.Clear(); // Reset the position of the box. GreenBox.X = 0; // Add a new transformation with the new easing type. var newEaseType = (Easing)Enum.Parse(typeof(Easing), val); GreenBox.Animations.Add(new Animation(AnimationProperty.X, newEaseType, GreenBox.X, WindowManager.VirtualScreen.X, 3000)); }) { Parent = Container, Alignment = Alignment.MidCenter, Y = GreenBox.Height + 40, Tint = Color.Red, Alpha = 0.35f, }; EasingSelection.ButtonSelectLeft.Tint = Color.Red; EasingSelection.ButtonSelectRight.Tint = Color.Red; EasingSelection.SelectedItemText.Tint = Color.White; }
/// <summary> /// </summary> /// <param name="width"></param> /// <param name="label"></param> /// <param name="options"></param> public LabelledHorizontalSelector(float width, string label, List <string> options, int selectedIndex = 0) { Size = new ScalableVector2(width, 62); Alpha = 0; Label = new SpriteTextBitmap(FontsBitmap.GothamRegular, label) { Parent = this, FontSize = 17 }; Selector = new QuaverHorizontalSelector(options, new ScalableVector2(186, 26), Fonts.SourceSansProSemiBold, 13, new ScalableVector2(20, 15), (s, i) => { }, selectedIndex) { Parent = this, Alignment = Alignment.TopRight, X = 26, Y = -2 }; Height = Selector.Height; }
/// <inheritdoc /> /// <summary> /// </summary> /// <param name="dialog"></param> /// <param name="name"></param> /// <param name="elements"></param> /// <param name="onChange"></param> /// <param name="selectedIndex"></param> protected SettingsHorizontalSelector(SettingsDialog dialog, string name, List <string> elements, Action <string, int> onChange, int selectedIndex) : base(dialog, name) { Selector = new HorizontalSelector(elements, new ScalableVector2(200, 26), Fonts.SourceSansProSemiBold, 13, FontAwesome.Get(FontAwesomeIcon.fa_chevron_pointing_to_the_left), FontAwesome.Get(FontAwesomeIcon.fa_right_chevron), new ScalableVector2(30, 22), 5, onChange, selectedIndex) { Parent = this, Alignment = Alignment.MidRight, Tint = Color.Transparent, SelectedItemText = { Tint = Color.White, UsePreviousSpriteBatchOptions = true }, ButtonSelectLeft = { UsePreviousSpriteBatchOptions = true }, ButtonSelectRight = { UsePreviousSpriteBatchOptions = true } }; Selector.X -= 68; }
/// <inheritdoc /> /// <summary> /// </summary> /// <param name="parent"></param> /// <param name="name"></param> /// <param name="elements"></param> /// <param name="onChange"></param> /// <param name="selectedIndex"></param> /// <param name="saveValue"></param> protected EditorMetadataHorizontalSelector(Drawable parent, string name, List <string> elements, Action <string, int> onChange, int selectedIndex, Action <string> saveValue) : base(parent, name, elements[selectedIndex], saveValue) { Selector = new HorizontalSelector(elements, new ScalableVector2(196, 26), Fonts.SourceSansProSemiBold, 13, FontAwesome.Get(FontAwesomeIcon.fa_chevron_pointing_to_the_left), FontAwesome.Get(FontAwesomeIcon.fa_right_chevron), new ScalableVector2(18, 18), 5, onChange, selectedIndex) { Parent = this, Alignment = Alignment.MidRight, Tint = Color.Transparent, SelectedItemText = { Tint = Color.White, UsePreviousSpriteBatchOptions = true }, ButtonSelectLeft = { UsePreviousSpriteBatchOptions = true }, ButtonSelectRight = { UsePreviousSpriteBatchOptions = true } }; Selector.X -= 34; }
private void SetupUserInterface() { var mainMenuSpriteMap = _spriteMapLoader.GetContent("assets/UI/title_menu_buttons.json"); var interfaceFont = _contentChest.Get <SpriteFont>("Fonts/InterfaceFont"); var inputBoxFont = _contentChest.Get <SpriteFont>("Fonts/InputBoxFont"); var portraitTexture = _contentChest.Get <Texture2D>("portrait_background"); var portraitImage = new Sprite(portraitTexture); var nineSlice = new NineSlice(_menuButtons, new Dictionary <Segment, Rectangle> { { Segment.TopLeft, new Rectangle(1, 189, 8, 9) }, { Segment.Top, new Rectangle(10, 189, 1, 9) }, { Segment.TopRight, new Rectangle(12, 189, 8, 9) }, { Segment.Right, new Rectangle(12, 199, 8, 1) }, { Segment.BottomRight, new Rectangle(12, 201, 8, 8) }, { Segment.Bottom, new Rectangle(10, 201, 1, 8) }, { Segment.BottomLeft, new Rectangle(1, 201, 8, 8) }, { Segment.Left, new Rectangle(1, 199, 8, 1) }, { Segment.Center, new Rectangle(10, 199, 1, 1) } }); var panelWidth = (int)(30 + 200 + 30 + portraitImage.Texture.Width * _buttonScale + 30); _panel = new Panel(nineSlice, new Rectangle( (int)(_viewPortPortManager.ViewPort.Center().X - panelWidth / 2f), (int)(_viewPortPortManager.ViewPort.Center().Y - (500 + 30 + 22 * _buttonScale) / 2f), panelWidth, 500), _buttonScale); // Back Button BackButton = new TexturedButton( mainMenuSpriteMap.CreateSpriteFromRegion("Back_Off"), mainMenuSpriteMap.CreateSpriteFromRegion("Back_On"), new Vector2(_panel.BottomLeft().X, _panel.BottomLeft().Y + 10), _buttonScale); // Done Button var doneOffSprite = mainMenuSpriteMap.CreateSpriteFromRegion("Done_Off"); DoneButton = new TexturedButton(doneOffSprite, mainMenuSpriteMap.CreateSpriteFromRegion("Done_On"), new Vector2(_panel.BottomRight().X - doneOffSprite.Source.Width * _buttonScale, _panel.BottomLeft().Y + 10), _buttonScale); // Name var nameSectionPosition = new Vector2(_panel.Left() + 30, _panel.Top() + 30); var nameTextBoxTitle = new TextBlock("Name", nameSectionPosition, interfaceFont, Color.White, Color.Black); NameTextBox = new TextBox(_contentChest, _keyboardDispatcher, nameSectionPosition + new Vector2(0, interfaceFont.MeasureString("Name").Y + 10), inputBoxFont, 200) { Value = _playerMaker.Name }; NameTextBox.Changed += OnPlayerNameSet; // Pronouns var pronounSectionPosition = new Vector2(_panel.Left() + 30, NameTextBox.Bounds.Bottom + 10); var pronounTextBoxTitle = new TextBlock("Pronouns", pronounSectionPosition, interfaceFont, Color.White, Color.Black); PronounDropDown = new DropDownBox(_contentChest, inputBoxFont, pronounSectionPosition + new Vector2(0, interfaceFont.MeasureString("Pronouns").Y + 10), _optionsManager.PronounOptions.Pronouns.Select(x => $"{x.Subjective}/{x.Objective}").ToArray(), 200); PronounDropDown.Hover += OnPronounSelect; PronounDropDown.SelectedIndex = _playerMaker.Pronouns; var characterPanel = new Image(portraitImage, new Vector2( PronounDropDown.Bounds.Right + 30 + (_panel.Right() - 30 - (PronounDropDown.Bounds.Right + 30)) / 2f - portraitImage.Center.X * _buttonScale, nameTextBoxTitle.Top()), _buttonScale); // Character Preview var characterPreview = new CharacterPreview(_characterRenderer, characterPanel.Center()); // Hair var hairText = new TextBlock("Hair Style", new Vector2(PronounDropDown.Left(), PronounDropDown.BottomLeft().Y + 10), interfaceFont, Color.White, Color.Black); PlayerHairDropDown = new DropDownBox(_contentChest, inputBoxFont, new Vector2(hairText.Left(), hairText.BottomLeft().Y + 10), _hair.Select(x => x.Name).ToArray(), 200); PlayerHairDropDown.Hover += (newIndex) => { characterPreview.Hair = _hair[newIndex]; }; PlayerHairDropDown.SelectedIndex = _playerMaker.Hair; // Head var headText = new TextBlock("Head Shape", PlayerHairDropDown.BottomLeft().Add(0, 10), interfaceFont, Color.White, Color.Black); var horizontalSelector = new HorizontalSelector(headText.BottomLeft().Add(0, 10), _heads.Select(x => x.Name).ToArray(), 200, mainMenuSpriteMap.CreateSpriteFromRegion("Arrow_Left"), mainMenuSpriteMap.CreateSpriteFromRegion("Arrow_Right"), interfaceFont, _buttonScale); horizontalSelector.SelectionChanged += (newIndex) => { characterPreview.Head = _heads[newIndex]; }; horizontalSelector.SelectedIndex = _playerMaker.Head; _panel.AddChild(pronounTextBoxTitle); _panel.AddChild(nameTextBoxTitle); _panel.AddChild(NameTextBox); _panel.AddChild(characterPanel); _panel.AddChild(BackButton); _panel.AddChild(DoneButton); _panel.AddChild(hairText); _panel.AddChild(headText); _panel.AddChild(horizontalSelector); _panel.AddChild(characterPreview); _panel.AddChild(PlayerHairDropDown); _panel.AddChild(PronounDropDown); _userInterface.AddWidget(_panel); DoneButton.OnClick += () => { Console.WriteLine("Saving Settings"); _playerMaker.SetHair(PlayerHairDropDown.SelectedIndex); _playerMaker.SetName(NameTextBox.GetValue()); _playerMaker.SetPronouns(PronounDropDown.SelectedIndex); }; }