167 lines
6.5 KiB
Lua
167 lines
6.5 KiB
Lua
require("Base/BasePanel")
|
|
SelectGiftListPopup = Inherit(BasePanel)
|
|
local this = SelectGiftListPopup
|
|
local curSelectSoulPrint = {}
|
|
local curSelectAllSoulPrintIds = {}
|
|
local curUpList={}
|
|
local targetSoulPrintSData = {}
|
|
local curIndex = 0
|
|
local openThisPanel
|
|
local equipSign = ConfigManager.GetConfig(ConfigName.EquipConfig)
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
local curSelectGO
|
|
local isShowGou = false
|
|
local curSelectId=0
|
|
local itemType=0
|
|
--初始化组件(用于子类重写)
|
|
function SelectGiftListPopup:InitComponent()
|
|
this.spLoader = SpriteLoader.New()
|
|
|
|
this.BtnBack = Util.GetGameObject(self.transform, "btnBack")
|
|
this.BtnSure = Util.GetGameObject(self.transform, "btnSure")
|
|
this.btnSelect = Util.GetGameObject(self.transform, "btnSelect")
|
|
Util.GetGameObject(self.transform, "toggleGrid"):SetActive(false)
|
|
this.btnSelectImage = Util.GetGameObject(self.transform, "btnSelect/SelectImage")
|
|
this.cardPre = Util.GetGameObject(self.gameObject, "equipPre")
|
|
|
|
this.Scrollbar= Util.GetGameObject(self.gameObject, "Scrollbar"):GetComponent("Scrollbar")
|
|
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView,Util.GetGameObject(self.gameObject, "scroll").transform,
|
|
this.cardPre, this.Scrollbar, Vector2.New(927.5, 1010), 1, 5, Vector2.New(19.32,15))
|
|
this.ScrollView.gameObject:GetComponent("RectTransform").anchoredPosition = Vector2.New(6.78, 27)
|
|
this.ScrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
|
|
this.ScrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
|
|
this.ScrollView.moveTween.MomentumAmount = 1
|
|
this.ScrollView.moveTween.Strength = 1
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function SelectGiftListPopup:BindEvent()
|
|
Util.AddClick(this.BtnBack, function()
|
|
self:ClosePanel()
|
|
end)
|
|
Util.AddClick(this.BtnSure, function()
|
|
self:ClosePanel()
|
|
openThisPanel.ShowTitleEquipData(nil,curSelectId,curIndex)
|
|
end)
|
|
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function SelectGiftListPopup:AddListener()
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function SelectGiftListPopup:RemoveListener()
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function SelectGiftListPopup:OnOpen(_openThisPanel,_curUpList,_curIndex,_targetSoulPrintSData,_itemType)
|
|
openThisPanel = _openThisPanel
|
|
itemType=_itemType
|
|
LogError("_curindex==========".._curIndex)
|
|
curSelectId = _curUpList[_curIndex]
|
|
curUpList = _curUpList
|
|
curIndex = _curIndex
|
|
targetSoulPrintSData = _targetSoulPrintSData
|
|
isShowGou = false
|
|
curSelectGO = nil
|
|
end
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
function SelectGiftListPopup:OnShow()
|
|
this.OnShowData()
|
|
end
|
|
--检测list里面含有的id数量
|
|
function this.CheckListHaveNum(_list,_id)
|
|
local num=0
|
|
for i=1,#_list do
|
|
if _list[i]==_id then
|
|
num=num+1
|
|
end
|
|
end
|
|
return num
|
|
end
|
|
|
|
function this.OnShowData()
|
|
local bagData = BagManager.GetBagItemDataByItemType(itemType)
|
|
local list = {}
|
|
for i=1,#bagData do
|
|
--如果当前的物品已经全部上到英雄身上的就不显示
|
|
LogError("curSelectId=="..curSelectId.." bagData[i].id=="..bagData[i].id)
|
|
if curSelectId~=bagData[i].id and this.CheckListHaveNum(curUpList,bagData[i].id)>=bagData[i].num then
|
|
else
|
|
if targetSoulPrintSData.Star>0 then
|
|
if bagData[i].id == targetSoulPrintSData.Formula[1][1] then
|
|
table.insert(list,bagData[i])
|
|
end
|
|
else
|
|
if bagData[i].quality == targetSoulPrintSData.Formula[1][1] then
|
|
table.insert(list,bagData[i])
|
|
end
|
|
end
|
|
|
|
|
|
end
|
|
end
|
|
table.sort(list, function(a,b) return a.id < b.id end)
|
|
this.ScrollView:SetData(list, function (index, go)
|
|
this.SingleItemDataShow(go,list[index])
|
|
end)
|
|
this.ShowSUreBtnState()
|
|
end
|
|
function this.SingleItemDataShow(_go,curBagSoulPrintData)
|
|
local curequipSign = equipSign[curBagSoulPrintData.id]
|
|
Util.GetGameObject(_go.transform,"frame"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetQuantityImageByquality(curequipSign.Quality))
|
|
local icon=Util.GetGameObject(_go.transform,"icon"):GetComponent("Image")
|
|
icon.sprite=this.spLoader:LoadSprite(GetResourcePath(itemConfig[curBagSoulPrintData.id].ResourceID))
|
|
icon.gameObject:SetActive(true)
|
|
Util.GetGameObject(_go.transform,"circleFrameBg"):SetActive(false)
|
|
Util.GetGameObject(_go.transform,"name"):GetComponent("Text").text = SubString2(string.gsub(GetLanguageStrById(curequipSign.Name),Language[11520],"",1), 10)
|
|
local numTxt=Util.GetGameObject(_go.transform,"num"):GetComponent("Text")
|
|
numTxt.text=curBagSoulPrintData.num
|
|
Util.GetGameObject(_go.transform, "Hero"):SetActive(false)
|
|
local curheroData = {}
|
|
local choosed =Util.GetGameObject(_go.transform, "choosed")
|
|
local starPar =Util.GetGameObject(_go.transform, "star")
|
|
SetHeroStars(this.spLoader,starPar,curequipSign.Star,1,nil,-15)
|
|
choosed:SetActive(curSelectId == curBagSoulPrintData.id and not isShowGou)
|
|
--local redPoint = Util.GetGameObject(_go.transform,"redPoint")
|
|
if curSelectId == curBagSoulPrintData.id and not isShowGou then
|
|
curSelectGO = _go
|
|
isShowGou = true
|
|
end
|
|
Util.AddLongPressClick(Util.GetGameObject(_go.transform,"frame"), function()
|
|
UIManager.OpenPanel(UIName.SoulPrintPopUp,0,nil,curBagSoulPrintData.id,nil,nil)
|
|
end, 0.5)
|
|
Util.AddOnceClick(Util.GetGameObject(_go.transform,"frame"), function()
|
|
this.SoulPrintClickShow(curequipSign,choosed,_go)
|
|
end)
|
|
end
|
|
function this.SoulPrintClickShow(curequipSign,choosed,_go)
|
|
if curSelectGO then
|
|
Util.GetGameObject(curSelectGO.transform, "choosed"):SetActive(false)
|
|
end
|
|
curSelectId = curequipSign.Id
|
|
choosed:SetActive(true)
|
|
curSelectGO = _go
|
|
this.ShowSUreBtnState()
|
|
end
|
|
function this.ShowSUreBtnState()
|
|
if curSelectId and curSelectId~=0 then
|
|
Util.SetGray(this.BtnSure,false)
|
|
this.BtnSure:GetComponent("Button").enabled = true
|
|
else
|
|
Util.SetGray(this.BtnSure,true)
|
|
this.BtnSure:GetComponent("Button").enabled = false
|
|
end
|
|
end
|
|
--界面关闭时调用(用于子类重写)
|
|
function SelectGiftListPopup:OnClose()
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function SelectGiftListPopup:OnDestroy()
|
|
this.spLoader:Destroy()
|
|
end
|
|
|
|
return SelectGiftListPopup |