protected virtual Drawable AddCharacterToFlow(char c) { // Remove all characters to the right and store them in a local list, // such that their depth can be updated. List <Drawable> charsRight = new List <Drawable>(); foreach (Drawable d in textFlow.Children.Skip(selectionLeft)) { charsRight.Add(d); } textFlow.Remove(charsRight); // Update their depth to make room for the to-be inserted character. int i = -selectionLeft; foreach (Drawable d in charsRight) { d.Depth = --i; } // Add the character Drawable ch; textFlow.Add(ch = new SpriteText { Text = c.ToString(), TextSize = DrawSize.Y, Depth = -selectionLeft, }); // Add back all the previously removed characters textFlow.Add(charsRight); return(ch); }
public void AddItem(DropDownMenuItem <T> item) { addMenuItem(item, internalItems.Count); internalItems.Add(item); if (listInitialized) { DropDownList.Add(item); } }
public override void Reset() { base.Reset(); FlowContainer textBoxes = new FlowContainer { Direction = FlowDirections.Vertical, Padding = new MarginPadding { Top = 50, }, Spacing = new Vector2(0, 50), Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, RelativeSizeAxes = Axes.Both, Size = new Vector2(0.8f, 1) }; Add(textBoxes); textBoxes.Add(new TextBox { Size = new Vector2(100, 16), }); textBoxes.Add(new TextBox { Text = @"Limited length", Size = new Vector2(200, 20), LengthLimit = 20 }); textBoxes.Add(new TextBox { Text = @"Box with some more text", Size = new Vector2(500, 30), }); textBoxes.Add(new TextBox { PlaceholderText = @"Placeholder text", Size = new Vector2(500, 30), }); textBoxes.Add(new TextBox { Text = @"prefilled placeholder", PlaceholderText = @"Placeholder text", Size = new Vector2(500, 30), }); //textBoxes.Add(tb = new PasswordTextBox(@"", 14, Vector2.Zero, 300)); }
public Button AddButton(string text, Action action) { Button b; buttonsContainer.Add(b = new Button { Colour = Color4.LightBlue, Size = new Vector2(150, 50), Text = text }); b.Action += action; return(b); }
public override void Reset() { base.Reset(); FlowContainer flow; Add(flow = new FlowContainer() { RelativeSizeAxes = Axes.Both, Size = new Vector2(0.5f), Anchor = Anchor.Centre, Origin = Anchor.Centre }); int i = 50; foreach (FontAwesome fa in Enum.GetValues(typeof(FontAwesome))) { flow.Add(new TextAwesome { Icon = fa, TextSize = 60, Colour = new Color4( Math.Max(0.5f, RNG.NextSingle()), Math.Max(0.5f, RNG.NextSingle()), Math.Max(0.5f, RNG.NextSingle()), 1) }); if (i-- == 0) break; } }
public ToolbarModeSelector() { RelativeSizeAxes = Axes.Y; Children = new Drawable[] { new OpaqueBackground(), modeButtons = new FlowContainer { RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, Direction = FlowDirection.HorizontalOnly, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Padding = new MarginPadding { Left = 10, Right = 10 }, }, modeButtonLine = new Container { RelativeSizeAxes = Axes.X, Size = new Vector2(0.3f, 3), Anchor = Anchor.BottomLeft, Origin = Anchor.TopLeft, Masking = true, EdgeEffect = new EdgeEffect { Type = EdgeEffectType.Glow, Colour = new Color4(255, 194, 224, 100), Radius = 15, Roundness = 15, }, Children = new [] { new Box { RelativeSizeAxes = Axes.Both, } } } }; int amountButtons = 0; foreach (PlayMode m in Enum.GetValues(typeof(PlayMode))) { ++amountButtons; var localMode = m; modeButtons.Add(new ToolbarModeButton { Mode = m, Action = delegate { SetGameMode(localMode); OnPlayModeChange?.Invoke(localMode); } }); } }
private void newMessagesArrived(IEnumerable <Message> newMessages) { if (!IsLoaded) { return; } var displayMessages = newMessages.Skip(Math.Max(0, newMessages.Count() - Channel.MAX_HISTORY)); if (scroll.IsScrolledToEnd(10) || !flow.Children.Any()) { scrollToEnd(); } //up to last Channel.MAX_HISTORY messages foreach (Message m in displayMessages) { var d = new ChatLine(m); flow.Add(d); } while (flow.Children.Count(c => c.LifetimeEnd == double.MaxValue) > Channel.MAX_HISTORY) { var d = flow.Children.First(c => c.LifetimeEnd == double.MaxValue); if (!scroll.IsScrolledToEnd(10)) { scroll.OffsetScrollPosition(-d.DrawHeight); } d.Expire(); } }
public override void Reset() { base.Reset(); FlowContainer flow; Children = new [] { new ScrollContainer { Children = new [] { flow = new FlowContainer { LayoutDuration = 100, LayoutEasing = EasingTypes.Out, Spacing = new Vector2(1, 1), RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Padding = new MarginPadding(5) } }, }, }; boxCreator?.Cancel(); boxCreator = Scheduler.AddDelayed(delegate { if (Parent == null) { return; } Box box; Container container = new Container { Size = new Vector2(80, 80), Children = new[] { box = new Box { RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, Colour = new Color4(RNG.NextSingle(), RNG.NextSingle(), RNG.NextSingle(), 1) } } }; flow.Add(container); container.FadeInFromZero(1000); container.Delay(RNG.Next(0, 20000), true); container.FadeOutFromOne(4000); box.RotateTo((RNG.NextSingle() - 0.5f) * 90, 4000); box.ScaleTo(0.5f, 4000); container.Expire(); }, 100, true); Scheduler.Add(boxCreator); }
public override void Reset() { base.Reset(); FlowContainer flow; Add(flow = new FlowContainer() { RelativeSizeAxes = Axes.Both, Size = new Vector2(0.5f), Anchor = Anchor.Centre, Origin = Anchor.Centre }); int i = 50; foreach (FontAwesome fa in Enum.GetValues(typeof(FontAwesome))) { flow.Add(new TextAwesome { Icon = fa, TextSize = 60, Colour = new Color4( Math.Max(0.5f, RNG.NextSingle()), Math.Max(0.5f, RNG.NextSingle()), Math.Max(0.5f, RNG.NextSingle()), 1) }); if (i-- == 0) { break; } } }
public void AddDifficultyIcons(IEnumerable <BeatmapPanel> panels) { foreach (var p in panels) { difficultyIcons.Add(new DifficultyIcon(p.Beatmap)); } }
public override void Reset() { base.Reset(); FlowContainer flow; Children = new Drawable[] { new ScrollContainer { Children = new[] { flow = new FlowContainer { Anchor = Anchor.TopLeft, AutoSizeAxes = Axes.Both, Direction = FlowDirection.VerticalOnly, } } } }; flow.Add(new SpriteText { Text = @"the quick red fox jumps over the lazy brown dog" }); flow.Add(new SpriteText { Text = @"THE QUICK RED FOX JUMPS OVER THE LAZY BROWN DOG" }); flow.Add(new SpriteText { Text = @"0123456789!@#$%^&*()_-+-[]{}.,<>;'\" }); for (int i = 1; i <= 200; i++) { SpriteText text = new SpriteText { Text = $@"Font testy at size {i}", TextSize = i }; flow.Add(text); } }
private void addChannel(Channel channel) { flow.Add(channelDisplay = new ChannelDisplay(channel) { Size = new Vector2(1, 0.3f) }); careChannels.Add(channel); }
protected virtual Drawable AddCharacterToFlow(char c) { int i = selectionLeft; foreach (Drawable dd in textFlow.Children.Skip(selectionLeft).Take(text.Length - selectionLeft)) { dd.Depth = i + 1; } Drawable ch; if (char.IsWhiteSpace(c)) { float width = SpaceWidth / 2; switch ((int)c) { case 0x3000: //double-width space width = SpaceWidth; break; } textFlow.Add(ch = new Container() { SizeMode = InheritMode.None, Size = new Vector2(width, SpaceWidth), Depth = selectionLeft }); } else { textFlow.Add(ch = new SpriteText() { Text = c.ToString(), TextSize = Size.Y, Depth = selectionLeft, }); } return(ch); }
public void AddTeam(TournamentTeam team) { GroupTeam gt = new GroupTeam(team); if (TeamsCount < 8) { teams.Add(gt); allTeams.Add(gt); TeamsCount++; } }
private void initializeDropDownList() { if (DropDownItemsContainer == null || !DropDownItemsContainer.IsLoaded) { return; } foreach (DropDownMenuItem <T> item in items) { DropDownItemsContainer.Add(item); } listInitialized = true; }
public ToolbarModeSelector() { RelativeSizeAxes = Axes.Y; Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = new Color4(20, 20, 20, 255) }, modeButtons = new FlowContainer { RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, Direction = FlowDirection.HorizontalOnly, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, modeButtonLine = new Box { RelativeSizeAxes = Axes.X, Size = new Vector2(0.3f, 3), Anchor = Anchor.BottomLeft, Origin = Anchor.TopCentre, Colour = Color4.White } }; int amountButtons = 0; foreach (PlayMode m in Enum.GetValues(typeof(PlayMode))) { ++amountButtons; var localMode = m; modeButtons.Add(new ToolbarModeButton { Mode = m, Action = delegate { SetGameMode(localMode); OnPlayModeChange?.Invoke(localMode); } }); } // We need to set the size within LoadComplete, because Size = new Vector2(amountButtons * ToolbarButton.WIDTH + padding * 2, 1); }
internal override void Reset() { base.Reset(); FlowContainer textBoxes = new FlowContainer() { Direction = FlowDirection.VerticalOnly, Padding = new Vector2(0, 50), Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, SizeMode = InheritMode.XY, Size = new Vector2(0.8f, 1) }; Add(textBoxes); textBoxes.Add(tb = new TextBox() { Size = new Vector2(100, 16), }); textBoxes.Add(tb = new TextBox() { Text = @"Limited length", Size = new Vector2(200, 20), LengthLimit = 20 }); textBoxes.Add(tb = new TextBox() { Text = @"Box with some more text", Size = new Vector2(500, 30), }); //textBoxes.Add(tb = new PasswordTextBox(@"", 14, Vector2.Zero, 300)); }
private void load(StraightConfigManager configManager) { StartPitch = configManager.Get <Pitch>(StraightSetting.StartPitch); // Column ColumnCount = configManager.Get <int>(StraightSetting.availableColumns);; for (int i = 0; i < ColumnCount; i++) { Column c = New <Column>(new object[] { StartPitch + i, VisibleTimeRange }, "Column " + (StartPitch + i)); AddChild(c); ColumnArranger.Add(c); Columns.Add(c); addNestedPlayField(c); } }
public override void Reset() { base.Reset(); createArea(scrollDir = Direction.Vertical); AddButton("Vertical", delegate { createArea(scrollDir = Direction.Vertical); }); AddButton("Horizontal", delegate { createArea(scrollDir = Direction.Horizontal); }); AddButton("Dragger Anchor 1", delegate { scroll.ScrollDraggerAnchor = scrollDir == Direction.Vertical ? Anchor.TopRight : Anchor.BottomLeft; }); AddButton("Dragger Anchor 2", delegate { scroll.ScrollDraggerAnchor = scrollDir == Direction.Vertical ? Anchor.TopLeft : Anchor.TopLeft; }); AddButton("Dragger Visible", delegate { scroll.ScrollDraggerVisible = !scroll.ScrollDraggerVisible; }); AddButton("Dragger Overlap", delegate { scroll.ScrollDraggerOverlapsContent = !scroll.ScrollDraggerOverlapsContent; }); boxCreator?.Cancel(); boxCreator = Scheduler.AddDelayed(delegate { if (Parent == null) { return; } Box box; Container container = new Container { Size = new Vector2(80, 80), Children = new[] { box = new Box { RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, Colour = new Color4(RNG.NextSingle(), RNG.NextSingle(), RNG.NextSingle(), 1) } } }; flow.Add(container); container.FadeInFromZero(1000); container.Delay(RNG.Next(0, 20000), true); container.FadeOutFromOne(4000); box.RotateTo((RNG.NextSingle() - 0.5f) * 90, 4000); box.ScaleTo(0.5f, 4000); container.Expire(); }, 100, true); }
protected override void Load(BaseGame game) { base.Load(game); BeatmapPanels = beatmapSet.Beatmaps.Select(b => new BeatmapPanel(b) { GainedSelection = panelGainedSelection, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, RelativeSizeAxes = Axes.X, }).ToList(); //for the time being, let's completely load the difficulty panels in the background. //this likely won't scale so well, but allows us to completely async the loading flow. Task.WhenAll(BeatmapPanels.Select(panel => panel.Preload(game, p => difficulties.Add(panel)))).Wait(); }
public void AddButton(string text, Color4 colour, Action action) { var button = new FooterButton { Text = text, Height = play_song_select_button_height, Width = play_song_select_button_width, SelectedColour = colour, DeselectedColour = colour.Opacity(0.5f), }; button.Hovered = () => updateModeLight(button); button.HoverLost = () => updateModeLight(); button.Action = action; buttons.Add(button); }
private void logger_NewEntry(LogEntry entry) { Schedule(() => { var drawEntry = new DrawableLogEntry(entry); flow.Add(drawEntry); drawEntry.Position = new Vector2(-drawEntry.DrawWidth, 0); drawEntry.FadeInFromZero(200); drawEntry.Delay(200); drawEntry.FadeOut(entry.Message.Length * 100, EasingTypes.InQuint); drawEntry.Expire(); }); }
private void initializeDropDownList() { if (DropDownItemsContainer == null || !DropDownItemsContainer.IsLoaded) { return; } for (int i = 0; i < items.Count; i++) { DropDownItemsContainer.Add(items[i]); } DropDown.Position = new Vector2(0, ComboBox.Height + DropDownListSpacing); listInitialized = true; }
public override void Load(BaseGame game) { base.Load(game); Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = new Color4(20, 20, 20, 255) }, modeButtons = new FlowContainer { RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, Direction = FlowDirection.HorizontalOnly, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, modeButtonLine = new Box { RelativeSizeAxes = Axes.X, Size = new Vector2(0.3f, 3), Anchor = Anchor.BottomLeft, Origin = Anchor.TopCentre, Colour = Color4.White } }; foreach (PlayMode m in Enum.GetValues(typeof(PlayMode))) { var localMode = m; modeButtons.Add(new ToolbarModeButton { Mode = m, Action = delegate { SetGameMode(localMode); OnPlayModeChange?.Invoke(localMode); } }); } RelativeSizeAxes = Axes.Y; Size = new Vector2(modeButtons.Children.Count() * ToolbarButton.WIDTH + padding * 2, 1); }
private void addButton(RadioButton button) { button.Selected.ValueChanged += v => { if (v) { currentlySelected?.Deselect(); currentlySelected = button; } else { currentlySelected = null; } }; buttonContainer.Add(new DrawableRadioButton(button)); }
private void addBeatmapSet(BeatmapSetInfo beatmapSet) { beatmapSet = database.GetWithChildren <BeatmapSetInfo>(beatmapSet.BeatmapSetID); beatmapSet.Beatmaps.ForEach(b => database.GetChildren(b)); beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.BaseDifficulty.OverallDifficulty).ToList(); Schedule(() => { var group = new BeatmapGroup(beatmapSet) { SelectionChanged = selectBeatmap }; setList.Add(group); if (setList.Children.Count() == 1) { group.State = BeatmapGroupState.Expanded; } }); }
public ManiaPlayfield(int columnCount) { this.columnCount = columnCount; if (columnCount <= 0) { throw new ArgumentException("Can't have zero or fewer columns."); } Children = new Drawable[] { new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = Color4.Black }, Columns = new FillFlowContainer <Column> { RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, Direction = FillDirection.Horizontal, Padding = new MarginPadding { Left = 1, Right = 1 }, Spacing = new Vector2(1, 0) } } } }; for (int i = 0; i < columnCount; i++) { Columns.Add(new Column()); } }
private void requestNewMessages() { messageRequest.Wait(); Channel channel = channels.Find(c => c.Name == "#osu"); GetMessagesRequest gm = new GetMessagesRequest(new List <Channel> { channel }, lastMessageId); gm.Success += delegate(List <Message> messages) { foreach (Message m in messages) { //m.LineWidth = this.Size.X; //this is kinda ugly. //m.Drawable.Depth = m.Id; //m.Drawable.FadeInFromZero(800); //flow.Add(m.Drawable); //if (osu.Messages.Count > 50) //{ // osu.Messages[0].Drawable.Expire(); // osu.Messages.RemoveAt(0); //} flow.Add(new ChatLine(m)); channel.Messages.Add(m); } lastMessageId = messages.LastOrDefault()?.Id ?? lastMessageId; Debug.Write("success!"); messageRequest.Continue(); }; gm.Failure += delegate { Debug.Write("failure!"); messageRequest.Continue(); }; api.Queue(gm); }
internal override void Reset() { base.Reset(); FlowContainer flow = new FlowContainer() { LayoutDuration = 100, LayoutEasing = EasingTypes.Out, Padding = new Vector2(1, 1), SizeMode = InheritMode.X }; boxCreator?.Cancel(); boxCreator = scheduler.AddDelayed(delegate { if (Parent == null) { return; } Box box = new Box() { Size = new Vector2(80, 80), Colour = new Color4(RNG.NextSingle(), RNG.NextSingle(), RNG.NextSingle(), 1) }; flow.Add(box); box.FadeInFromZero(1000); box.Delay(RNG.Next(0, 20000)); box.FadeOutFromOne(4000); box.Expire(); }, 100, true); scheduler.Add(boxCreator); ScrollContainer scrolling = new ScrollContainer(); scrolling.Add(flow); Add(scrolling); }
private void newMessages(IEnumerable <Message> newMessages) { if (!IsLoaded) { return; } var displayMessages = newMessages.Skip(Math.Max(0, newMessages.Count() - Channel.MAX_HISTORY)); //up to last Channel.MAX_HISTORY messages foreach (Message m in displayMessages) { flow.Add(new ChatLine(m)); } while (flow.Children.Count() > Channel.MAX_HISTORY) { flow.Remove(flow.Children.First()); } }
protected virtual Drawable AddCharacterToFlow(char c) { int i = selectionLeft; foreach (Drawable dd in textFlow.Children.Skip(selectionLeft).Take(InternalText.Length - selectionLeft)) { dd.Depth = -i - 1; } Drawable ch; textFlow.Add(ch = new SpriteText { Text = c.ToString(), TextSize = DrawSize.Y, Depth = -selectionLeft, }); return(ch); }