EquipCollectMainView = EquipCollectMainView or BaseClass(BaseView)
|
|
local EquipCollectMainView = EquipCollectMainView
|
|
EquipCollectMainView.TAB_DATA = {
|
|
{id = EquipCollectConst.TAB_ID.COLLECT, name = "装备收集", sub_id = 1},
|
|
-- {id = EquipCollectConst.TAB_ID.BOSS, name = "装备获取", sub_id = 2},
|
|
{id = EquipCollectConst.TAB_ID.UPGRADE, name = "装备升星", sub_id = 3},
|
|
-- {id = EquipCollectConst.TAB_ID.TASK, name = "装备交易", sub_id = 4},
|
|
}
|
|
|
|
function EquipCollectMainView:__init()
|
|
self.base_file = "equipCollect"
|
|
self.layout_file = "EquipCollectMainView"
|
|
self.layer_name = "UI"
|
|
self.destroy_imm = true
|
|
self.use_background = true --全屏界面默认使用这个参数
|
|
self.hide_maincancas = false --全屏界面需要放开隐藏主UI
|
|
self.change_scene_close = true
|
|
self.append_to_ctl_queue = true --是否要添加进界面堆栈
|
|
self.need_show_money = false --是否要显示顶部的金钱栏
|
|
self.sub_view_list = {}
|
|
self.tab_item = {}
|
|
self.is_trigger_guide = false
|
|
self.close_fog = true
|
|
self.model = EquipCollectModel:getInstance()
|
|
self.model:Fire(EquipCollectConst.REQUEST_SCMD_EVENT,14510)
|
|
self.model:Fire(EquipCollectConst.REQUEST_SCMD_EVENT,15218)
|
|
self.cur_select_index = 1
|
|
self.model.mask_lead_effect = {}--重置引导特效标记
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
self:AddEvent()
|
|
end
|
|
self.open_callback = function ( )
|
|
self:OpenSuccess()
|
|
self:UpdateRedDot()
|
|
end
|
|
self.switch_callback = function(index)
|
|
self:SwitchTab(index)
|
|
end
|
|
self.destroy_callback = function ( )
|
|
self:DestroySuccess()
|
|
end
|
|
end
|
|
|
|
function EquipCollectMainView:Open( index, id, sub_id, show_first_effect)
|
|
self.cur_select_index = index or self.cur_select_index
|
|
self.id = id
|
|
self.sub_id = sub_id
|
|
self.show_first_effect = show_first_effect
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function EquipCollectMainView:LoadSuccess()
|
|
local nodes = {
|
|
"container", "bg:raw", "close_btn:obj", "tab_con",
|
|
"title_image:img",
|
|
}
|
|
self:GetChildren(nodes)
|
|
lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("equipCollect_main_bg"),false)
|
|
|
|
self:AddToStageHandler()
|
|
end
|
|
|
|
function EquipCollectMainView:AddEvent()
|
|
local function on_click( target )
|
|
if target == self.close_btn_obj then
|
|
self:Close()
|
|
end
|
|
end
|
|
AddClickEvent(self.close_btn_obj, on_click)
|
|
|
|
local function on_ans_update_red_dot( tab_id,bool )--设置红点的状态注意此处的协议是从model那边发过来的
|
|
self:UpdateRedDot()
|
|
end
|
|
self:BindEvent(self.model, EquipCollectConst.ANS_UPDATE_EQUIP_COLLECT_RED_DOT, on_ans_update_red_dot)
|
|
|
|
local function onGuideTrigger()
|
|
self:AddToStageHandler()
|
|
end
|
|
self:BindEvent(GlobalEventSystem, EventName.TRIGGER_GUIDE_TYPE, onGuideTrigger)
|
|
|
|
local function bg_back_func( ... )
|
|
if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then
|
|
self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend"))
|
|
end
|
|
self:MoveUIToBack(self.bg_raw)
|
|
end
|
|
if self.background_wnd then
|
|
bg_back_func()
|
|
else
|
|
self.bg_back_func = bg_back_func
|
|
end
|
|
end
|
|
|
|
function EquipCollectMainView:OpenSuccess()
|
|
self:SetTabData()
|
|
self:UpdateView()
|
|
end
|
|
|
|
function EquipCollectMainView:UpdateRedDot( )
|
|
local red_data = self.model:GetAllEquipExamRedDot()
|
|
for k,v in pairs(red_data) do
|
|
if self.tab_item[k] then
|
|
self.tab_item[k]:ShowRedPoint(v)
|
|
end
|
|
end
|
|
end
|
|
|
|
function EquipCollectMainView:SetTabData( )
|
|
local y_offset = 100
|
|
local function on_click( index )
|
|
self:SwitchTab(index)
|
|
end
|
|
local index = 0
|
|
for i,v in ipairs(EquipCollectMainView.TAB_DATA) do
|
|
local is_open = GetModuleIsOpen(145, v.sub_id)
|
|
if is_open then
|
|
index = index + 1
|
|
local item = self.tab_item[v.id]
|
|
if not item then
|
|
item = EquipCollectTabItem.New(self.tab_con)
|
|
self.tab_item[v.id] = item
|
|
item:SetPosition(0,-(index - 1)*y_offset)
|
|
item:SetCallBackFunc(on_click)
|
|
end
|
|
item:SetData(v, v.id)
|
|
end
|
|
end
|
|
end
|
|
|
|
function EquipCollectMainView:UpdateView()
|
|
self:SwitchTab(self.cur_select_index)
|
|
end
|
|
|
|
|
|
function EquipCollectMainView:SwitchTab( index )
|
|
self.cur_select_index = index
|
|
for i,v in pairs(self.tab_item) do
|
|
v:SetSelect(i==index)
|
|
end
|
|
if index == EquipCollectConst.TAB_ID.COLLECT then
|
|
lua_resM:setImageSprite(self, self.title_image_img, "equipCollect_asset", "equipCollect_title1", true)
|
|
if self.sub_view_list[index] == nil then
|
|
self.sub_view_list[index] = EquipCollectSubView.New(self.container)
|
|
end
|
|
elseif index == EquipCollectConst.TAB_ID.BOSS then
|
|
if self.sub_view_list[index] == nil then
|
|
self.sub_view_list[index] = EquipExamBossView.New(self.container)
|
|
self.sub_view_list[index]:AppendToBackContainer(self)
|
|
end
|
|
elseif index == EquipCollectConst.TAB_ID.UPGRADE then
|
|
lua_resM:setImageSprite(self, self.title_image_img, "equipCollect_asset", "equipCollect_title3", true)
|
|
if self.sub_view_list[index] == nil then
|
|
self.sub_view_list[index] = EquipExamUpgradeView.New(self.container)
|
|
end
|
|
elseif index == EquipCollectConst.TAB_ID.TASK then
|
|
if self.sub_view_list[index] == nil then
|
|
self.sub_view_list[index] = EquipExamTaskView.New(self.container)
|
|
end
|
|
end
|
|
if index ~= EquipCollectConst.TAB_ID.COLLECT then
|
|
self.show_first_effect = nil--切页签关掉特效
|
|
end
|
|
self:PopUpChild(self.sub_view_list[index])
|
|
self.sub_view_list[index]:SetData(self.id, self.sub_id, self.show_first_effect)
|
|
if index == EquipCollectConst.TAB_ID.COLLECT then
|
|
self.id = nil
|
|
self.sub_id = nil
|
|
end
|
|
end
|
|
|
|
function EquipCollectMainView:DestroySuccess( )
|
|
for i,v in pairs(self.sub_view_list) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.sub_view_list = {}
|
|
|
|
for i,v in pairs(self.tab_item) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.tab_item = {}
|
|
end
|
|
|
|
function EquipCollectMainView:AddToStageHandler()
|
|
local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_EQUIP_COLLECT_ONE_CLOSE,1)
|
|
if not helpVo then return end
|
|
local help_type = helpVo.help_type
|
|
local step = helpVo.step
|
|
local button = false
|
|
if (help_type == HelpType.TYPE_EQUIP_COLLECT_ONE_CLOSE) and step == 1 then
|
|
button = self.close_btn_obj
|
|
end
|
|
if button then
|
|
local function call_back()
|
|
self:Close()
|
|
end
|
|
GlobalEventSystem:Fire(EventName.OPEN_GUIDE_PROMPT_VIEW, button.transform, self.transform, call_back, helpVo, self.layout_file)
|
|
end
|
|
end
|
|
|
|
function EquipCollectMainView:Close()
|
|
--完成引导
|
|
local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_EQUIP_COLLECT_ONE_CLOSE,1)
|
|
if helpVo then
|
|
GlobalEventSystem:Fire(EventName.FINISH_CURRENT_HELP_STEP,helpVo)
|
|
end
|
|
-- if self.is_trigger_guide then
|
|
-- GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK, true, true)
|
|
-- end
|
|
BaseView.Close(self)
|
|
end
|