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

71 line
2.2 KiB

  1. --[[
  2. @describtion:
  3. @author:hjp
  4. ]]
  5. UIRedDotIcon = UIRedDotIcon or BaseClass()
  6. --红点的类型
  7. UIRedDotIcon.RedDotType = {
  8. red_dot = "com_red_point", --提示红点
  9. red_dot_num = "com_red_point_2", --红点带数字
  10. }
  11. function UIRedDotIcon:__init(parent_wnd, type, pos, size)
  12. self.root_wnd = parent_wnd
  13. self.gameObject = UiFactory.createChild(parent_wnd,UIType.Image,"RedDotIcon")
  14. self.transform = self.gameObject.transform
  15. self.image = self.gameObject:GetComponent("Image")
  16. self.type = type or UIRedDotIcon.RedDotType.red_dot
  17. self.size = size
  18. lua_resM:setImageSprite(self,self.image,"mainui_asset", self.type, size == nil, function()
  19. if self.size then
  20. self.transform.sizeDelta = Vector2(self.size.x, self.size.y)
  21. else
  22. self.size = Vector2(self.transform.sizeDelta.x, self.transform.sizeDelta.y)
  23. end
  24. end)
  25. if type == UIRedDotIcon.RedDotType.red_dot_num then
  26. local label = UiFactory.createChild(self.transform, UIType.Label2, "Number")
  27. label.transform.sizeDelta = Vector2(0,0)
  28. label.transform.anchoredPosition = Vector3(-2.5,0.45,0)
  29. self.lbNumber = label:GetComponent("Text")
  30. self.lbNumber.color = Color(1,1,1,1)
  31. end
  32. if pos then self:SetPosition(pos.x, pos.y) end
  33. end
  34. function UIRedDotIcon:SetNumber(number)
  35. if self.lbNumber then
  36. self.lbNumber.text = number
  37. self.lbNumber.transform.sizeDelta = Vector2(self.lbNumber.preferredWidth, self.lbNumber.preferredHeight)
  38. end
  39. end
  40. function UIRedDotIcon:SetSize( x,y )
  41. self.size = Vector2(x,y)
  42. self.transform.sizeDelta = self.size
  43. end
  44. -- function UIRedDotIcon:SetRedDotRes( res )
  45. -- if self.ib_red_dot then
  46. -- self.ib_red_dot:SetString(ImageBoxProperty.Source, "comp:xx_red_dot")
  47. -- end
  48. -- end
  49. function UIRedDotIcon:SetPosition( x, y )
  50. self.transform.anchoredPosition = Vector3(x, y, 0)
  51. end
  52. function UIRedDotIcon:GetPosition()
  53. return self.transform.anchoredPosition
  54. end
  55. function UIRedDotIcon:SetVisible( flag )
  56. flag = flag or false
  57. self.gameObject:SetActive(flag)
  58. end
  59. function UIRedDotIcon:IsVisible()
  60. return self.gameObject.activeSelf
  61. end