Skip to content

Commit aafc074

Browse files
authored
620 fix version reading logic (#623)
* Initial check logic * Fixed dropdown colors
1 parent d043cb6 commit aafc074

File tree

5 files changed

+38
-12
lines changed

5 files changed

+38
-12
lines changed

Assets/Scripts/EphysLink/CommunicationManager.cs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,33 @@ public void VerifyVersion(Action onSuccess, Action onFailure)
153153
{
154154
GetVersion(version =>
155155
{
156-
if (!version.Split(".").Where((versionNumber, index) =>
157-
int.Parse(new string(versionNumber.TakeWhile(char.IsDigit).ToArray())) <
158-
EPHYS_LINK_MIN_VERSION[index])
159-
.Any())
160-
onSuccess.Invoke();
161-
else
156+
var versionNumbers = version.Split(".").Select(versionNumber =>
157+
int.Parse(new string(versionNumber.TakeWhile(char.IsDigit).ToArray()))).ToArray();
158+
159+
// Fail if major version mismatch (breaking changes).
160+
if (versionNumbers[0] != EPHYS_LINK_MIN_VERSION[0])
161+
{
162+
onFailure.Invoke();
163+
return;
164+
}
165+
166+
// Fail if minor version is too small (missing features).
167+
if (versionNumbers[1] < EPHYS_LINK_MIN_VERSION[0])
168+
{
162169
onFailure.Invoke();
170+
return;
171+
}
172+
173+
// Fail if patch version is too small and minor version is not greater (bug fixes).
174+
if (versionNumbers[1] == EPHYS_LINK_MIN_VERSION[1] &&
175+
versionNumbers[2] < EPHYS_LINK_MIN_VERSION[2])
176+
{
177+
onFailure.Invoke();
178+
return;
179+
}
180+
181+
// Passed checks.
182+
onSuccess.Invoke();
163183
}, onFailure.Invoke);
164184
}
165185

Assets/Scripts/Pinpoint/UI/EphysCopilot/InsertionOptionColorHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ private void Start()
2222
var textEndIndex = _text.text.LastIndexOf(": A", StringComparison.Ordinal);
2323
if (textEndIndex == -1) return;
2424

25-
// Get the probe manager with this UUID (if it exists)
25+
// Get the probe manager with this UUID (if it exists).
2626
var probeNameString = _text.text[..textEndIndex];
2727
var matchingManager = InsertionSelectionPanelHandler.TargetableProbeManagers.First(manager =>
2828
manager.name.Equals(probeNameString) || (manager.OverrideName?.Equals(probeNameString) ?? false));
2929
if (!matchingManager) return;
3030

31-
// Set the toggle color to match the probe color
31+
// Get a copy of the toggle's color block.
3232
var colorBlockCopy = _toggle.colors;
3333
colorBlockCopy.normalColor = matchingManager.Color;
3434
colorBlockCopy.selectedColor = new Color(colorBlockCopy.normalColor.r * 0.9f,

Assets/Scripts/Pinpoint/UI/EphysCopilot/InsertionSelectionPanelHandler.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ public void OnTargetInsertionDropdownValueChanged(int value)
137137
_lineGameObjects.ap.SetActive(false);
138138
_lineGameObjects.ml.SetActive(false);
139139
_lineGameObjects.dv.SetActive(false);
140+
141+
// Reset dropdown color.
142+
var colorBlockCopy = _targetInsertionDropdown.colors;
143+
colorBlockCopy.normalColor = new Color(1, 1, 1);
144+
colorBlockCopy.selectedColor = new Color(0.8f, 0.8f, 0.8f);
145+
colorBlockCopy.highlightedColor = colorBlockCopy.selectedColor;
146+
_targetInsertionDropdown.colors = colorBlockCopy;
140147
}
141148
else
142149
{

Assets/Scripts/Pinpoint/UI/EphysLinkSettings/EphysLinkSettings.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Linq;
44
using EphysLink;
55
using TMPro;
6-
using TrajectoryPlanner.UI.EphysLinkSettings;
76
using UnityEngine;
87
using UnityEngine.Events;
98
using UnityEngine.UI;

Assets/Scripts/Pinpoint/UI/EphysLinkSettings/ProbeOptionColorHandler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using UnityEngine;
22
using UnityEngine.UI;
33

4-
namespace TrajectoryPlanner.UI.EphysLinkSettings
4+
namespace Pinpoint.UI.EphysLinkSettings
55
{
66
public class ProbeOptionColorHandler : MonoBehaviour
77
{
@@ -14,11 +14,11 @@ public class ProbeOptionColorHandler : MonoBehaviour
1414

1515
private void Start()
1616
{
17-
// Get the probe manager with this UUID (if it exists)
17+
// Get the probe manager with this UUID (if it exists).
1818
var matchingManager = ProbeManager.Instances.Find(manager => manager.UUID == _text.text);
1919
if (!matchingManager) return;
2020

21-
// Set the toggle color to match the probe color
21+
// Get a copy of the toggle's color block.
2222
var colorBlockCopy = _toggle.colors;
2323
colorBlockCopy.normalColor = matchingManager.Color;
2424
colorBlockCopy.selectedColor = new Color(colorBlockCopy.normalColor.r * 0.9f,

0 commit comments

Comments
 (0)