Call the UserPanel `Action` when clicking on the flag

This commit is contained in:
Susko3 2022-01-21 14:01:49 +01:00
parent 9b63f15e68
commit 529610ee2e
2 changed files with 10 additions and 1 deletions

View File

@ -1,6 +1,7 @@
// 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.
using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -23,6 +24,12 @@ public Country Country
/// </summary>
public bool ShowPlaceholderOnNull = true;
/// <summary>
/// Perform an action in addition to showing the country ranking.
/// This should be used to perform auxiliary tasks and not as a primary action for clicking a flag (to maintain a consistent UX).
/// </summary>
public Action Action;
public UpdateableFlag(Country country = null)
{
Country = country;
@ -52,6 +59,7 @@ protected override Drawable CreateDrawable(Country country)
protected override bool OnClick(ClickEvent e)
{
Action?.Invoke();
rankingsOverlay?.ShowCountry(Country);
return true;
}

View File

@ -53,7 +53,8 @@ protected override void LoadComplete()
protected UpdateableFlag CreateFlag() => new UpdateableFlag(User.Country)
{
Size = new Vector2(39, 26)
Size = new Vector2(39, 26),
Action = Action,
};
protected SpriteIcon CreateStatusIcon() => statusIcon = new SpriteIcon