private static void OnMessageReceived(object sender, NetCoreEventArgs e) { try { // This is where you implement interaction. // Warning: Any error thrown in here will be caught by NetCore and handled by being displayed in the console. var message = e.message; var simpleMessage = message as NetCoreSimpleMessage; var advancedMessage = message as NetCoreAdvancedMessage; ConsoleEx.WriteLine(message.Type); switch (message.Type) //Handle received messages here { case RTCV.NetCore.Commands.Remote.AllSpecSent: { //We still need to set the emulator's path AllSpec.VanguardSpec.Update(VSPEC.EMUDIR, FileWatch.currentDir); SyncObjectSingleton.FormExecute(() => { FileWatch.UpdateDomains(); }); } break; case RTCV.NetCore.Commands.Basic.SaveSavestate: string key = (advancedMessage.objectValue as string); //TODO: Sync states with keys SyncObjectSingleton.FormExecute(() => { S.GET <StubForm>().btnRamSaveState_Click(null, null); string returnKey = VanguardCore.SaveSavestate_NET(key); e.setReturnValue(returnKey); }); break; case RTCV.NetCore.Commands.Basic.LoadSavestate: var cmd = advancedMessage.objectValue as object[]; var path = cmd[0] as string; var location = (StashKeySavestateLocation)cmd[1]; SyncObjectSingleton.FormExecute(() => { //e.setReturnValue(VanguardCore.LoadSavestate_NET(path, location)); VanguardCore.LoadSavestate_NET(path, location); S.GET <StubForm>().RepackState(false); }); e.setReturnValue(true); break; case RTCV.NetCore.Commands.Remote.PreCorruptAction: FileWatch.KillProcess(); FileWatch.currentFileInfo.targetInterface.CloseStream(); FileWatch.RestoreTarget(); break; case RTCV.NetCore.Commands.Remote.PostCorruptAction: //var fileName = advancedMessage.objectValue as String; FileWatch.currentFileInfo.targetInterface?.CloseStream(); SyncObjectSingleton.FormExecute(() => { Executor.Execute(); }); break; case RTCV.NetCore.Commands.Remote.CloseGame: SyncObjectSingleton.FormExecute(() => { FileWatch.KillProcess(); }); break; case RTCV.NetCore.Commands.Remote.DomainGetDomains: SyncObjectSingleton.FormExecute(() => { e.setReturnValue(FileWatch.GetInterfaces()); }); break; case RTCV.NetCore.Commands.Remote.EventEmuMainFormClose: SyncObjectSingleton.FormExecute(() => { Environment.Exit(0); }); break; case RTCV.NetCore.Commands.Remote.IsNormalAdvance: e.setReturnValue(true); break; case RTCV.NetCore.Commands.Remote.EventCloseEmulator: Environment.Exit(-1); break; } } catch (Exception ex) { if (VanguardCore.ShowErrorDialog(ex, true) == DialogResult.Abort) { throw new RTCV.NetCore.AbortEverythingException(); } } }
private static void OnMessageReceived(object sender, NetCoreEventArgs e) { try { // This is where you implement interaction. // Warning: Any error thrown in here will be caught by NetCore and handled by being displayed in the console. var message = e.message; var simpleMessage = message as NetCoreSimpleMessage; var advancedMessage = message as NetCoreAdvancedMessage; ConsoleEx.WriteLine(message.Type); switch (message.Type) //Handle received messages here { case RTCV.NetCore.Commands.Remote.AllSpecSent: { //We still need to set the emulator's path AllSpec.VanguardSpec.Update(VSPEC.EMUDIR, CemuWatch.currentGameInfo.cemuExeFile.Directory.FullName); SyncObjectSingleton.FormExecute(() => { CemuWatch.UpdateDomains(); }); } break; case RTCV.NetCore.Commands.Basic.SaveSavestate: SyncObjectSingleton.FormExecute(() => { e.setReturnValue(VanguardCore.SaveSavestate_NET(advancedMessage.objectValue as string)); //e.setReturnValue(""); }); break; case RTCV.NetCore.Commands.Basic.LoadSavestate: { var cmd = advancedMessage.objectValue as object[]; var path = cmd[0] as string; var location = (StashKeySavestateLocation)cmd[1]; SyncObjectSingleton.FormExecute(() => { e.setReturnValue(VanguardCore.LoadSavestate_NET(path, location)); }); e.setReturnValue(true); break; } case RTCV.NetCore.Commands.Remote.PreCorruptAction: CemuWatch.KillCemuProcess(false); CemuWatch.RestoreBackup(); break; case RTCV.NetCore.Commands.Remote.PostCorruptAction: { //var fileName = advancedMessage.objectValue as String; SyncObjectSingleton.FormExecute(() => { CemuWatch.StartRpx(); }); } break; case RTCV.NetCore.Commands.Remote.CloseGame: SyncObjectSingleton.FormExecute(() => { CemuWatch.KillCemuProcess(false); }); break; case RTCV.NetCore.Commands.Remote.DomainGetDomains: SyncObjectSingleton.FormExecute(() => { e.setReturnValue(CemuWatch.GetInterfaces()); }); break; case RTCV.NetCore.Commands.Remote.EventEmuMainFormClose: SyncObjectSingleton.FormExecute(() => { Environment.Exit(0); }); break; case RTCV.NetCore.Commands.Remote.IsNormalAdvance: e.setReturnValue(true); //e.setReturnValue(Hooks.isNormalAdvance); break; case RTCV.NetCore.Commands.Remote.EventCloseEmulator: Environment.Exit(-1); break; } } catch (Exception ex) { if (VanguardCore.ShowErrorDialog(ex, true) == DialogResult.Abort) { throw new RTCV.NetCore.AbortEverythingException(); } } }
private static void OnMessageReceived(object sender, NetCoreEventArgs e) { try { // This is where you implement interaction. // Warning: Any error thrown in here will be caught by NetCore and handled by being displayed in the console. var message = e.message; var simpleMessage = message as NetCoreSimpleMessage; var advancedMessage = message as NetCoreAdvancedMessage; ConsoleEx.WriteLine(message.Type); switch (message.Type) //Handle received messages here { case REMOTE_ALLSPECSSENT: { //We still need to set the emulator's path AllSpec.VanguardSpec.Update(VSPEC.EMUDIR, CemuWatch.currentGameInfo.cemuExeFile.Directory.FullName); SyncObjectSingleton.FormExecute(() => { CemuWatch.UpdateDomains(); }); } break; case SAVESAVESTATE: SyncObjectSingleton.FormExecute(() => { e.setReturnValue(VanguardCore.SaveSavestate_NET(advancedMessage.objectValue as string)); //e.setReturnValue(""); }); break; case LOADSAVESTATE: { var cmd = advancedMessage.objectValue as object[]; var path = cmd[0] as string; var location = (StashKeySavestateLocation)cmd[1]; SyncObjectSingleton.FormExecute(() => { e.setReturnValue(VanguardCore.LoadSavestate_NET(path, location)); }); e.setReturnValue(true); break; } case REMOTE_PRECORRUPTACTION: CemuWatch.KillCemuProcess(false); CemuWatch.RestoreBackup(); break; case REMOTE_POSTCORRUPTACTION: { //var fileName = advancedMessage.objectValue as String; SyncObjectSingleton.FormExecute(() => { CemuWatch.StartRpx(); }); } break; case REMOTE_CLOSEGAME: SyncObjectSingleton.FormExecute(() => { CemuWatch.KillCemuProcess(false); }); break; case REMOTE_DOMAIN_GETDOMAINS: SyncObjectSingleton.FormExecute(() => { e.setReturnValue(CemuWatch.GetInterfaces()); }); break; case REMOTE_EVENT_EMU_MAINFORM_CLOSE: SyncObjectSingleton.FormExecute(() => { Environment.Exit(0); }); break; case REMOTE_ISNORMALADVANCE: e.setReturnValue(true); //e.setReturnValue(Hooks.isNormalAdvance); break; case REMOTE_EVENT_CLOSEEMULATOR: Environment.Exit(-1); break; } } catch (Exception ex) { if (VanguardCore.ShowErrorDialog(ex, true) == DialogResult.Abort) { throw new RTCV.NetCore.AbortEverythingException(); } } }