lua-for-vscode icon indicating copy to clipboard operation
lua-for-vscode copied to clipboard

查看符号列表时发现少了一些函数

Open liuhaopen opened this issue 7 years ago • 1 comments

查看符号列表时发现少了不少函数,先是显示这个错误: image 重启之后也是一样的。

下面是我那个文件的所有代码: `--[[

  • 任务奖励物品展示
  • @author Administrator

]] AwardItem = AwardItem or BaseClass()

--[[@ 功能: 创建 参数: parent_wnd 父容器 ]] function AwardItem:__init(parent_wnd, showTips) self.root_wnd = parent_wnd:CreateChildNoName(UIType.Box, "") self.root_wnd:SetInt(WidgetProperty.Align, Align.Stretch) self.root_wnd:SetVector2(WidgetProperty.Size, Game.Vector2(120, 120)) self.typeId = 0 self.good = nil self.nameStr="" self.gray = false if showTips == nil then showTips = true end self.showTips = showTips

self.bg_visible=true

--背景
self.imageboxbg = self.root_wnd:CreateChildNoName(UIType.ImageBox, "ImageBox1")
self.imageboxbg:SetInt(WidgetProperty.Align, Align.Stretch)
self.imageboxbg:SetBool(ImageBoxProperty.AutoSize,false)
self.imageboxbg:SetString(ImageBoxProperty.Source, "comp:xx_itemBg")

-- 物品名字
self.defaultText = self.root_wnd:CreateChildNoName(UIType.Label, "Label1")
self.defaultText:SetVector2(WidgetProperty.Position, Game.Vector2(5,5))
self.defaultText:SetVector2(WidgetProperty.Size, Game.Vector2(70,70))
self.defaultText:SetInt(TextBoxProperty.TextAlign, Align.Center)
self.defaultText:SetBool(WidgetProperty.NeedMouse, false)
self.defaultText:SetBool(TextBoxProperty.WordWrap, true)
self.textImage = self.root_wnd:CreateChildNoName(UIType.ImageBox, "ImageBox")
self.textImage:SetVector2(WidgetProperty.Position,Game.Vector2(7,7))
--装备分类
self.typeIcon = self.root_wnd:CreateChildNoName(UIType.ImageBox, "ImageBox")
self.typeIcon:SetVector2(WidgetProperty.Position,Game.Vector2(0,0))
self.typeIcon:SetBool(ImageBoxProperty.AutoSize,false)
--物品图标
self.goodIcon = self.root_wnd:CreateChildNoName(UIType.ImageBox, "ImageBox")
self.goodIcon:SetVector2(WidgetProperty.Position, Game.Vector2(10, 10))
self.goodIcon:SetInt(WidgetProperty.Align, Align.Stretch)
self.goodIcon:SetBool(ImageBoxProperty.AutoSize, false)
self.goodIcon:SetVector2(WidgetProperty.Size, Game.Vector2(100, 100))
--部件类型图标
self.subtypeIcon = self.root_wnd:CreateChildNoName(UIType.ImageBox, "ImageBox")
self.subtypeIcon:SetVector2(WidgetProperty.Position, Game.Vector2(10, 10))
self.subtypeIcon:SetInt(WidgetProperty.Align, Align.Stretch)
self.subtypeIcon:SetBool(ImageBoxProperty.AutoSize, false)
self.subtypeIcon:SetVector2(WidgetProperty.Size, Game.Vector2(100, 100))
self.subtypeIcon:SetBool(ImageBoxProperty.ShowDefaultRes, false)
--部件级别图标
self.goodsLvIcon = self.root_wnd:CreateChildNoName(UIType.ImageBox, "ImageBox")
self.goodsLvIcon:SetVector2(WidgetProperty.Position, Game.Vector2(10, 10))
self.goodsLvIcon:SetInt(WidgetProperty.Align, Align.Stretch)
self.goodsLvIcon:SetBool(ImageBoxProperty.AutoSize, false)
self.goodsLvIcon:SetVector2(WidgetProperty.Size, Game.Vector2(100, 100))
self.goodsLvIcon:SetBool(ImageBoxProperty.ShowDefaultRes, false)
--选择发光
self.lightBg = self.root_wnd:CreateChildNoName(UIType.ImageBox, "ImageBox")
self.lightBg:SetString(ImageBoxProperty.Source, "comp:xx_blueRect3")
self.lightBg:SetVector2(WidgetProperty.Size, Game.Vector2(120, 120))
self.lightBg:SetBool(ImageBoxProperty.AutoSize, false)
self.lightBg:SetBool(WidgetProperty.Visible, false)

-- --选中框
-- self.selectedBg=self.root_wnd:CreateChildNoName(UIType.ImageBox,"ImageBox")
-- self.selectedBg:SetString(ImageBoxProperty.Source,"comp:xx_blueRect")
-- self.selectedBg:SetVector2(WidgetProperty.Size, Game.Vector2(80, 80))
-- self.selectedBg:SetVectorValue(WidgetProperty.Position, -3,-3)
-- self.selectedBg:SetBool(ImageBoxProperty.AutoSize, false)
-- self.selectedBg:SetBool(WidgetProperty.Visible, false)

--绑定图标
-- self.imglock = self.root_wnd:CreateChildNoName(UIType.ImageBox, "ImageBox1")
-- self.imglock:SetString(ImageBoxProperty.Source, "comp:lock")
-- self.imglock:SetVector2(WidgetProperty.Position, Game.Vector2(8+5, 90-5))
-- self.imglock:SetBool(WidgetProperty.Visible, false)

--个数或强化数
self.numtxt = self.root_wnd:CreateChildNoName(UIType.Label, "Label1")
self.numtxt:SetVectorL(WidgetProperty.Size, 20)
self.numtxt:SetInt(TextBoxProperty.TextHorzAlign, Align.Right)
self.numtxt:SetBool(WidgetProperty.NeedMouse, false)
self.numtxt:SetBool(TextBoxProperty.TextStroke, true)
-- 物品名字
self.txtName = self.root_wnd:CreateChildNoName(UIType.Label, "Label1")
self.txtName:SetVector2(WidgetProperty.Position, Game.Vector2(-20,80))
self.txtName:SetVector2(WidgetProperty.Size, Game.Vector2(120,32))
self.txtName:SetInt(TextBoxProperty.TextAlign, Align.Center)
self.txtName:SetBool(WidgetProperty.Visible, false)
self.txtName:SetBool(WidgetProperty.NeedMouse, false)

--自助礼包选择标签
self.buffetBg = self.root_wnd:CreateChildNoName(UIType.ImageBox, "")
self.buffetBg:SetBool(ImageBoxProperty.AutoSize, false)
self.buffetBg:SetBool(ImageBoxProperty.ShowDefaultRes, false)

self.tagBg = self.root_wnd:CreateChildNoName(UIType.ImageBox, "")
self.tagBg:SetBool(ImageBoxProperty.AutoSize, false)
self.tagBg:SetBool(ImageBoxProperty.ShowDefaultRes, false)

self.star_list = {} end

function AwardItem:__delete() if self.root_wnd ~= nil then self.root_wnd:DeleteMe() self.root_wnd = nil end end

function AwardItem:Load() end

function AwardItem:GetRootWnd() return self.root_wnd end

--num:1-9, gold_coin:1铜币,2元宝 function AwardItem:SetGoldCoin(num, gold_coin) if num >= 10 or num < 1 then assert(false, "invalid num:" .. tostring(num)) end self:clearData() local fmt, str = "luckyZodiac:luckyZodiac_%s_%d0", "coin" if gold_coin == 2 then str = "gold" end self.goodIcon:SetString(ImageBoxProperty.Source, string.format(fmt, str, math.floor(num))) self.goodIcon:SetBool(WidgetProperty.Visible, true) self.goodIcon:SetString(WidgetProperty.ParticleSystem, "UI_shangdian") end

function AwardItem:SetRebate(ratio) if nil == ratio then if self.rebateNode then self.imageboxbg:SetString(ImageBoxProperty.Source, "comp:xx_itemBg") self.rebateNode:DeleteMe() self.rebateNode = nil end return end self:clearData()

if nil == self.rebateNode then
	self.imageboxbg:SetString(ImageBoxProperty.Source, "comp:xx_equipBg4")
	self.rebateNode = self.root_wnd:CreateChildNoName(UIType.ImageBox, "ImageBox")
	self.rebateNode:SetBool(ImageBoxProperty.AutoSize, true)
	self.rebateNode:SetString(ImageBoxProperty.Source, "xx_lucky_turntable:luc_txt_rebate")
	local root_size = self.root_wnd:GetVector2(WidgetProperty.Size)
	local pos = Game.Vector2((root_size.x - 55) / 2, (root_size.y - 60) / 2)
	self.rebateNode:SetVector2(WidgetProperty.Position, pos)
	self.rebateNode:SetString(WidgetProperty.ParticleSystem, "UI_shangdian")

	self.rebateIcon = self.rebateNode:CreateChildNoName(UIType.ImageBox, "ImageBox")
	self.rebateIcon:SetBool(ImageBoxProperty.AutoSize, true)
	self.rebateIcon:SetString(ImageBoxProperty.Source, "xx_lucky_turntable:luc_txt_present")

	self.rebateNum = self.rebateIcon:CreateChildNoName(UIType.NumberCell, "NumberCell17")
	self.rebateNum:SetInt(TextBoxProperty.TextAlign, Align.Right)
	self.rebateNum:SetVectorValue(WidgetProperty.Position, -12, 8)

	-- self:ScaleSprite(self.rebateNode, Game.Vector2(55, 30), pos, root_size.x / 90)
end
self.rebateNum:SetString(TextBoxProperty.Label, ratio)
local num_size = self.rebateNum:GetVector2(TextBoxProperty.TextSize)
local pos = Game.Vector2((55 - (num_size.x + 30)) / 2 + num_size.x, 35)
self.rebateIcon:SetVector2(WidgetProperty.Position, pos)
self.rebateNode:SetBool(WidgetProperty.Visible, true)

end

function AwardItem:ScaleSprite(sprite, size, pos, scale) local newSize = Game.Vector2(size.x * scale, size.y * scale) sprite:SetBool(ImageBoxProperty.AutoSize, false) sprite:SetVector2(WidgetProperty.Size, newSize) local new_pos = Game.Vector2((size.x - newSize.x) / 2 + pos.x, (size.y - newSize.y) / 2 + pos.y) sprite:SetVector2(WidgetProperty.Position, new_pos) return newSize, size end

function AwardItem:clearData() -- self.imglock:SetBool(WidgetProperty.Visible, false) self.numtxt:SetString(TextBoxProperty.Label, tostring("")) self.txtName:SetString(TextBoxProperty.Label, tostring("")) self.typeIcon:SetString(ImageBoxProperty.Source, "") self.typeIcon:SetBool(WidgetProperty.Visible,false) self.typeIcon:SetString(WidgetProperty.ParticleSystem, "") self.goodIcon:SetString(ImageBoxProperty.Source, "") self.goodIcon:SetBool(WidgetProperty.Visible,false) self.goodIcon:SetString(WidgetProperty.ParticleSystem, "") self.subtypeIcon:SetString(ImageBoxProperty.Source, "") self.goodsLvIcon:SetString(ImageBoxProperty.Source, "") self.typeId = 0 self.gray = false self:removeToolTip() if self.styleIcon ~= nil then self.styleIcon:SetBool(WidgetProperty.Visible, false) end self:clearUpstage() self:clearTalismanEquipTag() self:ClearBuffetTag() end

function AwardItem:setGray(value) if self.goodIcon then self.goodIcon:SetBool(WidgetProperty.Gray,value) self.subtypeIcon:SetBool(WidgetProperty.Gray,value) self.goodsLvIcon:SetBool(WidgetProperty.Gray,value) end end

function AwardItem:setVisible( flag ) self.root_wnd:SetBool(WidgetProperty.Visible, flag) end

function AwardItem:getTypeId() return self.typeId end

function AwardItem:showName(b) self.txtName:SetBool(WidgetProperty.Visible, b) end --[[@ 功能: 显示物品 参数: typeId 物品类型ID,必要 count 数量,小于2时不显示,默认0 playEffect 设置nil就行了 info 礼包数据参数 bLock 是否绑定,默认false show_type nil 0 默认,1不需要显示等级和类型小图标 ]] function AwardItem:setData(typeId,count,playEffect,info,bLock,color,show_type, step_num) self:clearTalismanEquipTag()

local id = tonumber(typeId)
typeId = tonumber(typeId)
if typeId==2 or typeId==611103 then
	--经验和铜钱现在没有绑定的
	bLock=false
end
-- print("~~~~~~~~~~AwardItem:setData",id,count)
show_type= show_type or 0
self.typeId = id
playEffect = playEffect or false
info = info or ""
bLock = bLock or false
self.nameStr=""
local career
-- if id==532012 then --烤翅礼盒
-- 	career=RoleManager.Instance.mainRoleInfo.career
-- 	if career==1 then
-- 		id=106704
-- 	elseif career==2 then
-- 		id=106904
-- 	elseif career==3 then
-- 		id=106804
-- 	end
-- elseif id==532011 then --国宝时装礼盒
-- 	career=RoleManager.Instance.mainRoleInfo.career
-- 	if career==1 then
-- 		id=106107
-- 	elseif career==2 then
-- 		id=106307
-- 	elseif career==3 then
-- 		id=106207
-- 	end
-- end
local isLock = false
if info ==  "silver" then
	-- isLock = true;
	id = 611102;--元宝
	self.nameStr="礼券"
elseif info ==  "gold" then
	id = 611104;--元宝
	self.nameStr="元宝"
elseif info ==  "bcoin" then
	isLock = true;
	id = 611103;--绑定铜钱
	self.nameStr="铜币"
elseif info ==  "coin" then
	id = 611103;--铜钱
	self.nameStr="铜币"
end
if id==611101 or id==611103 then
	id=611103
	self.nameStr="铜币"
end
-- if bLock then
-- 	isLock = true
-- end
-- self.imglock:SetBool(WidgetProperty.Visible, isLock)

local gvo=GoodsManager.Instance:getGoodsBasicByTypeId(id)
if gvo==nil then
	print ("no id:", id)
	return
end

self.good = gvo
local goodColor = color or gvo.color
if id ~= 611102 and id ~= 611102 and gvo ~= nil then
	local colorStr = ColorUtil:getGoodColor(goodColor)
	self.nameStr = "<font color= '" .. colorStr .. "'>".. gvo.goods_name.."</font>";
end
-- print(id,gvo.goods_icon,"gvo等于nilgvo等于nilgvo等于nilgvo等于nilgvo等于nilgvo等于nil")
self.txtName:SetString(TextBoxProperty.Label, self.nameStr)
-- if self.typeId == 535351 then  --梦曦武器
-- 	self.goodIcon:SetString(ImageBoxProperty.Source, GameRes.PathTool.IconGoodsPic(700201))
-- elseif self.typeId == 535352 then  --梦曦衣服
-- 	self.goodIcon:SetString(ImageBoxProperty.Source, GameRes.PathTool.IconGoodsPic(700204))
-- elseif self.typeId == 535353 then  --琼劲武器
-- 	self.goodIcon:SetString(ImageBoxProperty.Source, GameRes.PathTool.IconGoodsPic(700301))
-- else
	self.goodIcon:SetString(ImageBoxProperty.Source, GameRes.PathTool.IconGoodsPic(gvo.goods_icon))
-- end
self.goodIcon:SetBool(WidgetProperty.Visible,true)
-- 如果是材料,要显示小图标
self.subtypeIcon:SetString(ImageBoxProperty.Source, "")
self.goodsLvIcon:SetString(ImageBoxProperty.Source, "")
if gvo.type==11 and not(show_type==1) then
	-- if gvo.equip_type>0 then
	-- 	self.subtypeIcon:SetString(ImageBoxProperty.Source, GameRes.PathTool.IconPng_Goods(""..gvo.equip_type))
	-- end
	if gvo.level>0 then
		self.goodsLvIcon:SetString(ImageBoxProperty.Source, GameRes.PathTool.IconPng_Goods("lv"..gvo.level))
	end
end
if gvo.type == 65 and not(show_type==1) then
	if gvo.level > 0 then
		if gvo.level == 5 then 
			self.goodsLvIcon:SetString(ImageBoxProperty.Source, GameRes.PathTool.IconPng_Goods("lvs5"))
		else
			self.goodsLvIcon:SetString(ImageBoxProperty.Source, GameRes.PathTool.IconPng_Goods("lv".. gvo.level))
		end
	end
end
if gvo.type==66 and not(show_type==1) then
	if GemstoneModel.Instance ~= nil then
		local gem_config=GemstoneModel.Instance:AgentGemstone_GemstoneModel_GetInfoById(gvo.goods_id)
		if gem_config and gem_config.lv>0 then
			self.goodsLvIcon:SetString(ImageBoxProperty.Source, GameRes.PathTool.IconPng_Goods("lvs".. gem_config.lv))
		end
	end
end
if gvo.type == 67 and not(show_type==1) then  --魂羽物品
	if gvo.level > 0 then
		self.goodsLvIcon:SetString(ImageBoxProperty.Source, GameRes.PathTool.IconPng_Goods("lvs".. gvo.level))
	end
end

self:changeNum(count)
self.typeIcon:SetBool(WidgetProperty.Visible,true)
if self.good.type == 70 then  --器灵装备
		--fist_prefix 代表器灵装备物品的阶数 prefix代表星数
		if self.good.fist_prefix and self.good.prefix then
			self.typeIcon:SetString(ImageBoxProperty.Source, "comp:".. WordManager:getTalismanGoodBgByStepNum(tonumber(self.good.fist_prefix)))
			self.typeIcon:SetString(WidgetProperty.ParticleSystem, WordManager:getTalismanEffectgByStepNum(tonumber(self.good.fist_prefix)))
			self.typeIcon:SetEffectScale(1.2, 2)
			print("该物品的星阶是==:", self.good.fist_prefix, self.good.prefix)
			-- self.good.fist_prefix = 5
			-- self.good.prefix = 10
			self:CreateTalismanEquipTag(1, self.good.fist_prefix, self.good.prefix)
		else
			self.typeIcon:SetString(ImageBoxProperty.Source,"comp:"..WordManager:getGoodBgByColor(3))
			self.typeIcon:SetString(WidgetProperty.ParticleSystem, "")
		end
	self.typeIcon:SetVector2(WidgetProperty.Size,Game.Vector2(self.width_value or 120,self.height or 120))
else
	if step_num and step_num >= 6 then
		self.typeIcon:SetString(ImageBoxProperty.Source,"comp:"..WordManager:getGoodBgByColor(5))
	else
		self.typeIcon:SetString(ImageBoxProperty.Source,"comp:"..WordManager:getGoodBgByColor(goodColor))
	end
	self.typeIcon:SetString(WidgetProperty.ParticleSystem, "")
	self.typeIcon:SetVector2(WidgetProperty.Size,Game.Vector2(self.width_value or 120,self.height or 120))
end
if self.good.type == 53 then --礼包类型
	local have_find, config = TalismanModel:getInstance():AgentTalisman_TalismanModel_findcConfigGift(self.typeId)
	if have_find == true then 
		if config then
			if config.style == 1 then
				self:CreateTalismanEquipTag(2, config.add_value)
			else
				self:CreateTalismanEquipTag(3, nil, config.add_value)
			end
			
		end
	end
end
if self.good.type == 72 then --自助礼包
	self:CreateBuffetTag(typeId)
else
	self:ClearBuffetTag()
end

if self.showTips then
	self:UnBindClickEvent()
	if self.good.type == 10 then --表示是装备
		UIToolTipMgr.Instance:AppendNoGetEquipTips(self.root_wnd, gvo)
	elseif self.good.type == 66 then --表示宝石
		local call=function ( ... )
			if GemstoneModel.Instance ~= nil then
				local pos=self.root_wnd:GetObsolutePosition()
				GemstoneModel.Instance:Fire(GemstoneModel.OPEN_GEMSTONE_TIP,GemstoneModel.TIP_TYPE.OTHER,pos,self.typeId)
			end
		end
		self:BindClickEvent(call)
	elseif self.good.type == 70 then --表示器灵装备
		local show_fun = function ( ... )
			local goodvo = TalismanModel:getInstance():AgentTalisman_TalismanModel_formatGoodsVo(self.typeId, self.good.fist_prefix, self.good.prefix)
			if goodvo and goodvo.id then 
				GlobalEventSystem:Fire(EventName.OPEN_TALISMAN_EQUIP_TIPS, goodvo, false)
			end
		end
		self:BindClickEvent(show_fun)
	-- elseif self.typeId == 535351 or self.typeId == 535352 or self.typeId == 535353 then  --礼包id,使用可分别开出梦曦武器, 梦曦衣服,琼劲武器
	-- 	local show_fun = function ( ... )
	-- 		local goodvo = TalismanModel:getInstance():AgentTalisman_TalismanModel_formatGoodsVo(self.typeId)
	-- 		if goodvo and goodvo.id then 
	-- 			GlobalEventSystem:Fire(EventName.OPEN_TALISMAN_EQUIP_TIPS, goodvo, false)
	-- 		end
	-- 	end
	-- 	self:BindClickEvent(show_fun)
	elseif self.good.type == 72 then --自选礼包
		local show_fun = function ( ... )
			GoodsManager.Instance:Fire(GoodsManager.OPEN_BUFFET_GIFT_VIEW, self.typeId, true)
		end
		self:BindClickEvent(show_fun)
	else
		UIToolTipMgr.Instance:AppendGoodsTips(self.root_wnd, gvo.goods_id, gvo.bind)
	end
end

self:setItemBgVisible(self.bg_visible)

end

function AwardItem:width() return self.width_value or 120 end

-- function AwardItem:GetWidth( ... ) -- return self.width_value or 120 -- end

function AwardItem:setDefaultText(str) self.defaultText:SetString(TextBoxProperty.Label,str) end

function AwardItem:setNameTextSize(val) self.txtName:SetInt(TextBoxProperty.FontSize, tonumber(val)) end

function AwardItem:setPosition(vector) self.root_wnd:SetVector2(WidgetProperty.Position,vector) end function AwardItem:setPositionValue(x,y) self.root_wnd:SetVectorValue(WidgetProperty.Position,x,y) end

function AwardItem:setGray(bool) self.gray = bool self.root_wnd:SetBool(WidgetProperty.Gray,bool) if bool == true then self.numtxt:SetString(TextBoxProperty.ColorStr, ColorUtil:getColorByName(ColorUtil.MyColorType.GRAY)) -- self.numtxt:SetBool(TextBoxProperty.TextStroke, not bool) else self.numtxt:SetString(TextBoxProperty.ColorStr, ColorUtil:getColorByName(ColorUtil.MyColorType.WHITE)) -- self.numtxt:SetBool(TextBoxProperty.TextStroke, not bool) end end

function AwardItem:setAlpha(value) if self.goodIcon then self.goodIcon:SetFloat(WidgetProperty.Alpha,value) end if self.styleIcon then local bool = self.styleIcon:GetBool(WidgetProperty.Visible) if bool == true then self.styleIcon:SetFloat(WidgetProperty.Alpha,value) end end end

function AwardItem:GetAlpha(value) local alpha if self.goodIcon then alpha = self.goodIcon:GetFloat(WidgetProperty.Alpha) end return alpha end

function AwardItem:getGray() return self.gray end

function AwardItem:BindClickEvent(func) if self.root_wnd ~= nil then self:removeToolTip() self:UnBindClickEvent() local tem_func=function ( widget,widget2 ) func(widget,widget2,self) end self.bind_click_event_handler = self.root_wnd:BindWindowEvent(WidgetEvent.MouseButtonClick, tem_func) end end

function AwardItem:UnBindClickEvent() if self.bind_click_event_handler ~= nil then self.root_wnd:UnBindWindowEvent(self.bind_click_event_handler) self.bind_click_event_handler = nil end end

--设置是否选择bool function AwardItem:setSelectedState(bool) self.selectedState = bool self.lightBg:SetBool(WidgetProperty.Visible,bool) end

function AwardItem:removeToolTip() UIToolTipMgr.Instance:ClearTooltipEvent(self.root_wnd) end

function AwardItem:setDefualtTextImg(source) self.textImage:SetString(ImageBoxProperty.Source,source)

end

function AwardItem:SetNumTextVisible(visible) self.numtxt:SetBool(WidgetProperty.Visible, visible) end

function AwardItem:setNum(num) self.numtxt:SetString(TextBoxProperty.Label, num) end

function AwardItem:changeNum(count) self.count = count and tonumber(count) or 0 if self.count > 1 or self.allwaysShowNumber then self:setNum(self.count) self:UpatdeNumtxtPos() else self:setNum("") end end

function AwardItem:UpatdeNumtxtPos() local size = self.numtxt:GetVector2(TextBoxProperty.TextSize) local root_size = self.root_wnd:GetVector2(WidgetProperty.Size) self.numtxt:SetVector2(WidgetProperty.Size, Game.Vector2(root_size.x - 5, 50)) self.numtxt:SetVector2(WidgetProperty.Position, Game.Vector2(0, root_size.y - 55)) self.numtxt:SetInt(TextBoxProperty.TextAlign, bit.bor(Align.Right, Align.Bottom)) if size.x > root_size.x - 20 or size.y < root_size.y / 5 then local scale = (root_size.x - 10) / size.x local font_size = self.numtxt:GetInt(TextBoxProperty.FontSize) self.numtxt:SetInt(TextBoxProperty.FontSize, math.min(font_size * scale, 24)) end end

function AwardItem:SetLockVisible(visible) -- self.imglock:SetBool(WidgetProperty.Visible, visible) end

function AwardItem:AttachEffect(name) self.goodIcon:SetString(WidgetProperty.ParticleSystem, name) end

function AwardItem:SetEffectScale(scale_x, scale_y) self.goodIcon:SetEffectScale(scale_x, scale_x) end

function AwardItem:setItemSize(width,height) if not self.root_wnd then return end

self.width_value=width or 120
self.height=height or 120
local bord = self.width_value * 1/12
--整个父窗
self.root_wnd:SetVector2(WidgetProperty.Size, Game.Vector2(self.width_value, self.height))
--背景
self.imageboxbg:SetVector2(WidgetProperty.Size,Game.Vector2(self.width_value,self.height))
--选中框
self.lightBg:SetVector2(WidgetProperty.Size,Game.Vector2(self.width_value,self.height))

--装备分类
self.typeIcon:SetVector2(WidgetProperty.Size,Game.Vector2(self.width_value,self.height))
--物品图标
self.goodIcon:SetVector2(WidgetProperty.Position, Game.Vector2(bord, bord))
self.goodIcon:SetVector2(WidgetProperty.Size, Game.Vector2(self.width_value-bord*2, self.height-bord*2))
self.subtypeIcon:SetVector2(WidgetProperty.Position, Game.Vector2(bord, bord))
self.subtypeIcon:SetVector2(WidgetProperty.Size, Game.Vector2(self.width_value-bord*2, self.height-bord*2))
self.goodsLvIcon:SetVector2(WidgetProperty.Position, Game.Vector2(bord, bord))
self.goodsLvIcon:SetVector2(WidgetProperty.Size, Game.Vector2(self.width_value-bord*2, self.height-bord*2))
self:UpatdeNumtxtPos()
self:resetTalismanEquipSize(bord)
self:resetBuffetGiftSize(bord)
-- 锁头
-- self.imglock:SetVector2(WidgetProperty.Position, Game.Vector2(8, self.height - bord - 20))

end

function AwardItem:setTxtSize(font_size) self.numtxt:SetInt(TextBoxProperty.FontSize, font_size) end

function AwardItem:setItemBgVisible(b) if b then self.imageboxbg:SetBool(WidgetProperty.Visible,true) self.typeIcon:SetBool(WidgetProperty.Visible,true) else self.imageboxbg:SetBool(WidgetProperty.Visible,false) self.typeIcon:SetBool(WidgetProperty.Visible,false) end self.bg_visible=b end

function AwardItem:setNeedMouse( flag ) self.root_wnd:SetBool(WidgetProperty.NeedMouse, flag) end

function AwardItem:showUpstageNum(num) self:clearUpstage() if num ~= nil then self:EnsureUpstageNum(num) end end

--创建阶数小太阳 function AwardItem:EnsureUpstageNum(num) if self.good == nil or self.good.color ~= 4 or self.good.equip_type == 7 or self.good.equip_type == 8 then return end if self.upstageBg == nil then self.upstageBg = self.root_wnd:CreateChildNoName(UIType.ImageBox, "") end self.upstageBg:SetBool(ImageBoxProperty.AutoSize, true) self.upstageBg:SetVector2(WidgetProperty.Position, Game.Vector2(8, 8)) self.upstageBg:SetString(ImageBoxProperty.Source, "comp_icon:dz_blackbg")

local real = num
if num > 5 then
	real = num - 5
end
local gap = 5 - real
-- local num = 5 - num
for i = 1, 5 do
    local star = self.star_list[i]
    if star == nil then
        star = self.upstageBg:CreateChildNoName(UIType.ImageBox, "")
        self.star_list[i] = star
    end
    star:SetBool(ImageBoxProperty.AutoSize, true)
    if i <= gap then
        star:SetString(ImageBoxProperty.Source, "comp_icon:dz_sun1")
    else
    	if num > 5 then
    		star:SetString(ImageBoxProperty.Source, "comp_icon:dz_sun2")
    	else
        	star:SetString(ImageBoxProperty.Source, "comp_icon:dz_sun")
        end
    end
    star:SetVector2(WidgetProperty.Size,Game.Vector2(20, 21))
    star:SetVector2(WidgetProperty.Position, Game.Vector2(3, (i - 1) * 20 ))
end

end

--清掉进阶小太阳 function AwardItem:clearUpstage() if self.upstageBg then self.upstageBg:DeleteMe() self.upstageBg = nil end for i,v in ipairs(self.star_list) do v:DeleteMe() v = nil end self.star_list = {} end

--没有物品ID时设置默认样式 function AwardItem:SetDefaultStype( ... ) self.typeIcon:SetBool(WidgetProperty.Visible,true) self.typeIcon:SetString(ImageBoxProperty.Source,"comp:"..WordManager:getGoodBgByColor(0)) self.typeIcon:SetVector2(WidgetProperty.Size,Game.Vector2(self.width_value or 120,self.height or 120)) end

--器灵装备显示阶数,星数标签 function AwardItem:CreateTalismanEquipTag(style, step_num, star_num) local source = "" if style == 1 then --显示阶和星 source = GameRes.PathTool.GetTalismanEquipTag(1, step_num, star_num) elseif style == 2 then --只显示阶 source = GameRes.PathTool.GetTalismanEquipTag(2, step_num) elseif style == 3 then --只显示星 source = GameRes.PathTool.GetTalismanEquipTag(3, nil, star_num) end if source and source ~= "" then self.tagBg:SetString(ImageBoxProperty.Source, source) end end

function AwardItem:resetTalismanEquipSize(bord) if self.tagBg then self.tagBg:SetVector2(WidgetProperty.Position, Game.Vector2(bord4, bord/4)) self.tagBg:SetVector2(WidgetProperty.Size, Game.Vector2(self.width_value-bord4, self.height-bord*4)) end end

--清掉进阶小太阳 function AwardItem:clearTalismanEquipTag() if self.tagBg then self.tagBg:SetString(ImageBoxProperty.Source, "") end end

function AwardItem:CreateBuffetTag( id ) local get_num = Config.Selfgift[id].reward_num self.buffetBg:SetString(ImageBoxProperty.Source, "xx_tooltips:to_choose_"..get_num) end

function AwardItem:resetBuffetGiftSize( bord ) self.buffetBg:SetVector2(WidgetProperty.Position, Game.Vector2(bord/3, bord/3)) self.buffetBg:SetVector2(WidgetProperty.Size, Game.Vector2(self.width_value-bord4, self.height-bord4)) end

function AwardItem:ClearBuffetTag( ) if self.buffetBg then self.buffetBg:SetString(ImageBoxProperty.Source, "") end end`

liuhaopen avatar Dec 13 '16 02:12 liuhaopen

local show_fun = function ( ... ) GoodsManager.Instance:Fire(GoodsManager.OPEN_BUFFET_GIFT_VIEW, self.typeId, true) end

目前不支持种函数定义, 下个版本修复一下

xxxg0001 avatar Dec 14 '16 01:12 xxxg0001