源战役客户端
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.

58 lines
1.6 KiB

  1. InstructionSmallView = InstructionSmallView or BaseClass(BaseView)
  2. function InstructionSmallView:__init()
  3. self.base_file = "common"
  4. self.layout_file = "InstructionSmallView"
  5. self.layer_name = "Activity"
  6. self.use_background = true
  7. self.click_bg_toClose = true
  8. self.is_set_zdepth = true
  9. self.background_alpha = 0
  10. self:AddPreLoadList("common",{"InstructionSmallItem"})
  11. self.item_list = {}
  12. self.load_callback = function()
  13. self:LoadSuccess()
  14. self:SetData()
  15. end
  16. self.close_callback = function ()
  17. self:Clear()
  18. end
  19. end
  20. function InstructionSmallView:Clear()
  21. for i,item in ipairs(self.item_list) do
  22. item:DeleteMe()
  23. end
  24. self.item_list = {}
  25. end
  26. function InstructionSmallView:LoadSuccess()
  27. self.window = self:GetChild("Window")
  28. self.scroll_content = self:GetChild("Window/ScrollView/Viewport/Content")
  29. end
  30. function InstructionSmallView:Open(index)
  31. self.index = index
  32. BaseView.Open(self)
  33. end
  34. function InstructionSmallView:SetData()
  35. local cfg = Config.ConfigInstruction[self.index]
  36. if cfg then
  37. local height = 10
  38. if cfg.info_list then
  39. local item = nil
  40. for i,vo in ipairs(cfg.info_list) do
  41. item = InstructionSmallItem.New(self.scroll_content)
  42. table.insert(self.item_list,item)
  43. item:SetData(vo)
  44. item:SetPosition(0,-height)
  45. height = height + item:GetHeight()
  46. end
  47. end
  48. self.scroll_content.sizeDelta = Vector2(self.scroll_content.sizeDelta.x, height)
  49. height = height + 30
  50. height = height > 400 and 400 or height
  51. self.window.sizeDelta = Vector2(self.window.sizeDelta.x, height)
  52. --self.scroll_content.localPosition = Vector3.zero
  53. end
  54. end