91 lines
2.3 KiB
C#
91 lines
2.3 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using UnityEngine.UI;
|
|
using System.Collections.Generic;
|
|
using GCGame;
|
|
|
|
public class HornEmojiLogic : UIControllerBase<HornEmojiLogic> {
|
|
|
|
public static void ShowChatEmoji(InputField inputText, List<ChatLinkBase> chatLinks)
|
|
{
|
|
Hashtable hash = new Hashtable();
|
|
hash.Add("InputText", inputText);
|
|
hash.Add("ChatLinks", chatLinks);
|
|
UIManager.ShowUI(UIInfo.HornEmojiRoot, ShowChatEmojiOver, hash);
|
|
}
|
|
|
|
public static void ShowChatEmojiOver(bool isSucess, object param)
|
|
{
|
|
if (!isSucess)
|
|
return;
|
|
|
|
Hashtable hashParam = param as Hashtable;
|
|
HornEmojiLogic.Instance().OnShowEmojiPanel((InputField)hashParam["InputText"], (List<ChatLinkBase>)hashParam["ChatLinks"]);
|
|
}
|
|
|
|
#region chat insert
|
|
|
|
private const int MAX_TEXTNUM = 128;
|
|
public GameObject _EmojiPanel;
|
|
public UIContainerBase _EmojiContainer;
|
|
|
|
private InputField _InputText;
|
|
private List<ChatLinkBase> ChatLinks = new List<ChatLinkBase>();
|
|
public void OnShowEmojiPanel(InputField inputText, List<ChatLinkBase> _ChatLinks)
|
|
{
|
|
if (inputText == null || _ChatLinks == null)
|
|
{
|
|
CloseWindow();
|
|
}
|
|
ChatLinks = _ChatLinks;
|
|
_InputText = inputText;
|
|
OnShowEmojiPage();
|
|
}
|
|
|
|
public void CloseWindow()
|
|
{
|
|
UIManager.CloseUI(UIInfo.HornEmojiRoot);
|
|
}
|
|
|
|
public void OnEmojiClick(int emojiID)
|
|
{
|
|
var chatLink = ChatLinkBase.CreateChatLink(emojiID);
|
|
ChatLinks.Add(chatLink);
|
|
chatLink.StartPosInText = _InputText.text.Length;
|
|
_InputText.text += chatLink.StrInput;
|
|
chatLink.EndPosInText = _InputText.text.Length;
|
|
}
|
|
|
|
public int _EmojiCnt = 30;
|
|
private bool _IsInit = false;
|
|
private void OnShowEmojiPage()
|
|
{
|
|
if (_IsInit)
|
|
return;
|
|
|
|
_IsInit = true;
|
|
List<int> emojiIds = new List<int>();
|
|
for (int i = 1; i < _EmojiCnt; ++i)
|
|
{
|
|
emojiIds.Add(i);
|
|
}
|
|
_EmojiContainer.InitContentItem(emojiIds, EmojiItemClick);
|
|
}
|
|
private void EmojiItemClick(object emojiGO)
|
|
{
|
|
int emojiID = (int)emojiGO;
|
|
OnEmojiClick(emojiID);
|
|
}
|
|
|
|
void OnEnable()
|
|
{
|
|
SetInstance(this);
|
|
}
|
|
|
|
void OnDisable()
|
|
{
|
|
SetInstance(null);
|
|
}
|
|
#endregion
|
|
}
|