Merge remote-tracking branch 'origin/dev' into dev_cyp
# Conflicts: # Assets/Resources/Images/back.png.meta # Assets/Resources/Images/change account.png.meta # Assets/Scripts/UI/Prefab/Panel/EditUserController.cs
This commit is contained in:
commit
f4cbad819b
22 files changed
+1829
-323
No files matched your search
@@ -1,10 +1,14 @@
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Assets.Scripts.UI.Control;
|
||||
using Assets.Scripts.UI.Prefab.Login;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
public class Tips : MonoBehaviour
|
||||
{
|
||||
@@ -20,10 +24,16 @@ public class Tips : MonoBehaviour
|
||||
private Text Count;
|
||||
private Text Distance;
|
||||
private Text TotalClimb;
|
||||
private PFUIButton pFUIButton;
|
||||
private PfUIButton pFUIButton;
|
||||
private RawImage countryIcon;
|
||||
private Text averageGrade;
|
||||
private List<CountryModel> countryList;
|
||||
private GameObject level;
|
||||
private GameObject m3DIcon;
|
||||
private void Awake()
|
||||
{
|
||||
var material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
var materialSource = Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial");
|
||||
var material = Instantiate(materialSource);
|
||||
|
||||
var rect = ((RectTransform)transform).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, 40f, 0));
|
||||
@@ -34,11 +44,25 @@ public class Tips : MonoBehaviour
|
||||
Distance = this.transform.Find("Distance").GetComponent<Text>();
|
||||
TotalClimb = this.transform.Find("TotalClimb").GetComponent<Text>();
|
||||
|
||||
pFUIButton = this.transform.Find("Ride").GetComponent<PFUIButton>();
|
||||
pFUIButton = this.transform.Find("Ride").GetComponent<PfUIButton>();
|
||||
UIManager.AddEvent(pFUIButton.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (e) => {
|
||||
App.RouteIdParam = _model.Id;
|
||||
SceneManager.LoadScene("Ride");
|
||||
});
|
||||
|
||||
averageGrade = this.transform.Find("AverageGrade").GetComponent<Text>();
|
||||
countryIcon = this.transform.Find("CountryIco").GetComponent<RawImage>();
|
||||
|
||||
var countryJson = Resources.Load<TextAsset>("UI/flags-mini").text;
|
||||
countryList = JsonConvert.DeserializeObject<List<CountryModel>>(countryJson);
|
||||
|
||||
level = this.transform.Find("Level").gameObject;
|
||||
var material1 = Instantiate(materialSource);
|
||||
var rect1 = ((RectTransform)level.transform).rect;
|
||||
material1.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect1.width, rect1.height, rect1.height, 0));
|
||||
level.GetComponent<Image>().material = material1;
|
||||
|
||||
m3DIcon = this.transform.Find("3DIcon").gameObject;
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
@@ -63,17 +87,30 @@ public class Tips : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
//this.gameObject.SetActive(true);
|
||||
_model = model;
|
||||
|
||||
Name.text = _model.Name;
|
||||
|
||||
Count.text = _model.TheHeat.ToString();
|
||||
Distance.text = _model.Distance.ToString("#.0")+"KM";
|
||||
TotalClimb.text = _model.TotalClimb.ToString();
|
||||
|
||||
averageGrade.text = _model.AverageGrade.ToString() + "%";
|
||||
|
||||
//var country = countryList.SingleOrDefault(r => r.abbreviation.Equals(_model.CountryCode, StringComparison.InvariantCultureIgnoreCase));
|
||||
//if(country )
|
||||
var country = Resources.Load<Sprite>($"UI/flags-mini/{ _model.CountryCode.ToLower() }");
|
||||
if(country != null)
|
||||
{
|
||||
//this.gameObject.SetActive(true);
|
||||
_model = model;
|
||||
|
||||
Name.text = _model.Name;
|
||||
|
||||
Count.text = _model.TheHeat.ToString();
|
||||
Distance.text = _model.Distance.ToString("#.0")+"KM";
|
||||
TotalClimb.text = _model.TotalClimb.ToString();
|
||||
countryIcon.texture = country.texture;
|
||||
}
|
||||
|
||||
level.transform.Find("Text").GetComponent<Text>().text = _model.Hard;
|
||||
|
||||
m3DIcon.SetActive(_model.Enable3D);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ConnectDeviceModal : PFUIPanel
|
||||
private Image Logo;
|
||||
private UnityEngine.Object deviceItem;
|
||||
private VerticalLayoutGroup content;
|
||||
private PFUIButton connectBtn;
|
||||
private PfUIButton connectBtn;
|
||||
private Dictionary<ushort, DeviceItem> deviceList;
|
||||
|
||||
protected override void Awake()
|
||||
@@ -60,7 +60,7 @@ public class ConnectDeviceModal : PFUIPanel
|
||||
|
||||
deviceItem = Resources.Load("UI/Prefab/Device/DeviceItem");
|
||||
|
||||
connectBtn = container.Find("ConnectBtn").GetComponent<PFUIButton>();
|
||||
connectBtn = container.Find("ConnectBtn").GetComponent<PfUIButton>();
|
||||
|
||||
UIManager.AddEvent(connectBtn.gameObject, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
|
||||
{
|
||||
|
||||
@@ -41,14 +41,6 @@ public class BigMapController : PFUIPanel
|
||||
mapManager = this.transform.Find("Map").GetComponent<AbstractMap>();
|
||||
mapManager.OnInitialized += MapManager_OnInitialized;
|
||||
mapManager.OnUpdated += MapManager_OnUpdated;
|
||||
mapManager.OnMapRedrawn += () =>
|
||||
{
|
||||
//Debug.Log("map redrawn");
|
||||
};
|
||||
mapManager.OnTileFinished += (e) =>
|
||||
{
|
||||
//Debug.Log("finished");
|
||||
};
|
||||
|
||||
//// mapManager.OnTileFinished += MapManager_OnTileFinished;
|
||||
//mapManager.SetZoom(13);
|
||||
@@ -58,26 +50,22 @@ public class BigMapController : PFUIPanel
|
||||
|
||||
canvas = this.transform.Find("Canvas").gameObject;
|
||||
canvas.GetComponent<Canvas>().worldCamera = Camera.main;
|
||||
var goList = canvas.transform.Find("GoList");
|
||||
var goList = canvas.transform.Find("SwitchMode");
|
||||
SetRounded(goList, 64);
|
||||
UIManager.AddEvent(goList.gameObject, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
//App.MainSceneParam.Add("Name", "MapListPanel");
|
||||
//SceneManager.LoadScene("MainScene");
|
||||
|
||||
mapManager.Destroy();
|
||||
|
||||
UIManager.ShowMapListPanel();
|
||||
|
||||
//this.gameObject.SetActive(false);
|
||||
DestroyImmediate(this.gameObject);
|
||||
});
|
||||
|
||||
var panel = canvas.transform.Find("Panel");
|
||||
SetRounded(panel,30f);
|
||||
base.SetRounded(panel,30f);
|
||||
|
||||
content = panel.Find("Scroll View").Find("Viewport").Find("Content").gameObject;
|
||||
var input = panel.Find("InputField");
|
||||
SetRounded(input, 20f);
|
||||
base.SetRounded(input, 20f);
|
||||
keyword = input.Find("Text").GetComponent<Text>();
|
||||
var searchBtn = input.Find("Search").gameObject;
|
||||
UIManager.AddEvent(searchBtn, EventTriggerType.PointerClick, Search);
|
||||
@@ -85,20 +73,26 @@ public class BigMapController : PFUIPanel
|
||||
tips = ((GameObject)Instantiate(Resources.Load("UI/Prefab/BigMap/Tips"), canvas.transform.Find("TipsContainer"))).GetComponent<Tips>();
|
||||
tips.Hide();
|
||||
|
||||
BindHeadImage();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 给对象设置圆角
|
||||
/// 绑定头像
|
||||
/// </summary>
|
||||
/// <param name="panel"></param>
|
||||
/// <param name="radius"></param>
|
||||
void SetRounded(Transform panel, float radius)
|
||||
void BindHeadImage()
|
||||
{
|
||||
var rounded = Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial");
|
||||
var material = Instantiate(rounded);
|
||||
var rect = ((RectTransform)panel).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, radius, 0));
|
||||
panel.GetComponent<Image>().material = material;
|
||||
var headImage = canvas.transform.Find("HeadImage").GetComponent<RawImage>();
|
||||
//var material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
var rect = ((RectTransform)headImage.transform).rect;
|
||||
//material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height, 0));
|
||||
//headImage.material = material;
|
||||
SetRounded(headImage.transform, rect.height);
|
||||
|
||||
Utils.DisplayImage(StartCoroutine, headImage, App.CurrentUser.WxHeadImg);
|
||||
|
||||
UIManager.AddEvent(headImage.gameObject, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
UIManager.ShowEditUserPanel();
|
||||
});
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
|
||||
@@ -37,7 +37,8 @@ public class DeviceController : PFUIPanel
|
||||
UIManager.AddEvent(mReturnBtn.gameObject, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
|
||||
{
|
||||
//UIManager.ShowHomePanel();
|
||||
UIManager.CloseModal();
|
||||
//UIManager.CloseModal();
|
||||
this.Close();
|
||||
}));
|
||||
|
||||
var bg = this.transform.Find("Status").Find("Bg");
|
||||
|
||||
@@ -6,6 +6,7 @@ using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
@@ -13,7 +14,6 @@ using UnityEngine.UI;
|
||||
public class EditUserController : PFUIPanel
|
||||
{
|
||||
private Button mSaveButton;
|
||||
private Button mReturnButton;
|
||||
private PFUIDropdown mSexDropdown;
|
||||
private PFUIDropdown mDayDropdown;
|
||||
private PFUIDropdown mMonthDropdown;
|
||||
@@ -22,6 +22,9 @@ public class EditUserController : PFUIPanel
|
||||
private Text mNameText;
|
||||
private RawImage mHeadImage;
|
||||
private UserApi userApi;
|
||||
private Button mCancelButton;
|
||||
private Button mBackButton;
|
||||
PfUIButton mChangeAvatar;
|
||||
protected override void Awake()
|
||||
{
|
||||
userApi = new UserApi();
|
||||
@@ -34,8 +37,43 @@ public class EditUserController : PFUIPanel
|
||||
mMonthDropdown = panel.Find("MonthDropdown").GetComponent<PFUIDropdown>();
|
||||
mDayDropdown = panel.Find("DayDropdown").GetComponent<PFUIDropdown>();
|
||||
mSaveButton = this.transform.Find("SaveButton").GetComponent<Button>();
|
||||
mReturnButton = transform.Find("CancelButton").GetComponent<Button>();
|
||||
mCancelButton = this.transform.Find("CancelButton").GetComponent<Button>();
|
||||
mHeadImage = this.transform.Find("HeadImage").GetComponent<RawImage>();
|
||||
mBackButton = this.transform.Find("BackButton").GetComponent<Button>();
|
||||
UIManager.AddEvent(mBackButton.gameObject, EventTriggerType.PointerClick, Cancel);
|
||||
|
||||
mChangeAvatar = this.transform.Find("ChangeAvatar").GetComponent<PfUIButton>();
|
||||
UIManager.AddEvent(mChangeAvatar.gameObject, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
OpenFileName ofn = new OpenFileName();
|
||||
|
||||
ofn.structSize = Marshal.SizeOf(ofn);
|
||||
|
||||
ofn.filter = "All Files\0*.*\0\0";
|
||||
|
||||
ofn.file = new string(new char[256]);
|
||||
|
||||
ofn.maxFile = ofn.file.Length;
|
||||
|
||||
ofn.fileTitle = new string(new char[64]);
|
||||
|
||||
ofn.maxFileTitle = ofn.fileTitle.Length;
|
||||
|
||||
ofn.initialDir = UnityEngine.Application.dataPath;//默认路径
|
||||
|
||||
ofn.title = "Open Project";
|
||||
|
||||
ofn.defExt = "JPG";//显示文件的类型
|
||||
//注意 一下项目不一定要全选 但是0x00000008项不要缺少
|
||||
ofn.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008;//OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR
|
||||
|
||||
|
||||
if (Win32.GetOpenFileName(ofn))
|
||||
{
|
||||
Debug.Log(ofn.file);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mSexDropdown.ClearOptions();
|
||||
mSexDropdown.AddOptions(new List<string>
|
||||
@@ -70,7 +108,6 @@ public class EditUserController : PFUIPanel
|
||||
{
|
||||
SetDayDropdown();
|
||||
};
|
||||
|
||||
|
||||
mDayDropdown.ClearOptions();
|
||||
SetDayDropdown();
|
||||
@@ -82,56 +119,44 @@ public class EditUserController : PFUIPanel
|
||||
// new Dropdown.OptionData()
|
||||
//});
|
||||
|
||||
LoadDataSyncAsync();
|
||||
LoadDataSync();
|
||||
|
||||
}
|
||||
async System.Threading.Tasks.Task Login()
|
||||
|
||||
void LoadDataSync()
|
||||
{
|
||||
var result = await new UserApi().Login("13115011550", "laozhong", "");
|
||||
App.CurrentUser = result.data;
|
||||
}
|
||||
async System.Threading.Tasks.Task LoadDataSyncAsync()
|
||||
{
|
||||
await Login();
|
||||
Material material = null;
|
||||
if (material == null)
|
||||
{
|
||||
material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
}
|
||||
var rect = ((RectTransform)mHeadImage.transform).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height, 0));
|
||||
mHeadImage.material = material;
|
||||
|
||||
SetRounded(mHeadImage.transform, rect.height);
|
||||
|
||||
var currentUser = App.CurrentUser;
|
||||
mIdText.text = "ID:" + currentUser.Id.ToString();
|
||||
|
||||
mIdText.text = currentUser.Id.ToString();
|
||||
mNameText.text = currentUser.Nickname;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(currentUser.WxHeadImg))
|
||||
{
|
||||
Utils.DisplayImage(StartCoroutine, mHeadImage, currentUser.WxHeadImg);
|
||||
}
|
||||
if (currentUser.Sex == 1)
|
||||
{
|
||||
mSexDropdown.SelectValue("男");
|
||||
}
|
||||
else
|
||||
{
|
||||
mSexDropdown.SelectValue("女");
|
||||
}
|
||||
if (currentUser.Birthday.HasValue)
|
||||
{
|
||||
var birthday = currentUser.Birthday.Value;
|
||||
mYearDropdown.SelectValue(birthday.Year.ToString());
|
||||
mMonthDropdown.SelectValue(birthday.Month.ToString());
|
||||
mDayDropdown.SelectValue(birthday.Day.ToString());
|
||||
}
|
||||
UIManager.AddEvent(mReturnButton.gameObject, EventTriggerType.PointerClick, Return);
|
||||
UIManager.AddEvent(mSaveButton.gameObject, EventTriggerType.PointerClick, Save);
|
||||
}
|
||||
Utils.DisplayImage(StartCoroutine, mHeadImage, currentUser.WxHeadImg);
|
||||
|
||||
private void Return(BaseEventData arg0)
|
||||
{
|
||||
UIManager.ShowUserInfoPanel();
|
||||
//if (!string.IsNullOrWhiteSpace(currentUser.WxHeadImg))
|
||||
//{
|
||||
// Utils.DisplayImage(StartCoroutine, mHeadImage, currentUser.WxHeadImg);
|
||||
//}
|
||||
//if (currentUser.Sex == 1)
|
||||
//{
|
||||
// mSexDropdown.SelectValue("男");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// mSexDropdown.SelectValue("女");
|
||||
//}
|
||||
//if (currentUser.Birthday.HasValue)
|
||||
//{
|
||||
// var birthday = currentUser.Birthday.Value;
|
||||
// mYearDropdown.SelectValue(birthday.Year.ToString());
|
||||
// mMonthDropdown.SelectValue(birthday.Month.ToString());
|
||||
// mDayDropdown.SelectValue(birthday.Day.ToString());
|
||||
//}
|
||||
|
||||
UIManager.AddEvent(mSaveButton.gameObject, EventTriggerType.PointerClick, Save);
|
||||
UIManager.AddEvent(mCancelButton.gameObject, EventTriggerType.PointerClick, Cancel);
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
@@ -181,4 +206,9 @@ public class EditUserController : PFUIPanel
|
||||
|
||||
UIManager.ShowAlert("result.errMsg");
|
||||
}
|
||||
|
||||
void Cancel(BaseEventData e)
|
||||
{
|
||||
UIManager.ShowHomePanel();
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,8 @@ public class MapListController : PFUIPanel
|
||||
//{
|
||||
// hardSelector.onValueChanged.AddListener(ChangeHard);
|
||||
//}
|
||||
btnMapMode = this.transform.Find("BtnMapMode").gameObject;
|
||||
btnMapMode = this.transform.Find("SwitchMode").gameObject;
|
||||
SetRounded(btnMapMode.transform, 64);
|
||||
UIManager.AddEvent(btnMapMode, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
UIManager.ShowBigMapPanel();
|
||||
@@ -97,7 +98,7 @@ public class MapListController : PFUIPanel
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
BindHeadImage();
|
||||
GetList();
|
||||
if (scroll != null)
|
||||
{
|
||||
@@ -185,6 +186,25 @@ public class MapListController : PFUIPanel
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定头像
|
||||
/// </summary>
|
||||
void BindHeadImage()
|
||||
{
|
||||
var headImage = this.transform.Find("HeadImage").GetComponent<RawImage>();
|
||||
var material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
var rect = ((RectTransform)headImage.transform).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height, 0));
|
||||
headImage.material = material;
|
||||
|
||||
Utils.DisplayImage(StartCoroutine, headImage, App.CurrentUser.WxHeadImg);
|
||||
|
||||
UIManager.AddEvent(headImage.gameObject, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
UIManager.ShowEditUserPanel();
|
||||
});
|
||||
}
|
||||
|
||||
private void OnEndDrag(BaseEventData arg0)
|
||||
{
|
||||
var scrollrect = scroll.GetComponent<ScrollRect>();
|
||||
|
||||
@@ -36,5 +36,30 @@ public class PFUIPanel : UIBehaviour
|
||||
}
|
||||
child.transform.SetParent(this.transform);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 给对象设置圆角
|
||||
/// </summary>
|
||||
/// <param name="panel"></param>
|
||||
/// <param name="radius"></param>
|
||||
protected void SetRounded(Transform panel, float radius)
|
||||
{
|
||||
var rounded = Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial");
|
||||
var material = Instantiate(rounded);
|
||||
var rect = ((RectTransform)panel).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, radius, 0));
|
||||
var img = panel.GetComponent<Image>();
|
||||
if (img != null)
|
||||
{
|
||||
img.material = material;
|
||||
return;
|
||||
}
|
||||
var rawImg = panel.GetComponent<RawImage>();
|
||||
if(rawImg != null)
|
||||
{
|
||||
rawImg.material = material;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
Reference in new issue
Block a user