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

100 lines
3.1 KiB

  1. DesignToolTips = DesignToolTips or BaseClass(BaseView)
  2. function DesignToolTips:__init()
  3. self.base_file = "common"
  4. self.layout_file = "DesignToolTips"
  5. self.layer_name = "Top"
  6. self.use_background = true
  7. self.hide_maincancas = false
  8. self.click_bg_toClose = true
  9. self.is_set_zdepth = true
  10. self.pos_x = 0
  11. self.pos_y = 0
  12. self.design_cfg = nil
  13. self.model = GoodsModel:getInstance()
  14. self.mainVo = RoleManager.Instance.mainRoleInfo
  15. self.curr_height = 0
  16. self.load_callback = function ()
  17. self:LoadSuccess()
  18. end
  19. self.open_callback = function ()
  20. self:SetData()
  21. end
  22. self.close_callback = function ()
  23. end
  24. self.destroy_callback = function ()
  25. end
  26. end
  27. function DesignToolTips:LoadSuccess()
  28. self.layout = self:GetChild("layout")
  29. self.bg = self:GetChild("layout/bg")
  30. self.icon_con = self:GetChild("layout/icon_con"):GetComponent("Image")
  31. self.nameText = self:GetChild("layout/nameText"):GetComponent("Text")
  32. self.typeText = self:GetChild("layout/typeText"):GetComponent("Text")
  33. self.line1 = self:GetChild("layout/line1")
  34. self.contentText = self:GetChild("layout/contentText")
  35. self.proText = self:GetChild("layout/proText")
  36. self.conditionText = self:GetChild("layout/conditionText")
  37. self.close_btn = self:GetChild("layout/close_btn").gameObject
  38. self:InitEvent()
  39. end
  40. function DesignToolTips:InitEvent()
  41. local function onclick(target)
  42. if target == self.close_btn then
  43. self:Close()
  44. end
  45. end
  46. AddClickEvent(self.close_btn,onclick)
  47. end
  48. function DesignToolTips:Open(design_id, x, y, conditionStr)
  49. self.design_id = design_id
  50. self.design_cfg = Config.Dsgt[design_id]
  51. self.conditionStr = conditionStr
  52. self.pos_x = x
  53. self.pos_y = y
  54. BaseView.Open(self)
  55. end
  56. function DesignToolTips:SetData()
  57. if self.design_cfg == nil then return end
  58. lua_resM:setOutsideImageSprite(self,self.icon_con,GameResPath.GetDesignImage(self.design_id),true)
  59. self.nameText.text = self.design_cfg.name
  60. self.typeText.text = "类型:称号"
  61. self.curr_height = 152
  62. self.contentText.localPosition = Vector3(32,-self.curr_height,0)
  63. --描述
  64. local contentStr = Trim(self.design_cfg.description)
  65. self.contentText:GetComponent("Text").text = contentStr
  66. self.curr_height = self.curr_height + self.contentText:GetComponent("Text").preferredHeight
  67. self.curr_height = self.curr_height + 36
  68. --属性
  69. local attr_list = ErlangParser.GetInstance():Parse(self.design_cfg.attr_list)
  70. local attrStr = "激活可加成:\n"
  71. for k,v in ipairs(attr_list) do
  72. attrStr = string.format("%s<color='%s'>%s</color>%s", attrStr, ColorUtil.GREEN,
  73. WordManager:GetPropertyInfo(tonumber(v[1]),tonumber(v[2])), "\n")
  74. end
  75. self.proText:GetComponent("Text").text = attrStr
  76. self.curr_height = self.curr_height + self.proText:GetComponent("Text").preferredHeight
  77. self.curr_height = self.curr_height + 36
  78. if self.conditionStr ~= "" then
  79. self.conditionText.localPosition = Vector3(32,-self.curr_height,0)
  80. self.conditionText:GetComponent("Text").text = self.conditionStr
  81. self.curr_height = self.curr_height + self.conditionText:GetComponent("Text").preferredHeight
  82. else
  83. self.conditionText:GetComponent("Text").text = ""
  84. end
  85. self.curr_height = self.curr_height + 20
  86. self.bg.sizeDelta = Vector2(407,self.curr_height)
  87. end