File: MonoGameGamerServicesHelper.cs

package info (click to toggle)
monogame 2.5.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 6,060 kB
  • ctags: 10,325
  • sloc: cs: 65,996; xml: 591; makefile: 22; ansic: 8
file content (89 lines) | stat: -rw-r--r-- 2,580 bytes parent folder | download | duplicates (2)
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
85
86
87
88
89
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Drawing;

using MonoMac.Foundation;
using MonoMac.AppKit;

namespace Microsoft.Xna.Framework.GamerServices
{
	internal static class MonoGameGamerServicesHelper
	{
		internal static void ShowSigninSheet ()
		{

			NSApplication NSApp = NSApplication.SharedApplication;
			NSWindow gameWindow = NSApp.MainWindow;

			SigninController controller = new SigninController ();

			NSWindow window = controller.Window;

			// Something has happened with BeginSheet and needs to be looked into.
			// Until then just use modal for now.
			RectangleF frame = window.Frame;
			PointF location = new PointF (gameWindow.Frame.Bottom, gameWindow.Frame.Left);
			location = new PointF(gameWindow.Frame.Location.X, gameWindow.Frame.Location.Y);

			window.SetFrameOrigin(location);
			NSApp.BeginInvokeOnMainThread(delegate {
				Guide.isVisible = true;
//				NSApp.BeginSheet (window, gameWindow);
				NSApp.RunModalForWindow (window);
//				// sheet is up here.....
//
//				NSApp.EndSheet (window);
				window.OrderOut (gameWindow);
				Guide.isVisible = false;
//
			});
			//window.MakeKeyAndOrderFront(gameWindow);
//				SignedInGamer sig = new SignedInGamer();
//				sig.DisplayName = "MonoMac Gamer";
//				sig.Gamertag = "MonoMac Gamer";
//				sig.InternalIdentifier = Guid.NewGuid();
//
//				Gamer.SignedInGamers.Add(sig);
		}

		internal static List<MonoGameLocalGamerProfile> DeserializeProfiles ()
		{
			var path = StorageLocation;
			var fileName = Path.Combine(path, "LocalProfiles.dat");
			var profiles  = new List<MonoGameLocalGamerProfile> ();
			try {
				using (Stream stream = File.Open (fileName, FileMode.Open)) {
					BinaryFormatter bin = new BinaryFormatter ();

					profiles = (List<MonoGameLocalGamerProfile>)bin.Deserialize (stream);
				}
				
			} catch (IOException) {
			}	
			return profiles;
		}

		internal static void SerializeProfiles (List<MonoGameLocalGamerProfile> profiles)
		{
			var path = StorageLocation;
			var fileName = Path.Combine(path, "LocalProfiles.dat");
			try {
				using (Stream stream = File.Open (fileName, FileMode.Create)) {
					BinaryFormatter bin = new BinaryFormatter ();
					bin.Serialize (stream, profiles);
				}
			} catch (IOException) {
			}	
		}
		
		internal static string StorageLocation 
		{
			get {
				return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
			}	
		}
	}
}