mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 15:07:44 +08:00
Move every class to it's own file
This commit is contained in:
parent
581689a84d
commit
18a714df74
@ -1,249 +0,0 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using System;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class BreakOverlay : Container
|
||||
{
|
||||
private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2;
|
||||
private const int remaining_time_container_max_size = 450;
|
||||
private const int element_margin = 25;
|
||||
|
||||
public List<BreakPeriod> Breaks;
|
||||
|
||||
public override IFrameBasedClock Clock
|
||||
{
|
||||
set
|
||||
{
|
||||
base.Clock = remainingTimeCounter.Clock = value;
|
||||
}
|
||||
get { return base.Clock; }
|
||||
}
|
||||
|
||||
private readonly bool letterboxing;
|
||||
private readonly LetterboxOverlay letterboxOverlay;
|
||||
private readonly Container remainingTimeBox;
|
||||
private readonly RemainingTimeCounter remainingTimeCounter;
|
||||
private readonly InfoContainer info;
|
||||
|
||||
public BreakOverlay(bool letterboxing)
|
||||
{
|
||||
this.letterboxing = letterboxing;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
letterboxOverlay = new LetterboxOverlay(),
|
||||
remainingTimeBox = new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(0, 8),
|
||||
CornerRadius = 4,
|
||||
Masking = true,
|
||||
Child = new Box { RelativeSizeAxes = Axes.Both }
|
||||
},
|
||||
remainingTimeCounter = new RemainingTimeCounter
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Margin = new MarginPadding { Bottom = element_margin },
|
||||
},
|
||||
info = new InfoContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Margin = new MarginPadding { Top = element_margin },
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
InitializeBreaks();
|
||||
}
|
||||
|
||||
public void InitializeBreaks()
|
||||
{
|
||||
if (Breaks != null)
|
||||
{
|
||||
foreach (var b in Breaks)
|
||||
{
|
||||
if (b.HasEffect)
|
||||
{
|
||||
using (BeginAbsoluteSequence(b.StartTime, true))
|
||||
{
|
||||
onBreakIn(b);
|
||||
|
||||
using (BeginDelayedSequence(b.Duration, true))
|
||||
onBreakOut();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onBreakIn(BreakPeriod b)
|
||||
{
|
||||
if (letterboxing)
|
||||
letterboxOverlay.FadeIn(fade_duration);
|
||||
|
||||
remainingTimeBox
|
||||
.ResizeWidthTo(remaining_time_container_max_size, fade_duration, Easing.OutQuint)
|
||||
.Then()
|
||||
.ResizeWidthTo(0, b.Duration);
|
||||
|
||||
Scheduler.AddDelayed(() => remainingTimeCounter.StartCounting(b.EndTime), b.StartTime - Clock.CurrentTime);
|
||||
remainingTimeCounter.FadeIn(fade_duration);
|
||||
|
||||
info.FadeIn(fade_duration);
|
||||
}
|
||||
|
||||
private void onBreakOut()
|
||||
{
|
||||
if (letterboxing)
|
||||
letterboxOverlay.FadeOut(fade_duration);
|
||||
|
||||
remainingTimeCounter.FadeOut(fade_duration);
|
||||
info.FadeOut(fade_duration);
|
||||
}
|
||||
|
||||
private class InfoContainer : FillFlowContainer
|
||||
{
|
||||
public InfoContainer()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Alpha = 0;
|
||||
Direction = FillDirection.Vertical;
|
||||
Spacing = new Vector2(5);
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Text = @"current progress".ToUpper(),
|
||||
TextSize = 15,
|
||||
Font = "Exo2.0-Black",
|
||||
},
|
||||
new FillFlowContainer<InfoLine>
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new []
|
||||
{
|
||||
new InfoLine(@"Accuracy", @"88.54%"),
|
||||
new InfoLine(@"Rank", @"#6584"),
|
||||
new InfoLine(@"Grade", @"A"),
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private class InfoLine : Container
|
||||
{
|
||||
private const int margin = 2;
|
||||
|
||||
private readonly OsuSpriteText text;
|
||||
private readonly OsuSpriteText valueText;
|
||||
|
||||
public InfoLine(string name, string value)
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
text = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.CentreRight,
|
||||
Text = name,
|
||||
TextSize = 17,
|
||||
Margin = new MarginPadding { Right = margin }
|
||||
},
|
||||
valueText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Text = value,
|
||||
TextSize = 17,
|
||||
Font = "Exo2.0-Bold",
|
||||
Margin = new MarginPadding { Left = margin }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
text.Colour = colours.Yellow;
|
||||
valueText.Colour = colours.YellowLight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class RemainingTimeCounter : Container
|
||||
{
|
||||
private readonly OsuSpriteText counter;
|
||||
|
||||
private int? previousSecond;
|
||||
|
||||
private double remainingTime;
|
||||
|
||||
private bool isCounting;
|
||||
|
||||
public RemainingTimeCounter()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Alpha = 0;
|
||||
Child = counter = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
TextSize = 33,
|
||||
Font = "Venera",
|
||||
};
|
||||
}
|
||||
|
||||
public void StartCounting(double remainingTime)
|
||||
{
|
||||
this.remainingTime = remainingTime;
|
||||
isCounting = true;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (isCounting)
|
||||
{
|
||||
var currentTime = Clock.CurrentTime;
|
||||
if (currentTime < remainingTime)
|
||||
{
|
||||
int currentSecond = (int)Math.Floor((remainingTime - Clock.CurrentTime) / 1000.0) + 1;
|
||||
if (currentSecond != previousSecond)
|
||||
{
|
||||
counter.Text = currentSecond.ToString();
|
||||
previousSecond = currentSecond;
|
||||
}
|
||||
}
|
||||
else isCounting = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs
Normal file
120
osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs
Normal file
@ -0,0 +1,120 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Screens.Play.BreaksOverlay
|
||||
{
|
||||
public class BreakOverlay : Container
|
||||
{
|
||||
private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2;
|
||||
private const int remaining_time_container_max_size = 450;
|
||||
private const int element_margin = 25;
|
||||
|
||||
public List<BreakPeriod> Breaks;
|
||||
|
||||
public override IFrameBasedClock Clock
|
||||
{
|
||||
set
|
||||
{
|
||||
base.Clock = remainingTimeCounter.Clock = value;
|
||||
}
|
||||
get { return base.Clock; }
|
||||
}
|
||||
|
||||
private readonly bool letterboxing;
|
||||
private readonly LetterboxOverlay letterboxOverlay;
|
||||
private readonly Container remainingTimeBox;
|
||||
private readonly RemainingTimeCounter remainingTimeCounter;
|
||||
private readonly InfoContainer info;
|
||||
|
||||
public BreakOverlay(bool letterboxing)
|
||||
{
|
||||
this.letterboxing = letterboxing;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
letterboxOverlay = new LetterboxOverlay(),
|
||||
remainingTimeBox = new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(0, 8),
|
||||
CornerRadius = 4,
|
||||
Masking = true,
|
||||
Child = new Box { RelativeSizeAxes = Axes.Both }
|
||||
},
|
||||
remainingTimeCounter = new RemainingTimeCounter
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Margin = new MarginPadding { Bottom = element_margin },
|
||||
},
|
||||
info = new InfoContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Margin = new MarginPadding { Top = element_margin },
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
InitializeBreaks();
|
||||
}
|
||||
|
||||
public void InitializeBreaks()
|
||||
{
|
||||
if (Breaks != null)
|
||||
{
|
||||
foreach (var b in Breaks)
|
||||
{
|
||||
if (b.HasEffect)
|
||||
{
|
||||
using (BeginAbsoluteSequence(b.StartTime, true))
|
||||
{
|
||||
onBreakIn(b);
|
||||
|
||||
using (BeginDelayedSequence(b.Duration, true))
|
||||
onBreakOut();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onBreakIn(BreakPeriod b)
|
||||
{
|
||||
if (letterboxing)
|
||||
letterboxOverlay.FadeIn(fade_duration);
|
||||
|
||||
remainingTimeBox
|
||||
.ResizeWidthTo(remaining_time_container_max_size, fade_duration, Easing.OutQuint)
|
||||
.Then()
|
||||
.ResizeWidthTo(0, b.Duration);
|
||||
|
||||
Scheduler.AddDelayed(() => remainingTimeCounter.StartCounting(b.EndTime), b.StartTime - Clock.CurrentTime);
|
||||
remainingTimeCounter.FadeIn(fade_duration);
|
||||
|
||||
info.FadeIn(fade_duration);
|
||||
}
|
||||
|
||||
private void onBreakOut()
|
||||
{
|
||||
if (letterboxing)
|
||||
letterboxOverlay.FadeOut(fade_duration);
|
||||
|
||||
remainingTimeCounter.FadeOut(fade_duration);
|
||||
info.FadeOut(fade_duration);
|
||||
}
|
||||
}
|
||||
}
|
87
osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs
Normal file
87
osu.Game/Screens/Play/BreaksOverlay/InfoContainer.cs
Normal file
@ -0,0 +1,87 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Screens.Play.BreaksOverlay
|
||||
{
|
||||
public class InfoContainer : FillFlowContainer
|
||||
{
|
||||
public InfoContainer()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Alpha = 0;
|
||||
Direction = FillDirection.Vertical;
|
||||
Spacing = new Vector2(5);
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Text = @"current progress".ToUpper(),
|
||||
TextSize = 15,
|
||||
Font = "Exo2.0-Black",
|
||||
},
|
||||
new FillFlowContainer<InfoLine>
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new []
|
||||
{
|
||||
new InfoLine(@"Accuracy", @"-"),
|
||||
new InfoLine(@"Rank", @"-"),
|
||||
new InfoLine(@"Grade", @"-"),
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private class InfoLine : Container
|
||||
{
|
||||
private const int margin = 2;
|
||||
|
||||
private readonly OsuSpriteText text;
|
||||
private readonly OsuSpriteText valueText;
|
||||
|
||||
public InfoLine(string name, string value)
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
text = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.CentreRight,
|
||||
Text = name,
|
||||
TextSize = 17,
|
||||
Margin = new MarginPadding { Right = margin }
|
||||
},
|
||||
valueText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Text = value,
|
||||
TextSize = 17,
|
||||
Font = "Exo2.0-Bold",
|
||||
Margin = new MarginPadding { Left = margin }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
text.Colour = colours.Yellow;
|
||||
valueText.Colour = colours.YellowLight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs
Normal file
60
osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs
Normal file
@ -0,0 +1,60 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Framework.Graphics;
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Screens.Play.BreaksOverlay
|
||||
{
|
||||
public class RemainingTimeCounter : Container
|
||||
{
|
||||
private readonly OsuSpriteText counter;
|
||||
|
||||
private int? previousSecond;
|
||||
|
||||
private double remainingTime;
|
||||
|
||||
private bool isCounting;
|
||||
|
||||
public RemainingTimeCounter()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Alpha = 0;
|
||||
Child = counter = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
TextSize = 33,
|
||||
Font = "Venera",
|
||||
};
|
||||
}
|
||||
|
||||
public void StartCounting(double remainingTime)
|
||||
{
|
||||
this.remainingTime = remainingTime;
|
||||
isCounting = true;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (isCounting)
|
||||
{
|
||||
var currentTime = Clock.CurrentTime;
|
||||
if (currentTime < remainingTime)
|
||||
{
|
||||
int currentSecond = (int)Math.Floor((remainingTime - Clock.CurrentTime) / 1000.0) + 1;
|
||||
if (currentSecond != previousSecond)
|
||||
{
|
||||
counter.Text = currentSecond.ToString();
|
||||
previousSecond = currentSecond;
|
||||
}
|
||||
}
|
||||
else isCounting = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -24,6 +24,7 @@ using osu.Game.Screens.Ranking;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Screens.Play.BreaksOverlay;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Play.BreaksOverlay;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
@ -22,6 +22,8 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
AddStep("Add 2s break", () => startBreak(2000));
|
||||
AddStep("Add 5s break", () => startBreak(5000));
|
||||
AddStep("Add 10s break", () => startBreak(10000));
|
||||
AddStep("Add 15s break", () => startBreak(15000));
|
||||
AddStep("Add 2 breaks (2s each)", startMultipleBreaks);
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,9 @@
|
||||
<Compile Include="Beatmaps\Formats\OsuLegacyDecoder.cs" />
|
||||
<Compile Include="Beatmaps\IO\ArchiveReader.cs" />
|
||||
<Compile Include="Beatmaps\IO\LegacyFilesystemReader.cs" />
|
||||
<Compile Include="Screens\Play\BreakOverlay.cs" />
|
||||
<Compile Include="Screens\Play\BreaksOverlay\BreakOverlay.cs" />
|
||||
<Compile Include="Screens\Play\BreaksOverlay\InfoContainer.cs" />
|
||||
<Compile Include="Screens\Play\BreaksOverlay\RemainingTimeCounter.cs" />
|
||||
<Compile Include="Screens\Play\LetterboxOverlay.cs" />
|
||||
<Compile Include="Beatmaps\IO\OszArchiveReader.cs" />
|
||||
<Compile Include="Beatmaps\Legacy\LegacyBeatmap.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user