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

62 lines
1.5 KiB

  1. GetWayTipsItem = GetWayTipsItem or BaseClass(BaseItem)
  2. function GetWayTipsItem:__init()
  3. self.base_file = "common"
  4. self.layout_file = "GetWayTipsItem"
  5. self.data = nil
  6. self:Load()
  7. end
  8. function GetWayTipsItem:Load_callback()
  9. self.btnGo = self:GetChild("btnGo").gameObject
  10. self.icon = self:GetChild("icon"):GetComponent("Image")
  11. self.name = self:GetChild("point/name"):GetComponent("Text")
  12. self.clickBg = self:GetChild("clickBg").gameObject
  13. self:InitEvent()
  14. end
  15. function GetWayTipsItem:InitEvent()
  16. local function onBtnClickHandler(target)
  17. if self.data then
  18. if target == self.btnGo or target == self.clickBg then
  19. OpenFun.Open(unpack(self.data))
  20. end
  21. end
  22. --关闭获取途径界面
  23. GlobalEventSystem:Fire(EventName.CLICK_GET_WAY_ITEM)
  24. end
  25. AddClickEvent(self.btnGo,onBtnClickHandler)
  26. AddClickEvent(self.clickBg,onBtnClickHandler)
  27. end
  28. function GetWayTipsItem:SetData(strs)
  29. if strs == nil or Trim(strs) == "" then
  30. return
  31. end
  32. local cfg_index = 1
  33. local array = {}
  34. local is_more = string.find(strs,"@")
  35. if is_more then
  36. array = Split(strs,"@")
  37. for k,v in pairs(array) do
  38. array[k] = tonumber(v)
  39. end
  40. cfg_index = array[1]
  41. else
  42. cfg_index = tonumber(strs)
  43. array[1] = cfg_index
  44. end
  45. local data = OpenFun.LinkWin[cfg_index]
  46. if not data then
  47. print("******没有对应的获取途径配置******")
  48. return
  49. end
  50. self.data = array
  51. lua_resM:setImageSprite(self, self.icon, "mainui_asset", data.icon_res)
  52. self.name.text = data.name or "未定义:OpenFun.lua"
  53. end