Esempio n. 1
0
        public Game()
        {
            // Initialize collections
            _services = new GameServiceContainer();
            _gameComponentCollection = new GameComponentCollection();

            _gameComponentCollection.ComponentAdded += Handle_gameComponentCollectionComponentAdded;

            // The default for Windows is 480 x 800
            //RectangleF frame = NSScreen.MainScreen.Frame;
            RectangleF frame = new RectangleF(0, 0, Microsoft.Xna.Framework.Graphics.PresentationParameters._defaultBackBufferWidth,
                                              Microsoft.Xna.Framework.Graphics.PresentationParameters._defaultBackBufferHeight);

            //Create a window
            _mainWindow = new MacGameNSWindow(frame, NSWindowStyle.Titled | NSWindowStyle.Closable, NSBackingStore.Buffered, true);

            // Perform any other window configuration you desire
            _mainWindow.IsOpaque = true;
            _mainWindow.EnableCursorRects();
            _gameWindow      = new GameWindow(frame);
            _gameWindow.game = this;

            _mainWindow.ContentView.AddSubview(_gameWindow);
            _mainWindow.AcceptsMouseMovedEvents = false;
            _mainWindow.Center();
            // Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime   = new GameTime();

            //Set the current directory.
            // We set the current directory to the ResourcePath on Mac
            Directory.SetCurrentDirectory(NSBundle.MainBundle.ResourcePath);

            //Tao.Sdl.Sdl.SDL_Init(Tao.Sdl.Sdl.SDL_INIT_JOYSTICK);

            // Leave these here for when we implement the Activate and Deactivated
            _mainWindow.DidBecomeKey += delegate(object sender, EventArgs e) {
                //if (!IsMouseVisible)
                //	_gameWindow.HideCursor();
                //Console.WriteLine("BecomeKey");
            };

            _mainWindow.DidResignKey += delegate(object sender, EventArgs e) {
                //if (!IsMouseVisible)
                //	_gameWindow.UnHideCursor();
                //Console.WriteLine("ResignKey");
            };

            _mainWindow.DidBecomeMain += delegate(object sender, EventArgs e) {
                //if (!IsMouseVisible)
                //_gameWindow.HideCursor();
                ////Console.WriteLine("BecomeMain");
            };

            _mainWindow.DidResignMain += delegate(object sender, EventArgs e) {
                //if (!IsMouseVisible)
                //	_gameWindow.UnHideCursor();
                //Console.WriteLine("ResignMain");
            };
        }
Esempio n. 2
0
        private void InitializeMainWindow()
        {
            var frame = new RectF(
                0, 0,
                GraphicsDeviceManager.DefaultBackBufferWidth,
                GraphicsDeviceManager.DefaultBackBufferHeight);

            _mainWindow = new MacGameNSWindow(
                frame, NSWindowStyle.Titled | NSWindowStyle.Closable | NSWindowStyle.Miniaturizable,
                NSBackingStore.Buffered, true);

            _mainWindow.WindowController = new NSWindowController(_mainWindow);
            _mainWindow.Delegate         = new MainWindowDelegate(this);

            _mainWindow.IsOpaque = true;
            _mainWindow.EnableCursorRects();
            _mainWindow.AcceptsMouseMovedEvents = false;
            _mainWindow.Center();

            if (GameWindow.CreateWindowDelegate == null)
            {
                _gameWindow = new GameWindow(Game, frame);
            }
            else
            {
                _gameWindow = GameWindow.CreateWindowDelegate(Game, frame);
            }
            Window = _gameWindow;
            _mainWindow.ContentView.AddSubview(_gameWindow);
        }
Esempio n. 3
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                // No need to dispose _gameWindow.  It will be released by the
                // nearest NSAutoreleasePool.
                if (_gameWindow != null)
                {
                    _gameWindow = null;
                }

                // No need to dispose _mainWindow.  It will be released by the
                // nearest NSAutoreleasePool.
                if (_mainWindow != null)
                {
                    _mainWindow = null;
                }
            }

            base.Dispose(disposing);
        }
Esempio n. 4
0
        private void InitializeMainWindow()
        {
            RectangleF frame = new RectangleF(
                0, 0,
                PresentationParameters._defaultBackBufferWidth,
                PresentationParameters._defaultBackBufferHeight);

            _mainWindow = new MacGameNSWindow(
                frame, NSWindowStyle.Titled | NSWindowStyle.Closable,
                NSBackingStore.Buffered, true);

            _mainWindow.WindowController = new NSWindowController(_mainWindow);
            _mainWindow.Delegate         = new MainWindowDelegate(this);

            _mainWindow.IsOpaque = true;
            _mainWindow.EnableCursorRects();
            _mainWindow.AcceptsMouseMovedEvents = false;
            _mainWindow.Center();

            _gameWindow = new GameWindow(Game, frame);
            Window      = _gameWindow;
            _mainWindow.ContentView.AddSubview(_gameWindow);
        }
Esempio n. 5
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                // No need to dispose _gameWindow.  It will be released by the
                // nearest NSAutoreleasePool.
                if (_gameWindow != null)
                    _gameWindow = null;

                // No need to dispose _mainWindow.  It will be released by the
                // nearest NSAutoreleasePool.
                if (_mainWindow != null)
                    _mainWindow = null;
            }

            base.Dispose(disposing);
        }
Esempio n. 6
0
        private void InitializeMainWindow()
        {
            RectangleF frame = new RectangleF(
                0, 0,
                GraphicsDeviceManager.DefaultBackBufferWidth,
                GraphicsDeviceManager.DefaultBackBufferHeight);

            _mainWindow = new MacGameNSWindow(
				frame, NSWindowStyle.Titled | NSWindowStyle.Closable | NSWindowStyle.Miniaturizable,
                NSBackingStore.Buffered, true);

            _mainWindow.WindowController = new NSWindowController(_mainWindow);
            _mainWindow.Delegate = new MainWindowDelegate(this);

            _mainWindow.IsOpaque = true;
            _mainWindow.EnableCursorRects();
            _mainWindow.AcceptsMouseMovedEvents = false;
            _mainWindow.Center();

			if (GameWindow.CreateWindowDelegate == null)
            	_gameWindow = new GameWindow(Game, frame);
			else
				_gameWindow = GameWindow.CreateWindowDelegate(Game, frame);
            Window = _gameWindow;
            _mainWindow.ContentView.AddSubview(_gameWindow);
        }
Esempio n. 7
0
        public Game()
        {
            // Initialize collections
            _services = new GameServiceContainer ();
            _gameComponentCollection = new GameComponentCollection ();

            _gameComponentCollection.ComponentAdded += Handle_gameComponentCollectionComponentAdded;

            // The default for Windows is 480 x 800
            //RectangleF frame = NSScreen.MainScreen.Frame;
            RectangleF frame = new RectangleF(0,0,Microsoft.Xna.Framework.Graphics.PresentationParameters._defaultBackBufferWidth,
                Microsoft.Xna.Framework.Graphics.PresentationParameters._defaultBackBufferHeight);

            //Create a window
            _mainWindow = new MacGameNSWindow (frame, NSWindowStyle.Titled | NSWindowStyle.Closable, NSBackingStore.Buffered, true);

            // Perform any other window configuration you desire
            _mainWindow.IsOpaque = true;
            _mainWindow.EnableCursorRects();
            _gameWindow = new GameWindow (frame);
            _gameWindow.game = this;

            _mainWindow.ContentView.AddSubview (_gameWindow);
            _mainWindow.AcceptsMouseMovedEvents = false;
            _mainWindow.Center();
            // Initialize GameTime
            _updateGameTime = new GameTime ();
            _drawGameTime = new GameTime ();

            //Set the current directory.
            // We set the current directory to the ResourcePath on Mac
            Directory.SetCurrentDirectory(NSBundle.MainBundle.ResourcePath);

            //Tao.Sdl.Sdl.SDL_Init(Tao.Sdl.Sdl.SDL_INIT_JOYSTICK);

            // Leave these here for when we implement the Activate and Deactivated
            _mainWindow.DidBecomeKey += delegate(object sender, EventArgs e) {
                //if (!IsMouseVisible)
                //	_gameWindow.HideCursor();
                //Console.WriteLine("BecomeKey");
            };

            _mainWindow.DidResignKey += delegate(object sender, EventArgs e) {
                //if (!IsMouseVisible)
                //	_gameWindow.UnHideCursor();
                //Console.WriteLine("ResignKey");
            };

            _mainWindow.DidBecomeMain += delegate(object sender, EventArgs e) {
                //if (!IsMouseVisible)
                    //_gameWindow.HideCursor();
                ////Console.WriteLine("BecomeMain");
            };

            _mainWindow.DidResignMain += delegate(object sender, EventArgs e) {
                //if (!IsMouseVisible)
                //	_gameWindow.UnHideCursor();
                //Console.WriteLine("ResignMain");
            };
        }
Esempio n. 8
0
        private void InitializeMainWindow()
        {
            RectangleF frame = new RectangleF(
                0, 0,
                PresentationParameters._defaultBackBufferWidth,
                PresentationParameters._defaultBackBufferHeight);

            _mainWindow = new MacGameNSWindow(
                frame, NSWindowStyle.Titled | NSWindowStyle.Closable,
                NSBackingStore.Buffered, true);

            _mainWindow.WindowController = new NSWindowController(_mainWindow);
            _mainWindow.Delegate = new MainWindowDelegate(this);

            _mainWindow.IsOpaque = true;
            _mainWindow.EnableCursorRects();
            _mainWindow.AcceptsMouseMovedEvents = false;
            _mainWindow.Center();

            _gameWindow = new GameWindow(Game, frame);
            Window = _gameWindow;
            _mainWindow.ContentView.AddSubview(_gameWindow);
        }