sk-client/Assets/ManagedResources/~Lua/Modules/Popup/RewardItemSingleShowPopup.lua

248 lines
10 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

require("Base/BasePanel")
RewardItemSingleShowPopup = Inherit(BasePanel)
local this = RewardItemSingleShowPopup
local JumpConfig = ConfigManager.GetConfig(ConfigName.JumpConfig)
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local itemSid
local itemConfigData
local func
-- local lanTuData = {}
local item
--初始化组件(用于子类重写)
function RewardItemSingleShowPopup:InitComponent()
this.btnBack = Util.GetGameObject(self.transform, "btnBack")
this.mask = Util.GetGameObject(self.transform, "mask")
this.name = Util.GetGameObject(self.transform, "bg/Content/armorInfo/name"):GetComponent("Text")
this.type = Util.GetGameObject(self.transform, "bg/Content/armorInfo/type"):GetComponent("Text")
this.desc = Util.GetGameObject(self.transform, "bg/Content/desc"):GetComponent("Text")
this.equipProGrid = Util.GetGameObject(self.transform, "bg/Content/scroll")
this.btnLeft = Util.GetGameObject(self.transform, "bg/Content/btnGrid/btnLeft")
this.btnLeftText = Util.GetGameObject(this.btnLeft.transform, "Text"):GetComponent("Text")
this.btnRight = Util.GetGameObject(self.transform, "bg/Content/btnGrid/btnRight")
this.itemPos = Util.GetGameObject(self.transform, "bg/Content/armorInfo/Item")
end
--绑定事件(用于子类重写)
function RewardItemSingleShowPopup:BindEvent()
Util.AddClick(this.mask, function()
self:ClosePanel()
end)
Util.AddClick(this.btnBack, function()
self:ClosePanel()
end)
Util.AddClick(this.btnLeft, function()
self:ClosePanel()
if itemConfigData.ItemType == ItemType.HeroDebris or itemConfigData.ItemType == ItemType.ItemDebris then
if BagManager.bagDatas[itemSid] and BagManager.GetItemCountById(itemSid) >= BagManager.bagDatas[itemSid].itemConfig.UsePerCount then
local _itemData = BagManager.bagDatas[itemSid]
UIManager.OpenPanel(UIName.BagResolveAnCompoundPanel, 3, _itemData, function()
if func then
func()
end
end)
else
if itemConfigData.ItemType == ItemType.HeroDebris then
PopupTipPanel.ShowTipByLanguageId(11592)
elseif itemConfigData.ItemType == ItemType.ItemDebris then
PopupTipPanel.ShowTipByLanguageId(50381)
end
end
-- elseif itemConfigData.ItemType == ItemType.Blueprint then
-- if lanTuData and lanTuData[1] == true then
-- local _itemData = BagManager.bagDatas[itemSid]
-- UIManager.OpenPanel(UIName.BagResolveAnCompoundPanel, 3, _itemData, function()
-- if func then
-- func()
-- end
-- end)
-- elseif lanTuData and lanTuData[1] == false and lanTuData[2] > 0 then
-- NetManager.GetWorkShopAvtiveLanTuRequest(lanTuData[2], 2, function()
-- this.DeleteActiveLanTuData()
-- end)
-- end
elseif itemConfigData.ItemType == ItemType.Box then
local _itemData = BagManager.bagDatas[itemSid]
if itemConfig[itemSid].UseType ~= 2 then
UIManager.OpenPanel(UIName.BagResolveAnCompoundPanel, 4, _itemData, function()
if func then
func()
end
end)
end
elseif itemConfigData.ItemType == ItemType.ChangeName then
UIManager.OpenPanel(UIName.CreateNamePopup)
else
local _itemData = BagManager.bagDatas[itemSid]
UIManager.OpenPanel(UIName.BagResolveAnCompoundPanel, 3, _itemData, function()
if func then
func()
end
end)
end
end)
Util.AddClick(this.btnRight, function()
self:ClosePanel()
if itemConfigData then
JumpManager.GoJump(itemConfigData.UseJump)
end
end)
end
-- --扣除解锁蓝图材料 并数据
-- function this.DeleteActiveLanTuData()
-- PopupTipPanel.ShowTip(GetLanguageStrById(11593) .. itemConfigData.Name)
-- if lanTuData and lanTuData[1] == false and lanTuData[2] > 0 then
-- WorkShopManager.UpdataWorkShopLanTuActiveState(2, lanTuData[2], itemConfigData.Id)--
-- end
-- if func then
-- func()
-- end
-- this:ClosePanel()
-- end
--添加事件监听(用于子类重写)
function RewardItemSingleShowPopup:AddListener()
end
--移除事件监听(用于子类重写)
function RewardItemSingleShowPopup:RemoveListener()
end
--界面打开时调用(用于子类重写)
function RewardItemSingleShowPopup:OnOpen(...)
local data = { ... }
itemSid = data[1]
if data[2] then
func = data[2]
end
this.isRewardItemPop = data[3]
itemConfigData = ConfigManager.GetConfigData(ConfigName.ItemConfig, itemSid)
LogGreen("道具ID"..itemSid)
end
function RewardItemSingleShowPopup:OnShow()
if not item then
item = SubUIManager.Open(SubUIConfig.ItemView, this.itemPos.transform)
end
item:OnOpen(false, {itemSid, 0}, 1)
if BagManager.isBagPanel and UIManager.IsOpen(UIName.RewardBoxPanel) then
this.btnLeft:SetActive(false)
elseif BagManager.isBagPanel and itemConfigData.IfResolve == 1 and func then--是否可分解
if itemConfigData.ItemType == ItemType.HeroDebris then
this.btnLeftText.text = GetLanguageStrById(10210)
this.btnLeft:SetActive(true)
elseif itemConfigData.ItemType == ItemType.Gene then
this.btnLeft:SetActive(false)
else
this.btnLeftText.text = GetLanguageStrById(10214)
this.btnLeft:SetActive(true)
end
elseif BagManager.isBagPanel and (itemConfigData.ItemType == ItemType.HeroDebris or itemConfigData.ItemType == ItemType.ItemDebris) and func then--是否是碎片可合成
this.btnLeftText.text = GetLanguageStrById(10210)
this.btnLeft:SetActive(true)
elseif BagManager.isBagPanel and itemConfigData.ItemType == ItemType.Box and func then
this.btnLeftText.text = GetLanguageStrById(10212)
this.btnLeft:SetActive(true)
elseif BagManager.isBagPanel and itemConfigData.ItemType == ItemType.ChangeName and func then
this.btnLeftText.text = GetLanguageStrById(10212)
this.btnLeft:SetActive(true)
elseif itemConfigData.ItemType == ItemType.ItemDebris and UIManager.IsOpen(UIName.DiscountTaskPanel) then
this.btnLeftText.text = GetLanguageStrById(10210)
this.btnLeft:SetActive(true)
else
this.btnLeft:SetActive(false)
end
this.btnRight:SetActive(itemConfigData.UseJump and itemConfigData.UseJump > 0 and BagManager.isBagPanel)
this.name.text = GetStringByEquipQua(itemConfigData.Quantity, GetLanguageStrById(itemConfigData.Name))
this.type.text = GetLanguageStrById(this.getType())
this.desc.text = string.gsub(GetLanguageStrById(itemConfigData.ItemDescribe), "\\n", "")
--装备获得途径
Util.ClearChild(this.equipProGrid.transform)
if itemConfigData and itemConfigData.Jump then
if itemConfigData.Jump and #itemConfigData.Jump > 0 then
local jumpSortData = {}
for i = 1, #itemConfigData.Jump do
local jumpData = {}
jumpData.id = itemConfigData.Jump[i]
jumpData.data = JumpConfig[itemConfigData.Jump[i]]
table.insert(jumpSortData, jumpData)
end
for i = 1, #jumpSortData do
if jumpSortData[i].id > 0 then
if not RECHARGEABLE then--(是否开启充值)
if this.isRewardItemPop == true or itemConfigData.Id == 61 or itemConfigData.Id == 19 then
SubUIManager.Open(SubUIConfig.JumpView, this.equipProGrid.transform, jumpSortData[i].id, false)
else
SubUIManager.Open(SubUIConfig.JumpView, this.equipProGrid.transform, jumpSortData[i].id, true)
end
else
if this.isRewardItemPop == true then
SubUIManager.Open(SubUIConfig.JumpView, this.equipProGrid.transform, jumpSortData[i].id, false)
else
SubUIManager.Open(SubUIConfig.JumpView, this.equipProGrid.transform, jumpSortData[i].id, true)
end
end
end
end
end
end
end
--获取道具种类
function this.getType()
local type = GetLanguageStrById(itemConfig[itemSid].ItemTypeDes)
-- if type == 1 then
-- return GetLanguageStrById(11093)..GetLanguageStrById(12266)
-- elseif type == 2 then
-- return GetLanguageStrById(11093)..GetLanguageStrById(10219)
-- elseif type == 4 then
-- return GetLanguageStrById(11093)..GetLanguageStrById(12267)
-- elseif type == 5 then
-- return GetLanguageStrById(11093)..GetLanguageStrById(12268)
-- elseif type == 6 then
-- return GetLanguageStrById(11093)..GetLanguageStrById(12269)
-- elseif type == 7 then
-- return GetLanguageStrById(11093)..GetLanguageStrById(12270)
-- end
return type
end
--为关卡跳转做的排序
function this.JumpSort(jumps)
table.sort(jumps, function(a, b)
if a.state == b.state then
if a.state == 2 and b.state == 2 then
return a.data.SortId > b.data.SortId
end
else
return a.state > b.state
end
end)
end
--道具 和 装备分解 发送请求后 回调
function this.SendBackResolveReCallBack(drop, curResolveAllItemList)
UIManager.OpenPanel(UIName.RewardItemPopup, drop, 1)
if func then
func()
end
this:ClosePanel()
end
--界面关闭时调用(用于子类重写)
function RewardItemSingleShowPopup:OnClose()
end
--界面销毁时调用(用于子类重写)
function RewardItemSingleShowPopup:OnDestroy()
item = nil
end
return RewardItemSingleShowPopup