1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 09:32:55 +08:00

Merge pull request #1010 from Tom94/container-collection-readonlylist

Update framework with ICollection & IReadOnlyList Containers
This commit is contained in:
Dean Herbert 2017-07-12 13:15:44 +09:00 committed by GitHub
commit a5d0bfb02f
29 changed files with 54 additions and 59 deletions

@ -1 +1 @@
Subproject commit 38363de3d466c60d668159745826df239318f875
Subproject commit 46a56e0e11d56c788ff8db089582718a606ed158

View File

@ -76,7 +76,7 @@ namespace osu.Desktop.VisualTests.Tests
ControlPointInfo = controlPointInfo
});
Add(new Drawable[]
AddRange(new Drawable[]
{
new Container
{

View File

@ -50,7 +50,7 @@ namespace osu.Desktop.VisualTests.Tests
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Position = new Vector2(20, -160),
Count = 5,
CountStars = 5,
};
Add(stars);
@ -59,7 +59,7 @@ namespace osu.Desktop.VisualTests.Tests
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Position = new Vector2(20, -190),
Text = stars.Count.ToString("0.00"),
Text = stars.CountStars.ToString("0.00"),
};
Add(starsLabel);
@ -69,8 +69,8 @@ namespace osu.Desktop.VisualTests.Tests
comboCounter.Current.Value = 0;
numerator = denominator = 0;
accuracyCounter.SetFraction(0, 0);
stars.Count = 0;
starsLabel.Text = stars.Count.ToString("0.00");
stars.CountStars = 0;
starsLabel.Text = stars.CountStars.ToString("0.00");
});
AddStep(@"Hit! :D", delegate
@ -91,8 +91,8 @@ namespace osu.Desktop.VisualTests.Tests
AddStep(@"Alter stars", delegate
{
stars.Count = RNG.NextSingle() * (stars.StarCount + 1);
starsLabel.Text = stars.Count.ToString("0.00");
stars.CountStars = RNG.NextSingle() * (stars.StarCount + 1);
starsLabel.Text = stars.CountStars.ToString("0.00");
});
AddStep(@"Stop counters", delegate

View File

@ -55,7 +55,7 @@ namespace osu.Desktop.VisualTests.Tests
timeRangeBindable.ValueChanged += v => timeRangeText.Text = $"Visible Range: {v:#,#.#}";
timeRangeBindable.ValueChanged += v => bottomLabel.Text = $"t minus {v:#,#}";
Add(new Drawable[]
AddRange(new Drawable[]
{
new Container
{

View File

@ -202,7 +202,7 @@ namespace osu.Desktop.Overlays
{
this.game = game;
IconContent.Add(new Drawable[]
IconContent.AddRange(new Drawable[]
{
new Box
{

View File

@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
RelativeSizeAxes = Axes.Both;
Height = (float)HitObject.Duration;
Add(new Drawable[]
AddRange(new Drawable[]
{
// For now the body piece covers the entire height of the container
// whereas possibly in the future we don't want to extend under the head/tail.

View File

@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Osu.UI
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Add(new Drawable[]
AddRange(new Drawable[]
{
connectionLayer = new FollowPointRenderer
{

View File

@ -68,7 +68,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces
{
EarlyActivationMilliseconds = pre_beat_transition_time;
AddInternal(new Drawable[]
AddRangeInternal(new Drawable[]
{
background = new CircularContainer
{

View File

@ -54,7 +54,7 @@ namespace osu.Game.Rulesets.Taiko.UI
public TaikoPlayfield()
{
AddInternal(new Drawable[]
AddRangeInternal(new Drawable[]
{
new ScaleFixContainer
{

View File

@ -140,7 +140,7 @@ namespace osu.Game.Beatmaps.Drawables
},
starCounter = new StarCounter
{
Count = (float)beatmap.StarDifficulty,
CountStars = (float)beatmap.StarDifficulty,
Scale = new Vector2(0.8f),
}
}

View File

@ -93,7 +93,7 @@ namespace osu.Game.Graphics.Containers
sections = value.ToList();
if (sections.Count == 0) return;
sectionsContainer.Add(sections);
sectionsContainer.AddRange(sections);
SelectedSection.Value = sections[0];
lastKnownScroll = float.NaN;
}

View File

@ -58,7 +58,7 @@ namespace osu.Game.Graphics.UserInterface
Direction = Direction,
});
//I'm using ToList() here because Where() returns an Enumerable which can change it's elements afterwards
Remove(Children.Where((bar, index) => index >= value.Count()).ToList());
RemoveRange(Children.Where((bar, index) => index >= value.Count()).ToList());
}
}
}

View File

@ -49,7 +49,7 @@ namespace osu.Game.Graphics.UserInterface
Content.Masking = true;
Content.CornerRadius = 5;
Add(new Drawable[]
AddRange(new Drawable[]
{
new Triangles
{

View File

@ -17,7 +17,7 @@ namespace osu.Game.Graphics.UserInterface
public SearchTextBox()
{
Height = 35;
Add(new Drawable[]
AddRange(new Drawable[]
{
new TextAwesome
{

View File

@ -33,25 +33,25 @@ namespace osu.Game.Graphics.UserInterface
private const float star_size = 20;
private const float star_spacing = 4;
private float count;
private float countStars;
/// <summary>
/// Amount of stars represented.
/// </summary>
public float Count
public float CountStars
{
get
{
return count;
return countStars;
}
set
{
if (count == value) return;
if (countStars == value) return;
if (IsLoaded)
transformCount(value);
count = value;
countStars = value;
}
}
@ -94,15 +94,15 @@ namespace osu.Game.Graphics.UserInterface
public void ResetCount()
{
count = 0;
countStars = 0;
StopAnimation();
}
public void ReplayAnimation()
{
var t = count;
var t = countStars;
ResetCount();
Count = t;
CountStars = t;
}
public void StopAnimation()
@ -111,8 +111,8 @@ namespace osu.Game.Graphics.UserInterface
foreach (var star in stars.Children)
{
star.ClearTransforms(true);
star.FadeTo(i < count ? 1.0f : minStarAlpha);
star.Icon.ScaleTo(getStarScale(i, count));
star.FadeTo(i < countStars ? 1.0f : minStarAlpha);
star.Icon.ScaleTo(getStarScale(i, countStars));
i++;
}
}
@ -132,7 +132,7 @@ namespace osu.Game.Graphics.UserInterface
{
star.ClearTransforms(true);
var delay = (count <= newValue ? Math.Max(i - count, 0) : Math.Max(count - 1 - i, 0)) * animationDelay;
var delay = (countStars <= newValue ? Math.Max(i - countStars, 0) : Math.Max(countStars - 1 - i, 0)) * animationDelay;
using (BeginDelayedSequence(delay, true))
{

View File

@ -141,7 +141,7 @@ namespace osu.Game
{
base.LoadComplete();
Add(new Drawable[] {
AddRange(new Drawable[] {
new VolumeControlReceptor
{
RelativeSizeAxes = Axes.Both,

View File

@ -67,7 +67,7 @@ namespace osu.Game.Overlays.Chat
var displayMessages = newMessages.Skip(Math.Max(0, newMessages.Count() - Channel.MAX_HISTORY));
//up to last Channel.MAX_HISTORY messages
flow.Add(displayMessages.Select(m => new ChatLine(m)));
flow.AddRange(displayMessages.Select(m => new ChatLine(m)));
if (!IsLoaded) return;

View File

@ -199,7 +199,7 @@ namespace osu.Game.Overlays.Mods
iconsContainer.Clear();
if (Mods.Length > 1)
{
iconsContainer.Add(new[]
iconsContainer.AddRange(new[]
{
backgroundIcon = new ModIcon(Mods[1])
{

View File

@ -49,7 +49,7 @@ namespace osu.Game.Overlays.Notifications
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
AddInternal(new Drawable[]
AddRangeInternal(new Drawable[]
{
Light = new NotificationLight
{

View File

@ -69,7 +69,7 @@ namespace osu.Game.Overlays.Notifications
Left = 20,
};
AddInternal(new Drawable[]
AddRangeInternal(new Drawable[]
{
new Container
{

View File

@ -42,7 +42,7 @@ namespace osu.Game.Overlays.Notifications
public SimpleNotification()
{
IconContent.Add(new Drawable[]
IconContent.AddRange(new Drawable[]
{
IconBackgound = new Box
{

View File

@ -44,7 +44,7 @@ namespace osu.Game.Overlays.Settings
const int header_size = 26;
const int header_margin = 25;
const int border_size = 2;
AddInternal(new Drawable[]
AddRangeInternal(new Drawable[]
{
new Box
{

View File

@ -33,7 +33,7 @@ namespace osu.Game.Overlays.Settings
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Direction = FillDirection.Vertical;
AddInternal(new Drawable[]
AddRangeInternal(new Drawable[]
{
new OsuSpriteText
{

View File

@ -114,8 +114,8 @@ namespace osu.Game.Screens.Menu
buttonsTopLevel.Add(new Button(@"osu!direct", string.Empty, FontAwesome.fa_osu_chevron_down_o, new Color4(165, 204, 0, 255), () => OnDirect?.Invoke(), 0, Key.D));
buttonsTopLevel.Add(new Button(@"exit", string.Empty, FontAwesome.fa_osu_cross_o, new Color4(238, 51, 153, 255), onExit, 0, Key.Q));
buttonFlow.Add(buttonsPlay);
buttonFlow.Add(buttonsTopLevel);
buttonFlow.AddRange(buttonsPlay);
buttonFlow.AddRange(buttonsTopLevel);
}
[BackgroundDependencyLoader(true)]

View File

@ -20,15 +20,15 @@ namespace osu.Game.Screens.Play
private SpriteText countSpriteText;
public bool IsCounting { get; set; }
private int count;
public int Count
private int countPresses;
public int CountPresses
{
get { return count; }
get { return countPresses; }
private set
{
if (count != value)
if (countPresses != value)
{
count = value;
countPresses = value;
countSpriteText.Text = value.ToString(@"#,0");
}
}
@ -45,7 +45,7 @@ namespace osu.Game.Screens.Play
isLit = value;
updateGlowSprite(value);
if (value && IsCounting)
Count++;
CountPresses++;
}
}
}
@ -98,7 +98,7 @@ namespace osu.Game.Screens.Play
},
countSpriteText = new OsuSpriteText
{
Text = Count.ToString(@"#,0"),
Text = CountPresses.ToString(@"#,0"),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativePositionAxes = Axes.Both,
@ -128,6 +128,6 @@ namespace osu.Game.Screens.Play
}
}
public void ResetCount() => Count = 0;
public void ResetCount() => CountPresses = 0;
}
}

View File

@ -200,7 +200,7 @@ namespace osu.Game.Screens.Play
scoreProcessor = HitRenderer.CreateScoreProcessor();
hudOverlay.KeyCounter.Add(rulesetInstance.CreateGameplayKeys());
hudOverlay.KeyCounter.AddRange(rulesetInstance.CreateGameplayKeys());
hudOverlay.BindProcessor(scoreProcessor);
hudOverlay.BindHitRenderer(HitRenderer);

View File

@ -40,7 +40,7 @@ namespace osu.Game.Screens.Ranking
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
AddInternal(new Drawable[]
AddRangeInternal(new Drawable[]
{
fill = new Box
{

View File

@ -12,7 +12,6 @@ using osu.Game.Beatmaps.Drawables;
using osu.Game.Configuration;
using osu.Framework.Input;
using OpenTK.Input;
using System.Collections;
using osu.Framework.MathUtils;
using System.Diagnostics;
using System.Threading.Tasks;
@ -22,7 +21,7 @@ using osu.Framework.Configuration;
namespace osu.Game.Screens.Select
{
internal class BeatmapCarousel : ScrollContainer, IEnumerable<BeatmapGroup>
internal class BeatmapCarousel : ScrollContainer
{
public BeatmapInfo SelectedBeatmap => selectedPanel?.Beatmap;
@ -265,10 +264,6 @@ namespace osu.Game.Screens.Select
perform();
}
public IEnumerator<BeatmapGroup> GetEnumerator() => groups.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
private BeatmapGroup createGroup(BeatmapSetInfo beatmapSet)
{
foreach (var b in beatmapSet.Beatmaps)
@ -307,7 +302,7 @@ namespace osu.Game.Screens.Select
panels.Remove(p);
scrollableContent.Remove(group.Header);
scrollableContent.Remove(group.BeatmapPanels);
scrollableContent.RemoveRange(group.BeatmapPanels);
if (selectedGroup == group)
SelectNext();

View File

@ -33,7 +33,7 @@ namespace osu.Game.Screens.Select
public BeatmapDetailArea()
{
AddInternal(new Drawable[]
AddRangeInternal(new Drawable[]
{
new BeatmapDetailAreaTabControl
{
@ -61,7 +61,7 @@ namespace osu.Game.Screens.Select
},
});
Add(new Drawable[]
AddRange(new Drawable[]
{
Details = new BeatmapDetails
{