Ejemplo n.º 1
0
        public MacGamePlatform(Game game) :
            base(game)
        {
            _state = RunState.NotStarted;
            game.Services.AddService(typeof(MacGamePlatform), this);

            // Setup our OpenALSoundController to handle our SoundBuffer pools
            try
            {
                OpenALSoundController soundControllerInstance = OpenALSoundController.GetInstance;
            }
            catch (DllNotFoundException ex)
            {
                throw (new NoAudioHardwareException("Failed to init OpenALSoundController", ex));
            }

            InitializeMainWindow();

            var path = NSBundle.MainBundle.ResourcePath;

            if (Directory.Exists(path))
            {
                // We set the current directory to the ResourcePath on Mac
                Directory.SetCurrentDirectory(NSBundle.MainBundle.ResourcePath);
            }
        }
Ejemplo n.º 2
0
        public iOSGamePlatform(Game game) :
            base(game)
        {
            game.Services.AddService(typeof(iOSGamePlatform), this);

            // Setup our OpenALSoundController to handle our SoundBuffer pools
            soundControllerInstance = OpenALSoundController.GetInstance;

            Directory.SetCurrentDirectory(NSBundle.MainBundle.ResourcePath);

            _applicationObservers = new List <NSObject>();

            UIApplication.SharedApplication.SetStatusBarHidden(true, UIStatusBarAnimation.Fade);

            // Create a full-screen window
            _mainWindow = new UIWindow(UIScreen.MainScreen.Bounds);
            //_mainWindow.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;

            game.Services.AddService(typeof(UIWindow), _mainWindow);

            _viewController = new iOSGameViewController(this);
            game.Services.AddService(typeof(UIViewController), _viewController);
            Window = new iOSGameWindow(_viewController);

            _mainWindow.RootViewController = _viewController;
            _mainWindow.Add(_viewController.View);

            _viewController.InterfaceOrientationChanged += ViewController_InterfaceOrientationChanged;

            Guide.Initialise(game);
        }
Ejemplo n.º 3
0
        public OpenTKGamePlatform(Game game)
            : base(game)
        {
            _view       = new OpenTKGameWindow();
            _view.Game  = game;
            this.Window = _view;

            // Setup our OpenALSoundController to handle our SoundBuffer pools
            try
            {
                soundControllerInstance = OpenALSoundController.GetInstance;
            }
            catch (DllNotFoundException ex)
            {
                throw (new NoAudioHardwareException("Failed to init OpenALSoundController", ex));
            }

#if LINUX
            // also set up SdlMixer to play background music. If one of these functions fails, we will not get any background music (but that should rarely happen)
            Tao.Sdl.Sdl.SDL_InitSubSystem(Tao.Sdl.Sdl.SDL_INIT_AUDIO);
            Tao.Sdl.SdlMixer.Mix_OpenAudio(44100, (short)Tao.Sdl.Sdl.AUDIO_S16SYS, 2, 1024);

            //even though this method is called whenever IsMouseVisible is changed it needs to be called during startup
            //so that the cursor can be put in the correct inital state (hidden)
            OnIsMouseVisibleChanged();
#endif
        }
        public iOSGamePlatform(Game game) :
            base(game)
        {
            game.Services.AddService(typeof(iOSGamePlatform), this);

            // Setup our OpenALSoundController to handle our SoundBuffer pools
            soundControllerInstance = OpenALSoundController.GetInstance;

            //This also runs the TitleContainer static constructor, ensuring it is done on the main thread
            Directory.SetCurrentDirectory(TitleContainer.Location);

            _applicationObservers = new List <NSObject>();

            #if !TVOS
            UIApplication.SharedApplication.SetStatusBarHidden(true, UIStatusBarAnimation.Fade);
            #endif

            // Create a full-screen window
            _mainWindow = new UIWindow(UIScreen.MainScreen.Bounds);
            //_mainWindow.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;

            game.Services.AddService(typeof(UIWindow), _mainWindow);

            _viewController = new iOSGameViewController(this);
            game.Services.AddService(typeof(UIViewController), _viewController);
            Window = new iOSGameWindow(_viewController);

            _mainWindow.Add(_viewController.View);

            _viewController.InterfaceOrientationChanged += ViewController_InterfaceOrientationChanged;

            //(SJ) Why is this called here when it's not in any other project
            //Guide.Initialise(game);
        }
Ejemplo n.º 5
0
        public SdlGamePlatform(Game game)
            : base(game)
        {
            // if we're on Windows, we need to detect the CPU arch and load the correct dlls
            // on other system, the MonoGame.Framework.dll.config handles this
            if (PlatformParameters.DetectWindowsArchitecture)
            {
                NativeHelper.InitDllDirectory();
            }

            _game = game;
            _keys = new List <Keys>();
            Keyboard.SetKeys(_keys);

            Sdl.Version sversion;
            Sdl.GetVersion(out sversion);

            Sdl.Major = sversion.Major;
            Sdl.Minor = sversion.Minor;
            Sdl.Patch = sversion.Patch;

            try
            {
                // HACK: The current development version of SDL
                // returns 2.0.4, to check SDL version we simply
                // need to try and execute a function that's only
                // available in the newer version of it.
                Sdl.Window.SetResizable(IntPtr.Zero, false);
                Sdl.Patch = 5;
            }
            catch { }

            var version = 100 * Sdl.Major + 10 * Sdl.Minor + Sdl.Patch;

            if (version <= 204)
            {
                Debug.WriteLine("Please use SDL 2.0.5 or higher.");
            }

            Sdl.Init((int)(
                         Sdl.InitFlags.Video |
                         Sdl.InitFlags.Joystick |
                         Sdl.InitFlags.GameController |
                         Sdl.InitFlags.Haptic
                         ));

            Sdl.DisableScreenSaver();

            Window = _view = new SdlGameWindow(_game);

            try
            {
                _soundControllerInstance = OpenALSoundController.GetInstance;
            }
            catch (DllNotFoundException ex)
            {
                throw (new NoAudioHardwareException("Failed to init OpenALSoundController", ex));
            }
        }
Ejemplo n.º 6
0
 public OpenTKGamePlatform(Game game)
     : base(game)
 {
     this._view      = new OpenTKGameWindow();
     this._view.Game = game;
     this.Window     = (GameWindow)this._view;
     this.soundControllerInstance = OpenALSoundController.Instance;
     WindowsHelperAccessibilityKeys.AllowAccessibilityShortcutKeys(false);
 }
Ejemplo n.º 7
0
 public OpenTKGamePlatform(Game game)
     : base(game)
 {
     this._view                   = new OpenTKGameWindow();
     this._view.Game              = game;
     this.Window                  = (GameWindow)this._view;
     this.IsMouseVisible          = true;
     this.soundControllerInstance = OpenALSoundController.Instance;
 }
Ejemplo n.º 8
0
        public SDL2_GamePlatform(Game game) : base(game)
        {
            // Set and initialize the SDL2 window
            INTERNAL_window      = new SDL2_GameWindow();
            INTERNAL_window.Game = game;
            this.Window          = INTERNAL_window;

            // Get our OpenALSoundController to handle the SoundBuffer pools
            soundControllerInstance = OpenALSoundController.GetInstance;
        }
Ejemplo n.º 9
0
        private void PlatformInitialize(string fileName)
        {
            // init OpenAL if need be
            OpenALSoundController.EnsureInitialized();

            stream = new OggStream(fileName, OnFinishedPlaying);
            stream.Prepare();

            _duration = stream.GetLength();
        }
Ejemplo n.º 10
0
        public SdlGamePlatform(Game game)
            : base(game)
        {
            // if we're on Windows, we need to detect the CPU arch and load the correct dlls
            // on other system, the MonoGame.Framework.dll.config handles this
            if (PlatformParameters.DetectWindowsArchitecture)
            {
                NativeHelper.InitDllDirectory();
            }

            _game = game;
            _keys = new List <Keys>();
            Keyboard.SetKeys(_keys);

            Sdl.Version sversion;
            Sdl.GetVersion(out sversion);

            Sdl.Major = sversion.Major;
            Sdl.Minor = sversion.Minor;
            Sdl.Patch = sversion.Patch;

            var version = 100 * Sdl.Major + 10 * Sdl.Minor + Sdl.Patch;

            if (version <= 204)
            {
                Debug.WriteLine("Please use SDL 2.0.5 or higher.");
            }

            // Needed so VS can debug the project on Windows
            if (version >= 205 && CurrentPlatform.OS == OS.Windows && Debugger.IsAttached)
            {
                Sdl.SetHint("SDL_WINDOWS_DISABLE_THREAD_NAMING", "1");
            }

            Sdl.Init((int)(
                         Sdl.InitFlags.Video |
                         Sdl.InitFlags.Joystick |
                         Sdl.InitFlags.GameController |
                         Sdl.InitFlags.Haptic
                         ));

            Sdl.DisableScreenSaver();

            GamePad.InitDatabase();
            Window = _view = new SdlGameWindow(_game);

            try
            {
                _soundControllerInstance = OpenALSoundController.GetInstance;
            }
            catch (DllNotFoundException ex)
            {
                throw (new NoAudioHardwareException("Failed to init OpenALSoundController", ex));
            }
        }
Ejemplo n.º 11
0
        public WindowsGamePlatform(Game game)
            : base(game)
        {
            _view       = new WindowsGameWindow();
            _view.Game  = game;
            this.Window = _view;

            // Setup our OpenALSoundController to handle our SoundBuffer pools
            soundControllerInstance = OpenALSoundController.GetInstance;

            //Initialize cursor visibility based on default value
            OnIsMouseVisibleChanged();
        }
Ejemplo n.º 12
0
        public MacGamePlatform(Game game) :
            base(game)
        {
            _state = RunState.NotStarted;
            game.Services.AddService(typeof(MacGamePlatform), this);

            // Setup our OpenALSoundController to handle our SoundBuffer pools
            soundControllerInstance = OpenALSoundController.GetInstance;

            InitializeMainWindow();

            // We set the current directory to the ResourcePath on Mac
            Directory.SetCurrentDirectory(NSBundle.MainBundle.ResourcePath);
        }
Ejemplo n.º 13
0
        public override void Exit()
        {
            //(SJ) Why is this called here when it's not in any other project
            //Net.NetworkSession.Exit();
            Interlocked.Increment(ref isExiting);

            // sound controller must be disposed here
            // so that it doesn't stop the game from disposing
            if (soundControllerInstance != null)
            {
                soundControllerInstance.Dispose();
                soundControllerInstance = null;
            }
            OpenTK.DisplayDevice.Default.RestoreResolution();
        }
Ejemplo n.º 14
0
        public SdlGamePlatform(Game game)
            : base(game)
        {
            _game = game;
            _keys = new List <Keys>();
            Keyboard.SetKeys(_keys);

            Sdl.Version sversion;
            Sdl.GetVersion(out sversion);

            Sdl.Major = sversion.Major;
            Sdl.Minor = sversion.Minor;
            Sdl.Patch = sversion.Patch;

            var version = 100 * Sdl.Major + 10 * Sdl.Minor + Sdl.Patch;

            if (version <= 204)
            {
                Debug.WriteLine("Please use SDL 2.0.5 or higher.");
            }

            // Needed so VS can debug the project on Windows
            if (version >= 205 && CurrentPlatform.OS == OS.Windows && Debugger.IsAttached)
            {
                Sdl.SetHint("SDL_WINDOWS_DISABLE_THREAD_NAMING", "1");
            }

            Sdl.Init((int)(
                         Sdl.InitFlags.Video |
                         Sdl.InitFlags.Joystick |
                         Sdl.InitFlags.GameController |
                         Sdl.InitFlags.Haptic
                         ));

            Sdl.DisableScreenSaver();

            GamePad.InitDatabase();
            Window = _view = new SdlGameWindow(_game);

            try
            {
                _soundControllerInstance = OpenALSoundController.GetInstance;
            }
            catch (DllNotFoundException ex)
            {
                throw (new NoAudioHardwareException("Failed to init OpenALSoundController", ex));
            }
        }
Ejemplo n.º 15
0
        public OpenTKGamePlatform(Game game)
            : base(game)
        {
            _view       = new OpenTKGameWindow(game);
            this.Window = _view;

            // Setup our OpenALSoundController to handle our SoundBuffer pools
            try
            {
                soundControllerInstance = OpenALSoundController.GetInstance;
            }
            catch (DllNotFoundException ex)
            {
                throw (new NoAudioHardwareException("Failed to init OpenALSoundController", ex));
            }
        }
        public OpenTKGamePlatform(Game game)
            : base(game)
        {
            _view       = new OpenTKGameWindow();
            _view.Game  = game;
            this.Window = _view;

            this.IsMouseVisible = true;

            // Setup our OpenALSoundController to handle our SoundBuffer pools
            soundControllerInstance = OpenALSoundController.GetInstance;

#if LINUX
            // also set up SdlMixer to play background music. If one of these functions fails, we will not get any background music (but that should rarely happen)
            Tao.Sdl.Sdl.SDL_InitSubSystem(Tao.Sdl.Sdl.SDL_INIT_AUDIO);
            Tao.Sdl.SdlMixer.Mix_OpenAudio(44100, (short)Tao.Sdl.Sdl.AUDIO_S16SYS, 2, 1024);
#endif
        }
Ejemplo n.º 17
0
        public AndroidGamePlatform(Game game) : base(game)
        {
            Game.Activity.Game           = Game;
            AndroidGameActivity.Paused  += Activity_Paused;
            AndroidGameActivity.Resumed += Activity_Resumed;

            _gameWindow = new AndroidGameWindow(Game.Activity, game);
            Window      = _gameWindow;

            try
            {
                OpenALSoundController soundControllerInstance = OpenALSoundController.GetInstance;
            }
            catch (DllNotFoundException ex)
            {
                throw new NoAudioHardwareException("Failed to init OpenALSoundController", ex);
            }
        }
Ejemplo n.º 18
0
        public iOSGamePlatform(Game game) : base(game)
        {
            game.Services.AddService(typeof(iOSGamePlatform), this);

            // Setup our OpenALSoundController to handle our SoundBuffer pools
            soundControllerInstance = OpenALSoundController.GetInstance;

            //This also runs the TitleContainer static constructor, ensuring it is done on the main thread
            Directory.SetCurrentDirectory(TitleContainer.Location);

            _applicationObservers = new List <NSObject> ();

            UIApplication.SharedApplication.SetStatusBarHidden(true, UIStatusBarAnimation.Fade);

            #region Modification 23-06-2014
            // Move view controller creation before Window creation
            // Create our viewcontroller first, it will have a reference to the AspyCores service lib/obj
            _viewController = new iOSGameViewController(this);
            game.Services.AddService(typeof(AspyViewController), _viewController);

            // Create a full-screen window
            // AspyMod - Not needed as we will already have a window object instanced and ready to rock
            //_mainWindow = new UIWindow (UIScreen.MainScreen.Bounds);

            //_mainWindow.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;

            //game.Services.AddService (typeof(AspyWindow), _mainWindow);
            game.Services.AddService(typeof(AspyWindow), _viewController.iOSGlobals.G__MainWindow);

            Window = new iOSGameWindow(_viewController);

            //_mainWindow.RootViewController = _viewController;
            //_mainWindow.Add (_viewController.View);

            // AspyCore handles orientation??
            // During any screen rotations check this if monogame swaps itself.
            _viewController.InterfaceOrientationChanged += ViewController_InterfaceOrientationChanged;

            #endregion

            //(SJ) Why is this called here when it's not in any other project
            //Guide.Initialise(game);
        }
Ejemplo n.º 19
0
        protected override void Dispose(bool disposing)
        {
            if (!IsDisposed)
            {
                if (INTERNAL_window != null)
                {
                    INTERNAL_window.INTERNAL_Destroy();
                    INTERNAL_window = null;
                }

                if (soundControllerInstance != null)
                {
                    soundControllerInstance.Dispose();
                    soundControllerInstance = null;
                }
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 20
0
        public AndroidGamePlatform(Game game)
            : base(game)
        {
            System.Diagnostics.Debug.Assert(Game.Activity != null, "Must set Game.Activity before creating the Game instance");
            Game.Activity.Game           = Game;
            AndroidGameActivity.Paused  += Activity_Paused;
            AndroidGameActivity.Resumed += Activity_Resumed;

            _gameWindow = new AndroidGameWindow(Game.Activity, game);
            Window      = _gameWindow;

            MediaLibrary.Context = Game.Activity;
            try
            {
                OpenALSoundController soundControllerInstance = OpenALSoundController.GetInstance;
            }
            catch (DllNotFoundException ex)
            {
                throw (new NoAudioHardwareException("Failed to init OpenALSoundController", ex));
            }
        }
Ejemplo n.º 21
0
        public OpenTKGamePlatform(Game game)
            : base(game)
        {
            if (PlatformParameters.PreferredBackend != Backend.Default)
            {
                Toolkit.Init(new ToolkitOptions {
                    Backend = PlatformBackend.PreferNative
                });
            }

            _view       = new OpenTKGameWindow(game);
            this.Window = _view;

            // Setup our OpenALSoundController to handle our SoundBuffer pools
            try
            {
                soundControllerInstance = OpenALSoundController.GetInstance;
            }
            catch (DllNotFoundException ex)
            {
                throw (new NoAudioHardwareException("Failed to init OpenALSoundController", ex));
            }
        }