源战役客户端
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

773 rader
27 KiB

4 veckor sedan
  1. UITabWindow = UITabWindow or BaseClass(BaseComponent)
  2. local UITabWindow = UITabWindow
  3. --窗口类型
  4. UITabWindow.SizeLarge = 1 -- 全屏窗口,有tab
  5. UITabWindow.SizeSmall = 2 -- 非全屏窗口,有tab
  6. UITabWindow.SizeLargeNoTab = 3 -- 全屏窗口,没有tab
  7. UITabWindow.SizeSmallNoTab = 4 -- --非全屏二级窗口,没有tab
  8. UITabWindow.SizeSmallHall = 5 -- 伪全屏窗口,带tab 但是tab不带头像 具体参考副本大厅
  9. UITabWindow.SizeSmallSP = 6 -- 特殊的二级带tab界面 参考送礼记录界面
  10. UITabWindow.SizeSmallHallNoTab = 7 -- 伪全屏窗口,不带tab 具体参考多人副本
  11. UITabWindow.SizeSmallFolderNoTab = 8 -- 非全屏二级窗口,没有tab,背景底样式类似于文件夹,参考查看玩家界面
  12. UITabWindow.SizeSmallActHall = 9 -- 伪全屏活动窗口,带tab 但是tab不带头像 具体参考充值
  13. UITabWindow.DesignWidth = 1560
  14. UITabWindow.DesignHeight = 720
  15. UITabWindow.ShowWidth = math.min(UITabWindow.DesignWidth, ScreenWidth)
  16. UITabWindow.ShowHeigth = math.min(UITabWindow.DesignHeight, ScreenHeight)
  17. --窗口类型参数
  18. UITabWindow.Parms = {
  19. --全屏窗口,带tab
  20. [1] = {
  21. win_width = UITabWindow.ShowWidth,
  22. win_height = UITabWindow.ShowHeigth,
  23. win_name = UIType.WindowNew,
  24. position = Vector3(0,0,0),
  25. tabbar_style = 1,
  26. },
  27. --非全屏窗口,有tab
  28. [2] = {
  29. win_width = 1067,
  30. win_height = 557,
  31. win_name = UIType.WindowNew2,--背景资源默认是WindowNew2_bg
  32. position = Vector3(0,0),
  33. tabbar_style = 2,
  34. },
  35. --全屏窗口,没有tab
  36. [3] = {
  37. win_width = UITabWindow.ShowWidth,
  38. win_height = UITabWindow.ShowHeigth,
  39. win_name = UIType.WindowNew,
  40. position = Vector3(0,0,0),
  41. tabbar_style = 0,
  42. },
  43. --非全屏二级窗口,没有tab
  44. [4] = {
  45. win_width = 1067,
  46. win_height = 557,
  47. win_name = UIType.WindowNew2,--背景资源默认是WindowNew2_bg
  48. position = Vector3(0,0),
  49. tabbar_style = 0,
  50. },
  51. --伪全屏窗口,带tab 但是tab不带头像 具体参考副本大厅
  52. [5] = {
  53. win_width = UITabWindow.ShowWidth,
  54. win_height = UITabWindow.ShowHeigth,
  55. win_name = UIType.WindowNew4,
  56. position = Vector3(0,0,0),
  57. tabbar_style = 3,
  58. },
  59. --非全屏窗口,有tab
  60. [6] = {
  61. win_width = 1067,
  62. win_height = 557,
  63. win_name = UIType.WindowNew6,
  64. position = Vector3(2.5,-6),
  65. tabbar_style = 4,
  66. },
  67. --伪全屏窗口,不带tab 具体参考多人副本
  68. [7] = {
  69. win_width = UITabWindow.ShowWidth,
  70. win_height = UITabWindow.ShowHeigth,
  71. win_name = UIType.WindowNew5,
  72. position = Vector3(0,0,0),
  73. tabbar_style = 0,
  74. },
  75. -- 非全屏二级窗口,没有tab,背景底样式类似于文件夹,参考查看玩家界面
  76. [8] = {
  77. win_width = UITabWindow.ShowWidth,
  78. win_height = UITabWindow.ShowHeigth,
  79. win_name = UIType.WindowNew7,
  80. position = Vector3(0,0,0),
  81. tabbar_style = 0,
  82. },
  83. --伪全屏活动窗口,带tab 但是tab不带头像 具体参考充值
  84. [9] = {
  85. win_width = UITabWindow.ShowWidth,
  86. win_height = UITabWindow.ShowHeigth,
  87. win_name = UIType.WindowNew8,
  88. position = Vector3(0,0,0),
  89. tabbar_style = 8,
  90. },
  91. }
  92. function UITabWindow:__init(parent,tabbar_list,select_callback,close_win_callback,background_wnd,attach_node,view_style, bg_name,ues_new_tab, need_show_money,extra_arg_table)
  93. -------------------------
  94. self._is_uitabwindow = true
  95. -------------------------
  96. self:InitData(tabbar_list,select_callback,close_win_callback,background_wnd,attach_node,view_style, bg_name,ues_new_tab,need_show_money,extra_arg_table)
  97. self.parms = UITabWindow.Parms[view_style] or UITabWindow.Parms[1]
  98. self.tabbar_style = ues_new_tab or self.parms.tabbar_style
  99. self:CreateGameObject(self.parms.win_name)
  100. local function on_back_change( )
  101. if IsNull(self.transform) then
  102. return
  103. end
  104. if BaseView.LastTabIndex and BaseView.LastTabIndex > 0 then
  105. self:SetTabBarIndex(BaseView.LastTabIndex)
  106. BaseView.LastTabIndex = 0
  107. end
  108. end
  109. self.key_back_change_id = GlobalEventSystem:Bind(EventName.KEY_BACK_CHANGE, on_back_change)
  110. end
  111. function UITabWindow:InitData(tabbar_list,select_callback,close_win_callback,background_wnd,attach_node,view_style, bg_name,ues_new_tab, need_show_money, extra_arg_table)
  112. self.curr_tabBtn_index = 0
  113. self.tabbar_item_list = {}
  114. self.tabbar_prefab = nil
  115. self.do_open_ani = false
  116. self.old_ani_top_pos = false
  117. self.old_ani_right_pos = false
  118. self.back_target_view = false
  119. self.tabbar_list = self:CheckTabbarOpen(tabbar_list)
  120. self.select_callback = select_callback
  121. self.close_win_callback = close_win_callback
  122. self.background_wnd = background_wnd
  123. self.attach_node = attach_node
  124. self.bg_name = bg_name
  125. self.view_style = view_style
  126. self.tabbar_style = ues_new_tab
  127. self.need_show_money = need_show_money
  128. self.extra_arg_table = extra_arg_table
  129. end
  130. function UITabWindow:LoadSuccess()
  131. self.win_transform = self.transform
  132. if self.view_style == UITabWindow.SizeLarge or self.view_style == UITabWindow.SizeLargeNoTab then
  133. self.win_bg_obj = self.transform.gameObject
  134. -- self.win_bg = self.win_transform:GetComponent("RawImage")
  135. self.win_bg_tf = self:GetChild("windowBg")
  136. self.win_bg = self:GetChild("windowBg"):GetComponent("RawImage")
  137. self.win_bg_mask = self:GetChild("windowBgMask")
  138. self.win_close_btn = self:GetChild("di_head/windowCloseBtn").gameObject
  139. self.win_tab_scroll = self:GetChild("di_right/windowTabScroll")
  140. self.win_tab_cont_scroll = self:GetChild("di_right/windowTabScroll/Viewport/windowTabCont")
  141. self.win_tab_cont = self:GetChild("di_right/windowTabCont")
  142. self.win_title = self:GetChild("di_head/windowTitleImg")
  143. self.di_right_obj = self:GetChild("di_right").gameObject
  144. self.di_head_trans = self:GetChild("di_head")
  145. self.di_right_trans = self:GetChild("di_right")
  146. self.con_money = self:GetChild("di_head/con_money")
  147. self.lb_title_txt = self:GetChild("di_head/lb_title"):GetComponent(typeof(TMPro.TextMeshProUGUI))
  148. if self.win_title then
  149. self.win_title_bg = self.win_title:GetComponent("Image")
  150. end
  151. --全屏界面排行榜页签位置特殊处理
  152. if self.view_style == UITabWindow.SizeLarge then
  153. if self.tabbar_style == 6 then--排行榜使用样式6的侧边tab,并且位置要偏下
  154. SetAnchoredPositionY(self.win_tab_scroll, -106)
  155. SetAnchoredPositionY(self.win_tab_cont, -117)
  156. else
  157. SetAnchoredPositionY(self.win_tab_scroll, -60.5)
  158. SetAnchoredPositionY(self.win_tab_cont, -71.5)
  159. end
  160. end
  161. elseif self.view_style == UITabWindow.SizeSmall
  162. or self.view_style == UITabWindow.SizeSmallNoTab
  163. or self.view_style == UITabWindow.SizeSmallHall
  164. or self.view_style == UITabWindow.SizeSmallHallNoTab
  165. or self.view_style == UITabWindow.SizeSmallSP
  166. or self.view_style == UITabWindow.SizeSmallFolderNoTab
  167. or self.view_style == UITabWindow.SizeSmallActHall
  168. then
  169. self.win_bg_obj = self.transform.gameObject
  170. self.win_bg_tf = self:GetChild("windowBg")
  171. self.win_bg = self:GetChild("windowBg"):GetComponent("RawImage")
  172. self.win_close_btn = self:GetChild("di_head/windowCloseBtn").gameObject
  173. self.win_title = self:GetChild("di_head/windowTitleImg")
  174. self.win_title_obj = self:GetChild("di_head/windowTitleImg").gameObject
  175. self.win_tab_scroll = self:GetChild("di_right/windowTabScroll")
  176. self.win_tab_cont_scroll = self:GetChild("di_right/windowTabScroll/Viewport/windowTabCont")
  177. self.win_tab_cont = self:GetChild("di_right/windowTabCont")
  178. self.di_right_obj = self:GetChild("di_right").gameObject
  179. -- self.title_name_obj = self:GetChild("di_head/title_name").gameObject
  180. -- self.title_name_tmp = self:GetChild("di_head/title_name"):GetComponent("Text")
  181. self.di_head_trans = self:GetChild("di_head")
  182. self.di_right_trans = self:GetChild("di_right")
  183. self.con_money = self:GetChild("di_head/con_money")
  184. self.nodes = {
  185. "di_head/title_name:tmp:obj",
  186. }
  187. self:GetChildren(self.nodes)
  188. if self.win_title then
  189. self.win_title_bg = self.win_title:GetComponent("Image")
  190. end
  191. if self.view_style == UITabWindow.SizeSmallHall or self.view_style == UITabWindow.SizeSmallHallNoTab then
  192. self.win_bg_left_raw = self:GetChild("bgLeft"):GetComponent("RawImage")
  193. self.win_bg_right_raw = self:GetChild("bgRight"):GetComponent("RawImage")
  194. lua_resM:setOutsideRawImage(self, self.win_bg_left_raw, GameResPath.GetViewBigBg("default_bg_6_left"), true)
  195. lua_resM:setOutsideRawImage(self, self.win_bg_right_raw, GameResPath.GetViewBigBg("default_bg_6_right"), true)
  196. elseif self.view_style == UITabWindow.SizeSmallActHall then
  197. self.win_bg_left_raw = self:GetChild("bgLeft"):GetComponent("RawImage")
  198. self.win_bg_right_raw = self:GetChild("bgRight"):GetComponent("RawImage")
  199. lua_resM:setOutsideRawImage(self, self.win_bg_left_raw, GameResPath.GetViewBigBg("default_bg_7_left"), true)
  200. lua_resM:setOutsideRawImage(self, self.win_bg_right_raw, GameResPath.GetViewBigBg("default_bg_7_right"), true)
  201. self.di_right_img = self:GetChild("di_right"):GetComponent("Image")
  202. lua_resM:setOutsideImageSprite(self, self.di_right_img, GameResPath.GetViewBigBg("ui_tab_bg8"), false)
  203. elseif self.view_style == UITabWindow.SizeSmallFolderNoTab then
  204. -- self.win_bg_base_raw = self:GetChild("windowBg_base"):GetComponent("RawImage")
  205. -- self.win_bg_base_trm = self:GetChild("windowBg_base")
  206. -- lua_resM:setOutsideRawImage(self, self.win_bg_base_raw, GameResPath.GetViewBigBg("folder_like_view_bg_no_tab"), false)
  207. end
  208. end
  209. self:DoOpenViewAnimation()
  210. --[[已废弃,设置背景统一使用SetBackgroundRes
  211. --设置背景
  212. if self.bg_name and self.win_bg and (not ClientConfig.alpha_mode or not ClientConfig.view_style_ui or ClientConfig.view_style_ui == "") then
  213. lua_resM:setOutsideRawImage(self, self.win_bg, GameResPath.GetViewBigBg(self.bg_name))
  214. end
  215. ]]
  216. self:InitEvent()
  217. self:LayoutUI()
  218. self:LoadTabbarPrefab()
  219. self:CreateMoney()
  220. if ClientConfig.alpha_mode then
  221. if ClientConfig.view_style_ui and ClientConfig.view_style_ui ~= "" then
  222. self:InitAlphaState()
  223. end
  224. end
  225. end
  226. --窗口类型
  227. function UITabWindow:CreateMoney( )
  228. --除了13579 其他是二级界面都不需要UIMoneyView--2021.3.1鑫爷的需求
  229. if self.view_style == UITabWindow.SizeLarge--1
  230. or self.view_style == UITabWindow.SizeLargeNoTab--3
  231. or self.view_style == UITabWindow.SizeSmallHall--5
  232. or self.view_style == UITabWindow.SizeSmallHallNoTab--7
  233. or self.view_style == UITabWindow.SizeSmallActHall--9
  234. then
  235. else
  236. return
  237. end
  238. -- --显示金钱
  239. if self.need_show_money and self.con_money and not ClientConfig.alpha_mode then
  240. if not self.money_view then
  241. self.money_view = UIMoneyView.New(self.con_money)
  242. end
  243. self.money_view:SetPosition(0,0)
  244. self.money_view:SetData()
  245. if self.money_view_add_res then
  246. self.money_view:ChangeAddBtnRes(self.money_view_add_res)
  247. end
  248. --小窗口只显示最多两个货币
  249. if self.view_style == UITabWindow.SizeSmall or self.view_style == UITabWindow.SizeSmallNoTab
  250. or self.view_style == UITabWindow.SizeSmallHall
  251. or self.view_style == UITabWindow.SizeSmallSP
  252. or self.view_style == UITabWindow.SizeSmallHallNoTab
  253. or self.view_style == UITabWindow.SizeSmallFolderNoTab
  254. or self.view_style == UITabWindow.SizeSmallActHall
  255. then
  256. self.money_view:ChangeShowFlag("smallWindow")
  257. end
  258. end
  259. end
  260. --切换背景
  261. function UITabWindow:SetBackgroundRes(res)
  262. local load_bg_callback = function ()
  263. self.win_bg_obj:SetActive(true)
  264. if ClientConfig.is_use_model_render then
  265. self.win_bg.gameObject:SetActive(false)
  266. end
  267. end
  268. if res and self.win_bg and (not ClientConfig.alpha_mode or not ClientConfig.view_style_ui or ClientConfig.view_style_ui == "") then
  269. local is_auto_size = false
  270. lua_resM:setOutsideRawImage(self, self.win_bg, GameResPath.GetViewBigBg(res), is_auto_size, load_bg_callback)
  271. if ClientConfig.is_use_model_render then
  272. if not self.backward_bg then
  273. local back_canvae = GameObject.Find("root").transform:Find("BackCanvas")
  274. print("back_canvae " , back_canvae)
  275. self.backward_bg = back_canvae.transform:Find("Bg/bg_contain/bg"):GetComponent("RawImage")
  276. end
  277. self.backward_bg.gameObject:SetActive(true)
  278. lua_resM:setOutsideRawImage(self, self.backward_bg, GameResPath.GetViewBigBg(res))
  279. end
  280. end
  281. end
  282. --切换标题
  283. function UITabWindow:SetTitleRes(ab_name, res_name)
  284. if self.win_title_bg and ab_name and res_name then
  285. if self.view_style == UITabWindow.SizeLarge or self.view_style == UITabWindow.SizeLargeNoTab then
  286. --不用图片标题
  287. else
  288. if self.title_name_obj then
  289. self.title_name_obj:SetActive(false)
  290. end
  291. lua_resM:setImageSprite(self, self.win_title_bg, ab_name, res_name, true)
  292. end
  293. end
  294. end
  295. function UITabWindow:SetTitleText( str )
  296. if str then
  297. if self.win_title_obj then
  298. self.win_title_obj:SetActive(false)
  299. end
  300. if self.lb_title_txt then
  301. self.lb_title_txt.text = str
  302. end
  303. if self.title_name_tmp then
  304. self.title_name_tmp.text = str
  305. end
  306. end
  307. end
  308. --在父窗口调用
  309. function UITabWindow:__delete()
  310. if self.back_target_view then
  311. LuaViewManager:getInstance():HideBackData(self.back_target_view)
  312. self.back_target_view = false
  313. end
  314. if self.orientation_change_id then
  315. GlobalEventSystem:UnBind(self.orientation_change_id)
  316. self.orientation_change_id = nil
  317. end
  318. if self.key_back_change_id then
  319. GlobalEventSystem:UnBind(self.key_back_change_id)
  320. self.key_back_change_id = nil
  321. end
  322. BaseView.LastTabIndex = 0
  323. self.temp_cur_index = false
  324. self.tabbar_prefab = nil
  325. self.curr_tabBtn_index = 0
  326. if ClientConfig.is_use_model_render then
  327. if self.backward_bg then
  328. self.backward_bg.gameObject:SetActive(false)
  329. end
  330. end
  331. if self.money_view then
  332. self.money_view:DeleteMe()
  333. self.money_view = nil
  334. end
  335. if self.tab_view then
  336. self.tab_view:DeleteMe()
  337. self.tab_view = nil
  338. end
  339. if self.action_nodes then
  340. for k,v in pairs(self.action_nodes) do
  341. cc.ActionManager:getInstance():removeAllActionsFromTarget(v)
  342. end
  343. self.action_nodes = nil
  344. end
  345. self.do_open_ani = false
  346. end
  347. function UITabWindow:LayoutUI()
  348. self.win_transform.anchorMin = Vector2(0.5,0.5)
  349. self.win_transform.anchorMax = Vector2(0.5,0.5)
  350. self.win_transform.localPosition = Vector3(0,0,0)
  351. self.win_transform.sizeDelta = Vector2(self.parms.win_width,self.parms.win_height)
  352. if self.view_style == UITabWindow.SizeLarge or self.view_style == UITabWindow.SizeLargeNoTab then
  353. self:SetIpxMode()
  354. else
  355. --非全屏界面,有偏移
  356. if self.parms.position then
  357. self.transform.localPosition = self.parms.position
  358. end
  359. end
  360. if self.background_wnd then
  361. local index = self.background_wnd.transform:GetSiblingIndex()
  362. self.transform:SetSiblingIndex(index + 1)
  363. else
  364. self.transform:SetAsFirstSibling()
  365. end
  366. -- self.win_title_con.sizeDelta = Vector2(self.title_width,self.title_height)
  367. if self.attach_node then
  368. self.attach_node:SetParent(self.win_transform)
  369. self.attach_node:SetAsFirstSibling()
  370. end
  371. self.win_bg_tf:SetAsFirstSibling()
  372. if self.win_bg_base_trm then--参考副本主界面
  373. self.win_bg_base_trm:SetAsFirstSibling()
  374. end
  375. end
  376. function UITabWindow:SetIpxMode( )
  377. local temp_win_width = self.parms.win_width
  378. local temp_win_off_x, temp_mask_off_x = 0,0
  379. local need_change = false
  380. --全屏界面要适配刘海
  381. if self.view_style == UITabWindow.SizeLarge or self.view_style == UITabWindow.SizeLargeNoTab then
  382. if ClientConfig.iphone_x_model then
  383. if ClientConfig.iphone_x_offset_left > 0 then
  384. temp_win_width = temp_win_width - ClientConfig.iphone_x_offset_left
  385. temp_win_off_x = ClientConfig.iphone_x_offset_left/2
  386. temp_mask_off_x = 0
  387. need_change = true
  388. end
  389. if ClientConfig.iphone_x_offset_right > 0 then
  390. temp_win_width = temp_win_width - ClientConfig.iphone_x_offset_right
  391. temp_win_off_x = temp_win_off_x-ClientConfig.iphone_x_offset_right/2
  392. temp_mask_off_x = temp_win_width + 100 --100是遮罩本身的大小
  393. need_change = true
  394. end
  395. end
  396. SetSizeDeltaX(self.di_head_trans.transform, ScreenWidth - ClientConfig.iphone_x_offset_left - ClientConfig.iphone_x_offset_right)
  397. SetAnchoredPosition( self.di_head_trans.transform, 0, ScreenHeight/2 )
  398. end
  399. if not need_change then
  400. return
  401. end
  402. --窗口偏移
  403. self.win_transform.localPosition = Vector3(temp_win_off_x+self.parms.position.x,self.parms.position.y,0)
  404. self.win_transform.sizeDelta = Vector2(temp_win_width,self.parms.win_height)
  405. --刘海遮罩偏移
  406. -- if self.win_bg_mask and temp_win_off_x ~= 0 then
  407. -- self.win_bg_mask.gameObject:SetActive(true)
  408. -- self.win_bg_mask:SetAsLastSibling()
  409. -- SetAnchoredPositionX(self.win_bg_mask, temp_mask_off_x)
  410. -- end
  411. end
  412. function UITabWindow:LoadTabbarPrefab()
  413. if not self.parms.tabbar_style or self.parms.tabbar_style == 0 then
  414. self.di_right_obj:SetActive(false)
  415. return
  416. end
  417. local function click_callback( index )
  418. if self.temp_cur_index then
  419. BaseView.LastTabIndex = self.temp_cur_index
  420. end
  421. self.select_callback(index)
  422. self.temp_cur_index = index
  423. end
  424. local function set_linebg_size( w,h,con_h )--设置linebg大小 以及容器大小
  425. SetSizeDeltaY(self.win_tab_cont_scroll.transform,con_h)
  426. end
  427. local len = TableSize(self.tabbar_list)
  428. if not self.tab_view then
  429. if len > 6 then--大于六个页签才给予滚动
  430. self.tab_view = UITabBarView.New(self.win_tab_cont_scroll,nil,self.layer_name,self.view_style,true)
  431. self.win_tab_cont.gameObject:SetActive(false)
  432. else
  433. self.tab_view = UITabBarView.New(self.win_tab_cont,nil,self.layer_name,self.view_style)
  434. self.win_tab_scroll.gameObject:SetActive(false)
  435. end
  436. end
  437. self.tab_view:SetData(self.tabbar_list, click_callback, self.tabbar_style, len > 6 and set_linebg_size or nil, self.extra_arg_table)
  438. end
  439. function UITabWindow:InitEvent()
  440. local function onCloseBtnHandler(target)
  441. if self.close_win_callback ~= nil then
  442. self.close_win_callback()
  443. end
  444. end
  445. AddClickEvent(self.win_close_btn,onCloseBtnHandler,LuaSoundManager.SOUND_UI.NONE,true)
  446. local function onOrientationChange( )
  447. self:SetIpxMode()
  448. end
  449. if not self.orientation_change_id then
  450. self.orientation_change_id = GlobalEventSystem:Bind(EventName.ORIENTATION_DID_CHANGE, onOrientationChange)
  451. end
  452. end
  453. function UITabWindow:SetTabBarIndex(index, force, ignore_call_back)
  454. if self.tab_view and self.tab_view.SetTabBarIndex then
  455. self.tab_view:SetTabBarIndex(index, force, ignore_call_back)
  456. end
  457. end
  458. function UITabWindow:GetTabBarBtn(index)
  459. if self.tab_view and self.tab_view.GetTabbarBtn then
  460. return self.tab_view:GetTabbarBtn(index, force)
  461. end
  462. end
  463. function UITabWindow:GetCurrentSelectIndex()
  464. if self.tab_view and self.tab_view.GetCurrentSelectIndex then
  465. return self.tab_view:GetCurrentSelectIndex()
  466. end
  467. end
  468. function UITabWindow:ShowRedPoint(index,bool)
  469. if self.tab_view and self.tab_view.ShowRedPoint then
  470. self.tab_view:ShowRedPoint(index, bool)
  471. end
  472. end
  473. function UITabWindow:ShowRedPointWithNum(index, num, force_show)
  474. -- print("Saber:UITabWindow [526] index, num, force_show: ",index, num, force_show)
  475. if self.tab_view and self.tab_view.ShowRedPointWithNum then
  476. self.tab_view:ShowRedPointWithNum(index, num, force_show)
  477. end
  478. end
  479. function UITabWindow:SetSpeacialImg(index, state)
  480. if self.tab_view and self.tab_view.SetSpeacialImg then
  481. self.tab_view:SetSpeacialImg(index, state)
  482. end
  483. end
  484. function UITabWindow:SetTextSize(font_size)
  485. if self.tab_view and self.tab_view.SetTextSize then
  486. self.tab_view:SetTextSize(font_size)
  487. end
  488. end
  489. function UITabWindow:CheckTabbarOpen( tabbar_list )
  490. if not tabbar_list then return end
  491. local result = {}
  492. local open_status = true
  493. for k,v in pairsByKeys(tabbar_list) do
  494. open_status = true
  495. if (not v.open_lv) and (not v.open_task) and (not v.open_day) and v.module_id and (v.sub_id or v.id) then
  496. --不填开放条件的时候就走一下检测
  497. open_status = GetModuleIsOpen( v.module_id,(v.sub_id or v.id),true )
  498. elseif not MainUIModel:getInstance():GetFunOpenState(v.open_lv, v.open_task or 0) then
  499. open_status = false
  500. elseif v.open_day and v.open_day > ServerTimeModel:getInstance():GetOpenServerDay() then
  501. open_status = false
  502. end
  503. if open_status then
  504. table.insert( result, v )
  505. end
  506. end
  507. return result
  508. end
  509. function UITabWindow:RefeshTabbar(tabbar_list, switch_callback, tabbar_style, force)
  510. self.tabbar_list = self:CheckTabbarOpen(tabbar_list or self.tabbar_list)
  511. self.select_callback = switch_callback or self.select_callback
  512. self.parms.tabbar_style = tabbar_style or self.parms.tabbar_style
  513. if self.tab_view then
  514. self.tab_view:RefreshTabData(self.tabbar_list, self.select_callback, self.parms.tabbar_style)
  515. self:SetTabBarIndex(self:GetCurrentSelectIndex(),force)
  516. -- self.tab_view:RefeshTabBar()
  517. end
  518. end
  519. function UITabWindow:InitAlphaState( )
  520. if self.win_tab_cont_scroll and self.win_tab_cont_scroll.gameObject then
  521. self.win_tab_cont_scroll.gameObject:SetActive(false)
  522. end
  523. if self.win_tab_cont and self.win_tab_cont.gameObject then
  524. self.win_tab_cont.gameObject:SetActive(false)
  525. end
  526. self.win_title_con = self:GetChild("windowTitleCon").gameObject
  527. if self.win_title_con then
  528. self.win_title_con:SetActive(false)
  529. end
  530. if self.win_title and self.win_title.gameObject then
  531. self.win_title.gameObject:SetActive(false)
  532. end
  533. self.close_btn_img = self:GetChild("di_head/windowCloseBtn"):GetComponent("Image")
  534. local btn_res_name, btn_pos, btn_size = AlphaModel:getInstance():GetCloseBtnStyle()
  535. if self.close_btn_img then
  536. lua_resM:setImageSprite(self, self.close_btn_img, "alpha_asset", btn_res_name, true)
  537. end
  538. if self.win_close_btn then
  539. self.win_close_btn.transform.anchoredPosition = btn_pos
  540. end
  541. -- local bg_res_name, bg_pos, bg_size = AlphaModel:getInstance():GetWinBgStyle()
  542. local style = ClientConfig.view_style_ui or 1
  543. local alpha_bg_name = "alpha_win_bg_"..style
  544. print("tanar - [ UITabWindow ] [297] ==> alpha_bg_name: ",alpha_bg_name)
  545. lua_resM:setOutsideRawImage(self, self.win_bg, GameResPath.GetViewBigBg(alpha_bg_name), false)
  546. -- print("tanar - [ UITabWindow ] [296] ==> bg_res_name: ",bg_res_name)
  547. -- lua_resM:setRawImage(self,self.win_bg, "alpha_asset", bg_res_name)
  548. if self.win_bg_obj then
  549. self.win_bg_obj.transform.localPosition = Vector3(-25,-21,0)
  550. self.win_bg_obj.transform.sizeDelta = Vector2(1155, 650)
  551. local alpha_bg_size = AlphaModel:getInstance():GetBgSize()
  552. if alpha_bg_size then
  553. self.win_bg_obj.transform.sizeDelta = alpha_bg_size
  554. end
  555. end
  556. if self.parent_transform then
  557. local win_name = self.parent_transform.name or "UITabWindow"
  558. local error_str = "Alpha record: Open Win " .. win_name
  559. if GameError and GameError.Instance then
  560. GameError.Instance:SendErrorMsg(error_str)
  561. end
  562. end
  563. end
  564. function UITabWindow:DoOpenViewAnimation(force)
  565. if self.parms.win_name ~= UIType.WindowNew or ClientConfig.tabwin_ani_mode == false then
  566. return
  567. end
  568. if self.do_open_ani and not force then
  569. return
  570. end
  571. self.do_open_ani = true
  572. if self.di_head_trans then
  573. self.old_ani_top_pos = self.old_ani_top_pos or self.di_head_trans.anchoredPosition
  574. cc.ActionManager:getInstance():removeAllActionsFromTarget(self.di_head_trans)
  575. SetAnchoredPosition(self.di_head_trans, self.old_ani_top_pos.x, self.old_ani_top_pos.y + 74)
  576. local moveActionTop = cc.MoveTo.createAnchoredType(1.5, self.di_head_trans.anchoredPosition.x, self.old_ani_top_pos.y)
  577. moveActionTop = cc.EaseExponentialOut.New(moveActionTop)
  578. self:AddAction(moveActionTop, self.di_head_trans)
  579. end
  580. if self.di_right_trans then
  581. self.old_ani_right_pos = self.old_ani_right_pos or self.di_right_trans.anchoredPosition
  582. cc.ActionManager:getInstance():removeAllActionsFromTarget(self.di_right_trans)
  583. SetAnchoredPosition(self.di_right_trans, self.old_ani_right_pos.x + 145, self.old_ani_right_pos.y)
  584. local moveActionRight = cc.MoveTo.createAnchoredType(1.5, self.old_ani_right_pos.x, self.di_right_trans.anchoredPosition.y)
  585. moveActionRight = cc.EaseExponentialOut.New(moveActionRight)
  586. self:AddAction(moveActionRight, self.di_right_trans)
  587. end
  588. end
  589. --自销毁动作
  590. function UITabWindow:AddAction( action, node )
  591. self.action_nodes = self.action_nodes or {}
  592. self.action_nodes[node] = node
  593. cc.ActionManager:getInstance():addAction(action, node)
  594. end
  595. --自销毁动作
  596. function UITabWindow:SetUIBack(data)
  597. if self.background_wnd then
  598. self.background_wnd.gameObject:SetActive(false)
  599. end
  600. local target = data.target
  601. local bg1 = data.bg1
  602. local bg2 = data.bg2
  603. local node_list = data.node_list
  604. local back_camera_args = data.camera_args
  605. if target == nil then
  606. error(">>>>>>>>>>>>>需要传入tabwin所在的view")
  607. end
  608. if self.view_style == UITabWindow.SizeLarge then
  609. local camera_args = LuaViewManager.CameraArgs.DepthZero
  610. local bg_list = target.model_activity_bg and {} or -- 显示背景模型的情况不展示图片背景
  611. {
  612. [1] = {res = bg1, args = args1 },
  613. }
  614. LuaViewManager:getInstance():ShowBackData({
  615. target = target,
  616. bg_list = bg_list,
  617. camera_args = camera_args,
  618. activity = {is_show = true,}
  619. })
  620. self.back_target_view = target
  621. elseif self.view_style == UITabWindow.SizeLargeNoTab then
  622. if self.win_bg then
  623. self.win_bg.gameObject:SetActive(false)
  624. end
  625. local args1 = {size = {x = 1560, y = 720,} ,pos = {x = 0, y = 0,}}
  626. local bg_list =
  627. {
  628. [1] = {res = bg1, args = args1 },
  629. }
  630. local data =
  631. {
  632. target = target,
  633. bg_list = bg_list,
  634. camera_args = back_camera_args,
  635. activity = {is_show = true,}
  636. }
  637. LuaViewManager:getInstance():ShowBackData(data)
  638. self.back_target_view = target
  639. elseif self.view_style == UITabWindow.SizeSmallHall
  640. or self.view_style == UITabWindow.SizeSmallHallNoTab
  641. or self.view_style == UITabWindow.SizeSmallActHall
  642. then
  643. if self.win_bg then
  644. self.win_bg.gameObject:SetActive(false)
  645. end
  646. if self.win_bg_base_trm then
  647. self.win_bg_base_trm.gameObject:SetActive(false)
  648. end
  649. local args1 = {size = {x = 1280, y = 720,} ,pos = {x = 0, y = 0,}}
  650. local bg_list =
  651. {
  652. [1] = {res = bg1, args = args1 },
  653. }
  654. local data =
  655. {
  656. target = target,
  657. bg_list = bg_list,
  658. camera_args = back_camera_args,
  659. activity = {is_show = true,}
  660. }
  661. LuaViewManager:getInstance():ShowBackData(data)
  662. self.back_target_view = target
  663. end
  664. end
  665. -- function UITabWindow:SetSceneTextureLimit( flag )
  666. -- local limit_level = flag and 4 or 0
  667. -- QualitySettings.masterTextureLimit = limit_level
  668. -- end
  669. function UITabWindow:UpdateTabInfo( tabbar_list )
  670. self.tabbar_list = self:CheckTabbarOpen(tabbar_list)
  671. self.tab_view:RefreshTabData(self.tabbar_list, self.select_callback, self.parms.tabbar_style)
  672. -- self:LoadTabbarPrefab()
  673. end
  674. --改变金钱界面显示类型
  675. function UITabWindow:ChangeShowFlag( money_type,goods_id )
  676. if self.money_view then
  677. self.money_view:ChangeShowFlag(money_type,goods_id)
  678. end
  679. end
  680. function UITabWindow:ChangeAddBtnRes( res )
  681. if self.money_view then
  682. print("huangcong:UITabWindow [start:735] res:", res)
  683. self.money_view:ChangeAddBtnRes(res)
  684. else
  685. self.money_view_add_res = res
  686. end
  687. end
  688. --设置 Head 的 Siblingindex
  689. --Is_down 是否降低(为false表示还原)
  690. function UITabWindow:SetHeadSiblingIndex(is_down)
  691. if is_down then
  692. if self.win_bg_tf and self.di_head_trans then
  693. local sibing_index = self.win_bg_tf:GetSiblingIndex()
  694. self.di_head_trans:SetSiblingIndex(sibing_index + 1)
  695. end
  696. else
  697. if self.di_head_trans then
  698. local child_num = self.di_head_trans.parent.childCount
  699. self.di_head_trans:SetSiblingIndex(child_num)
  700. end
  701. end
  702. end