• 注册
    • 总打赏排行
    • 今日收益排行
  • 小黄人
    小黄人
    如有问题,请发帖交流,私聊我可能看不到。
  • 兵者-设计
    兵者-设计
    他太懒了,什么都没有写
  • bmwz8
    bmwz8
    他太懒了,什么都没有写
  • 雪舞
    雪舞
    他太懒了,什么都没有写
  • 乐疯玩-雨轩(GM手游渠
    乐疯玩-雨轩(GM手游渠
    他太懒了,什么都没有写
  • ╭花落丶惜﹎
    ╭花落丶惜﹎
    他太懒了,什么都没有写
  • Lyn
    Lyn
    他太懒了,什么都没有写
  • tianshi777
    tianshi777
    他太懒了,什么都没有写
  • 平心静气
    平心静气
    他太懒了,什么都没有写
    • 今日签到
    • 累计签到
  • ╭花落丶惜﹎
    ╭花落丶惜﹎
    今天00:18
  • mstscexe
    mstscexe
    今天00:42
  • bmwz8
    bmwz8
    今天03:45
  • tianshi777
    tianshi777
    今天07:27
  • 小胖
    小胖
    今天09:15
  • 小黄人
    小黄人
    今天09:55
  • 小黄人
    小黄人
    如有问题,请发帖交流,私聊我可能看不到。
  • tianshi777
  • 冰龙
    冰龙
    冰龙
  • 隔壁老王
  • zxc583700871
  • mstscexe
  • 挽弦暮笙
  • zhangxhc
  • xiang262
  • zhyy7112
  • 查看作者
  • 添加装备描述功能

    白日门脚本添加装备描述功能 白日门脚本添加装备描述功能 白日门脚本添加装备描述功能 白日门脚本添加装备描述功能 白日门脚本添加装备描述功能

    下面是简单代码

    if itemDef.mDesp ~= "null" then
        if str == "" then
           str =  "<font color=#ff00ff>"..itemDef.mDesp.."</font>"

    -- str = itemDef.mDesp
    else
    str = str.."
    "..itemDef.mDesp..""
    -- str = str.."
    "..itemDef.mDesp
    end
    end

    完整UItips

    UITips = {}
    
    local title2Name = {
    	["更多"] = "btn_tips_more", 
    	["使用"] = "btn_tips_use", 
    	["装备"] = "btn_tips_dress", 
    	["卸下"] = "btn_tips_dress", 
    	["强化"] = "btn_tips_upgrade",
    	["精炼"] = "btn_tips_refine", 
    	["存放"] = "btn_tips_store", 
    	["取出"] = "btn_tips_take", 
    	["出售"] = "btn_tips_sell", 
    	["丢弃"] = "btn_tips_drop", 
    	["交易"] = "btn_tips_trade", 
    	["合成"] = "btn_tips_compound",
    	["拆分"] = "btn_tips_split", 
    	["发送聊天"] = "btn_tips_send_chat",
    	["寄售"] = "btn_tips_consign",
    	["摧毁"] = "btn_tips_destory"
    }
    
    -- 特殊处理,绑定物品丢弃时候提示丢弃即是摧毁
    
    local USE_TYPE = {
    	NULL = 0,
    	USEITEM = 1,
    	DRESSEQUIP = 2,
    	UNDRESSEQUIP = 3,
    	DEPOTIN = 4, --存入仓库
    	DEPOTOUT = 5, --仓库取出
    	TRADEIN = 6, --交易
    	-- DRESSGEM = 7, --镶嵌宝石
    	-- UNDRESSGEM = 8, -- 卸下宝石
    	TREASURE=7,
    	CUSTOM = 10,
    }
    
    -- Const.TIPS_TYPE = {
    -- 	GENERAL = 1,
    -- 	BAG = 2,
    -- 	DEPOT = 3,
    -- 	TRADE = 4,
    -- 	CONSIGN = 5,
    -- 	GEM = 6,
    -- 	UPGRADE = 7,
    -- 	REFINE = 8,
    -- 	GUILD = 9,
    ---TREASURE=10
    -- }
    
    -- tips分类依据:
    -- 1 类别枚举;1(通用),2(背包),3(仓库),4(交易),5(寄售),6(宝石),7(强化),8(精炼),9(帮会)
    -- 2,pos位枚举;1(身上),2(背包),,3(仓库), 4(寻宝), 5(行会仓库), 6(自定义)
    -- 3,物品类型枚举;0(所有物品),1(装备),2(药品),3(其他),4(帮会帮主副帮主看的tips)
    -- tag = enmuType * 100 + enumPos * 10 + enmuItemType
    local TIPS_TAG = {
    	GENERAL_DRESSED_EQUIP = 111,
    
    	BAG_BAG_EQUIP = 221,
    	BAG_BAG_DRUG = 222,
    	BAG_BAG_OTHER = 223,
    
    
    	DEPOT_BAG_EQUIP = 321, -- 存放
    	DEPOT_BAG_DRUG = 322, -- 存放, 更多(拆分)
    	DEPOT_BAG_OTHER = 323, -- 存放, 更多(拆分)
    
    	DEPOT_DEPOT_EQUIP = 331, -- 取出
    	DEPOT_DEPOT_DRUG = 332, -- 取出, 更多(拆分)
    	DEPOT_DEPOT_OTHER = 333, -- 取出, 更多(拆分)
    
    	TRADE_BAG_EQUIP = 421, 
    	TRADE_BAG_DRUG = 422,
    	TRADE_BAG_OTHER = 423,
    
    	CONSIGN_BAG_ALL=520,
    
    	GEM_BAG_OTHER = 623,
    
    	
    
    	UPGRADE_BAG_EQUIP = 721,
    
    	HUISHOU_GET_OUT=733,--回收取出
    
    	GEM_GET_OUT=743,--宝石取下
    
    	UPGRADE_IN_EQUIP = 761,
    
    	HUISHOU_GET_IN=763,--回收投入
    
    	GUILD_BAG_ALL = 920,
    	GUILD_GUILD_ALL = 950,
    	GUILD_GUILD_ALL_ADMIN = 954,
    
    	TREASURE_BAG_ALL=1040,
    	
    	-- CONSIGN = 501,
    	-- GEM = 601,
    	-- UPGRADE = 701,
    	-- REFINE = 801,
    }
    
    local buttonsConfig = {
    	[TIPS_TAG.BAG_BAG_EQUIP] = {
    		useTitle = "装备", useType = USE_TYPE.DRESSEQUIP,  more = {"强化", "出售","丢弃","寄售",}
    	},
    	[TIPS_TAG.BAG_BAG_DRUG] = {
    		useTitle = "使用", useType = USE_TYPE.USEITEM, more = {"出售","丢弃","拆分","寄售",}
    	},
    	[TIPS_TAG.BAG_BAG_OTHER] = {
    		useTitle = "使用", useType = USE_TYPE.USEITEM, more = {"出售","丢弃","拆分"}
    	},
    	[TIPS_TAG.GENERAL_DRESSED_EQUIP] = {
    		useTitle = "卸下", useType = USE_TYPE.UNDRESSEQUIP,
    	},
    	[TIPS_TAG.DEPOT_BAG_EQUIP] = {
    		useTitle = "存放", useType = USE_TYPE.DEPOTIN, more = {"强化", "出售",	"丢弃",}
    	},
    	[TIPS_TAG.DEPOT_BAG_DRUG] = {
    		useTitle = "存放", useType = USE_TYPE.DEPOTIN, more = {"出售", "丢弃", "拆分"}
    	},
    	[TIPS_TAG.DEPOT_BAG_OTHER] = {
    		useTitle = "存放", useType = USE_TYPE.DEPOTIN, more = {"出售", "丢弃", "拆分"}
    	},
    	[TIPS_TAG.DEPOT_DEPOT_EQUIP] = {
    		useTitle = "取出", useType = USE_TYPE.DEPOTOUT,
    	},
    	[TIPS_TAG.DEPOT_DEPOT_DRUG] = {
    		useTitle = "取出", useType = USE_TYPE.DEPOTOUT,
    	},
    	[TIPS_TAG.DEPOT_DEPOT_OTHER] = {
    		useTitle = "取出", useType = USE_TYPE.DEPOTOUT,
    	},
    	[TIPS_TAG.TRADE_BAG_EQUIP] = {
    		useTitle = "放入", useType = USE_TYPE.CUSTOM,
    	},
    	[TIPS_TAG.TRADE_BAG_DRUG] = {
    		useTitle = "放入", useType = USE_TYPE.CUSTOM, --more = {"拆分"}
    	},
    	[TIPS_TAG.TRADE_BAG_OTHER] = {
    		useTitle = "放入", useType = USE_TYPE.CUSTOM, --more = {"拆分"}
    	},
    	[TIPS_TAG.GEM_BAG_OTHER] = {
    		useTitle = "镶嵌", useType = USE_TYPE.CUSTOM,
    	},
    	[TIPS_TAG.UPGRADE_BAG_EQUIP] = {
    		useTitle = "放入", useType = USE_TYPE.CUSTOM
    	},
    	[TIPS_TAG.TREASURE_BAG_ALL] = {
    		useTitle = "取出", useType = USE_TYPE.TREASURE
    	},
    
    	[TIPS_TAG.CONSIGN_BAG_ALL] = {
    		useTitle = "寄售", useType = USE_TYPE.CUSTOM
    	},
    	[TIPS_TAG.GUILD_BAG_ALL] = {
    		useTitle = "投入", useType = USE_TYPE.CUSTOM
    	},
    	[TIPS_TAG.GUILD_GUILD_ALL] = {
    		useTitle = "兑换", useType = USE_TYPE.CUSTOM
    	},
    	[TIPS_TAG.GUILD_GUILD_ALL_ADMIN] = {
    		useTitle = "兑换", useType = USE_TYPE.CUSTOM, more = {"摧毁"}
    	},
    	[TIPS_TAG.UPGRADE_IN_EQUIP] = {
    		useTitle = "取出", useType = USE_TYPE.CUSTOM
    	},
    	[TIPS_TAG.HUISHOU_GET_OUT] = {
    		useTitle = "取出", useType = USE_TYPE.CUSTOM
    	},
    	[TIPS_TAG.HUISHOU_GET_IN] = {
    		useTitle = "投入", useType = USE_TYPE.CUSTOM
    	},
    	[TIPS_TAG.GEM_GET_OUT] = {
    		useTitle = "取下", useType = USE_TYPE.CUSTOM
    	},
    
    }
    
    local function getTipsTag(xmlTips)
    	
    	local itemPos = xmlTips.itemPos
    	local itemDef = xmlTips.itemDef
    	local typeId = xmlTips.typeId
    	local enmuType = xmlTips.tipsType or 0
    	local enmuPos = xmlTips.enmuPos or 0
    	local enmuItemType = 0
    
    	if xmlTips.enmuItemType then
    		enmuItemType = xmlTips.enmuItemType
    	else
    		if game.IsEquipment(typeId) then
    			enmuItemType = 1
    		elseif game.IsDrug(typeId) then
    			enmuItemType = 2
    		else
    			enmuItemType = 3
    		end
    	end
    
    	if enmuPos == 0 then
    		if game.IsPosInAvatar(itemPos) then
    			enmuPos = 1
    		elseif game.IsPosInBag(itemPos) then
    			enmuPos = 2
    		elseif game.IsPosInDepot(itemPos) then
    			enmuPos = 3
    		elseif game.IsPosInLottoryDepot(itemPos) then -- 寻宝仓库强制为0
    			enmuPos = 4
    		end
    	end
    
    	if enmuType==5 then 
    		enmuPos = 2
    		enmuItemType = 0
    	end
    	-- if enmuType == 9 then
    	-- 	enmuItemType = 0
    	-- end
    	if enmuType == 4 then
    		if game.IsEquipment(typeId) then
    			enmuItemType = 1
    		elseif game.IsDrug(typeId) then
    			enmuItemType = 2
    		else
    			enmuItemType = 3
    		end
    	end
    
    	return enmuType * 100 + enmuPos * 10 + enmuItemType
    end
    
    local function DropBindItem(itemPos, typeId)
    	local mParam = {
    		name = Notify.EVENT_SHOW_TIPS, str = "confirm", lblConfirm = "绑定物品丢弃即摧毁(确认丢弃)",
    		btnConfirm = "确定", btnCancel = "取消",
    		confirmCallBack = function ()
    			NetClient:DestoryItem(itemPos, typeId)
    		end
    	}
    	NetClient:dispatchEvent(mParam)
    end
    
    local itemsChangeTab = {
    	["depot"]	= {name = "仓库", begin = Const.ITEM_DEPOT_BEGIN,	size = Const.ITEM_DEPOT_SIZE, add = "mDepotSlotAdd"},
    	["bag"]		= {name = "背包", begin = Const.ITEM_BAG_BEGIN,	size = Const.ITEM_BAG_SIZE, add = "mBagSlotAdd"},
    	["treasure"]= {name = "背包", begin = Const.ITEM_BAG_BEGIN,	size = Const.ITEM_BAG_SIZE, add = "mBagSlotAdd"},
    }
    
    -- 存入和取出
    local function changeItemPosTo(itemPos, slot)
    	-- print("changeItemPosTo", itemPos, slot)
    	local add = 0;
    	local conf = itemsChangeTab[slot]
    	if conf then
    		-- print("has conf")
    		local num = conf.size + NetClient[conf.add]
    		for i = 0, num - 1 do
    			if not NetClient:getNetItem(i + conf.begin) then -- 表示空位
    				if NetClient:getNetItem(itemPos) then
    					NetClient:ItemPositionExchange(itemPos, i + conf.begin)
    					return
    				end
    			end
    		end
    		NetClient:alertLocalMsg(conf.name.."空间不足")
    	end
    end
    
    -- tips列表按钮的回调函数
    local function pushTipsButtons(sender)
    	local btnName = sender:getName()
    	local xmlTips = sender.xmlTips
    	local itemPos = xmlTips.itemPos
    	local typeId = xmlTips.typeId
    	local netItem = xmlTips.netItem
    	local itemDef = xmlTips.itemDef
    
    	-- print("pushTipsButtons", btnName, xmlTips, itemPos, typeId)
    	if btnName == "btn_tips_split" then
    		NetClient:SplitItem(itemPos, typeId, 1)
    	elseif btnName == "btn_tips_upgrade" then --强化
    		NetClient:dispatchEvent({name = Notify.EVENT_OPEN_PANEL,str="main_forge"})
    	elseif btnName == "btn_tips_refine" then --精炼
    
    	elseif btnName == "btn_tips_sell" then
    		local num = game.checkBatchSell(typeId) and netItem.mNumber or 1
    		NetClient:NPCSell(100, itemPos, typeId, num, 200)
    	elseif btnName == "btn_tips_drop" then
    		if bit.band(netItem.mItemFlags, Const.ITEM_FLAG_BIND) > 0 then
    			DropBindItem(itemPos, typeId)
    		else
    			NetClient:DropItem(itemPos, typeId, 1)
    		end
    	elseif btnName == "btn_tips_destory" then
    		if xmlTips.destoryCallFunc then
    			xmlTips.destoryCallFunc()
    		else
    			NetClient:DestoryItem(itemPos, typeId)
    		end
    
    		-- NetClient:dispatchEvent({name = Notify.EVENT_DESTORY_ITEM, })
    	elseif btnName == "btn_tips_trade" then
    
    	elseif btnName == "btn_tips_store" then
    		changeItemPosTo(itemPos, "depot")
    	elseif btnName == "btn_tips_take" then
    		changeItemPosTo(itemPos, "bag")
    	elseif btnName == "btn_tips_merge" then
    
    	elseif btnName == "btn_tips_compound" then
    
    	elseif btnName == "btn_tips_send_chat" then
    		if itemDef and netItem then
    			local msg = "<item src=\""..itemDef.mName..","..netItem.mLevel..","..netItem.mZLevel.."\"/>"
    			NetClient:sendChatToLastChannel(msg)
    		end
    	elseif btnName == "btn_tips_consign" then
    		NetClient:dispatchEvent({name = Notify.EVENT_OPEN_PANEL,str="main_consign", tab = 2})
    	end
    	NetClient:dispatchEvent({name = Notify.EVENT_HANDLE_TIPS, visible = false})
    end
    
    -- tips使用按钮的回调函数
    local function pushTipsUseButton(sender)
    	local mUseType = sender.useType
    	local xmlTips = sender.xmlTips
    	local itemPos = xmlTips.itemPos
    	local typeId = xmlTips.typeId
    	if mUseType == USE_TYPE.USEITEM then -- 使用,针对背包非装备
    		if game.IsPosInBag(itemPos) then
    			if game.canBatchUse(typeId) then
    				local netItem = xmlTips.netItem
    				local num = netItem.mNumber
    				NetClient:BagUseItem(itemPos, typeId, num)
    			else
    				NetClient:BagUseItem(itemPos, typeId)
    			end
    		end
    	elseif mUseType == USE_TYPE.DRESSEQUIP then
    		if game.IsPosInBag(itemPos) then
    			NetClient:BagUseItem(itemPos, typeId)
    		end
    	elseif mUseType == USE_TYPE.UNDRESSEQUIP then
    		if game.IsPosInAvatar(itemPos) then
    			NetClient:UndressItem(itemPos)
    		end
    	elseif mUseType == USE_TYPE.DEPOTIN then
    		if game.IsPosInBag(itemPos) then
    			changeItemPosTo(itemPos, "depot")
    		end
    	elseif mUseType == USE_TYPE.DEPOTOUT then
    		if game.IsPosInDepot(itemPos) then
    			changeItemPosTo(itemPos, "bag")
    		end
    	elseif mUseType == USE_TYPE.TREASURE then
    		if game.IsPosInLottoryDepot(itemPos) then
    			if NetClient:takeItemFromLottory(itemPos) then 
    				NetClient:takeItemFromLottory(itemPos)
    			else
    				NetClient:alertLocalMsg("背包空间不足")
    			end 	
    			--changeItemPosTo(itemPos, "treasure")
    		end
    	elseif mUseType == USE_TYPE.CUSTOM then
    		if xmlTips.customCallFunc then
    			xmlTips.customCallFunc()
    		end
    
    	end
    	NetClient:dispatchEvent({name = Notify.EVENT_HANDLE_TIPS, visible = false})
    end
    
    -- 控制tips列表按钮显隐
    local function handleButtonsListVisible(sender, visible)
    	local xmlTips = sender.xmlTips
    	sender.showMore = visible
    	local listButtons = xmlTips:getWidgetByName("list_buttons")
    	listButtons:setVisible(visible)
    	sender:getWidgetByName("img_more_flag"):setScaleY(visible and -1 or 1);
    end
    
    -- 初始化tips上通用按钮
    local function initTipsButtons(xmlTips)
    
    	local btnTips = xmlTips:getWidgetByName("btn_tips_more")
    	btnTips.showMore = false
    	UIRedPoint.addUIPoint(btnTips, function (sender)
    		handleButtonsListVisible(sender, not sender.showMore)
    	end)
    
    	local btnTipsUse = xmlTips:getWidgetByName("btn_tips_use")
    	btnTipsUse.xmlTips = xmlTips
    	UIRedPoint.addUIPoint(btnTipsUse, pushTipsUseButton)
    
    	local listButtons = xmlTips:getWidgetByName("list_buttons")
    	listButtons:setItemsMargin(3)
    end
    
    -- tips创建函数
    local function newTips(typeId)
    	local xmlTips
    	if game.IsEquipment(typeId) then
    		xmlTips = UILuaLoader.load("uilayout/EquipTips.uif")
    		xmlTips:getWidgetByName("list_base_attr"):setGravity(ccui.ListViewGravity.left)
    		xmlTips:getWidgetByName("list_upd_attr"):setGravity(ccui.ListViewGravity.left)
    
    		xmlTips:getWidgetByName("lbl_zhuling_pre"):hide()
    		xmlTips:getWidgetByName("img_zhuling_bar_bg"):hide()
    
    		local listBaseAttr = xmlTips:getWidgetByName("list_base_attr")
    		if false then
    			listBaseAttr:setContentSize(listBaseAttr:getContentSize().width, 230)
    			xmlTips:getWidgetByName("lbl_upd_pre"):hide()
    			xmlTips:getWidgetByName("list_upd_attr"):hide()
    			xmlTips:getWidgetByName("img_tips_line2"):hide()
    		else
    			listBaseAttr:setContentSize(listBaseAttr:getContentSize().width, 85)
    			xmlTips:getWidgetByName("lbl_upd_pre"):show()
    			xmlTips:getWidgetByName("list_upd_attr"):show()
    			xmlTips:getWidgetByName("img_tips_line2"):show()
    		end
    	else
    		xmlTips = UILuaLoader.load("uilayout/PropsTips.uif")
    
    		xmlTips:getWidgetByName("list_source"):setGravity(ccui.ListViewGravity.left)
    		xmlTips:getWidgetByName("list_desp"):setGravity(ccui.ListViewGravity.left)
    	end
    	initTipsButtons(xmlTips)
    	return xmlTips
    end
    
    -- tips上的物品图标刷新
    local function updateTipsIcon(xmlTips)
    	local itemDef = xmlTips.itemDef
    	if itemDef then
    		local imgIconFrame = xmlTips:getWidgetByName("img_icon_frame")
    		local filepath = "picicon/"..itemDef.mIconID..".png"
    		-- imgIconFrame.resLoaded = false
    		-- asyncload_callback("picicon/"..itemDef.mIconID..".png", imgIconFrame, function(filepath, texture)
    		-- 	if util.isObjectExist(xmlTips) and xmlTips.typeId then
    				-- if not imgIconFrame.resLoaded then
    					local imgIcon = imgIconFrame:getWidgetByName("img_icon")
    					imgIcon:loadTexture(filepath)
    					local size = imgIcon:getContentSize()
    					local pSize = imgIconFrame:getContentSize()
    					imgIcon:setScale(pSize.width / size.width * 0.7)
    				-- end
    			
    				-- local itemdef = NetClient:getItemDefByID(xmlTips.typeId)
    				local img_icon_bg = imgIconFrame:getWidgetByName("img_icon_bg")
    				-- if itemdef and "picicon/"..itemdef.mIconID..".png" == filepath then
    				-- 	imgIconFrame.resLoaded = true
    				-- end
    				if itemDef and itemDef.mItemBg > 0 then
    					filepath = string.format("picicon/iconbg%s.png", itemDef.mItemBg)
    				else
    					filepath = "picicon/null.png"
    				end
    				img_icon_bg:loadTexture(filepath)
    		-- 	end
    		-- end)
    	end
    end
    
    -- tips上半部分基础信息
    local function updateBasicInfo(xmlTips)
    	local netItem = xmlTips.netItem
    	local itemDef = xmlTips.itemDef
    
    	if itemDef then
    		xmlTips:getWidgetByName("lbl_name"):setString(itemDef.mName):setColor(game.getItemColor(itemDef.mEquipLevel))
    		xmlTips:getWidgetByName("lbl_type"):setString(game.getItemType(itemDef.mTypeID))
    
    		local lblLevel = xmlTips:getWidgetByName("lbl_level")
    		if itemDef.mNeedZsLevel > 0 then
    			lblLevel:setString(itemDef.mNeedZsLevel.."转")
    			-- lblLevel:setPosition(cc.p(190,315))
    			if itemDef.mNeedZsLevel <= MainRole._mainAvatar:NetAttr(Const.net_zslevel) then
    				lblLevel:setColor(cc.c3b(48,255,0))
    			else
    				lblLevel:setColor(cc.c3b(255,0,0))
    			end
    		elseif itemDef.mNeedParam >= 0 then
    			lblLevel:setString(itemDef.mNeedParam.."级")
    			if itemDef.mNeedParam <= MainRole._mainAvatar:NetAttr(Const.net_level) then
    				lblLevel:setColor(cc.c3b(48,255,0))
    			else
    				lblLevel:setColor(cc.c3b(255,0,0))
    			end
    		end
    	end
    end
    
    -- 物品tips描述和产出
    local function updatePropsTips(xmlTips)
    	local netItem = xmlTips.netItem
    	local itemDef = xmlTips.itemDef
    
    	if itemDef then
    		local listDesp = xmlTips:getWidgetByName("list_desp")
    		local size = listDesp:getInnerContainerSize()
    		local richLabelDesp = xmlTips:getWidgetByName("richLabel_desp")
    		richLabelDesp:setRichLabel("<font color=#B2A58B>"..itemDef.mDesp.."</font>", "tips_desp", 16)
    		listDesp:requestDoLayout()
    
    		local listSource = xmlTips:getWidgetByName("list_source")
    		size = listSource:getInnerContainerSize()
    		local richLabelSource = xmlTips:getWidgetByName("richLabel_source")
    		richLabelSource:setRichLabel("<font color=#B2A58B>"..itemDef.mSource.."</font>", "tips_src", 16)
    		listSource:requestDoLayout()
    	end
    end
    
    -- 装备tips基础属性(包含强化加成)
    -- 显示物防,魔防,物攻,法攻,道攻,血,暴击,内功,字号16
    
    local MIN_VALUE = 0
    
    local function buildEquipBaseAttr(itemDef, xmlTips)
    	local mUpdLevel = xmlTips.mUpdLevel
    	local baseAttrs = {
    		{key = "物理攻击:", value = {min = itemDef.mDC, max = itemDef.mDCMax}},
    		{key = "魔法攻击:", value = {min = itemDef.mMC, max = itemDef.mMCMax}},
    		{key = "道士攻击:", value = {min = itemDef.mSC, max = itemDef.mSCMax}},
    		{key = "物理防御:", value = {min = itemDef.mAC, max = itemDef.mACMax}},
    		{key = "魔法防御:", value = {min = itemDef.mMAC, max = itemDef.mMACMax}},
    		{key = "生命上限:", value = itemDef.mMaxHp},
    		{key = "暴击率:", value = itemDef.mBaojiProb},
    		{key = "暴击:", value = itemDef.mBaojiPres},
    		{key = "内功:", value = itemDef.mAddPower},
    		{key = "幸运值:", value = itemDef.mLuck},
    	}
    
    	local netItem = xmlTips.netItem
    	if netItem then
    		baseAttrs[10].value = baseAttrs[10].value + netItem.mLuck
    		-- baseAttrs[10].value = 100
    	end
    
    	local updAttrs = {}
    	if mUpdLevel and mUpdLevel > 0 then
    		local updId = itemDef.mJob*10000+itemDef.mEquipType*100+mUpdLevel
    		local uid = NetClient.mUpgradeDesp[updId]
    		-- print("//////////////////buildEquipBaseAttr//////////////////", updId, uid)
    		if uid then
    			-- print("//////////////////buildEquipBaseAttr//////////////////", util.encode(uid))
    			updAttrs = {
    				{min = uid.mDC, max = uid.mDCMax},
    				{min = uid.mMC, max = uid.mMCMax},
    				{min = uid.mSC, max = uid.mSCMax},
    				{min = uid.mAC, max = uid.mACMax},
    				{min = uid.mMAC, max = uid.mMACMax},
    			}
    		end
    	end
    
    	local str = ""
    	for i,v in ipairs(baseAttrs) do
    		if util.isTable(v.value) then
    			if v.value.max > MIN_VALUE then
    				str = str..v.key..v.value.min.."-"..v.value.max
    				if updAttrs[i] and updAttrs[i].max > 0 then
    					str = str.."<font color=#BC813A> 强化+("..updAttrs[i].min.."-"..updAttrs[i].max..")</font>"
    				end
    				str = str.."<br>"
    			end
    		elseif v.value > MIN_VALUE then
    			if v.key == "暴击率:" then
    				v.value = (v.value / 100).."%"
    			end
    			str = str..v.key..v.value.."<br>"
    		end
    	end
    	str = "<font color=#B2A58B>"..str.."</font>"
    	return str
    end
    
    -- 装备tips强化可激活属性
    local function buildEquipActivateAttr(itemDef, mUpdLevel)
    	local str = ""
    	if not (mUpdLevel and mUpdLevel > 0) then
    		return str 
    	end
    	-- uid.mJob*10000+uid.mEquipType*100+uid.mLevel
    	local updId = itemDef.mJob*10000+itemDef.mEquipType*100+mUpdLevel
    	local uid = NetClient.mUpgradeDesp[updId]
    	if not uid then 
    		return str 
    	end
    
    	local activeAttrs = {
    		{key = "物理攻击:", value = {min = uid.mDC, max = uid.mDCMax}},
    		{key = "魔法攻击:", value = {min = uid.mMC, max = uid.mMCMax}},
    		{key = "道士攻击:", value = {min = uid.mSC, max = uid.mSCMax}},
    		{key = "物理防御:", value = {min = uid.mAC, max = uid.mACMax}},
    		{key = "魔法防御:", value = {min = uid.mMAC, max = uid.mMACMax}},
    	}
    
    	for i,v in ipairs(activeAttrs) do
    		if v.value.max > MIN_VALUE then
    			str = str..v.key
    			if v.value and v.value.max > 0 then
    				str = str.."<font color=#BC813A> 强化+"..mUpdLevel.."("..v.value.min.."-"..v.value.max..")</font>"
    			end
    			str = str.."<br>"
    		end
    	end
    	str =  "<font color=#B2A58B>"..str.."</font>"
    	return str
    end
    
    -- 装备tips回收收益
    local function buildAdditionalInfo(itemDef)
    	local str = ""
    	if itemDef.mRecycleExp > 0 then
    		str = "回收可获得:"..itemDef.mRecycleExp.."经验<br>"
    	end
    	if itemDef.mRecycleXuefu > 0 then
    		if str == "" then
    			str = "回收可获得:"..itemDef.mRecycleXuefu.."玉佩<br>"
    		else
    			str = str.."                   "..itemDef.mRecycleXuefu.."玉佩<br>"
    		end
    	end
    	if itemDef.mEquipContribute > 0 then
    		str = str.."捐献帮会可获得:"..itemDef.mEquipContribute.."贡献值"
    	end
    	str = "<font color=#88BD07>"..str.."</font>"
    	   
    
        if itemDef.mMabiProb > 0 then
            if str == "" then
                str =  "<font color=#B2A58B>近战物理伤害有"..(itemDef.mMabiProb / 100).."%几率麻痹目标<br>麻痹持续时间:"..itemDef.mMabiDura.."秒</font>"
            else
                str =  str.."<br><font color=#B2A58B>近战物理伤害有"..(itemDef.mMabiProb / 100).."%几率麻痹目标<br>麻痹持续时间:"..itemDef.mMabiDura.."秒</font>"
            end
        end
    
        if itemDef.mFuyuanCd > 0 then
            if str == "" then
                str =  "<font color=#B2A58B>死亡后立即满血复活不掉落装备<br>复活间隔:"..itemDef.mFuyuanCd.."秒 复活后恢复内功值:"..itemDef.mFuyuanPres.."%</font>"
            else
                str =  str.."<br><font color=#B2A58B>死亡后立即满血复活,不掉落装备<br>复活间隔:"..itemDef.mFuyuanCd.."秒 复活后恢复内功值:"..itemDef.mFuyuanPres.."%</font>"
            end
        end
    
        if itemDef.mDixiaoPres > 0 then
            if str == "" then
                str =  "<font color=#B2A58B>一定比例的伤害由魔法值抵消<br>魔法值抵消伤害比例:"..(itemDef.mDixiaoPres / 100).."%</font>"
            else
                str =  str.."<br><font color=#B2A58B>一定比例的伤害由魔法值抵消<br>魔法值抵消伤害比例:"..(itemDef.mDixiaoPres / 100).."%</font>"
            end
        end
    
        if itemDef.mDesp ~= "null" then
            if str == "" then
               str =  "<font color=#ff00ff>"..itemDef.mDesp.."</font>"
    --            str =  itemDef.mDesp
            else
                str =  str.."<br><font color=#ff00ff>"..itemDef.mDesp.."</font>"
    --            str =  str.."<br>"..itemDef.mDesp
            end
        end
    	return str
    end
    
    local function updateEquipUpdStar(xmlTips)
    	local mUpdLevel = xmlTips.mUpdLevel
    	local imgUpgradeStar
    	local starLight = "img_star_light"
    	local starGray = "img_star_gray"
    	if mUpdLevel and mUpdLevel > 10 then
    		starLight = "img_yang_light"
    		starGray = "img_yang_gray"
    		mUpdLevel = mUpdLevel - 10
    	end
    	for i=1,10 do
    		imgUpgradeStar = xmlTips:getWidgetByName("img_upgrade_star"..i)
    		if mUpdLevel and i <= mUpdLevel then
    			imgUpgradeStar:loadTexture(starLight, ccui.TextureResType.plistType)
    		else
    			imgUpgradeStar:loadTexture(starGray, ccui.TextureResType.plistType)
    		end
    	end
    end
    
    -- 装备tips刷新函数 
    local function updateEquipTips(xmlTips)
    	local netItem = xmlTips.netItem
    	local itemDef = xmlTips.itemDef
    	xmlTips:getWidgetByName("lbl_bind"):setString("")
    	xmlTips:getWidgetByName("img_equip_state"):hide()
    
    	xmlTips:getWidgetByName("lbl_upd_level"):setString("")
    	if (xmlTips.mUpdLevel and xmlTips.mUpdLevel > 0) then
    		xmlTips:getWidgetByName("lbl_upd_level"):setString("+"..xmlTips.mUpdLevel)
    	end
    
    	if netItem then
    		if netItem.position < 0 then
    			xmlTips:getWidgetByName("img_equip_state"):show()
    		else
    			xmlTips:getWidgetByName("img_equip_state"):hide()
    		end
    	end
    
    	if game.IsViceEquipment(nil, itemDef) and game.IsFurnaceEquipment(nil, itemDef) then
    		xmlTips:getWidgetByName("lbl_upgrade_pre"):hide()
    		xmlTips:getWidgetByName("box_upgrade_bg"):hide()
    	else
    		xmlTips:getWidgetByName("lbl_upgrade_pre"):show()
    		xmlTips:getWidgetByName("box_upgrade_bg"):show()
    		updateEquipUpdStar(xmlTips)
    	end
    
    	if itemDef then
    		-- 职业 lbl_job
    		local lblJob = xmlTips:getWidgetByName("lbl_job")
    		if itemDef.mJob ~= 0 then
    			if itemDef.mJob == Const.JOB_ZS then
    				lblJob:setString(Const.str_zs)
    			elseif itemDef.mJob == Const.JOB_FS then
    				lblJob:setString(Const.str_fs)
    			elseif itemDef.mJob == Const.JOB_DS then
    				lblJob:setString(Const.str_ds)
    			end
    			if itemDef.mJob == MainRole._mainAvatar:NetAttr(Const.net_job) then
    				lblJob:setColor(cc.c3b(48,255,0))
    			else
    				lblJob:setColor(cc.c3b(255,0,0))
    			end
    		else
    			lblJob:setString("通用")
    			lblJob:setColor(cc.c3b(48,255,0))
    		end
    
    		-- 性别 lbl_gender
    		local lblGender = xmlTips:getWidgetByName("lbl_gender")
    		if itemDef.mGender ~= 0 then
    			if itemDef.mGender == Const.GENDER_MALE then
    				lblGender:setString(Const.str_male)
    			elseif itemDef.mGender == Const.GENDER_FEMALE then
    				lblGender:setString(Const.str_female)
    			end
    			if itemDef.mGender == MainRole._mainAvatar:NetAttr(Const.net_gender) then
    				lblGender:setColor(cc.c3b(48,255,0))
    			else
    				lblGender:setColor(cc.c3b(255,0,0))
    			end
    		else
    			lblGender:setString("通用")
    			lblGender:setColor(cc.c3b(48,255,0))
    		end
    		-- 基础属性
    		local listBaseAttr = xmlTips:getWidgetByName("list_base_attr")
    		local size = listBaseAttr:getInnerContainerSize()
    		local richLabelBaseAttr = xmlTips:getWidgetByName("richLabel_base_attr")
    		local strBaseAttr = buildEquipBaseAttr(itemDef, xmlTips)
    		richLabelBaseAttr:setRichLabel(strBaseAttr, "tips_base_attr", 16)
    		listBaseAttr:requestDoLayout()
    
    		-- local imgTipsLine2 = xmlTips:getWidgetByName("img_tips_line2")
    		-- local lblUpdPre = xmlTips:getWidgetByName("lbl_upd_pre")
    		-- local listUpdAttr = xmlTips:getWidgetByName("list_upd_attr")
    		-- local listAdditionalInfo = xmlTips:getWidgetByName("list_additional_info")
    		-- local imgTipsLine3 = xmlTips:getWidgetByName("img_tips_line3")
    
    		if not game.IsViceEquipment(nil, itemDef) then
    			xmlTips:getWidgetByName("tips_bg"):setContentSize(409, 553):pos(0, 0)
    			xmlTips:getWidgetByName("box_other"):show()
    			xmlTips:getWidgetByName("box_base"):pos(0, 240)
    
    			xmlTips:getWidgetByName("img_tips_line1"):setPositionY(126) --126
    			xmlTips:getWidgetByName("lbl_desp_pre"):setPositionY(111) --111
    			xmlTips:getWidgetByName("list_base_attr"):setPositionY(85) --85
    
    			local strAdditionalInfo = buildAdditionalInfo(itemDef)
    			local listAdditionalInfo = xmlTips:getWidgetByName("list_additional_info")
    			size = listAdditionalInfo:getInnerContainerSize()
    			local richLabelAdditionalInfo = xmlTips:getWidgetByName("richLabel_additional_info")
    			richLabelAdditionalInfo:setRichLabel(strAdditionalInfo, "tips_additional", 16)
    			listAdditionalInfo:requestDoLayout()
    			
    			-- 强化可激活
    			local listUpdAttr = xmlTips:getWidgetByName("list_upd_attr")
    			size = listUpdAttr:getInnerContainerSize()
    			local richLabelUpdAttr = xmlTips:getWidgetByName("richLabel_upd_attr")
    			local strActiveAttr = buildEquipActivateAttr(itemDef, xmlTips.mUpdLevel and xmlTips.mUpdLevel + 1 or 1)
    			richLabelUpdAttr:setRichLabel(strActiveAttr, "tips_upd_attr", 16)
    			listUpdAttr:requestDoLayout()
    		else
    			xmlTips:getWidgetByName("tips_bg"):setContentSize(409, 313):pos(0, 120)
    			xmlTips:getWidgetByName("box_other"):hide()
    			xmlTips:getWidgetByName("box_base"):pos(0, 0)
    
    			if game.IsFurnaceEquipment(nil, itemDef) then
    				xmlTips:getWidgetByName("img_tips_line1"):setPositionY(167) --126
    				xmlTips:getWidgetByName("lbl_desp_pre"):setPositionY(131) --111
    				xmlTips:getWidgetByName("list_base_attr"):setPositionY(110) --85
    			else
    				xmlTips:getWidgetByName("img_tips_line1"):setPositionY(146) --126
    				xmlTips:getWidgetByName("lbl_desp_pre"):setPositionY(131) --111
    				xmlTips:getWidgetByName("list_base_attr"):setPositionY(105) --85
    			end
    
    		end
    	end
    end
    
    -- 刷新tips按钮列表
    local function updateTipsButtons(xmlTips)
    	
    	local listButtons = xmlTips:getWidgetByName("list_buttons")
    	listButtons:removeAllItems()
    
    	local tipsTag = getTipsTag(xmlTips)
    	local conf = buttonsConfig[tipsTag]
    	local btnTipsUse = xmlTips:getWidgetByName("btn_tips_use")
    	btnTipsUse.useType = USE_TYPE.NULL
    	local btnTipsMore = xmlTips:getWidgetByName("btn_tips_more")
    	if conf then
    		if conf.useTitle then
    			btnTipsUse:setTitleText(conf.useTitle):show()
    			btnTipsUse.useType = conf.useType or USE_TYPE.NULL
    		else
    			btnTipsUse:hide()
    			btnTipsUse.useType = USE_TYPE.NULL
    		end
    
    		if conf.more then
    			local btnName
    			for i,v in ipairs(conf.more) do
    				btnTips = btnTipsUse:clone()
    				btnName = title2Name[v] or "btn_tips_default"
    				btnTips:setName(btnName)
    				btnTips:setTitleText(v)
    				listButtons:pushBackCustomItem(btnTips)
    				UIRedPoint.addUIPoint(btnTips, pushTipsButtons)
    				btnTips.xmlTips = xmlTips
    			end
    			btnTipsMore:show()
    			-- local innerSize = listButtons:getInnerContainerSize()
    			local pSize = listButtons:getContentSize()
    			local pMargin = listButtons:getItemsMargin()
    			pSize.height = (34 + pMargin) * #conf.more - pMargin
    			-- if innerSize.height > 
    			listButtons:setContentSize(pSize)
    		else
    			btnTipsMore:hide()
    		end
    	else
    		btnTipsUse:hide()
    		btnTipsMore:hide()
    	end
    end
    
    -- tips刷新函数 
    local function updateTips(xmlTips, betterState)
    	
    	if xmlTips.typeId then
    		local netItem = xmlTips.netItem
    		--非自己的物品操作按钮不显示
    		xmlTips:getWidgetByName("box_buttons"):setVisible(netItem and true or false)
    		if xmlTips.enmuPos == 5 then
    			xmlTips:getWidgetByName("box_buttons"):show()
    		end
    		
    		xmlTips:getWidgetByName("lbl_bind"):setString("")
    		if netItem then
    			if bit.band(netItem.mItemFlags, Const.ITEM_FLAG_BIND) > 0 then
    				xmlTips:getWidgetByName("lbl_bind"):setString("已绑定")
    			else
    				xmlTips:getWidgetByName("lbl_bind"):setString("未绑定")
    			end
    		end
    
    		local betteFlag
    		local worseFlag
    		if betterState == nil or betterState == Const.ITEM_UNUSE_SELF or betterState == Const.ITEM_UNUSE_SELF then
    			betteFlag = false
    			worseFlag = false
    		elseif betterState == Const.ITEM_BETTER_SELF then
    			betteFlag = true
    			worseFlag = false
    		elseif betterState == Const.ITEM_WORSE_SELF then
    			betteFlag = false
    			worseFlag = true
    		end
    		local img_better_flag = xmlTips:getWidgetByName("img_better_flag")
    		local img_worse_flag = xmlTips:getWidgetByName("img_worse_flag")
    		if img_better_flag and img_worse_flag then
    			img_better_flag:hide()--:setVisible(betteFlag)
    			img_worse_flag:hide()--:setVisible(worseFlag)
    		end
    
    		updateTipsIcon(xmlTips)
    		updateBasicInfo(xmlTips)
    		updateTipsButtons(xmlTips)
    
    		if game.IsEquipment(xmlTips.typeId) then
    			updateEquipTips(xmlTips)
    		else
    			updatePropsTips(xmlTips)
    		end
    	end
    end
    
    local function addComparetips(xmlTips, typeId, itemPos, param)
    	local showTable = {
    		Const.EQUIP_TYPE_WEAPON,
    		Const.EQUIP_TYPE_CLOTH,
    		Const.EQUIP_TYPE_HAT,
    		Const.EQUIP_TYPE_NICKLACE,
    		Const.EQUIP_TYPE_GLOVE,
    		Const.EQUIP_TYPE_RING,
    		Const.EQUIP_TYPE_BELT,
    		Const.EQUIP_TYPE_BOOT,
    		Const.EQUIP_TYPE_MIRROR_ARMOUR,
    		Const.EQUIP_TYPE_DRAGON_BONE,
    		Const.EQUIP_TYPE_FACE_CLOTH,
    		Const.EQUIP_TYPE_CATILLA
    	}
    	local itemDef = NetClient:getItemDefByID(typeId)
    	local equipType = itemDef.mEquipType
    	-- print("addComparetips", equipType, table.indexof(showTable, equipType))
    	local index = table.indexof(showTable, equipType)
    	if not (index and index > 0) then
    		return
    	end
    
    	local pos = -2 * equipType
    	local selfEquip = NetClient:getNetItem(pos)
    	if selfEquip then
    		if game.IsRing(selfEquip.mTypeID) or game.IsGlove(selfEquip.mTypeID) then
    			local other = NetClient:getNetItem(pos - 1)
    			if other then
    				if NetClient:getItemDefByID(other.mTypeID).mNeedParam > NetClient:getItemDefByID(selfEquip.mTypeID).mNeedParam then
    					selfEquip = other
    				end
    			end
    		end
    
    		local selfEquipDef = NetClient:getItemDefByID(selfEquip.mTypeID)
    		local betterState = game.CompareItem(itemPos, pos, itemDef)
    		if betterState ~= Const.ITEM_UNUSE_SELF then
    			local selfEquiptip = newTips(selfEquip.mTypeID)
    			if selfEquiptip then
    				selfEquiptip:addTo(xmlTips):pos(-selfEquiptip:getContentSize().width, 0):setName("selfEquiptip")
    
    				selfEquiptip.netItem = selfEquip
    				selfEquiptip.itemDef = selfEquipDef
    				selfEquiptip.itemPos = pos
    				selfEquiptip.typeId = selfEquip.mTypeID
    				selfEquiptip.tipsType = param.tipsType
    				selfEquiptip.mUpdLevel = selfEquip.mLevel
    				updateTips(selfEquiptip)
    				selfEquiptip:getWidgetByName("box_buttons"):hide()
    			end
    		end
    		return betterState
    	end
    end
    
    -- 暴露给外部使用函数
    function UITips.showTips(param)
    	local xmlTips
    	local itemPos = param.itemPos
    	local typeId = param.typeId
    	local mUpdLevel = param.mUpdLevel
    	local netItem = NetClient:getNetItem(itemPos)
    	if netItem then 
    		typeId = netItem.mTypeID
    		mUpdLevel = netItem.mLevel
    	elseif param.mLevel then
    		mUpdLevel = param.mLevel --外部传值
    	end
    	if typeId then
    		local itemDef = NetClient:getItemDefByID(typeId)
    		if itemDef then
    			xmlTips = param.tips or newTips(typeId)
    			if xmlTips then
    				xmlTips.netItem = netItem
    				xmlTips.itemDef = itemDef
    				xmlTips.itemPos = itemPos
    				xmlTips.typeId = typeId
    				xmlTips.tipsType = param.tipsType
    				xmlTips.mUpdLevel = mUpdLevel
    				xmlTips.customCallFunc = param.customCallFunc
    				xmlTips.destoryCallFunc = param.destoryCallFunc
    				xmlTips.enmuPos = param.enmuPos
    				xmlTips.enmuItemType = param.enmuItemType
    
    				xmlTips:removeChildByName("selfEquiptip")
    				local betterState
    				if param.compare then
    					betterState = addComparetips(xmlTips, typeId, itemPos, param)
    				end
    
    				updateTips(xmlTips, betterState)
    				local btnTipsMore = xmlTips:getWidgetByName("btn_tips_more")
    				btnTipsMore.xmlTips = xmlTips
    				handleButtonsListVisible(btnTipsMore, false)
    			end
    		end
    	end
    	return xmlTips
    end
    


    30.00% (3) 次Baidu访问
    40.00% (4) 次Google访问
    30.00% (3) 次sm访问
    • 蜘蛛:Baidu,3次,更新时间:2020-07-03 14:53:44
    • 蜘蛛:Google,4次,更新时间:2020-09-13 19:17:36
    • 蜘蛛:sm,3次,更新时间:2020-07-21 08:09:21
  • 0
  • 0
  • 0
  • 18
  • 请登录之后再进行评论

    登录
  • 做任务
  • 实时动态
  • 偏好设置
  • 返回顶部
  • 单栏布局 侧栏位置: