mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 16:43:52 +09:00
Display readable tablet notifications and link to supported list page
This commit is contained in:
@ -24,6 +24,7 @@ using osu.Framework.Graphics.Sprites;
|
|||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Framework.Input.Handlers.Tablet;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
@ -187,7 +188,8 @@ namespace osu.Game
|
|||||||
{
|
{
|
||||||
this.args = args;
|
this.args = args;
|
||||||
|
|
||||||
forwardLoggedErrorsToNotifications();
|
forwardRuntimeLogsToNotifications();
|
||||||
|
forwardTabletLogsToNotifications();
|
||||||
|
|
||||||
SentryLogger = new SentryLogger(this);
|
SentryLogger = new SentryLogger(this);
|
||||||
}
|
}
|
||||||
@ -992,7 +994,7 @@ namespace osu.Game
|
|||||||
overlay.Depth = (float)-Clock.CurrentTime;
|
overlay.Depth = (float)-Clock.CurrentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void forwardLoggedErrorsToNotifications()
|
private void forwardRuntimeLogsToNotifications()
|
||||||
{
|
{
|
||||||
int recentLogCount = 0;
|
int recentLogCount = 0;
|
||||||
|
|
||||||
@ -1033,6 +1035,49 @@ namespace osu.Game
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void forwardTabletLogsToNotifications()
|
||||||
|
{
|
||||||
|
bool notifyOnWarning = true;
|
||||||
|
|
||||||
|
Logger.NewEntry += entry =>
|
||||||
|
{
|
||||||
|
if (entry.Level < LogLevel.Important || entry.LoggerName != ITabletHandler.LOGGER_NAME)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (entry.Level == LogLevel.Error)
|
||||||
|
{
|
||||||
|
Schedule(() => Notifications.Post(new SimpleNotification
|
||||||
|
{
|
||||||
|
Text = $"Encountered tablet error: \"{entry.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;
|
private Task asyncLoadStream;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -124,6 +124,8 @@ namespace osu.Game
|
|||||||
|
|
||||||
protected SessionStatics SessionStatics { get; private set; }
|
protected SessionStatics SessionStatics { get; private set; }
|
||||||
|
|
||||||
|
protected OsuColour Colours { get; private set; }
|
||||||
|
|
||||||
protected BeatmapManager BeatmapManager { get; private set; }
|
protected BeatmapManager BeatmapManager { get; private set; }
|
||||||
|
|
||||||
protected BeatmapModelDownloader BeatmapDownloader { get; private set; }
|
protected BeatmapModelDownloader BeatmapDownloader { get; private set; }
|
||||||
@ -308,7 +310,7 @@ namespace osu.Game
|
|||||||
dependencies.CacheAs(powerStatus);
|
dependencies.CacheAs(powerStatus);
|
||||||
|
|
||||||
dependencies.Cache(SessionStatics = new SessionStatics());
|
dependencies.Cache(SessionStatics = new SessionStatics());
|
||||||
dependencies.Cache(new OsuColour());
|
dependencies.Cache(Colours = new OsuColour());
|
||||||
|
|
||||||
RegisterImportHandler(BeatmapManager);
|
RegisterImportHandler(BeatmapManager);
|
||||||
RegisterImportHandler(ScoreManager);
|
RegisterImportHandler(ScoreManager);
|
||||||
|
Reference in New Issue
Block a user