A game framework written with osu! in mind.
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2// See the LICENCE file in the repository root for full licence text.
3
4using System;
5using System.Collections.Generic;
6using JetBrains.Annotations;
7using osu.Framework.Configuration;
8using osu.Framework.Graphics;
9using osu.Framework.Platform;
10using osuTK;
11using osuTK.Graphics;
12using WindowState = osu.Framework.Platform.WindowState;
13
14namespace osu.Framework.iOS
15{
16 public class IOSGameWindow : OsuTKWindow
17 {
18 [NotNull]
19 private readonly IOSGameView gameView;
20
21 public override void SetupWindow(FrameworkConfigManager config)
22 {
23 Resize += onResize;
24 }
25
26 public IOSGameWindow([NotNull] IOSGameView gameView)
27 : base(gameView)
28 {
29 this.gameView = gameView;
30 }
31
32 public override IGraphicsContext Context => gameView.GraphicsContext;
33
34 public override bool Focused => true;
35
36 public override WindowState WindowState
37 {
38 get => WindowState.Normal;
39 set { }
40 }
41
42 protected override DisplayDevice CurrentDisplayDevice
43 {
44 get => DisplayDevice.Default;
45 set => throw new InvalidOperationException();
46 }
47
48 protected override IEnumerable<WindowMode> DefaultSupportedWindowModes => new[]
49 {
50 Configuration.WindowMode.Fullscreen,
51 };
52
53 public override void Run()
54 {
55 // do nothing for iOS
56 }
57
58 private void onResize(object sender, EventArgs e)
59 {
60 SafeAreaPadding.Value = new MarginPadding
61 {
62 Top = (float)gameView.SafeArea.Top * gameView.Scale,
63 Left = (float)gameView.SafeArea.Left * gameView.Scale,
64 Bottom = (float)gameView.SafeArea.Bottom * gameView.Scale,
65 Right = (float)gameView.SafeArea.Right * gameView.Scale
66 };
67 }
68 }
69}