fix:1、添加项目
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
|
||||
|
||||
namespace FlowerPower
|
||||
{
|
||||
public class PersonViewCtrl : BaseCtrl
|
||||
{
|
||||
public static PersonViewCtrl Instance { get; private set; }
|
||||
|
||||
private PersonViewModel model;
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void AddServerListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void RemoveServerListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6123f1dc19568994a838a69b54d83a7d
|
||||
timeCreated: 1676360266
|
||||
@@ -0,0 +1,70 @@
|
||||
|
||||
using System.Linq;
|
||||
namespace FlowerPower
|
||||
{
|
||||
public class PersonViewModel : BaseModel
|
||||
{
|
||||
public bool IsOpenMusic
|
||||
{
|
||||
get { return AudioManager.Instance.IsOpenBGM; }
|
||||
set { AudioManager.Instance.IsOpenBGM = value; }
|
||||
}
|
||||
|
||||
public bool IsOpenEffect
|
||||
{
|
||||
get { return AudioManager.Instance.IsOpenEffect; }
|
||||
set { AudioManager.Instance.IsOpenEffect = value; }
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
|
||||
public string LangIdKey = "LangIdKey";
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
}
|
||||
|
||||
// protected override void OnReset()
|
||||
// {
|
||||
// }
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region 读取数据
|
||||
|
||||
// protected override void OnReadData()
|
||||
// {
|
||||
// }
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region 本地存储
|
||||
|
||||
|
||||
|
||||
// protected override void WriteLocalStorage()
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e1d869c1d542eb8428bfe2f7fd546b97
|
||||
timeCreated: 1676360266
|
||||
@@ -0,0 +1,169 @@
|
||||
using System;
|
||||
using FairyGUI;
|
||||
using FGUI.P01_Common;
|
||||
using FGUI.P04_Menu;
|
||||
|
||||
// using FGUI.G006_menu;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace FlowerPower
|
||||
{
|
||||
public class PersonViewUI : BaseUI
|
||||
{
|
||||
private PersonViewUICtrl ctrl;
|
||||
private PersonViewModel model;
|
||||
private int selectIndex = -1;
|
||||
|
||||
private int total_item;
|
||||
private FGUI.P04_Menu.com_person ui;
|
||||
|
||||
public PersonViewUI(PersonViewUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.MenuUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "P04_Menu";
|
||||
uiInfo.assetName = "com_person";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
model = moduleManager.GetModel(ModelConst.PersonViewModel) as PersonViewModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
CommonHelper.FadeOut(ui);
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.P04_Menu.com_person;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
// if (Screen.safeArea.y != 0)
|
||||
// {
|
||||
// ui.title.y += Screen.safeArea.y;
|
||||
// }
|
||||
total_item = 8;
|
||||
selectIndex = PreferencesMgr.Instance.PlayerAvatarId;
|
||||
|
||||
InitView();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
// CommonHelper.FadeIn(ui);
|
||||
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
HallManager.Instance.AddChangeGiftSwitch(InitView);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
HallManager.Instance.RemoveChangeGiftSwitch(InitView);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void InitView()
|
||||
{
|
||||
|
||||
|
||||
var namStr = GameHelper.GetUserName();
|
||||
ui.edit_name.input.text = namStr;
|
||||
ui.btn_update.SetClick(UpdateUserInfo);
|
||||
ui.edit_name.btn_amend.SetClick(SaveName);
|
||||
ui.btn_close.SetClick(CtrlCloseUI);
|
||||
|
||||
ui.list.itemRenderer = UpdateItem;
|
||||
ui.list.numItems = total_item;
|
||||
|
||||
}
|
||||
|
||||
private void UpdateItem(int index, GObject items)
|
||||
{
|
||||
var currentIndex = index + 1;
|
||||
var head = items as btn_item_head;
|
||||
var imgHead = head.head as btn_head;
|
||||
|
||||
TextureHelper.SetAvatarToLoader(currentIndex, imgHead.load_avatar);
|
||||
head.head_select.selectedIndex = selectIndex == currentIndex
|
||||
? btn_item_head.Head_select_select
|
||||
: btn_item_head.Head_select_none;
|
||||
|
||||
head.SetClick(() =>
|
||||
{
|
||||
selectIndex = currentIndex;
|
||||
ui.list.numItems = total_item;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void UpdateUserInfo()
|
||||
{
|
||||
if (selectIndex != -1)
|
||||
{
|
||||
PreferencesMgr.Instance.PlayerAvatarId = selectIndex;
|
||||
}
|
||||
|
||||
SaveName();
|
||||
CtrlCloseUI();
|
||||
}
|
||||
|
||||
private void SaveName()
|
||||
{
|
||||
var name = ui.edit_name.input.text;
|
||||
|
||||
if (string.IsNullOrEmpty(name) || name.IsNullOrWhiteSpace())
|
||||
{
|
||||
GameHelper.ShowTips("The input cannot be null", true);
|
||||
return;
|
||||
}
|
||||
|
||||
// if (name.Equals(GameHelper.GetPlayerInviteCode()))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (name.Equals(PreferencesMgr.Instance.PlayerName)) return;
|
||||
|
||||
GameHelper.ShowTips($"Name changed successfully");
|
||||
PreferencesMgr.Instance.PlayerName = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa7665fa39ef3004298d59fd734db4db
|
||||
timeCreated: 1676360265
|
||||
@@ -0,0 +1,82 @@
|
||||
|
||||
namespace FlowerPower
|
||||
{
|
||||
public class PersonViewUICtrl : BaseUICtrl
|
||||
{
|
||||
private PersonViewUI ui;
|
||||
private PersonViewModel model;
|
||||
|
||||
private uint openUIMsg = UICtrlMsg.PersonViewUI_Open;
|
||||
private uint closeUIMsg = UICtrlMsg.PersonViewUI_Close;
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OpenUI(object args = null)
|
||||
{
|
||||
if (ui == null)
|
||||
{
|
||||
ui = new PersonViewUI(this);
|
||||
ui.Open(args);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public override void CloseUI(object args = null)
|
||||
{
|
||||
|
||||
if (ui != null && !ui.isClose)
|
||||
{
|
||||
ui.Close();
|
||||
}
|
||||
ui = null;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
public override uint GetOpenUIMsg(string uiName)
|
||||
{
|
||||
return openUIMsg;
|
||||
}
|
||||
|
||||
public override uint GetCloseUIMsg(string uiName)
|
||||
{
|
||||
return closeUIMsg;
|
||||
}
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
uiCtrlDispatcher.AddListener(openUIMsg, OpenUI);
|
||||
uiCtrlDispatcher.AddListener(closeUIMsg, CloseUI);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
uiCtrlDispatcher.RemoveListener(openUIMsg, OpenUI);
|
||||
uiCtrlDispatcher.RemoveListener(closeUIMsg, CloseUI);
|
||||
}
|
||||
|
||||
protected override void AddServerListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void RemoveServerListener()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90ccff2d2f946bf409b5fb31c316a76b
|
||||
timeCreated: 1676360266
|
||||
Reference in New Issue
Block a user