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

184 rivejä
5.1 KiB

4 viikkoa sitten
  1. FullWindowComponent = FullWindowComponent or BaseClass(BaseComponent)
  2. local FullWindowComponent = FullWindowComponent
  3. --title 窗口名字
  4. --tabbar_list 标签名字数组
  5. --tabbar_asset 图片的预设资源
  6. --select_callback 选择的回调函数
  7. --close_win_callback 关闭窗口的回调函数
  8. --background_wnd 窗口的background_wnd属性
  9. --show_anim 标签按钮是否移动显示
  10. --hide_coin_add 是否隐藏金币栏
  11. --ShowRoleLevelItem方法 显示人物等级
  12. --HideCoinAddByType方法 是否隐藏某种金币类型
  13. function FullWindowComponent:__init(parent,title,tabbar_asset,tabbar_list,select_callback,close_win_callback,background_wnd,show_anim,hide_coin_add)
  14. self:InitData(title,tabbar_asset,tabbar_list,select_callback,close_win_callback,background_wnd,show_anim,hide_coin_add)
  15. self:CreateGameObject(UIType.FullWindowComponent)
  16. end
  17. function FullWindowComponent:InitData(title,tabbar_asset,tabbar_list,select_callback,close_win_callback,background_wnd,show_anim,hide_coin_add)
  18. self.curr_tabBtn_index = 0
  19. self.tabbar_item_list = {}
  20. self.tabbar_prefab = nil
  21. self.title = title
  22. self.tabbar_asset = tabbar_asset
  23. self.tabbar_list = tabbar_list or {}
  24. self.select_callback = select_callback
  25. self.close_win_callback = close_win_callback
  26. self.background_wnd = background_wnd
  27. self.show_anim = show_anim
  28. self.hide_coin_add = hide_coin_add
  29. end
  30. --根据类型隐藏金币/红钻/彩钻
  31. function FullWindowComponent:ShowRoleLevelItem(level,turn,need_lv,alignment_type,add_str,font_color,font_size,front_str)
  32. if self.RoleLevelItem == nil then
  33. self.RoleLevelItem = RoleLevelItem.New(self.transform)
  34. self.RoleLevelItem:SetOrignPos(co.TableXY(-275, 334))
  35. end
  36. self.RoleLevelItem:SetData(level,turn,need_lv,alignment_type,add_str,font_color,font_size,front_str)
  37. end
  38. --根据类型隐藏金币/红钻/彩钻
  39. function FullWindowComponent:HideCoinAddByType( type, bool )
  40. if self.coinAddBar then
  41. self.coinAddBar:ShowByType(type, bool)
  42. end
  43. end
  44. function FullWindowComponent:LoadSuccess()
  45. self.win_transform = self.GetChild("Window")
  46. self.win_title = self:GetChild("Window/windowTitleCon/windowTitleText"):GetComponent("Text")
  47. self.subtitle = self:GetChild("Window/subtitle"):GetComponent("Text")
  48. self.win_close_btn = self:GetChild("Window/windowCloseBtn").gameObject
  49. self.mScroll = self:GetChild("ScrollView")
  50. self.mContent = self:GetChild("ScrollView/Viewport/Content")
  51. self.cdn_image = self:GetChild("Window"):GetComponent("Image")
  52. if not self.hide_coin_add then
  53. self.coinAddBar = CoinAddBar.New(self.transform)
  54. self.coinAddBar_transform = self.coinAddBar.transform
  55. end
  56. lua_resM:setOutsideImageSprite(self, self.cdn_image, GameResPath.GetJpgImage("bag_bg.jpg"), false)
  57. self:InitEvent()
  58. self:LayoutUI()
  59. self:LoadTabbarPrefab()
  60. end
  61. --在父窗口调用
  62. function FullWindowComponent:__delete()
  63. self.tabbar_prefab = nil
  64. self.curr_tabBtn_index = 0
  65. for i,item in pairs(self.tabbar_item_list) do
  66. item:DeleteMe()
  67. end
  68. self.tabbar_item_list = {}
  69. if self.coinAddBar then
  70. self.coinAddBar:DeleteMe()
  71. self.coinAddBar = nil
  72. end
  73. if self.RoleLevelItem then
  74. self.RoleLevelItem:DeleteMe()
  75. self.RoleLevelItem = nil
  76. end
  77. end
  78. function FullWindowComponent:SetTitle( name )
  79. self.title = name
  80. self.win_title.text = self.title
  81. end
  82. function FullWindowComponent:SetSubtitle(name)
  83. self.subtitle.text = name
  84. end
  85. function FullWindowComponent:LayoutUI()
  86. self.win_title.text = self.title
  87. if self.coinAddBar then
  88. self.coinAddBar:SetImageBg(false)
  89. self.coinAddBar_transform.anchoredPosition = Vector3(202,334)
  90. end
  91. if self.background_wnd then
  92. local index = self.background_wnd.transform:GetSiblingIndex()
  93. self.transform:SetSiblingIndex(index + 1)
  94. else
  95. self.transform:SetAsFirstSibling()
  96. end
  97. end
  98. function FullWindowComponent:LoadTabbarPrefab()
  99. local name = nil
  100. local item = nil
  101. local len = #self.tabbar_list
  102. for index,vo in ipairs(self.tabbar_list) do
  103. item = self.tabbar_item_list[index]
  104. if item == nil then
  105. item = FullTabButton.New(self.mContent)
  106. self.tabbar_item_list[index] = item
  107. end
  108. item:SetVisible(true)
  109. item:SetData(index,self.tabbar_asset,vo,self.select_callback,self.show_anim)
  110. end
  111. self.mContent.sizeDelta = Vector2(144, len * 100)
  112. for i=#self.tabbar_list + 1,#self.tabbar_item_list do
  113. self.tabbar_item_list[i]:SetVisible(false)
  114. end
  115. end
  116. function FullWindowComponent:InitEvent()
  117. local function onCloseBtnHandler(target)
  118. if self.close_win_callback ~= nil then
  119. self.close_win_callback()
  120. end
  121. end
  122. AddClickEvent(self.win_close_btn,onCloseBtnHandler,1)
  123. end
  124. function FullWindowComponent:SetTabBarIndex(index)
  125. if self.curr_tabBtn_index == index then return end
  126. ------------这是tabbar按钮样式------------------------
  127. local tabbar = self.tabbar_item_list[self.curr_tabBtn_index]
  128. if tabbar then
  129. tabbar:SetSelect(false)
  130. end
  131. self.curr_tabBtn_index = index
  132. tabbar = self.tabbar_item_list[self.curr_tabBtn_index]
  133. if tabbar then
  134. tabbar:SetSelect(true)
  135. end
  136. end
  137. function FullWindowComponent:GetCurrentSelectIndex()
  138. return self.curr_tabBtn_index
  139. end
  140. function FullWindowComponent:ShowRedPoint(index,bool)
  141. local tabbar = self.tabbar_item_list[index]
  142. if tabbar then
  143. tabbar:ShowRedPoint(bool)
  144. end
  145. end