local UIHomeMain = UIViewClass() local EventSystem = require('Event/EventSystem') function UIHomeMain:OnCreated() self.homeMainEffectId = 0 end function UIHomeMain:OnOpened(context) local viewList = CTL.HomeMain.GetDontDestroyView() for i,v in ipairs(viewList) do self:OpenSubView(self.dontDestroyRoot, v) end if context then self:UpdateView(context) end self:RegistSystemEvent(EventID.UI_HomeMain_PlayEffect, self.PlayEffect) self:RegistSystemEvent(EventID.UI_TeamLevelUpdate,self.OnLevelUp) self:RegistSystemEvent(EventID.UI_HomeMain_ChangeDontMergeView, self.OnChangeDontMergeView) self:RegistSystemEvent(EventID.UI_HomeMain_UpdateChangeRootUI, self.UpdateChangeRootUI) self.context = context end function UIHomeMain:OnBackButtonPressed() -- 新手关 起名之前,弹出当前关卡无法使用此功能提示 if LevelManager.GetCurLevelType() == LuaConst.LevelType.NORMAL and string.isNilOrEmpty(BattleDataGetter.GetPlayerName()) then if not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIMessageBoxView) then UTL.MessageBox.ShowOnlyOkBox("", UIUtils.GetLocalizedTxt(Const_IDS.IDS_system_escapeforbid)) else UIManager.CloseView(Const_UI_Lua.UIEnum.UIMessageBoxView) end return end if MDL.HomeMain.GetTownHomeUIFoldStateByType(MDL.HomeMain.TownFoldType.RightBottom) then EventSystem.Dispatch(EventID.UI_ActivityNotice_FoldOut) else SDKUtil.Exit(); end end function UIHomeMain:OnLevelUp() self:PlayUIAnimation("levelUp") end function UIHomeMain:StopEffect() if self.homeMainEffectId>0 then AuxUtil.StopDynamicObject(self.homeMainEffectId) self.homeMainEffectId = 0 end end function UIHomeMain:PlayEffect(path, duration) self:StopEffect() self.homeMainEffectId = AuxUtil.PlayDynamicObject(path,duration, self.effect) end function UIHomeMain:UpdateView(viewTable) self.changeRoot:CloseAll() for i, v in ipairs(viewTable) do self:OpenSubView(self.changeRoot, v) end self.context = viewTable if not BattleDataGetter.IsTownLevel() then self:SetPushStyle(LuaConst.PushStyleEnum.HIDE) end end function UIHomeMain:OpenSubView(root, viewName) if not MDL.ChannelChat.GetFirstPassLevelForNew() and (viewName == Const_UI_Lua.UIEnum.UIChannelChatGlobalChatDlg or viewName == Const_UI_Lua.UIEnum.UIBattleChatDlg ) then return elseif viewName == Const_UI_Lua.UIEnum.UIMiniMapMain then if (MDL.GuildWar.IsGuildWarBattle() or BattleDataGetter.IsGuildWarWaitingArea()) then -- 势力战小地图 root:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIGuildWarMiniMapMain), nil, viewName) elseif BattleDataGetter.IsFightThroneLevel() then -- 大乱斗小地图 root:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIMiniMapFightThrone), nil, viewName) elseif BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.DragonArteryWaitingArea) or BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.DragonArtery) then -- 龙脉战小地图 root:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIMiniMapDragonArtery), nil, viewName) elseif BattleDataGetter.IsCityWarLevel() then -- 城池战小地图 root:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIChangAnSiegeMiniMap), nil, viewName) else root:OpenView(GetViewClass(viewName)) end else root:OpenView(GetViewClass(viewName)) end end function UIHomeMain:OnChangeDontMergeView(viewName, isShow) if isShow then if not self.dontDestroyRoot:IsViewOpened(viewName) then self.dontDestroyRoot:OpenView(GetViewClass(viewName)) end else self.dontDestroyRoot:CloseView(viewName) end end function UIHomeMain:UpdateChangeRootUI(viewName, isShow) if isShow then if not self.changeRoot:IsViewOpened(viewName) then self.changeRoot:OpenView(GetViewClass(viewName)) end else self.changeRoot:CloseView(viewName) end end function UIHomeMain:OnClosed() self:StopEffect() end return UIHomeMain