1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 08:22:56 +08:00

Fix deprecated calls and code styling (partly)

This commit is contained in:
Dean Herbert 2019-05-13 00:46:22 +09:00
parent 34f54aa945
commit 31b72f168d
17 changed files with 62 additions and 56 deletions

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using NUnit.Framework; using NUnit.Framework;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays; using osu.Game.Overlays;
@ -20,7 +19,9 @@ namespace osu.Game.Tests.Visual
Add(changelog = new ChangelogOverlay()); Add(changelog = new ChangelogOverlay());
AddStep(@"Show", changelog.Show); AddStep(@"Show", changelog.Show);
AddStep(@"Hide", changelog.Hide); AddStep(@"Hide", changelog.Hide);
AddWaitStep(3);
AddWaitStep("wait for hide", 3);
AddStep(@"Show with Lazer 2018.712.0", () => AddStep(@"Show with Lazer 2018.712.0", () =>
{ {
changelog.FetchAndShowBuild(new APIChangelogBuild changelog.FetchAndShowBuild(new APIChangelogBuild
@ -30,9 +31,11 @@ namespace osu.Game.Tests.Visual
}); });
changelog.Show(); changelog.Show();
}); });
AddWaitStep(3);
AddWaitStep("wait for show", 3);
AddStep(@"Hide", changelog.Hide); AddStep(@"Hide", changelog.Hide);
AddWaitStep(3); AddWaitStep("wait for hide", 3);
AddStep(@"Show with listing", () => AddStep(@"Show with listing", () =>
{ {
changelog.ShowListing(); changelog.ShowListing();

View File

@ -42,7 +42,6 @@ namespace osu.Game.Tests.Visual
AddStep(@"Hide text", () => textBadgePair.HideText(200)); AddStep(@"Hide text", () => textBadgePair.HideText(200));
AddStep(@"Show text", () => textBadgePair.ShowText(200)); AddStep(@"Show text", () => textBadgePair.ShowText(200));
AddStep(@"Different text", () => textBadgePair.ChangeText(200, "This one's a little bit wider")); AddStep(@"Different text", () => textBadgePair.ChangeText(200, "This one's a little bit wider"));
AddWaitStep(1);
AddStep(@"Different text", () => textBadgePair.ChangeText(200, "Ok?..")); AddStep(@"Different text", () => textBadgePair.ChangeText(200, "Ok?.."));
} }
} }

View File

@ -36,6 +36,7 @@ namespace osu.Game.Graphics
if (!string.IsNullOrEmpty(name)) if (!string.IsNullOrEmpty(name))
if (colours.TryGetValue(name, out ColourInfo colour)) if (colours.TryGetValue(name, out ColourInfo colour))
return colour; return colour;
return new Color4(0, 0, 0, 255); return new Color4(0, 0, 0, 255);
} }
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
@ -25,11 +24,12 @@ namespace osu.Game.Graphics.UserInterface
/// </summary> /// </summary>
public bool IsHorizontal public bool IsHorizontal
{ {
get { return isHorizontal; } get => isHorizontal;
set set
{ {
if (value == isHorizontal) if (value == isHorizontal)
return; return;
if (IsLoaded) if (IsLoaded)
{ {
FinishTransforms(); FinishTransforms();
@ -41,6 +41,7 @@ namespace osu.Game.Graphics.UserInterface
} }
else else
RelativeSizeAxes = value ? Axes.X : Axes.Y; RelativeSizeAxes = value ? Axes.X : Axes.Y;
isHorizontal = value; isHorizontal = value;
} }
} }

View File

@ -36,7 +36,7 @@ namespace osu.Game.Graphics.UserInterface
/// </summary> /// </summary>
public bool IsEnabled public bool IsEnabled
{ {
get { return isEnabled; } get => isEnabled;
set set
{ {
isEnabled = value; isEnabled = value;
@ -77,6 +77,7 @@ namespace osu.Game.Graphics.UserInterface
sampleClick?.Play(); sampleClick?.Play();
Action?.Invoke(); Action?.Invoke();
} }
return base.OnClick(e); return base.OnClick(e);
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Online.API.Requests namespace osu.Game.Online.API.Requests

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Online.API.Requests namespace osu.Game.Online.API.Requests
@ -10,12 +9,19 @@ namespace osu.Game.Online.API.Requests
{ {
private readonly string updateStream; private readonly string updateStream;
public GetChangelogChartRequest() => updateStream = null; public GetChangelogChartRequest()
{
updateStream = null;
}
public GetChangelogChartRequest(string updateStreamName) => updateStream = updateStreamName; public GetChangelogChartRequest(string updateStreamName)
{
updateStream = updateStreamName;
}
protected override string Target => $@"changelog/{(!string.IsNullOrEmpty(updateStream) ? protected override string Target => $@"changelog/{(!string.IsNullOrEmpty(updateStream) ?
updateStream + "/" : "")}chart-config"; updateStream + "/" : "")}chart-config";
protected override string Uri => $@"https://houtarouoreki.github.io/fake-api/{Target}"; // for testing protected override string Uri => $@"https://houtarouoreki.github.io/fake-api/{Target}"; // for testing
} }
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Online.API.Requests namespace osu.Game.Online.API.Requests

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -4,7 +4,6 @@
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.Framework.Graphics.Shapes;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using System; using System;
using osuTK.Graphics; using osuTK.Graphics;
@ -13,7 +12,6 @@ namespace osu.Game.Overlays.Changelog
{ {
public class ChangelogContent : FillFlowContainer public class ChangelogContent : FillFlowContainer
{ {
private APIAccess api;
private ChangelogContentGroup changelogContentGroup; private ChangelogContentGroup changelogContentGroup;
public delegate void BuildSelectedEventHandler(APIChangelogBuild build, EventArgs args); public delegate void BuildSelectedEventHandler(APIChangelogBuild build, EventArgs args);

View File

@ -65,19 +65,17 @@ namespace osu.Game.Overlays.Changelog
new SpriteText new SpriteText
{ {
Text = build.UpdateStream.DisplayName, Text = build.UpdateStream.DisplayName,
TextSize = 28, // web: 24, Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 28), // web: 24,
Font = @"Exo2.0-Medium",
}, },
new SpriteText new SpriteText
{ {
Text = " ", Text = " ",
TextSize = 28, Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 28), // web: 24,
}, },
new SpriteText new SpriteText
{ {
Text = build.DisplayVersion, Text = build.DisplayVersion,
TextSize = 28, // web: 24, Font = OsuFont.GetFont(weight: FontWeight.Light, size: 28), // web: 24,
Font = @"Exo2.0-Light",
Colour = StreamColour.FromStreamName(build.UpdateStream.Name), Colour = StreamColour.FromStreamName(build.UpdateStream.Name),
}, },
} }
@ -100,9 +98,8 @@ namespace osu.Game.Overlays.Changelog
// do we need .ToUniversalTime() here? // do we need .ToUniversalTime() here?
// also, this should be 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") + ", ", ""), Text = build.CreatedAt.Date.ToLongDateString().Replace(build.CreatedAt.ToString("dddd") + ", ", ""),
TextSize = 17, // web: 14, Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 17), // web: 14,
Colour = OsuColour.FromHex(@"FD5"), Colour = OsuColour.FromHex(@"FD5"),
Font = @"Exo2.0-Medium",
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Margin = new MarginPadding { Top = 5 }, Margin = new MarginPadding { Top = 5 },
@ -130,9 +127,8 @@ namespace osu.Game.Overlays.Changelog
// do we need .ToUniversalTime() here? // do we need .ToUniversalTime() here?
// also, this should be 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") + ", ", ""), Text = build.CreatedAt.Date.ToLongDateString().Replace(build.CreatedAt.ToString("dddd") + ", ", ""),
TextSize = 28, // web: 24, Font = OsuFont.GetFont(weight: FontWeight.Light, size: 28), // web: 24,
Colour = OsuColour.FromHex(@"FD5"), Colour = OsuColour.FromHex(@"FD5"),
Font = @"Exo2.0-Light",
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Margin = new MarginPadding { Top = 20 }, Margin = new MarginPadding { Top = 20 },
@ -155,14 +151,12 @@ namespace osu.Game.Overlays.Changelog
new SpriteText new SpriteText
{ {
Text = build.UpdateStream.DisplayName, Text = build.UpdateStream.DisplayName,
TextSize = 20, // web: 18, Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 20), // web: 19,
Font = @"Exo2.0-Medium",
}, },
new SpriteText new SpriteText
{ {
Text = build.DisplayVersion, Text = build.DisplayVersion,
TextSize = 20, // web: 18, Font = OsuFont.GetFont(weight: FontWeight.Light, size: 20), // web: 19,
Font = @"Exo2.0-Light",
Colour = StreamColour.FromStreamName(build.UpdateStream.Name), Colour = StreamColour.FromStreamName(build.UpdateStream.Name),
}, },
}, },
@ -226,8 +220,7 @@ namespace osu.Game.Overlays.Changelog
ChangelogEntries.Add(new SpriteText ChangelogEntries.Add(new SpriteText
{ {
Text = category.Key, Text = category.Key,
TextSize = 24, // web: 18, Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 24), // web: 24,
Font = @"Exo2.0-Bold",
Margin = new MarginPadding { Top = 35, Bottom = 15 }, Margin = new MarginPadding { Top = 35, Bottom = 15 },
}); });
@ -240,40 +233,47 @@ namespace osu.Game.Overlays.Changelog
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Vertical = 5 }, Margin = new MarginPadding { Vertical = 5 },
}; };
title.AddIcon(FontAwesome.Solid.Check, t => title.AddIcon(FontAwesome.Solid.Check, t =>
{ {
t.TextSize = 12; t.Font = OsuFont.GetFont(size: 12);
t.Padding = new MarginPadding { Left = -17, Right = 5 }; t.Padding = new MarginPadding { Left = -17, Right = 5 };
}); });
title.AddText(entry.Title, t => { t.TextSize = 18; });
title.AddText(entry.Title, t => { t.Font = OsuFont.GetFont(size: 18); });
if (!string.IsNullOrEmpty(entry.Repository)) if (!string.IsNullOrEmpty(entry.Repository))
{ {
title.AddText(" (", t => t.TextSize = 18); title.AddText(" (", t => t.Font = OsuFont.GetFont(size: 18));
title.AddLink($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}", title.AddLink($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}",
entry.GithubUrl, Online.Chat.LinkAction.External, null, entry.GithubUrl, Online.Chat.LinkAction.External, null,
null, t => { t.TextSize = 18; }); null, t => { t.Font = OsuFont.GetFont(size: 18); });
title.AddText(")", t => t.TextSize = 18); title.AddText(")", t => t.Font = OsuFont.GetFont(size: 18));
} }
title.AddText(" by ", t => t.TextSize = 14); title.AddText(" by ", t => t.Font = OsuFont.GetFont(size: 14));
if (entry.GithubUser.GithubUrl != null) if (entry.GithubUser.GithubUrl != null)
title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl, title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl,
Online.Chat.LinkAction.External, null, null, Online.Chat.LinkAction.External, null, null,
t => t.TextSize = 14); t => t.Font = OsuFont.GetFont(size: 14));
else else
title.AddText(entry.GithubUser.DisplayName, t => t.TextSize = 14); //web: 12; title.AddText(entry.GithubUser.DisplayName, t => t.Font = OsuFont.GetFont(size: 14)); //web: 12;
ChangelogEntries.Add(title); ChangelogEntries.Add(title);
TextFlowContainer messageContainer = new TextFlowContainer TextFlowContainer messageContainer = new TextFlowContainer
{ {
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
}; };
messageContainer.AddText($"{entry.MessageHtml?.Replace("<p>", "").Replace("</p>", "")}\n", t => messageContainer.AddText($"{entry.MessageHtml?.Replace("<p>", "").Replace("</p>", "")}\n", t =>
{ {
t.TextSize = 14; // web: 12, t.Font = OsuFont.GetFont(size: 14); // web: 12,
t.Colour = new Color4(235, 184, 254, 255); t.Colour = new Color4(235, 184, 254, 255);
}); });
ChangelogEntries.Add(messageContainer); ChangelogEntries.Add(messageContainer);
} }
} }

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics.Textures;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Overlays.Changelog.Header; using osu.Game.Overlays.Changelog.Header;
using System; using System;
using osu.Game.Graphics;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -97,14 +98,12 @@ namespace osu.Game.Overlays.Changelog
new OsuSpriteText new OsuSpriteText
{ {
Text = "Changelog ", Text = "Changelog ",
Font = @"Exo2.0-Light", Font = OsuFont.GetFont(weight: FontWeight.Light, size: 38), // web: 30,
TextSize = 38, // web: 30
}, },
titleStream = new OsuSpriteText titleStream = new OsuSpriteText
{ {
Text = "Listing", Text = "Listing",
TextSize = 38, // web: 30 Font = OsuFont.GetFont(weight: FontWeight.Light, size: 38), // web: 30,
Font = @"Exo2.0-Light",
Colour = Purple, Colour = Purple,
}, },
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
@ -12,6 +11,7 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using System; using System;
using osu.Game.Graphics;
namespace osu.Game.Overlays.Changelog.Header namespace osu.Game.Overlays.Changelog.Header
{ {
@ -36,7 +36,7 @@ namespace osu.Game.Overlays.Changelog.Header
{ {
Text = new SpriteText Text = new SpriteText
{ {
TextSize = 21, // web: 16, Font = OsuFont.GetFont(size: 21), // web: 16,
Text = displayText, Text = displayText,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
@ -56,6 +56,8 @@ namespace osu.Game.Overlays.Changelog.Header
/// <param name="duration"> /// <param name="duration">
/// The duration of popping in and popping out not combined. /// The duration of popping in and popping out not combined.
/// Full change takes double this time.</param> /// Full change takes double this time.</param>
/// <param name="displayText"></param>
/// <param name="easing"></param>
public void ChangeText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic) public void ChangeText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic)
{ {
LineBadge.Collapse(); LineBadge.Collapse();

View File

@ -54,21 +54,18 @@ namespace osu.Game.Overlays.Changelog
new SpriteText new SpriteText
{ {
Text = LatestBuild.UpdateStream.DisplayName, Text = LatestBuild.UpdateStream.DisplayName,
Font = @"Exo2.0-Bold", Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14), // web: 12,
TextSize = 14, // web: 12,
Margin = new MarginPadding { Top = 6 }, Margin = new MarginPadding { Top = 6 },
}, },
new SpriteText new SpriteText
{ {
Text = LatestBuild.DisplayVersion, Text = LatestBuild.DisplayVersion,
Font = @"Exo2.0-Light", Font = OsuFont.GetFont(weight: FontWeight.Light, size: 20), // web: 16,
TextSize = 20, // web: 16,
}, },
new SpriteText new SpriteText
{ {
Text = LatestBuild.Users > 0 ? $"{LatestBuild.Users:N0} users online" : null, Text = LatestBuild.Users > 0 ? $"{LatestBuild.Users:N0} users online" : null,
TextSize = 12, // web: 10, Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 12), // web: 10,
Font = @"Exo2.0-Regular",
Colour = new Color4(203, 164, 218, 255), Colour = new Color4(203, 164, 218, 255),
}, },
} }

View File

@ -161,8 +161,10 @@ namespace osu.Game.Overlays
private void fetchListing() private void fetchListing()
{ {
header.ShowListing(); header.ShowListing();
if (isAtListing) if (isAtListing)
return; return;
isAtListing = true; isAtListing = true;
var req = new GetChangelogRequest(); var req = new GetChangelogRequest();
badges.SelectNone(); badges.SelectNone();
@ -173,8 +175,10 @@ namespace osu.Game.Overlays
public void ShowListing() public void ShowListing()
{ {
header.ShowListing(); header.ShowListing();
if (isAtListing) if (isAtListing)
return; return;
isAtListing = true; isAtListing = true;
content.Hide(); content.Hide();
listing.Show(); listing.Show();
@ -187,8 +191,8 @@ namespace osu.Game.Overlays
/// <summary> /// <summary>
/// Fetches and shows a specific build from a specific update stream. /// Fetches and shows a specific build from a specific update stream.
/// </summary> /// </summary>
/// <param name="build">Must contain at least <see cref="APIChangelogBuild.UpdateStream.Name"/> and /// <param name="build">Must contain at least <see cref="UpdateStream.Name"/> and
/// <see cref="APIChangelogBuild.Version"/>. If <see cref="APIChangelogBuild.UpdateStream.DisplayName"/> and /// <see cref="APIChangelogBuild.Version"/>. If <see cref="UpdateStream.DisplayName"/> and
/// <see cref="APIChangelogBuild.DisplayVersion"/> are specified, the header will instantly display them.</param> /// <see cref="APIChangelogBuild.DisplayVersion"/> are specified, the header will instantly display them.</param>
/// <param name="updateBadges">Whether to update badges. Should be set to false in case /// <param name="updateBadges">Whether to update badges. Should be set to false in case
/// the function is called by selecting a badge, to avoid an infinite loop.</param> /// the function is called by selecting a badge, to avoid an infinite loop.</param>