mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:07:52 +08:00
Merge pull request #20344 from frenzibyte/better-tablet-notifications
Improve tablet error/warning notifications messaging
This commit is contained in:
commit
8a7526aaa3
@ -52,7 +52,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.831.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.916.1" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.922.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="Transitive Dependencies">
|
||||
<!-- Realm needs to be directly referenced in all Xamarin projects, as it will not pull in its transitive dependencies otherwise. -->
|
||||
|
@ -24,6 +24,7 @@ using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Input.Handlers.Tablet;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Screens;
|
||||
@ -187,7 +188,8 @@ namespace osu.Game
|
||||
{
|
||||
this.args = args;
|
||||
|
||||
forwardLoggedErrorsToNotifications();
|
||||
forwardGeneralLogsToNotifications();
|
||||
forwardTabletLogsToNotifications();
|
||||
|
||||
SentryLogger = new SentryLogger(this);
|
||||
}
|
||||
@ -994,7 +996,7 @@ namespace osu.Game
|
||||
overlay.Depth = (float)-Clock.CurrentTime;
|
||||
}
|
||||
|
||||
private void forwardLoggedErrorsToNotifications()
|
||||
private void forwardGeneralLogsToNotifications()
|
||||
{
|
||||
int recentLogCount = 0;
|
||||
|
||||
@ -1002,7 +1004,7 @@ namespace osu.Game
|
||||
|
||||
Logger.NewEntry += entry =>
|
||||
{
|
||||
if (entry.Level < LogLevel.Important || entry.Target == null) return;
|
||||
if (entry.Level < LogLevel.Important || entry.Target > LoggingTarget.Database) return;
|
||||
|
||||
const int short_term_display_limit = 3;
|
||||
|
||||
@ -1035,6 +1037,52 @@ namespace osu.Game
|
||||
};
|
||||
}
|
||||
|
||||
private void forwardTabletLogsToNotifications()
|
||||
{
|
||||
const string tablet_prefix = @"[Tablet] ";
|
||||
bool notifyOnWarning = true;
|
||||
|
||||
Logger.NewEntry += entry =>
|
||||
{
|
||||
if (entry.Level < LogLevel.Important || entry.Target != LoggingTarget.Input || !entry.Message.StartsWith(tablet_prefix, StringComparison.OrdinalIgnoreCase))
|
||||
return;
|
||||
|
||||
string message = entry.Message.Replace(tablet_prefix, string.Empty);
|
||||
|
||||
if (entry.Level == LogLevel.Error)
|
||||
{
|
||||
Schedule(() => Notifications.Post(new SimpleNotification
|
||||
{
|
||||
Text = $"Encountered tablet error: \"{message}\"",
|
||||
Icon = FontAwesome.Solid.PenSquare,
|
||||
IconColour = Colours.RedDark,
|
||||
}));
|
||||
}
|
||||
else if (notifyOnWarning)
|
||||
{
|
||||
Schedule(() => Notifications.Post(new SimpleNotification
|
||||
{
|
||||
Text = @"Encountered tablet warning, your tablet may not function correctly. Click here for a list of all tablets supported.",
|
||||
Icon = FontAwesome.Solid.PenSquare,
|
||||
IconColour = Colours.YellowDark,
|
||||
Activated = () =>
|
||||
{
|
||||
OpenUrlExternally("https://opentabletdriver.net/Tablets", true);
|
||||
return true;
|
||||
}
|
||||
}));
|
||||
|
||||
notifyOnWarning = false;
|
||||
}
|
||||
};
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
ITabletHandler tablet = Host.AvailableInputHandlers.OfType<ITabletHandler>().SingleOrDefault();
|
||||
tablet?.Tablet.BindValueChanged(_ => notifyOnWarning = true, true);
|
||||
});
|
||||
}
|
||||
|
||||
private Task asyncLoadStream;
|
||||
|
||||
/// <summary>
|
||||
|
@ -125,6 +125,8 @@ namespace osu.Game
|
||||
|
||||
protected SessionStatics SessionStatics { get; private set; }
|
||||
|
||||
protected OsuColour Colours { get; private set; }
|
||||
|
||||
protected BeatmapManager BeatmapManager { get; private set; }
|
||||
|
||||
protected BeatmapModelDownloader BeatmapDownloader { get; private set; }
|
||||
@ -311,7 +313,7 @@ namespace osu.Game
|
||||
dependencies.CacheAs(powerStatus);
|
||||
|
||||
dependencies.Cache(SessionStatics = new SessionStatics());
|
||||
dependencies.Cache(new OsuColour());
|
||||
dependencies.Cache(Colours = new OsuColour());
|
||||
|
||||
RegisterImportHandler(BeatmapManager);
|
||||
RegisterImportHandler(ScoreManager);
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
@ -41,6 +42,12 @@ namespace osu.Game.Overlays.Notifications
|
||||
}
|
||||
}
|
||||
|
||||
public ColourInfo IconColour
|
||||
{
|
||||
get => IconContent.Colour;
|
||||
set => IconContent.Colour = value;
|
||||
}
|
||||
|
||||
private TextFlowContainer? textDrawable;
|
||||
|
||||
private SpriteIcon? iconDrawable;
|
||||
|
@ -35,7 +35,7 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Realm" Version="10.15.1" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2022.916.1" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2022.922.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.831.0" />
|
||||
<PackageReference Include="Sentry" Version="3.20.1" />
|
||||
<PackageReference Include="SharpCompress" Version="0.32.2" />
|
||||
|
@ -61,7 +61,7 @@
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="Package References">
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2022.916.1" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2022.922.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.831.0" />
|
||||
</ItemGroup>
|
||||
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net6.0) -->
|
||||
@ -82,7 +82,7 @@
|
||||
<PackageReference Include="DiffPlex" Version="1.7.1" />
|
||||
<PackageReference Include="Humanizer" Version="2.14.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2022.916.1" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2022.922.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.32.1" />
|
||||
<PackageReference Include="NUnit" Version="3.13.3" />
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
|
Loading…
Reference in New Issue
Block a user