-- <* -- @Author: Saber -- @Description: 社团职位分配界面 -- *> GuildPositionAllotView = GuildPositionAllotView or BaseClass(BaseView) local GuildPositionAllotView = GuildPositionAllotView function GuildPositionAllotView:__init() self.base_file = "guild" self.layout_file = "GuildPositionAllotView" self.layer_name = "Activity" self.destroy_imm = true self.use_background = true --全屏界面默认使用这个参数,非全屏界面自行设置 self.change_scene_close = true --是否切换场景时关闭(弹出界面使用) self.blur_activity_bg = true self.use_show_anim = true self.use_hide_anim = true self.sort_type = 1 -- 12战力排序规则:1降序 2升序 34活跃排序规则:3降序 4升序 self.tab_index = 1 self.model = GuildModel:getInstance() self.model:Fire(GuildModel.RequestMemberViewMemberInfoEvt) self.pos_tab = { [1] = {pos = GuildModel.GuildPosition.Leader}, [2] = {pos = GuildModel.GuildPosition.ViceLeader}, [3] = {pos = GuildModel.GuildPosition.Teasure}, [4] = {pos = GuildModel.GuildPosition.Elite}, } self.load_callback = function () self:LoadSuccess() self:AddEvent() end self.open_callback = function ( ) self:UpdateView() end self.destroy_callback = function ( ) self:DestroySuccess() end end function GuildPositionAllotView:Open(index) local role_pos = RoleManager.Instance.mainRoleInfo.position index = index or 1 self.tab_index = role_pos == GuildModel.GuildPosition.Leader and index or 3 BaseView.Open(self) end function GuildPositionAllotView:LoadSuccess() local nodes = { "content", "content/tab_con", "content/item_scroll", "content/item_scroll/Viewport/item_con", "content/guildlist_title/t_power:obj", "content/guildlist_title/power_arrow:obj", "content/guildlist_title/t_active:obj", "content/guildlist_title/active_arrow:obj", } self:GetChildren(nodes) local function close_callback() self:Close() end self.tabWindowComponent = UITabWindow.New(self.transform, {}, nil, close_callback, self.background_wnd, self.content, UITabWindow.SizeSmallNoTab, nil, nil, false) self.tabWindowComponent:SetTitleText("职位分配") self.tabWindowComponent:SetBackgroundRes("WindowNew2_bg") end function GuildPositionAllotView:AddEvent() local function click_event(target) if target == self.t_power_obj then self:SwitchSortType(self.power_arrow.localScale.y < 0 and 1 or 2) elseif target == self.t_active_obj then self:SwitchSortType(self.active_arrow.localScale.y < 0 and 3 or 4) end end AddClickEvent(self.t_power_obj, click_event, LuaSoundManager.SOUND_UI.SWITCH) AddClickEvent(self.t_active_obj, click_event, LuaSoundManager.SOUND_UI.SWITCH) -- 成员任命更新 40013 local function on_change_mem_pos() self:UpdateMemItem(self.pos_tab[self.tab_index]) end self:BindEvent(self.model, GuildModel.RefreshMainViewMemberInfoEvt, on_change_mem_pos) end function GuildPositionAllotView:UpdateView() self:SwitchSortType(1, true) self:UpdatePosTab() end function GuildPositionAllotView:UpdatePosTab( ) local function callback(index) self:SwitchTab(index) end self.tab_item_creator = self.tab_item_creator or self:AddUIComponent(UI.ItemListCreator) local info = { data_list = self.pos_tab, item_con = self.tab_con, scroll_view = self.tab_con, item_class = GuildPositionAllotTabItem, item_height = 118, space_y = 6, create_frequency = 0.01, alignment = UnityEngine.TextAnchor.UpperLeft, final_callback = function() callback(self.tab_index) end, on_update_item = function(item, i, v) item:SetData(i, v , callback) end, } self.tab_item_creator:UpdateItems(info) end function GuildPositionAllotView:SwitchTab( index ) local role_pos = RoleManager.Instance.mainRoleInfo.position if (index == 1 or index == 2) and role_pos ~= GuildModel.GuildPosition.Leader then -- 团长副团任命只能给团长来 Message.show("您不是团长,无法调整该职位") if self.tab_index == 3 or self.tab_index == 4 then -- 这里考虑了从团长退到副团长的情况 return else index = 3 end end self.tab_index = index if self.tab_item_creator then self.tab_item_creator:IterateItems(function( item, i ) item:SetSelected(i == self.tab_index) end) end self:UpdateMemItem(self.pos_tab[index]) end function GuildPositionAllotView:SwitchSortType(type, no_update) self.sort_type = type if type == 1 or type == 2 then self.power_arrow_obj:SetActive(true) self.active_arrow_obj:SetActive(false) SetLocalScale(self.power_arrow, 1, type == 1 and 1 or -1, 1) elseif type == 3 or type == 4 then self.power_arrow_obj:SetActive(false) self.active_arrow_obj:SetActive(true) SetLocalScale(self.active_arrow, 1, type == 3 and 1 or -1, 1) end if not no_update then self:UpdateMemItem(self.pos_tab[self.tab_index]) end end function GuildPositionAllotView:UpdateMemItem(pos_data) local tab_data = self.model:GetMemDataByPosAndSortCondition(pos_data.pos, self.sort_type) self.mem_item_creator = self.mem_item_creator or self:AddUIComponent(UI.ItemListCreator) local info = { data_list = tab_data, item_con = self.item_con, scroll_view = self.item_scroll, item_class = GuildPositionAllotItem, item_height = 70, create_frequency = 0.01, alignment = UnityEngine.TextAnchor.UpperLeft, on_update_item = function(item, i, v) item:SetData(v, i, pos_data.pos) end, } self.mem_item_creator:UpdateItems(info) end function GuildPositionAllotView:DestroySuccess( ) if self.tabWindowComponent then self.tabWindowComponent:DeleteMe() self.tabWindowComponent = nil end end