Ver Fonte

修改bug

lzx há 1 dia atrás
pai
commit
a20969d51c

+ 5 - 0
Assets/Res/UI/XianTuLogPanel/XianTuLogInfoPanel.prefab

@@ -97,6 +97,11 @@ MonoBehaviour:
     isAssetBundle: 0
     isList: 0
     ListCollectorDatas: []
+  - key: Sr
+    gameObject: {fileID: 7883865494936010614}
+    isAssetBundle: 0
+    isList: 0
+    ListCollectorDatas: []
   isAssetBundle: 1
 --- !u!1 &1850343213030836377
 GameObject:

+ 9 - 0
Assets/Scripts/GameUI/UI/XianTuLogPanel/EventLogInfoWidget.cs

@@ -6,6 +6,7 @@ namespace Fort23.Mono
 	[UIBinding(prefab = "EventLogInfoWidget"  )]
 	public partial class EventLogInfoWidget : ItemWidgetBasic
 	{
+		public XianTuLogInfoData data;
 		private void Init()
 		{
 
@@ -29,6 +30,14 @@ namespace Fort23.Mono
 			LayoutRebuilder.ForceRebuildLayoutImmediate(Text_Name.GetComponent<RectTransform>());
 			LayoutRebuilder.ForceRebuildLayoutImmediate(Text_Name.transform.parent.GetComponent<RectTransform>());
 		}
+		
+		public void CustomInit(XianTuLogInfoData data)
+		{
+			this.data = data;
+			Text_Name.text = data.message;
+			LayoutRebuilder.ForceRebuildLayoutImmediate(Text_Name.GetComponent<RectTransform>());
+			LayoutRebuilder.ForceRebuildLayoutImmediate(Text_Name.transform.parent.GetComponent<RectTransform>());
+		}
 
 	}
 }

+ 9 - 0
Assets/Scripts/GameUI/UI/XianTuLogPanel/EventLogMessageWidget.cs

@@ -6,6 +6,7 @@ namespace Fort23.Mono
 	[UIBinding(prefab = "EventLogMessageWidget"  )]
 	public partial class EventLogMessageWidget : ItemWidgetBasic
 	{
+		public XianTuLogInfoData data;
 		private void Init()
 		{
 
@@ -28,5 +29,13 @@ namespace Fort23.Mono
 			LayoutRebuilder.ForceRebuildLayoutImmediate(Text_Name.GetComponent<RectTransform>());
 			LayoutRebuilder.ForceRebuildLayoutImmediate(Text_Name.transform.parent.GetComponent<RectTransform>());
 		}
+		
+		public void CustomInit(XianTuLogInfoData data)
+		{
+			this.data = data;
+			Text_Name.text = data.message;
+			LayoutRebuilder.ForceRebuildLayoutImmediate(Text_Name.GetComponent<RectTransform>());
+			LayoutRebuilder.ForceRebuildLayoutImmediate(Text_Name.transform.parent.GetComponent<RectTransform>());
+		}
 	}
 }

+ 9 - 0
Assets/Scripts/GameUI/UI/XianTuLogPanel/EventLogTitleWidget.cs

@@ -6,6 +6,7 @@ namespace Fort23.Mono
 	[UIBinding(prefab = "EventLogTitleWidget"  )]
 	public partial class EventLogTitleWidget : ItemWidgetBasic
 	{
+		public XianTuLogInfoData data;
 		private void Init()
 		{
 
@@ -29,6 +30,14 @@ namespace Fort23.Mono
 			LayoutRebuilder.ForceRebuildLayoutImmediate(Text_Name.GetComponent<RectTransform>());
 			LayoutRebuilder.ForceRebuildLayoutImmediate(Text_Name.transform.parent.GetComponent<RectTransform>());
 		}
+		
+		public void CustomInit(XianTuLogInfoData data)
+		{
+			this.data = data;
+			Text_Name.text = data.message;
+			LayoutRebuilder.ForceRebuildLayoutImmediate(Text_Name.GetComponent<RectTransform>());
+			LayoutRebuilder.ForceRebuildLayoutImmediate(Text_Name.transform.parent.GetComponent<RectTransform>());
+		}
 
 	}
 }

+ 72 - 23
Assets/Scripts/GameUI/UI/XianTuLogPanel/XianTuLogInfoPanel.cs

@@ -17,6 +17,8 @@ namespace Fort23.Mono
         public int type;
 
         public string message;
+
+        public int id;
     }
 
 
@@ -31,7 +33,7 @@ namespace Fort23.Mono
 
         List<UIComponent> components = new List<UIComponent>();
 
-        List<EventLogTitleWidget> titleWidgets = new List<EventLogTitleWidget>();
+        // List<EventLogTitleWidget> titleWidgets = new List<EventLogTitleWidget>();
 
         private int type;
 
@@ -50,6 +52,12 @@ namespace Fort23.Mono
         public override void AddButtonEvent()
         {
             Btn_Close.onClick.AddListener(() => { UIManager.Instance.HideUIUIPanel(this); });
+            Sr.onValueChanged.AddListener(OnValueChanged);
+        }
+
+        private void OnValueChanged(Vector2 arg0)
+        {
+            UpdateTitleWidget();
         }
 
         public async void CustomInit(int type, int id)
@@ -82,6 +90,7 @@ namespace Fort23.Mono
                     PlacesConfig placesConfig = ConfigComponent.Instance.Get<PlacesConfig>(keyValuePair.Key);
                     XianTuLogInfoData xianTuLogInfoData3 = new XianTuLogInfoData();
                     xianTuLogInfoData3.type = 1;
+                    xianTuLogInfoData3.id = keyValuePair.Value[0].ID;
                     xianTuLogInfoData3.message = LanguageManager.Instance.Text(placesConfig.placeName);
                     showXianTuLogInfoData.Add(xianTuLogInfoData3);
                 }
@@ -96,10 +105,12 @@ namespace Fort23.Mono
                         {
                             XianTuLogInfoData xianTuLogInfoData = new XianTuLogInfoData();
                             xianTuLogInfoData.type = 2;
+                            xianTuLogInfoData.id = eventConfig.ID;
                             xianTuLogInfoData.message = "????????";
 
                             XianTuLogInfoData xianTuLogInfoData1 = new XianTuLogInfoData();
                             xianTuLogInfoData1.type = 3;
+                            xianTuLogInfoData1.id = eventConfig.ID;
                             xianTuLogInfoData1.message = "?????????????????????????????????";
 
                             showXianTuLogInfoData.Add(xianTuLogInfoData);
@@ -110,6 +121,7 @@ namespace Fort23.Mono
                     {
                         XianTuLogInfoData xianTuLogInfoData = new XianTuLogInfoData();
                         xianTuLogInfoData.type = 2;
+                        xianTuLogInfoData.id = eventConfig.ID;
                         xianTuLogInfoData.message = LanguageManager.Instance.Text(eventConfig.EventName);
                         showXianTuLogInfoData.Add(xianTuLogInfoData);
                         foreach (var eventListSelectEventLinkId in eventList.selectEventLinkIds)
@@ -121,6 +133,7 @@ namespace Fort23.Mono
                                 {
                                     XianTuLogInfoData xianTuLogInfoData1 = new XianTuLogInfoData();
                                     xianTuLogInfoData1.type = 3;
+                                    xianTuLogInfoData1.id = eventConfig.ID;
                                     if (eventLinkConfig.NPCID != 0)
                                     {
                                         xianTuLogInfoData1.message = $"<color=#A6A6A6>{LanguageManager.Instance.Text(i)}</color>";
@@ -129,8 +142,8 @@ namespace Fort23.Mono
                                     {
                                         xianTuLogInfoData1.message = $"<color=#867169>{LanguageManager.Instance.Text(i)}</color>";
                                     }
-                                  
-                                  
+
+
                                     showXianTuLogInfoData.Add(xianTuLogInfoData1);
                                 }
                             }
@@ -142,13 +155,13 @@ namespace Fort23.Mono
             if (type == 1)
             {
                 // eventLogTitleWidget.SetActive(true);
-                Sv.SetParent(Marsk1,false);
+                Sv.SetParent(Marsk1, false);
                 eventLogTitleWidget.CustomInit(showXianTuLogInfoData[0].message);
                 eventLogTitleWidget.own.SetActive(true);
             }
             else if (type == 2)
             {
-                Sv.SetParent(Marsk2,false);
+                Sv.SetParent(Marsk2, false);
                 eventLogTitleWidget.own.SetActive(false);
             }
 
@@ -167,22 +180,22 @@ namespace Fort23.Mono
             if (xianTuLogInfoData.type == 1)
             {
                 EventLogTitleWidget eventLogTitleWidget = await UIManager.Instance.CreateGComponent<EventLogTitleWidget>(null, ContentRoot);
-                eventLogTitleWidget.CustomInit(xianTuLogInfoData.message);
-                titleWidgets.Add(eventLogTitleWidget);
+                eventLogTitleWidget.CustomInit(xianTuLogInfoData);
+                // titleWidgets.Add(eventLogTitleWidget);
                 components.Add(eventLogTitleWidget);
                 return eventLogTitleWidget;
             }
             else if (xianTuLogInfoData.type == 2)
             {
                 EventLogInfoWidget eventLogInfoWidget = await UIManager.Instance.CreateGComponent<EventLogInfoWidget>(null, ContentRoot);
-                eventLogInfoWidget.CustomInit(xianTuLogInfoData.message);
+                eventLogInfoWidget.CustomInit(xianTuLogInfoData);
                 components.Add(eventLogInfoWidget);
                 return eventLogInfoWidget;
             }
             else if (xianTuLogInfoData.type == 3)
             {
                 EventLogMessageWidget eventLogInfoWidget = await UIManager.Instance.CreateGComponent<EventLogMessageWidget>(null, ContentRoot);
-                eventLogInfoWidget.CustomInit(xianTuLogInfoData.message);
+                eventLogInfoWidget.CustomInit(xianTuLogInfoData);
                 components.Add(eventLogInfoWidget);
                 return eventLogInfoWidget;
             }
@@ -198,10 +211,10 @@ namespace Fort23.Mono
                 components.Remove(widget as UIComponent);
             }
 
-            if (titleWidgets.Contains(widget as EventLogTitleWidget))
-            {
-                titleWidgets.Remove(widget as EventLogTitleWidget);
-            }
+            // if (titleWidgets.Contains(widget as EventLogTitleWidget))
+            // {
+            //     titleWidgets.Remove(widget as EventLogTitleWidget);
+            // }
         }
 
         public override void Close()
@@ -213,36 +226,72 @@ namespace Fort23.Mono
             }
 
             components.Clear();
-            titleWidgets.Clear();
+            // titleWidgets.Clear();
 
             base.Close();
         }
 
-        [CustomMethod(CustomMethodType.Update)]
-        public void Update()
+        List<UIComponent> _components = new List<UIComponent>();
+        private float maxY;
+        private float minY;
+
+       
+        public void UpdateTitleWidget()
         {
             if (type != 1)
                 return;
-            EventLogTitleWidget highestItem = null;
-            float maxY = float.MinValue;
+            UIComponent highestItem = null;
+            maxY = float.MinValue;
+            minY = float.MaxValue;
+            _components.Clear();
 
 
-            foreach (var xianTuTitleWidget in titleWidgets)
+            foreach (var xianTuTitleWidget in components)
             {
                 float itemY = xianTuTitleWidget.own.transform.position.y; // 使用世界坐标的 Y 值
-                if (itemY > maxY)
+                if (itemY > eventLogTitleWidget.own.transform.position.y)
                 {
                     maxY = itemY;
-                    highestItem = xianTuTitleWidget;
+                    // highestItem = xianTuTitleWidget;
+                    _components.Add(xianTuTitleWidget);
+                }
+            }
+
+            foreach (var uiComponent in _components)
+            {
+                float itemY = uiComponent.own.transform.position.y; // 使用世界坐标的 Y 值
+                if (itemY < minY)
+                {
+                    minY = itemY;
+                    highestItem = uiComponent;
                 }
             }
 
+
             if (highestItem != null)
             {
                 float outsideY = eventLogTitleWidget.own.transform.position.y;
-                if (maxY > outsideY )
+                if (maxY > outsideY)
                 {
-                    eventLogTitleWidget.CustomInit(highestItem.Text_Name.text);
+                    EventConfig eventConfig = default;
+                    if (highestItem is EventLogTitleWidget)
+                    {
+                        EventLogTitleWidget eventLogTitleWidget = highestItem as EventLogTitleWidget;
+                        eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventLogTitleWidget.data.id);
+                    }
+                    else if (highestItem is EventLogInfoWidget)
+                    {
+                        EventLogInfoWidget eventLogTitleWidget = highestItem as EventLogInfoWidget;
+                        eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventLogTitleWidget.data.id);
+                    }
+                    else if (highestItem is EventLogMessageWidget)
+                    {
+                        EventLogMessageWidget eventLogTitleWidget = highestItem as EventLogMessageWidget;
+                        eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventLogTitleWidget.data.id);
+                    }
+
+                    PlacesConfig placesConfig = ConfigComponent.Instance.Get<PlacesConfig>(eventConfig.placeID);
+                    eventLogTitleWidget.CustomInit(LanguageManager.Instance.Text(placesConfig.placeName));
                 }
             }
         }

+ 11 - 0
Assets/Scripts/GameUI/UI/XianTuLogPanel/XianTuLogInfoPanelData.cs

@@ -96,6 +96,17 @@ namespace Fort23.Mono
 	      return _Sv;
 	     }
 	   }
+	  private ScrollRect _Sr;
+	  public ScrollRect Sr
+	   {
+	   get{
+	      if (_Sr == null)
+	       {
+	         _Sr  = GetUIUnit<ScrollRect>("Sr"); 
+	       }
+	      return _Sr;
+	     }
+	   }
 	  #endregion 自定义数据结束 
 	 public override async CTask SetUIGameObject(GameObject gObjectPoolInterface)
 	{