1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-07 19:22:58 +08:00

Remove a lot of constants (use object initialisers instead).

This commit is contained in:
Dean Herbert 2017-02-23 12:17:59 +09:00
parent aec5fa9d72
commit 8787b0dc90
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq; using System.Linq;
using osu.Framework;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Graphics; using osu.Game.Graphics;
@ -14,40 +15,14 @@ namespace osu.Game.Overlays
{ {
public abstract class WaveOverlayContainer : OverlayContainer public abstract class WaveOverlayContainer : OverlayContainer
{ {
private const float first_wave_position = -130;
private const float second_wave_position = 0;
private const float third_wave_position = 70;
private const float fourth_wave_position = 100;
private const float waves_container_position = -150;
private float[] wavePositions
{
get
{
return new float[] { first_wave_position, second_wave_position, third_wave_position, fourth_wave_position };
}
}
private const float first_wave_duration = 600;
private const float second_wave_duration = 700;
private const float third_wave_duration = 800;
private const float fourth_wave_duration = 900;
private const float container_wait = 200; private const float container_wait = 200;
private const float waves_container_duration = 400; private const float waves_container_duration = 400;
private const float content_duration = 700; private const float content_duration = 700;
private const float content_transition_wait = 100; private const float content_transition_wait = 100;
internal const float CONTENT_EXIT_DURATION = 600;
private float[] waveDurations
{
get
{
return new float[] { first_wave_duration, second_wave_duration, third_wave_duration, fourth_wave_duration };
}
}
private const float first_wave_rotation = 13; internal const float CONTENT_EXIT_DURATION = 600;
private const float second_wave_rotation = -7;
private const float third_wave_rotation = 4; private const float waves_container_position = -150;
private const float fourth_wave_rotation = -2;
private Wave firstWave, secondWave, thirdWave, fourthWave; private Wave firstWave, secondWave, thirdWave, fourthWave;
@ -56,76 +31,62 @@ namespace osu.Game.Overlays
private readonly Container contentContainer; private readonly Container contentContainer;
protected override Container<Drawable> Content => contentContainer; protected override Container<Drawable> Content => contentContainer;
private Color4 firstWaveColour;
public Color4 FirstWaveColour public Color4 FirstWaveColour
{ {
get get
{ {
return firstWaveColour; return firstWave.Colour;
} }
set set
{ {
if (firstWaveColour == value) return; if (firstWave.Colour == value) return;
firstWaveColour = value;
firstWave.Colour = value; firstWave.Colour = value;
} }
} }
private Color4 secondWaveColour;
public Color4 SecondWaveColour public Color4 SecondWaveColour
{ {
get get
{ {
return secondWaveColour; return secondWave.Colour;
} }
set set
{ {
if (secondWaveColour == value) return; if (secondWave.Colour == value) return;
secondWaveColour = value;
secondWave.Colour = value; secondWave.Colour = value;
} }
} }
private Color4 thirdWaveColour;
public Color4 ThirdWaveColour public Color4 ThirdWaveColour
{ {
get get
{ {
return thirdWaveColour; return thirdWave.Colour;
} }
set set
{ {
if (thirdWaveColour == value) return; if (thirdWave.Colour == value) return;
thirdWaveColour = value;
thirdWave.Colour = value; thirdWave.Colour = value;
} }
} }
private Color4 fourthWaveColour;
public Color4 FourthWaveColour public Color4 FourthWaveColour
{ {
get get
{ {
return fourthWaveColour; return fourthWave.Colour;
} }
set set
{ {
if (fourthWaveColour == value) return; if (fourthWave.Colour == value) return;
fourthWaveColour = value;
fourthWave.Colour = value; fourthWave.Colour = value;
} }
} }
protected override void PopIn() protected override void PopIn()
{ {
base.Show();
int i = 0;
foreach (var w in wavesContainer.Children) foreach (var w in wavesContainer.Children)
{ w.State = Visibility.Visible;
w.MoveToY(wavePositions[i], waveDurations[i], EasingTypes.OutQuint);
i++;
}
DelayReset(); DelayReset();
Delay(container_wait); Delay(container_wait);
@ -133,7 +94,7 @@ namespace osu.Game.Overlays
{ {
if (State == Visibility.Visible) if (State == Visibility.Visible)
{ {
wavesContainer.MoveToY(waves_container_position, waves_container_duration, EasingTypes.None); //wavesContainer.MoveToY(waves_container_position, waves_container_duration, EasingTypes.None);
contentContainer.FadeIn(content_duration, EasingTypes.OutQuint); contentContainer.FadeIn(content_duration, EasingTypes.OutQuint);
contentContainer.MoveToY(0, content_duration, EasingTypes.OutQuint); contentContainer.MoveToY(0, content_duration, EasingTypes.OutQuint);
@ -147,24 +108,16 @@ namespace osu.Game.Overlays
protected override void PopOut() protected override void PopOut()
{ {
base.Hide();
contentContainer.FadeOut(CONTENT_EXIT_DURATION, EasingTypes.InSine); contentContainer.FadeOut(CONTENT_EXIT_DURATION, EasingTypes.InSine);
contentContainer.MoveToY(DrawHeight, CONTENT_EXIT_DURATION, EasingTypes.InSine); contentContainer.MoveToY(DrawHeight, CONTENT_EXIT_DURATION, EasingTypes.InSine);
TransitionOut(); TransitionOut();
foreach (var w in wavesContainer.Children) foreach (var w in wavesContainer.Children)
w.MoveToY(DrawHeight, second_wave_duration, EasingTypes.InSine); w.State = Visibility.Hidden;
DelayReset(); DelayReset();
Delay(container_wait); Delay(container_wait);
Schedule(() => //wavesContainer.MoveToY(0, waves_container_duration);
{
if (State == Visibility.Hidden)
{
wavesContainer.MoveToY(0, waves_container_duration, EasingTypes.None);
}
});
} }
protected abstract void TransitionOut(); protected abstract void TransitionOut();
@ -173,37 +126,52 @@ namespace osu.Game.Overlays
{ {
Masking = true; Masking = true;
const int wave_count = 4;
const float total_duration = 800;
const float duration_change = 0;
float appearDuration = total_duration - wave_count * duration_change;
float disappearDuration = total_duration;
AddInternal(wavesContainer = new Container<Wave> AddInternal(wavesContainer = new Container<Wave>
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Children = new Wave[] Children = new[]
{ {
firstWave = new Wave firstWave = new Wave
{ {
Rotation = first_wave_rotation, Rotation = 13,
Colour = FirstWaveColour, FinalPosition = -830,
TransitionDurationAppear = (appearDuration += duration_change),
TransitionDurationDisappear = (disappearDuration -= duration_change),
}, },
secondWave = new Wave secondWave = new Wave
{ {
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Rotation = second_wave_rotation, Rotation = -7,
Colour = SecondWaveColour, FinalPosition = -460,
TransitionDurationAppear = (appearDuration += duration_change),
TransitionDurationDisappear = (disappearDuration -= duration_change),
}, },
thirdWave = new Wave thirdWave = new Wave
{ {
Rotation = third_wave_rotation, Rotation = 4,
Colour = ThirdWaveColour, FinalPosition = -290,
TransitionDurationAppear = (appearDuration += duration_change),
TransitionDurationDisappear = (disappearDuration -= duration_change),
}, },
fourthWave = new Wave fourthWave = new Wave
{ {
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Rotation = fourth_wave_rotation, Rotation = -2,
Colour = FourthWaveColour, FinalPosition = -120,
TransitionDurationAppear = (appearDuration += duration_change),
TransitionDurationDisappear = (disappearDuration -= duration_change),
}, },
}, },
}); });
@ -224,8 +192,12 @@ namespace osu.Game.Overlays
}); });
} }
class Wave : Container class Wave : Container, IStateful<Visibility>
{ {
public float FinalPosition;
public float TransitionDurationAppear;
public float TransitionDurationDisappear;
public Wave() public Wave()
{ {
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
@ -246,6 +218,27 @@ namespace osu.Game.Overlays
}, },
}; };
} }
private Visibility state;
public Visibility State
{
get { return state; }
set
{
if (value == state) return;
state = value;
switch (value)
{
case Visibility.Hidden:
MoveToY(DrawHeight / Height, TransitionDurationDisappear, EasingTypes.OutSine);
break;
case Visibility.Visible:
MoveToY(FinalPosition, TransitionDurationAppear, EasingTypes.Out);
break;
}
}
}
} }
} }
} }