Update - 1.15.0.134
EN: 1.15.0.134 CN: 1.15.0.133 JP: 1.15.0.137 KR: 1.15.0.139
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
local LocalData = require("GameCore.Data.LocalData")
|
||||
local PotentialPreselectionCtrl = class("PotentialPreselectionCtrl", BaseCtrl)
|
||||
PotentialPreselectionCtrl._mapNodeConfig = {
|
||||
TopBar = {
|
||||
@@ -28,6 +29,16 @@ PotentialPreselectionCtrl._mapNodeConfig = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Import"
|
||||
},
|
||||
SystemRcmdSwitch = {},
|
||||
btnSwitch = {
|
||||
nCount = 2,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Switch"
|
||||
},
|
||||
txtSystemRcmdSwitch = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_System_Preset_Rcmd"
|
||||
},
|
||||
BuildList = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
@@ -48,6 +59,9 @@ PotentialPreselectionCtrl._mapNodeConfig = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Filter"
|
||||
},
|
||||
btnRoot = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
imgFilterChoose = {},
|
||||
btnCreate = {
|
||||
sComponentName = "UIButton",
|
||||
@@ -79,6 +93,79 @@ PotentialPreselectionCtrl._mapEventConfig = {
|
||||
PotentialPreselectionCtrl._mapRedDotConfig = {}
|
||||
local PanelState = {normal = 1, delete = 2}
|
||||
local SortOrder = {Descending = true, Ascending = false}
|
||||
local ShowSystemRcmdKey = "ShowSystemRecommend"
|
||||
function PotentialPreselectionCtrl:ConvertUnpackData(tbUnpackData)
|
||||
local tbCharPotential = {}
|
||||
if tbUnpackData == nil then
|
||||
return tbCharPotential
|
||||
end
|
||||
for _, mapCharData in ipairs(tbUnpackData) do
|
||||
local tbPotential = {}
|
||||
for _, mapPotential in ipairs(mapCharData.Potentials or {}) do
|
||||
table.insert(tbPotential, {
|
||||
nId = mapPotential.Id,
|
||||
nLevel = mapPotential.Level
|
||||
})
|
||||
end
|
||||
table.insert(tbCharPotential, {
|
||||
nCharId = mapCharData.CharId,
|
||||
tbPotential = tbPotential
|
||||
})
|
||||
end
|
||||
return tbCharPotential
|
||||
end
|
||||
function PotentialPreselectionCtrl:RefreshSelectCharFromTeam()
|
||||
if self.nTeamIndex == nil or self.nTeamIndex <= 0 then
|
||||
return
|
||||
end
|
||||
local _, tbTeamMemberId = PlayerData.Team:GetTeamData(self.nTeamIndex)
|
||||
if tbTeamMemberId == nil then
|
||||
return
|
||||
end
|
||||
self.tbSelectChar = {}
|
||||
for i = 1, 3 do
|
||||
self.tbSelectChar[i] = tbTeamMemberId[i] or 0
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionCtrl:GetSystemRecommendList()
|
||||
local tbList = {}
|
||||
if not self.bShowSystemRecommend or self.tbSelectChar == nil then
|
||||
return tbList
|
||||
end
|
||||
local mapTeamCharId = {}
|
||||
for i = 1, 3 do
|
||||
local nCharId = self.tbSelectChar[i]
|
||||
if nCharId ~= nil and 0 < nCharId then
|
||||
mapTeamCharId[nCharId] = true
|
||||
end
|
||||
end
|
||||
if next(mapTeamCharId) == nil then
|
||||
return tbList
|
||||
end
|
||||
local tbPotentialPreset = ConfigTable.Get("PotentialPreset")
|
||||
ForEachTableLine(tbPotentialPreset, function(mapCfg)
|
||||
if mapTeamCharId[mapCfg.CharacterId] == true then
|
||||
local tbUnpackData = PlayerData.PotentialPreselection:UnPackPotentialData(mapCfg.ShareCode)
|
||||
if tbUnpackData ~= nil then
|
||||
table.insert(tbList, {
|
||||
nId = mapCfg.Id,
|
||||
nSystemPresetId = mapCfg.Id,
|
||||
nTimestamp = 0,
|
||||
sName = mapCfg.Name,
|
||||
sDescription = mapCfg.Description,
|
||||
sShareCode = mapCfg.ShareCode,
|
||||
bPreference = false,
|
||||
bSystemRecommend = true,
|
||||
tbCharPotential = self:ConvertUnpackData(tbUnpackData)
|
||||
})
|
||||
end
|
||||
end
|
||||
end)
|
||||
table.sort(tbList, function(a, b)
|
||||
return a.nSystemPresetId < b.nSystemPresetId
|
||||
end)
|
||||
return tbList
|
||||
end
|
||||
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
|
||||
@@ -88,25 +175,42 @@ function PotentialPreselectionCtrl:RefreshPanel()
|
||||
self:RefreshList()
|
||||
end
|
||||
function PotentialPreselectionCtrl:RefreshList()
|
||||
self:RefreshSelectCharFromTeam()
|
||||
self.tbAllPreselectionList = PlayerData.PotentialPreselection:GetPreselectionList()
|
||||
self.tbPreselectionList = {}
|
||||
local tbNormalPreselectionList = {}
|
||||
for _, v in pairs(self.tbAllPreselectionList) do
|
||||
local mapMainChar = v.tbCharPotential[1]
|
||||
local nCharId = mapMainChar.nCharId
|
||||
local isFilter = PlayerData.Filter:CheckFilterByCharAndOption(nCharId, self._panel.tbOption)
|
||||
if isFilter then
|
||||
table.insert(self.tbPreselectionList, v)
|
||||
table.insert(tbNormalPreselectionList, v)
|
||||
end
|
||||
end
|
||||
table.sort(tbNormalPreselectionList, function(a, b)
|
||||
if self.nSortOrder == SortOrder.Descending then
|
||||
return a.nTimestamp > b.nTimestamp
|
||||
else
|
||||
return a.nTimestamp < b.nTimestamp
|
||||
end
|
||||
end)
|
||||
local tbSystemRecommendList = self:GetSystemRecommendList()
|
||||
for _, mapData in ipairs(tbSystemRecommendList) do
|
||||
table.insert(self.tbPreselectionList, mapData)
|
||||
end
|
||||
for _, mapData in ipairs(tbNormalPreselectionList) do
|
||||
table.insert(self.tbPreselectionList, mapData)
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txt_BuildCount, string.format("%d/%d", #self.tbAllPreselectionList, self.nAllBuildCount))
|
||||
local isDirty = PlayerData.Filter:IsDirtyByOption(self._panel.tbOption)
|
||||
self._mapNode.imgFilterChoose:SetActive(isDirty)
|
||||
local bEmpty = #self.tbAllPreselectionList == 0
|
||||
local bEmpty = #self.tbAllPreselectionList == 0 and #tbSystemRecommendList == 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)
|
||||
CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.btnRoot)
|
||||
for nInstanceId, objCtrl in pairs(self.mapGridCtrl or {}) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.mapGridCtrl[nInstanceId] = nil
|
||||
@@ -119,13 +223,6 @@ function PotentialPreselectionCtrl:RefreshList()
|
||||
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)
|
||||
@@ -138,28 +235,28 @@ function PotentialPreselectionCtrl:OnGridRefresh(goGrid, gridIndex)
|
||||
end
|
||||
local mapData = self.tbPreselectionList[nIndex]
|
||||
if mapData ~= nil then
|
||||
local bSelected = mapData.nId == self.nSelectPreselectionId
|
||||
local bSelected = mapData.bSystemRecommend ~= true and mapData.nId == self.nSelectPreselectionId
|
||||
local bCharDiff = false
|
||||
if self.tbSelectChar ~= nil then
|
||||
local tbSelectChar = {}
|
||||
for i = 1, 3 do
|
||||
if self.tbSelectChar[i] == nil then
|
||||
self.tbSelectChar[i] = 0
|
||||
end
|
||||
tbSelectChar[i] = self.tbSelectChar[i] or 0
|
||||
end
|
||||
for k, v in ipairs(mapData.tbCharPotential) do
|
||||
if k == 1 then
|
||||
if v.nCharId ~= self.tbSelectChar[k] then
|
||||
if v.nCharId ~= tbSelectChar[k] then
|
||||
bCharDiff = true
|
||||
break
|
||||
end
|
||||
elseif table.indexof(self.tbSelectChar, v.nCharId) == 0 then
|
||||
elseif table.indexof(tbSelectChar, v.nCharId) == 0 then
|
||||
bCharDiff = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
objCtrl:RefreshItem(mapData, bCharDiff, bSelected)
|
||||
objCtrl:ShowDelete(self.nPanelType == PanelState.delete)
|
||||
local bSystemRecommend = mapData.bSystemRecommend == true
|
||||
objCtrl:RefreshItem(mapData, bCharDiff, bSelected, bSystemRecommend)
|
||||
objCtrl:ShowDelete(self.nPanelType == PanelState.delete and not bSystemRecommend)
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionCtrl:OnGridBtnClick(goGrid, gridIndex)
|
||||
@@ -169,7 +266,11 @@ function PotentialPreselectionCtrl:OnGridBtnClick(goGrid, gridIndex)
|
||||
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)
|
||||
if mapData.bSystemRecommend == true then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.PotentialPreselectionEdit, AllEnum.PreselectionPanelType.SystemPreview, mapData, self.tbSelectChar or {}, self.nTeamIndex or 0, mapData.sName)
|
||||
else
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.PotentialPreselectionEdit, AllEnum.PreselectionPanelType.Preview, mapData, self.tbSelectChar, self.nTeamIndex)
|
||||
end
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionCtrl:FadeIn()
|
||||
@@ -191,10 +292,15 @@ function PotentialPreselectionCtrl:OnEnable()
|
||||
end
|
||||
PlayerData.Filter:SyncFilterByCache()
|
||||
end
|
||||
self.tbSelectChar = nil
|
||||
self.nTeamIndex = nil
|
||||
self.bEnableSystemRecommend = false
|
||||
self.nSelectPreselectionId = nil
|
||||
local tbParam = self:GetPanelParam()
|
||||
if type(tbParam) == "table" then
|
||||
self.tbSelectChar = tbParam[1]
|
||||
self.nTeamIndex = tbParam[2]
|
||||
self.bEnableSystemRecommend = tbParam[3] == true
|
||||
end
|
||||
if self.nTeamIndex ~= nil then
|
||||
self.nSelectPreselectionId = PlayerData.Team:GetTeamPreselectionId(self.nTeamIndex)
|
||||
@@ -203,6 +309,21 @@ function PotentialPreselectionCtrl:OnEnable()
|
||||
self.nPanelType = PanelState.normal
|
||||
self.nSortOrder = SortOrder.Descending
|
||||
self.nAllBuildCount = ConfigTable.GetConfigNumber("PotentialPreselectionMaxCount")
|
||||
local bHasTeamChar = false
|
||||
if self.tbSelectChar ~= nil then
|
||||
for i = 1, 3 do
|
||||
local nCharId = self.tbSelectChar[i]
|
||||
if nCharId ~= nil and 0 < nCharId then
|
||||
bHasTeamChar = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
self.bEnableSystemRecommend = self.bEnableSystemRecommend and bHasTeamChar
|
||||
self.bShowSystemRecommend = self.bEnableSystemRecommend and (LocalData.GetPlayerLocalData(ShowSystemRcmdKey) == "1" or LocalData.GetPlayerLocalData(ShowSystemRcmdKey) == nil)
|
||||
self._mapNode.SystemRcmdSwitch.gameObject:SetActive(self.bEnableSystemRecommend)
|
||||
self._mapNode.btnSwitch[2].gameObject:SetActive(self.bShowSystemRecommend)
|
||||
self._mapNode.btnSwitch[1].gameObject:SetActive(not self.bShowSystemRecommend)
|
||||
self:InitSort()
|
||||
self:RefreshPanel()
|
||||
end
|
||||
@@ -264,6 +385,22 @@ function PotentialPreselectionCtrl:OnBtnClick_Create()
|
||||
self._panel._nFadeInType = 2
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.PotentialPreselectionEdit, AllEnum.PreselectionPanelType.Create, {}, self.tbSelectChar, self.nTeamIndex)
|
||||
end
|
||||
function PotentialPreselectionCtrl:OnBtnClick_Switch(btn, nIndex)
|
||||
if not self.bEnableSystemRecommend then
|
||||
return
|
||||
end
|
||||
self.bShowSystemRecommend = not self.bShowSystemRecommend
|
||||
LocalData.SetPlayerLocalData(ShowSystemRcmdKey, self.bShowSystemRecommend and "1" or "0")
|
||||
self._mapNode.btnSwitch[2].gameObject:SetActive(self.bShowSystemRecommend)
|
||||
self._mapNode.btnSwitch[1].gameObject:SetActive(not self.bShowSystemRecommend)
|
||||
local sTip = self.bShowSystemRecommend and ConfigTable.GetUIText("Potential_Preselection_SystemRecommend_Show") or ConfigTable.GetUIText("Potential_Preselection_SystemRecommend_Hide")
|
||||
EventManager.Hit(EventId.OpenMessageBox, {
|
||||
nType = AllEnum.MessageBox.Tips,
|
||||
bPositive = true,
|
||||
sContent = sTip
|
||||
})
|
||||
self:RefreshList()
|
||||
end
|
||||
function PotentialPreselectionCtrl:OnBtnClick_CloseDelete()
|
||||
self.nPanelType = PanelState.normal
|
||||
self:RefreshPanel()
|
||||
|
||||
@@ -174,6 +174,12 @@ PotentialPreselectionEditCtrl._mapEventConfig = {
|
||||
PotentialPreselectionEditCtrl._mapRedDotConfig = {}
|
||||
local COLOR_PREFER = Color(0.14901960784313725, 0.25882352941176473, 0.47058823529411764)
|
||||
local COLOR_NO_PREFER = Color(0.5803921568627451, 0.6666666666666666, 0.7529411764705882)
|
||||
function PotentialPreselectionEditCtrl:IsPreviewMode()
|
||||
return self._panel.nPanelType == AllEnum.PreselectionPanelType.Preview or self._panel.nPanelType == AllEnum.PreselectionPanelType.SystemPreview
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:IsSystemPreviewMode()
|
||||
return self._panel.nPanelType == AllEnum.PreselectionPanelType.SystemPreview
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:InitSelectList()
|
||||
self.tbSelectCharList = {}
|
||||
if self.initPreselectData ~= nil and next(self.initPreselectData) ~= nil then
|
||||
@@ -203,14 +209,25 @@ function PotentialPreselectionEditCtrl:ChangePanel()
|
||||
if self.nTeamIndex == nil or self.curPreselectData == nil then
|
||||
return
|
||||
end
|
||||
self._mapNode.btnPreviewRoot.gameObject:SetActive(self._panel.nPanelType == AllEnum.PreselectionPanelType.Preview)
|
||||
self._mapNode.btnEditRoot.gameObject:SetActive(self._panel.nPanelType ~= AllEnum.PreselectionPanelType.Preview)
|
||||
local bPreviewMode = self:IsPreviewMode()
|
||||
local bSystemPreview = self:IsSystemPreviewMode()
|
||||
local bSystemPreviewWithTeam = bSystemPreview and self.nTeamIndex > 0
|
||||
self._mapNode.btnPreviewRoot.gameObject:SetActive(bPreviewMode)
|
||||
self._mapNode.btnEditRoot.gameObject:SetActive((not bPreviewMode or bSystemPreview) and not bSystemPreviewWithTeam)
|
||||
self._mapNode.btn_Preference.gameObject:SetActive(self._panel.nPanelType == AllEnum.PreselectionPanelType.Preview)
|
||||
self._mapNode.btnEditName.gameObject:SetActive(self._panel.nPanelType == AllEnum.PreselectionPanelType.Preview)
|
||||
self._mapNode.btnEdit.gameObject:SetActive(not bSystemPreview)
|
||||
self._mapNode.btnShare.gameObject:SetActive(not bSystemPreview)
|
||||
self._mapNode.btnDelete.gameObject:SetActive(not bSystemPreview)
|
||||
self._mapNode.btnAbandon.gameObject:SetActive(not bSystemPreview)
|
||||
self._mapNode.btnSave.gameObject:SetActive((bSystemPreview or not bPreviewMode) and not bSystemPreviewWithTeam)
|
||||
if self.nTeamIndex > 0 and self._panel.nPanelType == AllEnum.PreselectionPanelType.Preview then
|
||||
local nPreselectionId = PlayerData.Team:GetTeamPreselectionId(self.nTeamIndex)
|
||||
self._mapNode.btnUse.gameObject:SetActive(nPreselectionId ~= self.curPreselectData.nId)
|
||||
self._mapNode.btnCancel.gameObject:SetActive(nPreselectionId == self.curPreselectData.nId)
|
||||
elseif self.nTeamIndex > 0 and bSystemPreview then
|
||||
self._mapNode.btnUse.gameObject:SetActive(true)
|
||||
self._mapNode.btnCancel.gameObject:SetActive(false)
|
||||
else
|
||||
self._mapNode.btnUse.gameObject:SetActive(false)
|
||||
self._mapNode.btnCancel.gameObject:SetActive(false)
|
||||
@@ -236,7 +253,7 @@ function PotentialPreselectionEditCtrl:RefreshContent()
|
||||
end
|
||||
self:RefreshCharList()
|
||||
self:RefreshPotentialList()
|
||||
if self._panel.nPanelType ~= AllEnum.PreselectionPanelType.Preview and self.bShowCharList then
|
||||
if not self:IsPreviewMode() and self.bShowCharList then
|
||||
local tbSelect = {}
|
||||
for _, v in ipairs(self.tbSelectCharList) do
|
||||
table.insert(tbSelect, v.nCharId)
|
||||
@@ -292,7 +309,7 @@ function PotentialPreselectionEditCtrl:RefreshPotentialList()
|
||||
end
|
||||
nPotentialCount = nPotentialCount + nAllCount
|
||||
if self.nSelectId == nil then
|
||||
if self._panel.nPanelType == AllEnum.PreselectionPanelType.Preview then
|
||||
if self:IsPreviewMode() then
|
||||
if nSelectId ~= 0 then
|
||||
self.nSelectId = nSelectId
|
||||
end
|
||||
@@ -315,7 +332,7 @@ function PotentialPreselectionEditCtrl:RefreshPotentialList()
|
||||
else
|
||||
self._mapNode.potentialCardRoot.gameObject:SetActive(false)
|
||||
end
|
||||
self._mapNode.potentialEmpty.gameObject:SetActive(self._panel.nPanelType == AllEnum.PreselectionPanelType.Preview and nPotentialCount == 0)
|
||||
self._mapNode.potentialEmpty.gameObject:SetActive(self:IsPreviewMode() and nPotentialCount == 0)
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.rtPotentialContent)
|
||||
@@ -363,8 +380,8 @@ function PotentialPreselectionEditCtrl:RefreshSelectPotential(bPlayAnim)
|
||||
end
|
||||
self._mapNode.PotentialCard:SetPotentialItem(self.nSelectId, nLevel, nil, bSimple, nil, 0, AllEnum.PotentialCardType.CharInfo)
|
||||
self._mapNode.PotentialCard:ChangeWordRaycast(true)
|
||||
self._mapNode.goQuantitySelector.gameObject:SetActive(self._panel.nPanelType ~= AllEnum.PreselectionPanelType.Preview)
|
||||
if self._panel.nPanelType ~= AllEnum.PreselectionPanelType.Preview then
|
||||
self._mapNode.goQuantitySelector.gameObject:SetActive(not self:IsPreviewMode())
|
||||
if not self:IsPreviewMode() then
|
||||
local callback = function(nCount)
|
||||
self.nSelectLevel = nCount
|
||||
self:RefreshPotentialCount()
|
||||
@@ -469,7 +486,7 @@ function PotentialPreselectionEditCtrl:SetEmpty()
|
||||
self._mapNode.txtPotentialCount[i].gameObject:SetActive(false)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCharName[i], ConfigTable.GetUIText("Potential_Preselection_Char_Empty"))
|
||||
end
|
||||
if self._panel.nPanelType ~= AllEnum.PreselectionPanelType.Preview then
|
||||
if not self:IsPreviewMode() then
|
||||
local tbSelect = {}
|
||||
for _, v in ipairs(self.tbSelectCharList) do
|
||||
table.insert(tbSelect, v.nCharId)
|
||||
@@ -532,6 +549,7 @@ function PotentialPreselectionEditCtrl:Awake()
|
||||
self.initPreselectData = tbParam[2]
|
||||
self.tbBuildChar = tbParam[3]
|
||||
self.nTeamIndex = tbParam[4] or 0
|
||||
self.sPresetName = tbParam[5] or ""
|
||||
self.bShowCharList = false
|
||||
self.curPreselectData = nil
|
||||
end
|
||||
@@ -578,7 +596,7 @@ function PotentialPreselectionEditCtrl:OnBtnClick_EditName()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.PreselectionRename, self.curPreselectData, callback, self._panel.nPanelType ~= AllEnum.PreselectionPanelType.Preview)
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnBtnClick_CharList()
|
||||
if self._mapNode.goCharList.gameObject.activeSelf or self._panel.nPanelType == AllEnum.PreselectionPanelType.Preview then
|
||||
if self._mapNode.goCharList.gameObject.activeSelf or self:IsPreviewMode() then
|
||||
return
|
||||
end
|
||||
self.bShowCharList = true
|
||||
@@ -606,6 +624,147 @@ function PotentialPreselectionEditCtrl:OnBtnClick_Preference()
|
||||
PlayerData.PotentialPreselection:SendPreselectionPreference(tbCheckIn, tbCheckOut, callback)
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:GetSaveCharPotential()
|
||||
local tbCharPotential = {}
|
||||
for _, mapData in ipairs(self.tbSelectCharList) do
|
||||
local tbPotential = {}
|
||||
local nCharId = mapData.nCharId
|
||||
for _, tb in ipairs(mapData.tbPotential or {}) do
|
||||
for _, data in ipairs(tb) do
|
||||
if data.nLevel > 0 then
|
||||
local mapPotentialCfg = ConfigTable.GetData("Potential", data.nId)
|
||||
if mapPotentialCfg ~= nil then
|
||||
table.insert(tbPotential, {
|
||||
Id = data.nId,
|
||||
Level = data.nLevel
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
table.insert(tbCharPotential, {CharId = nCharId, Potentials = tbPotential})
|
||||
end
|
||||
return tbCharPotential
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:CheckSavePreselectionLimit()
|
||||
local tbAllPreselectionList = PlayerData.PotentialPreselection:GetPreselectionList()
|
||||
local nAllCount = ConfigTable.GetConfigNumber("PotentialPreselectionMaxCount")
|
||||
if nAllCount <= #tbAllPreselectionList then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Potential_Preselection_Build_Max"))
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:GetSystemPreviewSaveName()
|
||||
local sName = ConfigTable.GetUIText("Potential_Preselection_Name_Init")
|
||||
if self.sPresetName ~= nil and self.sPresetName ~= "" then
|
||||
sName = self.sPresetName
|
||||
end
|
||||
return sName
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:NormalizeShareCode(sShareCode)
|
||||
if sShareCode == nil or sShareCode == "" then
|
||||
return nil
|
||||
end
|
||||
sShareCode = sShareCode:gsub("-", "+")
|
||||
sShareCode = sShareCode:gsub("_", "/")
|
||||
local nMod = #sShareCode % 4
|
||||
if nMod ~= 0 then
|
||||
sShareCode = sShareCode .. string.rep("=", 4 - nMod)
|
||||
end
|
||||
return sShareCode
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:GetSavedSystemPreviewPreselection()
|
||||
local sSystemShareCode = self:NormalizeShareCode(self.curPreselectData and self.curPreselectData.sShareCode)
|
||||
if sSystemShareCode == nil then
|
||||
return nil
|
||||
end
|
||||
local tbAllPreselectionList = PlayerData.PotentialPreselection:GetPreselectionList()
|
||||
for _, mapPreselection in ipairs(tbAllPreselectionList) do
|
||||
local sShareCode = self:NormalizeShareCode(PlayerData.PotentialPreselection:PackPotentialData(mapPreselection.tbCharPotential))
|
||||
if sShareCode == sSystemShareCode then
|
||||
return mapPreselection
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:SaveSystemPreviewPreselection(callback)
|
||||
if not self:CheckSavePreselectionLimit() then
|
||||
return
|
||||
end
|
||||
PlayerData.PotentialPreselection:SavePreselectionFromRank(self:GetSystemPreviewSaveName(), false, self:GetSaveCharPotential(), callback)
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:ApplyPreselectionToTeam(nPreselectionId, bUsePresetTeam)
|
||||
local callback = function()
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Potential_Preselection_Select_Suc"))
|
||||
self:ClosePanel(true)
|
||||
end
|
||||
local tmpDisc = PlayerData.Team:GetTeamDiscData(self.nTeamIndex)
|
||||
local tbTeamMemberId
|
||||
if bUsePresetTeam then
|
||||
tbTeamMemberId = {}
|
||||
for _, v in ipairs(self.tbSelectCharList) do
|
||||
table.insert(tbTeamMemberId, v.nCharId)
|
||||
end
|
||||
else
|
||||
_, tbTeamMemberId = PlayerData.Team:GetTeamData(self.nTeamIndex)
|
||||
end
|
||||
PlayerData.Team:UpdateFormationInfo(self.nTeamIndex, tbTeamMemberId, tmpDisc, nPreselectionId, callback)
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:SaveAndApplySystemPreview(bUsePresetTeam)
|
||||
self:SaveSystemPreviewPreselection(function(mapBuildData)
|
||||
if mapBuildData ~= nil then
|
||||
self:ApplyPreselectionToTeam(mapBuildData.nId, bUsePresetTeam)
|
||||
end
|
||||
end)
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnBtnClick_UseSystemPreview(bCharDiff, bCharLock)
|
||||
local SaveAndApply = function(bApply)
|
||||
local mapSavedPreselection = self:GetSavedSystemPreviewPreselection()
|
||||
if mapSavedPreselection ~= nil then
|
||||
self:ApplyPreselectionToTeam(mapSavedPreselection.nId, bCharDiff and bApply)
|
||||
return
|
||||
end
|
||||
local sTipsKey = "Potential_Preselection_SystemRcmd_Same"
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Confirm,
|
||||
sContent = ConfigTable.GetUIText(sTipsKey),
|
||||
callbackConfirm = function()
|
||||
self:SaveAndApplySystemPreview(bCharDiff and bApply)
|
||||
end
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
end
|
||||
if bCharLock then
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Confirm,
|
||||
sContent = ConfigTable.GetUIText("Potential_Preselection_Char_Lock_Tip"),
|
||||
callbackConfirm = function()
|
||||
SaveAndApply(false)
|
||||
end,
|
||||
callbackCancel = function()
|
||||
self:ClosePanel()
|
||||
end
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
elseif bCharDiff then
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Confirm,
|
||||
sContent = ConfigTable.GetUIText("Potential_Preselection_Build_Auto"),
|
||||
callbackConfirm = function()
|
||||
if self.nTeamIndex > 0 then
|
||||
SaveAndApply(true)
|
||||
end
|
||||
end,
|
||||
callbackCancel = function()
|
||||
SaveAndApply(false)
|
||||
end
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
else
|
||||
SaveAndApply(true)
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnBtnClick_Use()
|
||||
local bCharDiff = false
|
||||
local bCharLock = false
|
||||
@@ -621,18 +780,16 @@ function PotentialPreselectionEditCtrl:OnBtnClick_Use()
|
||||
bCharLock = true
|
||||
end
|
||||
end
|
||||
if self:IsSystemPreviewMode() then
|
||||
self:OnBtnClick_UseSystemPreview(bCharDiff, bCharLock)
|
||||
return
|
||||
end
|
||||
if bCharLock then
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Confirm,
|
||||
sContent = ConfigTable.GetUIText("Potential_Preselection_Char_Lock_Tip"),
|
||||
callbackConfirm = function()
|
||||
local callback = function()
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Potential_Preselection_Select_Suc"))
|
||||
self:ClosePanel(true)
|
||||
end
|
||||
local tmpDisc = PlayerData.Team:GetTeamDiscData(self.nTeamIndex)
|
||||
local _, tbTeamMemberId = PlayerData.Team:GetTeamData(self.nTeamIndex)
|
||||
PlayerData.Team:UpdateFormationInfo(self.nTeamIndex, tbTeamMemberId, tmpDisc, self.curPreselectData.nId, callback)
|
||||
self:ApplyPreselectionToTeam(self.curPreselectData.nId, false)
|
||||
end,
|
||||
callbackCancel = function()
|
||||
self:ClosePanel()
|
||||
@@ -645,37 +802,16 @@ function PotentialPreselectionEditCtrl:OnBtnClick_Use()
|
||||
sContent = ConfigTable.GetUIText("Potential_Preselection_Build_Auto"),
|
||||
callbackConfirm = function()
|
||||
if self.nTeamIndex > 0 then
|
||||
local callback = function()
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Potential_Preselection_Select_Suc"))
|
||||
self:ClosePanel(true)
|
||||
end
|
||||
local tmpDisc = PlayerData.Team:GetTeamDiscData(self.nTeamIndex)
|
||||
local tbTeam = {}
|
||||
for _, v in ipairs(self.tbSelectCharList) do
|
||||
table.insert(tbTeam, v.nCharId)
|
||||
end
|
||||
PlayerData.Team:UpdateFormationInfo(self.nTeamIndex, tbTeam, tmpDisc, self.curPreselectData.nId, callback)
|
||||
self:ApplyPreselectionToTeam(self.curPreselectData.nId, true)
|
||||
end
|
||||
end,
|
||||
callbackCancel = function()
|
||||
local callback = function()
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Potential_Preselection_Select_Suc"))
|
||||
self:ClosePanel(true)
|
||||
end
|
||||
local tmpDisc = PlayerData.Team:GetTeamDiscData(self.nTeamIndex)
|
||||
local _, tbTeamMemberId = PlayerData.Team:GetTeamData(self.nTeamIndex)
|
||||
PlayerData.Team:UpdateFormationInfo(self.nTeamIndex, tbTeamMemberId, tmpDisc, self.curPreselectData.nId, callback)
|
||||
self:ApplyPreselectionToTeam(self.curPreselectData.nId, false)
|
||||
end
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
else
|
||||
local callback = function()
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Potential_Preselection_Select_Suc"))
|
||||
self:ClosePanel(true)
|
||||
end
|
||||
local tmpDisc = PlayerData.Team:GetTeamDiscData(self.nTeamIndex)
|
||||
local _, tbTeamMemberId = PlayerData.Team:GetTeamData(self.nTeamIndex)
|
||||
PlayerData.Team:UpdateFormationInfo(self.nTeamIndex, tbTeamMemberId, tmpDisc, self.curPreselectData.nId, callback)
|
||||
self:ApplyPreselectionToTeam(self.curPreselectData.nId, false)
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnBtnClick_Cancel()
|
||||
@@ -730,26 +866,14 @@ function PotentialPreselectionEditCtrl:OnBtnClick_Delete()
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnBtnClick_Save()
|
||||
local tbCharPotential = {}
|
||||
for k, mapData in ipairs(self.tbSelectCharList) do
|
||||
local tbPotential = {}
|
||||
local nCharId = mapData.nCharId
|
||||
for nType, tb in ipairs(mapData.tbPotential) do
|
||||
for _, data in ipairs(tb) do
|
||||
if data.nLevel > 0 then
|
||||
local mapPotentialCfg = ConfigTable.GetData("Potential", data.nId)
|
||||
if mapPotentialCfg ~= nil then
|
||||
table.insert(tbPotential, {
|
||||
Id = data.nId,
|
||||
Level = data.nLevel
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
table.insert(tbCharPotential, {CharId = nCharId, Potentials = tbPotential})
|
||||
end
|
||||
local tbCharPotential = self:GetSaveCharPotential()
|
||||
local bSystemPreview = self:IsSystemPreviewMode()
|
||||
local callback = function(mapBuildData)
|
||||
if bSystemPreview then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Potential_Preselection_Save_Form_Rank"))
|
||||
EventManager.Hit("RefreshPreselectionList")
|
||||
return
|
||||
end
|
||||
self.initPreselectData = mapBuildData
|
||||
self.curPreselectData = clone(self.initPreselectData)
|
||||
self._panel.nPanelType = AllEnum.PreselectionPanelType.Preview
|
||||
@@ -759,6 +883,8 @@ function PotentialPreselectionEditCtrl:OnBtnClick_Save()
|
||||
local sName = self.curPreselectData.sName
|
||||
local bPreference = self.curPreselectData.bPreference
|
||||
PlayerData.PotentialPreselection:SavePreselection(sName, bPreference, tbCharPotential, callback)
|
||||
elseif self:IsSystemPreviewMode() then
|
||||
self:SaveSystemPreviewPreselection(callback)
|
||||
else
|
||||
PlayerData.PotentialPreselection:SendUpdatePotential(self.curPreselectData.nId, tbCharPotential, callback)
|
||||
end
|
||||
@@ -861,7 +987,7 @@ function PotentialPreselectionEditCtrl:OnEvent_SelectPotential(nPotentialId, nLe
|
||||
self:RefreshSelectPotential(bPlayAnim)
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnEvent_Back()
|
||||
if self._panel.nPanelType ~= AllEnum.PreselectionPanelType.Preview then
|
||||
if not self:IsPreviewMode() then
|
||||
if self.bShowCharList then
|
||||
local bCloseCharList = true
|
||||
if self._panel.nPanelType == AllEnum.PreselectionPanelType.Create then
|
||||
@@ -902,7 +1028,7 @@ function PotentialPreselectionEditCtrl:OnEvent_Back()
|
||||
self:ClosePanel()
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnEvent_BackHome()
|
||||
if self._panel.nPanelType ~= AllEnum.PreselectionPanelType.Preview then
|
||||
if not self:IsPreviewMode() then
|
||||
local bChange, tbChangeChar = self:CheckChange()
|
||||
if bChange then
|
||||
local msg = {
|
||||
|
||||
@@ -26,16 +26,22 @@ PotentialPreselectionItemCtrl._mapNodeConfig = {
|
||||
sLanguageId = "Potential_Preselection_Select"
|
||||
},
|
||||
goMask = {},
|
||||
txtMask = {sComponentName = "TMP_Text"}
|
||||
txtMask = {sComponentName = "TMP_Text"},
|
||||
imgSystemRecommend = {},
|
||||
txtSystemRecmd = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_System_Preset_Title"
|
||||
}
|
||||
}
|
||||
PotentialPreselectionItemCtrl._mapEventConfig = {}
|
||||
PotentialPreselectionItemCtrl._mapRedDotConfig = {}
|
||||
function PotentialPreselectionItemCtrl:RefreshItem(mapData, bCharDiff, bSelect)
|
||||
function PotentialPreselectionItemCtrl:RefreshItem(mapData, bCharDiff, bSelect, bSystemRecommend)
|
||||
self.mapData = mapData
|
||||
self:ShowDelete(false)
|
||||
self:SetSelect(bSelect)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtBuildName, mapData.sName)
|
||||
self._mapNode.imgLike.gameObject:SetActive(mapData.bPreference)
|
||||
self._mapNode.imgSystemRecommend.gameObject:SetActive(bSystemRecommend == true)
|
||||
local bCharLock = false
|
||||
for k, v in ipairs(mapData.tbCharPotential) do
|
||||
local nCharId = v.nCharId
|
||||
@@ -67,7 +73,7 @@ function PotentialPreselectionItemCtrl:RefreshItem(mapData, bCharDiff, bSelect)
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionItemCtrl:ShowDelete(bShow)
|
||||
if self.mapData ~= nil and not self.mapData.bPreference then
|
||||
if self.mapData ~= nil and not self.mapData.bPreference and self.mapData.bSystemRecommend ~= true then
|
||||
self._mapNode.btnDelete.gameObject:SetActive(bShow)
|
||||
else
|
||||
self._mapNode.btnDelete.gameObject:SetActive(false)
|
||||
@@ -86,6 +92,9 @@ end
|
||||
function PotentialPreselectionItemCtrl:OnDestroy()
|
||||
end
|
||||
function PotentialPreselectionItemCtrl:OnBtnClick_Delete()
|
||||
if self.mapData == nil or self.mapData.bSystemRecommend == true then
|
||||
return
|
||||
end
|
||||
if self.mapData ~= nil then
|
||||
local callback = function()
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Potential_Preselection_Delete_Suc"))
|
||||
|
||||
Reference in New Issue
Block a user