mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 16:52:55 +08:00
move shared stuff between MostPlayedBeatmapDrawable and DrawableScore to DrawableBeatmapRow
This commit is contained in:
parent
6b3347d6ac
commit
02fa1f9dd6
118
osu.Game/Overlays/Profile/Sections/DrawableBeatmapRow.cs
Normal file
118
osu.Game/Overlays/Profile/Sections/DrawableBeatmapRow.cs
Normal file
@ -0,0 +1,118 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
public abstract class DrawableBeatmapRow : Container
|
||||
{
|
||||
private const int fade_duration = 200;
|
||||
|
||||
private Box underscoreLine;
|
||||
private readonly Box coloredBackground;
|
||||
private readonly Container background;
|
||||
|
||||
protected abstract Drawable CreatePicture();
|
||||
|
||||
protected FillFlowContainer LeftFlowContainer { get; private set; }
|
||||
protected FillFlowContainer RightFlowContainer { get; private set; }
|
||||
|
||||
protected override Container<Drawable> Content { get; }
|
||||
|
||||
protected DrawableBeatmapRow()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = 60;
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
background = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
CornerRadius = 3,
|
||||
Alpha = 0,
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Offset = new Vector2(0f, 1f),
|
||||
Radius = 1f,
|
||||
Colour = Color4.Black.Opacity(0.2f),
|
||||
},
|
||||
Child = coloredBackground = new Box { RelativeSizeAxes = Axes.Both }
|
||||
},
|
||||
Content = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Width = 0.97f,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuColour colour)
|
||||
{
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
underscoreLine = new Box
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 1,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new[]
|
||||
{
|
||||
CreatePicture(),
|
||||
LeftFlowContainer = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Margin = new MarginPadding { Left = 10 },
|
||||
Direction = FillDirection.Vertical,
|
||||
},
|
||||
}
|
||||
},
|
||||
RightFlowContainer = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Direction = FillDirection.Vertical,
|
||||
},
|
||||
});
|
||||
|
||||
coloredBackground.Colour = underscoreLine.Colour = colour.Gray4;
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state) => true;
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
background.FadeIn(fade_duration, Easing.OutQuint);
|
||||
underscoreLine.FadeOut(fade_duration, Easing.OutQuint);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
background.FadeOut(fade_duration, Easing.OutQuint);
|
||||
underscoreLine.FadeIn(fade_duration, Easing.OutQuint);
|
||||
base.OnHoverLost(state);
|
||||
}
|
||||
}
|
||||
}
|
@ -2,14 +2,11 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using OpenTK;
|
||||
@ -17,144 +14,99 @@ using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
{
|
||||
public class MostPlayedBeatmapDrawable : Container
|
||||
public class MostPlayedBeatmapDrawable : DrawableBeatmapRow
|
||||
{
|
||||
private readonly BeatmapInfo beatmap;
|
||||
private readonly OsuHoverContainer mapperContainer;
|
||||
|
||||
private readonly EdgeEffectParameters edgeEffectNormal = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Offset = new Vector2(0, 1f),
|
||||
Radius = 2f,
|
||||
Colour = Color4.Black.Opacity(0.25f),
|
||||
};
|
||||
|
||||
private readonly EdgeEffectParameters edgeEffectHovered = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Offset = new Vector2(0, 5f),
|
||||
Radius = 10f,
|
||||
Colour = Color4.Black.Opacity(0.25f),
|
||||
};
|
||||
private readonly int playCount;
|
||||
private OsuHoverContainer mapperContainer;
|
||||
|
||||
public MostPlayedBeatmapDrawable(BeatmapInfo beatmap, int playCount)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = 50;
|
||||
Margin = new MarginPadding { Bottom = 10 };
|
||||
Masking = true;
|
||||
EdgeEffect = edgeEffectNormal;
|
||||
this.playCount = playCount;
|
||||
}
|
||||
|
||||
protected override Drawable CreatePicture() => new Container
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box //Background for this container, otherwise the shadow would be visible
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = OsuColour.Gray(0.2f),
|
||||
},
|
||||
new Box //Image Background while loading
|
||||
{
|
||||
Size = new Vector2(80, 50),
|
||||
Colour = Color4.Black,
|
||||
Size = new Vector2(80, 50),
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
new DelayedLoadWrapper(new BeatmapSetCover(beatmap.BeatmapSet, BeatmapSetCoverType.List)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
FillMode = FillMode.Fit,
|
||||
}),
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding(10) { Left = 90 },
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new BeatmapMetadataContainer(beatmap),
|
||||
new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new []
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Text = playCount.ToString(),
|
||||
TextSize = 18,
|
||||
Font = @"Exo2.0-SemiBoldItalic"
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Text = @"times played ",
|
||||
TextSize = 12,
|
||||
Font = @"Exo2.0-RegularItalic"
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = @"mapped by ",
|
||||
TextSize = 12,
|
||||
},
|
||||
mapperContainer = new OsuHoverContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = beatmap.Metadata.AuthorString,
|
||||
TextSize = 12,
|
||||
Font = @"Exo2.0-MediumItalic"
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(UserProfileOverlay profileOverlay)
|
||||
{
|
||||
LeftFlowContainer.Add(new BeatmapMetadataContainer(beatmap));
|
||||
LeftFlowContainer.Add(new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = @"mapped by ",
|
||||
TextSize = 12,
|
||||
},
|
||||
mapperContainer = new OsuHoverContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = beatmap.Metadata.AuthorString,
|
||||
TextSize = 12,
|
||||
Font = @"Exo2.0-MediumItalic"
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
RightFlowContainer.Add(new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Text = playCount.ToString(),
|
||||
TextSize = 18,
|
||||
Font = @"Exo2.0-SemiBoldItalic"
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Text = @"times played ",
|
||||
TextSize = 12,
|
||||
Font = @"Exo2.0-RegularItalic"
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
if(profileOverlay != null)
|
||||
mapperContainer.Action = () => profileOverlay.ShowUser(beatmap.BeatmapSet.Metadata.Author);
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
TweenEdgeEffectTo(edgeEffectHovered, 120, Easing.OutQuint);
|
||||
return base.OnHover(state);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
TweenEdgeEffectTo(edgeEffectNormal, 120, Easing.OutQuint);
|
||||
base.OnHoverLost(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
private void load(OsuColour colour)
|
||||
{
|
||||
double pp = Score.PP ?? 0;
|
||||
Stats.Add(new OsuSpriteText
|
||||
RightFlowContainer.Add(new OsuSpriteText
|
||||
{
|
||||
Text = $"{pp:0}pp",
|
||||
Anchor = Anchor.TopRight,
|
||||
@ -34,7 +34,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
|
||||
if (weight.HasValue)
|
||||
{
|
||||
Stats.Add(new OsuSpriteText
|
||||
RightFlowContainer.Add(new OsuSpriteText
|
||||
{
|
||||
Text = $"weighted: {pp * weight:0}pp ({weight:P0})",
|
||||
Anchor = Anchor.TopRight,
|
||||
|
@ -11,24 +11,14 @@ using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.Select.Leaderboards;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
{
|
||||
public abstract class DrawableScore : Container
|
||||
public abstract class DrawableScore : DrawableBeatmapRow
|
||||
{
|
||||
private const int fade_duration = 200;
|
||||
|
||||
protected readonly FillFlowContainer<OsuSpriteText> Stats;
|
||||
private readonly FillFlowContainer metadata;
|
||||
private readonly ScoreModsContainer modsContainer;
|
||||
protected readonly Score Score;
|
||||
private readonly Box underscoreLine;
|
||||
private readonly Box coloredBackground;
|
||||
private readonly Container background;
|
||||
|
||||
protected DrawableScore(Score score)
|
||||
{
|
||||
@ -38,85 +28,21 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
Height = 60;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new Container
|
||||
modsContainer = new ScoreModsContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
CornerRadius = 3,
|
||||
Alpha = 0,
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Offset = new Vector2(0f, 1f),
|
||||
Radius = 1f,
|
||||
Colour = Color4.Black.Opacity(0.2f),
|
||||
},
|
||||
Child = coloredBackground = new Box { RelativeSizeAxes = Axes.Both }
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Width = 0.97f,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
underscoreLine = new Box
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 1,
|
||||
},
|
||||
new DrawableRank(score.Rank)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 60,
|
||||
FillMode = FillMode.Fit,
|
||||
},
|
||||
Stats = new FillFlowContainer<OsuSpriteText>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Direction = FillDirection.Vertical,
|
||||
},
|
||||
metadata = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Margin = new MarginPadding { Left = 70 },
|
||||
Direction = FillDirection.Vertical,
|
||||
Child = new OsuSpriteText
|
||||
{
|
||||
Text = score.Date.LocalDateTime.ToShortDateString(),
|
||||
TextSize = 11,
|
||||
Colour = OsuColour.Gray(0xAA),
|
||||
Depth = -1,
|
||||
},
|
||||
},
|
||||
modsContainer = new ScoreModsContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Width = 60,
|
||||
Margin = new MarginPadding { Right = 160 }
|
||||
}
|
||||
}
|
||||
},
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Width = 60,
|
||||
Margin = new MarginPadding { Right = 160 }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuColour colour)
|
||||
{
|
||||
coloredBackground.Colour = underscoreLine.Colour = colour.Gray4;
|
||||
|
||||
Stats.Add(new OsuSpriteText
|
||||
RightFlowContainer.Add(new OsuSpriteText
|
||||
{
|
||||
Text = $"accuracy: {Score.Accuracy:P2}",
|
||||
Anchor = Anchor.TopRight,
|
||||
@ -127,26 +53,23 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
Depth = -1,
|
||||
});
|
||||
|
||||
metadata.Add(new BeatmapMetadataContainer(Score.Beatmap));
|
||||
LeftFlowContainer.Add(new BeatmapMetadataContainer(Score.Beatmap));
|
||||
LeftFlowContainer.Add(new OsuSpriteText
|
||||
{
|
||||
Text = Score.Date.LocalDateTime.ToShortDateString(),
|
||||
TextSize = 11,
|
||||
Colour = OsuColour.Gray(0xAA),
|
||||
});
|
||||
|
||||
foreach (Mod mod in Score.Mods)
|
||||
modsContainer.Add(new ModIcon(mod) { Scale = new Vector2(0.5f) });
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state) => true;
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
protected override Drawable CreatePicture() => new DrawableRank(Score.Rank)
|
||||
{
|
||||
background.FadeIn(fade_duration, Easing.OutQuint);
|
||||
underscoreLine.FadeOut(fade_duration, Easing.OutQuint);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
background.FadeOut(fade_duration, Easing.OutQuint);
|
||||
underscoreLine.FadeIn(fade_duration, Easing.OutQuint);
|
||||
base.OnHoverLost(state);
|
||||
}
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 60,
|
||||
FillMode = FillMode.Fit,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Stats.Add(new OsuSpriteText
|
||||
RightFlowContainer.Add(new OsuSpriteText
|
||||
{
|
||||
Text = Score.TotalScore.ToString("#,###"),
|
||||
Anchor = Anchor.TopRight,
|
||||
|
@ -294,6 +294,7 @@
|
||||
<Compile Include="Online\API\Requests\GetUserBeatmapsRequest.cs" />
|
||||
<Compile Include="Overlays\Profile\Sections\BeatmapMetadataContainer.cs" />
|
||||
<Compile Include="Overlays\Profile\Sections\Beatmaps\PaginatedBeatmapContainer.cs" />
|
||||
<Compile Include="Overlays\Profile\Sections\DrawableBeatmapRow.cs" />
|
||||
<Compile Include="Overlays\Profile\Sections\Historical\MostPlayedBeatmapDrawable.cs" />
|
||||
<Compile Include="Overlays\Profile\Sections\Historical\PaginatedMostPlayedBeatmapContainer.cs" />
|
||||
<Compile Include="Overlays\Profile\Sections\Kudosu\KudosuInfo.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user