Skip to content

Commit

Permalink
Add HostOptions.FriendlyGameName and set as SDL APP_NAME hint
Browse files Browse the repository at this point in the history
  • Loading branch information
FreezyLemon committed Apr 21, 2024
1 parent af8bbd2 commit e1bdd85
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions osu.Framework/HostOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,14 @@ public class HostOptions
/// If the SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR environment variable is set, this property will have no effect.
/// </remarks>
public bool BypassCompositor { get; set; } = true;

/// <summary>
/// The friendly name of the game to be hosted. This is used to display the name to the user,
/// for example in the window title bar or in OS windows and prompts.
/// </summary>
/// <remarks>
/// If empty, GameHost will choose a default name based on the gameName.
/// </remarks>
public string FriendlyGameName { get; set; } = string.Empty;
}
}
5 changes: 5 additions & 0 deletions osu.Framework/Platform/GameHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@ protected GameHost([NotNull] string gameName, [CanBeNull] HostOptions options =
{
Options = options ?? new HostOptions();

if (string.IsNullOrEmpty(Options.FriendlyGameName))
{
Options.FriendlyGameName = $@"osu!framework (running ""{gameName}"")";
}

Name = gameName;

JsonConvert.DefaultSettings = () => new JsonSerializerSettings
Expand Down
3 changes: 3 additions & 0 deletions osu.Framework/Platform/SDL3GameHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using osu.Framework.Input.Handlers.Tablet;
using osu.Framework.Input.Handlers.Touch;
using osu.Framework.Platform.SDL;
using SDL;

namespace osu.Framework.Platform
{
Expand All @@ -21,6 +22,8 @@ public abstract class SDL3GameHost : GameHost
protected SDL3GameHost(string gameName, HostOptions? options = null)
: base(gameName, options)
{
if (this is not HeadlessGameHost)
SDL3.SDL_SetHint(SDL3.SDL_HINT_APP_NAME, Options.FriendlyGameName);
}

protected override TextInputSource CreateTextInput()
Expand Down

0 comments on commit e1bdd85

Please sign in to comment.