diff --git a/Assets/Scripts/Pinpoint/UI/EphysLinkSettings/EphysLinkSettings.cs b/Assets/Scripts/Pinpoint/UI/EphysLinkSettings/EphysLinkSettings.cs index 2dfbec9d..ad773098 100644 --- a/Assets/Scripts/Pinpoint/UI/EphysLinkSettings/EphysLinkSettings.cs +++ b/Assets/Scripts/Pinpoint/UI/EphysLinkSettings/EphysLinkSettings.cs @@ -216,6 +216,9 @@ void ConnectToServer() { _connectionErrorText.text = err; _connectButtonText.text = "Connect"; + + _manipulatorTypeDropdown.interactable = !CommunicationManager.Instance.IsConnected; + _launchEphysLinkButton.interactable = !CommunicationManager.Instance.IsConnected; } else { @@ -260,24 +263,7 @@ public void OnConnectDisconnectPressed() else { // Disconnect from server - QuestionDialogue.Instance.YesCallback = () => - { - foreach (var probeManager in ProbeManager.Instances - .Where(probeManager => probeManager.IsEphysLinkControlled)) - { - probeManager.SetIsEphysLinkControlled(false, - probeManager.ManipulatorBehaviorController.ManipulatorID); - - // FIXME: This is done because of race condition with closing out server. Should be fixed with non-registration setup. - probeManager.ManipulatorBehaviorController.Deinitialize(); - } - - CommunicationManager.Instance.DisconnectFromServer(() => - { - KillEphysLinkProcess(); - UpdateConnectionPanel(); - }); - }; + QuestionDialogue.Instance.YesCallback = HandleDisconnectingFromServer; QuestionDialogue.Instance.NewQuestion( "Are you sure you want to disconnect?\nAll incomplete movements will be canceled."); @@ -325,6 +311,25 @@ private void HandleSuccessfulConnection() }); } + private void HandleDisconnectingFromServer() + { + foreach (var probeManager in ProbeManager.Instances + .Where(probeManager => probeManager.IsEphysLinkControlled)) + { + probeManager.SetIsEphysLinkControlled(false, + probeManager.ManipulatorBehaviorController.ManipulatorID); + + // FIXME: This is done because of race condition with closing out server. Should be fixed with non-registration setup. + probeManager.ManipulatorBehaviorController.Deinitialize(); + } + + CommunicationManager.Instance.DisconnectFromServer(() => + { + KillEphysLinkProcess(); + UpdateConnectionPanel(); + }); + } + /// /// Populate UI elements with current connection settings. ///