public TestScheduledUpdatesScreenView(Screen screen) : base(screen) { Scheduled = new SpriteTextPlus(FontManager.GetWobbleFont("exo2-semibold"), "", 36) { Alignment = Alignment.TopCenter, Y = 250 }; Task.Run(() => { while (!Scheduled.IsDisposed) { if (IsScheduled) { Scheduled.ScheduleUpdate(() => Scheduled.Text = $"Scheduled - {DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}"); } else { Scheduled.Text = $"Unscheduled - {DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}"; } } }); new SpriteText("exo2-semibold", "Press 1 to toggle between scheduled & unscheduled", 32) { Parent = Container, Alignment = Alignment.BotCenter }; }
/// <summary> /// </summary> /// <param name="screen"></param> public TestSpriteTextPlusScreenView(Screen screen) : base(screen) { Font = FontManager.GetWobbleFont("exo2-semibold"); var text = new SpriteTextPlus(Font, "Hello, World! いろはにほへど\nthis should be on a new line\n🍆😀 😁 😂 🤣😃 😄 😅 😆 😉 😊 😋 😎\nhi", 48) { Parent = Container, Alignment = Alignment.MidCenter, }; text.AddBorder(Color.Crimson, 2); text.MoveToY(-300, Easing.Linear, 2000); var cyrillic = new SpriteTextPlus(Font, "Лорем ипсум долор сит амет, еяуидем маиорум медиоцрем ут дуо", 22) { Parent = Container, Alignment = Alignment.MidCenter, Y = text.Height + 20, Tint = Color.Lime }; cyrillic.AddBorder(Color.Cyan, 2); }
/// <inheritdoc /> /// <summary> /// </summary> /// <param name="options"></param> /// <param name="selectorSize"></param> /// <param name="selectorFont"></param> /// <param name="fontScale"></param> /// <param name="leftButtonImage"></param> /// <param name="rightButtonImage"></param> /// <param name="buttonSize"></param> /// <param name="buttonSpacing"></param> /// <param name="onChange"></param> /// <param name="selectedIndex"></param> public HorizontalSelector(List <string> options, ScalableVector2 selectorSize, WobbleFontStore font, int fontSize, Texture2D leftButtonImage, Texture2D rightButtonImage, ScalableVector2 buttonSize, int buttonSpacing, Action <string, int> onChange, int selectedIndex = 0) { if (options.Count == 0) { throw new ArgumentException("HorizontalSelector must be initialized with more than one option."); } Options = options; OnChange = onChange; if (SelectedIndex < 0 || selectedIndex > Options.Count - 1) { throw new ArgumentException("Default selectedIndex must be in range of the options."); } SelectedIndex = selectedIndex; Size = selectorSize; // Create the text that displays the currently selected item. SelectedItemText = new SpriteTextPlus(font, Options[SelectedIndex], fontSize) { Parent = this, Alignment = Alignment.MidCenter, Tint = Color.Black }; // Create the left selection button. ButtonSelectLeft = new ImageButton(leftButtonImage, (sender, e) => HandleSelection(Direction.Backward)) { Parent = this, Alignment = Alignment.MidLeft, Size = buttonSize, Image = leftButtonImage, X = -buttonSize.X.Value - buttonSpacing }; // Create the right selection button. ButtonSelectRight = new ImageButton(rightButtonImage, (sender, e) => HandleSelection(Direction.Forward)) { Parent = this, Alignment = Alignment.MidRight, Size = buttonSize, Image = rightButtonImage, X = buttonSize.X.Value + buttonSpacing }; }
public override void Update(GameTime gameTime) { if (State.Count != JoystickManager.CurrentState.Buttons.Length) { foreach (var text in State) { text.Destroy(); } State.Clear(); var font = FontManager.GetWobbleFont("exo2-semibold"); float y = 0; for (var key = 0; key < JoystickManager.CurrentState.Buttons.Length; ++key) { var text = new SpriteTextPlus(font, $"Button {key}:") { Parent = Container, Y = y }; y += text.Height; State.Add(text); } } for (var key = 0; key < JoystickManager.CurrentState.Buttons.Length; ++key) { if (JoystickManager.CurrentState.Buttons[key] == ButtonState.Pressed) { State[key].Text = $"Button {key}: Down"; } else { State[key].Text = $"Button {key}:"; } } Container?.Update(gameTime); }
/// <summary> /// </summary> /// <param name="screen"></param> public TestSpriteTextPlusScreenView(Screen screen) : base(screen) { Font = FontManager.GetWobbleFont("exo2-semibold"); var text = new SpriteTextPlus(Font, "Hello, World! いろはにほへど\nthis should be on a new line\n🍆😀 😁 😂 🤣😃 😄 😅 😆 😉 😊 😋 😎\nhi", 48) { Parent = Container, Alignment = Alignment.MidLeft, }; text.AddBorder(Color.Crimson, 2); text.MoveToY(-300, Easing.Linear, 2000); var cyrillic = new SpriteTextPlus(Font, "Лорем ипсум долор сит амет, еяуидем маиорум медиоцрем ут дуо", 22) { Parent = Container, Alignment = Alignment.MidCenter, Y = text.Height + 20, Tint = Color.Lime }; cyrillic.AddBorder(Color.Cyan, 2); var ltr = new SpriteTextPlus(Font, "This text is aligned from\nleft to right", 22) { Parent = Container, Alignment = Alignment.MidLeft, TextAlignment = TextAlignment.Left, X = 20, Y = 100 }; ltr.AddBorder(Color.White, 2); // ReSharper disable once ObjectCreationAsStatement var rtl = new SpriteTextPlus(Font, "This text is aligned from\nright to left", 22) { Parent = Container, Alignment = Alignment.MidRight, TextAlignment = TextAlignment.Right, X = -20, Y = 100 }; rtl.AddBorder(Color.White, 2); // ReSharper disable once ObjectCreationAsStatement var center = new SpriteTextPlus(Font, "This text is aligned\nin the center", 22) { Parent = Container, Alignment = Alignment.MidCenter, TextAlignment = TextAlignment.Center, Y = 100 }; center.AddBorder(Color.White, 2); wrapped = new SpriteTextPlus(Font, "This text is too long and will be wrapped. Also AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.\n\n Hello there as well ! ", 22) { Parent = Container, Alignment = Alignment.TopLeft, TextAlignment = TextAlignment.Left, MaxWidth = 100 }; }