Skip to content

Commit

Permalink
Subclass to SDLWindow for better readability
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Jan 9, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent aab562f commit 554b909
Showing 8 changed files with 10 additions and 18 deletions.
1 change: 1 addition & 0 deletions osu-framework.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -317,6 +317,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PM/@EntryIndexedValue">PM</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RGB/@EntryIndexedValue">RGB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RNG/@EntryIndexedValue">RNG</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SDL/@EntryIndexedValue">SDL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SHA/@EntryIndexedValue">SHA</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RGB/@EntryIndexedValue">RGB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SRGB/@EntryIndexedValue">SRGB</s:String>
4 changes: 2 additions & 2 deletions osu.Framework/Input/GameWindowTextInput.cs
Original file line number Diff line number Diff line change
@@ -37,15 +37,15 @@ public string GetPendingText()

public void Deactivate(object sender)
{
if (window is Window win)
if (window is SDLWindow win)
win.KeyTyped -= HandleKeyTyped;
else
window.KeyPress -= HandleKeyPress;
}

public void Activate(object sender)
{
if (window is Window win)
if (window is SDLWindow win)
win.KeyTyped += HandleKeyTyped;
else
window.KeyPress += HandleKeyPress;
2 changes: 1 addition & 1 deletion osu.Framework/Input/Handlers/Keyboard/KeyboardHandler.cs
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ public class KeyboardHandler : InputHandler

public override bool Initialize(GameHost host)
{
if (!(host.Window is Window window))
if (!(host.Window is SDLWindow window))
return false;

Enabled.BindValueChanged(e =>
4 changes: 2 additions & 2 deletions osu.Framework/Platform/GameHost.cs
Original file line number Diff line number Diff line change
@@ -402,7 +402,7 @@ public async Task<Image<Rgba32>> TakeScreenshotAsync()

DrawThread.Scheduler.Add(() =>
{
if (Window is Window win)
if (Window is SDLWindow win)
win.MakeCurrent();
else if (GraphicsContext.CurrentContext == null)
throw new GraphicsContextMissingException();
@@ -547,7 +547,7 @@ public void Run(Game game)
{
if (Window != null)
{
if (Window is Window window)
if (Window is SDLWindow window)
{
window.KeyDown += keyDown;
window.Update += handleInput;
4 changes: 2 additions & 2 deletions osu.Framework/Platform/Linux/LinuxGameHost.cs
Original file line number Diff line number Diff line change
@@ -23,11 +23,11 @@ protected override void SetupForRun()
}

protected override IWindow CreateWindow() =>
!UseSdl ? (IWindow)new LinuxGameWindow() : new Window();
!UseSdl ? (IWindow)new LinuxGameWindow() : new SDLWindow();

protected override Storage GetStorage(string baseName) => new LinuxStorage(baseName, this);

public override Clipboard GetClipboard() =>
Window is Window || (Window as LinuxGameWindow)?.IsSdl == true ? (Clipboard)new SdlClipboard() : new LinuxClipboard();
Window is SDLWindow || (Window as LinuxGameWindow)?.IsSdl == true ? (Clipboard)new SdlClipboard() : new LinuxClipboard();
}
}
2 changes: 1 addition & 1 deletion osu.Framework/Platform/MacOS/MacOSGameHost.cs
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ internal MacOSGameHost(string gameName, bool bindIPC = false, ToolkitOptions too
}

protected override IWindow CreateWindow() =>
!UseSdl ? (IWindow)new MacOSGameWindow() : new Window();
!UseSdl ? (IWindow)new MacOSGameWindow() : new SDLWindow();

protected override Storage GetStorage(string baseName) => new MacOSStorage(baseName, this);

9 changes: 0 additions & 9 deletions osu.Framework/Platform/Window.cs
Original file line number Diff line number Diff line change
@@ -232,15 +232,6 @@ public bool VerticalSync

#region Constructors

/// <summary>
/// Convenience constructor that uses <see cref="Sdl2WindowBackend"/> and
/// <see cref="PassthroughGraphicsBackend"/>.
/// </summary>
public Window()
: this(new Sdl2WindowBackend(), new PassthroughGraphicsBackend())
{
}

/// <summary>
/// Creates a new <see cref="Window"/> using the specified window and graphics backends.
/// </summary>
2 changes: 1 addition & 1 deletion osu.Framework/Platform/Windows/WindowsGameHost.cs
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ protected override void SetupForRun()
}

protected override IWindow CreateWindow() =>
!UseSdl ? (IWindow)new WindowsGameWindow() : new Window();
!UseSdl ? (IWindow)new WindowsGameWindow() : new SDLWindow();

protected override void Dispose(bool isDisposing)
{

0 comments on commit 554b909

Please sign in to comment.