/// <summary> /// Constructs a new menu entry with the specified text. /// </summary> public MenuEntry( MenuScreen menu, string text, EntryType type, GameScreen screen, Texture2D preview ) { _text = text; _screen = screen; _type = type; _menu = menu; _scale = 0.9f; _alpha = 1.0f; Preview = preview; }
/// <summary> /// Load your graphics content. /// </summary> protected override void LoadContent() { ContentHelper.Initialize( Game ); _spriteBatch = new SpriteBatch( GraphicsDevice ); _lineBatch = new LineBatch( GraphicsDevice ); _assetCreator = new AssetCreator( GraphicsDevice ); _assetCreator.LoadContent(); _input.LoadContent(); PresentationParameters _pp = GraphicsDevice.PresentationParameters; _transitions.Add( new RenderTarget2D( GraphicsDevice, _pp.BackBufferWidth, _pp.BackBufferHeight, false, SurfaceFormat.Color, _pp.DepthStencilFormat, _pp.MultiSampleCount, RenderTargetUsage.DiscardContents ) ); _menuScreen = new MenuScreen(); _menuScreen.AddMenuItem( "Levels", EntryType.Separator, null ); var assembly = Assembly.GetExecutingAssembly(); foreach ( LevelBase level in ( from SampleType in assembly.GetTypes() where SampleType.IsSubclassOf( typeof( LevelBase ) ) select assembly.CreateInstance( SampleType.ToString() ) ).OfType<LevelBase>() ) { RenderTarget2D preview = new RenderTarget2D( GraphicsDevice, _pp.BackBufferWidth / 2, _pp.BackBufferHeight / 2, false, SurfaceFormat.Color, _pp.DepthStencilFormat, _pp.MultiSampleCount, RenderTargetUsage.DiscardContents ); level.ScreenManager = this; level.LoadContent(); // "Abuse" transition rendertarget to render screen preview GraphicsDevice.SetRenderTarget( _transitions[ 0 ] ); GraphicsDevice.Clear( Color.Transparent ); level.Update( new GameTime( level.TransitionOnTime, level.TransitionOnTime ), true, false ); level.Draw(new GameTime()); level.Draw(new GameTime()); GraphicsDevice.SetRenderTarget( preview ); GraphicsDevice.Clear( Color.Transparent ); SpriteBatch.Begin(); SpriteBatch.Draw( _transitions[ 0 ], preview.Bounds, Color.White ); SpriteBatch.End(); GraphicsDevice.SetRenderTarget( null ); level.ExitScreen(); level.Update( new GameTime( level.TransitionOffTime, level.TransitionOffTime ), true, false ); _menuScreen.AddLevelItem( new LevelTutorial(), preview ); } _menuScreen.AddMenuItem( "", EntryType.Separator, null ); _menuScreen.AddMenuItem( "Exit", EntryType.ExitItem, null ); AddScreen( new BackgroundScreen() ); AddScreen( _menuScreen ); AddScreen( new LogoScreen( TimeSpan.FromSeconds( 3.0 ) ) ); // Tell each of the screens to load their content. foreach ( GameScreen screen in _screens ) { screen.LoadContent(); } }
/// <summary> /// Constructs a new menu entry with the specified text. /// </summary> public MenuEntry( MenuScreen menu, string text, EntryType type, GameScreen screen ) : this(menu, text, type, screen, null) { }