CSMainAppointAllRoleListItem = CSMainAppointAllRoleListItem or BaseClass(BaseItem)
|
|
local CSMainAppointAllRoleListItem = CSMainAppointAllRoleListItem
|
|
|
|
function CSMainAppointAllRoleListItem:__init()
|
|
self.base_file = "csMain"
|
|
self.layout_file = "CSMainAppointAllRoleListItem"
|
|
self.model = CSMainModel:getInstance()
|
|
|
|
self.role_item_list = {}
|
|
|
|
self:Load()
|
|
end
|
|
|
|
function CSMainAppointAllRoleListItem:Load_callback()
|
|
self.nodes = {
|
|
"bg2:img", "bg1:img", "roleCon", "time:tmp",
|
|
}
|
|
self:GetChildren(self.nodes)
|
|
|
|
lua_resM:setOutsideImageSprite(self, self.bg1_img, GameResPath.GetCSMainImage("cs_main_appoint_bottom_2_short"))
|
|
lua_resM:setOutsideImageSprite(self, self.bg2_img, GameResPath.GetCSMainImage("cs_main_appoint_bottom_1"))
|
|
|
|
self:AddEvents()
|
|
if self.need_refreshData then
|
|
self:UpdateView()
|
|
end
|
|
end
|
|
|
|
function CSMainAppointAllRoleListItem:AddEvents( )
|
|
|
|
end
|
|
|
|
function CSMainAppointAllRoleListItem:UpdateView( )
|
|
self.time_tmp.text = string.format("[%s]",TimeUtil:timeConversion(self.data.issue, "yyyy.mm.dd"))
|
|
|
|
local role_list = {}
|
|
local my_ser_num = RoleManager.Instance.mainRoleInfo.server_num
|
|
for i,v in ipairs(self.data.servers) do
|
|
if v.ser_num == my_ser_num then
|
|
for k,v in pairs(v.directors) do
|
|
role_list[v.pos] = v
|
|
end
|
|
end
|
|
end
|
|
|
|
for k,v in pairs(self.role_item_list) do
|
|
v:SetVisible(false)
|
|
end
|
|
for i=1,7 do
|
|
local item = self.role_item_list[i]
|
|
if not item then
|
|
item = CSMainAppointRoleItem.New(self.roleCon)
|
|
self.role_item_list[i] = item
|
|
end
|
|
|
|
if i == 1 then
|
|
item:SetAnchoredPosition(-130 , 92)
|
|
elseif i == 2 then
|
|
item:SetAnchoredPosition(0 , 92)
|
|
elseif i == 3 then
|
|
item:SetAnchoredPosition(130 , 92)
|
|
elseif i == 4 then
|
|
item:SetAnchoredPosition(-195 , -88)
|
|
elseif i == 5 then
|
|
item:SetAnchoredPosition(-65 , -88)
|
|
elseif i == 6 then
|
|
item:SetAnchoredPosition(65 , -88)
|
|
elseif i == 7 then
|
|
item:SetAnchoredPosition(195 , -88)
|
|
end
|
|
|
|
item:SetVisible(true)
|
|
item:SetData(role_list[i],i)
|
|
end
|
|
end
|
|
|
|
function CSMainAppointAllRoleListItem:SetData( data )
|
|
self.data = data
|
|
if self.is_loaded then
|
|
self.need_refreshData = false
|
|
self:UpdateView()
|
|
else
|
|
self.need_refreshData = true
|
|
end
|
|
end
|
|
|
|
function CSMainAppointAllRoleListItem:__delete( )
|
|
for i, v in ipairs(self.role_item_list) do
|
|
v:DeleteMe()
|
|
end
|
|
self.role_item_list = {}
|
|
end
|