Refactor3

This commit is contained in:
HoutarouOreki
2018-07-20 00:52:50 +02:00
parent a9299423cd
commit a857999950
9 changed files with 56 additions and 51 deletions

View File

@ -23,7 +23,8 @@ namespace osu.Game.Tests.Visual
AddStep(@"Show", changelog.Show); AddStep(@"Show", changelog.Show);
AddRepeatStep(@"Toggle Release Stream", () => AddRepeatStep(@"Toggle Release Stream", () =>
{ {
if (isLoaded) changelog.Streams.BadgesContainer.Children[index].Activate(); if (isLoaded)
changelog.Streams.BadgesContainer.Children[index].Activate();
indexIncrement(); indexIncrement();
}, 6); }, 6);
AddStep(@"Listing", changelog.ActivateListing); AddStep(@"Listing", changelog.ActivateListing);
@ -31,7 +32,8 @@ namespace osu.Game.Tests.Visual
AddWaitStep(3); AddWaitStep(3);
AddStep(@"Show with Release Stream", () => AddStep(@"Show with Release Stream", () =>
{ {
if (isLoaded) changelog.Streams.BadgesContainer.Children[index].Activate(); if (isLoaded)
changelog.Streams.BadgesContainer.Children[index].Activate();
changelog.Show(); changelog.Show();
indexIncrement(); indexIncrement();
}); });
@ -48,7 +50,8 @@ namespace osu.Game.Tests.Visual
AddWaitStep(3); AddWaitStep(3);
AddStep(@"Activate release", () => AddStep(@"Activate release", () =>
{ {
if (isLoaded) changelog.Streams.BadgesContainer.Children[index].Activate(); if (isLoaded)
changelog.Streams.BadgesContainer.Children[index].Activate();
indexIncrement(); indexIncrement();
}); });
AddStep(@"Show with listing", () => AddStep(@"Show with listing", () =>
@ -56,6 +59,18 @@ namespace osu.Game.Tests.Visual
changelog.ActivateListing(); changelog.ActivateListing();
changelog.Show(); changelog.Show();
}); });
AddStep(@"Activate Release", () =>
{
if (isLoaded)
changelog.Streams.BadgesContainer.Children[index].Activate();
});
AddStep(@"Activate Listing", changelog.ActivateListing);
AddStep(@"Activate Release", () =>
{
if (isLoaded)
changelog.Streams.BadgesContainer.Children[index].Activate();
indexIncrement();
});
} }
} }
} }

View File

@ -22,22 +22,21 @@ namespace osu.Game.Graphics.UserInterface
public TooltipIconButton() public TooltipIconButton()
{ {
Children = new Drawable[] Children = new Drawable[]
{
new Box
{ {
new Box RelativeSizeAxes = Axes.Both,
{ Alpha = 0,
RelativeSizeAxes = Axes.Both, },
Alpha = 0, icon = new SpriteIcon
}, {
icon = new SpriteIcon Origin = Anchor.Centre,
{ Anchor = Anchor.Centre,
Origin = Anchor.Centre, Size = new Vector2(18),
Anchor = Anchor.Centre, }
Size = new Vector2(18), };
}
};
} }
public string TooltipText { get; set; } public string TooltipText { get; set; }
} }
} }

View File

@ -27,12 +27,6 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty("created_at")] [JsonProperty("created_at")]
public DateTimeOffset CreatedAt { get; set; } public DateTimeOffset CreatedAt { get; set; }
[JsonProperty("disqus_id")]
public string DisqusId { get; set; }
[JsonProperty("disqus_title")]
public string DisqusTitle { get; set; }
[JsonProperty("update_stream")] [JsonProperty("update_stream")]
public UpdateStream UpdateStream { get; set; } public UpdateStream UpdateStream { get; set; }

View File

@ -60,9 +60,8 @@ namespace osu.Game.Overlays.Changelog
{ {
SelectedRelease = streamBadge.ChangelogEntry; SelectedRelease = streamBadge.ChangelogEntry;
foreach (StreamBadge item in BadgesContainer.Children) foreach (StreamBadge item in BadgesContainer.Children)
{ if (item.ChangelogEntry.Id != streamBadge.ChangelogEntry.Id)
if (item.ChangelogEntry.Id != streamBadge.ChangelogEntry.Id) item.Deactivate(); item.Deactivate();
}
OnSelection?.Invoke(); OnSelection?.Invoke();
}; };
} }
@ -77,11 +76,10 @@ namespace osu.Game.Overlays.Changelog
if (SelectedRelease != null) if (SelectedRelease != null)
{ {
if (SelectedRelease.UpdateStream.Id != streamBadge.ChangelogEntry.Id) if (SelectedRelease.UpdateStream.Id != streamBadge.ChangelogEntry.Id)
{
streamBadge.Deactivate(); streamBadge.Deactivate();
}
} }
else streamBadge.Deactivate(); else
streamBadge.Deactivate();
} }
return base.OnHover(state); return base.OnHover(state);
} }
@ -89,9 +87,8 @@ namespace osu.Game.Overlays.Changelog
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(InputState state)
{ {
if (SelectedRelease == null) if (SelectedRelease == null)
{ foreach (StreamBadge streamBadge in BadgesContainer.Children)
foreach (StreamBadge streamBadge in BadgesContainer.Children) streamBadge.Activate(true); streamBadge.Activate(true);
}
base.OnHoverLost(state); base.OnHoverLost(state);
} }
} }

View File

@ -44,7 +44,8 @@ namespace osu.Game.Overlays.Changelog.Header
public void ShowText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic) public void ShowText(double duration = 0, string displayText = null, Easing easing = Easing.InOutCubic)
{ {
LineBadge.IsCollapsed = false; LineBadge.IsCollapsed = false;
if (!string.IsNullOrEmpty(displayText)) Text.Text = displayText; if (!string.IsNullOrEmpty(displayText))
Text.Text = displayText;
Text.MoveToY(0, duration, easing) Text.MoveToY(0, duration, easing)
.FadeIn(duration, easing); .FadeIn(duration, easing);
} }
@ -111,7 +112,8 @@ namespace osu.Game.Overlays.Changelog.Header
protected override bool OnHover(InputState state) protected override bool OnHover(InputState state)
{ {
if (!IsActivated) sampleHover?.Play(); if (!IsActivated)
sampleHover?.Play();
return base.OnHover(state); return base.OnHover(state);
} }

View File

@ -63,7 +63,8 @@ namespace osu.Game.Overlays.Changelog.Header
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(InputState state)
{ {
if (IsActivated == false) LineBadge.ResizeHeightTo(1, LineBadge.TransitionDuration, Easing.Out); if (!IsActivated)
LineBadge.ResizeHeightTo(1, LineBadge.TransitionDuration, Easing.Out);
base.OnHoverLost(state); base.OnHoverLost(state);
} }

View File

@ -23,13 +23,12 @@ namespace osu.Game.Overlays.Changelog.Header
{ {
if (IsActivated) if (IsActivated)
{ {
if (displayText != Text.Text) ChangeText(transition_duration, displayText); if (displayText != Text.Text)
ChangeText(transition_duration, displayText);
} }
else else
{
ShowText(transition_duration, displayText); ShowText(transition_duration, displayText);
IsActivated = true; IsActivated = true;
}
SampleActivate?.Play(); SampleActivate?.Play();
OnActivation?.Invoke(); OnActivation?.Invoke();
} }

View File

@ -64,7 +64,7 @@ namespace osu.Game.Overlays.Changelog
new SpriteText new SpriteText
{ {
Text = ChangelogEntry.Users > 0 ? Text = ChangelogEntry.Users > 0 ?
string.Join(" ", ChangelogEntry.Users.ToString("N0"), "users online"): string.Format($"{ChangelogEntry.Users:N0} users online") :
null, null,
TextSize = 12, TextSize = 12,
Font = @"Exo2.0-Regular", Font = @"Exo2.0-Regular",
@ -87,7 +87,8 @@ namespace osu.Game.Overlays.Changelog
isActivated = true; isActivated = true;
this.FadeIn(transition_duration); this.FadeIn(transition_duration);
lineBadge.IsCollapsed = false; lineBadge.IsCollapsed = false;
if (!withoutHeaderUpdate) OnActivation?.Invoke(); if (!withoutHeaderUpdate)
OnActivation?.Invoke();
} }
public void Deactivate() public void Deactivate()

View File

@ -96,9 +96,11 @@ namespace osu.Game.Overlays
content.Clear(); content.Clear();
// should add listing to content here // should add listing to content here
if (!Streams.IsHovered) if (!Streams.IsHovered)
foreach (StreamBadge item in Streams.BadgesContainer.Children) item.Activate(true); foreach (StreamBadge item in Streams.BadgesContainer.Children)
item.Activate(true);
else else
foreach (StreamBadge item in Streams.BadgesContainer.Children) item.Deactivate(); foreach (StreamBadge item in Streams.BadgesContainer.Children)
item.Deactivate();
}; };
} }
@ -112,13 +114,10 @@ namespace osu.Game.Overlays
switch (action) switch (action)
{ {
case GlobalAction.Back: case GlobalAction.Back:
if (header.IsListingActivated()) State = Visibility.Hidden; if (header.IsListingActivated())
State = Visibility.Hidden;
// the problem here is that when hovering over the builds' container else
// and pressing back, they don't lower their opacity they're rehovered on header.ActivateListing();
else header.ActivateListing();
return true;
case GlobalAction.Select:
return true; return true;
} }
@ -150,9 +149,7 @@ namespace osu.Game.Overlays
{ {
Streams.BadgesContainer.Clear(); Streams.BadgesContainer.Clear();
foreach (APIChangelog item in res) foreach (APIChangelog item in res)
{
Streams.BadgesContainer.Add(new StreamBadge(item)); Streams.BadgesContainer.Add(new StreamBadge(item));
}
}; };
api.Queue(req); api.Queue(req);
} }