122 lines
3.0 KiB
C#
122 lines
3.0 KiB
C#
using Cysharp.Threading.Tasks;
|
|
using Framework;
|
|
using Gameplay;
|
|
using Gameplay.Net;
|
|
using System;
|
|
using TMPro;
|
|
using UnityEngine.UI;
|
|
using Button = UnityEngine.UI.Button;
|
|
using Image = UnityEngine.UI.Image;
|
|
|
|
public class UI_EditBirthdayController : UIWindow
|
|
{
|
|
//UI GameObj
|
|
///Auto Gen Start///
|
|
public Image Image_Bg;
|
|
public Button Button_Close;
|
|
public TMP_Text Text_Title;
|
|
public TMP_InputField InputField_Year;
|
|
public TMP_Text Text_TitleYear;
|
|
public TMP_InputField InputField_Month;
|
|
public TMP_Text Text_TitleMonth;
|
|
public TMP_InputField InputField_Day;
|
|
public TMP_Text Text_TitleDay;
|
|
public Button Button_Confirm;
|
|
|
|
///Auto Gen End///
|
|
|
|
public RawImage rawImageGaussianBlurMask;
|
|
|
|
// deal with input data
|
|
public override void PreLoad(object data = null)
|
|
{
|
|
|
|
}
|
|
|
|
public static async UniTask<UIWindow> Open()
|
|
{
|
|
CommonUtils.CaptureScreenshot(); // 截取当前屏幕截图
|
|
return await UIManager.Instance.CreateAndOpenWindow(UINameConst.UI_EditBirthday);
|
|
}
|
|
|
|
// Use this for initialization
|
|
public override void OnInit()
|
|
{
|
|
//bind UI GameObj
|
|
UI_EditBirthdayBinder.GetComponents(this);
|
|
|
|
rawImageGaussianBlurMask = GetComponent<RawImage>("GaussianBlurMask");
|
|
rawImageGaussianBlurMask.texture = CommonUtils.GetScreenTexture2D();
|
|
|
|
BindButton(Button_Close, OnCloseClick);
|
|
BindButton(Button_Confirm, OnConfirmClick);
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.PlayerInfoUpdate, OnChangeInfo);
|
|
}
|
|
|
|
//invoke when open window
|
|
protected override void OnShowWindow(object data = null)
|
|
{
|
|
|
|
}
|
|
|
|
//invoke when reload window
|
|
protected override void OnReloadWindow(object data = null)
|
|
{
|
|
|
|
}
|
|
|
|
//invoke when close window
|
|
protected override void OnHideWindow()
|
|
{
|
|
|
|
}
|
|
|
|
//invoke when destroy
|
|
public override void OnRelease()
|
|
{
|
|
base.OnRelease();
|
|
EventManager.Instance.Unregister(EventManager.EventName.PlayerInfoUpdate, OnChangeInfo);
|
|
}
|
|
|
|
protected override void OnCloseClick()
|
|
{
|
|
AudioManager.Instance.PlayAudio(Framework.Constants.Sound.COMMON_CLICK);
|
|
base.OnCloseClick();
|
|
CloseWindow();
|
|
}
|
|
void OnConfirmClick()
|
|
{
|
|
try
|
|
{
|
|
var year = int.Parse(InputField_Year.text);
|
|
var month = int.Parse(InputField_Month.text);
|
|
var day = int.Parse(InputField_Day.text);
|
|
|
|
if (year < 1970 || year > DateTime.Now.Year)
|
|
{
|
|
CommonUtils.ShowMessageTips(CommonUtils.GetLocalizeText("PlayerInfo_ErrorYear"));
|
|
return;
|
|
}
|
|
|
|
if (DateTime.TryParse(year + "-" + month + "-" + day, out DateTime dt))
|
|
{
|
|
AudioManager.Instance.PlayAudio(Framework.Constants.Sound.COMMON_CLICK);
|
|
NetHelper.SetPlayerBirthday(dt);
|
|
}
|
|
else
|
|
{
|
|
CommonUtils.ShowMessageTips(CommonUtils.GetLocalizeText("PlayerInfo_ErrorDate"));
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
CommonUtils.ShowMessageTips(CommonUtils.GetLocalizeText("PlayerInfo_ErrorDate"));
|
|
}
|
|
}
|
|
|
|
void OnChangeInfo()
|
|
{
|
|
CloseWindow();
|
|
}
|
|
} |