源战役客户端
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

169 wiersze
6.1 KiB

4 tygodni temu
  1. -- <*
  2. -- @Author: Saber
  3. -- @Description: 社团职位分配界面
  4. -- *>
  5. GuildPositionAllotView = GuildPositionAllotView or BaseClass(BaseView)
  6. local GuildPositionAllotView = GuildPositionAllotView
  7. function GuildPositionAllotView:__init()
  8. self.base_file = "guild"
  9. self.layout_file = "GuildPositionAllotView"
  10. self.layer_name = "Activity"
  11. self.destroy_imm = true
  12. self.use_background = true --全屏界面默认使用这个参数,非全屏界面自行设置
  13. self.change_scene_close = true --是否切换场景时关闭(弹出界面使用)
  14. self.blur_activity_bg = true
  15. self.use_show_anim = true
  16. self.use_hide_anim = true
  17. self.sort_type = 1 -- 12战力排序规则:1降序 2升序 34活跃排序规则:3降序 4升序
  18. self.tab_index = 1
  19. self.model = GuildModel:getInstance()
  20. self.model:Fire(GuildModel.RequestMemberViewMemberInfoEvt)
  21. self.pos_tab = {
  22. [1] = {pos = GuildModel.GuildPosition.Leader},
  23. [2] = {pos = GuildModel.GuildPosition.ViceLeader},
  24. [3] = {pos = GuildModel.GuildPosition.Teasure},
  25. [4] = {pos = GuildModel.GuildPosition.Elite},
  26. }
  27. self.load_callback = function ()
  28. self:LoadSuccess()
  29. self:AddEvent()
  30. end
  31. self.open_callback = function ( )
  32. self:UpdateView()
  33. end
  34. self.destroy_callback = function ( )
  35. self:DestroySuccess()
  36. end
  37. end
  38. function GuildPositionAllotView:Open(index)
  39. local role_pos = RoleManager.Instance.mainRoleInfo.position
  40. index = index or 1
  41. self.tab_index = role_pos == GuildModel.GuildPosition.Leader and index or 3
  42. BaseView.Open(self)
  43. end
  44. function GuildPositionAllotView:LoadSuccess()
  45. local nodes = {
  46. "content",
  47. "content/tab_con",
  48. "content/item_scroll", "content/item_scroll/Viewport/item_con",
  49. "content/guildlist_title/t_power:obj", "content/guildlist_title/power_arrow:obj",
  50. "content/guildlist_title/t_active:obj", "content/guildlist_title/active_arrow:obj",
  51. }
  52. self:GetChildren(nodes)
  53. local function close_callback()
  54. self:Close()
  55. end
  56. self.tabWindowComponent = UITabWindow.New(self.transform, {}, nil, close_callback, self.background_wnd, self.content, UITabWindow.SizeSmallNoTab, nil, nil, false)
  57. self.tabWindowComponent:SetTitleText("职位分配")
  58. self.tabWindowComponent:SetBackgroundRes("WindowNew2_bg")
  59. end
  60. function GuildPositionAllotView:AddEvent()
  61. local function click_event(target)
  62. if target == self.t_power_obj then
  63. self:SwitchSortType(self.power_arrow.localScale.y < 0 and 1 or 2)
  64. elseif target == self.t_active_obj then
  65. self:SwitchSortType(self.active_arrow.localScale.y < 0 and 3 or 4)
  66. end
  67. end
  68. AddClickEvent(self.t_power_obj, click_event, LuaSoundManager.SOUND_UI.SWITCH)
  69. AddClickEvent(self.t_active_obj, click_event, LuaSoundManager.SOUND_UI.SWITCH)
  70. -- 成员任命更新 40013
  71. local function on_change_mem_pos()
  72. self:UpdateMemItem(self.pos_tab[self.tab_index])
  73. end
  74. self:BindEvent(self.model, GuildModel.RefreshMainViewMemberInfoEvt, on_change_mem_pos)
  75. end
  76. function GuildPositionAllotView:UpdateView()
  77. self:SwitchSortType(1, true)
  78. self:UpdatePosTab()
  79. end
  80. function GuildPositionAllotView:UpdatePosTab( )
  81. local function callback(index)
  82. self:SwitchTab(index)
  83. end
  84. self.tab_item_creator = self.tab_item_creator or self:AddUIComponent(UI.ItemListCreator)
  85. local info = {
  86. data_list = self.pos_tab,
  87. item_con = self.tab_con,
  88. scroll_view = self.tab_con,
  89. item_class = GuildPositionAllotTabItem,
  90. item_height = 118,
  91. space_y = 6,
  92. create_frequency = 0.01,
  93. alignment = UnityEngine.TextAnchor.UpperLeft,
  94. final_callback = function()
  95. callback(self.tab_index)
  96. end,
  97. on_update_item = function(item, i, v)
  98. item:SetData(i, v , callback)
  99. end,
  100. }
  101. self.tab_item_creator:UpdateItems(info)
  102. end
  103. function GuildPositionAllotView:SwitchTab( index )
  104. local role_pos = RoleManager.Instance.mainRoleInfo.position
  105. if (index == 1 or index == 2) and role_pos ~= GuildModel.GuildPosition.Leader then -- 团长副团任命只能给团长来
  106. Message.show("您不是团长,无法调整该职位")
  107. if self.tab_index == 3 or self.tab_index == 4 then -- 这里考虑了从团长退到副团长的情况
  108. return
  109. else
  110. index = 3
  111. end
  112. end
  113. self.tab_index = index
  114. if self.tab_item_creator then
  115. self.tab_item_creator:IterateItems(function( item, i )
  116. item:SetSelected(i == self.tab_index)
  117. end)
  118. end
  119. self:UpdateMemItem(self.pos_tab[index])
  120. end
  121. function GuildPositionAllotView:SwitchSortType(type, no_update)
  122. self.sort_type = type
  123. if type == 1 or type == 2 then
  124. self.power_arrow_obj:SetActive(true)
  125. self.active_arrow_obj:SetActive(false)
  126. SetLocalScale(self.power_arrow, 1, type == 1 and 1 or -1, 1)
  127. elseif type == 3 or type == 4 then
  128. self.power_arrow_obj:SetActive(false)
  129. self.active_arrow_obj:SetActive(true)
  130. SetLocalScale(self.active_arrow, 1, type == 3 and 1 or -1, 1)
  131. end
  132. if not no_update then
  133. self:UpdateMemItem(self.pos_tab[self.tab_index])
  134. end
  135. end
  136. function GuildPositionAllotView:UpdateMemItem(pos_data)
  137. local tab_data = self.model:GetMemDataByPosAndSortCondition(pos_data.pos, self.sort_type)
  138. self.mem_item_creator = self.mem_item_creator or self:AddUIComponent(UI.ItemListCreator)
  139. local info = {
  140. data_list = tab_data,
  141. item_con = self.item_con,
  142. scroll_view = self.item_scroll,
  143. item_class = GuildPositionAllotItem,
  144. item_height = 70,
  145. create_frequency = 0.01,
  146. alignment = UnityEngine.TextAnchor.UpperLeft,
  147. on_update_item = function(item, i, v)
  148. item:SetData(v, i, pos_data.pos)
  149. end,
  150. }
  151. self.mem_item_creator:UpdateItems(info)
  152. end
  153. function GuildPositionAllotView:DestroySuccess( )
  154. if self.tabWindowComponent then
  155. self.tabWindowComponent:DeleteMe()
  156. self.tabWindowComponent = nil
  157. end
  158. end