protected override void Initialize() { base.Initialize(); UserInterface.Initialize(Content, BuiltinThemes.editor); //UserInterface.Active.UseRenderTarget = true; //Panel panel = new Panel(new Vector2(graphics.PreferredBackBufferHeight, graphics.PreferredBackBufferHeight), anchor: Anchor.CenterRight); //panel.PanelOverflowBehavior = PanelOverflowBehavior.VerticalScroll; //UserInterface.Active.AddEntity(panel); SelectList list = new SelectList(new Vector2(graphics.PreferredBackBufferHeight, graphics.PreferredBackBufferHeight), anchor: Anchor.CenterRight); UserInterface.Active.AddEntity(list); var directory = new DirectoryInfo($"{Content.RootDirectory}/roms/"); foreach (var file in directory.GetFiles("*.*")) { list.AddItem(file.Name); } list.SelectedIndex = 0; list.OnValueChange += e => StartRom(list.SelectedValue); chip = new Chip8(); chip.LoadGame(program); chipSound = new ChipSound(); chipInput = new ChipInput(); chipRenderer = new ChipRenderer(Chip8.ScreenWidth, Chip8.ScreenHeight, 512, 256, GraphicsDevice); }
private void StartRom(string name) { using (var stream = TitleContainer.OpenStream($"Content/roms/{name}")) { var bytes = new byte[stream.Length]; stream.Read(bytes, 0, (int)stream.Length); program = bytes; } chip = new Chip8(); chip.LoadGame(program); }