예제 #1
0
        public Game()
        {
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            LaunchParameters = new LaunchParameters();
            Content          = new ContentManager();

            IsMouseVisible    = false;
            IsFixedTimeStep   = true;
            TargetElapsedTime = TimeSpan.FromTicks(166667);             // 60fps
            InactiveSleepTime = TimeSpan.FromSeconds(0.02);

            textInputControlDown   = new bool[FNAPlatform.TextInputCharacters.Length];
            textInputControlRepeat = new int[FNAPlatform.TextInputCharacters.Length];

            hasInitialized = false;
            suppressDraw   = false;
            isDisposed     = false;

            gameTime = new GameTime();

            Window                  = FNAPlatform.CreateWindow();
            Mouse.WindowHandle      = Window.Handle;
            TouchPanel.WindowHandle = Window.Handle;

            FrameworkDispatcher.Update();

            // Ready to run the loop!
            RunApplication = true;

            GraphicsDeviceManager.Instance = new GraphicsDeviceManager(this);
        }
예제 #2
0
        public Game()
        {
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            LaunchParameters = new LaunchParameters();
            Components       = new GameComponentCollection();
            Services         = new GameServiceContainer();
            Content          = new ContentManager(Services);

            updateableComponents        = new List <IUpdateable>();
            currentlyUpdatingComponents = new List <IUpdateable>();
            drawableComponents          = new List <IDrawable>();
            currentlyDrawingComponents  = new List <IDrawable>();

            IsMouseVisible    = false;
            IsFixedTimeStep   = true;
            TargetElapsedTime = TimeSpan.FromTicks(166667);             // 60fps
            InactiveSleepTime = TimeSpan.FromSeconds(0.02);

            hasInitialized = false;
            suppressDraw   = false;
            isDisposed     = false;

            gameTime = new GameTime();

            Window                  = FNAPlatform.CreateWindow();
            Mouse.WindowHandle      = Window.Handle;
            TouchPanel.WindowHandle = Window.Handle;

            FrameworkDispatcher.Update();

            // Ready to run the loop!
            RunApplication = true;
        }
예제 #3
0
        public Game()
        {
            _instance        = this;
            LaunchParameters = new LaunchParameters();
            _services        = new GameServiceContainer();
            _components      = new GameComponentCollection();
            Content          = new ContentManager(_services);

            Platform              = GamePlatform.Create(this);
            Platform.Activated   += Platform_Activated;
            Platform.Deactivated += Platform_Deactivated;
            _services.AddService(typeof(GamePlatform), Platform);
        }
예제 #4
0
        public Game()
        {
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            LaunchParameters = new LaunchParameters();
            _services        = new GameServiceContainer();
            _components      = new GameComponentCollection();
            _content         = new ContentManager(_services);

            Window = FNAPlatform.CreateWindow();

            AudioDevice.Initialize();

            // Ready to run the loop!
            RunApplication = true;
        }
예제 #5
0
파일: Game.cs 프로젝트: lovelife/MonoGame
        public Game()
        {
            _instance = this;

            TitleContainer.Initialize();

            LaunchParameters = new LaunchParameters();
            _services        = new GameServiceContainer();
            _components      = new GameComponentCollection();
            Content          = new ContentManager(_services);

            Platform              = GamePlatform.Create(this);
            Platform.Activated   += OnActivated;
            Platform.Deactivated += OnDeactivated;
            _services.AddService(typeof(GamePlatform), Platform);

            /* Set the window title
             * TODO: Get the title from the WindowsPhoneManifest.xml for WP7 projects
             */
            string windowTitle = string.Empty;

            // When running unit tests this can return null
            Assembly assembly = Assembly.GetEntryAssembly();

            if (assembly != null)
            {
                // Use the Title attribute of the Assembly if possible
                AssemblyTitleAttribute assemblyTitleAtt = (AssemblyTitleAttribute)
                                                          AssemblyTitleAttribute.GetCustomAttribute(
                    assembly,
                    typeof(AssemblyTitleAttribute)
                    );

                if (assemblyTitleAtt != null)
                {
                    windowTitle = assemblyTitleAtt.Title;
                }

                // Otherwise, fallback to the Name of the assembly
                if (string.IsNullOrEmpty(windowTitle))
                {
                    windowTitle = assembly.GetName().Name;
                }
            }

            Window.Title = windowTitle;
        }
예제 #6
0
        public Game()
        {
            _instance = this;

            LaunchParameters = new LaunchParameters();
            _services        = new GameServiceContainer();
            _components      = new GameComponentCollection();
            _content         = new ContentManager(_services);

            Platform              = GamePlatform.Create(this);
            Platform.Activated   += OnActivated;
            Platform.Deactivated += OnDeactivated;
            _services.AddService(typeof(GamePlatform), Platform);

#if WINDOWS_STOREAPP && !WINDOWS_PHONE81
            Platform.ViewStateChanged += Platform_ApplicationViewChanged;
#endif
        }
예제 #7
0
        public Game()
        {
            Instance = this;

            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            LaunchParameters = new LaunchParameters();
            _services        = new GameServiceContainer();
            _components      = new GameComponentCollection();
            _content         = new ContentManager(_services);

            Platform              = GamePlatform.Create(this);
            Platform.Activated   += OnActivated;
            Platform.Deactivated += OnDeactivated;
            _services.AddService(typeof(GamePlatform), Platform);

            AudioDevice.Initialize();
        }
예제 #8
0
파일: Game.cs 프로젝트: KqSMea8/gueslang
        public Game()
        {
            _instance        = this;
            LaunchParameters = new LaunchParameters();
            _services        = new GameServiceContainer();
            _components      = new GameComponentCollection();
            Content          = new ContentManager(_services);

            Platform              = GamePlatform.Create(this);
            Platform.Activated   += OnActivated;
            Platform.Deactivated += OnDeactivated;
            _services.AddService(typeof(GamePlatform), Platform);

#if WINDOWS_STOREAPP
            Platform.ViewStateChanged += Platform_ApplicationViewChanged;
#endif

#if MONOMAC || WINDOWS || LINUX
            // Set the window title.
            // TODO: Get the title from the WindowsPhoneManifest.xml for WP7 projects.
            string windowTitle = string.Empty;

            // When running unit tests this can return null.
            var assembly = Assembly.GetEntryAssembly();
            if (assembly != null)
            {
                //Use the Title attribute of the Assembly if possible.
                var assemblyTitleAtt = ((AssemblyTitleAttribute)AssemblyTitleAttribute.GetCustomAttribute(assembly, typeof(AssemblyTitleAttribute)));
                if (assemblyTitleAtt != null)
                {
                    windowTitle = assemblyTitleAtt.Title;
                }

                // Otherwise, fallback to the Name of the assembly.
                if (string.IsNullOrEmpty(windowTitle))
                {
                    windowTitle = assembly.GetName().Name;
                }
            }

            Window.Title = windowTitle;
#endif
        }
예제 #9
0
파일: Game.cs 프로젝트: ReaTsukuda/ReaMG
        public Game()
        {
            _instance = this;

            LaunchParameters = new LaunchParameters();
            _services        = new GameServiceContainer();
            _components      = new GameComponentCollection();
            _content         = new ContentManager(_services);

            Platform              = GamePlatform.PlatformCreate(this);
            Platform.Activated   += OnActivated;
            Platform.Deactivated += OnDeactivated;
            _services.AddService(typeof(GamePlatform), Platform);

            // Calling Update() for first time initializes some systems
            FrameworkDispatcher.Update();

            // Allow some optional per-platform construction to occur too.
            PlatformConstruct();
        }
예제 #10
0
        public Game()
        {
            _instance = this;

            LaunchParameters = new LaunchParameters();
            _services        = new GameServiceContainer();
            _components      = new GameComponentCollection();
            _content         = new ContentManager(_services);

            Platform              = GamePlatform.PlatformCreate(this);
            Platform.Activated   += OnActivated;
            Platform.Deactivated += OnDeactivated;
            _services.AddService(typeof(GamePlatform), Platform);

            // Calling Update() for first time initializes some systems
            FrameworkDispatcher.Update();

#if WINDOWS_STOREAPP && !WINDOWS_PHONE81
            Platform.ViewStateChanged += Platform_ApplicationViewChanged;
#endif
        }
예제 #11
0
        static FNAPlatform()
        {
            /* I suspect you may have an urge to put an #if in here for new
             * FNAPlatform implementations.
             *
             * DON'T.
             *
             * Determine this at runtime, or load dynamically.
             * No amount of whining will get me to budge on this.
             * -flibit
             */

            // Environment.GetEnvironmentVariable("FNA_PLATFORM_BACKEND");

            // Built-in command line arguments
            LaunchParameters args = new LaunchParameters();
            string           arg;

            if (args.TryGetValue("enablehighdpi", out arg) && arg == "1")
            {
                Environment.SetEnvironmentVariable(
                    "FNA_GRAPHICS_ENABLE_HIGHDPI",
                    "1"
                    );
            }
            if (args.TryGetValue("gldevice", out arg))
            {
                Environment.SetEnvironmentVariable(
                    "FNA3D_FORCE_DRIVER",
                    arg
                    );
            }
            if (args.TryGetValue("disablelateswaptear", out arg) && arg == "1")
            {
                Environment.SetEnvironmentVariable(
                    "FNA3D_DISABLE_LATESWAPTEAR",
                    "1"
                    );
            }
            if (args.TryGetValue("mojoshaderprofile", out arg))
            {
                Environment.SetEnvironmentVariable(
                    "FNA3D_MOJOSHADER_PROFILE",
                    arg
                    );
            }
            if (args.TryGetValue("backbufferscalenearest", out arg) && arg == "1")
            {
                Environment.SetEnvironmentVariable(
                    "FNA3D_BACKBUFFER_SCALE_NEAREST",
                    "1"
                    );
            }
            if (args.TryGetValue("usescancodes", out arg) && arg == "1")
            {
                Environment.SetEnvironmentVariable(
                    "FNA_KEYBOARD_USE_SCANCODES",
                    "1"
                    );
            }

            CreateWindow               = SDL2_FNAPlatform.CreateWindow;
            DisposeWindow              = SDL2_FNAPlatform.DisposeWindow;
            ApplyWindowChanges         = SDL2_FNAPlatform.ApplyWindowChanges;
            GetWindowBounds            = SDL2_FNAPlatform.GetWindowBounds;
            GetWindowResizable         = SDL2_FNAPlatform.GetWindowResizable;
            SetWindowResizable         = SDL2_FNAPlatform.SetWindowResizable;
            GetWindowBorderless        = SDL2_FNAPlatform.GetWindowBorderless;
            SetWindowBorderless        = SDL2_FNAPlatform.SetWindowBorderless;
            SetWindowTitle             = SDL2_FNAPlatform.SetWindowTitle;
            RegisterGame               = SDL2_FNAPlatform.RegisterGame;
            UnregisterGame             = SDL2_FNAPlatform.UnregisterGame;
            PollEvents                 = SDL2_FNAPlatform.PollEvents;
            GetGraphicsAdapters        = SDL2_FNAPlatform.GetGraphicsAdapters;
            GetCurrentDisplayMode      = SDL2_FNAPlatform.GetCurrentDisplayMode;
            GetKeyFromScancode         = SDL2_FNAPlatform.GetKeyFromScancode;
            StartTextInput             = SDL2.SDL.SDL_StartTextInput;
            StopTextInput              = SDL2.SDL.SDL_StopTextInput;
            SetTextInputRectangle      = SDL2_FNAPlatform.SetTextInputRectangle;
            GetMouseState              = SDL2_FNAPlatform.GetMouseState;
            SetMousePosition           = SDL2.SDL.SDL_WarpMouseInWindow;
            OnIsMouseVisibleChanged    = SDL2_FNAPlatform.OnIsMouseVisibleChanged;
            GetRelativeMouseMode       = SDL2_FNAPlatform.GetRelativeMouseMode;
            SetRelativeMouseMode       = SDL2_FNAPlatform.SetRelativeMouseMode;
            GetGamePadCapabilities     = SDL2_FNAPlatform.GetGamePadCapabilities;
            GetGamePadState            = SDL2_FNAPlatform.GetGamePadState;
            SetGamePadVibration        = SDL2_FNAPlatform.SetGamePadVibration;
            GetGamePadGUID             = SDL2_FNAPlatform.GetGamePadGUID;
            SetGamePadLightBar         = SDL2_FNAPlatform.SetGamePadLightBar;
            GetStorageRoot             = SDL2_FNAPlatform.GetStorageRoot;
            GetDriveInfo               = SDL2_FNAPlatform.GetDriveInfo;
            ShowRuntimeError           = SDL2_FNAPlatform.ShowRuntimeError;
            GetMicrophones             = SDL2_FNAPlatform.GetMicrophones;
            GetMicrophoneSamples       = SDL2_FNAPlatform.GetMicrophoneSamples;
            GetMicrophoneQueuedBytes   = SDL2_FNAPlatform.GetMicrophoneQueuedBytes;
            StartMicrophone            = SDL2_FNAPlatform.StartMicrophone;
            StopMicrophone             = SDL2_FNAPlatform.StopMicrophone;
            GetTouchCapabilities       = SDL2_FNAPlatform.GetTouchCapabilities;
            UpdateTouchPanelState      = SDL2_FNAPlatform.UpdateTouchPanelState;
            GetNumTouchFingers         = SDL2_FNAPlatform.GetNumTouchFingers;
            SupportsOrientationChanges = SDL2_FNAPlatform.SupportsOrientationChanges;
            NeedsPlatformMainLoop      = SDL2_FNAPlatform.NeedsPlatformMainLoop;
            RunPlatformMainLoop        = SDL2_FNAPlatform.RunPlatformMainLoop;

            FNALoggerEXT.Initialize();

            AppDomain.CurrentDomain.ProcessExit += SDL2_FNAPlatform.ProgramExit;
            TitleLocation = SDL2_FNAPlatform.ProgramInit(args);
        }