private bool ReloadRom(EmulatorWindow ew) { bool deterministic = ew.Emulator.DeterministicEmulation; string path = ew.CurrentRomPath; var loader = new RomLoader { ChooseArchive = LoadArhiveChooser, ChoosePlatform = ChoosePlatformForRom, Deterministic = deterministic, MessageCallback = AddMessage }; loader.OnLoadError += ShowLoadError; loader.OnLoadSettings += CoreSettings; loader.OnLoadSyncSettings += CoreSyncSettings; var nextComm = new CoreComm(ShowMessageCoreComm, AddMessage); var result = loader.LoadRom(path, nextComm); if (result) { ew.SaveRam(); ew.Emulator.Dispose(); ew.Emulator = loader.LoadedEmulator; ew.CoreComm = nextComm; _inputManager.SyncControls(); if (EmulatorWindows.First() == ew) { Global.Emulator = ew.Emulator; } return true; } else { return false; } }
private bool LoadRom(string path) { bool deterministic = true; var loader = new RomLoader { ChooseArchive = LoadArhiveChooser, ChoosePlatform = ChoosePlatformForRom, Deterministic = deterministic, MessageCallback = AddMessage }; loader.OnLoadError += ShowLoadError; loader.OnLoadSettings += CoreSettings; loader.OnLoadSyncSettings += CoreSyncSettings; var nextComm = new CoreComm(ShowMessageCoreComm, AddMessage); var result = loader.LoadRom(path, nextComm); if (result) { var ew = new EmulatorWindow(this) { TopLevel = false, Text = Path.GetFileNameWithoutExtension(StripArchivePath(path)), Emulator = loader.LoadedEmulator, GL = new Bizware.BizwareGL.Drivers.OpenTK.IGL_TK(), GLManager = GLManager.Instance, Game = loader.Game, CurrentRomPath = loader.CanonicalFullPath }; nextComm.RequestGLContext = () => ew.GLManager.CreateGLContext(); nextComm.ActivateGLContext = (gl) => ew.GLManager.Activate((GLManager.ContextRef)ew.GL); nextComm.DeactivateGLContext = () => ew.GLManager.Deactivate(); ew.CoreComm = nextComm; ew.Init(); if (EmulatorWindows.Any()) { // Attempt to open the window is a smart location var last = EmulatorWindows.Last(); int x = last.Location.X + last.Width + 5; int y = last.Location.Y; if (x + (last.Width / 2) > Width) // If it will go too far off screen { y += last.Height + 5; x = EmulatorWindows.First().Location.X; } ew.Location = new Point(x, y); } EmulatorWindows.Add(ew); WorkspacePanel.Controls.Add(ew); ew.Show(); Global.Config.RecentRoms.Add(loader.CanonicalFullPath); if (EmulatorWindows.Count == 1) { Global.Emulator = ew.Emulator; } _inputManager.SyncControls(); return true; } else { return false; } }
public void EmulatorWindowClosed(EmulatorWindow ew) { EmulatorWindows.Remove(ew); WorkspacePanel.Controls.Remove(ew); if (ew.Emulator == Global.Emulator) { if (EmulatorWindows.Any()) { Global.Emulator = EmulatorWindows.Master.Emulator; } else { Global.Emulator = null; } } }