local UIOfficialPositionBase = UIViewClass() local INDEX_OFFICIAL_POSITION = 0 local INDEX_OFFICIAL_PRIVILEGE = 1 local UI_OFFICIAL_POSITION = Const_UI_Lua.UIEnum.UIOfficialPositionMain local UI_OFFICIAL_PRIVILEGE = Const_UI_Lua.UIEnum.UIOfficialPrivilegeMain function UIOfficialPositionBase:OnOpened(context) UTL.Toggle.InitToggleGroupByIDS(self.group_LeftBtn.toggles_Group, "txt",{Const_IDS.IDS_FunctionName_OfficialPosition, Const_IDS.IDS_OfficialPrivilege_OfficialRights}) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.OfficialPosition_Main, self.UpdateRedPoint) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.OfficialPosition_Privilege, self.UpdateRedPoint) self:UpdateRedPoint() UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_OfficialPosition_Title) UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, false) self.lastIndex = -1 if context and context.isPrivilege == true then self.group_LeftBtn.toggles_Group:SelectIndex(INDEX_OFFICIAL_PRIVILEGE) else self.group_LeftBtn.toggles_Group:SelectIndex(INDEX_OFFICIAL_POSITION) end end function UIOfficialPositionBase:UpdateRedPoint() local mainRed = CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.OfficialPosition_Main) self.group_LeftBtn.toggles_Group:SetRedPoint(0, mainRed) local privilegeRed = CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.OfficialPosition_Privilege) self.group_LeftBtn.toggles_Group:SetRedPoint(1, privilegeRed) end function UIOfficialPositionBase:OnValueChanged(comp, index) if comp == self.group_LeftBtn.toggles_Group then if index == 1 and not CTL.HotFix.CheckAssetIsReady("OfficialPrivilege") then self.group_LeftBtn.toggles_Group:SelectIndex(0) CTL.Tips.AddTipsMsg(Const_IDS.IDS_DownloadNotFinish) return end self:SwitchPanel(index) end end function UIOfficialPositionBase:OnClosed() UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) end function UIOfficialPositionBase:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIOfficialPositionBase:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() end end function UIOfficialPositionBase:SwitchPanel(index) if index == self.lastIndex then return end self.lastIndex = index if self.subView then self.subView:CloseView() end if index == INDEX_OFFICIAL_POSITION then self.subView = self.panelRoot:OpenView(GetViewClass(UI_OFFICIAL_POSITION)) else self.subView = self.panelRoot:OpenView(GetViewClass(UI_OFFICIAL_PRIVILEGE)) end end return UIOfficialPositionBase