1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 15:07:44 +08:00

ModSelect -> ModSelectOverlay, + WaveOverlayContainer, + ModButton selected colours, made song select OnExit not handle closing mod select

This commit is contained in:
DrabWeb 2017-02-18 07:28:22 -04:00
parent 4ccfa380f5
commit 006fb5502d
12 changed files with 399 additions and 172 deletions

View File

@ -5,24 +5,28 @@ using osu.Framework.Graphics;
using osu.Game.Overlays.Mods;
using osu.Framework.GameModes.Testing;
using osu.Game.Modes;
using osu.Game.Graphics;
using osu.Framework.Allocation;
using osu.Game.Overlays;
namespace osu.Desktop.VisualTests.Tests
{
class TestCaseModSelect : TestCase
class TestCaseModSelectOverlay : TestCase
{
public override string Name => @"Mod Select";
public override string Description => @"Tests the mod select overlay";
private ModSelect modSelect;
private ModSelectOverlay modSelect;
private WaveOverlayContainer wave;
public override void Reset()
{
base.Reset();
Add(modSelect = new ModSelect
Add(modSelect = new ModSelectOverlay
{
RelativeSizeAxes = Axes.Both,
RelativeSizeAxes = Axes.X,
Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre,
ModMode = PlayMode.Osu,

View File

@ -191,7 +191,7 @@
<Compile Include="Platform\TestStorage.cs" />
<Compile Include="Tests\TestCaseOptions.cs" />
<Compile Include="Tests\TestCasePauseOverlay.cs" />
<Compile Include="Tests\TestCaseModSelect.cs" />
<Compile Include="Tests\TestCaseModSelectOverlay.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup />

View File

@ -215,7 +215,7 @@ namespace osu.Game.Modes
public override FontAwesome Icon => FontAwesome.fa_osu_mod_autopilot;
public override string Description(PlayMode mode) => @"Automatic cursor movement - just follow the rhythm.";
public override double ScoreMultiplier(PlayMode mode) => 0;
public override bool Ranked(PlayMode mode) => mode == PlayMode.Osu;
public override bool Ranked(PlayMode mode) => false;
}
public class ModPerfect : ModSuddenDeath

View File

@ -86,6 +86,7 @@ namespace osu.Game
private void load(OsuColour colours)
{
Colour = colours.Blue;
SelectedColour = colours.BlueLight;
}
public AssistedSection(PlayMode mode)

View File

@ -21,6 +21,7 @@ namespace osu.Game
private void load(OsuColour colours)
{
Colour = colours.Yellow;
SelectedColour = colours.YellowLight;
}
public DifficultyIncreaseSection()

View File

@ -19,6 +19,7 @@ namespace osu.Game
private void load(OsuColour colours)
{
Colour = colours.Green;
SelectedColour = colours.GreenLight;
}
public DifficultyReductionSection()

View File

@ -52,6 +52,12 @@ namespace osu.Game.Overlays.Mods
iconsContainer.RotateTo(Selected ? 5f : 0f, 300, EasingTypes.OutElastic);
iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, EasingTypes.OutElastic);
for (int i = 0; i < icons.Length; i++)
{
// TODO: Find out how to fade between colours here (FadeColour makes the colours look different)
if (Selected && i == icons.Length - 1) icons[i].Colour = SelectedColour;
else icons[i].Colour = Colour;
}
displaySelectedMod();
}
@ -74,8 +80,8 @@ namespace osu.Game.Overlays.Mods
}
set
{
if (value == backgroundColour) return;
backgroundColour = value;
foreach (ModIcon icon in icons)
{
icon.Colour = value;
@ -83,6 +89,21 @@ namespace osu.Game.Overlays.Mods
}
}
private Color4 selectedColour;
public Color4 SelectedColour
{
get
{
return selectedColour;
}
set
{
if (value == selectedColour) return;
selectedColour = value;
if (Selected) icons[0].Colour = value;
}
}
private Mod[] mods;
public Mod[] Mods
{
@ -92,6 +113,7 @@ namespace osu.Game.Overlays.Mods
}
set
{
if (mods == value) return;
mods = value;
createIcons();
if (value.Length > 0)

View File

@ -102,6 +102,25 @@ namespace osu.Game.Overlays.Mods
}
}
private Color4 selectedColour = Color4.White;
public Color4 SelectedColour
{
get
{
return selectedColour;
}
set
{
if (value == selectedColour) return;
selectedColour = value;
foreach (ModButton button in buttons)
{
button.SelectedColour = value;
}
}
}
private void buttonPressed(Mod mod)
{
Action?.Invoke(SelectedMods);

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
using System.Collections.Generic;
using OpenTK;
using OpenTK.Graphics;
@ -15,20 +14,14 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Sprites;
using osu.Game.Modes;
using System;
using osu.Framework.Allocation;
namespace osu.Game.Overlays.Mods
{
public class ModSelect : OverlayContainer
public class ModSelectOverlay : WaveOverlayContainer
{
private readonly int waves_duration = 1000;
private readonly int move_up_duration = 1500;
private readonly int move_up_delay = 200;
private readonly int move_out_duration = 500;
private readonly int button_duration = 1500;
private readonly int ranked_multiplier_duration = 2000;
private readonly int button_duration = 800; // 1000
private readonly int ranked_multiplier_duration = 800; // 1000
private readonly float content_width = 0.8f;
private Color4 low_multiplier_colour;
@ -42,9 +35,13 @@ namespace osu.Game.Overlays.Mods
private DifficultyReductionSection difficultyReductionSection;
private DifficultyIncreaseSection difficultyIncreaseSection;
private AssistedSection assistedSection;
private Container contentContainer;
private Container[] waves;
private ModSection[] sections
{
get
{
return new ModSection[] { difficultyReductionSection, difficultyIncreaseSection, assistedSection };
}
}
public Bindable<Mod[]> SelectedMods = new Bindable<Mod[]>();
@ -87,64 +84,35 @@ namespace osu.Game.Overlays.Mods
}
}
protected override void PopIn()
protected override void TransitionIn()
{
FadeIn(move_up_duration, EasingTypes.OutQuint);
rankedMultiplerContainer.MoveToX(0, ranked_multiplier_duration, EasingTypes.OutQuint);
rankedMultiplerContainer.FadeIn(ranked_multiplier_duration, EasingTypes.OutQuint);
Delay(move_up_delay);
Schedule(() =>
{
contentContainer.MoveToY(0, move_up_duration, EasingTypes.OutQuint);
rankedMultiplerContainer.MoveToX(0, ranked_multiplier_duration, EasingTypes.OutQuint);
rankedMultiplerContainer.FadeIn(ranked_multiplier_duration, EasingTypes.OutQuint);
ModSection[] sections = { difficultyReductionSection, difficultyIncreaseSection, assistedSection };
for (int i = 0; i < sections.Length; i++)
{
sections[i].ButtonsContainer.TransformSpacingTo(new Vector2(50f, 0f), button_duration, EasingTypes.OutQuint);
sections[i].ButtonsContainer.MoveToX(0, button_duration, EasingTypes.OutQuint);
sections[i].FadeIn(button_duration, EasingTypes.OutQuint);
}
});
for (int i = 0; i < waves.Length; i++)
foreach (ModSection section in sections)
{
waves[i].MoveToY(-200, waves_duration + ((i + 1) * 500), EasingTypes.OutQuint);
section.ButtonsContainer.TransformSpacingTo(new Vector2(50f, 0f), button_duration, EasingTypes.OutQuint);
section.ButtonsContainer.MoveToX(0, button_duration, EasingTypes.OutQuint);
section.ButtonsContainer.FadeIn(button_duration, EasingTypes.OutQuint);
}
}
protected override void PopOut()
protected override void TransitionOut()
{
FadeOut(move_out_duration, EasingTypes.InSine);
contentContainer.MoveToY(DrawHeight, move_out_duration, EasingTypes.InSine);
rankedMultiplerContainer.MoveToX(rankedMultiplerContainer.DrawSize.X, move_out_duration, EasingTypes.InSine);
rankedMultiplerContainer.FadeOut(move_out_duration, EasingTypes.InSine);
ModSection[] sections = { difficultyReductionSection, difficultyIncreaseSection, assistedSection };
for (int i = 0; i < sections.Length; i++)
{
sections[i].ButtonsContainer.TransformSpacingTo(new Vector2(100f, 0f), move_out_duration, EasingTypes.InSine);
sections[i].ButtonsContainer.MoveToX(100f, move_out_duration, EasingTypes.InSine);
sections[i].FadeIn(move_out_duration, EasingTypes.InSine);
}
for (int i = 0; i < waves.Length; i++)
{
waves[i].MoveToY(DrawHeight + 200);
rankedMultiplerContainer.MoveToX(rankedMultiplerContainer.DrawSize.X, close_duration, EasingTypes.InSine);
rankedMultiplerContainer.FadeOut(close_duration, EasingTypes.InSine);
foreach (ModSection section in sections)
{
section.ButtonsContainer.TransformSpacingTo(new Vector2(100f, 0f), close_duration, EasingTypes.InSine);
section.ButtonsContainer.MoveToX(100f, close_duration, EasingTypes.InSine);
section.ButtonsContainer.FadeTo(0.01f, close_duration, EasingTypes.InSine); // TODO: Fix this so 0.01 opacity isn't used
}
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
waves[0].Colour = colours.BlueLight;
waves[1].Colour = colours.Blue;
waves[2].Colour = colours.BlueDark;
waves[3].Colour = colours.BlueDarker;
low_multiplier_colour = colours.Red;
high_multiplier_colour = colours.Green;
}
@ -250,111 +218,50 @@ namespace osu.Game.Overlays.Mods
SelectedMods.Value = selectedMods.ToArray();
}
public ModSelect()
public ModSelectOverlay()
{
FirstWaveColour = OsuColour.FromHex(@"19b0e2");
SecondWaveColour = OsuColour.FromHex(@"2280a2");
ThirdWaveColour = OsuColour.FromHex(@"005774");
FourthWaveColour = OsuColour.FromHex(@"003a4e");
Height = 548; // TODO: Remove when autosize works
//AutoSizeAxes = Axes.Y;
//Content.RelativeSizeAxes = Axes.X;
//Content.AutoSizeAxes = Axes.Y;
Children = new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.Both,
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Masking = true,
Children = waves = new Container[]
Children = new Drawable[]
{
new Container
new Box
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Width = 1.5f,
Position = new Vector2(0f),
Rotation = -10f,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
},
},
Colour = new Color4(36, 50, 68, 255)
},
new Container
new Triangles
{
TriangleScale = 5,
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Width = 1.5f,
Position = new Vector2(0f, 50f),
Rotation = 8f,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
},
},
},
new Container
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Width = 1.5f,
Position = new Vector2(0f, 150f),
Rotation = -5f,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
},
},
},
new Container
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Width = 1.5f,
Position = new Vector2(0f, 300f),
Rotation = 2f,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
},
},
ColourLight = new Color4(53, 66, 82, 255),
ColourDark = new Color4(41, 54, 70, 255),
},
},
},
contentContainer = new Container
new FlowContainer
{
RelativeSizeAxes = Axes.Both,
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
Direction = FlowDirections.Vertical,
Spacing = new Vector2(0f, 10f),
Children = new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = new Color4(36, 50, 68, 255)
},
new Triangles
{
TriangleScale = 5,
RelativeSizeAxes = Axes.Both,
ColourLight = new Color4(53, 66, 82, 255),
ColourDark = new Color4(41, 54, 70, 255),
},
}
},
// Header
new Container
{
RelativeSizeAxes = Axes.X,
@ -410,6 +317,7 @@ namespace osu.Game.Overlays.Mods
},
},
},
// Body
modSectionsContainer = new FlowContainer
{
Origin = Anchor.TopCentre,
@ -418,10 +326,6 @@ namespace osu.Game.Overlays.Mods
AutoSizeAxes = Axes.Y,
Spacing = new Vector2(0f, 10f),
Width = content_width,
Margin = new MarginPadding
{
Top = 100,
},
Children = new Drawable[]
{
difficultyReductionSection = new DifficultyReductionSection
@ -447,16 +351,13 @@ namespace osu.Game.Overlays.Mods
},
},
},
// Footer
new Container
{
RelativeSizeAxes = Axes.X,
Height = 70,
Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre,
Margin = new MarginPadding
{
Bottom = 50,
},
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Children = new Drawable[]
{
new Box

View File

@ -0,0 +1,277 @@
// 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.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using OpenTK;
using osu.Framework.Graphics.Transformations;
namespace osu.Game.Overlays
{
public abstract class WaveOverlayContainer : OverlayContainer
{
private readonly float first_wave_position = -130;
private readonly float second_wave_position = 0;
private readonly float third_wave_position = 70;
private readonly float fourth_wave_position = 100;
private readonly float container_position = -150;
private float[] wave_positions
{
get
{
return new float[] { first_wave_position, second_wave_position, third_wave_position, fourth_wave_position };
}
}
private readonly float first_wave_duration = 700;
private readonly float second_wave_duration = 800;
private readonly float third_wave_duration = 900;
private readonly float fourth_wave_duration = 1000;
private readonly float container_wait = 300;
private readonly float container_duration = 500;
private readonly float content_duration = 800;
internal readonly float close_duration = 500;
private readonly float content_transition_wait = 150; // 100
private float [] wave_durations
{
get
{
return new float[] { first_wave_duration, second_wave_duration, third_wave_duration, fourth_wave_duration };
}
}
private readonly float first_wave_rotation = 13;
private readonly float second_wave_rotation = -7;
private readonly float third_wave_rotation = 4;
private readonly float fourth_wave_rotation = -2;
private Container firstWave, secondWave, thirdWave, fourthWave, wavesContainer;
private readonly Container[] waves;
private readonly Container contentContainer;
protected override Container<Drawable> Content => contentContainer;
private EdgeEffect waveShadow = new EdgeEffect
{
Type = EdgeEffectType.Shadow,
Colour = Color4.Black.Opacity(50),
Radius = 20f,
};
private Color4 firstWaveColour;
public Color4 FirstWaveColour
{
get
{
return firstWaveColour;
}
set
{
if (firstWaveColour == value) return;
firstWaveColour = value;
firstWave.Colour = value;
}
}
private Color4 secondWaveColour;
public Color4 SecondWaveColour
{
get
{
return secondWaveColour;
}
set
{
if (secondWaveColour == value) return;
secondWaveColour = value;
secondWave.Colour = value;
}
}
private Color4 thirdWaveColour;
public Color4 ThirdWaveColour
{
get
{
return thirdWaveColour;
}
set
{
if (thirdWaveColour == value) return;
thirdWaveColour = value;
thirdWave.Colour = value;
}
}
private Color4 fourthWaveColour;
public Color4 FourthWaveColour
{
get
{
return fourthWaveColour;
}
set
{
if (fourthWaveColour == value) return;
fourthWaveColour = value;
fourthWave.Colour = value;
}
}
protected override void PopIn()
{
base.Show();
FadeIn();
for (int i = 0; i < waves.Length; i++)
{
waves[i].MoveToY(wave_positions[i], wave_durations[i], EasingTypes.OutQuint);
}
DelayReset();
Delay(container_wait);
Schedule(() =>
{
if (State == Visibility.Visible)
{
wavesContainer.MoveToY(container_position, container_duration, EasingTypes.None);
contentContainer.FadeIn(content_duration, EasingTypes.OutQuint);
contentContainer.MoveToY(0, content_duration, EasingTypes.OutQuint);
Delay(content_transition_wait);
Schedule(() => { if (State == Visibility.Visible) TransitionIn(); });
}
});
}
protected abstract void TransitionIn();
protected override void PopOut()
{
FadeIn();
foreach (Container wave in waves)
{
wave.MoveToY(DrawHeight, close_duration, EasingTypes.InSine);
}
wavesContainer.MoveToY(0, close_duration, EasingTypes.InSine);
contentContainer.MoveToY(DrawHeight, close_duration, EasingTypes.InSine);
contentContainer.FadeOut(close_duration, EasingTypes.InSine);
TransitionOut();
DelayReset();
Delay(close_duration);
Schedule(() => { if (State == Visibility.Hidden) FadeOut(); });
}
protected abstract void TransitionOut();
public WaveOverlayContainer()
{
Masking = true;
AddInternal(wavesContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Children = new Drawable[]
{
firstWave = new Container
{
RelativeSizeAxes = Axes.Both,
Origin = Anchor.TopLeft,
Anchor = Anchor.TopLeft,
Size = new Vector2(1.5f),
Rotation = first_wave_rotation,
Colour = FirstWaveColour,
Masking = true,
EdgeEffect = waveShadow,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
},
},
},
secondWave = new Container
{
RelativeSizeAxes = Axes.Both,
Origin = Anchor.TopRight,
Anchor = Anchor.TopRight,
Size = new Vector2(1.5f),
Rotation = second_wave_rotation,
Colour = SecondWaveColour,
Masking = true,
EdgeEffect = waveShadow,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
},
},
},
thirdWave = new Container
{
RelativeSizeAxes = Axes.Both,
Origin = Anchor.TopLeft,
Anchor = Anchor.TopLeft,
Size = new Vector2(1.5f),
Rotation = third_wave_rotation,
Colour = ThirdWaveColour,
Masking = true,
EdgeEffect = waveShadow,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
},
},
},
fourthWave = new Container
{
RelativeSizeAxes = Axes.Both,
Origin = Anchor.TopRight,
Anchor = Anchor.TopRight,
Size = new Vector2(1.5f),
Rotation = fourth_wave_rotation,
Colour = FourthWaveColour,
Masking = true,
EdgeEffect = waveShadow,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
},
},
},
},
});
AddInternal(contentContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White.Opacity(50),
},
},
});
waves = new Container[] { firstWave, secondWave, thirdWave, fourthWave };
}
}
}

View File

@ -29,6 +29,7 @@ using OpenTK.Input;
using System.Collections.Generic;
using osu.Framework.Graphics.Containers;
using osu.Framework.Threading;
using osu.Game.Overlays.Mods;
namespace osu.Game.Screens.Select
{
@ -44,7 +45,7 @@ namespace osu.Game.Screens.Select
private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 225);
private BeatmapInfoWedge beatmapInfoWedge;
private Overlays.Mods.ModSelect modSelect;
private ModSelectOverlay modSelect;
private static readonly Vector2 background_blur = new Vector2(20);
private CancellationTokenSource initialAddSetsTask;
@ -134,11 +135,15 @@ namespace osu.Game.Screens.Select
Right = 20,
},
},
modSelect = new Overlays.Mods.ModSelect
modSelect = new ModSelectOverlay
{
RelativeSizeAxes = Axes.Both,
RelativeSizeAxes = Axes.X,
Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre,
Margin = new MarginPadding
{
Bottom = 50,
},
},
footer = new Footer()
{
@ -258,12 +263,6 @@ namespace osu.Game.Screens.Select
protected override bool OnExiting(GameMode next)
{
if (modSelect.State == Visibility.Visible)
{
modSelect.Hide();
return true;
}
beatmapInfoWedge.MoveToX(-100, 800, EasingTypes.InQuint);
beatmapInfoWedge.RotateTo(10, 800, EasingTypes.InQuint);
@ -286,6 +285,7 @@ namespace osu.Game.Screens.Select
private void playMode_ValueChanged(object sender, EventArgs e)
{
modSelect.ModMode = playMode;
}
private void changeBackground(WorkingBeatmap beatmap)

View File

@ -272,7 +272,7 @@
<Compile Include="Overlays\Pause\ResumeButton.cs" />
<Compile Include="Overlays\Pause\RetryButton.cs" />
<Compile Include="Overlays\Pause\QuitButton.cs" />
<Compile Include="Overlays\Mods\ModSelect.cs" />
<Compile Include="Overlays\Mods\ModSelectOverlay.cs" />
<Compile Include="Modes\Mod.cs" />
<Compile Include="Overlays\Mods\ModButton.cs" />
<Compile Include="Modes\UI\ModIcon.cs" />
@ -280,6 +280,7 @@
<Compile Include="Overlays\Mods\DifficultyReductionSection.cs" />
<Compile Include="Overlays\Mods\DifficultyIncreaseSection.cs" />
<Compile Include="Overlays\Mods\AssistedSection.cs" />
<Compile Include="Overlays\WaveOverlayContainer.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">