public MainMenu(TestGame game, CommandConsole console, GraphicsDevice device, ContentManager content, IServiceProvider services) { this.game = game; this.player = game.Player; ui = new UserInterface(device); ui.Actors.Add(player); var tests = from type in Assembly.GetExecutingAssembly().GetTypes() where typeof(TestScreen).IsAssignableFrom(type) where !type.IsAbstract select type; this.menu = new Menu(ui.Root); menu.SetPoint(Points.BottomLeft, 50, -50); int index = 0; foreach (var test in tests) { index++; var testKernel = new StandardKernel(); testKernel.Bind<GraphicsDevice>().ToConstant(device); testKernel.Bind<ContentManager>().ToConstant(new ContentManager(services)); testKernel.Bind<Game>().ToConstant(game); testKernel.Bind<TestGame>().ToConstant(game); testKernel.Bind<CommandConsole>().ToConstant(console); testKernel.Bind<IServiceProvider>().ToConstant(game.Services); //testKernel.Bind<InputActor>().ToConstant(player); var instance = testKernel.Get(test) as TestScreen; var menuOption = new TextButton(menu, content.Load<SpriteFont>("Consolas"), instance.Name); menuOption.Highlight = Color.Red; menuOption.Gestures.Bind((gesture, time, input) => Manager.Push(instance), new MouseReleased(MouseButtons.Left), new KeyReleased(Keys.Enter)); } var quit = new TextButton(menu, content.Load<SpriteFont>("Consolas"), "Exit"); quit.Highlight = Color.Red; quit.Gestures.Bind((gesture, time, input) => game.Exit(), new MouseReleased(MouseButtons.Left), new KeyReleased(Keys.Enter)); menu.Arrange(Justification.Left); }
public TestScreen(string name, IKernel kernel) { Name = name; Game = kernel.Get<TestGame>(); content = kernel.Get<ContentManager>(); content.RootDirectory = "Content"; UI = kernel.Get<UserInterface>(); UI.Root.Gestures.Bind((gesture, time, device) => Manager.Pop(), new KeyReleased(Keys.Escape)); actor = Game.Player; UI.Actors.Add(actor); var title = new Label(UI.Root, content.Load<SpriteFont>("Consolas")); title.Text = Name; title.Justification = Justification.Centre; title.SetPoint(Points.Top, Int2D.Zero); }