// Build a full GameSettings from a package public static GameSettings CreateFromPackage(Package package, PlatformType platform) { var result = new GameSettings(); // Default settings var sharedProfile = package.Profiles.FindSharedProfile(); if (sharedProfile != null) { var sceneAsset = sharedProfile.Properties.Get(DefaultScene); if (sceneAsset != null) result.DefaultSceneUrl = sceneAsset.Location; result.DefaultBackBufferWidth = sharedProfile.Properties.Get(BackBufferWidth); result.DefaultBackBufferHeight = sharedProfile.Properties.Get(BackBufferHeight); result.DefaultGraphicsProfileUsed = sharedProfile.Properties.Get(DefaultGraphicsProfile); } // Platform-specific settings have priority if (platform != PlatformType.Shared) { var platformProfile = package.Profiles.FirstOrDefault(o => o.Platform == platform); if (platformProfile != null) { var customProfile = platformProfile.Properties.Get(DefaultGraphicsProfile); if (customProfile > 0) result.DefaultGraphicsProfileUsed = customProfile; } } return result; }
protected internal override void PrepareContext() { base.PrepareContext(); // Init assets if (Context.InitializeDatabase) { InitializeAssetDatabase(); // Load several default settings if (AutoLoadDefaultSettings && Asset.Exists(GameSettings.AssetUrl)) { gameSettings = Asset.Load<GameSettings>(GameSettings.AssetUrl); var deviceManager = (GraphicsDeviceManager)graphicsDeviceManager; if (gameSettings.DefaultGraphicsProfileUsed > 0) deviceManager.PreferredGraphicsProfile = new[] { gameSettings.DefaultGraphicsProfileUsed }; if (gameSettings.DefaultBackBufferWidth > 0) deviceManager.PreferredBackBufferWidth = gameSettings.DefaultBackBufferWidth; if (gameSettings.DefaultBackBufferHeight > 0) deviceManager.PreferredBackBufferHeight = gameSettings.DefaultBackBufferHeight; deviceManager.PreferredColorSpace = gameSettings.ColorSpace; SceneSystem.InitialSceneUrl = gameSettings.DefaultSceneUrl; } } }