mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 10:45:36 +08:00
Compare commits
12 Commits
513bfc1cbc
...
101f207040
Author | SHA1 | Date | |
---|---|---|---|
|
101f207040 | ||
|
3ef490689e | ||
|
69b4713731 | ||
|
23068034b1 | ||
|
df4de4a090 | ||
|
5dff7f0955 | ||
|
3c8ccf3c7d | ||
|
377ae3e685 | ||
|
8fdf859375 | ||
|
f9aa6b9c07 | ||
|
a8c31c31ad | ||
|
d92e93ed31 |
@ -13,17 +13,17 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ExpandingBar : Circle
|
public class ExpandingBar : Circle
|
||||||
{
|
{
|
||||||
private bool isCollapsed;
|
private bool expanded = true;
|
||||||
|
|
||||||
public bool IsCollapsed
|
public bool Expanded
|
||||||
{
|
{
|
||||||
get => isCollapsed;
|
get => expanded;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value == isCollapsed)
|
if (value == expanded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
isCollapsed = value;
|
expanded = value;
|
||||||
updateState();
|
updateState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,19 +83,21 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
updateState();
|
updateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Collapse() => IsCollapsed = true;
|
public void Collapse() => Expanded = false;
|
||||||
|
|
||||||
public void Expand() => IsCollapsed = false;
|
public void Expand() => Expanded = true;
|
||||||
|
|
||||||
private void updateState()
|
private void updateState()
|
||||||
{
|
{
|
||||||
float newSize = IsCollapsed ? CollapsedSize : ExpandedSize;
|
float newSize = expanded ? ExpandedSize : CollapsedSize;
|
||||||
Easing easingType = IsCollapsed ? Easing.Out : Easing.OutElastic;
|
Easing easingType = expanded ? Easing.OutElastic : Easing.Out;
|
||||||
|
|
||||||
if (RelativeSizeAxes == Axes.X)
|
if (RelativeSizeAxes == Axes.X)
|
||||||
this.ResizeHeightTo(newSize, 400, easingType);
|
this.ResizeHeightTo(newSize, 400, easingType);
|
||||||
else
|
else
|
||||||
this.ResizeWidthTo(newSize, 400, easingType);
|
this.ResizeWidthTo(newSize, 400, easingType);
|
||||||
|
|
||||||
|
this.FadeTo(expanded ? 1 : 0.5f, 100, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
|
||||||
@ -22,6 +24,8 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
|
|
||||||
private const string listing_string = "listing";
|
private const string listing_string = "listing";
|
||||||
|
|
||||||
|
private Box streamsBackground;
|
||||||
|
|
||||||
public ChangelogHeader()
|
public ChangelogHeader()
|
||||||
{
|
{
|
||||||
TabControl.AddItem(listing_string);
|
TabControl.AddItem(listing_string);
|
||||||
@ -40,6 +44,12 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OverlayColourProvider colourProvider)
|
||||||
|
{
|
||||||
|
streamsBackground.Colour = colourProvider.Background5;
|
||||||
|
}
|
||||||
|
|
||||||
private ChangelogHeaderTitle title;
|
private ChangelogHeaderTitle title;
|
||||||
|
|
||||||
private void showBuild(ValueChangedEvent<APIChangelogBuild> e)
|
private void showBuild(ValueChangedEvent<APIChangelogBuild> e)
|
||||||
@ -72,7 +82,21 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
Streams = new UpdateStreamBadgeArea(),
|
streamsBackground = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Padding = new MarginPadding
|
||||||
|
{
|
||||||
|
Horizontal = 65,
|
||||||
|
Vertical = 20
|
||||||
|
},
|
||||||
|
Child = Streams = new UpdateStreamBadgeArea()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
|
|
||||||
private readonly APIUpdateStream stream;
|
private readonly APIUpdateStream stream;
|
||||||
|
|
||||||
private Container fadeContainer;
|
|
||||||
private FillFlowContainer<SpriteText> text;
|
private FillFlowContainer<SpriteText> text;
|
||||||
private ExpandingBar expandingBar;
|
private ExpandingBar expandingBar;
|
||||||
|
|
||||||
@ -44,47 +43,39 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
|
|
||||||
AddRange(new Drawable[]
|
AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
fadeContainer = new Container
|
text = new FillFlowContainer<SpriteText>
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Direction = FillDirection.Vertical,
|
||||||
|
Margin = new MarginPadding { Top = 6 },
|
||||||
|
Children = new[]
|
||||||
{
|
{
|
||||||
text = new FillFlowContainer<SpriteText>
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.X,
|
Text = stream.DisplayName,
|
||||||
RelativeSizeAxes = Axes.Y,
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Black),
|
||||||
Direction = FillDirection.Vertical,
|
|
||||||
Margin = new MarginPadding { Top = 6 },
|
|
||||||
Children = new[]
|
|
||||||
{
|
|
||||||
new OsuSpriteText
|
|
||||||
{
|
|
||||||
Text = stream.DisplayName,
|
|
||||||
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Black),
|
|
||||||
},
|
|
||||||
new OsuSpriteText
|
|
||||||
{
|
|
||||||
Text = stream.LatestBuild.DisplayVersion,
|
|
||||||
Font = OsuFont.GetFont(size: 16, weight: FontWeight.Regular),
|
|
||||||
},
|
|
||||||
new OsuSpriteText
|
|
||||||
{
|
|
||||||
Text = stream.LatestBuild.Users > 0 ? $"{"user".ToQuantity(stream.LatestBuild.Users, "N0")} online" : null,
|
|
||||||
Font = OsuFont.GetFont(size: 10),
|
|
||||||
Colour = colourProvider.Foreground1
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
expandingBar = new ExpandingBar
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
Text = stream.LatestBuild.DisplayVersion,
|
||||||
Colour = stream.Colour,
|
Font = OsuFont.GetFont(size: 16, weight: FontWeight.Regular),
|
||||||
ExpandedSize = 4,
|
},
|
||||||
CollapsedSize = 2,
|
new OsuSpriteText
|
||||||
IsCollapsed = true
|
{
|
||||||
|
Text = stream.LatestBuild.Users > 0 ? $"{"user".ToQuantity(stream.LatestBuild.Users, "N0")} online" : null,
|
||||||
|
Font = OsuFont.GetFont(size: 10),
|
||||||
|
Colour = colourProvider.Foreground1
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
expandingBar = new ExpandingBar
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Colour = stream.Colour,
|
||||||
|
ExpandedSize = 4,
|
||||||
|
CollapsedSize = 2,
|
||||||
|
Expanded = true
|
||||||
|
},
|
||||||
new HoverClickSounds()
|
new HoverClickSounds()
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -109,38 +100,41 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
|
|
||||||
private void updateState()
|
private void updateState()
|
||||||
{
|
{
|
||||||
// Expand based on the local state
|
// highlighted regardless if we are hovered
|
||||||
bool shouldExpand = Active.Value || IsHovered;
|
bool textHighlighted = IsHovered;
|
||||||
|
bool barExpanded = IsHovered;
|
||||||
|
|
||||||
// Expand based on whether no build is selected and the badge area is hovered
|
if (SelectedTab.Value == null)
|
||||||
shouldExpand |= SelectedTab.Value == null && !externalDimRequested;
|
|
||||||
|
|
||||||
if (shouldExpand)
|
|
||||||
{
|
{
|
||||||
expandingBar.Expand();
|
// at listing, all badges are highlighted when user is not hovering any badge.
|
||||||
fadeContainer.FadeTo(1, transition_duration);
|
textHighlighted |= !userHoveringArea;
|
||||||
|
barExpanded |= !userHoveringArea;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
expandingBar.Collapse();
|
// bar is always expanded when active
|
||||||
fadeContainer.FadeTo(0.5f, transition_duration);
|
barExpanded |= Active.Value;
|
||||||
|
|
||||||
|
// text is highlighted only when hovered or active (but not if in selection mode)
|
||||||
|
textHighlighted |= Active.Value && !userHoveringArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
text.FadeTo(externalDimRequested && !IsHovered ? 0.5f : 1, transition_duration);
|
expandingBar.Expanded = barExpanded;
|
||||||
|
text.FadeTo(textHighlighted ? 1 : 0.5f, transition_duration, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool externalDimRequested;
|
private bool userHoveringArea;
|
||||||
|
|
||||||
public void EnableDim()
|
public bool UserHoveringArea
|
||||||
{
|
{
|
||||||
externalDimRequested = true;
|
set
|
||||||
updateState();
|
{
|
||||||
}
|
if (value == userHoveringArea)
|
||||||
|
return;
|
||||||
|
|
||||||
public void DisableDim()
|
userHoveringArea = value;
|
||||||
{
|
updateState();
|
||||||
externalDimRequested = false;
|
}
|
||||||
updateState();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,25 +6,16 @@ using osu.Framework.Input.Events;
|
|||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Changelog
|
namespace osu.Game.Overlays.Changelog
|
||||||
{
|
{
|
||||||
public class UpdateStreamBadgeArea : TabControl<APIUpdateStream>
|
public class UpdateStreamBadgeArea : TabControl<APIUpdateStream>
|
||||||
{
|
{
|
||||||
[BackgroundDependencyLoader]
|
public UpdateStreamBadgeArea()
|
||||||
private void load(OverlayColourProvider colourProvider)
|
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
|
|
||||||
AddInternal(new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = colourProvider.Background5,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Populate(List<APIUpdateStream> streams)
|
public void Populate(List<APIUpdateStream> streams)
|
||||||
@ -36,7 +27,7 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
foreach (var streamBadge in TabContainer.Children.OfType<UpdateStreamBadge>())
|
foreach (var streamBadge in TabContainer.Children.OfType<UpdateStreamBadge>())
|
||||||
streamBadge.EnableDim();
|
streamBadge.UserHoveringArea = true;
|
||||||
|
|
||||||
return base.OnHover(e);
|
return base.OnHover(e);
|
||||||
}
|
}
|
||||||
@ -44,26 +35,17 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
protected override void OnHoverLost(HoverLostEvent e)
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
{
|
{
|
||||||
foreach (var streamBadge in TabContainer.Children.OfType<UpdateStreamBadge>())
|
foreach (var streamBadge in TabContainer.Children.OfType<UpdateStreamBadge>())
|
||||||
streamBadge.DisableDim();
|
streamBadge.UserHoveringArea = false;
|
||||||
|
|
||||||
base.OnHoverLost(e);
|
base.OnHoverLost(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override TabFillFlowContainer CreateTabFlow()
|
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
|
||||||
{
|
{
|
||||||
var flow = base.CreateTabFlow();
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
flow.RelativeSizeAxes = Axes.X;
|
AllowMultiline = true,
|
||||||
flow.AutoSizeAxes = Axes.Y;
|
};
|
||||||
flow.AllowMultiline = true;
|
|
||||||
flow.Padding = new MarginPadding
|
|
||||||
{
|
|
||||||
Vertical = 20,
|
|
||||||
Horizontal = 85,
|
|
||||||
};
|
|
||||||
|
|
||||||
return flow;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override Dropdown<APIUpdateStream> CreateDropdown() => null;
|
protected override Dropdown<APIUpdateStream> CreateDropdown() => null;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user