CSMainMilitaryRanksRankItem = CSMainMilitaryRanksRankItem or BaseClass(BaseItem) local CSMainMilitaryRanksRankItem = CSMainMilitaryRanksRankItem function CSMainMilitaryRanksRankItem:__init() self.base_file = "csMain" self.layout_file = "CSMainMilitaryRanksRankItem" self.model = CSMainModel:getInstance() self:Load() end function CSMainMilitaryRanksRankItem:Load_callback() self.nodes = { "rankIcon:obj:img", "militaryBigIcon:img", "militarySmallIcon:img", "sex:img", "vipCon", "name:tmp", "contrayName:tmp", "rank:tmp", } self:GetChildren(self.nodes) self.vipItem = RoleVipItem.New(self.vipCon) self:AddEvents() if self.need_refreshData then self:UpdateView() end end function CSMainMilitaryRanksRankItem:AddEvents( ) end function CSMainMilitaryRanksRankItem:UpdateView( ) self.vipItem:SetData(self.data.vip,self.data.svip) self.name_tmp.text = GetCSLongName(self.data.name,self.data.ser_num) local sex_res = self.data.sex == 1 and "com_boy" or "com_girl" lua_resM:setImageSprite(self, self.sex_img, "common_asset", sex_res, true) SetAnchoredPositionX(self.sex, -228+self.name_tmp.preferredWidth+20) if self.data.rank >= 1 and self.data.rank <= 3 then lua_resM:setImageSprite(self, self.rankIcon_img, "csMain_asset","cs_main_rank_"..self.data.rank,true) self.rankIcon_obj:SetActive(true) self.rank_tmp.text = "" else self.rankIcon_obj:SetActive(false) self.rank_tmp.text = self.data.rank end local country_name = KfWorldModel:GetInstance():GetContrayNameById(self.data.faction) self.contrayName_tmp.text = country_name lua_resM:setOutsideImageSprite(self, self.militarySmallIcon_img, GameResPath.GetMilitaryImage("military_ranks_"..self.data.pos), true) -- local high_military_ranks = self.model:GetCSMainHighMilitaryRanks(self.data.pos) -- lua_resM:setOutsideImageSprite(self, self.militaryBigIcon_img, GameResPath.GetCSMainImage("military_ranks_big_icon_"..high_military_ranks), true) end function CSMainMilitaryRanksRankItem:SetData( data ) self.data = data if self.is_loaded then self.need_refreshData = false self:UpdateView() else self.need_refreshData = true end end function CSMainMilitaryRanksRankItem:__delete( ) if self.vipItem then self.vipItem:DeleteMe() self.vipItem = nil end end