Update - 1.9.0.103
EN: 1.9.0.103 CN: 1.9.0.104 JP: 1.9.0.106 KR: 1.9.0.108
This commit is contained in:
@@ -0,0 +1,293 @@
|
||||
local PotentialPreselectionCtrl = class("PotentialPreselectionCtrl", BaseCtrl)
|
||||
PotentialPreselectionCtrl._mapNodeConfig = {
|
||||
TopBar = {
|
||||
sNodeName = "TopBarPanel",
|
||||
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
|
||||
},
|
||||
EmptyContent = {},
|
||||
txt_Empty = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_List_Empty"
|
||||
},
|
||||
ExistContent = {},
|
||||
imgAllCount = {},
|
||||
txt_BuildCount = {sComponentName = "TMP_Text"},
|
||||
btn_DeleteBuild = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Delete"
|
||||
},
|
||||
txtBtnDelete = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Delete"
|
||||
},
|
||||
btnImport = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Import"
|
||||
},
|
||||
txtBtnImport = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Import"
|
||||
},
|
||||
BuildList = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
goFilterEmpty = {},
|
||||
txt_FilterEmpty = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_List_Empty_Filter"
|
||||
},
|
||||
btn_sort_time = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_SortTime"
|
||||
},
|
||||
txt_sort_timeTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "RoguelikeBuild_Manage_SortTime"
|
||||
},
|
||||
btnFilter = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Filter"
|
||||
},
|
||||
imgFilterChoose = {},
|
||||
btnCreate = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Create"
|
||||
},
|
||||
txtBtnCreate = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Create"
|
||||
},
|
||||
DeleteContent = {},
|
||||
btn_CloseDelete = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_CloseDelete"
|
||||
},
|
||||
txt_CloseDelete = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "RoguelikeBuild_Common_BtnCancle"
|
||||
},
|
||||
txtDelete = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Deleting"
|
||||
}
|
||||
}
|
||||
PotentialPreselectionCtrl._mapEventConfig = {
|
||||
[EventId.FilterConfirm] = "OnEvent_RefreshByFilter",
|
||||
DeletePotentialPreselection = "OnEvent_DeleteSuc",
|
||||
RefreshPreselectionList = "OnEvent_RefreshPreselectionList"
|
||||
}
|
||||
PotentialPreselectionCtrl._mapRedDotConfig = {}
|
||||
local PanelState = {normal = 1, delete = 2}
|
||||
local SortOrder = {Descending = true, Ascending = false}
|
||||
function PotentialPreselectionCtrl:InitSort()
|
||||
self._mapNode.btn_sort_time.transform:Find("AnimRoot/btn_AsceIcon"):GetComponent("Button").interactable = self.nSortOrder == SortOrder.Ascending
|
||||
self._mapNode.btn_sort_time.transform:Find("AnimRoot/btn_DescIcon"):GetComponent("Button").interactable = self.nSortOrder == SortOrder.Descending
|
||||
end
|
||||
function PotentialPreselectionCtrl:RefreshPanel()
|
||||
self._mapNode.DeleteContent.gameObject:SetActive(self.nPanelType == PanelState.delete)
|
||||
self:RefreshList()
|
||||
end
|
||||
function PotentialPreselectionCtrl:RefreshList()
|
||||
self.tbAllPreselectionList = PlayerData.PotentialPreselection:GetPreselectionList()
|
||||
if self.tbPreselectionList == nil then
|
||||
self.tbPreselectionList = self.tbAllPreselectionList
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_BuildCount, string.format("%d/%d", #self.tbAllPreselectionList, self.nAllBuildCount))
|
||||
local isDirty = PlayerData.Filter:IsDirty(AllEnum.OptionType.Char)
|
||||
self._mapNode.imgFilterChoose:SetActive(isDirty)
|
||||
local bEmpty = #self.tbAllPreselectionList == 0
|
||||
self._mapNode.EmptyContent.gameObject:SetActive(bEmpty)
|
||||
self._mapNode.ExistContent.gameObject:SetActive(not bEmpty)
|
||||
self._mapNode.btn_sort_time.gameObject:SetActive(not bEmpty)
|
||||
self._mapNode.btnFilter.gameObject:SetActive(not bEmpty)
|
||||
self._mapNode.imgAllCount.gameObject:SetActive(not bEmpty)
|
||||
for nInstanceId, objCtrl in pairs(self.mapGridCtrl or {}) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.mapGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
if bEmpty then
|
||||
return
|
||||
end
|
||||
self._mapNode.goFilterEmpty.gameObject:SetActive(#self.tbPreselectionList == 0)
|
||||
self._mapNode.BuildList.gameObject:SetActive(#self.tbPreselectionList > 0)
|
||||
if #self.tbPreselectionList == 0 then
|
||||
return
|
||||
end
|
||||
table.sort(self.tbPreselectionList, function(a, b)
|
||||
if self.nSortOrder == SortOrder.Descending then
|
||||
return a.nTimestamp > b.nTimestamp
|
||||
else
|
||||
return a.nTimestamp < b.nTimestamp
|
||||
end
|
||||
end)
|
||||
self._mapNode.BuildList:Init(#self.tbPreselectionList, self, self.OnGridRefresh, self.OnGridBtnClick)
|
||||
end
|
||||
function PotentialPreselectionCtrl:OnGridRefresh(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local nInstanceId = goGrid:GetInstanceID()
|
||||
local objCtrl = self.mapGridCtrl[nInstanceId]
|
||||
if objCtrl == nil then
|
||||
objCtrl = self:BindCtrlByNode(goGrid, "Game.UI.PotentialPreselection.PotentialPreselectionItemCtrl")
|
||||
self.mapGridCtrl[nInstanceId] = objCtrl
|
||||
end
|
||||
local mapData = self.tbPreselectionList[nIndex]
|
||||
if mapData ~= nil then
|
||||
local bSelected = mapData.nId == self.nSelectPreselectionId
|
||||
local bCharDiff = false
|
||||
if self.tbSelectChar ~= nil then
|
||||
for i = 1, 3 do
|
||||
if self.tbSelectChar[i] == nil then
|
||||
self.tbSelectChar[i] = 0
|
||||
end
|
||||
end
|
||||
for k, v in ipairs(mapData.tbCharPotential) do
|
||||
if k == 1 then
|
||||
if v.nCharId ~= self.tbSelectChar[k] then
|
||||
bCharDiff = true
|
||||
break
|
||||
end
|
||||
elseif table.indexof(self.tbSelectChar, v.nCharId) == 0 then
|
||||
bCharDiff = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
objCtrl:RefreshItem(mapData, bCharDiff, bSelected)
|
||||
objCtrl:ShowDelete(self.nPanelType == PanelState.delete)
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionCtrl:OnGridBtnClick(goGrid, gridIndex)
|
||||
if self.nPanelType == PanelState.delete then
|
||||
return
|
||||
end
|
||||
local nIndex = gridIndex + 1
|
||||
local mapData = self.tbPreselectionList[nIndex]
|
||||
if mapData ~= nil then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.PotentialPreselectionEdit, AllEnum.PreselectionPanelType.Preview, mapData, self.tbSelectChar, self.nTeamIndex)
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionCtrl:FadeIn()
|
||||
if self._panel._nFadeInType == 1 then
|
||||
EventManager.Hit(EventId.SetTransition)
|
||||
if #self.tbPreselectionList > 0 then
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.4)
|
||||
end
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionCtrl:Awake()
|
||||
self.mapCacheFilter = {}
|
||||
self.tbOption = {
|
||||
AllEnum.ChooseOption.Char_Element
|
||||
}
|
||||
end
|
||||
function PotentialPreselectionCtrl:OnEnable()
|
||||
if next(self.mapCacheFilter) ~= nil then
|
||||
for fKey, data in pairs(self.mapCacheFilter) do
|
||||
for sKey, value in pairs(data) do
|
||||
PlayerData.Filter:SetCacheFilterByKey(fKey, sKey, value)
|
||||
end
|
||||
end
|
||||
PlayerData.Filter:SyncFilterByCache()
|
||||
end
|
||||
local tbParam = self:GetPanelParam()
|
||||
if type(tbParam) == "table" then
|
||||
self.tbSelectChar = tbParam[1]
|
||||
self.nTeamIndex = tbParam[2]
|
||||
end
|
||||
if self.nTeamIndex ~= nil then
|
||||
self.nSelectPreselectionId = PlayerData.Team:GetTeamPreselectionId(self.nTeamIndex)
|
||||
end
|
||||
self.mapGridCtrl = {}
|
||||
self.nPanelType = PanelState.normal
|
||||
self.nSortOrder = SortOrder.Descending
|
||||
self.nAllBuildCount = ConfigTable.GetConfigNumber("PotentialPreselectionMaxCount")
|
||||
self:InitSort()
|
||||
self:RefreshPanel()
|
||||
end
|
||||
function PotentialPreselectionCtrl:OnDisable()
|
||||
for nInstanceId, objCtrl in pairs(self.mapGridCtrl or {}) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.mapGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self.mapGridCtrl = {}
|
||||
self.mapCacheFilter = {}
|
||||
for _, fKey in ipairs(self.tbOption) do
|
||||
if self.mapCacheFilter[fKey] == nil then
|
||||
self.mapCacheFilter[fKey] = {}
|
||||
end
|
||||
local data = PlayerData.Filter:GetCacheFilter(fKey)
|
||||
if data ~= nil then
|
||||
for sKey, value in pairs(data) do
|
||||
self.mapCacheFilter[fKey][sKey] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
PlayerData.Filter:Reset(self.tbOption)
|
||||
end
|
||||
function PotentialPreselectionCtrl:OnDestroy()
|
||||
end
|
||||
function PotentialPreselectionCtrl:OnRelease()
|
||||
end
|
||||
function PotentialPreselectionCtrl:OnBtnClick_Delete()
|
||||
if self.nPanelType == PanelState.delete then
|
||||
return
|
||||
end
|
||||
self.nPanelType = PanelState.delete
|
||||
self:RefreshPanel()
|
||||
end
|
||||
function PotentialPreselectionCtrl:OnBtnClick_Import()
|
||||
if self.nPanelType == PanelState.delete then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Potential_Preselection_Import_Disable"))
|
||||
return
|
||||
end
|
||||
if #self.tbAllPreselectionList >= self.nAllBuildCount then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Potential_Preselection_Build_Max"))
|
||||
return
|
||||
end
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.ImportPreselection)
|
||||
end
|
||||
function PotentialPreselectionCtrl:OnBtnClick_SortTime()
|
||||
self.nSortOrder = not self.nSortOrder
|
||||
self._mapNode.btn_sort_time.transform:Find("AnimRoot/btn_AsceIcon"):GetComponent("Button").interactable = self.nSortOrder == SortOrder.Ascending
|
||||
self._mapNode.btn_sort_time.transform:Find("AnimRoot/btn_DescIcon"):GetComponent("Button").interactable = self.nSortOrder == SortOrder.Descending
|
||||
self:RefreshList()
|
||||
end
|
||||
function PotentialPreselectionCtrl:OnBtnClick_Filter()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.FilterPopupPanel, self.tbOption)
|
||||
end
|
||||
function PotentialPreselectionCtrl:OnBtnClick_Create()
|
||||
if #self.tbAllPreselectionList >= self.nAllBuildCount then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Potential_Preselection_Build_Max"))
|
||||
return
|
||||
end
|
||||
self._panel._nFadeInType = 2
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.PotentialPreselectionEdit, AllEnum.PreselectionPanelType.Create, {}, self.tbSelectChar, self.nTeamIndex)
|
||||
end
|
||||
function PotentialPreselectionCtrl:OnBtnClick_CloseDelete()
|
||||
self.nPanelType = PanelState.normal
|
||||
self:RefreshPanel()
|
||||
end
|
||||
function PotentialPreselectionCtrl:OnEvent_RefreshByFilter()
|
||||
self.mapCacheFilter = {}
|
||||
self.tbPreselectionList = {}
|
||||
for _, v in pairs(self.tbAllPreselectionList) do
|
||||
local mapMainChar = v.tbCharPotential[1]
|
||||
local nCharId = mapMainChar.nCharId
|
||||
local isFilter = PlayerData.Filter:CheckFilterByChar(nCharId)
|
||||
if isFilter then
|
||||
table.insert(self.tbPreselectionList, v)
|
||||
end
|
||||
end
|
||||
self:RefreshList()
|
||||
end
|
||||
function PotentialPreselectionCtrl:OnEvent_DeleteSuc()
|
||||
self.tbPreselectionList = nil
|
||||
self:RefreshList()
|
||||
end
|
||||
function PotentialPreselectionCtrl:OnEvent_RefreshPreselectionList()
|
||||
if self.nTeamIndex ~= nil then
|
||||
self.nSelectPreselectionId = PlayerData.Team:GetTeamPreselectionId(self.nTeamIndex)
|
||||
end
|
||||
self:RefreshList()
|
||||
end
|
||||
return PotentialPreselectionCtrl
|
||||
Reference in New Issue
Block a user