mirror of
https://github.com/ppy/osu
synced 2025-03-23 03:16:53 +00:00
Merge branch 'master' into mania-barlines
This commit is contained in:
commit
a0c542f461
osu.Desktop.VisualTests
osu.Game.Rulesets.Mania
osu.Game
39
osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs
Normal file
39
osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// 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.Testing;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Desktop.VisualTests.Tests
|
||||||
|
{
|
||||||
|
internal class TestCaseBreadcrumbs : TestCase
|
||||||
|
{
|
||||||
|
public override string Description => @"breadcrumb > control";
|
||||||
|
|
||||||
|
public override void Reset()
|
||||||
|
{
|
||||||
|
base.Reset();
|
||||||
|
|
||||||
|
BreadcrumbControl<BreadcrumbTab> c;
|
||||||
|
Add(c = new BreadcrumbControl<BreadcrumbTab>
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Width = 0.5f,
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep(@"first", () => c.Current.Value = BreadcrumbTab.Click);
|
||||||
|
AddStep(@"second", () => c.Current.Value = BreadcrumbTab.The);
|
||||||
|
AddStep(@"third", () => c.Current.Value = BreadcrumbTab.Circles);
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum BreadcrumbTab
|
||||||
|
{
|
||||||
|
Click,
|
||||||
|
The,
|
||||||
|
Circles,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -223,6 +223,7 @@
|
|||||||
<Compile Include="Tests\TestCaseDrawableRoom.cs" />
|
<Compile Include="Tests\TestCaseDrawableRoom.cs" />
|
||||||
<Compile Include="Tests\TestCaseUserPanel.cs" />
|
<Compile Include="Tests\TestCaseUserPanel.cs" />
|
||||||
<Compile Include="Tests\TestCaseDirect.cs" />
|
<Compile Include="Tests\TestCaseDirect.cs" />
|
||||||
|
<Compile Include="Tests\TestCaseBreadcrumbs.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
|
@ -13,6 +13,7 @@ using osu.Game.Rulesets.Mania.MathUtils;
|
|||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy;
|
using osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Beatmaps
|
namespace osu.Game.Rulesets.Mania.Beatmaps
|
||||||
{
|
{
|
||||||
@ -161,9 +162,10 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
|||||||
pattern.Add(new HoldNote
|
pattern.Add(new HoldNote
|
||||||
{
|
{
|
||||||
StartTime = HitObject.StartTime,
|
StartTime = HitObject.StartTime,
|
||||||
Samples = HitObject.Samples,
|
|
||||||
Duration = endTimeData.Duration,
|
Duration = endTimeData.Duration,
|
||||||
Column = column,
|
Column = column,
|
||||||
|
Head = { Samples = sampleInfoListAt(HitObject.StartTime) },
|
||||||
|
Tail = { Samples = sampleInfoListAt(endTimeData.EndTime) },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (positionData != null)
|
else if (positionData != null)
|
||||||
@ -178,6 +180,24 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
|||||||
|
|
||||||
return pattern;
|
return pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the sample info list at a point in time.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="time">The time to retrieve the sample info list from.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private SampleInfoList sampleInfoListAt(double time)
|
||||||
|
{
|
||||||
|
var curveData = HitObject as IHasCurve;
|
||||||
|
|
||||||
|
if (curveData == null)
|
||||||
|
return HitObject.Samples;
|
||||||
|
|
||||||
|
double segmentTime = (curveData.EndTime - HitObject.StartTime) / curveData.RepeatCount;
|
||||||
|
|
||||||
|
int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime);
|
||||||
|
return curveData.RepeatSamples[index];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,9 @@ namespace osu.Game.Rulesets.Mania.Objects
|
|||||||
|
|
||||||
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
||||||
tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate;
|
tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate;
|
||||||
|
|
||||||
|
Head.ApplyDefaults(controlPointInfo, difficulty);
|
||||||
|
Tail.ApplyDefaults(controlPointInfo, difficulty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
84
osu.Game/Graphics/UserInterface/BreadcrumbControl.cs
Normal file
84
osu.Game/Graphics/UserInterface/BreadcrumbControl.cs
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
// 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;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace osu.Game.Graphics.UserInterface
|
||||||
|
{
|
||||||
|
public class BreadcrumbControl<T> : OsuTabControl<T>
|
||||||
|
{
|
||||||
|
private const float padding = 10;
|
||||||
|
|
||||||
|
protected override TabItem<T> CreateTabItem(T value) => new BreadcrumbTabItem(value);
|
||||||
|
|
||||||
|
public BreadcrumbControl()
|
||||||
|
{
|
||||||
|
Height = 26;
|
||||||
|
TabContainer.Spacing = new Vector2(padding, 0f);
|
||||||
|
Current.ValueChanged += tab =>
|
||||||
|
{
|
||||||
|
foreach (var t in TabContainer.Children.OfType<BreadcrumbTabItem>())
|
||||||
|
{
|
||||||
|
var tIndex = TabContainer.IndexOf(t);
|
||||||
|
var tabIndex = TabContainer.IndexOf(TabMap[tab]);
|
||||||
|
|
||||||
|
t.State = tIndex < tabIndex ? Visibility.Hidden : Visibility.Visible;
|
||||||
|
t.Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, EasingTypes.OutQuint);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private class BreadcrumbTabItem : OsuTabItem, IStateful<Visibility>
|
||||||
|
{
|
||||||
|
public readonly TextAwesome Chevron;
|
||||||
|
|
||||||
|
//don't allow clicking between transitions and don't make the chevron clickable
|
||||||
|
protected override bool InternalContains(Vector2 screenSpacePos) => Alpha == 1f && Text.Contains(screenSpacePos);
|
||||||
|
public override bool HandleInput => State == Visibility.Visible;
|
||||||
|
|
||||||
|
private Visibility state;
|
||||||
|
public Visibility State
|
||||||
|
{
|
||||||
|
get { return state; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == state) return;
|
||||||
|
state = value;
|
||||||
|
|
||||||
|
const float transition_duration = 500;
|
||||||
|
|
||||||
|
if (State == Visibility.Visible)
|
||||||
|
{
|
||||||
|
FadeIn(transition_duration, EasingTypes.OutQuint);
|
||||||
|
ScaleTo(new Vector2(1f), transition_duration, EasingTypes.OutQuint);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FadeOut(transition_duration, EasingTypes.OutQuint);
|
||||||
|
ScaleTo(new Vector2(0.8f, 1f), transition_duration, EasingTypes.OutQuint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BreadcrumbTabItem(T value) : base(value)
|
||||||
|
{
|
||||||
|
Text.TextSize = 16;
|
||||||
|
Padding = new MarginPadding { Right = padding + 8 }; //padding + chevron width
|
||||||
|
Add(Chevron = new TextAwesome
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreRight,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
TextSize = 12,
|
||||||
|
Icon = FontAwesome.fa_chevron_right,
|
||||||
|
Margin = new MarginPadding { Left = padding },
|
||||||
|
Alpha = 0f,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -27,6 +27,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
public class ModButton : ModButtonEmpty, IHasTooltip
|
public class ModButton : ModButtonEmpty, IHasTooltip
|
||||||
{
|
{
|
||||||
private ModIcon foregroundIcon;
|
private ModIcon foregroundIcon;
|
||||||
|
private ModIcon backgroundIcon;
|
||||||
private readonly SpriteText text;
|
private readonly SpriteText text;
|
||||||
private readonly Container<ModIcon> iconsContainer;
|
private readonly Container<ModIcon> iconsContainer;
|
||||||
private SampleChannel sampleOn, sampleOff;
|
private SampleChannel sampleOn, sampleOff;
|
||||||
@ -35,38 +36,67 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
public string TooltipText => (SelectedMod?.Description ?? Mods.FirstOrDefault()?.Description) ?? string.Empty;
|
public string TooltipText => (SelectedMod?.Description ?? Mods.FirstOrDefault()?.Description) ?? string.Empty;
|
||||||
|
|
||||||
private int _selectedIndex = -1;
|
private const EasingTypes mod_switch_easing = EasingTypes.InOutSine;
|
||||||
private int selectedIndex
|
private const double mod_switch_duration = 120;
|
||||||
|
|
||||||
|
// A selected index of -1 means not selected.
|
||||||
|
private int selectedIndex = -1;
|
||||||
|
|
||||||
|
protected int SelectedIndex
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _selectedIndex;
|
return selectedIndex;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value == _selectedIndex) return;
|
if (value == selectedIndex) return;
|
||||||
_selectedIndex = value;
|
|
||||||
|
int direction = value < selectedIndex ? -1 : 1;
|
||||||
|
bool beforeSelected = Selected;
|
||||||
|
|
||||||
|
Mod modBefore = SelectedMod ?? Mods[0];
|
||||||
|
|
||||||
if (value >= Mods.Length)
|
if (value >= Mods.Length)
|
||||||
{
|
selectedIndex = -1;
|
||||||
_selectedIndex = -1;
|
else if (value < -1)
|
||||||
}
|
selectedIndex = Mods.Length - 1;
|
||||||
else if (value <= -2)
|
else
|
||||||
{
|
selectedIndex = value;
|
||||||
_selectedIndex = Mods.Length - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Mod modAfter = SelectedMod ?? Mods[0];
|
||||||
|
|
||||||
|
if (beforeSelected != Selected)
|
||||||
|
{
|
||||||
iconsContainer.RotateTo(Selected ? 5f : 0f, 300, EasingTypes.OutElastic);
|
iconsContainer.RotateTo(Selected ? 5f : 0f, 300, EasingTypes.OutElastic);
|
||||||
iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, EasingTypes.OutElastic);
|
iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, EasingTypes.OutElastic);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modBefore != modAfter)
|
||||||
|
{
|
||||||
|
const float rotate_angle = 16;
|
||||||
|
|
||||||
|
foregroundIcon.RotateTo(rotate_angle * direction, mod_switch_duration, mod_switch_easing);
|
||||||
|
backgroundIcon.RotateTo(-rotate_angle * direction, mod_switch_duration, mod_switch_easing);
|
||||||
|
|
||||||
|
backgroundIcon.Icon = modAfter.Icon;
|
||||||
|
using (iconsContainer.BeginDelayedSequence(mod_switch_duration, true))
|
||||||
|
{
|
||||||
|
foregroundIcon.RotateTo(-rotate_angle * direction);
|
||||||
|
foregroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing);
|
||||||
|
|
||||||
|
backgroundIcon.RotateTo(rotate_angle * direction);
|
||||||
|
backgroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing);
|
||||||
|
|
||||||
|
iconsContainer.Schedule(() => displayMod(modAfter));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foregroundIcon.Highlighted = Selected;
|
foregroundIcon.Highlighted = Selected;
|
||||||
|
|
||||||
if (mod != null)
|
|
||||||
displayMod(SelectedMod ?? Mods[0]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Selected => selectedIndex != -1;
|
public bool Selected => SelectedIndex != -1;
|
||||||
|
|
||||||
|
|
||||||
private Color4 selectedColour;
|
private Color4 selectedColour;
|
||||||
public Color4 SelectedColour
|
public Color4 SelectedColour
|
||||||
@ -117,7 +147,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
// the mods from Mod, only multiple if Mod is a MultiMod
|
// the mods from Mod, only multiple if Mod is a MultiMod
|
||||||
|
|
||||||
public override Mod SelectedMod => Mods.ElementAtOrDefault(selectedIndex);
|
public override Mod SelectedMod => Mods.ElementAtOrDefault(SelectedIndex);
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audio)
|
private void load(AudioManager audio)
|
||||||
@ -142,23 +172,25 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
public void SelectNext()
|
public void SelectNext()
|
||||||
{
|
{
|
||||||
(++selectedIndex == -1 ? sampleOff : sampleOn).Play();
|
(++SelectedIndex == -1 ? sampleOff : sampleOn).Play();
|
||||||
Action?.Invoke(SelectedMod);
|
Action?.Invoke(SelectedMod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectPrevious()
|
public void SelectPrevious()
|
||||||
{
|
{
|
||||||
(--selectedIndex == -1 ? sampleOff : sampleOn).Play();
|
(--SelectedIndex == -1 ? sampleOff : sampleOn).Play();
|
||||||
Action?.Invoke(SelectedMod);
|
Action?.Invoke(SelectedMod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Deselect()
|
public void Deselect()
|
||||||
{
|
{
|
||||||
selectedIndex = -1;
|
SelectedIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayMod(Mod mod)
|
private void displayMod(Mod mod)
|
||||||
{
|
{
|
||||||
|
if (backgroundIcon != null)
|
||||||
|
backgroundIcon.Icon = foregroundIcon.Icon;
|
||||||
foregroundIcon.Icon = mod.Icon;
|
foregroundIcon.Icon = mod.Icon;
|
||||||
text.Text = mod.Name;
|
text.Text = mod.Name;
|
||||||
}
|
}
|
||||||
@ -170,17 +202,17 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
iconsContainer.Add(new[]
|
iconsContainer.Add(new[]
|
||||||
{
|
{
|
||||||
new ModIcon(Mods[0])
|
backgroundIcon = new ModIcon(Mods[1])
|
||||||
{
|
{
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.BottomRight,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.BottomRight,
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Position = new Vector2(1.5f),
|
Position = new Vector2(1.5f),
|
||||||
},
|
},
|
||||||
foregroundIcon = new ModIcon(Mods[0])
|
foregroundIcon = new ModIcon(Mods[0])
|
||||||
{
|
{
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.BottomRight,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.BottomRight,
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Position = new Vector2(-1.5f),
|
Position = new Vector2(-1.5f),
|
||||||
},
|
},
|
||||||
|
@ -451,6 +451,7 @@
|
|||||||
<Compile Include="Overlays\Direct\SlimEnumDropdown.cs" />
|
<Compile Include="Overlays\Direct\SlimEnumDropdown.cs" />
|
||||||
<Compile Include="Graphics\Containers\ReverseDepthFillFlowContainer.cs" />
|
<Compile Include="Graphics\Containers\ReverseDepthFillFlowContainer.cs" />
|
||||||
<Compile Include="Database\RankStatus.cs" />
|
<Compile Include="Database\RankStatus.cs" />
|
||||||
|
<Compile Include="Graphics\UserInterface\BreadcrumbControl.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">
|
<ProjectReference Include="..\osu-framework\osu.Framework\osu.Framework.csproj">
|
||||||
|
Loading…
Reference in New Issue
Block a user