少年修仙传客户端代码仓库
hch
2025-07-24 50e53441950268933694eeb5aad36147bbe1014d
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
using System.Linq;
using UnityEngine;
 
namespace vnxbqy.UI
{
    public class FairySiegeBaseDonateInfoWin : Window
    {
        [SerializeField] ButtonEx btnClose;
        [SerializeField] TextEx txtQuery;
        [SerializeField] TextEx txtNoResult;
        [SerializeField] ScrollerController scroller;
        FairySiegeActModel model { get { return ModelCenter.Instance.GetModel<FairySiegeActModel>(); } }
 
        #region Build-in
 
        protected override void AddListeners()
        {
            btnClose.SetListener(CloseClick);
        }
 
        protected override void BindController()
        {
        }
 
        protected override void OnPreOpen()
        {
            txtQuery.SetActive(model.contributionInfoDict.IsNullOrEmpty());
            txtNoResult.SetActive(false);
            scroller.Refresh();
            scroller.Restart();
            scroller.OnRefreshCell += OnRefreshCell;
            model.UpdateFamilyGCZContributionInfoEvent += OnUpdateFamilyGCZContributionInfoEvent;
            model.SendQuery(1, 0, 0, 0);
        }
 
        protected override void OnPreClose()
        {
            scroller.OnRefreshCell -= OnRefreshCell;
            model.UpdateFamilyGCZContributionInfoEvent -= OnUpdateFamilyGCZContributionInfoEvent;
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnAfterClose()
        {
        }
 
        #endregion
 
        private void OnUpdateFamilyGCZContributionInfoEvent()
        {
            txtQuery.SetActive(false);
            CreateScroller();
        }
 
        private void OnRefreshCell(ScrollerDataType type, CellView cell)
        {
            var _cell = cell.GetComponent<FairySiegeBaseDonateInfoCell>();
            _cell?.Display(cell.index);
        }
 
        private void CreateScroller()
        {
            scroller.Refresh();
            bool isNullOrEmpty = model.contributionInfoDict.IsNullOrEmpty();
            txtNoResult.SetActive(isNullOrEmpty);
            if (!isNullOrEmpty)
            {
                var list = model.contributionInfoDict.Keys.ToList();
                list.Sort((a, b) =>
                {
                    uint contributionValueA = model.contributionInfoDict[a];
                    uint contributionValueB = model.contributionInfoDict[b];
                    return contributionValueB.CompareTo(contributionValueA);
                });
                foreach (var item in list)
                {
                    scroller.AddCell(ScrollerDataType.Header, (int)item);
                }
            }
            scroller.Restart();
        }
    }
}