--任务界面 TaskNewBaseView = TaskNewBaseView or BaseClass(BaseView) local TaskNewBaseView = TaskNewBaseView -----------------------扩展模块需要修改的地方-------------------------- TaskNewBaseView.Index2View = { [1] = {index = 1,view = TaskSubMainView}, [2] = {index = 2,view = TaskSubExtensionView}, [3] = {index = 3,view = TaskSubCommonView}, } ---------------------------------------------------------------- function TaskNewBaseView:__init() self.base_file = "task" self.layout_file = "TaskNewBaseView" self.layer_name = "UI" self.append_to_ctl_queue = true self.use_background = true self.change_scene_close = true self.close_fog = true self.model = TaskModel:getInstance() self.show_tabs = {} self.tab_name_list = {} self.contaner_list = {} local playerLv = RoleManager:getInstance():GetMainRoleVo().level for i,v in ipairs(Config.ConfigTaskEffect.Tabbuttons) do if v.open_lv <= playerLv then if i == 2 and not ClientConfig.alpha_mode then table.insert(self.show_tabs, TaskNewBaseView.Index2View[i]) table.insert(self.tab_name_list,v) -- elseif i == 5 and self.model:HasTurnLine() then -- table.insert(self.show_tabs, TaskNewBaseView.Index2View[i]) -- table.insert(self.tab_name_list,v) else table.insert(self.show_tabs, TaskNewBaseView.Index2View[i]) table.insert(self.tab_name_list,v) end end end self.load_callback = function () self:LoadSuccess() self:InitEvent() end self.open_callback = function () self:InitView() end self.close_callback = function( ) end self.destroy_callback = function () self:Remove() end end -- task_id 针对第二个标签 --parent_index,sub_index 针对第三个标签 function TaskNewBaseView:Open(index,task_id,parent_index,sub_index) self.open_index = self:GetRealTabIndex(index or 1) self.task_id = task_id self.parent_index = parent_index self.sub_index = sub_index BaseView.Open(self) end function TaskNewBaseView:InitView() self:SeletedTabbar(self.open_index) end function TaskNewBaseView:LoadSuccess() self.sub_conta = self:GetChild("SubElement") local select_callback = function(index) self:SeletedTabbar(index) end local closeWin_callback = function() self:Close() end self.tabWindowComponent = TabWindowComponent.New(self.transform,"主线任务",self.tab_name_list,1264,632,306,52, select_callback,closeWin_callback,Vector3(0,0,0),self.background_wnd,"task_asset") end function TaskNewBaseView:InitEvent() local close_fun = function () self:Close() end self.event_id = self.model:Bind(TaskEvent.CLOSE_TASK_VIEW, close_fun) end function TaskNewBaseView:Remove() if self.event_id then self.model:UnBind(self.event_id) self.event_id = nil end for i, view in pairs(self.contaner_list) do view:DeleteMe() end self.contaner_list = nil if self.tabWindowComponent then self.tabWindowComponent:DeleteMe() end self.tabWindowComponent = nil end function TaskNewBaseView:SeletedTabbar(index) local current_index = self.tabWindowComponent:GetCurrentSelectIndex() if current_index == index then return end local real_index = self:GetRealTabIndex(index) if real_index == 4 then if RoleManager.Instance.mainRoleInfo.guild_id <= 0 then Message.show(string.format("请先加入一个社团")) return end end self.select_tab = index if self.tabWindowComponent ~= nil then self.tabWindowComponent:SetTabBarIndex(self.select_tab) self:SwitchBar() end end function TaskNewBaseView:SwitchBar() local index = self.tabWindowComponent:GetCurrentSelectIndex() local chile_view = self.contaner_list[index] local viewIndex,viewName = self.show_tabs[index].index,self.show_tabs[index].view local taskType = self:GetTaskTypeByIndex(viewIndex) local config = Config.ConfigTaskEffect.Tabbuttons[viewIndex] if config then self.tabWindowComponent:SetTitle(config.name) end if chile_view == nil then local viewModule = viewName chile_view = viewModule.New(self.sub_conta) self.contaner_list[index] = chile_view end chile_view:SetData(taskType,self.task_id,self.parent_index,self.sub_index) self.task_id = false self.parent_index = false self.sub_index = false self:PopUpChild(chile_view) end function TaskNewBaseView:GetRealTabIndex(index) for i,v in ipairs(self.show_tabs) do if v.index == index then return i end end return 1 end function TaskNewBaseView:GetTaskTypeByIndex( index ) local task_type if index == 1 then task_type = TaskType.MAIN_LINE elseif index == 2 then task_type = TaskType.EXTENSION_LINE elseif index == 3 then task_type = TaskType.BOUNTY_LINE elseif index == 4 then task_type = TaskType.GUILD_LINE elseif index == 5 then task_type = TaskType.TRUN_LINE end return task_type end