CSGWarSupportItem = CSGWarSupportItem or BaseClass(BaseItem) local CSGWarSupportItem = CSGWarSupportItem function CSGWarSupportItem:__init() self.base_file = "CSGWar" self.layout_file = "CSGWarSupportItem" self.model = CSGWarModel:GetInstance() self:Load() end function CSGWarSupportItem:Load_callback() self.nodes = { "power_text:txt", "num_text:tmp", "my_image:obj", "guild_text:tmp", "name_text:tmp", "country_text:tmp", "progress_image:img", "support_text:tmp","select_image:obj", "click_con:obj", "bg:img", "boss_power_text:txt", "contry_image:img", } self:GetChildren(self.nodes) self:AddEvents() if self.need_refreshData then self:UpdateView() end if self.need_reselect then self:SetSelect(self.select) end end function CSGWarSupportItem:AddEvents( ) local function on_click( ... ) if self.call_back then self.call_back(self.data, self.index) end end AddClickEvent(self.click_con_obj, on_click) end function CSGWarSupportItem:UpdateView( ) local data = self.data self.country_text_tmp.text = KfWorldModel:GetInstance():GetContrayNameById(self.index) lua_resM:setOutsideImageSprite(self, self.bg_img, GameResPath.GetCSGWarImage("csgwar_support_bg"..self.index)) if data and TableSize(data) > 0 then lua_resM:setImageSprite(self, self.contry_image_img, "CSGWar_asset", "CSGWar_color"..self.index) self.power_text_txt.text = data.guild_power -- self.progress_image_img.fillAmount = data.help_num/self.all_support_num self.progress_image_img.fillAmount = data.help_num/100--改成100作为分母了 self.name_text_tmp.text = "团长: "..data.chief_name self.num_text_tmp.text = data.help_num self.guild_text_tmp.text = GetCSLongName(data.guild_name, data.server_num, false, ColorUtil.GREEN_DARK) self.my_image_obj:SetActive(data.my_help_num > 0) self.support_text_tmp.text = string.format("我的应援:%s", data.my_help_num) self.boss_power_text_txt.text = data.chief_power else self.power_text_txt.text = 0 self.progress_image_img.fillAmount = 0 self.name_text_tmp.text = "暂无" self.num_text_tmp.text = 0 self.guild_text_tmp.text = "暂无社团" self.my_image_obj:SetActive(false) self.support_text_tmp.text = "我的应援:0" self.boss_power_text_txt.text = 0 end end function CSGWarSupportItem:SetCallBackFunc( func ) self.call_back = func end function CSGWarSupportItem:GetData( ) return self.data end function CSGWarSupportItem:SetData( data,index,all_support_num ) self.data = data self.index = index self.all_support_num = all_support_num or 1 if self.is_loaded then self.need_refreshData = false self:UpdateView() else self.need_refreshData = true end end function CSGWarSupportItem:SetSelect( bool ) self.select = bool if self.is_loaded then self.need_reselect = false self.select_image_obj:SetActive(bool) else self.need_reselect = true end end function CSGWarSupportItem:__delete( ) end