RankWarSoulView = RankWarSoulView or BaseClass(BaseItem)
|
|
local RankWarSoulView = RankWarSoulView
|
|
|
|
function RankWarSoulView:__init()
|
|
self.base_file = "rank"
|
|
self.layout_file = "RankWarSoulView"
|
|
self.model = RankModel:getInstance()
|
|
|
|
self.show_role_id = 0
|
|
|
|
self.warSoul_item_list = {}
|
|
|
|
self:Load()
|
|
end
|
|
|
|
function RankWarSoulView:Load_callback()
|
|
self.nodes = {
|
|
"contain/warSoul_conta:obj", "contain/bg:img",
|
|
}
|
|
self:GetChildren(self.nodes)
|
|
|
|
lua_resM:setOutsideImageSprite(self, self.bg_img, GameResPath.GetRankImage("rank_warSoul_bg"))
|
|
|
|
self:AddEvents()
|
|
if self.need_refreshData then
|
|
self:SetData(self.data)
|
|
end
|
|
end
|
|
|
|
function RankWarSoulView:AddEvents( )
|
|
local function OnUpdateWarSoulInfo(role_id)
|
|
if role_id == self.data.role_id then
|
|
self:UpdateView()
|
|
end
|
|
end
|
|
self:BindEvent(RankModel:getInstance(), RankModel.UPDATE_WARSOUL_INFO, OnUpdateWarSoulInfo)
|
|
end
|
|
|
|
function RankWarSoulView:UpdateView( )
|
|
-- local warSoul_data = self.model:GetWarSoulList(self.data.role_id)
|
|
|
|
for k,v in pairs(self.warSoul_item_list) do
|
|
v:SetVisible(false)
|
|
end
|
|
for i=1,7 do
|
|
local vo = self.model:GetWarSoulDataByCell(self.data.role_id, i)
|
|
local item = self.warSoul_item_list[i]
|
|
if not item then
|
|
item = RankWarSoulItem.New(self.warSoul_conta)
|
|
self.warSoul_item_list[i] = item
|
|
end
|
|
item:SetVisible(true)
|
|
item:SetData(vo,i)
|
|
item:SetAnchoredPosition(Config.ConfigRank.WarSoulItemPos[i].x, Config.ConfigRank.WarSoulItemPos[i].y)
|
|
end
|
|
|
|
end
|
|
|
|
function RankWarSoulView:SetData( data )
|
|
self.data = data
|
|
if self.is_loaded then
|
|
self.need_refreshData = false
|
|
if self.show_role_id ~= self.data.role_id then
|
|
self.show_role_id = self.data.role_id
|
|
self.model:Fire(RankModel.REQUEST_CCMD_EVENT,22112,self.show_role_id)
|
|
-- RankController.Instance:TestHandle22112(self.show_role_id)
|
|
end
|
|
else
|
|
self.need_refreshData = true
|
|
end
|
|
end
|
|
|
|
function RankWarSoulView:__delete( )
|
|
for i, v in ipairs(self.warSoul_item_list) do
|
|
v:DeleteMe()
|
|
end
|
|
self.warSoul_item_list = {}
|
|
end
|