蓝牙断开重连相关逻辑优化
This commit is contained in:
1 parent
87a0e7fb6d
commit
f25d0b7b8c
11 files changed
+455
-27
No files matched your search
@@ -50,6 +50,8 @@ public class PFUISlider : MonoBehaviour
|
||||
}
|
||||
public void SetValue(float a)
|
||||
{
|
||||
a = a > 1 ? 1 : a;
|
||||
a = a < 0 ? 0 : a;
|
||||
slider.value = a;
|
||||
slider.onValueChanged?.Invoke(a);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ public class ConnectDeviceModal : PFUIPanel
|
||||
private Dictionary<string, DeviceItem> deviceList;
|
||||
private Text noDevice,Title;
|
||||
private RectTransform searchIconRect;
|
||||
private GameObject deviceNotFound;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
@@ -52,6 +53,7 @@ public class ConnectDeviceModal : PFUIPanel
|
||||
deviceList = new Dictionary<string, DeviceItem>();
|
||||
|
||||
var container = this.transform.Find("GameObject");
|
||||
deviceNotFound = container.Find("Panel/Error").gameObject;
|
||||
var closeBtn = container.Find("CloseBtn");
|
||||
Logo = container.Find("Logo").GetComponent<Image>();
|
||||
Title = container.Find("Title").GetComponent<Text>();
|
||||
@@ -259,6 +261,7 @@ public class ConnectDeviceModal : PFUIPanel
|
||||
//如果没有可连接的设备按钮只读
|
||||
connectBtn.mButton.enabled = deviceList.Count > 0;
|
||||
connectBtn.mButton.interactable = deviceList.Count > 0;
|
||||
deviceNotFound.SetActive(deviceList.Count <= 0);
|
||||
}
|
||||
}
|
||||
//选中需要连接的设备
|
||||
|
||||
@@ -466,6 +466,10 @@ public class RowerHomeScript : PFUIPanel
|
||||
int truelyTime = 0;
|
||||
private void StartFunc(object sender, EventArgs e)
|
||||
{
|
||||
var rowdata = (IRowerCommonData)sender;
|
||||
if (rowdata != RowerData)
|
||||
return;
|
||||
|
||||
Debug.Log($"开始了:{openTimer}");
|
||||
if (UIManager.Instance.confirm != null && UIManager.Instance.confirm.IsActive())
|
||||
{
|
||||
@@ -626,6 +630,7 @@ public class RowerHomeScript : PFUIPanel
|
||||
|
||||
private void Init()
|
||||
{
|
||||
pointCount = 0;
|
||||
print("初始化");
|
||||
if (Rower != null)
|
||||
{
|
||||
@@ -734,20 +739,18 @@ public class RowerHomeScript : PFUIPanel
|
||||
transform.Find("ResBar/BtnSub").GetComponent<Button>().interactable = !(bool)sender;
|
||||
transform.Find("ResBar/BtnAdd").GetComponent<Button>().interactable = !(bool)sender;
|
||||
}
|
||||
bool initRes = false;
|
||||
|
||||
private void ResChanged(object sender, EventArgs e)
|
||||
{
|
||||
Debug.Log(Convert.ToSingle(sender));
|
||||
if (!initRes && slider)
|
||||
var originData = (IRowerCommonData)sender;
|
||||
if (slider && RowerData!= null && originData == RowerData)
|
||||
{
|
||||
var origin = Convert.ToSingle(sender);
|
||||
var origin = RowerData.ResistanceLevel;
|
||||
var wrapped = origin< 50 ? 50 : origin;
|
||||
slider.GetComponent<PFUISlider>().SetValue((wrapped - 50) / 300f);
|
||||
initRes = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool checkRowing()
|
||||
{
|
||||
if (seconds > 0)
|
||||
@@ -792,6 +795,7 @@ public class RowerHomeScript : PFUIPanel
|
||||
private Text rmyAvgForceText { get; set; }
|
||||
private Text PeakForceText { get; set; }
|
||||
private Text rmyPeakForceText { get; set; }
|
||||
private bool interruptFlag{ get; set; }
|
||||
|
||||
void TimerTicks()
|
||||
{
|
||||
@@ -801,21 +805,26 @@ public class RowerHomeScript : PFUIPanel
|
||||
PaintPullCurve((ushort)(a / 10));
|
||||
if (RowerData == null) return;
|
||||
#endif
|
||||
#if !UNITY_EDITOR
|
||||
//#if !UNITY_EDITOR
|
||||
if (Rower == null)
|
||||
{
|
||||
interruptFlag = true;
|
||||
//HandleDiscardDirect();
|
||||
isPause = true;
|
||||
UIManager.ShowConfirm(App.GetLocalString("Warning"), App.GetLocalString("Save the game?"), () =>
|
||||
{
|
||||
HandleSaveDirect();
|
||||
UIManager.CloseConfirm();
|
||||
interruptFlag = false;
|
||||
}, 2, ()=> {
|
||||
Init();
|
||||
interruptFlag = false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (interruptFlag) return;
|
||||
if (RowerData == null) return;
|
||||
#endif
|
||||
//#endif
|
||||
var heartRate = HeartRate ?? 0;
|
||||
BPMText.text = heartRate.ToString();
|
||||
//断线重连继续
|
||||
@@ -1087,7 +1096,10 @@ public class RowerHomeScript : PFUIPanel
|
||||
|
||||
void PaintPullCurve(object sender, EventArgs e)
|
||||
{
|
||||
//防止设备断开重连rowData对象发生变化,事件重复触发
|
||||
var ftms = (IRowerCommonData)sender;
|
||||
if (RowerData != ftms)
|
||||
return;
|
||||
//Debug.Log(ftms.PullValue);
|
||||
PaintPullCurve(ftms.PullValue);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class RowerDeviceView : MonoBehaviour
|
||||
/// </summary>
|
||||
private Sprite sprite3;
|
||||
|
||||
private float timer = 1.0f;
|
||||
private float timer = 0f;
|
||||
private void Awake()
|
||||
{
|
||||
title = this.transform.Find("Title").GetComponent<Text>();
|
||||
@@ -274,7 +274,7 @@ public class RowerDeviceView : MonoBehaviour
|
||||
|
||||
logo.sprite = sprite0;
|
||||
|
||||
searchState.text = App.GetLocalString("CHOOSE DEVICE");
|
||||
|
||||
var hasDevice = false;
|
||||
if (SensorType == SensorType.SpeedCadence)
|
||||
{
|
||||
@@ -284,6 +284,7 @@ public class RowerDeviceView : MonoBehaviour
|
||||
{
|
||||
hasDevice = App.MainDeviceAdapter.GetDevices().Any(d => d.Sensor == SensorType);
|
||||
}
|
||||
searchState.text = hasDevice ? App.GetLocalString("CHOOSE DEVICE") : App.GetLocalString("NO DEVICE");
|
||||
noDevice.text = "";// App.GetLocalString("NOCONN DEVICE"); //hasDevice ? App.GetLocalString("CHOOSE DEVICE") : ;
|
||||
if (hasDevice)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user