| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: 第二世界 |
| | | // [ Date ]: Monday, April 09, 2018 |
| | | //-------------------------------------------------------- |
| | | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using TableConfig; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | namespace Snxxz.UI { |
| | | |
| | | public class ChatExtentWin : Window |
| | | { |
| | | [SerializeField] RectTransform m_ContainerQuickChat; |
| | | [SerializeField] List<Button> m_QuickChatBtns; |
| | | [SerializeField] List<Text> m_QuickChats; |
| | | |
| | | [SerializeField] RectTransform m_ContainerBag; |
| | | [SerializeField] ScrollerController m_BagControl; |
| | | [SerializeField] RectTransform m_ContainerFace; |
| | | [SerializeField] ScrollerController m_FaceControl; |
| | | |
| | | [SerializeField] Button m_FaceBtn; |
| | | [SerializeField] Button m_QuickChatBtn; |
| | | [SerializeField] Button m_BagBtn; |
| | | [SerializeField] Text m_FaceBtnTxt; |
| | | [SerializeField] Text m_QuickChatBtnTxt; |
| | | [SerializeField] Text m_BagBtnTxt; |
| | | |
| | | ChatCenter m_ChatCenter; |
| | | ChatCenter chatCenter |
| | | { |
| | | get |
| | | { |
| | | return m_ChatCenter ?? (m_ChatCenter = ModelCenter.Instance.GetModel<ChatCenter>()); |
| | | } |
| | | } |
| | | |
| | | PlayerPackModel _playerPack; |
| | | PlayerPackModel playerPack |
| | | { |
| | | get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>()); } |
| | | } |
| | | |
| | | List<string> m_Faces = null; |
| | | List<ItemModel> m_DisplayItems = new List<ItemModel>(); |
| | | |
| | | private int presentSelect = 0; |
| | | #region Built-in |
| | | protected override void BindController() |
| | | { |
| | | } |
| | | |
| | | protected override void AddListeners() |
| | | { |
| | | for (int i = 0; i < m_QuickChatBtns.Count; i++) |
| | | { |
| | | int _index = i; |
| | | m_QuickChatBtns[i].onClick.AddListener(()=> |
| | | { |
| | | OnQuickChat(_index); |
| | | }); |
| | | } |
| | | |
| | | m_FaceBtn.onClick.AddListener(OnFaceBtn); |
| | | m_BagBtn.onClick.AddListener(OnBagBtn); |
| | | m_QuickChatBtn.onClick.AddListener(OnQuickChat); |
| | | |
| | | m_FaceControl.OnRefreshCell += OnRefreshFaceCell; |
| | | m_BagControl.OnRefreshCell += OnRefreshBagCell; |
| | | } |
| | | |
| | | private void OnRefreshBagCell(ScrollerDataType type, CellView cell) |
| | | { |
| | | ChatItemCell _itemCell = cell as ChatItemCell; |
| | | int _line = cell.index; |
| | | for (int i = 0; i < 3; i++) |
| | | { |
| | | int index = _line * 3 + i; |
| | | if (index < m_DisplayItems.Count) |
| | | { |
| | | _itemCell.items[i].gameObject.SetActive(true); |
| | | ItemModel _item = m_DisplayItems[index]; |
| | | ItemConfig itemCfg = ConfigManager.Instance.GetTemplate<ItemConfig>((int)_item.itemInfo.ItemID); |
| | | _itemCell.items[i].Init(_item); |
| | | _itemCell.itemEquips[i].gameObject.SetActive(_item.packType == PackType.rptEquip); |
| | | _itemCell.items[i].cellBtn.onClick.RemoveAllListeners(); |
| | | _itemCell.items[i].cellBtn.onClick.AddListener(() => |
| | | { |
| | | OnItemClick(_item); |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | _itemCell.items[i].gameObject.SetActive(false); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void OnItemClick(ItemModel _item) |
| | | { |
| | | if (chatCenter.recentlyChat != null) |
| | | { |
| | | chatCenter.recentlyChat = null; |
| | | chatCenter.ChangeChatValue(string.Empty, false, false); |
| | | } |
| | | ItemConfig _cfg = ConfigManager.Instance.GetTemplate<ItemConfig>((int)_item.itemInfo.ItemID); |
| | | string _showtext = StringUtility.Contact("[", _cfg.ItemName, "]"); |
| | | ChatCtrl.Inst.itemPlaceList.Add(_item); |
| | | chatCenter.ChangeChatValue(_showtext, true, true); |
| | | } |
| | | |
| | | private void OnRefreshFaceCell(ScrollerDataType type, CellView cell) |
| | | { |
| | | ChatFaceCell _chatFaceCell = cell as ChatFaceCell; |
| | | int _line = cell.index; |
| | | for (int i = 0; i < 3; i++) |
| | | { |
| | | int index = _line * 3 + i; |
| | | if (index < m_Faces.Count) |
| | | { |
| | | _chatFaceCell.faceBtns[i].gameObject.SetActive(true); |
| | | _chatFaceCell.faceFrames[i].ResetFrame(m_Faces[index]); |
| | | _chatFaceCell.faceBtns[i].RemoveAllListeners(); |
| | | _chatFaceCell.faceBtns[i].onClick.AddListener(() => |
| | | { |
| | | OnFaceClick(index); |
| | | }); |
| | | _chatFaceCell.faceFrames[i].enabled = true; |
| | | } |
| | | else |
| | | { |
| | | _chatFaceCell.faceBtns[i].gameObject.SetActive(false); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void OnFaceClick(int index) |
| | | { |
| | | if (chatCenter.chatInputLength + 5 > chatCenter.chatCharacterLimit) |
| | | { |
| | | return; |
| | | } |
| | | if (index < m_Faces.Count) |
| | | { |
| | | string facename = m_Faces[index]; |
| | | if (facename.Length == 1) |
| | | { |
| | | facename = "00" + facename; |
| | | } |
| | | else if (facename.Length == 2) |
| | | { |
| | | facename = "0" + facename; |
| | | } |
| | | chatCenter.ChangeChatValue(string.Format("#~{0}", facename), true, true); |
| | | } |
| | | } |
| | | |
| | | private void OnFaceBtn() |
| | | { |
| | | presentSelect = 0; |
| | | UpdateButtonState(); |
| | | |
| | | if (m_Faces == null) |
| | | { |
| | | m_Faces = UIFrameMgr.Inst.GetAllFace().Keys.ToList(); |
| | | int _line = Mathf.CeilToInt((float)m_Faces.Count / 3); |
| | | m_FaceControl.Refresh(); |
| | | for (int i = 0; i < _line; i++) |
| | | { |
| | | m_FaceControl.AddCell(ScrollerDataType.Normal, i); |
| | | } |
| | | m_FaceControl.Restart(); |
| | | } |
| | | if (m_FaceControl.GetNumberOfCells(m_FaceControl.m_Scorller) > 0) |
| | | { |
| | | m_FaceControl.JumpIndex(0); |
| | | } |
| | | } |
| | | |
| | | private void OnBagBtn() |
| | | { |
| | | presentSelect = 2; |
| | | UpdateButtonState(); |
| | | |
| | | if (!m_ContainerBag.gameObject.activeInHierarchy) |
| | | { |
| | | return; |
| | | } |
| | | OnRefreshBagItem(); |
| | | } |
| | | |
| | | private void OnQuickChat() |
| | | { |
| | | presentSelect = 1; |
| | | chatCenter.recentlyChat = null; |
| | | UpdateButtonState(); |
| | | RecentlyChatChangeEvent(); |
| | | } |
| | | |
| | | private void OnQuickChat(int _index) |
| | | { |
| | | if (_index < chatCenter.recentlyChats.Count) |
| | | { |
| | | chatCenter.recentlyChat = chatCenter.recentlyChats[_index]; |
| | | chatCenter.recentlyChat.Reset(); |
| | | chatCenter.ChangeChatValue(chatCenter.recentlyChats[_index].display, false, true); |
| | | } |
| | | } |
| | | |
| | | protected override void OnPreOpen() |
| | | { |
| | | presentSelect = 0; |
| | | playerPack.RefreshItemCountAct += RefreshItemCnt; |
| | | chatCenter.RecentlyChatChangeEvent += RecentlyChatChangeEvent; |
| | | OnFaceBtn(); |
| | | } |
| | | |
| | | protected override void OnAfterOpen() |
| | | { |
| | | } |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | playerPack.RefreshItemCountAct -= RefreshItemCnt; |
| | | chatCenter.RecentlyChatChangeEvent -= RecentlyChatChangeEvent; |
| | | } |
| | | |
| | | protected override void OnAfterClose() |
| | | { |
| | | } |
| | | #endregion |
| | | private void RecentlyChatChangeEvent() |
| | | { |
| | | for (int i = 0; i < m_QuickChatBtns.Count; i++) |
| | | { |
| | | m_QuickChatBtns[i].gameObject.SetActive(i < chatCenter.recentlyChats.Count); |
| | | if (i < chatCenter.recentlyChats.Count) |
| | | { |
| | | var _value = chatCenter.recentlyChats[i].display; |
| | | m_QuickChats[i].text = _value; |
| | | if (GetCutOffValue(m_QuickChats[i], _value, ImgAnalysis.FaceRegex.IsMatch(_value) ? 2 : 3, out _value)) |
| | | { |
| | | m_QuickChats[i].text = StringUtility.Contact(_value, "..."); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private bool GetCutOffValue(Text _text,string _value,int _line,out string _display) |
| | | { |
| | | _display = string.Empty; |
| | | if (_text.preferredWidth >= _text.rectTransform.rect.width * _line) |
| | | { |
| | | CharacterInfo _info; |
| | | float _length = 0; |
| | | var _index = 0; |
| | | var _font = _text.font; |
| | | _font.RequestCharactersInTexture(_value, _text.fontSize, _text.fontStyle); |
| | | for (int i = 0; i < _value.Length; i++) |
| | | { |
| | | _font.GetCharacterInfo(_value[i], out _info, _text.fontSize, _text.fontStyle); |
| | | _length += _info.advance; |
| | | if (_length >= _text.rectTransform.rect.width * _line) |
| | | { |
| | | _index = i; |
| | | break; |
| | | } |
| | | } |
| | | _display= _value.Substring(0, Mathf.Max(0, _index - 5)); |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private void RefreshItemCnt(PackType type, int index, int id) |
| | | { |
| | | OnRefreshBagItem(); |
| | | } |
| | | |
| | | private void OnRefreshBagItem() |
| | | { |
| | | m_BagControl.Refresh(); |
| | | m_DisplayItems.Clear(); |
| | | var _packModel = ModelCenter.Instance.GetModel<PlayerPackModel>(); |
| | | SinglePackModel packTypeModel = _packModel.GetSinglePackModel(PackType.rptEquip); |
| | | if (packTypeModel != null) |
| | | { |
| | | Dictionary<int, ItemModel> equipBodyDict = packTypeModel.GetPackModelIndexDict(); |
| | | if (equipBodyDict != null && equipBodyDict.Count > 0) |
| | | { |
| | | foreach (var _equip in equipBodyDict.Values) |
| | | { |
| | | if (_equip.itemInfo.ItemPlace <= (int)RoleEquipType.retSpiritAnimal) |
| | | { |
| | | m_DisplayItems.Add(_equip); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | packTypeModel = _packModel.GetSinglePackModel(PackType.rptItem); |
| | | if (packTypeModel != null) |
| | | { |
| | | Dictionary<int, ItemModel> dic = packTypeModel.GetPackModelIndexDict(); |
| | | if (dic != null && dic.Count > 0) |
| | | { |
| | | m_DisplayItems.AddRange(dic.Values.ToList()); |
| | | } |
| | | } |
| | | if (m_DisplayItems.Count > 0) |
| | | { |
| | | int _line = Mathf.CeilToInt((float)m_DisplayItems.Count / 3); |
| | | for (int i = 0; i < _line; i++) |
| | | { |
| | | m_BagControl.AddCell(ScrollerDataType.Normal, i); |
| | | } |
| | | } |
| | | m_BagControl.Restart(); |
| | | } |
| | | |
| | | void UpdateButtonState() |
| | | { |
| | | m_ContainerFace.gameObject.SetActive(presentSelect == 0); |
| | | m_ContainerBag.gameObject.SetActive(presentSelect == 2); |
| | | m_ContainerQuickChat.gameObject.SetActive(presentSelect == 1); |
| | | |
| | | m_BagBtn.image.SetSprite(presentSelect == 2 ? "Chat_SelectBtn" : "Chat_UnSelectBtn"); |
| | | m_FaceBtn.image.SetSprite(presentSelect == 0 ? "Chat_SelectBtn" : "Chat_UnSelectBtn"); |
| | | m_QuickChatBtn.image.SetSprite(presentSelect == 1 ? "Chat_SelectBtn" : "Chat_UnSelectBtn"); |
| | | |
| | | m_QuickChatBtnTxt.color = presentSelect == 1 ? UIHelper.s_LightYellow : UIHelper.GetUIColor(TextColType.NavyBrown); |
| | | m_BagBtnTxt.color = presentSelect == 2 ? UIHelper.s_LightYellow : UIHelper.GetUIColor(TextColType.NavyBrown); |
| | | m_FaceBtnTxt.color = presentSelect == 0 ? UIHelper.s_LightYellow : UIHelper.GetUIColor(TextColType.NavyBrown); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //--------------------------------------------------------
|
| | | // [Author]: 第二世界
|
| | | // [ Date ]: Monday, April 09, 2018
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System;
|
| | | using System.Collections;
|
| | | using System.Collections.Generic;
|
| | | using System.Linq;
|
| | | using TableConfig;
|
| | | using UnityEngine;
|
| | | using UnityEngine.UI;
|
| | |
|
| | | namespace Snxxz.UI {
|
| | |
|
| | | public class ChatExtentWin : Window
|
| | | {
|
| | | [SerializeField] RectTransform m_ContainerQuickChat;
|
| | | [SerializeField] List<Button> m_QuickChatBtns;
|
| | | [SerializeField] List<Text> m_QuickChats;
|
| | |
|
| | | [SerializeField] RectTransform m_ContainerBag;
|
| | | [SerializeField] ScrollerController m_BagControl;
|
| | | [SerializeField] RectTransform m_ContainerFace;
|
| | | [SerializeField] ScrollerController m_FaceControl;
|
| | |
|
| | | [SerializeField] Button m_FaceBtn;
|
| | | [SerializeField] Button m_QuickChatBtn;
|
| | | [SerializeField] Button m_BagBtn;
|
| | | [SerializeField] Text m_FaceBtnTxt;
|
| | | [SerializeField] Text m_QuickChatBtnTxt;
|
| | | [SerializeField] Text m_BagBtnTxt;
|
| | |
|
| | | ChatCenter m_ChatCenter;
|
| | | ChatCenter chatCenter
|
| | | {
|
| | | get
|
| | | {
|
| | | return m_ChatCenter ?? (m_ChatCenter = ModelCenter.Instance.GetModel<ChatCenter>());
|
| | | }
|
| | | }
|
| | |
|
| | | PlayerPackModel _playerPack;
|
| | | PlayerPackModel playerPack
|
| | | {
|
| | | get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>()); }
|
| | | }
|
| | |
|
| | | List<string> m_Faces = null;
|
| | | List<ItemModel> m_DisplayItems = new List<ItemModel>();
|
| | |
|
| | | private int presentSelect = 0;
|
| | | #region Built-in
|
| | | protected override void BindController()
|
| | | {
|
| | | }
|
| | |
|
| | | protected override void AddListeners()
|
| | | {
|
| | | for (int i = 0; i < m_QuickChatBtns.Count; i++)
|
| | | {
|
| | | int _index = i;
|
| | | m_QuickChatBtns[i].onClick.AddListener(()=> |
| | | {
|
| | | OnQuickChat(_index);
|
| | | });
|
| | | }
|
| | |
|
| | | m_FaceBtn.onClick.AddListener(OnFaceBtn);
|
| | | m_BagBtn.onClick.AddListener(OnBagBtn);
|
| | | m_QuickChatBtn.onClick.AddListener(OnQuickChat);
|
| | |
|
| | | m_FaceControl.OnRefreshCell += OnRefreshFaceCell;
|
| | | m_BagControl.OnRefreshCell += OnRefreshBagCell;
|
| | | }
|
| | |
|
| | | private void OnRefreshBagCell(ScrollerDataType type, CellView cell)
|
| | | {
|
| | | ChatItemCell _itemCell = cell as ChatItemCell;
|
| | | int _line = cell.index;
|
| | | for (int i = 0; i < 3; i++)
|
| | | {
|
| | | int index = _line * 3 + i;
|
| | | if (index < m_DisplayItems.Count)
|
| | | {
|
| | | _itemCell.items[i].gameObject.SetActive(true);
|
| | | ItemModel _item = m_DisplayItems[index];
|
| | | ItemConfig itemCfg = Config.Instance.Get<ItemConfig>((int)_item.itemInfo.ItemID);
|
| | | _itemCell.items[i].Init(_item);
|
| | | _itemCell.itemEquips[i].gameObject.SetActive(_item.packType == PackType.rptEquip);
|
| | | _itemCell.items[i].cellBtn.onClick.RemoveAllListeners();
|
| | | _itemCell.items[i].cellBtn.onClick.AddListener(() =>
|
| | | {
|
| | | OnItemClick(_item);
|
| | | });
|
| | | }
|
| | | else
|
| | | {
|
| | | _itemCell.items[i].gameObject.SetActive(false);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnItemClick(ItemModel _item)
|
| | | {
|
| | | if (chatCenter.recentlyChat != null)
|
| | | {
|
| | | chatCenter.recentlyChat = null;
|
| | | chatCenter.ChangeChatValue(string.Empty, false, false);
|
| | | }
|
| | | ItemConfig _cfg = Config.Instance.Get<ItemConfig>((int)_item.itemInfo.ItemID);
|
| | | string _showtext = StringUtility.Contact("[", _cfg.ItemName, "]");
|
| | | ChatCtrl.Inst.itemPlaceList.Add(_item);
|
| | | chatCenter.ChangeChatValue(_showtext, true, true);
|
| | | }
|
| | |
|
| | | private void OnRefreshFaceCell(ScrollerDataType type, CellView cell)
|
| | | {
|
| | | ChatFaceCell _chatFaceCell = cell as ChatFaceCell;
|
| | | int _line = cell.index;
|
| | | for (int i = 0; i < 3; i++)
|
| | | {
|
| | | int index = _line * 3 + i;
|
| | | if (index < m_Faces.Count)
|
| | | {
|
| | | _chatFaceCell.faceBtns[i].gameObject.SetActive(true);
|
| | | _chatFaceCell.faceFrames[i].ResetFrame(m_Faces[index]);
|
| | | _chatFaceCell.faceBtns[i].RemoveAllListeners();
|
| | | _chatFaceCell.faceBtns[i].onClick.AddListener(() =>
|
| | | {
|
| | | OnFaceClick(index);
|
| | | });
|
| | | _chatFaceCell.faceFrames[i].enabled = true;
|
| | | }
|
| | | else
|
| | | {
|
| | | _chatFaceCell.faceBtns[i].gameObject.SetActive(false);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnFaceClick(int index)
|
| | | {
|
| | | if (chatCenter.chatInputLength + 5 > chatCenter.chatCharacterLimit)
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (index < m_Faces.Count)
|
| | | {
|
| | | string facename = m_Faces[index];
|
| | | if (facename.Length == 1)
|
| | | {
|
| | | facename = "00" + facename;
|
| | | }
|
| | | else if (facename.Length == 2)
|
| | | {
|
| | | facename = "0" + facename;
|
| | | }
|
| | | chatCenter.ChangeChatValue(string.Format("#~{0}", facename), true, true);
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnFaceBtn()
|
| | | {
|
| | | presentSelect = 0;
|
| | | UpdateButtonState();
|
| | |
|
| | | if (m_Faces == null)
|
| | | {
|
| | | m_Faces = UIFrameMgr.Inst.GetAllFace().Keys.ToList();
|
| | | int _line = Mathf.CeilToInt((float)m_Faces.Count / 3);
|
| | | m_FaceControl.Refresh();
|
| | | for (int i = 0; i < _line; i++)
|
| | | {
|
| | | m_FaceControl.AddCell(ScrollerDataType.Normal, i);
|
| | | }
|
| | | m_FaceControl.Restart();
|
| | | }
|
| | | if (m_FaceControl.GetNumberOfCells(m_FaceControl.m_Scorller) > 0)
|
| | | {
|
| | | m_FaceControl.JumpIndex(0);
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnBagBtn()
|
| | | {
|
| | | presentSelect = 2;
|
| | | UpdateButtonState();
|
| | |
|
| | | if (!m_ContainerBag.gameObject.activeInHierarchy)
|
| | | {
|
| | | return;
|
| | | }
|
| | | OnRefreshBagItem();
|
| | | }
|
| | |
|
| | | private void OnQuickChat()
|
| | | {
|
| | | presentSelect = 1;
|
| | | chatCenter.recentlyChat = null;
|
| | | UpdateButtonState();
|
| | | RecentlyChatChangeEvent();
|
| | | }
|
| | |
|
| | | private void OnQuickChat(int _index)
|
| | | {
|
| | | if (_index < chatCenter.recentlyChats.Count)
|
| | | {
|
| | | chatCenter.recentlyChat = chatCenter.recentlyChats[_index];
|
| | | chatCenter.recentlyChat.Reset();
|
| | | chatCenter.ChangeChatValue(chatCenter.recentlyChats[_index].display, false, true);
|
| | | }
|
| | | }
|
| | |
|
| | | protected override void OnPreOpen()
|
| | | {
|
| | | presentSelect = 0;
|
| | | playerPack.RefreshItemCountAct += RefreshItemCnt;
|
| | | chatCenter.RecentlyChatChangeEvent += RecentlyChatChangeEvent;
|
| | | OnFaceBtn();
|
| | | }
|
| | |
|
| | | protected override void OnAfterOpen()
|
| | | {
|
| | | }
|
| | |
|
| | | protected override void OnPreClose()
|
| | | {
|
| | | playerPack.RefreshItemCountAct -= RefreshItemCnt;
|
| | | chatCenter.RecentlyChatChangeEvent -= RecentlyChatChangeEvent;
|
| | | }
|
| | |
|
| | | protected override void OnAfterClose()
|
| | | {
|
| | | }
|
| | | #endregion
|
| | | private void RecentlyChatChangeEvent()
|
| | | {
|
| | | for (int i = 0; i < m_QuickChatBtns.Count; i++)
|
| | | {
|
| | | m_QuickChatBtns[i].gameObject.SetActive(i < chatCenter.recentlyChats.Count);
|
| | | if (i < chatCenter.recentlyChats.Count)
|
| | | {
|
| | | var _value = chatCenter.recentlyChats[i].display;
|
| | | m_QuickChats[i].text = _value;
|
| | | if (GetCutOffValue(m_QuickChats[i], _value, ImgAnalysis.FaceRegex.IsMatch(_value) ? 2 : 3, out _value))
|
| | | {
|
| | | m_QuickChats[i].text = StringUtility.Contact(_value, "...");
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private bool GetCutOffValue(Text _text,string _value,int _line,out string _display)
|
| | | {
|
| | | _display = string.Empty;
|
| | | if (_text.preferredWidth >= _text.rectTransform.rect.width * _line)
|
| | | {
|
| | | CharacterInfo _info;
|
| | | float _length = 0;
|
| | | var _index = 0;
|
| | | var _font = _text.font;
|
| | | _font.RequestCharactersInTexture(_value, _text.fontSize, _text.fontStyle);
|
| | | for (int i = 0; i < _value.Length; i++)
|
| | | {
|
| | | _font.GetCharacterInfo(_value[i], out _info, _text.fontSize, _text.fontStyle);
|
| | | _length += _info.advance;
|
| | | if (_length >= _text.rectTransform.rect.width * _line)
|
| | | {
|
| | | _index = i;
|
| | | break;
|
| | | }
|
| | | }
|
| | | _display= _value.Substring(0, Mathf.Max(0, _index - 5));
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | private void RefreshItemCnt(PackType type, int index, int id)
|
| | | {
|
| | | OnRefreshBagItem();
|
| | | }
|
| | |
|
| | | private void OnRefreshBagItem()
|
| | | {
|
| | | m_BagControl.Refresh();
|
| | | m_DisplayItems.Clear();
|
| | | var _packModel = ModelCenter.Instance.GetModel<PlayerPackModel>();
|
| | | SinglePackModel packTypeModel = _packModel.GetSinglePackModel(PackType.rptEquip);
|
| | | if (packTypeModel != null)
|
| | | {
|
| | | Dictionary<int, ItemModel> equipBodyDict = packTypeModel.GetPackModelIndexDict();
|
| | | if (equipBodyDict != null && equipBodyDict.Count > 0)
|
| | | {
|
| | | foreach (var _equip in equipBodyDict.Values)
|
| | | {
|
| | | if (_equip.itemInfo.ItemPlace <= (int)RoleEquipType.retSpiritAnimal)
|
| | | {
|
| | | m_DisplayItems.Add(_equip);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | packTypeModel = _packModel.GetSinglePackModel(PackType.rptItem);
|
| | | if (packTypeModel != null)
|
| | | {
|
| | | Dictionary<int, ItemModel> dic = packTypeModel.GetPackModelIndexDict();
|
| | | if (dic != null && dic.Count > 0)
|
| | | {
|
| | | m_DisplayItems.AddRange(dic.Values.ToList());
|
| | | }
|
| | | }
|
| | | if (m_DisplayItems.Count > 0)
|
| | | {
|
| | | int _line = Mathf.CeilToInt((float)m_DisplayItems.Count / 3);
|
| | | for (int i = 0; i < _line; i++)
|
| | | {
|
| | | m_BagControl.AddCell(ScrollerDataType.Normal, i);
|
| | | }
|
| | | }
|
| | | m_BagControl.Restart();
|
| | | }
|
| | |
|
| | | void UpdateButtonState()
|
| | | {
|
| | | m_ContainerFace.gameObject.SetActive(presentSelect == 0);
|
| | | m_ContainerBag.gameObject.SetActive(presentSelect == 2);
|
| | | m_ContainerQuickChat.gameObject.SetActive(presentSelect == 1);
|
| | |
|
| | | m_BagBtn.image.SetSprite(presentSelect == 2 ? "Chat_SelectBtn" : "Chat_UnSelectBtn");
|
| | | m_FaceBtn.image.SetSprite(presentSelect == 0 ? "Chat_SelectBtn" : "Chat_UnSelectBtn");
|
| | | m_QuickChatBtn.image.SetSprite(presentSelect == 1 ? "Chat_SelectBtn" : "Chat_UnSelectBtn");
|
| | |
|
| | | m_QuickChatBtnTxt.color = presentSelect == 1 ? UIHelper.s_LightYellow : UIHelper.GetUIColor(TextColType.NavyBrown);
|
| | | m_BagBtnTxt.color = presentSelect == 2 ? UIHelper.s_LightYellow : UIHelper.GetUIColor(TextColType.NavyBrown);
|
| | | m_FaceBtnTxt.color = presentSelect == 0 ? UIHelper.s_LightYellow : UIHelper.GetUIColor(TextColType.NavyBrown);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | |
|