Merge remote-tracking branch 'origin/dev_cyp' into dev_lishuo
# Conflicts: # Assets/Scripts/Apis/Models/MapCompetition.cs
This commit is contained in:
commit
4a8239a2db
18 files changed
+1541
-286
No files matched your search
@@ -58,7 +58,8 @@ public class HomeController : PFUIPanel
|
||||
if (!System.IO.File.Exists(path))
|
||||
{
|
||||
//TODO: auto update
|
||||
Application.OpenURL("https://powerfun.oss-cn-shanghai.aliyuncs.com/Releases/PowerFunWorkouts.exe");
|
||||
UIManager.ShowDownloadWorkoutsPanel();
|
||||
//Application.OpenURL("https://powerfun.oss-cn-shanghai.aliyuncs.com/Releases/PowerFunWorkouts.exe");
|
||||
return;
|
||||
}
|
||||
Utils.ExecFile(path);
|
||||
|
||||
@@ -10,10 +10,10 @@ namespace Assets.Scripts.UI.Prefab.Race
|
||||
{
|
||||
public static Dictionary<string, string> statusDict = new Dictionary<string, string>()
|
||||
{
|
||||
{"Not started","1" },
|
||||
{"Appling","2" },
|
||||
{"All","" },
|
||||
{"Not started","1,2" },
|
||||
{"Racing","3" },
|
||||
{"Finished","4" },
|
||||
{"Done","4" },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ public class RaceHomeScript : RaceScript
|
||||
{
|
||||
base.Show();
|
||||
handleAvatar();
|
||||
GetData();
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
@@ -58,8 +59,7 @@ public class RaceHomeScript : RaceScript
|
||||
UIManager.ShowRaceListPanel();
|
||||
};
|
||||
});
|
||||
handleAvatar();
|
||||
GetData();
|
||||
|
||||
}
|
||||
|
||||
async void GetData()
|
||||
@@ -87,6 +87,15 @@ public class RaceHomeScript : RaceScript
|
||||
// game.transform.SetParent(rightContainer.Find("Container-1"));
|
||||
// game.transform.localScale = Vector3.one;
|
||||
//}
|
||||
foreach (Transform t in rightContainer.Find("Container-2"))
|
||||
{
|
||||
if (t.name != "BtnGoList")
|
||||
{
|
||||
t.gameObject.Destroy();
|
||||
}
|
||||
}
|
||||
scroll.transform.Find("DotList").DestroyChildren();
|
||||
scroll.content.DestroyChildren();
|
||||
for (; i < list.Count; i++)
|
||||
{
|
||||
var game = Instantiate<GameObject>(smallGame);
|
||||
|
||||
@@ -30,7 +30,7 @@ public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterH
|
||||
Utils.DisplayImage(transform.GetComponent<RawImage>(), mapCompetition.RouteCover, true);
|
||||
Utils.DisplayImage(transform.Find("AltitudeCurve").GetComponent<RawImage>(), mapCompetition.AltitudeGraph, true);
|
||||
transform.Find("InfoContainer/Text").GetComponent<Text>().SetTextWithEllipsis(mapCompetition.Title);
|
||||
transform.Find("GetReadyContainer").gameObject.SetActive(mapCompetition.Status != 4);
|
||||
transform.Find("GetReadyContainer").gameObject.SetActive(mapCompetition.Status != 3);
|
||||
transform.Find("GetReadyContainer-2").gameObject.SetActive(mapCompetition.Status == 1);
|
||||
//transform.Find("Text").GetComponent<Text>().text = mapCompetition.Title;
|
||||
//props.Find("DistanceText").GetComponent<Text>().text = $"{myMap.Distance.ToString(myMap.Distance > 1000 ? "#0" : "#0.00")}KM";
|
||||
@@ -55,71 +55,89 @@ public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterH
|
||||
|
||||
private void SetButtonGroup(MapCompetition mapCompetition)
|
||||
{
|
||||
if (mapCompetition.Status == 1)
|
||||
{
|
||||
var game = Resources.Load<GameObject>("UI/Prefab/Race/ButtonGroup/BtnContainer-Enter");
|
||||
var igame = Instantiate(game);
|
||||
igame.name = "BtnContainer";
|
||||
igame.GetComponent<RaceButtonGroupScript>().map = mapCompetition;
|
||||
igame.GetComponent<RaceButtonGroupScript>().parent = transform;
|
||||
igame.transform.SetParent(transform);
|
||||
igame.transform.localScale = Vector3.one;
|
||||
var loc = Vector3.zero;
|
||||
loc.y = myType == ItemType.big ? -252 : -257;
|
||||
igame.transform.localPosition = loc;
|
||||
}
|
||||
else if (mapCompetition.Status == 4)
|
||||
{
|
||||
var game = Resources.Load<GameObject>("UI/Prefab/Race/ButtonGroup/BtnContainer-Watch");
|
||||
var igame = Instantiate(game);
|
||||
igame.name = "BtnContainer";
|
||||
igame.GetComponent<RaceButtonGroupScript>().map = mapCompetition;
|
||||
igame.GetComponent<RaceButtonGroupScript>().parent = transform;
|
||||
igame.transform.SetParent(transform);
|
||||
igame.transform.localScale = Vector3.one;
|
||||
var loc = Vector3.zero;
|
||||
loc.y = myType == ItemType.big ? -252 : -257;
|
||||
igame.transform.localPosition = loc;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (myType == ItemType.big)
|
||||
{
|
||||
var game = Resources.Load<GameObject>("UI/Prefab/Race/ButtonGroup/BtnContainer-Double-H");
|
||||
var igame = Instantiate(game);
|
||||
igame.name = "BtnContainer";
|
||||
igame.GetComponent<RaceButtonGroupScript>().map = mapCompetition;
|
||||
igame.GetComponent<RaceButtonGroupScript>().parent = transform;
|
||||
igame.transform.Find("BtnJoin").gameObject.SetActive(mapCompetition.CanJoin);
|
||||
igame.transform.Find("BtnCancel").gameObject.SetActive(mapCompetition.HasJoin);
|
||||
igame.transform.SetParent(transform);
|
||||
igame.transform.localScale = Vector3.one;
|
||||
igame.transform.GetComponent<RectTransform>().anchorMax = new Vector2(0, 0);
|
||||
igame.transform.GetComponent<RectTransform>().anchorMin = new Vector2(1, 0);
|
||||
igame.transform.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0);
|
||||
var loc = Vector3.zero;
|
||||
loc.y = 20;
|
||||
igame.transform.GetComponent<RectTransform>().anchoredPosition = loc;
|
||||
}
|
||||
else
|
||||
{
|
||||
var game = Resources.Load<GameObject>("UI/Prefab/Race/ButtonGroup/BtnContainer-Double-V");
|
||||
var igame = Instantiate(game);
|
||||
igame.name = "BtnContainer";
|
||||
igame.GetComponent<RaceButtonGroupScript>().map = mapCompetition;
|
||||
igame.GetComponent<RaceButtonGroupScript>().parent = transform;
|
||||
igame.transform.Find("BtnJoin").gameObject.SetActive(mapCompetition.CanJoin);
|
||||
igame.transform.Find("BtnCancel").gameObject.SetActive(mapCompetition.HasJoin);
|
||||
igame.transform.SetParent(transform);
|
||||
igame.transform.localScale = Vector3.one;
|
||||
igame.transform.GetComponent<RectTransform>().anchorMax = new Vector2(0, 0);
|
||||
igame.transform.GetComponent<RectTransform>().anchorMin = new Vector2(1, 0);
|
||||
igame.transform.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0);
|
||||
var loc = Vector3.zero;
|
||||
loc.y = 20;
|
||||
igame.transform.GetComponent<RectTransform>().anchoredPosition = loc;
|
||||
}
|
||||
}
|
||||
var container = transform.Find("BtnContainer");
|
||||
container.GetComponent<RaceButtonGroupScript>().map = mapCompetition;
|
||||
container.GetComponent<RaceButtonGroupScript>().parent = transform;
|
||||
container.Find("BtnCancel").gameObject.SetActive(mapCompetition.CanCancelJoin);
|
||||
container.Find("BtnJoin").gameObject.SetActive(mapCompetition.CanJoin);
|
||||
container.Find("BtnEnter").gameObject.SetActive(mapCompetition.Status != 4);
|
||||
container.Find("BtnWatch").gameObject.SetActive(mapCompetition.Status == 4);
|
||||
//if (transform.Find("BtnContainer") != null)
|
||||
//{
|
||||
// transform.Find("BtnContainer").gameObject.Destroy();
|
||||
//}
|
||||
//if (mapCompetition.Status == 1)
|
||||
//{
|
||||
// var game = Resources.Load<GameObject>("UI/Prefab/Race/ButtonGroup/BtnContainer-Enter");
|
||||
// var igame = Instantiate(game);
|
||||
// igame.name = "BtnContainer";
|
||||
// igame.GetComponent<RaceButtonGroupScript>().map = mapCompetition;
|
||||
// igame.GetComponent<RaceButtonGroupScript>().parent = transform;
|
||||
// igame.transform.SetParent(transform);
|
||||
// igame.transform.localScale = Vector3.one;
|
||||
// var loc = Vector3.zero;
|
||||
// loc.y = myType == ItemType.big ? -252 : -257;
|
||||
// igame.transform.localPosition = loc;
|
||||
//}
|
||||
//else
|
||||
//if (mapCompetition.Status == 4)
|
||||
//{
|
||||
// var game = Resources.Load<GameObject>("UI/Prefab/Race/ButtonGroup/BtnContainer-Watch");
|
||||
// var igame = Instantiate(game);
|
||||
// igame.name = "BtnContainer";
|
||||
// igame.GetComponent<RaceButtonGroupScript>().map = mapCompetition;
|
||||
// igame.GetComponent<RaceButtonGroupScript>().parent = transform;
|
||||
// igame.transform.SetParent(transform);
|
||||
// igame.transform.localScale = Vector3.one;
|
||||
// var loc = Vector3.zero;
|
||||
// loc.y = myType == ItemType.big ? -252 : -257;
|
||||
// igame.transform.localPosition = loc;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// if (myType == ItemType.big)
|
||||
// {
|
||||
// var game = Resources.Load<GameObject>("UI/Prefab/Race/ButtonGroup/BtnContainer-Double-H");
|
||||
// var igame = Instantiate(game);
|
||||
// igame.name = "BtnContainer";
|
||||
// igame.GetComponent<RaceButtonGroupScript>().map = mapCompetition;
|
||||
// igame.GetComponent<RaceButtonGroupScript>().parent = transform;
|
||||
// igame.transform.Find("BtnJoin").gameObject.SetActive(mapCompetition.CanJoin);
|
||||
// igame.transform.Find("BtnCancel").gameObject.SetActive(mapCompetition.CanCancelJoin);
|
||||
// igame.transform.SetParent(transform);
|
||||
// igame.transform.localScale = Vector3.one;
|
||||
// igame.transform.GetComponent<RectTransform>().anchorMax = new Vector2(0, 0);
|
||||
// igame.transform.GetComponent<RectTransform>().anchorMin = new Vector2(1, 0);
|
||||
// igame.transform.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0);
|
||||
// var loc = Vector3.zero;
|
||||
// loc.y = 20;
|
||||
// loc.y = 20;
|
||||
// igame.transform.GetComponent<RectTransform>().anchoredPosition = loc;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var game = Resources.Load<GameObject>("UI/Prefab/Race/ButtonGroup/BtnContainer-Double-V");
|
||||
// var igame = Instantiate(game);
|
||||
// igame.name = "BtnContainer";
|
||||
// igame.GetComponent<RaceButtonGroupScript>().map = mapCompetition;
|
||||
// igame.GetComponent<RaceButtonGroupScript>().parent = transform;
|
||||
// igame.transform.Find("BtnJoin").gameObject.SetActive(mapCompetition.CanJoin);
|
||||
// igame.transform.Find("BtnCancel").gameObject.SetActive(mapCompetition.CanCancelJoin);
|
||||
|
||||
// igame.transform.SetParent(transform);
|
||||
// igame.transform.localScale = Vector3.one;
|
||||
// igame.transform.GetComponent<RectTransform>().anchorMax = new Vector2(0, 0);
|
||||
// igame.transform.GetComponent<RectTransform>().anchorMin = new Vector2(1, 0);
|
||||
// igame.transform.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0);
|
||||
// var loc = Vector3.zero;
|
||||
// loc.y = 20;
|
||||
// igame.transform.GetComponent<RectTransform>().anchoredPosition = loc;
|
||||
// }
|
||||
//}
|
||||
//if (transform.Find("Masking").GetComponent<CanvasGroup>().alpha == 1)
|
||||
//{
|
||||
// transform.Find("BtnContainer").GetComponent<CanvasGroup>().alpha = 1;
|
||||
//}
|
||||
}
|
||||
|
||||
private Dictionary<int, string> statusColorDict = new Dictionary<int, string>
|
||||
@@ -136,9 +154,9 @@ public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterH
|
||||
else
|
||||
{
|
||||
status.GetComponent<RawImage>().color = Utils.HexToColorHtml(statusColorDict[mapCompetition.Status]);
|
||||
if (mapCompetition.Status == 2 && mapCompetition.HasJoin)
|
||||
if (mapCompetition.Status == 2 && !mapCompetition.HasJoin)
|
||||
{
|
||||
status.Find("Text").GetComponent<Text>().text = "Applied";
|
||||
status.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -149,7 +167,6 @@ public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterH
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
transform.Find("Masking").GetComponent<CanvasGroup>().DOFade(0, 0.5f);
|
||||
transform.Find("AltitudeCurve").GetComponent<RawImage>().DOFade(0, 0.5f);
|
||||
transform.Find("InfoContainer/Text").GetComponent<CanvasGroup>().DOFade(1, 0.5f);
|
||||
@@ -176,7 +193,6 @@ public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterH
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
Cursor.SetCursor(Resources.Load<Texture2D>("Images/PointerButtonHover"), Vector2.zero, CursorMode.Auto);
|
||||
transform.Find("Masking").GetComponent<CanvasGroup>().DOFade(1, 0.5f);
|
||||
transform.Find("AltitudeCurve").GetComponent<RawImage>().DOFade(1, 0.5f);
|
||||
transform.Find("InfoContainer/Text").GetComponent<CanvasGroup>().DOFade(0, 0.5f);
|
||||
@@ -211,12 +227,18 @@ public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterH
|
||||
var res = ConfigHelper.mapCompetitionApi.ApplyMapCompetition(mapCompetition.Id);
|
||||
if (res.result)
|
||||
{
|
||||
mapCompetition.HasJoin = true;
|
||||
mapCompetition.CanJoin = false;
|
||||
transform.Find("CountContainer/Text").GetComponent<Text>().text = (++mapCompetition.ApplyCount).ToString();
|
||||
SetStatus(mapCompetition);
|
||||
transform.Find("BtnContainer").gameObject.Destroy();
|
||||
SetButtonGroup(mapCompetition);
|
||||
|
||||
//mapCompetition.HasJoin = true;
|
||||
//mapCompetition.CanJoin = false;
|
||||
//transform.Find("CountContainer/Text").GetComponent<Text>().text = (++mapCompetition.ApplyCount).ToString();
|
||||
//SetStatus(mapCompetition);
|
||||
//transform.Find("BtnContainer").gameObject.Destroy();
|
||||
//SetButtonGroup(mapCompetition);
|
||||
var res1 = ConfigHelper.mapCompetitionApi.GetById(mapCompetition.Id);
|
||||
if (res1.result)
|
||||
{
|
||||
Initial(res1.data, null);
|
||||
}
|
||||
Utils.showToast(null, "Successful application!", type: 1);
|
||||
}
|
||||
else
|
||||
@@ -229,12 +251,17 @@ public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterH
|
||||
var res = ConfigHelper.mapCompetitionApi.CancelMapCompetition(mapCompetition.Id);
|
||||
if (res.result)
|
||||
{
|
||||
mapCompetition.HasJoin = false;
|
||||
mapCompetition.CanJoin = true;
|
||||
transform.Find("CountContainer/Text").GetComponent<Text>().text = (--mapCompetition.ApplyCount).ToString();
|
||||
SetStatus(mapCompetition);
|
||||
transform.Find("BtnContainer").gameObject.Destroy();
|
||||
SetButtonGroup(mapCompetition);
|
||||
//mapCompetition.HasJoin = false;
|
||||
//mapCompetition.CanJoin = true;
|
||||
//transform.Find("CountContainer/Text").GetComponent<Text>().text = (--mapCompetition.ApplyCount).ToString();
|
||||
//SetStatus(mapCompetition);
|
||||
//transform.Find("BtnContainer").gameObject.Destroy();
|
||||
//SetButtonGroup(mapCompetition);
|
||||
var res1 = ConfigHelper.mapCompetitionApi.GetById(mapCompetition.Id);
|
||||
if (res1.result)
|
||||
{
|
||||
Initial(res1.data, null);
|
||||
}
|
||||
Utils.showToast(null, "Successful cancellation application!", type: 1);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -26,6 +26,7 @@ public class RaceListScript : RaceScript
|
||||
{
|
||||
base.Show();
|
||||
handleAvatar();
|
||||
//Refresh();
|
||||
}
|
||||
//筛选条件
|
||||
void Start()
|
||||
@@ -44,24 +45,66 @@ public class RaceListScript : RaceScript
|
||||
var button = t.GetComponent<Button>();
|
||||
var image = t.GetComponent<Image>();
|
||||
var text = t.Find("Text").GetComponent<Text>();
|
||||
UIManager.AddEvent(button.gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
if (t.name == "Btn1")
|
||||
{
|
||||
Color c1 = Utils.HexToColorHtml("#23232D");
|
||||
if (image.color.r == c1.r && image.color.g == c1.g && image.color.b == c1.b)
|
||||
image.color = Utils.HexToColorHtml("#F93086");
|
||||
text.color = new Color(1, 1, 1, 1);
|
||||
UIManager.AddEvent(button.gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
image.color = Utils.HexToColorHtml("#F93086");
|
||||
text.color = new Color(1, 1, 1, 1);
|
||||
statusOptions.Add(RaceFilterOptions.statusDict[text.text]);
|
||||
}
|
||||
else
|
||||
foreach (Transform t1 in statusOptionContainer)
|
||||
{
|
||||
var image1 = t1.GetComponent<Image>();
|
||||
var text1 = t1.Find("Text").GetComponent<Text>();
|
||||
if (t1.name == t.name)
|
||||
{
|
||||
image1.color = Utils.HexToColorHtml("#F93086");
|
||||
text1.color = new Color(1, 1, 1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
image1.color = Utils.HexToColorHtml("#23232D");
|
||||
text1.color = new Color(1, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
statusOptions.Clear();
|
||||
scroll.GetComponent<ScrollRect>().verticalNormalizedPosition = 1;
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
UIManager.AddEvent(button.gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
image.color = c1;
|
||||
text.color = new Color(1, 1, 1, 1);
|
||||
statusOptions.Remove(RaceFilterOptions.statusDict[text.text]);
|
||||
}
|
||||
scroll.GetComponent<ScrollRect>().verticalNormalizedPosition = 1;
|
||||
Refresh();
|
||||
});
|
||||
Color c1 = Utils.HexToColorHtml("#23232D");
|
||||
if (image.color.r == c1.r && image.color.g == c1.g && image.color.b == c1.b)
|
||||
{
|
||||
image.color = Utils.HexToColorHtml("#F93086");
|
||||
text.color = new Color(1, 1, 1, 1);
|
||||
statusOptions.Add(RaceFilterOptions.statusDict[text.text]);
|
||||
}
|
||||
else
|
||||
{
|
||||
image.color = c1;
|
||||
text.color = new Color(1, 1, 1, 1);
|
||||
statusOptions.Remove(RaceFilterOptions.statusDict[text.text]);
|
||||
}
|
||||
Transform t1 = statusOptionContainer.GetChild(0);
|
||||
var image1 = t1.GetComponent<Image>();
|
||||
var text1 = t1.Find("Text").GetComponent<Text>();
|
||||
if (statusOptions.Count == 0)
|
||||
{
|
||||
image1.color = Utils.HexToColorHtml("#F93086");
|
||||
text1.color = new Color(1, 1, 1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
image1.color = Utils.HexToColorHtml("#23232D");
|
||||
text1.color = new Color(1, 1, 1, 1);
|
||||
}
|
||||
scroll.GetComponent<ScrollRect>().verticalNormalizedPosition = 1;
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
reserveContainer = transform.Find("ListContainer/Conditions/ReserveContainer");
|
||||
@@ -98,7 +141,11 @@ public class RaceListScript : RaceScript
|
||||
searchInput = transform.Find("ListContainer/Conditions/SearchInput");
|
||||
if (searchInput != null)
|
||||
{
|
||||
UIManager.AddEvent(searchInput.Find("Button").gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
//UIManager.AddEvent(searchInput.Find("Button").gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
//{
|
||||
// //onEndEdit();
|
||||
//});
|
||||
searchInput.GetComponent<InputField>().onEndEdit.AddListener((string s) =>
|
||||
{
|
||||
onEndEdit();
|
||||
});
|
||||
@@ -114,7 +161,6 @@ public class RaceListScript : RaceScript
|
||||
};
|
||||
});
|
||||
}
|
||||
handleAvatar();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
@@ -143,10 +189,10 @@ public class RaceListScript : RaceScript
|
||||
OnEndDrag(null);
|
||||
}
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Return))
|
||||
{
|
||||
onEndEdit();
|
||||
}
|
||||
//if (Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Return))
|
||||
//{
|
||||
// onEndEdit();
|
||||
//}
|
||||
}
|
||||
|
||||
private void OnEndDrag(BaseEventData arg0)
|
||||
|
||||
@@ -77,13 +77,30 @@ public class RaceScript : PFUIPanel
|
||||
if (map.Status == 1)
|
||||
{
|
||||
currentItem.Find("GetReadyContainer/Title").GetComponent<Text>().text = "Application Start Time";
|
||||
currentItem.Find("GetReadyContainer/Value").GetComponent<Text>().text =
|
||||
currentItem.Find("GetReadyContainer/Value").GetComponent<Text>().text =
|
||||
map.StartApplyTime.ToString("yyyy-MM-dd HH:mm");
|
||||
currentItem.Find("GetReadyContainer-2/Title").GetComponent<Text>().text = "Race Start Time";
|
||||
currentItem.Find("GetReadyContainer-2/Value").GetComponent<Text>().text =
|
||||
map.StartTime.ToString("yyyy-MM-dd HH:mm");
|
||||
|
||||
if ((map.StartApplyTime - UIManager.Now.GetDateTime()).TotalSeconds < 0 ||
|
||||
(map.StartTime - UIManager.Now.GetDateTime()).TotalSeconds < 0)
|
||||
{
|
||||
var res = ConfigHelper.mapCompetitionApi.GetById(map.Id);
|
||||
if (res.result)
|
||||
{
|
||||
currentItem.GetComponent<RaceItemScript>().Initial(res.data, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (map.Status == 4)
|
||||
{
|
||||
currentItem.Find("GetReadyContainer/Title").GetComponent<Text>().text = "Race End Time";
|
||||
currentItem.Find("GetReadyContainer/Value").GetComponent<Text>().text =
|
||||
map.FirstEndTime.HasValue?
|
||||
map.FirstEndTime.Value.ToString("yyyy-MM-dd HH:mm"):map.EndTime.ToString("yyyy-MM-dd HH:mm");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Dictionary<int,>
|
||||
var time = (map.Status == 2 ? map.StartTime.ToLocalTime() : map.EndTime.ToLocalTime()) - UIManager.Now.GetDateTime();
|
||||
@@ -91,7 +108,7 @@ public class RaceScript : PFUIPanel
|
||||
{
|
||||
currentItem.Find("GetReadyContainer").GetComponent<CanvasGroup>().alpha = 0;
|
||||
var res = ConfigHelper.mapCompetitionApi.GetById(map.Id);
|
||||
if (res.result)
|
||||
if (res.result)
|
||||
{
|
||||
currentItem.GetComponent<RaceItemScript>().Initial(res.data, null);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@@ -15,6 +17,19 @@ public class DownloadWorkoutsController : PFUIPanel
|
||||
ScrollRect scroll;
|
||||
string path;
|
||||
[SerializeField] Transform log;
|
||||
AppDownloadInfo wpf;
|
||||
public override void Show()
|
||||
{
|
||||
base.Show();
|
||||
Btn = transform.Find("Panel/BtnConfirm");
|
||||
BtnStart = transform.Find("Panel/BtnStart");
|
||||
Loading = transform.Find("Panel/LoadingContainer");
|
||||
scroll = transform.Find("Panel/Scroll View").GetComponent<ScrollRect>();
|
||||
Exit = transform.Find("Panel/Exit");
|
||||
BtnStart.GetComponent<Button>().enabled = true;
|
||||
BtnStart.GetComponent<Button>().interactable = true;
|
||||
SetType(1);
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
Btn = transform.Find("Panel/BtnConfirm");
|
||||
@@ -22,63 +37,102 @@ public class DownloadWorkoutsController : PFUIPanel
|
||||
Loading = transform.Find("Panel/LoadingContainer");
|
||||
scroll = transform.Find("Panel/Scroll View").GetComponent<ScrollRect>();
|
||||
Exit = transform.Find("Panel/Exit");
|
||||
SetType(1);
|
||||
UIManager.AddEvent(Exit.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
Utils.showToast(gameObject, "Please update to the latest version.");
|
||||
//UIManager.CloseConfirm();
|
||||
if (request != null)
|
||||
{
|
||||
request.Abort();
|
||||
}
|
||||
if (_fs != null)
|
||||
{
|
||||
_fs.Close();
|
||||
}
|
||||
if (_netStream != null)
|
||||
{
|
||||
_netStream.Close();
|
||||
}
|
||||
gameObject.SetActive(false);
|
||||
});
|
||||
SetType(1);
|
||||
|
||||
//Button.GetComponent<Button>().enabled = false;
|
||||
//Button.GetComponent<Button>().interactable = false;
|
||||
path = Application.persistentDataPath + "/PowerFun.exe";
|
||||
path = Application.persistentDataPath + "/PowerFunWorkouts.exe";
|
||||
UIManager.AddEvent(Btn.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
Application.Quit();
|
||||
//Application.Quit();
|
||||
Utils.ExecFile(path);
|
||||
});
|
||||
UIManager.AddEvent(BtnStart.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (_base) =>
|
||||
UIManager.AddEvent(BtnStart.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick,async (_base) =>
|
||||
{
|
||||
if (App.UpdateObject != null)
|
||||
var res = await ConfigHelper.userApi.GetAppVersion();
|
||||
if (res.result)
|
||||
{
|
||||
BtnStart.GetComponent<Button>().enabled = false;
|
||||
BtnStart.GetComponent<Button>().interactable = false;
|
||||
StartCoroutine(DownLoadExe(App.UpdateObject.Url, path, (a, b, isComplete) =>
|
||||
wpf = res.data.WPF;
|
||||
if (wpf != null)
|
||||
{
|
||||
transform.Find("Panel/LoadingContainer/Text").GetComponent<Text>().text = $"Downloaded {a.ToString("#0")}M / {b.ToString("#0")}M";// string.Format(, a, b);
|
||||
transform.Find("Panel/LoadingContainer/Loading").GetComponent<Image>().fillAmount = (float)(a / b);
|
||||
if (isComplete)
|
||||
BtnStart.GetComponent<Button>().enabled = false;
|
||||
BtnStart.GetComponent<Button>().interactable = false;
|
||||
Debug.Log(path);
|
||||
StartCoroutine(DownLoadExe(wpf.Url, path, (a, b, isComplete) =>
|
||||
{
|
||||
SetType(3);
|
||||
|
||||
PlayerPrefs.SetString("exeVersion", App.UpdateObject.Code);
|
||||
new FileInfo(path + ".pfdownload").MoveTo(path);
|
||||
}
|
||||
}));
|
||||
Debug.Log($"{a} {b} {isComplete}");
|
||||
transform.Find("Panel/LoadingContainer/Text").GetComponent<Text>().text = $"Downloaded {a.ToString("#0")}M / {b.ToString("#0")}M";// string.Format(, a, b);
|
||||
transform.Find("Panel/LoadingContainer/Loading").GetComponent<Image>().fillAmount = (float)(a / b);
|
||||
if (isComplete)
|
||||
{
|
||||
SetType(3);
|
||||
PlayerPrefs.SetString("exeVersion_w", wpf.Version);
|
||||
new FileInfo(path + ".pfdownload").MoveTo(path);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
//if (App.UpdateObject != null)
|
||||
//{
|
||||
// BtnStart.GetComponent<Button>().enabled = false;
|
||||
// BtnStart.GetComponent<Button>().interactable = false;
|
||||
// StartCoroutine(DownLoadExe(App.UpdateObject.Url, path, (a, b, isComplete) =>
|
||||
// {
|
||||
// transform.Find("Panel/LoadingContainer/Text").GetComponent<Text>().text = $"Downloaded {a.ToString("#0")}M / {b.ToString("#0")}M";// string.Format(, a, b);
|
||||
// transform.Find("Panel/LoadingContainer/Loading").GetComponent<Image>().fillAmount = (float)(a / b);
|
||||
// if (isComplete)
|
||||
// {
|
||||
// SetType(3);
|
||||
|
||||
// PlayerPrefs.SetString("exeVersion", App.UpdateObject.Code);
|
||||
// new FileInfo(path + ".pfdownload").MoveTo(path);
|
||||
// }
|
||||
// }));
|
||||
//}
|
||||
});
|
||||
//transform
|
||||
if (App.UpdateObject != null)
|
||||
{
|
||||
|
||||
for (var i = 0; i < App.UpdateObject.UpdateLog.Count; i++)
|
||||
{
|
||||
var newLog = Instantiate<Transform>(log);
|
||||
newLog.GetComponent<DownloadLog>().Initial(App.UpdateObject.UpdateLog[i]);
|
||||
if (i == App.UpdateObject.UpdateLog.Count - 1)
|
||||
{
|
||||
newLog.GetComponent<DownloadLog>().HideLine();
|
||||
}
|
||||
newLog.SetParent(scroll.content);
|
||||
newLog.localScale = Vector3.one;
|
||||
}
|
||||
}
|
||||
//if (App.UpdateObject != null)
|
||||
//{
|
||||
// for (var i = 0; i < App.UpdateObject.UpdateLog.Count; i++)
|
||||
// {
|
||||
// var newLog = Instantiate<Transform>(log);
|
||||
// newLog.GetComponent<DownloadLog>().Initial(App.UpdateObject.UpdateLog[i]);
|
||||
// if (i == App.UpdateObject.UpdateLog.Count - 1)
|
||||
// {
|
||||
// newLog.GetComponent<DownloadLog>().HideLine();
|
||||
// }
|
||||
// newLog.SetParent(scroll.content);
|
||||
// newLog.localScale = Vector3.one;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
bool stop = false;
|
||||
HttpWebRequest request;
|
||||
Stream _fs, _netStream;
|
||||
/*下载文件*/
|
||||
IEnumerator DownLoadExe(string url, string desFileName, Action<double, double, bool> OnDownloadProgressEvent)
|
||||
{
|
||||
string version = null;
|
||||
if (App.UpdateObject != null)
|
||||
if (wpf != null)
|
||||
{
|
||||
version = App.UpdateObject.Code;
|
||||
version = wpf.Version;
|
||||
}
|
||||
if (File.Exists(desFileName))
|
||||
{
|
||||
@@ -89,9 +143,9 @@ public class DownloadWorkoutsController : PFUIPanel
|
||||
}
|
||||
else
|
||||
{
|
||||
if (version == PlayerPrefs.GetString("exeVersion"))
|
||||
if (version == PlayerPrefs.GetString("exeVersion_w"))
|
||||
{
|
||||
Application.Quit();
|
||||
//Application.Quit();
|
||||
Utils.ExecFile(desFileName);
|
||||
yield break;
|
||||
}
|
||||
@@ -108,8 +162,9 @@ public class DownloadWorkoutsController : PFUIPanel
|
||||
File.Delete(desFileName + ".pfdownload");
|
||||
}
|
||||
SetType(2);
|
||||
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
|
||||
request = (HttpWebRequest)HttpWebRequest.Create(url);
|
||||
request.Timeout = 5000;
|
||||
|
||||
WebResponse response = request.GetResponse();
|
||||
//UnityWebRequest request = UnityWebRequest.Get(url);
|
||||
//yield return request.SendWebRequest();
|
||||
@@ -121,6 +176,8 @@ public class DownloadWorkoutsController : PFUIPanel
|
||||
using (FileStream fs = new FileStream(desFileName + ".pfdownload", FileMode.Create))
|
||||
using (Stream netStream = response.GetResponseStream())
|
||||
{
|
||||
_fs = fs;
|
||||
_netStream = netStream;
|
||||
nReadSize = netStream.Read(nbytes, 0, packLength);
|
||||
while (nReadSize > 0)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user