mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 03:22:55 +08:00
Refactor2
This commit is contained in:
parent
bcd132e87f
commit
a9299423cd
@ -63,8 +63,6 @@ namespace osu.Game.Input.Bindings
|
||||
ToggleChat,
|
||||
[Description("Toggle social overlay")]
|
||||
ToggleSocial,
|
||||
[Description("Toggle changelog")]
|
||||
ToggleChangelog,
|
||||
[Description("Reset input settings")]
|
||||
ResetInputSettings,
|
||||
[Description("Toggle toolbar")]
|
||||
|
@ -53,8 +53,6 @@ namespace osu.Game
|
||||
|
||||
private DialogOverlay dialogOverlay;
|
||||
|
||||
private ChangelogOverlay changelog;
|
||||
|
||||
private DirectOverlay direct;
|
||||
|
||||
private SocialOverlay social;
|
||||
@ -112,8 +110,6 @@ namespace osu.Game
|
||||
|
||||
public void ToggleDirect() => direct.ToggleVisibility();
|
||||
|
||||
public void ToggleChangelog() => changelog.ToggleVisibility();
|
||||
|
||||
/// <summary>
|
||||
/// Close all game-wide overlays.
|
||||
/// </summary>
|
||||
@ -285,7 +281,6 @@ namespace osu.Game
|
||||
loadComponentSingleFile(screenshotManager, Add);
|
||||
|
||||
//overlay elements
|
||||
loadComponentSingleFile(changelog = new ChangelogOverlay { Depth = -1 }, mainContent.Add);
|
||||
loadComponentSingleFile(direct = new DirectOverlay { Depth = -1 }, mainContent.Add);
|
||||
loadComponentSingleFile(social = new SocialOverlay { Depth = -1 }, mainContent.Add);
|
||||
loadComponentSingleFile(chat = new ChatOverlay { Depth = -1 }, mainContent.Add);
|
||||
@ -320,7 +315,6 @@ namespace osu.Game
|
||||
dependencies.Cache(settings);
|
||||
dependencies.Cache(onscreenDisplay);
|
||||
dependencies.Cache(social);
|
||||
dependencies.Cache(changelog);
|
||||
dependencies.Cache(direct);
|
||||
dependencies.Cache(chat);
|
||||
dependencies.Cache(userProfile);
|
||||
@ -355,7 +349,7 @@ namespace osu.Game
|
||||
}
|
||||
|
||||
// ensure only one of these overlays are open at once.
|
||||
var singleDisplayOverlays = new OverlayContainer[] { chat, social, direct, changelog };
|
||||
var singleDisplayOverlays = new OverlayContainer[] { chat, social, direct };
|
||||
overlays.AddRange(singleDisplayOverlays);
|
||||
|
||||
foreach (var overlay in singleDisplayOverlays)
|
||||
@ -465,9 +459,6 @@ namespace osu.Game
|
||||
case GlobalAction.ToggleSocial:
|
||||
social.ToggleVisibility();
|
||||
return true;
|
||||
case GlobalAction.ToggleChangelog:
|
||||
changelog.ToggleVisibility();
|
||||
return true;
|
||||
case GlobalAction.ResetInputSettings:
|
||||
var sensitivity = frameworkConfig.GetBindable<double>(FrameworkSetting.CursorSensitivity);
|
||||
|
||||
|
@ -10,6 +10,7 @@ using osu.Game.Graphics;
|
||||
namespace osu.Game.Overlays.Changelog
|
||||
{
|
||||
// maybe look to osu.Game.Screens.Play.SquareGraph for reference later
|
||||
// placeholder json file: https://api.myjson.com/bins/10ye8a
|
||||
public class ChangelogChart : BufferedContainer
|
||||
{
|
||||
public ChangelogChart()
|
||||
|
@ -11,8 +11,13 @@ namespace osu.Game.Overlays.Changelog
|
||||
public ChangelogContent()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
//AutoSizeAxes = Axes.Y;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Direction = FillDirection.Vertical;
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Left = 70,
|
||||
Right = 70,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,8 @@ namespace osu.Game.Overlays.Changelog
|
||||
{
|
||||
Text = build.DisplayVersion,
|
||||
TextSize = 28, // web: 24,
|
||||
Colour = StreamColour.STABLE,
|
||||
Font = @"Exo2.0-Light",
|
||||
Colour = StreamColour.FromStreamName(build.UpdateStream.Name),
|
||||
},
|
||||
}
|
||||
},
|
||||
@ -90,7 +91,7 @@ namespace osu.Game.Overlays.Changelog
|
||||
new SpriteText
|
||||
{
|
||||
// do we need .ToUniversalTime() here?
|
||||
// also, this is a temporary solution to weekdays in >localized< date strings
|
||||
// also, this should be a temporary solution to weekdays in >localized< date strings
|
||||
Text = build.CreatedAt.Date.ToLongDateString().Replace(build.CreatedAt.ToString("dddd") + ", ", ""),
|
||||
TextSize = 17, // web: 14,
|
||||
Colour = OsuColour.FromHex(@"FD5"),
|
||||
|
@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Changelog
|
||||
{
|
||||
protected Color4 Purple = new Color4(191, 4, 255, 255);
|
||||
private readonly Sprite coverImage;
|
||||
private readonly Sprite headerBadge; //50x50, margin-right: 20
|
||||
private readonly Sprite headerBadge;
|
||||
private readonly OsuSpriteText titleStream;
|
||||
private readonly TextBadgePairListing listing;
|
||||
private readonly TextBadgePairRelease releaseStream;
|
||||
@ -46,10 +46,7 @@ namespace osu.Game.Overlays.Changelog
|
||||
coverImage = new Sprite
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = new Vector2(1),
|
||||
FillMode = FillMode.Fill,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
new Container // this is the line badge-Changelog-Stream
|
||||
{
|
||||
@ -79,11 +76,11 @@ namespace osu.Game.Overlays.Changelog
|
||||
|
||||
// this box has 2 functions:
|
||||
// - ensures the circle doesn't disappear on the X and Y edges
|
||||
// - lessens the white "contamination" on the circle (due to smoothing)
|
||||
// - gets rid of the white "contamination" on the circle (due to smoothing)
|
||||
// (https://i.imgur.com/SMuvWBZ.png)
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = new Vector2(1),
|
||||
Alpha = 0,
|
||||
AlwaysPresent = true,
|
||||
Colour = Purple,
|
||||
|
@ -14,42 +14,44 @@ namespace osu.Game.Overlays.Changelog
|
||||
public class ChangelogStreams : Container
|
||||
{
|
||||
private const float container_height = 106.5f;
|
||||
private const float container_margin_y = 20;
|
||||
private const float container_margin_x = 85;
|
||||
private const float padding_y = 20;
|
||||
private const float padding_x = 85;
|
||||
public Action OnSelection;
|
||||
|
||||
public APIChangelog SelectedRelease;
|
||||
// not using SelectedRelease as a Bindable and then using .OnValueChange instead of OnSelection
|
||||
// because it doesn't "refresh" the selection if the same stream is chosen
|
||||
|
||||
public readonly FillFlowContainer<StreamBadge> BadgesContainer;
|
||||
|
||||
public ChangelogStreams()
|
||||
{
|
||||
Height = container_height;
|
||||
// this should actually be resizeable (https://streamable.com/yw2ug)
|
||||
// if not, with small width:height ratio it cuts off right-most content
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = new OpenTK.Vector2(1),
|
||||
Colour = new Color4(32, 24, 35, 255),
|
||||
},
|
||||
BadgesContainer = new FillFlowContainer<StreamBadge>
|
||||
{
|
||||
Direction = FillDirection.Horizontal,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Margin = new MarginPadding
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Top = container_margin_y,
|
||||
Bottom = container_margin_y,
|
||||
Left = container_margin_x,
|
||||
Right = container_margin_x,
|
||||
Top = padding_y,
|
||||
Bottom = padding_y,
|
||||
Left = padding_x,
|
||||
Right = padding_x,
|
||||
},
|
||||
},
|
||||
};
|
||||
// ok, so this is probably not the best.
|
||||
// will need to reflect on this.
|
||||
// do we need the changelog to be updateable?
|
||||
// how else can this be done?
|
||||
BadgesContainer.OnUpdate = d =>
|
||||
{
|
||||
foreach (StreamBadge streamBadge in BadgesContainer.Children)
|
||||
|
@ -61,9 +61,8 @@ namespace osu.Game.Overlays.Changelog.Header
|
||||
.MoveToY(0, duration, easing)
|
||||
.FadeIn(duration, easing);
|
||||
|
||||
// since using .finally/.oncomplete after first fadeout made the badge
|
||||
// not hide sometimes in visual tests(because FinishTransforms()/CancelTransforms()
|
||||
// didn't apply to transforms that come after the .finally), I'm using a scheduler here
|
||||
// since using .finally/.oncomplete after first fadeout made the badge not hide
|
||||
// sometimes in visual tests (https://streamable.com/0qssq), I'm using a scheduler here
|
||||
Scheduler.AddDelayed(() =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(displayText)) Text.Text = displayText;
|
||||
@ -79,10 +78,8 @@ namespace osu.Game.Overlays.Changelog.Header
|
||||
{
|
||||
Text = new SpriteText
|
||||
{
|
||||
TextSize = 21, // web is 16, but here it looks too small?
|
||||
TextSize = 21, // web: 16,
|
||||
Text = displayText,
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.TopLeft,
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Top = 5,
|
||||
@ -91,7 +88,6 @@ namespace osu.Game.Overlays.Changelog.Header
|
||||
},
|
||||
LineBadge = new LineBadge(startCollapsed)
|
||||
{
|
||||
Width = 1,
|
||||
Colour = badgeColour,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
}
|
||||
|
@ -17,10 +17,7 @@ namespace osu.Game.Overlays.Changelog.Header
|
||||
Text.Alpha = 0;
|
||||
}
|
||||
|
||||
public void SetText(string displayText)
|
||||
{
|
||||
Text.Text = displayText;
|
||||
}
|
||||
public void SetText(string displayText) => Text.Text = displayText;
|
||||
|
||||
public void Activate(string displayText = null)
|
||||
{
|
||||
|
@ -76,10 +76,8 @@ namespace osu.Game.Overlays.Changelog
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Width = 1,
|
||||
Colour = StreamColour.FromStreamName(ChangelogEntry.UpdateStream.Name),
|
||||
RelativeSizeAxes = Axes.X,
|
||||
TransitionDuration = 600,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -79,6 +79,7 @@ namespace osu.Game.Overlays
|
||||
},
|
||||
},
|
||||
};
|
||||
OnLoadComplete += d => FetchChangelog(); // is i
|
||||
Streams.OnSelection = () =>
|
||||
{
|
||||
if (Streams.SelectedRelease != null)
|
||||
@ -86,13 +87,9 @@ namespace osu.Game.Overlays
|
||||
header.ChangelogEntry = Streams.SelectedRelease;
|
||||
}
|
||||
header.ShowReleaseStream();
|
||||
content.Clear();
|
||||
content.Clear(); // this should probably happen with some transition
|
||||
content.Add(new ChangelogContentGroup(Streams.SelectedRelease));
|
||||
};
|
||||
Streams.BadgesContainer.OnLoadComplete += d =>
|
||||
{
|
||||
FetchChangelog();
|
||||
};
|
||||
header.OnListingActivated += () =>
|
||||
{
|
||||
Streams.SelectedRelease = null;
|
||||
@ -151,6 +148,7 @@ namespace osu.Game.Overlays
|
||||
var req = new GetChangelogLatestBuildsRequest();
|
||||
req.Success += res =>
|
||||
{
|
||||
Streams.BadgesContainer.Clear();
|
||||
foreach (APIChangelog item in res)
|
||||
{
|
||||
Streams.BadgesContainer.Add(new StreamBadge(item));
|
||||
|
@ -1,22 +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.Allocation;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
public class ToolbarChangelogButton : ToolbarOverlayToggleButton
|
||||
{
|
||||
public ToolbarChangelogButton()
|
||||
{
|
||||
SetIcon(FontAwesome.fa_list);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(ChangelogOverlay changelog)
|
||||
{
|
||||
StateContainer = changelog;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user