源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

111 行
3.3 KiB

  1. DsgtToolTip = DsgtToolTip or BaseClass(BaseView)
  2. function DsgtToolTip:__init()
  3. self.base_file = "common"
  4. self.layout_file = "DsgtToolTips"
  5. self.layer_name = "Top"
  6. self.use_background = true
  7. self.click_bg_toClose = true
  8. self.append_to_ctl_queue = false
  9. self.hide_maincancas = false
  10. self.pos_x = 0
  11. self.pos_y = 0
  12. self.curr_height = 0
  13. self.load_callback = function ()
  14. self:LoadSuccess()
  15. end
  16. self.open_callback = function ()
  17. self:SetData()
  18. end
  19. self.close_callback = function ()
  20. end
  21. self.destroy_callback = function ()
  22. self:Remove()
  23. end
  24. end
  25. function DsgtToolTip:LoadSuccess()
  26. self.bg = self:GetChild("layout/bg")
  27. self.img = self:GetChild("layout/img"):GetComponent("Image")
  28. -- lua_resM:setOutsideImageSprite(self,self.img,GameResPath.GetJpgImage("bg_dsgtTip.jpg"),false)
  29. self.combat = self:GetChild("layout/combat/val"):GetComponent("Text")
  30. self.des_con = self:GetChild("layout/Designation")
  31. self.content_text = self:GetChild("layout/contentText")
  32. self.getway = self:GetChild("layout/getway")
  33. self.layout = self:GetChild("layout")
  34. self.getway_text = self:GetChild("layout/getway/getwayText"):GetComponent("Text")
  35. end
  36. function DsgtToolTip:Open(dsgt_id,x,y)
  37. self.dsgt_id = dsgt_id
  38. self.pos_x = x
  39. self.pos_y = y
  40. BaseView.Open(self)
  41. end
  42. function DsgtToolTip:SetData()
  43. if self.dsgt_id then
  44. if self.dsgt_item == nil then
  45. self.dsgt_item = PerfectLoverDesignationItem.New(self.des_con)
  46. end
  47. end
  48. self.dsgt_item:SetData(self.dsgt_id)
  49. self.cfg = Config.Dsgt[self.dsgt_id]
  50. if self.cfg == nil then return end
  51. if type(self.cfg.attr_list) ~= "table" then
  52. attr_list = ErlangParser:GetInstance():Parse(self.cfg.attr_list)
  53. end
  54. self.combat.text = GetFighting(attr_list)
  55. self.curr_height = 185
  56. self.content_text.localPosition = Vector3(28.3,-self.curr_height,0)
  57. local str = "<color=#835741>称号属性加成:</color>\n"
  58. if #attr_list > 0 then
  59. local attr_name = ""
  60. local attr_value = ""
  61. for i = 1,#attr_list do
  62. local attr_id = attr_list[i].attr_id or tonumber(attr_list[i][1])
  63. local attr_num = attr_list[i].attr_num or tonumber(attr_list[i][2])
  64. attr_name = WordManager:GetProperties(attr_id)
  65. attr_value = WordManager:GetPropertyValue(attr_id,attr_num)
  66. str = str..string.format("<color=#a77755>%s</color><color=%s> + %s</color>\n",attr_name,ColorUtil.GREEN,attr_value)
  67. end
  68. end
  69. self.content_text:GetComponent("Text").text = str
  70. self.curr_height = self.curr_height + self.content_text:GetComponent("Text").preferredHeight + 10
  71. self.getway.localPosition = Vector3(17.4,-self.curr_height,0)
  72. self.getway_text.text = "<color=#60a0ff>"..Trim(self.cfg.description).."</color>"
  73. self.curr_height = self.curr_height + self.getway_text.preferredHeight + 10
  74. self.bg.sizeDelta = Vector2(340.5,self.curr_height + 15)
  75. local x,y = ScreenToViewportPoint(self.pos_x,self.pos_y)
  76. self.layout.anchoredPosition = Vector3(x + 10,y +self.bg.sizeDelta.y,0)
  77. if self.pos_x and self.pos_y then
  78. local x,y = ScreenToViewportPoint(self.pos_x,self.pos_y)
  79. if x+340.5 > ScreenWidth then
  80. x = ScreenWidth-340.5-20
  81. elseif x<20 then
  82. x = 20
  83. end
  84. if y < 20 then
  85. y = 20
  86. elseif y+self.bg.sizeDelta.y > ScreenHeight then
  87. y = ScreenHeight-self.bg.sizeDelta.y -20
  88. end
  89. self.layout.anchoredPosition = Vector3(x + 10,y +self.bg.sizeDelta.y,0)
  90. end
  91. end
  92. function DsgtToolTip:Remove()
  93. if self.dsgt_item then
  94. self.dsgt_item:DeleteMe()
  95. self.dsgt_item = nil
  96. end
  97. end