Skip to content

Commit

Permalink
Merge pull request ppy#31403 from frenzibyte/mobile-disclaimer
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy authored Jan 3, 2025
2 parents 2d4a3aa + 2cd86cb commit b469885
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 7 deletions.
3 changes: 3 additions & 0 deletions osu.Game/Configuration/OsuConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Diagnostics;
using osu.Framework;
using osu.Framework.Bindables;
using osu.Framework.Configuration;
using osu.Framework.Configuration.Tracking;
Expand Down Expand Up @@ -163,6 +164,7 @@ protected override void InitialiseDefaults()
SetDefault(OsuSetting.Version, string.Empty);

SetDefault(OsuSetting.ShowFirstRunSetup, true);
SetDefault(OsuSetting.ShowMobileDisclaimer, RuntimeInfo.IsMobile);

SetDefault(OsuSetting.ScreenshotFormat, ScreenshotFormat.Jpg);
SetDefault(OsuSetting.ScreenshotCaptureMenuCursor, false);
Expand Down Expand Up @@ -452,5 +454,6 @@ public enum OsuSetting
AlwaysRequireHoldingForPause,
MultiplayerShowInProgressFilter,
BeatmapListingFeaturedArtistFilter,
ShowMobileDisclaimer,
}
}
19 changes: 19 additions & 0 deletions osu.Game/Localisation/ButtonSystemStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,25 @@ public static class ButtonSystemStrings
/// </summary>
public static LocalisableString DailyChallenge => new TranslatableString(getKey(@"daily_challenge"), @"daily challenge");

/// <summary>
/// "A few important words from your dev team!"
/// </summary>
public static LocalisableString MobileDisclaimerHeader => new TranslatableString(getKey(@"mobile_disclaimer_header"), @"A few important words from your dev team!");

/// <summary>
/// "While we have released osu! on mobile platforms to maximise the number of people that can enjoy the game, our focus is still on the PC version.
///
/// Your experience will not be perfect, and may even feel subpar compared to games which are made mobile-first.
///
/// Please bear with us as we continue to improve the game for you!"
/// </summary>
public static LocalisableString MobileDisclaimerBody => new TranslatableString(getKey(@"mobile_disclaimer_body"),
@"While we have released osu! on mobile platforms to maximise the number of people that can enjoy the game, our focus is still on the PC version.
Your experience will not be perfect, and may even feel subpar compared to games which are made mobile-first.
Please bear with us as we continue to improve the game for you!");

private static string getKey(string key) => $@"{prefix}:{key}";
}
}
7 changes: 5 additions & 2 deletions osu.Game/Overlays/Dialog/PopupDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ public LocalisableString BodyText
return;

bodyText = value;

body.Text = value;
body.TextAnchor = bodyText.ToString().Contains('\n') ? Anchor.TopLeft : Anchor.TopCentre;
}
}

Expand Down Expand Up @@ -210,13 +212,12 @@ protected PopupDialog()
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
TextAnchor = Anchor.TopCentre,
Padding = new MarginPadding { Horizontal = 15 },
Padding = new MarginPadding { Horizontal = 15, Bottom = 10 },
},
body = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 18))
{
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
TextAnchor = Anchor.TopCentre,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Horizontal = 15 },
Expand Down Expand Up @@ -301,13 +302,15 @@ protected override void PopIn()
{
content.ScaleTo(0.7f);
ring.ResizeTo(ringMinifiedSize);
icon.ScaleTo(0f);
}

content
.ScaleTo(1, 750, Easing.OutElasticHalf)
.FadeIn(ENTER_DURATION, Easing.OutQuint);

ring.ResizeTo(ringSize, ENTER_DURATION * 1.5f, Easing.OutQuint);
icon.Delay(100).ScaleTo(1, ENTER_DURATION * 1.5f, Easing.OutQuint);
}

protected override void PopOut()
Expand Down
53 changes: 48 additions & 5 deletions osu.Game/Screens/Menu/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Framework.Screens;
using osu.Framework.Threading;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Graphics;
Expand All @@ -39,6 +41,7 @@
using osu.Game.Seasonal;
using osuTK;
using osuTK.Graphics;
using osu.Game.Localisation;

namespace osu.Game.Screens.Menu
{
Expand Down Expand Up @@ -87,6 +90,7 @@ public partial class MainMenu : OsuScreen, IHandlePresentBeatmap, IKeyBindingHan

private Bindable<double> holdDelay;
private Bindable<bool> loginDisplayed;
private Bindable<bool> showMobileDisclaimer;

private HoldToExitGameOverlay holdToExitGameOverlay;

Expand All @@ -111,6 +115,7 @@ private void load(BeatmapListingOverlay beatmapListing, SettingsOverlay settings
{
holdDelay = config.GetBindable<double>(OsuSetting.UIHoldActivationDelay);
loginDisplayed = statics.GetBindable<bool>(Static.LoginOverlayDisplayed);
showMobileDisclaimer = config.GetBindable<bool>(OsuSetting.ShowMobileDisclaimer);

if (host.CanExit)
{
Expand Down Expand Up @@ -255,6 +260,9 @@ public override void OnEntering(ScreenTransitionEvent e)
[CanBeNull]
private Drawable proxiedLogo;

[CanBeNull]
private ScheduledDelegate mobileDisclaimerSchedule;

protected override void LogoArriving(OsuLogo logo, bool resuming)
{
base.LogoArriving(logo, resuming);
Expand All @@ -275,27 +283,42 @@ protected override void LogoArriving(OsuLogo logo, bool resuming)

sideFlashes.Delay(FADE_IN_DURATION).FadeIn(64, Easing.InQuint);
}
else if (!api.IsLoggedIn || api.State.Value == APIState.RequiresSecondFactorAuth)
else
{
// copy out old action to avoid accidentally capturing logo.Action in closure, causing a self-reference loop.
var previousAction = logo.Action;

// we want to hook into logo.Action to display the login overlay, but also preserve the return value of the old action.
// we want to hook into logo.Action to display certain overlays, but also preserve the return value of the old action.
// therefore pass the old action to displayLogin, so that it can return that value.
// this ensures that the OsuLogo sample does not play when it is not desired.
logo.Action = () => displayLogin(previousAction);
logo.Action = () => onLogoClick(previousAction);
}
}

bool displayLogin(Func<bool> originalAction)
private bool onLogoClick(Func<bool> originalAction)
{
if (!api.IsLoggedIn || api.State.Value == APIState.RequiresSecondFactorAuth)
{
if (!loginDisplayed.Value)
{
Scheduler.AddDelayed(() => login?.Show(), 500);
loginDisplayed.Value = true;
}
}

return originalAction.Invoke();
if (showMobileDisclaimer.Value)
{
mobileDisclaimerSchedule?.Cancel();
mobileDisclaimerSchedule = Scheduler.AddDelayed(() =>
{
dialogOverlay.Push(new MobileDisclaimerDialog(() =>
{
showMobileDisclaimer.Value = false;
}));
}, 500);
}

return originalAction.Invoke();
}

protected override void LogoSuspending(OsuLogo logo)
Expand Down Expand Up @@ -443,5 +466,25 @@ public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
{
}

private partial class MobileDisclaimerDialog : PopupDialog
{
public MobileDisclaimerDialog(Action confirmed)
{
HeaderText = ButtonSystemStrings.MobileDisclaimerHeader;
BodyText = ButtonSystemStrings.MobileDisclaimerBody;

Icon = FontAwesome.Solid.SmileBeam;

Buttons = new PopupDialogButton[]
{
new PopupDialogOkButton
{
Text = "Understood",
Action = confirmed,
},
};
}
}
}
}

0 comments on commit b469885

Please sign in to comment.