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

233 regels
8.0 KiB

1 maand geleden
  1. --[[@------------------------------------------------------------------
  2. @description:
  3. @author:huangcong
  4. ----------------------------------------------------------------------]]
  5. GuildSupportInfoMainView = GuildSupportInfoMainView or BaseClass(BaseView)
  6. GuildSupportInfoMainView.TabData = {
  7. {id = GuildModel.SupportTab.List, name = "协助列表", module_id = 400, sub_id = 6, sort_id = 1},
  8. {id = GuildModel.SupportTab.Thank, name = "发送感谢", module_id = 400, sub_id = 6, sort_id = 2},
  9. {id = GuildModel.SupportTab.Gift, name = "接受感谢", module_id = 400, sub_id = 6, sort_id = 3},
  10. }
  11. local GuildSupportInfoMainView = GuildSupportInfoMainView
  12. function GuildSupportInfoMainView:__init()
  13. self.base_file = "guild"
  14. self.layout_file = "GuildSupportInfoMainView"
  15. self.layer_name = "UI"
  16. self.need_show_money = false
  17. self.destroy_imm = true
  18. self.use_background = true
  19. self.hide_maincancas = false --全屏界面需要放开隐藏主UI
  20. self.append_to_ctl_queue = true --添加进入控制队列
  21. self.change_scene_close = true
  22. -- self.fire_change_visible_event = true
  23. -- self.is_set_zdepth = true
  24. self.blur_activity_bg = true
  25. self.model = GuildModel:getInstance()
  26. self.tab_list = {}
  27. self.tab_index = GuildModel.SupportTab.List
  28. self.mainVo = RoleManager.Instance.mainRoleInfo
  29. self.tab_list = {}
  30. self.sub_view_list = {}
  31. self.load_callback = function ()
  32. self:LoadSuccess()
  33. self:InitEvent()
  34. end
  35. self.open_callback = function ()
  36. self:OpenCallBack()
  37. end
  38. self.close_callback = function ()
  39. self:Remove()
  40. end
  41. end
  42. function GuildSupportInfoMainView:Open(id,speaciel_data)
  43. self.tab_index = id or self.tab_index
  44. self.speaciel_data = speaciel_data or self.speaciel_data
  45. BaseView.Open(self)
  46. -- print("huangcong:GuildSupportInfoMainView [start:61] :", self.speaciel_data)
  47. -- PrintTable(self.speaciel_data)
  48. -- print("huangcong:GuildSupportInfoMainView [end]")
  49. end
  50. function GuildSupportInfoMainView:OpenCallBack( )
  51. end
  52. function GuildSupportInfoMainView:Remove()
  53. if self.delay_id then
  54. GlobalTimerQuest:CancelQuest(self.delay_id)
  55. self.delay_id = nil
  56. end
  57. for k,v in pairs(self.tab_list) do
  58. v:DeleteMe()
  59. end
  60. self.tab_list = {}
  61. for k,v in pairs(self.sub_view_list) do
  62. v:DeleteMe()
  63. end
  64. self.sub_view_list = {}
  65. end
  66. function GuildSupportInfoMainView:LoadSuccess()
  67. self.nodes = {
  68. "bg:raw", "closeBtn:obj", "container", "titleNameText:tmp", "tabCon",
  69. --下方名望券相关节点
  70. "horCon/goodsCon/goods_icon:img","horCon/pro_value:tmp","horCon/lb1:tmp",
  71. "horCon/help:obj","horCon:obj",
  72. }
  73. self:GetChildren(self.nodes)
  74. self.titleNameText_tmp.text = "社团协助"
  75. self.cost_goods_id = WordManager:GetPriceTypeId(4)
  76. self.goods_name = GoodsModel:getInstance():getGoodsName(self.cost_goods_id, true)
  77. self.lb1_tmp.text = string.format("每日协助获得%s上限:",self.goods_name)
  78. local res_asset, res_name = WordManager:GetCommonMoneyIcon(Config.ConfigNotNormalGoods[4].type)
  79. lua_resM:setImageSprite(self, self.goods_icon_img, res_asset, res_name)
  80. self:UpdateView()
  81. end
  82. function GuildSupportInfoMainView:InitEvent()
  83. local function onBtnClickHandler(target,x,y)
  84. if target == self.help_obj then--帮助
  85. EventSystem.Fire(GlobalEventSystem,EventName.OPEN_INSTRUCTION_VIEW, 40006)
  86. elseif target == self.closeBtn_obj then--关闭
  87. self:Close()
  88. end
  89. end
  90. AddClickEvent(self.closeBtn_obj, onBtnClickHandler, LuaSoundManager.SOUND_UI.NONE)
  91. AddClickEvent(self.help_obj, onBtnClickHandler, LuaSoundManager.SOUND_UI.NONE)
  92. local function updateDataInfo( )
  93. if not self.is_loaded then
  94. return
  95. end
  96. self:UpdateReputation()
  97. end
  98. self:BindEvent(self.model, GuildModel.UPDATE_GUILD_SUPPOR_INFO, updateDataInfo)--刷新协助信息列表
  99. end
  100. function GuildSupportInfoMainView:UpdateView( id,speaciel_data )
  101. self.tab_index = id or self.tab_index
  102. self.speaciel_data = speaciel_data or self.speaciel_data
  103. self:UpdateTabList()
  104. self:UpdateReputation()
  105. end
  106. function GuildSupportInfoMainView:UpdateTabList( )--页签数据更新
  107. local tab_list = GuildSupportInfoMainView.TabData
  108. if not tab_list or TableSize(tab_list) == 0 then return end
  109. local function callback( index,force )
  110. self:SwitchView(index,force)
  111. end
  112. local offer_x = 2
  113. local offer_y = 0
  114. local x = 0
  115. local y = 0
  116. for i, v in ipairs(tab_list) do
  117. local item = self.tab_list[i]
  118. if item == nil then
  119. item = GuildSupportInfoMainTab.New(self.tabCon, nil, self.layer_name)
  120. self.tab_list[i] = item
  121. y = -(GuildSupportInfoMainTab.Height + offer_y)* (i-1)
  122. x = 0
  123. item:SetPosition(x,y)
  124. item:SetCallBack(callback)
  125. end
  126. item:SetData(v,i,self.tab_index)
  127. end
  128. callback(self.tab_index,true)
  129. self:UpdateTabRedDot()
  130. end
  131. function GuildSupportInfoMainView:SwitchView(id,force)
  132. if self.tab_index == id and not force then return end
  133. for k,v in ipairs(self.tab_list) do
  134. v:SetSelect(id)
  135. end
  136. if id == GuildModel.SupportTab.List then--协助列表
  137. if self.sub_view_list[id] == nil then
  138. self.sub_view_list[id] = GuildSupportInfoMainListView.New(self.container,nil,self.layer_name)
  139. end
  140. self.sub_view_list[id]:SetData(self.speaciel_data)
  141. lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("guild_support_bg"),false)
  142. elseif id == GuildModel.SupportTab.Thank then--协助感谢
  143. if self.sub_view_list[id] == nil then
  144. self.sub_view_list[id] = GuildSupportInfoMainThankView.New(self.container,nil,self.layer_name)
  145. end
  146. self.sub_view_list[id]:SetData(self.speaciel_data)
  147. lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("guild_support_bg2"),false)
  148. elseif id == GuildModel.SupportTab.Gift then--协助礼物收下
  149. if self.sub_view_list[id] == nil then
  150. self.sub_view_list[id] = GuildSupportInfoMainGiftView.New(self.container,nil,self.layer_name)
  151. end
  152. self.sub_view_list[id]:SetData(self.speaciel_data)
  153. lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("guild_support_bg2"),false)
  154. end
  155. self:PopUpChild(self.sub_view_list[id])
  156. self.tab_index = id
  157. self.speaciel_data = nil
  158. end
  159. function GuildSupportInfoMainView:CancelHide( )
  160. BaseView.CancelHide(self)
  161. if self.is_loaded then
  162. end
  163. end
  164. function GuildSupportInfoMainView:UpdateTabRedDot(id)--更新页签红点
  165. local red_data = self.model.support_red_list
  166. if not id then
  167. for k,v in ipairs(self.tab_list) do
  168. v:SetRedDot(red_data[k] or false)
  169. end
  170. else
  171. for k,v in ipairs(self.tab_list) do
  172. if k == id then
  173. v:SetRedDot(red_data[k] or false)
  174. break
  175. end
  176. end
  177. end
  178. end
  179. function GuildSupportInfoMainView:UpdateReputation( )--更新名望券
  180. local max_num = GoodsModel:getInstance():GetReputationMaxNum() or 0
  181. --宠物生活技能 每日名望获取上限额外提高
  182. local life_skill_active = PetModel:getInstance():IsLifeSkillActived(PetConst.LifeSkill.FameDailyLimitUp)
  183. local life_skill_ratio = PetModel:getInstance():GetPetLifeSkillRatio(PetConst.LifeSkill.FameDailyLimitUp)
  184. if life_skill_active then
  185. max_num = max_num + life_skill_ratio
  186. end
  187. local cur_num = GoodsModel:getInstance():GetDaliyReputation() or 0
  188. local guild_position = RoleManager.Instance.mainRoleInfo.position
  189. local cfg = Config.Guildpos[guild_position]
  190. local add_str = " (普通成员以上获得上限加成,"
  191. if cfg and cfg.reputation_add then
  192. add_str = " (社团"..Trim(cfg.name)..HtmlColorTxt("+"..cfg.reputation_add, ColorUtil.GREEN_DARK).."上限,"
  193. end
  194. local cur_str = HtmlColorTxt(cur_num, max_num <= cur_num and ColorUtil.RED_DARK or ColorUtil.GREEN_DARK)
  195. local str = ""
  196. if guild_position ~= 0 then
  197. str = string.format("%s/%s%s%s",cur_str,max_num,add_str,"每天"..HtmlColorTxt("4:00", ColorUtil.GREEN_DARK).."重置)")
  198. else
  199. str = string.format("%s/%s%s",cur_str,max_num," (社团普通成员以上提高上限,每天"..HtmlColorTxt("4:00", ColorUtil.GREEN_DARK).."重置)")
  200. end
  201. if self.delay_id then
  202. GlobalTimerQuest:CancelQuest(self.delay_id)
  203. self.delay_id = nil
  204. end
  205. local function callback( ... )
  206. self.pro_value_tmp.text = str
  207. SetSizeDeltaX(self.pro_value,self.pro_value_tmp.preferredWidth+2)
  208. end
  209. self.delay_id = setTimeout(callback,0.01) -- 下一帧再加载
  210. end