InstructionSmallView = InstructionSmallView or BaseClass(BaseView)
|
|
function InstructionSmallView:__init()
|
|
self.base_file = "common"
|
|
self.layout_file = "InstructionSmallView"
|
|
self.layer_name = "Activity"
|
|
self.use_background = true
|
|
self.click_bg_toClose = true
|
|
self.is_set_zdepth = true
|
|
self.background_alpha = 0
|
|
self:AddPreLoadList("common",{"InstructionSmallItem"})
|
|
self.item_list = {}
|
|
self.load_callback = function()
|
|
self:LoadSuccess()
|
|
self:SetData()
|
|
end
|
|
self.close_callback = function ()
|
|
self:Clear()
|
|
end
|
|
end
|
|
|
|
function InstructionSmallView:Clear()
|
|
for i,item in ipairs(self.item_list) do
|
|
item:DeleteMe()
|
|
end
|
|
self.item_list = {}
|
|
end
|
|
|
|
function InstructionSmallView:LoadSuccess()
|
|
self.window = self:GetChild("Window")
|
|
self.scroll_content = self:GetChild("Window/ScrollView/Viewport/Content")
|
|
end
|
|
|
|
function InstructionSmallView:Open(index)
|
|
self.index = index
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function InstructionSmallView:SetData()
|
|
local cfg = Config.ConfigInstruction[self.index]
|
|
if cfg then
|
|
local height = 10
|
|
if cfg.info_list then
|
|
local item = nil
|
|
for i,vo in ipairs(cfg.info_list) do
|
|
item = InstructionSmallItem.New(self.scroll_content)
|
|
table.insert(self.item_list,item)
|
|
item:SetData(vo)
|
|
item:SetPosition(0,-height)
|
|
height = height + item:GetHeight()
|
|
end
|
|
end
|
|
self.scroll_content.sizeDelta = Vector2(self.scroll_content.sizeDelta.x, height)
|
|
height = height + 30
|
|
height = height > 400 and 400 or height
|
|
self.window.sizeDelta = Vector2(self.window.sizeDelta.x, height)
|
|
--self.scroll_content.localPosition = Vector3.zero
|
|
end
|
|
end
|