Initial version - 1.2.0.60
EN: 1.2.0.60 CN: 1.2.0.61 JP: 1.2.0.63 KR: 1.2.0.67
This commit is contained in:
@@ -0,0 +1,392 @@
|
||||
local DepotCtrl = class("DepotCtrl", BaseCtrl)
|
||||
local DepotData = require("GameCore.Data.DataClass.DepotData")
|
||||
DepotCtrl._mapNodeConfig = {
|
||||
TopBar = {
|
||||
sNodeName = "TopBarPanel",
|
||||
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
|
||||
},
|
||||
aniRoot = {
|
||||
sNodeName = "----SafeAreaRoot----",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
sv = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
trSv = {sNodeName = "sv", sComponentName = "Transform"},
|
||||
imgEmpty = {},
|
||||
txtEmptyTitle = {sComponentName = "TMP_Text"},
|
||||
ItemList = {
|
||||
sNodeName = "---ItemList---"
|
||||
},
|
||||
ItemInfo = {
|
||||
sNodeName = "---ItemInfo---"
|
||||
},
|
||||
tog = {
|
||||
nCount = 6,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_ChangeSheet"
|
||||
},
|
||||
ctrlTog = {
|
||||
nCount = 6,
|
||||
sNodeName = "tog",
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateToggleCtrl"
|
||||
},
|
||||
goTitle = {
|
||||
sCtrlName = "Game.UI.DepotEx.DepotItemTitleCtrl"
|
||||
},
|
||||
goInfoList = {
|
||||
sCtrlName = "Game.UI.DepotEx.DepotItemInfoCtrl"
|
||||
},
|
||||
btnDetail = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Detail"
|
||||
},
|
||||
txtDetail = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Depot_Btn_Info"
|
||||
},
|
||||
btnUse = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Use"
|
||||
},
|
||||
txtUse = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Depot_Btn_Use"
|
||||
},
|
||||
goListBtn = {
|
||||
sCtrlName = "Game.UI.DepotEx.DepotSortCtrl"
|
||||
}
|
||||
}
|
||||
DepotCtrl._mapEventConfig = {
|
||||
ConsumableUsed = "OnEvent_RefreshDepot",
|
||||
CraftingSuccess = "OnEvent_RefreshDepot",
|
||||
DepotChangeSort = "OnEvent_ChangeSort",
|
||||
RefreshTogTimeLimit = "OnEvent_RefreshTogTimeLimit"
|
||||
}
|
||||
function DepotCtrl:SwitchTog()
|
||||
self._mapNode.goListBtn:RefreshSort(self.nCurTog)
|
||||
self:RefreshListData()
|
||||
self:RefreshEmpty()
|
||||
self:RefreshItemList()
|
||||
self:RefreshBottom()
|
||||
self:RefreshInfo()
|
||||
end
|
||||
function DepotCtrl:RefreshListData(bSort)
|
||||
local mapSort = self._mapNode.goListBtn:GetSortCfg(self.nCurTog)
|
||||
local tbFilter = self._mapNode.goListBtn:GetFilterCfg(self.nCurTog)
|
||||
self.DepotData:Init(self.nCurTog)
|
||||
local tbItem = self.DepotData:GetSortedList(self.nCurTog, mapSort, tbFilter)
|
||||
self.nItemCount = self.DepotData:GetGridCount(self.nCurTog)
|
||||
self.nSortCount = #tbItem
|
||||
if self.nSortCount > 0 then
|
||||
self.tbItem = tbItem
|
||||
else
|
||||
self.tbItem = {}
|
||||
end
|
||||
if bSort then
|
||||
self.mapSelect = nil
|
||||
end
|
||||
self:SetSelectData()
|
||||
self:RefreshInfo()
|
||||
end
|
||||
function DepotCtrl:SetSelectData()
|
||||
if self.mapSelect then
|
||||
for i, mapData in pairs(self.tbItem) do
|
||||
if mapData.nId == self.mapSelect.nId then
|
||||
self.mapSelect = mapData
|
||||
self.nSelectIndex = i
|
||||
return
|
||||
end
|
||||
end
|
||||
self.mapSelect = nil
|
||||
end
|
||||
self.nSelectIndex = 1
|
||||
self.mapSelect = self.tbItem[self.nSelectIndex]
|
||||
end
|
||||
function DepotCtrl:RefreshEmpty()
|
||||
self._mapNode.imgEmpty:SetActive(self.nItemCount <= 0)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtEmptyTitle, ConfigTable.GetUIText("Depot_Empty"))
|
||||
end
|
||||
function DepotCtrl:RefreshListWithPos(bReset)
|
||||
if bReset then
|
||||
self.nPos = nil
|
||||
else
|
||||
self.nPos = self._mapNode.sv:GetScrollPos()
|
||||
end
|
||||
self:RefreshItemList()
|
||||
end
|
||||
function DepotCtrl:RefreshItemList()
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self._mapNode.ItemList:SetActive(self.nItemCount > 0)
|
||||
self._mapNode.sv.gameObject:SetActive(0 < self.nSortCount)
|
||||
if 0 < self.nSortCount then
|
||||
self._mapNode.sv:Init(self.nSortCount, self, self.OnGridRefresh, self.OnGridBtnClick, self.nPos ~= nil)
|
||||
end
|
||||
end
|
||||
function DepotCtrl:OnGridRefresh(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local mapItem = self.tbItem[nIndex]
|
||||
local nInstanceID = goGrid:GetInstanceID()
|
||||
if not self.tbGridCtrl[nInstanceID] then
|
||||
self.tbGridCtrl[nInstanceID] = self:BindCtrlByNode(goGrid, "Game.UI.TemplateEx.TemplateItemCtrl")
|
||||
end
|
||||
self.tbGridCtrl[nInstanceID]:SetItem(mapItem.nTid, mapItem.nRarity, mapItem.nCount, mapItem.nExpire)
|
||||
self.tbGridCtrl[nInstanceID]:SetSelect(self.nSelectIndex == nIndex)
|
||||
end
|
||||
function DepotCtrl:OnGridBtnClick(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local nInstanceID = goGrid:GetInstanceID()
|
||||
if self.nSelectIndex then
|
||||
local goSelect = self._mapNode.trSv:Find("Viewport/Content/" .. self.nSelectIndex - 1)
|
||||
if goSelect then
|
||||
self.tbGridCtrl[goSelect.gameObject:GetInstanceID()]:SetSelect(false)
|
||||
end
|
||||
end
|
||||
self.tbGridCtrl[nInstanceID]:SetSelect(true)
|
||||
self.nSelectIndex = nIndex
|
||||
self.mapSelect = self.tbItem[nIndex]
|
||||
self:RefreshInfo()
|
||||
end
|
||||
function DepotCtrl:RefreshBottom()
|
||||
self._mapNode.btnDetail.gameObject:SetActive(false)
|
||||
self._mapNode.btnUse.gameObject:SetActive(self.nCurTog == GameEnum.packMark.Consumables)
|
||||
end
|
||||
function DepotCtrl:RefreshInfo()
|
||||
self._mapNode.ItemInfo:SetActive(self.nSortCount > 0)
|
||||
if self.mapSelect then
|
||||
self._mapNode.goTitle:SetItemTitle(self.nCurTog, self.mapSelect)
|
||||
self._mapNode.goInfoList:SetItemInfo(self.nCurTog, self.mapSelect)
|
||||
local nSelectTid = self.mapSelect.nTid
|
||||
local mapItemCfgData = ConfigTable.GetData_Item(nSelectTid)
|
||||
if not mapItemCfgData then
|
||||
return
|
||||
end
|
||||
self._mapNode.btnUse.gameObject:SetActive(mapItemCfgData.UseMode == GameEnum.useMode.UseModeManual)
|
||||
else
|
||||
self._mapNode.btnUse.gameObject:SetActive(false)
|
||||
end
|
||||
end
|
||||
function DepotCtrl:SetDefaultTog()
|
||||
self.DepotData:Init()
|
||||
if type(self.nCurTog) ~= "number" or self.nCurTog <= 0 then
|
||||
self.nCurTog = nil
|
||||
for _, tog in ipairs(self.TogSort) do
|
||||
if 0 < self.DepotData:GetGridCount(tog) then
|
||||
self.nCurTog = tog
|
||||
break
|
||||
end
|
||||
end
|
||||
if self.nCurTog == nil then
|
||||
self.nCurTog = self.TogSort[1]
|
||||
end
|
||||
end
|
||||
for i = 1, 6 do
|
||||
self._mapNode.tog[i].gameObject:SetActive(false)
|
||||
end
|
||||
for _, tog in ipairs(self.TogSort) do
|
||||
local i = table.keyof(self.TogSort, tog)
|
||||
self._mapNode.ctrlTog[i]:SetDefault(tog == self.nCurTog)
|
||||
self._mapNode.tog[i].gameObject:SetActive(true)
|
||||
end
|
||||
self:SwitchTog()
|
||||
end
|
||||
function DepotCtrl:RefreshTogTimeLimit()
|
||||
local nCurTime = CS.ClientManager.Instance.serverTimeStamp
|
||||
for k, tog in ipairs(self.TogSort) do
|
||||
if self._mapNode.tog[k] ~= nil then
|
||||
local imgTimeLimit = self._mapNode.tog[k].transform:Find("AnimRoot/AnimSwitch/goBg/unSelect/imgTimeLimit")
|
||||
local imgRemainTime1 = imgTimeLimit.transform:Find("imgRemainTime1")
|
||||
local imgRemainTime2 = imgTimeLimit.transform:Find("imgRemainTime2")
|
||||
local imgRemainTime3 = imgTimeLimit.transform:Find("imgRemainTime3")
|
||||
local txtTimeLimit = imgTimeLimit.transform:Find("txtTimeLimit"):GetComponent("TMP_Text")
|
||||
local nMinExpire = -1
|
||||
local tbItems = self.DepotData:GetSortedList(tog)
|
||||
if tbItems ~= nil then
|
||||
for _, v in ipairs(tbItems) do
|
||||
if v.nExpire ~= 0 and (nMinExpire == -1 or nMinExpire > v.nExpire) and nCurTime < v.nExpire then
|
||||
nMinExpire = v.nExpire
|
||||
end
|
||||
end
|
||||
end
|
||||
imgTimeLimit.gameObject:SetActive(0 < nMinExpire)
|
||||
local remainTime = nMinExpire - nCurTime
|
||||
if 86400 <= remainTime then
|
||||
local day = math.floor(remainTime / 86400)
|
||||
local hour = math.floor((remainTime - day * 86400) / 3600)
|
||||
if hour == 0 then
|
||||
day = day - 1
|
||||
hour = 24
|
||||
end
|
||||
NovaAPI.SetTMPText(txtTimeLimit, string.format("%s%s%s%s", day, ConfigTable.GetUIText("Depot_LeftTime_Day"), hour, ConfigTable.GetUIText("Depot_LeftTime_Hour")))
|
||||
elseif 3600 <= remainTime then
|
||||
local hour = math.floor(remainTime / 3600)
|
||||
local min = math.floor((remainTime - hour * 3600) / 60)
|
||||
if min == 0 then
|
||||
hour = hour - 1
|
||||
min = 60
|
||||
end
|
||||
NovaAPI.SetTMPText(txtTimeLimit, string.format("%s%s%s%s", hour, ConfigTable.GetUIText("Depot_LeftTime_Hour"), min, ConfigTable.GetUIText("Depot_LeftTime_Min")))
|
||||
else
|
||||
local min = math.max(math.floor(remainTime / 60), 1)
|
||||
NovaAPI.SetTMPText(txtTimeLimit, string.format("%s%s", min, ConfigTable.GetUIText("Depot_LeftTime_Min")))
|
||||
end
|
||||
imgRemainTime1.gameObject:SetActive(86400 <= remainTime)
|
||||
imgRemainTime2.gameObject:SetActive(remainTime < 86400 and 3600 <= remainTime)
|
||||
imgRemainTime3.gameObject:SetActive(remainTime < 3600)
|
||||
end
|
||||
end
|
||||
end
|
||||
function DepotCtrl:RefreshTogText()
|
||||
for _, v in ipairs(self.TogSort) do
|
||||
self._mapNode.ctrlTog[table.keyof(self.TogSort, v)]:SetText(self:GetTogTextByType(v))
|
||||
end
|
||||
end
|
||||
function DepotCtrl:GetTogTextByType(nMark)
|
||||
local text = ""
|
||||
local foreachItemPackMark = function(mapData)
|
||||
if mapData.PackMark == nMark then
|
||||
text = mapData.Name
|
||||
end
|
||||
end
|
||||
ForEachTableLine(DataTable.ItemPackMark, foreachItemPackMark)
|
||||
return text
|
||||
end
|
||||
function DepotCtrl:ResetTogData()
|
||||
self.mapSelect = nil
|
||||
self.nSelectIndex = nil
|
||||
self.nPos = nil
|
||||
end
|
||||
function DepotCtrl:SortItemPackMark()
|
||||
local tbItemPackMark = {}
|
||||
local foreachItemPackMark = function(mapData)
|
||||
table.insert(tbItemPackMark, mapData)
|
||||
end
|
||||
ForEachTableLine(DataTable.ItemPackMark, foreachItemPackMark)
|
||||
table.sort(tbItemPackMark, function(a, b)
|
||||
return a.Sort < b.Sort
|
||||
end)
|
||||
self.TogSort = {}
|
||||
for i = 1, #tbItemPackMark do
|
||||
self.TogSort[i] = tbItemPackMark[i].PackMark
|
||||
end
|
||||
end
|
||||
function DepotCtrl:JumpDetail()
|
||||
end
|
||||
function DepotCtrl:FadeIn(bPlayFadeIn)
|
||||
EventManager.Hit(EventId.SetTransition)
|
||||
self._mapNode.aniRoot:Play("depot_t_in")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.3)
|
||||
end
|
||||
function DepotCtrl:Awake()
|
||||
self:ResetTogData()
|
||||
self.nCurTog = nil
|
||||
local tbParam = self:GetPanelParam()
|
||||
if type(tbParam) == "table" then
|
||||
self.nCurTog = tbParam[1]
|
||||
end
|
||||
self:SortItemPackMark()
|
||||
self:RefreshTogText()
|
||||
end
|
||||
function DepotCtrl:OnEnable()
|
||||
self.tbGridCtrl = {}
|
||||
self.tbItem = nil
|
||||
self.DepotData = DepotData.new()
|
||||
self:SetDefaultTog()
|
||||
self:RefreshTogTimeLimit()
|
||||
end
|
||||
function DepotCtrl:OnDisable()
|
||||
self.DepotData:Clear()
|
||||
self.DepotData = nil
|
||||
self.tbItem = nil
|
||||
if self.nSortCount and self.nSortCount > 0 then
|
||||
self.nPos = self._mapNode.sv:GetScrollPos()
|
||||
end
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function DepotCtrl:OnDestroy()
|
||||
self:ResetTogData()
|
||||
self.nCurTog = nil
|
||||
end
|
||||
function DepotCtrl:OnBtnClick_ChangeSheet(btn, nIndex)
|
||||
local nSelectTog = self.TogSort[nIndex]
|
||||
if nSelectTog == self.nCurTog then
|
||||
return
|
||||
end
|
||||
self._mapNode.ctrlTog[nIndex]:SetTrigger(true)
|
||||
self._mapNode.ctrlTog[table.keyof(self.TogSort, self.nCurTog)]:SetTrigger(false)
|
||||
self.nCurTog = nSelectTog
|
||||
self:ResetTogData()
|
||||
self:SwitchTog()
|
||||
self:RefreshTogTimeLimit()
|
||||
end
|
||||
function DepotCtrl:OnBtnClick_Detail(btn)
|
||||
self._mapNode.aniRoot:Play("depot_t_out")
|
||||
self:AddTimer(1, 0.1, "JumpDetail", true, true)
|
||||
end
|
||||
function DepotCtrl:OnBtnClick_Use(btn)
|
||||
if self.mapSelect ~= nil then
|
||||
local nSelectTid = self.mapSelect.nTid
|
||||
local mapItemCfgData = ConfigTable.GetData_Item(nSelectTid)
|
||||
if not mapItemCfgData then
|
||||
return
|
||||
end
|
||||
if mapItemCfgData.Stype == GameEnum.itemStype.EnergyItem or mapItemCfgData.Stype == GameEnum.itemStype.SouvenirEnergyItem then
|
||||
local mapItemCahceData = PlayerData.Item:GetItemCacheDataByID(self.mapSelect.nTid)
|
||||
if not mapItemCahceData then
|
||||
return
|
||||
end
|
||||
local nCurEnergy = PlayerData.Base:GetCurEnergy().nEnergy
|
||||
local nMaxEnergy = ConfigTable.GetConfigNumber("EnergyObtainLimit")
|
||||
if nCurEnergy >= nMaxEnergy then
|
||||
local sTip = ConfigTable.GetUIText("Energy_Use_Tip_2")
|
||||
EventManager.Hit(EventId.OpenMessageBox, {
|
||||
nType = AllEnum.MessageBox.Tips,
|
||||
sContent = sTip
|
||||
})
|
||||
return
|
||||
end
|
||||
local useCfg = decodeJson(mapItemCfgData.UseArgs)
|
||||
local nEnergyValue = 0
|
||||
for itemId, count in pairs(useCfg) do
|
||||
local checkItemCfg = ConfigTable.GetData_Item(tonumber(itemId))
|
||||
if nil ~= checkItemCfg and checkItemCfg.Stype == GameEnum.itemStype.Energy then
|
||||
nEnergyValue = count
|
||||
else
|
||||
printLog(string.format("体力道具使用参数配置错误!!!请检查!itemId = [%s]", itemId))
|
||||
end
|
||||
end
|
||||
local mapItem = {
|
||||
nTid = mapItemCahceData.Tid,
|
||||
mapId = mapItemCahceData.mapExpires[self.mapSelect.nExpire].mapId,
|
||||
nExpire = self.mapSelect.nExpire,
|
||||
nTimeLimit = 0 < self.mapSelect.nExpire and 1 or 0,
|
||||
nCount = mapItemCahceData.mapExpires[self.mapSelect.nExpire].nTotalCount,
|
||||
nEnergyValue = nEnergyValue
|
||||
}
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.EnergyBuy, AllEnum.EnergyPanelType.ItemUse, mapItem, true)
|
||||
elseif mapItemCfgData.Stype == GameEnum.itemStype.ComCYO or mapItemCfgData.Stype == GameEnum.itemStype.OutfitCYO or mapItemCfgData.Stype == GameEnum.itemStype.RandomPackage then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.Consumable, {
|
||||
self.mapSelect.nTid
|
||||
})
|
||||
elseif mapItemCfgData.Stype == GameEnum.itemStype.CharacterYO then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.CharConsumablePanel, self.mapSelect.nTid)
|
||||
end
|
||||
end
|
||||
end
|
||||
function DepotCtrl:OnEvent_ChangeSort(bReset)
|
||||
self:RefreshListData(true)
|
||||
self:RefreshListWithPos(bReset)
|
||||
end
|
||||
function DepotCtrl:OnEvent_RefreshDepot()
|
||||
self.DepotData:Init()
|
||||
self:SwitchTog()
|
||||
self:RefreshTogTimeLimit()
|
||||
end
|
||||
return DepotCtrl
|
||||
@@ -0,0 +1,25 @@
|
||||
local DepotInfoDescribeCtrl = class("DepotInfoDescribeCtrl", BaseCtrl)
|
||||
DepotInfoDescribeCtrl._mapNodeConfig = {
|
||||
txtTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Depot_Info_Describe"
|
||||
},
|
||||
txtDesc = {sComponentName = "TMP_Text"}
|
||||
}
|
||||
DepotInfoDescribeCtrl._mapEventConfig = {}
|
||||
function DepotInfoDescribeCtrl:SetDesc(nId)
|
||||
if ConfigTable.GetData_Item(nId).Desc and ConfigTable.GetData_Item(nId).Desc ~= "" then
|
||||
if ConfigTable.GetData_Item(nId).Literary and ConfigTable.GetData_Item(nId).Literary ~= "" then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtDesc, ConfigTable.GetData_Item(nId).Desc .. [[
|
||||
|
||||
<color=#5E89B4>]] .. ConfigTable.GetData_Item(nId).Literary .. "</color>")
|
||||
else
|
||||
NovaAPI.SetTMPText(self._mapNode.txtDesc, ConfigTable.GetData_Item(nId).Desc)
|
||||
end
|
||||
elseif ConfigTable.GetData_Item(nId).Literary and ConfigTable.GetData_Item(nId).Literary ~= "" then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtDesc, ConfigTable.GetData_Item(nId).Literary)
|
||||
else
|
||||
NovaAPI.SetTMPText(self._mapNode.txtDesc, "")
|
||||
end
|
||||
end
|
||||
return DepotInfoDescribeCtrl
|
||||
@@ -0,0 +1,27 @@
|
||||
local DepotInfoSkillCtrl = class("DepotInfoSkillCtrl", BaseCtrl)
|
||||
DepotInfoSkillCtrl._mapNodeConfig = {
|
||||
txtTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Depot_Info_Skill"
|
||||
},
|
||||
txtSkillName = {sComponentName = "TMP_Text"},
|
||||
txtSkillDesc = {sComponentName = "TMP_Text"},
|
||||
TMP_Link = {
|
||||
sNodeName = "txtSkillDesc",
|
||||
sComponentName = "TMPHyperLink",
|
||||
callback = "OnLinkClick_Word"
|
||||
}
|
||||
}
|
||||
DepotInfoSkillCtrl._mapEventConfig = {}
|
||||
function DepotInfoSkillCtrl:Awake()
|
||||
end
|
||||
function DepotInfoSkillCtrl:OnEnable()
|
||||
end
|
||||
function DepotInfoSkillCtrl:OnDisable()
|
||||
end
|
||||
function DepotInfoSkillCtrl:OnDestroy()
|
||||
end
|
||||
function DepotInfoSkillCtrl:OnLinkClick_Word(link, sWordId)
|
||||
UTILS.ClickWordLink(link, sWordId)
|
||||
end
|
||||
return DepotInfoSkillCtrl
|
||||
@@ -0,0 +1,96 @@
|
||||
local DepotInfoSourceCtrl = class("DepotInfoSourceCtrl", BaseCtrl)
|
||||
local JumpUtil = require("Game.Common.Utils.JumpUtil")
|
||||
local RapidJson = require("rapidjson")
|
||||
DepotInfoSourceCtrl._mapNodeConfig = {
|
||||
txtTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Depot_Info_Source"
|
||||
},
|
||||
goJump = {},
|
||||
trBg = {sNodeName = "rtBg", sComponentName = "Transform"}
|
||||
}
|
||||
DepotInfoSourceCtrl._mapEventConfig = {}
|
||||
function DepotInfoSourceCtrl:Refresh(nId)
|
||||
self.nId = nId
|
||||
local mapItem = ConfigTable.GetData_Item(nId)
|
||||
local tbJumpTo = mapItem.JumpTo
|
||||
if #tbJumpTo == 0 then
|
||||
self.gameObject:SetActive(false)
|
||||
return
|
||||
end
|
||||
self:RemoveAllBtn()
|
||||
self.tbJumptoData = {}
|
||||
for _, nJumptoId in ipairs(tbJumpTo) do
|
||||
local mapJumpTo = ConfigTable.GetData("JumpTo", nJumptoId)
|
||||
if mapJumpTo ~= nil then
|
||||
if mapJumpTo.Type == GameEnum.jumpType.ComCYO then
|
||||
local mapProduceCfg = ConfigTable.GetData("ProduceHelper", nId)
|
||||
if mapProduceCfg ~= nil then
|
||||
local tbComCYO = mapProduceCfg.ComCYOIds
|
||||
for _, v in ipairs(tbComCYO) do
|
||||
local nCount = PlayerData.Item:GetItemCountByID(v)
|
||||
if 0 < nCount then
|
||||
local itemCfgData = ConfigTable.GetData_Item(v, true)
|
||||
if itemCfgData ~= nil then
|
||||
local mapAfter = clone(mapJumpTo)
|
||||
mapAfter.Desc = string.format(mapAfter.Desc, itemCfgData.Title)
|
||||
mapAfter.Param = {v}
|
||||
table.insert(self.tbJumptoData, mapAfter)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
table.insert(self.tbJumptoData, mapJumpTo)
|
||||
end
|
||||
end
|
||||
end
|
||||
for i, mapJumpTo in ipairs(self.tbJumptoData) do
|
||||
local goJumpto = instantiate(self._mapNode.goJump, self._mapNode.trBg)
|
||||
goJumpto:SetActive(true)
|
||||
local btnComp = goJumpto.transform:Find("btnJump"):GetComponent("Button")
|
||||
table.insert(self.tbGoJumpto, btnComp)
|
||||
local func_Handler = ui_handler(self, self.OnBtnClick_JumpTo, btnComp, i)
|
||||
btnComp.onClick:AddListener(func_Handler)
|
||||
local imgIconJumpto = goJumpto.transform:Find("btnJump/AnimRoot/imgIcon"):GetComponent("Image")
|
||||
local txtDesc = goJumpto.transform:Find("btnJump/AnimRoot/txtDesc"):GetComponent("TMP_Text")
|
||||
local goArrow = goJumpto.transform:Find("btnJump/AnimRoot/imgArrow").gameObject
|
||||
if mapJumpTo.Icon == nil then
|
||||
mapJumpTo.Icon = ""
|
||||
end
|
||||
self:SetPngSprite(imgIconJumpto, mapJumpTo.Icon)
|
||||
NovaAPI.SetImageNativeSize(imgIconJumpto)
|
||||
NovaAPI.SetTMPText(txtDesc, mapJumpTo.Desc)
|
||||
if mapJumpTo.Type == GameEnum.jumpType.Text then
|
||||
btnComp.interactable = false
|
||||
goArrow:SetActive(false)
|
||||
else
|
||||
btnComp.interactable = true
|
||||
goArrow:SetActive(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
function DepotInfoSourceCtrl:RemoveAllBtn()
|
||||
if self.tbGoJumpto == nil then
|
||||
return
|
||||
end
|
||||
for _, btnComp in pairs(self.tbGoJumpto) do
|
||||
btnComp.onClick:RemoveAllListeners()
|
||||
end
|
||||
self.tbGoJumpto = {}
|
||||
delChildren(self._mapNode.trBg)
|
||||
end
|
||||
function DepotInfoSourceCtrl:OnBtnClick_JumpTo(_, nIndex)
|
||||
JumpUtil.JumpTo(self.tbJumptoData[nIndex].Id, self.tbJumptoData[nIndex].Param, self.nId)
|
||||
end
|
||||
function DepotInfoSourceCtrl:Awake()
|
||||
self.tbGoJumpto = {}
|
||||
end
|
||||
function DepotInfoSourceCtrl:OnEnable()
|
||||
end
|
||||
function DepotInfoSourceCtrl:OnDisable()
|
||||
self:RemoveAllBtn()
|
||||
end
|
||||
function DepotInfoSourceCtrl:OnDestroy()
|
||||
end
|
||||
return DepotInfoSourceCtrl
|
||||
@@ -0,0 +1,38 @@
|
||||
local DepotItemInfoCtrl = class("DepotItemInfoCtrl", BaseCtrl)
|
||||
DepotItemInfoCtrl._mapNodeConfig = {
|
||||
goSkill = {
|
||||
sCtrlName = "Game.UI.DepotEx.DepotInfoSkillCtrl"
|
||||
},
|
||||
goDescribe = {
|
||||
sCtrlName = "Game.UI.DepotEx.DepotInfoDescribeCtrl"
|
||||
},
|
||||
goSource = {
|
||||
sCtrlName = "Game.UI.DepotEx.DepotInfoSourceCtrl"
|
||||
},
|
||||
Content = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
Scrollbar = {sComponentName = "Transform"}
|
||||
}
|
||||
DepotItemInfoCtrl._mapEventConfig = {}
|
||||
function DepotItemInfoCtrl:SetItemInfo(nTog, mapItem)
|
||||
self._mapNode.Scrollbar.localScale = Vector3.zero
|
||||
self:SetItem(mapItem.nTid)
|
||||
self._mapNode.Scrollbar.localScale = Vector3.one
|
||||
end
|
||||
function DepotItemInfoCtrl:SetItem(nId)
|
||||
self._mapNode.goSkill.gameObject:SetActive(false)
|
||||
self._mapNode.goDescribe.gameObject:SetActive(true)
|
||||
self._mapNode.goSource.gameObject:SetActive(true)
|
||||
self._mapNode.goDescribe:SetDesc(nId)
|
||||
self._mapNode.goSource:Refresh(nId)
|
||||
end
|
||||
function DepotItemInfoCtrl:Awake()
|
||||
end
|
||||
function DepotItemInfoCtrl:OnEnable()
|
||||
end
|
||||
function DepotItemInfoCtrl:OnDisable()
|
||||
end
|
||||
function DepotItemInfoCtrl:OnDestroy()
|
||||
end
|
||||
return DepotItemInfoCtrl
|
||||
@@ -0,0 +1,82 @@
|
||||
local DepotItemTitleCtrl = class("DepotItemTitleCtrl", BaseCtrl)
|
||||
DepotItemTitleCtrl._mapNodeConfig = {
|
||||
goItemL = {
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateItemCtrl"
|
||||
},
|
||||
txtName = {sComponentName = "TMP_Text"},
|
||||
btnLock = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Lock"
|
||||
},
|
||||
imgLock = {},
|
||||
imgUnlock = {},
|
||||
goItemStar = {
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateStarCtrl"
|
||||
},
|
||||
txtLevelCn = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Depot_Level"
|
||||
},
|
||||
txtTitleLevel = {sComponentName = "TMP_Text"},
|
||||
txtCountCn = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Depot_ItemQTY"
|
||||
},
|
||||
txtItemCount = {sComponentName = "TMP_Text"},
|
||||
goRemain = {},
|
||||
txtRemain = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Depot_LeftTime"
|
||||
},
|
||||
imgRemainTime = {nCount = 3},
|
||||
txtTime = {sComponentName = "TMP_Text"}
|
||||
}
|
||||
DepotItemTitleCtrl._mapEventConfig = {}
|
||||
function DepotItemTitleCtrl:SetItemTitle(nTog, mapItem)
|
||||
self.nCurTog = nTog
|
||||
self:SetItem(mapItem.nTid, mapItem.nRarity, mapItem.nCount, mapItem.nExpire)
|
||||
end
|
||||
function DepotItemTitleCtrl:SetItem(nId, nRarity, nCount, nExpire)
|
||||
self._mapNode.btnLock.gameObject:SetActive(false)
|
||||
self._mapNode.goItemStar.gameObject:SetActive(false)
|
||||
self._mapNode.txtLevelCn.gameObject:SetActive(false)
|
||||
self._mapNode.txtCountCn.gameObject:SetActive(true)
|
||||
self._mapNode.goRemain.gameObject:SetActive(nExpire and nExpire ~= 0)
|
||||
self._mapNode.goItemL:SetItem(nId, nRarity, nil, nil, nil, nil, nil, nil, nil, true)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtName, ConfigTable.GetData_Item(nId).Title)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtItemCount, nCount)
|
||||
if nExpire and nExpire ~= 0 then
|
||||
local curTime = CS.ClientManager.Instance.serverTimeStamp
|
||||
local remainTime = nExpire - curTime
|
||||
if 86400 <= remainTime then
|
||||
local day = math.floor(remainTime / 86400)
|
||||
local hour = math.floor((remainTime - day * 86400) / 3600)
|
||||
if hour == 0 then
|
||||
day = day - 1
|
||||
hour = 24
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTime, string.format("%s%s%s%s", day, ConfigTable.GetUIText("Depot_LeftTime_Day"), hour, ConfigTable.GetUIText("Depot_LeftTime_Hour")))
|
||||
elseif 3600 <= remainTime then
|
||||
local hour = math.floor(remainTime / 3600)
|
||||
local min = math.floor((remainTime - hour * 3600) / 60)
|
||||
if min == 0 then
|
||||
hour = hour - 1
|
||||
min = 60
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTime, string.format("%s%s%s%s", hour, ConfigTable.GetUIText("Depot_LeftTime_Hour"), min, ConfigTable.GetUIText("Depot_LeftTime_Min")))
|
||||
else
|
||||
local min = math.max(math.floor(remainTime / 60), 1)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTime, string.format("%s%s", min, ConfigTable.GetUIText("Depot_LeftTime_Min")))
|
||||
end
|
||||
self._mapNode.imgRemainTime[1]:SetActive(86400 <= remainTime)
|
||||
self._mapNode.imgRemainTime[2]:SetActive(remainTime < 86400 and 3600 <= remainTime)
|
||||
self._mapNode.imgRemainTime[3]:SetActive(remainTime < 3600)
|
||||
end
|
||||
end
|
||||
function DepotItemTitleCtrl:_ChangeLock(bLock)
|
||||
self._mapNode.imgLock:SetActive(bLock)
|
||||
self._mapNode.imgUnlock:SetActive(not bLock)
|
||||
end
|
||||
function DepotItemTitleCtrl:OnBtnClick_Lock(btn)
|
||||
end
|
||||
return DepotItemTitleCtrl
|
||||
@@ -0,0 +1,9 @@
|
||||
local DepotPanel = class("DepotPanel", BasePanel)
|
||||
DepotPanel._bAddToBackHistory = true
|
||||
DepotPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "DepotEx/DepotPanel.prefab",
|
||||
sCtrlName = "Game.UI.DepotEx.DepotCtrl"
|
||||
}
|
||||
}
|
||||
return DepotPanel
|
||||
@@ -0,0 +1,105 @@
|
||||
local DepotSortCtrl = class("DepotSortCtrl", BaseCtrl)
|
||||
DepotSortCtrl._mapNodeConfig = {
|
||||
btnRarity = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Rarity"
|
||||
},
|
||||
ctrlBtnRarity = {
|
||||
sNodeName = "btnRarity",
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateSortBtnCtrl"
|
||||
},
|
||||
btnLevel = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Level"
|
||||
},
|
||||
ctrlBtnLevel = {
|
||||
sNodeName = "btnLevel",
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateSortBtnCtrl"
|
||||
},
|
||||
btnFilter = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Filter"
|
||||
},
|
||||
imgFilterChoose = {}
|
||||
}
|
||||
DepotSortCtrl._mapEventConfig = {
|
||||
[EventId.FilterConfirm] = "RefreshByFilter"
|
||||
}
|
||||
function DepotSortCtrl:RefreshSort(nTog)
|
||||
local bReset = self.nCurTog ~= nTog
|
||||
self.nCurTog = nTog
|
||||
self.tbFilterCfg = {}
|
||||
if bReset then
|
||||
end
|
||||
self:RefreshSortState(bReset)
|
||||
end
|
||||
function DepotSortCtrl:RefreshSortState(bReset)
|
||||
self._mapNode.btnRarity.gameObject:SetActive(false)
|
||||
self._mapNode.btnLevel.gameObject:SetActive(false)
|
||||
self._mapNode.btnFilter.gameObject:SetActive(false)
|
||||
local isDirty = false
|
||||
self._mapNode.imgFilterChoose:SetActive(isDirty)
|
||||
end
|
||||
function DepotSortCtrl:RefreshSortText()
|
||||
self._mapNode.ctrlBtnRarity:SetText("Depot_SortByRare")
|
||||
self._mapNode.ctrlBtnLevel:SetText("Depot_SortByLevel")
|
||||
end
|
||||
function DepotSortCtrl:GetSortCfg()
|
||||
return self.mapSortCfg
|
||||
end
|
||||
function DepotSortCtrl:GetFilterCfg()
|
||||
return self.tbFilterCfg
|
||||
end
|
||||
function DepotSortCtrl:Awake()
|
||||
self.tbFilterCfg = nil
|
||||
self.mapSortCfg = nil
|
||||
self:RefreshSortText()
|
||||
end
|
||||
function DepotSortCtrl:OnEnable()
|
||||
end
|
||||
function DepotSortCtrl:OnDisable()
|
||||
end
|
||||
function DepotSortCtrl:OnDestroy()
|
||||
self.tbFilterCfg = nil
|
||||
self.mapSortCfg = nil
|
||||
end
|
||||
function DepotSortCtrl:OnBtnClick_Rarity(btn)
|
||||
local bSwitch = self.mapSortCfg.nSortType == AllEnum.SortType.Level
|
||||
if bSwitch then
|
||||
self.mapSortCfg.nSortType = AllEnum.SortType.Rarity
|
||||
self.mapSortCfg.bOrder = true
|
||||
self._mapNode.ctrlBtnLevel:Refresh(false)
|
||||
else
|
||||
self.mapSortCfg.bOrder = not self.mapSortCfg.bOrder
|
||||
end
|
||||
self._mapNode.ctrlBtnRarity:Refresh(self.mapSortCfg.nSortType == AllEnum.SortType.Rarity, self.mapSortCfg.bOrder)
|
||||
EventManager.Hit("DepotChangeSort")
|
||||
end
|
||||
function DepotSortCtrl:OnBtnClick_Level(btn)
|
||||
local bSwitch = self.mapSortCfg.nSortType == AllEnum.SortType.Rarity
|
||||
if bSwitch then
|
||||
self.mapSortCfg.nSortType = AllEnum.SortType.Level
|
||||
self.mapSortCfg.bOrder = true
|
||||
self._mapNode.ctrlBtnRarity:Refresh(false)
|
||||
else
|
||||
self.mapSortCfg.bOrder = not self.mapSortCfg.bOrder
|
||||
end
|
||||
self._mapNode.ctrlBtnLevel:Refresh(self.mapSortCfg.nSortType == AllEnum.SortType.Level, self.mapSortCfg.bOrder)
|
||||
EventManager.Hit("DepotChangeSort")
|
||||
end
|
||||
function DepotSortCtrl:OnBtnClick_Filter()
|
||||
local tbOption = {
|
||||
AllEnum.ChooseOption.Equip_Rarity,
|
||||
AllEnum.ChooseOption.Equip_Type,
|
||||
AllEnum.ChooseOption.Equip_PowerStyle,
|
||||
AllEnum.ChooseOption.Equip_TacticalStyle,
|
||||
AllEnum.ChooseOption.Equip_AffiliatedForces
|
||||
}
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.FilterPopupPanel, tbOption)
|
||||
end
|
||||
function DepotSortCtrl:RefreshByFilter()
|
||||
local isDirty = false
|
||||
self._mapNode.imgFilterChoose:SetActive(isDirty)
|
||||
EventManager.Hit("DepotChangeSort")
|
||||
end
|
||||
return DepotSortCtrl
|
||||
Reference in New Issue
Block a user