From 39001a600fcae2bcf27c225df8752d75fb92fef4 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 31 十月 2025 11:18:26 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.1.20:10010/r/Project_SG_scripts

---
 Main/System/HeroUI/HeroListWin.cs |  100 ++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 80 insertions(+), 20 deletions(-)

diff --git a/Main/System/HeroUI/HeroListWin.cs b/Main/System/HeroUI/HeroListWin.cs
index bdb9c5a..7415bd7 100644
--- a/Main/System/HeroUI/HeroListWin.cs
+++ b/Main/System/HeroUI/HeroListWin.cs
@@ -17,10 +17,7 @@
     [SerializeField] Button attrOnTipBtn;
 
     [SerializeField] Button changeHeroPosBtn; //甯冮樀鎸夐挳
-
-
-    private List<Image> countrySelectImgList;
-    private List<Image> jobSelectImgList;
+    [SerializeField] HeroSelectBehaviour fiterManager;  //姝﹀皢绛涢��
 
     SinglePack singlePack;
 
@@ -36,15 +33,23 @@
             HeroUIManager.Instance.selectTeamType = TeamType.Story;
             UIManager.Instance.OpenWindow<HeroPosWin>();
         });
+        attrOnTipBtn.AddListener(() =>
+        {
+            attrOnTip.SetActive(!attrOnTip.activeSelf);
+        });
     }
 
 
     protected override void OnPreOpen()
     {
+        HeroUIManager.Instance.selectHeroListJob = 0;
+        HeroUIManager.Instance.selectHeroListCountry = 0;
         singlePack = PackManager.Instance.GetSinglePack(PackType.Hero);
         heroListScroller.OnRefreshCell += OnRefreshCell;
-        //闇�瑕佽�冭檻璋冩暣涓烘灏嗙殑浜嬩欢锛岃�屼笉鏄儗鍖�
-        PackManager.Instance.RefreshItemEvent += RefreshPakCount;
+        PackManager.Instance.gridRefreshEvent += GridRefreshEvent;
+        PackManager.Instance.RefreshItemEvent += RefreshItemEvent;
+        UIManager.Instance.OnCloseWindow += OnCloseWindow;
+        HeroManager.Instance.onHeroDeleteEvent += HeroDeleteEvent;
         HeroUIManager.Instance.SortHeroList();
         CreateScroller();
         Refresh();
@@ -53,13 +58,50 @@
     protected override void OnPreClose()
     {
         heroListScroller.OnRefreshCell -= OnRefreshCell;
-        PackManager.Instance.RefreshItemEvent -= RefreshPakCount;
+        PackManager.Instance.RefreshItemEvent -= RefreshItemEvent;
+        PackManager.Instance.gridRefreshEvent -= GridRefreshEvent;
+        UIManager.Instance.OnCloseWindow -= OnCloseWindow;
+        HeroManager.Instance.onHeroDeleteEvent -= HeroDeleteEvent;
+    }
+
+
+    private void OnCloseWindow(UIBase closeUI)
+    {
+        //鍏朵粬姝﹀皢鍔熻兘浜х敓鏁版嵁鍙樺寲锛岄渶瑕佸埛鏂版灏嗗垪琛�
+        if (closeUI is HeroTrainWin ||
+            closeUI is HeroCallWin ||
+            closeUI is HeroPosWin)
+        {
+            HeroUIManager.Instance.SortHeroList();
+            CreateScroller();
+            Refresh();
+        }
     }
 
 
     public override void Refresh()
     {
-        if (singlePack == null || singlePack.GetAllItems().Count <= 0)
+        RefreshEmptyTip();
+        OnBattleTeamAttrPer();
+
+        RefreshPackCount();
+
+        fiterManager.Display(0, HeroUIManager.Instance.selectHeroListJob, HeroUIManager.Instance.selectHeroListCountry, SelectJobCountry);
+
+    }
+
+    void HeroDeleteEvent(int heroID)
+    {
+        HeroUIManager.Instance.SortHeroList();
+        heroListScroller.m_Scorller.RefreshActiveCellViews();
+    }
+
+
+
+
+    void RefreshEmptyTip()
+    {
+        if (HeroUIManager.Instance.heroSortList.Count <= 0)
         {
             heroListEmpty.SetActive(true);
             heroListScroller.SetActive(false);
@@ -69,10 +111,15 @@
             heroListEmpty.SetActive(false);
             heroListScroller.SetActive(true);
         }
+    }
 
-        OnBattleTeamAttrPer();
-        
-        RefreshPakCount(PackType.Hero, 0, 0);
+    void SelectJobCountry(int job, int country)
+    {
+        HeroUIManager.Instance.selectHeroListJob = job;
+        HeroUIManager.Instance.selectHeroListCountry = country;
+        HeroUIManager.Instance.SortHeroList();
+        RefreshEmptyTip();
+        CreateScroller();
     }
 
     //涓婇樀鍔犳垚
@@ -84,13 +131,15 @@
         {
             for (int i = 0; i < team.serverHeroes.Length; i++)
             {
+                if (team.serverHeroes[i] == null)
+                    continue;
                 var hero = HeroManager.Instance.GetHero(team.serverHeroes[i].guid);
                 if (hero != null)
                 {
                     valuePer += hero.GetOnBattleAddPer();
                 }
             }
-  
+
         }
         //涓婇樀灞炴��
         for (int i = 0; i < attrOnList.Count; i++)
@@ -118,18 +167,29 @@
         heroListScroller.Restart();
     }
 
-    void RefreshPakCount(PackType type, int index, int itemID)
+    void RefreshItemEvent(PackType type, int index, int itemID)
     {
         if (type != PackType.Hero)
             return;
-        if (singlePack == null)
+
+
+        RefreshPackCount();
+
+    }
+
+    void RefreshPackCount()
+    {
+        int count = singlePack.GetAllItems().Count;
+        heroPackText.text = UIHelper.AppendColor(count >= singlePack.unlockedGridCount ? TextColType.Red : TextColType.NavyBrown,
+                            string.Format("{0}/{1}", count, singlePack.unlockedGridCount));
+
+    }
+
+    void GridRefreshEvent(PackType type)
+    { 
+        if (type != PackType.Hero)
             return;
 
-        int count = singlePack.GetAllItems().Count;
-
-        heroPackText.text = UIHelper.AppendColor(count > singlePack.unlockedGridCount ? TextColType.Red : TextColType.NavyBrown,
-                            string.Format("{0}/{1}", count, singlePack.unlockedGridCount));
-        
+        RefreshPackCount();
     }
-    
 }
\ No newline at end of file

--
Gitblit v1.8.0