少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
    public class ChatFaceItemCell : CellView
    {
        [SerializeField] List<ImageEx> imgFaceList;
        [SerializeField] HorizontalLayoutGroup horizontalLayoutGroup;
        [SerializeField] RectTransform rectTransform;
        int rowIndex;
        PhantasmPavilionModel model { get { return ModelCenter.Instance.GetModel<PhantasmPavilionModel>(); } }
        ChatCenter chatCenter { get { return ModelCenter.Instance.GetModel<ChatCenter>(); } }
        public void Display(int rowIndex)
        {
            this.rowIndex = rowIndex;
            int id = model.selectEmojiPackID;
            model.GetShowEmojiInfo(this.rectTransform.rect.width, id, out int rowCount, out int emojiCount, out int space);
            model.GetEmojiShowSize(id, out int emojiWidth, out int emojiHeight);
            rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, emojiHeight);
            horizontalLayoutGroup.spacing = space;
            List<string> emojiList = model.GetEmojiList(id);
            for (int i = 0; i < model.MaxEmojiCount; i++)
            {
                if (i < emojiCount)
                {
                    imgFaceList[i].rectTransform.sizeDelta = new Vector2(emojiWidth, emojiHeight);
                    int index = rowIndex * emojiCount + i;
                    if (index < emojiList.Count)
                    {
                        string name = emojiList[index];
                        imgFaceList[i].SetActive(true);
                        if (!FaceConfig.Has(name))
                            continue;
                        FaceConfig config = FaceConfig.Get(name);
                        UIFrame frame = imgFaceList[i].GetComponent<UIFrame>();
                        if (UIFrameMgr.Inst.ContainsDynamicImage(config.name))
                        {
                            if (frame == null)
                                frame = imgFaceList[i].gameObject.AddComponent<UIFrame>();
                            frame.ResetFrame(config.name);
                            frame.enabled = true;
                        }
                        else
                        {
                            if (frame != null)
                                frame.enabled = false;
                            imgFaceList[i].SetSprite(config.name);
                        }
 
                        ButtonEx buttonEx = imgFaceList[i].GetComponent<ButtonEx>();
                        if (buttonEx != null)
                        {
                            buttonEx.SetListener(() => OnFaceClick(name));
                        }
                    }
                    else
                    {
                        imgFaceList[i].SetActive(false);
                    }
                }
                else
                {
                    imgFaceList[i].SetActive(false);
                }
 
            }
 
        }
 
 
        private void OnFaceClick(string index)
        {
            List<string> emojiList = model.GetEmojiList(model.selectEmojiPackID);
 
            if (!FaceConfig.Has(index))
                return;
            FaceConfig config = FaceConfig.Get(index);
 
            if (config.EmojiPackID == 1)
            {
                if (chatCenter.chatInputLength + 5 > chatCenter.chatCharacterLimit)
                {
                    return;
                }
                string facename = config.name;
                if (facename.Length == 1)
                {
                    facename = "00" + facename;
                }
                else if (facename.Length == 2)
                {
                    facename = "0" + facename;
                }
                chatCenter.ChangeChatValue(string.Format("#~{0}", facename), true, true);
            }
            else
            {
 
                string msg = config.name;
                if (msg.Length == 1)
                {
                    msg = "00" + msg;
                }
                else if (msg.Length == 2)
                {
                    msg = "0" + msg;
                }
                //ChatCtrl.Inst.SendChatInfo(ChatCtrl.Inst.presentChatType, string.Format("#~{0}", msg));
                model.SendChatAction?.Invoke(string.Format("#~{0}", msg));
            }
 
        }
 
 
    }
}