源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

153 lines
3.8 KiB

GetPicTips = GetPicTips or BaseClass(BaseView)
local GetPicTips = GetPicTips
function GetPicTips:__init()
self.base_file = "common"
self.layout_file = "GetGoodsTips"
self.layer_name = "Activity"
self.open_wnd_anim = 0
self.use_background = true
self.click_bg_toClose = true
self.is_set_zdepth = true
self.item_list = {}
self.load_callback = function ()
self:LoadSuccess()
self:SetPosition()
end
self.open_callback = function ()
self:OpenView()
end
self.close_callback = function ()
end
self.destroy_callback = function ()
self:Remove()
end
end
function GetPicTips:LoadSuccess()
self.layout = self:GetChild("layout")
self.bg = self:GetChild("layout/Window2")
self.closeBtn = self:GetChild("layout/Window2/windowCloseBtn").gameObject
self.name = self:GetChild("layout/name"):GetComponent("Text")
self.content_parent = self:GetChild("layout/itemScrollView/Viewport/Content")
self.icon_tra = self:GetChild("layout/award")
self.icon_go = UiFactory.createChild(self.icon_tra,UIType.Image)
self.icon_img = self.icon_go.transform:GetComponent("Image")
self.icon_item = AwardItem.New(self:GetChild("layout/award"))
self:InitEvent()
end
function GetPicTips:InitEvent()
local function onBtnClickHandler(target)
if target == self.closeBtn then
self:Close()
end
end
AddClickEvent(self.closeBtn, onBtnClickHandler, 1)
end
function GetPicTips:SetPosition()
if self.pos_x and self.pos_y then
local layout_width = self.bg.sizeDelta.x
local layout_height = self.bg.sizeDelta.y
local x,y = ScreenToViewportPoint(self.pos_x,self.pos_y)
x = x - 300
y = y - 100
if x < layout_width - 50 then
x = layout_width - 50
end
if x + layout_width > ScreenWidth then
x = ScreenWidth - layout_width - 80
end
if y < layout_height - 200 then
y = layout_height - 200
end
self.layout.anchoredPosition = Vector2(x,y)
end
end
function GetPicTips:Open(pic_id, x, y)
self.pic_id = pic_id
self.pos_x = x
self.pos_y = y
BaseView.Open(self)
end
--加载可添加的item
function GetPicTips:OpenView()
self.icon_item:SetGoodsIcon(24030002,true)
self.icon_item:SetBgShow(0)
--lua_resM:setOutsideImageSprite(self,self.icon_img,GameResPath.GetGoodsIcon(24030002),true)
for i, v in ipairs(self.item_list) do
v:SetVisible(false)
end
local function callback()
self:Close()
end
local config = Config.Pic[self.pic_id]
if config then
self.name.text = "<color="..ColorUtil:GetColor(0)..">"..config.name.."</color>"
if config.get_way then
local list_1, list_2 = {}, {}
local getway = ErlangParser:GetInstance():Parse(config.get_way)
for i, v in ipairs(getway) do
local main = tonumber(v[1])
local sub = tonumber(v[2])
print(main,sub)
if main == 132 then
table.insert(list_1, v)
elseif main and sub then
local cfg = OpenFun.GetFunCfg(main, sub)
if cfg then
if RoleManager.Instance.mainRoleInfo.level < cfg.openLv then
table.insert(list_2, v)
else
table.insert(list_1, v)
end
else
print("=================== can't find config, fun id is ", main, sub)
end
end
end
for i, v in ipairs(list_1) do
self.item_list[i] = self.item_list[i] or GetPicItem.New(self.content_parent)
self.item_list[i]:SetVisible(true)
self.item_list[i]:SetData(v, self.pic_id, callback)
end
local count = #list_1
for i, v in ipairs(list_2) do
self.item_list[count + i] = self.item_list[count + i] or GetPicItem.New(self.content_parent)
self.item_list[count + i]:SetVisible(true)
self.item_list[count + i]:SetData(v, self.pic_id, callback)
end
end
end
end
function GetPicTips:Remove()
for i, v in ipairs(self.item_list) do
v:DeleteMe()
v = nil
end
self.item_list = {}
if self.icon_item then
self.icon_item:DeleteMe()
self.icon_item = nil
end
if self.icon_go then
destroy(self.icon_go,true)
end
end