mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 05:02:55 +08:00
Merge branch 'master' into api-error-shouldnt-retry
This commit is contained in:
commit
fb349e68a3
@ -1 +1 @@
|
||||
Subproject commit 71900dc350bcebbb60d912d4023a1d2a6bbbc3c1
|
||||
Subproject commit 6372fb22c1c85f600921a139849b8dedf71026d5
|
@ -101,7 +101,7 @@ namespace osu.Game.Rulesets.Catch
|
||||
|
||||
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap, Mod[] mods = null) => new CatchDifficultyCalculator(beatmap);
|
||||
|
||||
public override int LegacyID => 2;
|
||||
public override int? LegacyID => 2;
|
||||
|
||||
public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new CatchReplayFrame();
|
||||
|
||||
|
@ -114,7 +114,7 @@ namespace osu.Game.Rulesets.Mania
|
||||
|
||||
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap, Mod[] mods = null) => new ManiaDifficultyCalculator(beatmap);
|
||||
|
||||
public override int LegacyID => 3;
|
||||
public override int? LegacyID => 3;
|
||||
|
||||
public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new ManiaReplayFrame();
|
||||
|
||||
|
@ -145,7 +145,7 @@ namespace osu.Game.Rulesets.Osu
|
||||
|
||||
public override SettingsSubsection CreateSettings() => new OsuSettings();
|
||||
|
||||
public override int LegacyID => 0;
|
||||
public override int? LegacyID => 0;
|
||||
|
||||
public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new OsuReplayFrame();
|
||||
|
||||
|
@ -103,7 +103,7 @@ namespace osu.Game.Rulesets.Taiko
|
||||
|
||||
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap, Mod[] mods = null) => new TaikoDifficultyCalculator(beatmap);
|
||||
|
||||
public override int LegacyID => 1;
|
||||
public override int? LegacyID => 1;
|
||||
|
||||
public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new TaikoReplayFrame();
|
||||
|
||||
|
30
osu.Game.Tests/Visual/TestCaseVolumePieces.cs
Normal file
30
osu.Game.Tests/Visual/TestCaseVolumePieces.cs
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Overlays.Volume;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
public class TestCaseVolumePieces : OsuTestCase
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(VolumeMeter), typeof(MuteButton) };
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
VolumeMeter meter;
|
||||
MuteButton mute;
|
||||
Add(meter = new VolumeMeter("MASTER", 125, Color4.Blue));
|
||||
Add(mute = new MuteButton
|
||||
{
|
||||
Margin = new MarginPadding { Top = 200 }
|
||||
});
|
||||
|
||||
AddSliderStep("master volume", 0, 10, 0, i => meter.Bindable.Value = i * 0.1);
|
||||
AddToggleStep("mute", b => mute.Current.Value = b);
|
||||
}
|
||||
}
|
||||
}
|
@ -174,6 +174,7 @@
|
||||
<Compile Include="Visual\TestCaseUserPanel.cs" />
|
||||
<Compile Include="Visual\TestCaseUserProfile.cs" />
|
||||
<Compile Include="Visual\TestCaseUserRanks.cs" />
|
||||
<Compile Include="Visual\TestCaseVolumePieces.cs" />
|
||||
<Compile Include="Visual\TestCaseWaveform.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -1,8 +1,6 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
|
||||
@ -11,7 +9,5 @@ namespace osu.Game.Graphics.Containers
|
||||
public class ReverseChildIDFillFlowContainer<T> : FillFlowContainer<T> where T : Drawable
|
||||
{
|
||||
protected override int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y);
|
||||
|
||||
protected override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.Reverse();
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
public Action Exit;
|
||||
|
||||
public override bool HandleLeftRightArrows => false;
|
||||
|
||||
private bool focus;
|
||||
public bool HoldFocus
|
||||
{
|
||||
|
@ -9,6 +9,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
@ -56,6 +57,14 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
protected override TabFillFlowContainer CreateTabFlow() => new OsuTabFillFlowContainer
|
||||
{
|
||||
Direction = FillDirection.Full,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Depth = -1,
|
||||
Masking = true
|
||||
};
|
||||
|
||||
public class OsuTabItem : TabItem<T>, IHasAccentColour
|
||||
{
|
||||
protected readonly SpriteText Text;
|
||||
@ -239,5 +248,10 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class OsuTabFillFlowContainer : TabFillFlowContainer
|
||||
{
|
||||
protected override int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
protected virtual bool AllowCommit => false;
|
||||
|
||||
public override bool HandleLeftRightArrows => false;
|
||||
|
||||
public SearchTextBox()
|
||||
{
|
||||
Height = 35;
|
||||
|
@ -1,108 +0,0 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Input.Bindings;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface.Volume
|
||||
{
|
||||
public class VolumeMeter : Container, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
private readonly Box meterFill;
|
||||
public BindableDouble Bindable { get; } = new BindableDouble();
|
||||
|
||||
public VolumeMeter(string meterName)
|
||||
{
|
||||
Size = new Vector2(40, 180);
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = Color4.Black,
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = new Vector2(0.5f, 0.9f),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = Color4.DarkGray,
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
meterFill = new Box
|
||||
{
|
||||
Colour = Color4.White,
|
||||
Scale = new Vector2(1, 0),
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Anchor = Anchor.BottomCentre
|
||||
}
|
||||
}
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = meterName,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.TopCentre
|
||||
}
|
||||
};
|
||||
|
||||
Bindable.ValueChanged += delegate { updateFill(); };
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
updateFill();
|
||||
}
|
||||
|
||||
public double Volume
|
||||
{
|
||||
get => Bindable.Value;
|
||||
private set => Bindable.Value = value;
|
||||
}
|
||||
|
||||
public void Increase()
|
||||
{
|
||||
Volume += 0.05f;
|
||||
}
|
||||
|
||||
public void Decrease()
|
||||
{
|
||||
Volume -= 0.05f;
|
||||
}
|
||||
|
||||
private void updateFill() => meterFill.ScaleTo(new Vector2(1, (float)Volume), 300, Easing.OutQuint);
|
||||
|
||||
public bool OnPressed(GlobalAction action)
|
||||
{
|
||||
if (!IsHovered) return false;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case GlobalAction.DecreaseVolume:
|
||||
Decrease();
|
||||
return true;
|
||||
case GlobalAction.IncreaseVolume:
|
||||
Increase();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool OnReleased(GlobalAction action) => false;
|
||||
}
|
||||
}
|
@ -10,7 +10,6 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Graphics.UserInterface.Volume;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Overlays.Toolbar;
|
||||
using osu.Game.Screens;
|
||||
@ -33,6 +32,7 @@ using osu.Game.Input.Bindings;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Skinning;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Game.Overlays.Volume;
|
||||
|
||||
namespace osu.Game
|
||||
{
|
||||
@ -75,7 +75,7 @@ namespace osu.Game
|
||||
|
||||
private OsuScreen screenStack;
|
||||
|
||||
private VolumeControl volume;
|
||||
private VolumeOverlay volume;
|
||||
private OnScreenDisplay onscreenDisplay;
|
||||
|
||||
private Bindable<int> configRuleset;
|
||||
@ -232,7 +232,7 @@ namespace osu.Game
|
||||
},
|
||||
}, overlayContent.Add);
|
||||
|
||||
loadComponentSingleFile(volume = new VolumeControl(), Add);
|
||||
loadComponentSingleFile(volume = new VolumeOverlay(), overlayContent.Add);
|
||||
loadComponentSingleFile(onscreenDisplay = new OnScreenDisplay(), Add);
|
||||
|
||||
//overlay elements
|
||||
|
@ -53,9 +53,9 @@ namespace osu.Game.Overlays.Chat
|
||||
|
||||
protected override void AddTabItem(TabItem<Channel> item, bool addToDropdown = true)
|
||||
{
|
||||
if (selectorTab.Depth < float.MaxValue)
|
||||
if (item != selectorTab && TabContainer.GetLayoutPosition(selectorTab) < float.MaxValue)
|
||||
// performTabSort might've made selectorTab's position wonky, fix it
|
||||
TabContainer.ChangeChildDepth(selectorTab, float.MaxValue);
|
||||
TabContainer.SetLayoutPosition(selectorTab, float.MaxValue);
|
||||
|
||||
base.AddTabItem(item, addToDropdown);
|
||||
|
||||
|
@ -101,11 +101,10 @@ namespace osu.Game.Overlays.Music
|
||||
|
||||
public void AddBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
items.Add(new PlaylistItem(beatmapSet)
|
||||
{
|
||||
OnSelect = set => OnSelect?.Invoke(set),
|
||||
Depth = items.Count
|
||||
});
|
||||
var newItem = new PlaylistItem(beatmapSet) { OnSelect = set => OnSelect?.Invoke(set) };
|
||||
|
||||
items.Add(newItem);
|
||||
items.SetLayoutPosition(newItem, items.Count);
|
||||
}
|
||||
|
||||
public void RemoveBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||
@ -197,7 +196,7 @@ namespace osu.Game.Overlays.Music
|
||||
{
|
||||
var itemsPos = items.ToLocalSpace(nativeDragPosition);
|
||||
|
||||
int srcIndex = (int)draggedItem.Depth;
|
||||
int srcIndex = (int)items.GetLayoutPosition(draggedItem);
|
||||
|
||||
// Find the last item with position < mouse position. Note we can't directly use
|
||||
// the item positions as they are being transformed
|
||||
@ -219,15 +218,15 @@ namespace osu.Game.Overlays.Music
|
||||
if (srcIndex < dstIndex)
|
||||
{
|
||||
for (int i = srcIndex + 1; i <= dstIndex; i++)
|
||||
items.ChangeChildDepth(items[i], i - 1);
|
||||
items.SetLayoutPosition(items[i], i - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = dstIndex; i < srcIndex; i++)
|
||||
items.ChangeChildDepth(items[i], i + 1);
|
||||
items.SetLayoutPosition(items[i], i + 1);
|
||||
}
|
||||
|
||||
items.ChangeChildDepth(draggedItem, dstIndex);
|
||||
items.SetLayoutPosition(draggedItem, dstIndex);
|
||||
}
|
||||
|
||||
private class ItemSearchContainer : FillFlowContainer<PlaylistItem>, IHasFilterableChildren
|
||||
@ -243,9 +242,6 @@ namespace osu.Game.Overlays.Music
|
||||
}
|
||||
}
|
||||
|
||||
// Compare with reversed ChildID and Depth
|
||||
protected override int Compare(Drawable x, Drawable y) => base.Compare(y, x);
|
||||
|
||||
public IEnumerable<IFilterable> FilterableChildren => Children;
|
||||
|
||||
public ItemSearchContainer()
|
||||
|
@ -129,7 +129,6 @@ namespace osu.Game.Overlays
|
||||
public void Post(Notification notification) => postScheduler.Add(() =>
|
||||
{
|
||||
++runningDepth;
|
||||
notification.Depth = notification.DisplayOnTop ? runningDepth : -runningDepth;
|
||||
|
||||
notification.Closed += notificationClosed;
|
||||
|
||||
@ -138,7 +137,9 @@ namespace osu.Game.Overlays
|
||||
hasCompletionTarget.CompletionTarget = Post;
|
||||
|
||||
var ourType = notification.GetType();
|
||||
sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => accept.IsAssignableFrom(ourType)))?.Add(notification);
|
||||
|
||||
var section = sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => accept.IsAssignableFrom(ourType)));
|
||||
section?.Add(notification, notification.DisplayOnTop ? -runningDepth : runningDepth);
|
||||
|
||||
updateCounts();
|
||||
});
|
||||
|
@ -25,10 +25,13 @@ namespace osu.Game.Overlays.Notifications
|
||||
private FlowContainer<Notification> notifications;
|
||||
|
||||
public int DisplayedCount => notifications.Count(n => !n.WasClosed);
|
||||
|
||||
public int UnreadCount => notifications.Count(n => !n.WasClosed && !n.Read);
|
||||
|
||||
public void Add(Notification notification) => notifications.Add(notification);
|
||||
public void Add(Notification notification, float position)
|
||||
{
|
||||
notifications.Add(notification);
|
||||
notifications.SetLayoutPosition(notification, position);
|
||||
}
|
||||
|
||||
public IEnumerable<Type> AcceptTypes;
|
||||
|
||||
|
@ -40,16 +40,18 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuColour colour)
|
||||
{
|
||||
RightFlowContainer.Add(new OsuSpriteText
|
||||
var text = new OsuSpriteText
|
||||
{
|
||||
Text = $"accuracy: {Score.Accuracy:P2}",
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Colour = colour.GrayA,
|
||||
TextSize = 11,
|
||||
Font = "Exo2.0-RegularItalic",
|
||||
Depth = -1,
|
||||
});
|
||||
Font = "Exo2.0-RegularItalic"
|
||||
};
|
||||
|
||||
RightFlowContainer.Add(text);
|
||||
RightFlowContainer.SetLayoutPosition(text, 1);
|
||||
|
||||
LeftFlowContainer.Add(new BeatmapMetadataContainer(Score.Beatmap));
|
||||
LeftFlowContainer.Add(new OsuSpriteText
|
||||
|
@ -45,7 +45,8 @@ namespace osu.Game.Overlays.Settings
|
||||
if (text == null)
|
||||
{
|
||||
// construct lazily for cases where the label is not needed (may be provided by the Control).
|
||||
Add(text = new OsuSpriteText { Depth = 1 });
|
||||
Add(text = new OsuSpriteText());
|
||||
FlowContent.SetLayoutPosition(text, -1);
|
||||
}
|
||||
|
||||
text.Text = value;
|
||||
|
83
osu.Game/Overlays/Volume/MuteButton.cs
Normal file
83
osu.Game/Overlays/Volume/MuteButton.cs
Normal file
@ -0,0 +1,83 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Volume
|
||||
{
|
||||
public class MuteButton : Container, IHasCurrentValue<bool>
|
||||
{
|
||||
public Bindable<bool> Current { get; } = new Bindable<bool>();
|
||||
|
||||
private Color4 hoveredColour, unhoveredColour;
|
||||
private const float width = 100;
|
||||
public const float HEIGHT = 35;
|
||||
|
||||
public MuteButton()
|
||||
{
|
||||
Masking = true;
|
||||
BorderThickness = 3;
|
||||
CornerRadius = HEIGHT / 2;
|
||||
Size = new Vector2(width, HEIGHT);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
hoveredColour = colours.YellowDark;
|
||||
BorderColour = unhoveredColour = colours.Gray1.Opacity(0.9f);
|
||||
|
||||
SpriteIcon icon;
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.Gray1,
|
||||
Alpha = 0.9f,
|
||||
},
|
||||
icon = new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Size = new Vector2(20),
|
||||
}
|
||||
});
|
||||
|
||||
Current.ValueChanged += newValue =>
|
||||
{
|
||||
icon.Icon = newValue ? FontAwesome.fa_volume_off : FontAwesome.fa_volume_up;
|
||||
icon.Margin = new MarginPadding { Left = newValue ? width / 2 - 15 : width / 2 - 10 }; //Magic numbers to line up both icons because they're different widths
|
||||
};
|
||||
Current.TriggerChange();
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
this.TransformTo<MuteButton, SRGBColour>("BorderColour", hoveredColour, 500, Easing.OutQuint);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
this.TransformTo<MuteButton, SRGBColour>("BorderColour", unhoveredColour, 500, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
Current.Value = !Current.Value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ using osu.Framework.Input;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Input.Bindings;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface.Volume
|
||||
namespace osu.Game.Overlays.Volume
|
||||
{
|
||||
public class VolumeControlReceptor : Container, IKeyBindingHandler<GlobalAction>, IHandleGlobalInput
|
||||
{
|
186
osu.Game/Overlays/Volume/VolumeMeter.cs
Normal file
186
osu.Game/Overlays/Volume/VolumeMeter.cs
Normal file
@ -0,0 +1,186 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Input.Bindings;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Volume
|
||||
{
|
||||
public class VolumeMeter : Container, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
private CircularProgress volumeCircle;
|
||||
public BindableDouble Bindable { get; } = new BindableDouble { MinValue = 0, MaxValue = 1 };
|
||||
private readonly float circleSize;
|
||||
private readonly Color4 meterColour;
|
||||
private readonly string name;
|
||||
|
||||
private OsuSpriteText text;
|
||||
private BufferedContainer maxGlow;
|
||||
|
||||
public VolumeMeter(string name, float circleSize, Color4 meterColour)
|
||||
{
|
||||
this.circleSize = circleSize;
|
||||
this.meterColour = meterColour;
|
||||
this.name = name;
|
||||
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Add(new Container
|
||||
{
|
||||
Size = new Vector2(120, 20),
|
||||
CornerRadius = 10,
|
||||
Masking = true,
|
||||
Margin = new MarginPadding { Left = circleSize + 10 },
|
||||
Origin = Anchor.CentreLeft,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.Gray1,
|
||||
Alpha = 0.9f,
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = "Exo2.0-Bold",
|
||||
Text = name
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
CircularProgress bgProgress;
|
||||
|
||||
Add(new CircularContainer
|
||||
{
|
||||
Masking = true,
|
||||
Size = new Vector2(circleSize),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colours.Gray1,
|
||||
Alpha = 0.9f,
|
||||
},
|
||||
bgProgress = new CircularProgress
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
InnerRadius = 0.05f,
|
||||
Rotation = 180,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Colour = colours.Gray2,
|
||||
Size = new Vector2(0.8f)
|
||||
},
|
||||
(volumeCircle = new CircularProgress
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
InnerRadius = 0.05f,
|
||||
Rotation = 180,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(0.8f)
|
||||
}).WithEffect(new GlowEffect
|
||||
{
|
||||
Colour = meterColour,
|
||||
Strength = 2
|
||||
}),
|
||||
maxGlow = (text = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Font = "Venera",
|
||||
TextSize = 0.16f * circleSize
|
||||
}).WithEffect(new GlowEffect
|
||||
{
|
||||
Colour = Color4.Transparent,
|
||||
PadExtent = true,
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
Bindable.ValueChanged += newVolume => { this.TransformTo("DisplayVolume", newVolume, 400, Easing.OutQuint); };
|
||||
bgProgress.Current.Value = 0.75f;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
Bindable.TriggerChange();
|
||||
}
|
||||
|
||||
private double displayVolume;
|
||||
|
||||
protected double DisplayVolume
|
||||
{
|
||||
get => displayVolume;
|
||||
set
|
||||
{
|
||||
displayVolume = value;
|
||||
|
||||
if (displayVolume > 0.99f)
|
||||
{
|
||||
text.Text = "MAX";
|
||||
maxGlow.EffectColour = meterColour.Opacity(2f);
|
||||
}
|
||||
else
|
||||
{
|
||||
maxGlow.EffectColour = Color4.Transparent;
|
||||
text.Text = Math.Round(displayVolume * 100).ToString(CultureInfo.CurrentCulture);
|
||||
}
|
||||
|
||||
volumeCircle.Current.Value = displayVolume * 0.75f;
|
||||
}
|
||||
}
|
||||
|
||||
public double Volume
|
||||
{
|
||||
get => Bindable;
|
||||
private set => Bindable.Value = value;
|
||||
}
|
||||
|
||||
public void Increase() => Volume += 0.05f;
|
||||
|
||||
public void Decrease() => Volume -= 0.05f;
|
||||
|
||||
public bool OnPressed(GlobalAction action)
|
||||
{
|
||||
if (!IsHovered) return false;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case GlobalAction.DecreaseVolume:
|
||||
Decrease();
|
||||
return true;
|
||||
case GlobalAction.IncreaseVolume:
|
||||
Increase();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool OnReleased(GlobalAction action) => false;
|
||||
}
|
||||
}
|
@ -1,57 +1,84 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Threading;
|
||||
using OpenTK;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Overlays.Volume;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface.Volume
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
public class VolumeControl : OverlayContainer
|
||||
public class VolumeOverlay : OverlayContainer
|
||||
{
|
||||
private readonly VolumeMeter volumeMeterMaster;
|
||||
private readonly IconButton muteIcon;
|
||||
private const float offset = 10;
|
||||
|
||||
private VolumeMeter volumeMeterMaster;
|
||||
private VolumeMeter volumeMeterEffect;
|
||||
private VolumeMeter volumeMeterMusic;
|
||||
private MuteButton muteButton;
|
||||
|
||||
protected override bool BlockPassThroughMouse => false;
|
||||
|
||||
public VolumeControl()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Anchor = Anchor.BottomRight;
|
||||
Origin = Anchor.BottomRight;
|
||||
private readonly BindableDouble muteAdjustment = new BindableDouble();
|
||||
|
||||
Children = new Drawable[]
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio, OsuColour colours)
|
||||
{
|
||||
AutoSizeAxes = Axes.X;
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 300,
|
||||
Colour = ColourInfo.GradientHorizontal(Color4.Black.Opacity(0.75f), Color4.Black.Opacity(0))
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
Direction = FillDirection.Vertical,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Margin = new MarginPadding { Left = 10, Right = 10, Top = 30, Bottom = 30 },
|
||||
Spacing = new Vector2(15, 0),
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Spacing = new Vector2(0, offset),
|
||||
Margin = new MarginPadding { Left = offset },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
volumeMeterEffect = new VolumeMeter("EFFECTS", 125, colours.BlueDarker)
|
||||
{
|
||||
Size = new Vector2(IconButton.BUTTON_SIZE),
|
||||
Child = muteIcon = new IconButton
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Icon = FontAwesome.fa_volume_up,
|
||||
Action = () => Adjust(GlobalAction.ToggleMute),
|
||||
}
|
||||
Margin = new MarginPadding { Top = 100 + MuteButton.HEIGHT } //to counter the mute button and re-center the volume meters
|
||||
},
|
||||
volumeMeterMaster = new VolumeMeter("Master"),
|
||||
volumeMeterEffect = new VolumeMeter("Effects"),
|
||||
volumeMeterMusic = new VolumeMeter("Music")
|
||||
volumeMeterMaster = new VolumeMeter("MASTER", 150, colours.PinkDarker),
|
||||
volumeMeterMusic = new VolumeMeter("MUSIC", 125, colours.BlueDarker),
|
||||
muteButton = new MuteButton
|
||||
{
|
||||
Margin = new MarginPadding { Top = 100 }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
volumeMeterMaster.Bindable.BindTo(audio.Volume);
|
||||
volumeMeterEffect.Bindable.BindTo(audio.VolumeSample);
|
||||
volumeMeterMusic.Bindable.BindTo(audio.VolumeTrack);
|
||||
|
||||
muteButton.Current.ValueChanged += mute =>
|
||||
{
|
||||
if (mute)
|
||||
audio.AddAdjustment(AdjustableProperty.Volume, muteAdjustment);
|
||||
else
|
||||
audio.RemoveAdjustment(AdjustableProperty.Volume, muteAdjustment);
|
||||
};
|
||||
}
|
||||
|
||||
@ -62,7 +89,13 @@ namespace osu.Game.Graphics.UserInterface.Volume
|
||||
volumeMeterMaster.Bindable.ValueChanged += _ => settingChanged();
|
||||
volumeMeterEffect.Bindable.ValueChanged += _ => settingChanged();
|
||||
volumeMeterMusic.Bindable.ValueChanged += _ => settingChanged();
|
||||
muted.ValueChanged += _ => settingChanged();
|
||||
muteButton.Current.ValueChanged += _ => settingChanged();
|
||||
}
|
||||
|
||||
private void settingChanged()
|
||||
{
|
||||
Show();
|
||||
schedulePopOut();
|
||||
}
|
||||
|
||||
public bool Adjust(GlobalAction action)
|
||||
@ -83,50 +116,15 @@ namespace osu.Game.Graphics.UserInterface.Volume
|
||||
return true;
|
||||
case GlobalAction.ToggleMute:
|
||||
Show();
|
||||
muted.Toggle();
|
||||
muteButton.Current.Value = !muteButton.Current;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void settingChanged()
|
||||
{
|
||||
Show();
|
||||
schedulePopOut();
|
||||
}
|
||||
|
||||
private readonly BindableDouble muteAdjustment = new BindableDouble();
|
||||
|
||||
private readonly BindableBool muted = new BindableBool();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
volumeMeterMaster.Bindable.BindTo(audio.Volume);
|
||||
volumeMeterEffect.Bindable.BindTo(audio.VolumeSample);
|
||||
volumeMeterMusic.Bindable.BindTo(audio.VolumeTrack);
|
||||
|
||||
muted.ValueChanged += mute =>
|
||||
{
|
||||
if (mute)
|
||||
{
|
||||
audio.AddAdjustment(AdjustableProperty.Volume, muteAdjustment);
|
||||
muteIcon.Icon = FontAwesome.fa_volume_off;
|
||||
}
|
||||
else
|
||||
{
|
||||
audio.RemoveAdjustment(AdjustableProperty.Volume, muteAdjustment);
|
||||
muteIcon.Icon = FontAwesome.fa_volume_up;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private ScheduledDelegate popOutDelegate;
|
||||
|
||||
private readonly VolumeMeter volumeMeterEffect;
|
||||
private readonly VolumeMeter volumeMeterMusic;
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
ClearTransforms();
|
@ -64,7 +64,7 @@ namespace osu.Game.Rulesets
|
||||
/// <summary>
|
||||
/// Do not override this unless you are a legacy mode.
|
||||
/// </summary>
|
||||
public virtual int LegacyID => -1;
|
||||
public virtual int? LegacyID => null;
|
||||
|
||||
/// <summary>
|
||||
/// A unique short name to reference this ruleset in online requests.
|
||||
|
@ -4,8 +4,6 @@
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using OpenTK;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Screens.Menu
|
||||
{
|
||||
@ -22,8 +20,6 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
protected override int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y);
|
||||
|
||||
protected override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.Reverse();
|
||||
|
||||
public override Anchor Origin => Anchor.Custom;
|
||||
|
||||
public override Vector2 OriginPosition
|
||||
|
@ -41,19 +41,25 @@ namespace osu.Game.Screens.Select
|
||||
/// <para>Higher depth to be put on the left, and lower to be put on the right.</para>
|
||||
/// <para>Notice this is different to <see cref="Options.BeatmapOptionsOverlay"/>!</para>
|
||||
/// </param>
|
||||
public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0) => buttons.Add(new FooterButton
|
||||
public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0)
|
||||
{
|
||||
Text = text,
|
||||
Height = play_song_select_button_height,
|
||||
Width = play_song_select_button_width,
|
||||
Depth = depth,
|
||||
SelectedColour = colour,
|
||||
DeselectedColour = colour.Opacity(0.5f),
|
||||
Hotkey = hotkey,
|
||||
Hovered = updateModeLight,
|
||||
HoverLost = updateModeLight,
|
||||
Action = action,
|
||||
});
|
||||
var button = new FooterButton
|
||||
{
|
||||
Text = text,
|
||||
Height = play_song_select_button_height,
|
||||
Width = play_song_select_button_width,
|
||||
Depth = depth,
|
||||
SelectedColour = colour,
|
||||
DeselectedColour = colour.Opacity(0.5f),
|
||||
Hotkey = hotkey,
|
||||
Hovered = updateModeLight,
|
||||
HoverLost = updateModeLight,
|
||||
Action = action,
|
||||
};
|
||||
|
||||
buttons.Add(button);
|
||||
buttons.SetLayoutPosition(button, -depth);
|
||||
}
|
||||
|
||||
private readonly List<OverlayContainer> overlays = new List<OverlayContainer>();
|
||||
|
||||
|
@ -95,7 +95,7 @@ namespace osu.Game.Screens.Select.Options
|
||||
/// </param>
|
||||
public void AddButton(string firstLine, string secondLine, FontAwesome icon, Color4 colour, Action action, Key? hotkey = null, float depth = 0)
|
||||
{
|
||||
buttonsContainer.Add(new BeatmapOptionsButton
|
||||
var button = new BeatmapOptionsButton
|
||||
{
|
||||
FirstLineText = firstLine,
|
||||
SecondLineText = secondLine,
|
||||
@ -108,7 +108,10 @@ namespace osu.Game.Screens.Select.Options
|
||||
action?.Invoke();
|
||||
},
|
||||
HotKey = hotkey
|
||||
});
|
||||
};
|
||||
|
||||
buttonsContainer.Add(button);
|
||||
buttonsContainer.SetLayoutPosition(button, depth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -351,6 +351,10 @@
|
||||
<Compile Include="Overlays\Profile\Sections\Ranks\ScoreModsContainer.cs" />
|
||||
<Compile Include="Overlays\Settings\Sections\Gameplay\ScrollingSettings.cs" />
|
||||
<Compile Include="Overlays\Settings\Sections\Maintenance\DeleteAllBeatmapsDialog.cs" />
|
||||
<Compile Include="Overlays\VolumeOverlay.cs" />
|
||||
<Compile Include="Overlays\Volume\MuteButton.cs" />
|
||||
<Compile Include="Overlays\Volume\VolumeControlReceptor.cs" />
|
||||
<Compile Include="Overlays\Volume\VolumeMeter.cs" />
|
||||
<Compile Include="Rulesets\Configuration\IRulesetConfigManager.cs" />
|
||||
<Compile Include="Rulesets\Configuration\RulesetConfigManager.cs" />
|
||||
<Compile Include="Rulesets\Edit\Layers\BorderLayer.cs" />
|
||||
@ -474,9 +478,6 @@
|
||||
<Compile Include="Graphics\UserInterface\SimpleComboCounter.cs" />
|
||||
<Compile Include="Graphics\UserInterface\StarCounter.cs" />
|
||||
<Compile Include="Graphics\UserInterface\TwoLayerButton.cs" />
|
||||
<Compile Include="Graphics\UserInterface\Volume\VolumeControl.cs" />
|
||||
<Compile Include="Graphics\UserInterface\Volume\VolumeControlReceptor.cs" />
|
||||
<Compile Include="Graphics\UserInterface\Volume\VolumeMeter.cs" />
|
||||
<Compile Include="Input\Bindings\DatabasedKeyBinding.cs" />
|
||||
<Compile Include="Input\Bindings\DatabasedKeyBindingContainer.cs" />
|
||||
<Compile Include="Input\Bindings\GlobalActionContainer.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user