设备连接界面文案与交互调整

This commit is contained in:
lishuo committed 2022-05-31 18:25:53 +08:00
1 parent 2524e3a004
commit a1010091f8
9 files changed
+78 -45

No files matched your search

+16
View File
@@ -23,6 +23,22 @@ public static class PFConstants
return Application.persistentDataPath + "/RowerRecords/";
}
}
/// <summary>
/// 划船机训练保存在本地的路径
/// </summary>
public static string RowerRecordCacheFolder
{
get
{
if (!Directory.Exists(Application.persistentDataPath + "/RowerRecordCaches/"))
{
Directory.CreateDirectory(Application.persistentDataPath + "/RowerRecordCaches/");
}
return Application.persistentDataPath + "/RowerRecordCaches/";
}
}
/// <summary>
/// 课程训练保存在本地的路径
/// </summary>
@@ -202,27 +202,6 @@ public class ConnectDeviceModal : PFUIPanel
UIManager.AddEvent(deviceItemObj.gameObject, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
{
deviceItemObj.Set(true);
var trainer = SensorType == SensorType.Trainer && deviceItemObj.DeviceInfo.State == DeviceState.Connected;
var nontrainer = deviceItemObj.DeviceInfo.Sensor != SensorType.Trainer && SensorType != SensorType.Trainer && deviceItemObj.DeviceInfo.State == DeviceState.Connected;
if (trainer || nontrainer)
{
connectBtnText.text = App.GetLocalString("DISCONNECT");
connectBtnText.GetComponent<PFUIText>().key = "DISCONNECT";
}
else
{
connectBtnText.text = App.GetLocalString("CONNECT");
connectBtnText.GetComponent<PFUIText>().key = "CONNECT";
}
foreach (var item in deviceList)
{
if (item.Key != deviceItemObj.DeviceInfo.Id)
{
item.Value.Set(false);
}
}
}));
//UIManager.AddEvent(deviceItemObj.gameObject, EventTriggerType.Deselect, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
@@ -259,6 +238,14 @@ public class ConnectDeviceModal : PFUIPanel
//connectBtn.text.text = "DISCOUNECT";
noDevice.text = firstDevice.DeviceInfo.Name;
}
else
{
var defaultDevice = deviceList.FirstOrDefault();
if (defaultDevice.Value != null)
{
defaultDevice.Value.Set(true);
}
}
//DeviceItem firstDevice;
//var devicesTemp = deviceList.Select(d => d.Value).Where(d => d.DeviceInfo.State == DeviceState.Connected);
//if(SensorType == SensorType.Cadence || SensorType == SensorType.SpeedCadence)
@@ -268,6 +255,30 @@ public class ConnectDeviceModal : PFUIPanel
}
}
}
//选中需要连接的设备
public void SelectDevice(DeviceItem deviceItemObj)
{
var trainer = SensorType == SensorType.Trainer && deviceItemObj.DeviceInfo.State == DeviceState.Connected;
var nontrainer = deviceItemObj.DeviceInfo.Sensor != SensorType.Trainer && SensorType != SensorType.Trainer && deviceItemObj.DeviceInfo.State == DeviceState.Connected;
if (trainer || nontrainer)
{
connectBtnText.text = App.GetLocalString("DISCONNECT");
connectBtnText.GetComponent<PFUIText>().key = "DISCONNECT";
}
else
{
connectBtnText.text = App.GetLocalString("CONNECT");
connectBtnText.GetComponent<PFUIText>().key = "CONNECT";
}
foreach (var item in deviceList)
{
if (item.Key != deviceItemObj.DeviceInfo.Id)
{
item.Value.Set(false);
}
}
}
public override void Show()
{
@@ -153,6 +153,8 @@ public class DeviceItem : Selectable, IEventSystemHandler, IPointerClickHandler
if (this.isOn)
{
SetSelectedStyle();
var manager = FindObjectOfType<ConnectDeviceModal>();
manager.SelectDevice(this);
}
else
{
@@ -137,7 +137,10 @@ public class DeviceView : MonoBehaviour
connectButtonClick();
}));
#endif
UIManager.AddEvent(mSearchButton, EventTriggerType.PointerClick, new UnityAction<UnityEngine.EventSystems.BaseEventData>(e =>
{
connectButtonClick();
}));
UIManager.AddEvent(mPairButton, EventTriggerType.PointerClick, new UnityAction<UnityEngine.EventSystems.BaseEventData>(e =>
{
connectButtonClick();
@@ -857,7 +857,7 @@ public class RowerHomeScript : PFUIPanel
{
try
{
var files = Directory.GetFiles(PFConstants.RowerRecordFolder);
var files = Directory.GetFiles(PFConstants.RowerRecordCacheFolder);
if (files.Length > 0)
{
UIManager.ShowConfirm(App.GetLocalString("Warn"), App.GetLocalString("continue a game?"), () =>
@@ -894,7 +894,7 @@ public class RowerHomeScript : PFUIPanel
{
try
{
var path = $"{PFConstants.RowerRecordFolder}/{Id}.txt";
var path = $"{PFConstants.RowerRecordCacheFolder}/{Id}.txt";
File.WriteAllText(path, string.Join("\r\n", records));
}
catch (Exception e)
@@ -67,7 +67,7 @@ public class RowerDeviceView : MonoBehaviour
mSearchButton = unconnectionPanel.transform.Find("SearchButton").gameObject;
mPairButton = unconnectionPanel.transform.Find("PairButton").gameObject;
searchState = unconnectionPanel.transform.Find("SearchState").GetComponent<Text>();
mPairButton.SetActive(false);
//mPairButton.SetActive(false);
connectionPanel = this.transform.Find("ConnectionPanel").gameObject;
var material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
@@ -278,7 +278,7 @@ public class RowerDeviceView : MonoBehaviour
#if !(UNITY_IOS || UNITY_ANDROID)
mSearchButton.SetActive(true);
#endif
mPairButton.SetActive(false);
//mPairButton.SetActive(false);
}
}
else if(connectedDevice.State == DeviceState.Connecting)