源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.2 KiB

  1. InstructionView = InstructionView or BaseClass(BaseView)
  2. function InstructionView:__init()
  3. self.base_file = "common"
  4. self.layout_file = "instructionView"
  5. self.layer_name = "Top"
  6. self.use_background = true
  7. self.click_bg_toClose = true
  8. self.is_set_zdepth = true
  9. self:AddPreLoadList("common",{"instructionItem"})
  10. self.item_list = {}
  11. self.load_callback = function()
  12. self:LoadSuccess()
  13. self:AddEvents()
  14. self:SetData()
  15. end
  16. self.close_callback = function ()
  17. self:Clear()
  18. end
  19. end
  20. function InstructionView:Clear()
  21. for i,item in ipairs(self.item_list) do
  22. item:DeleteMe()
  23. end
  24. self.item_list = {}
  25. end
  26. function InstructionView:LoadSuccess()
  27. self.nodes = {
  28. "ScrollView/Viewport/Content","Window/windowCloseBtn:obj","Window:raw:obj", "Window/windowTitleText:tmp",
  29. }
  30. self:GetChildren(self.nodes)
  31. local function call_bace( )
  32. if self.Window_obj then
  33. self.Window_obj:SetActive(true)
  34. end
  35. end
  36. lua_resM:setOutsideRawImage(self, self.Window_raw, GameResPath.GetViewBigBg("tips_comm_bg6"), false, call_bace)
  37. end
  38. function InstructionView:AddEvents( )
  39. local function call_back( target )
  40. if target == self.windowCloseBtn_obj then
  41. self:Close()
  42. end
  43. end
  44. AddClickEvent(self.windowCloseBtn_obj,call_back,false)
  45. end
  46. function InstructionView:Open(index,extra_info)
  47. self.index = index
  48. self.extra_info = extra_info
  49. BaseView.Open(self)
  50. end
  51. function InstructionView:SetData()
  52. local cfg = false
  53. if self.extra_info then
  54. cfg = self.extra_info
  55. else
  56. cfg = DeepCopy(Config.ConfigInstruction[self.index])
  57. end
  58. if cfg then
  59. cfg.ViewTitle = ChuanWenManager:getInstance():FormatColorTag(cfg.ViewTitle)
  60. for k,v in pairs(cfg.info_list) do
  61. v.itemTitle = ChuanWenManager:getInstance():FormatColorTag(v.itemTitle)
  62. v.content = ChuanWenManager:getInstance():FormatColorTag(v.content)
  63. end
  64. self.windowTitleText_tmp.text = cfg.ViewTitle or "功能说明"
  65. local height = 10
  66. if cfg.info_list then
  67. local item = nil
  68. for i,vo in ipairs(cfg.info_list) do
  69. item = InstructionItem.New(self.Content)
  70. table.insert(self.item_list,item)
  71. item:SetData(vo)
  72. item:SetAnchoredPosition(0,-height)
  73. height = height + item:GetHeight()
  74. end
  75. end
  76. self.Content.sizeDelta = Vector2(774,height)
  77. self.Content.localPosition = Vector3.zero
  78. end
  79. end