CombatPeportMassgeModle.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #if UNITY_EDITOR
  2. using System.Text;
  3. using Core.BattleReport;
  4. using GameLogic.Combat.CombatTool.CombatReport;
  5. using UnityEngine.UIElements;
  6. namespace xy002Editor.CombatEditor
  7. {
  8. public class CombatPeportMassgeModle
  9. {
  10. private string sxV = "";
  11. private Label label;
  12. private StringBuilder stringBuilder;
  13. private CombatReportEntityInfo combatReportEntityInfo;
  14. private int index = 0;
  15. public void Init(VisualElement root, CombatReportEntityInfo combatReportEntityInfo,
  16. CombaReportEnditorManager combaReportEnditorManager)
  17. {
  18. this.combatReportEntityInfo = combatReportEntityInfo;
  19. TextField textField = new TextField();
  20. textField.label = "筛选信息";
  21. textField.RegisterValueChangedCallback((e) => { sxV = e.newValue; });
  22. root.Add(textField);
  23. Button button = new Button();
  24. button.text = "上一页";
  25. button.clicked+= () =>
  26. {
  27. index--;
  28. if (index < 0)
  29. {
  30. index = 0;
  31. }
  32. };
  33. root.Add(button);
  34. button = new Button();
  35. button.text = "下一页";
  36. button.clicked += () =>
  37. {
  38. index++;
  39. if (index > combatReportEntityInfo.MsgModule.ReportFightMassgeLogDatas.Count / 20)
  40. {
  41. index = combatReportEntityInfo.MsgModule.ReportFightMassgeLogDatas.Count / 20 + 1;
  42. }
  43. };
  44. root.Add(button);
  45. ScrollView miaoshu = combaReportEnditorManager.Copy<ScrollView>("value_scrollview");
  46. root.Add(miaoshu);
  47. label = new Label();
  48. miaoshu.Add(label);
  49. stringBuilder = new StringBuilder();
  50. }
  51. public void OnGui()
  52. {
  53. stringBuilder.Clear();
  54. for (int i = index*20; i < index*20+20; i++)
  55. {
  56. if (combatReportEntityInfo.MsgModule.ReportFightMassgeLogDatas.Count <= i)
  57. {
  58. break;
  59. }
  60. ReportFightMassgeLogData reportFightMassgeLogData =
  61. combatReportEntityInfo.MsgModule.ReportFightMassgeLogDatas[i];
  62. if (!string.IsNullOrEmpty(sxV))
  63. {
  64. if (!reportFightMassgeLogData.msg.Contains(sxV))
  65. {
  66. continue;
  67. }
  68. }
  69. stringBuilder.Append(reportFightMassgeLogData.time + " " + reportFightMassgeLogData.msg + "\n");
  70. }
  71. label.text = stringBuilder.ToString();
  72. }
  73. }
  74. }
  75. #endif