-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
84 lines (77 loc) · 1.85 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
#if MONOMAC
using MonoMac.AppKit;
using MonoMac.Foundation;
#elif __IOS__ || __TVOS__
using Foundation;
using UIKit;
#endif
#endregion
namespace Badass_Teroids
{
#if __IOS__ || __TVOS__
[Register("AppDelegate")]
class Program : UIApplicationDelegate
#else
static class Program
#endif
{
private static BadassGame game;
internal static void RunGame()
{
game = new BadassGame();
game.Run();
#if !__IOS__ && !__TVOS__
game.Dispose();
#endif
}
/// <summary>
/// The main entry point for the application.
/// </summary>
#if !MONOMAC && !__IOS__ && !__TVOS__
[STAThread]
#endif
static void Main(string[] args)
{
#if MONOMAC
NSApplication.Init ();
using (var p = new NSAutoreleasePool ()) {
NSApplication.SharedApplication.Delegate = new AppDelegate();
NSApplication.Main(args);
}
#elif __IOS__ || __TVOS__
UIApplication.Main(args, null, "AppDelegate");
#else
RunGame();
#endif
}
#if __IOS__ || __TVOS__
public override void FinishedLaunching(UIApplication app)
{
RunGame();
}
#endif
}
#if MONOMAC
class AppDelegate : NSApplicationDelegate
{
public override void FinishedLaunching (MonoMac.Foundation.NSObject notification)
{
AppDomain.CurrentDomain.AssemblyResolve += (object sender, ResolveEventArgs a) => {
if (a.Name.StartsWith("MonoMac")) {
return typeof(MonoMac.AppKit.AppKitFramework).Assembly;
}
return null;
};
Program.RunGame();
}
public override bool ApplicationShouldTerminateAfterLastWindowClosed (NSApplication sender)
{
return true;
}
}
#endif
}