Skip to content

Commit

Permalink
Add setting to allow hiding all country flags
Browse files Browse the repository at this point in the history
There have been enough requests for this at this point to implement it.
  • Loading branch information
peppy committed May 10, 2024
1 parent 5285b35 commit b026309
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7 deletions.
5 changes: 4 additions & 1 deletion osu.Game/Configuration/OsuConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ protected override void InitialiseDefaults()
SetDefault(OsuSetting.EditorLimitedDistanceSnap, false);
SetDefault(OsuSetting.EditorShowSpeedChanges, false);

SetDefault(OsuSetting.HideCountryFlags, false);

SetDefault(OsuSetting.MultiplayerRoomFilter, RoomPermissionsFilter.All);

SetDefault(OsuSetting.LastProcessedMetadataId, -1);
Expand Down Expand Up @@ -435,6 +437,7 @@ public enum OsuSetting
TouchDisableGameplayTaps,
ModSelectTextSearchStartsActive,
UserOnlineStatus,
MultiplayerRoomFilter
MultiplayerRoomFilter,
HideCountryFlags,
}
}
5 changes: 5 additions & 0 deletions osu.Game/Localisation/OnlineSettingsStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ public static class OnlineSettingsStrings
/// </summary>
public static LocalisableString DiscordPresenceOff => new TranslatableString(getKey(@"discord_presence_off"), @"Off");

/// <summary>
/// "Hide country flags"
/// </summary>
public static LocalisableString HideCountryFlags => new TranslatableString(getKey(@"hide_country_flags"), @"Hide country flags");

private static string getKey(string key) => $"{prefix}:{key}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ private void load(OsuConfigManager config)
LabelText = OnlineSettingsStrings.NotifyOnPrivateMessage,
Current = config.GetBindable<bool>(OsuSetting.NotifyOnPrivateMessage)
},
new SettingsCheckbox
{
LabelText = OnlineSettingsStrings.HideCountryFlags,
Current = config.GetBindable<bool>(OsuSetting.HideCountryFlags)
},
};
}
}
Expand Down
31 changes: 25 additions & 6 deletions osu.Game/Users/Drawables/UpdateableFlag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,32 @@

using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;

namespace osu.Game.Users.Drawables
{
public partial class UpdateableFlag : ModelBackedDrawable<CountryCode>
{
private CountryCode countryCode;

public CountryCode CountryCode
{
get => Model;
set => Model = value;
get => countryCode;
set
{
countryCode = value;
updateModel();
}
}

/// <summary>
/// Whether to show a place holder on unknown country.
/// Whether to show a placeholder on unknown country.
/// </summary>
public bool ShowPlaceholderOnUnknown = true;

Expand All @@ -30,9 +38,21 @@ public CountryCode CountryCode
/// </summary>
public Action? Action;

private readonly Bindable<bool> hideFlags = new BindableBool();

[Resolved]
private RankingsOverlay? rankingsOverlay { get; set; }

public UpdateableFlag(CountryCode countryCode = CountryCode.Unknown)
{
CountryCode = countryCode;
hideFlags.BindValueChanged(_ => updateModel());
}

[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
config.BindWith(OsuSetting.HideCountryFlags, hideFlags);
}

protected override Drawable? CreateDrawable(CountryCode countryCode)
Expand All @@ -54,14 +74,13 @@ public UpdateableFlag(CountryCode countryCode = CountryCode.Unknown)
};
}

[Resolved]
private RankingsOverlay? rankingsOverlay { get; set; }

protected override bool OnClick(ClickEvent e)
{
Action?.Invoke();
rankingsOverlay?.ShowCountry(CountryCode);
return true;
}

private void updateModel() => Model = hideFlags.Value ? CountryCode.Unknown : countryCode;
}
}

0 comments on commit b026309

Please sign in to comment.