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,132 @@
|
||||
local CharPotentialListCtrl = class("CharPotentialListCtrl", BaseCtrl)
|
||||
CharPotentialListCtrl._mapNodeConfig = {
|
||||
txtCharName = {sComponentName = "TMP_Text"},
|
||||
txtHas = {sComponentName = "TMP_Text"},
|
||||
txtAll = {sComponentName = "TMP_Text"},
|
||||
imgHead = {sComponentName = "Image"},
|
||||
imgHeadFrame = {sComponentName = "Image"},
|
||||
PotentialStyle = {nCount = 3},
|
||||
txtPotentialTitle = {nCount = 2, sComponentName = "TMP_Text"},
|
||||
txtPotentialTitle3 = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Build_Common"
|
||||
},
|
||||
rtPotential = {
|
||||
nCount = 3,
|
||||
sComponentName = "RectTransform"
|
||||
}
|
||||
}
|
||||
CharPotentialListCtrl._mapEventConfig = {}
|
||||
CharPotentialListCtrl._mapRedDotConfig = {}
|
||||
function CharPotentialListCtrl:RefreshPotential(nCharId, mapPotential, goPotentialItem, bMaster, nPanelType)
|
||||
self.mapPotential = mapPotential
|
||||
self.mapPotentialCtrl = {}
|
||||
local charCfg = ConfigTable.GetData_Character(nCharId)
|
||||
if nil ~= charCfg then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCharName, charCfg.Name)
|
||||
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
|
||||
local skinCfg = ConfigTable.GetData_CharacterSkin(nSkinId)
|
||||
self:SetPngSprite(self._mapNode.imgHead, skinCfg.Icon, AllEnum.CharHeadIconSurfix.XXL)
|
||||
local sFrame = AllEnum.FrameType_New.BoardFrame .. AllEnum.BoardFrameColor[charCfg.Grade]
|
||||
self:SetAtlasSprite(self._mapNode.imgHeadFrame, "12_rare", sFrame)
|
||||
end
|
||||
local tbPotential = mapPotential
|
||||
local tbBuild1 = tbPotential[GameEnum.potentialBuild.PotentialBuild1] or {}
|
||||
local tbBuild2 = tbPotential[GameEnum.potentialBuild.PotentialBuild2] or {}
|
||||
local tbBuildCommon = tbPotential[GameEnum.potentialBuild.PotentialBuildCommon] or {}
|
||||
self._mapNode.PotentialStyle[1]:SetActive(0 < #tbBuild1)
|
||||
self._mapNode.PotentialStyle[2]:SetActive(0 < #tbBuild2)
|
||||
self._mapNode.PotentialStyle[3]:SetActive(0 < #tbBuildCommon)
|
||||
local nAllCount = #tbBuild1 + #tbBuild2 + #tbBuildCommon
|
||||
NovaAPI.SetTMPText(self._mapNode.txtAll, string.format("/%s", nAllCount))
|
||||
self.nHasCount = 0
|
||||
local nPotentialCount = 1
|
||||
local createPotentialItem = function(tbPotential, rtContent)
|
||||
if 0 < #tbPotential then
|
||||
for k, v in ipairs(tbPotential) do
|
||||
if nil == self.tbPotentialItemCtrl[nPotentialCount] then
|
||||
local itemObj = instantiate(goPotentialItem, rtContent)
|
||||
itemObj.gameObject:SetActive(true)
|
||||
local itemCtrl = self:BindCtrlByNode(itemObj, "Game.UI.StarTower.Depot.DepotPotentialItemCtrl")
|
||||
itemCtrl:InitItem(v.nId, v.nLevel, 0, true)
|
||||
table.insert(self.tbPotentialItemCtrl, itemCtrl)
|
||||
self.mapPotentialCtrl[v.nId] = itemCtrl
|
||||
else
|
||||
self.tbPotentialItemCtrl[nPotentialCount]:InitItem(v.nId, v.nLevel, 0, true)
|
||||
self.mapPotentialCtrl[v.nId] = self.tbPotentialItemCtrl[nPotentialCount]
|
||||
end
|
||||
self.nHasCount = self.nHasCount + v.nLevel
|
||||
nPotentialCount = nPotentialCount + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
local wait = function()
|
||||
createPotentialItem(tbBuild1, self._mapNode.rtPotential[1])
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
createPotentialItem(tbBuild2, self._mapNode.rtPotential[2])
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
createPotentialItem(tbBuildCommon, self._mapNode.rtPotential[3])
|
||||
local bShowAll = nPanelType == AllEnum.PreselectionPanelType.Edit or nPanelType == AllEnum.PreselectionPanelType.Create
|
||||
self:SwitchPotentialAll(bShowAll)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtHas, self.nHasCount)
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
self:SetPotentialBuildName(nCharId, bMaster)
|
||||
end
|
||||
function CharPotentialListCtrl:SwitchPotentialAll(bShowAll)
|
||||
local nPotentialIndex = 1
|
||||
for nStyle, tbSubMap in ipairs(self.mapPotential) do
|
||||
local bShowStyle = false
|
||||
for k, v in ipairs(tbSubMap) do
|
||||
if bShowAll then
|
||||
bShowStyle = true
|
||||
self.tbPotentialItemCtrl[nPotentialIndex].gameObject:SetActive(true)
|
||||
else
|
||||
local bShow = v.nLevel > 0
|
||||
self.tbPotentialItemCtrl[nPotentialIndex].gameObject:SetActive(bShow)
|
||||
if bShow then
|
||||
bShowStyle = true
|
||||
end
|
||||
end
|
||||
nPotentialIndex = nPotentialIndex + 1
|
||||
end
|
||||
self._mapNode.PotentialStyle[nStyle]:SetActive(bShowStyle)
|
||||
end
|
||||
self.gameObject:SetActive(bShowAll or 0 < self.nHasCount)
|
||||
end
|
||||
function CharPotentialListCtrl:SetPotentialBuildName(nCharId, bMaster)
|
||||
local charDescCfg = ConfigTable.GetData("CharacterDes", nCharId)
|
||||
if charDescCfg ~= nil then
|
||||
for i = 1, 2 do
|
||||
NovaAPI.SetTMPText(self._mapNode.txtPotentialTitle[i], bMaster and charDescCfg["PotentialMain" .. i] or charDescCfg["PotentialAssistant" .. i])
|
||||
end
|
||||
end
|
||||
end
|
||||
function CharPotentialListCtrl:RefreshPotentialLevel(nPotentialId, nLevel, nLastLevel)
|
||||
if nil ~= self.mapPotentialCtrl[nPotentialId] then
|
||||
self.mapPotentialCtrl[nPotentialId]:RefreshPreselectionLevel(nLevel)
|
||||
self.nHasCount = self.nHasCount - nLastLevel + nLevel
|
||||
NovaAPI.SetTMPText(self._mapNode.txtHas, self.nHasCount)
|
||||
end
|
||||
end
|
||||
function CharPotentialListCtrl:ShowAllCount(bShowAll)
|
||||
self._mapNode.txtAll.gameObject:SetActive(bShowAll)
|
||||
end
|
||||
function CharPotentialListCtrl:Awake()
|
||||
self.tbPotentialItemCtrl = {}
|
||||
self.mapPotential = {}
|
||||
end
|
||||
function CharPotentialListCtrl:OnEnable()
|
||||
end
|
||||
function CharPotentialListCtrl:OnDisable()
|
||||
for nInstanceId, objCtrl in pairs(self.tbPotentialItemCtrl) do
|
||||
local obj = objCtrl.gameObject
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbPotentialItemCtrl[nInstanceId] = nil
|
||||
destroy(obj)
|
||||
end
|
||||
self.tbPotentialItemCtrl = {}
|
||||
end
|
||||
function CharPotentialListCtrl:OnDestroy()
|
||||
end
|
||||
return CharPotentialListCtrl
|
||||
@@ -0,0 +1,84 @@
|
||||
local ImportPreselectionCtrl = class("ImportPreselectionCtrl", BaseCtrl)
|
||||
ImportPreselectionCtrl._mapNodeConfig = {
|
||||
txtWindowTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Import_Title"
|
||||
},
|
||||
txtCodeDesc = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Import_Input"
|
||||
},
|
||||
input = {
|
||||
sComponentName = "TMP_InputField",
|
||||
callback = "OnValueChanged_Import"
|
||||
},
|
||||
btnClose = {sComponentName = "UIButton", callback = "ClosePanel"},
|
||||
btnClose1 = {sComponentName = "UIButton", callback = "ClosePanel"},
|
||||
btnConfirm2 = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Confirm"
|
||||
},
|
||||
txtBtnConfirm = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "MessageBox_Confirm"
|
||||
},
|
||||
animator = {
|
||||
sNodeName = "---Import---",
|
||||
sComponentName = "Animator"
|
||||
}
|
||||
}
|
||||
ImportPreselectionCtrl._mapEventConfig = {}
|
||||
function ImportPreselectionCtrl:Refresh()
|
||||
NovaAPI.SetTMPInputFieldText(self._mapNode.input, "")
|
||||
end
|
||||
function ImportPreselectionCtrl:PlayInAni()
|
||||
self.gameObject:SetActive(true)
|
||||
self._mapNode.animator:Play("t_window_04_t_in")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.3)
|
||||
end
|
||||
function ImportPreselectionCtrl:PlayOutAni(callback)
|
||||
self._mapNode.animator:Play("t_window_04_t_out")
|
||||
self:AddTimer(1, 0.2, callback, true, true, true)
|
||||
end
|
||||
function ImportPreselectionCtrl:ClosePanel()
|
||||
local cb = function()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.ImportPreselection)
|
||||
end
|
||||
self:PlayOutAni(cb)
|
||||
end
|
||||
function ImportPreselectionCtrl:Awake()
|
||||
self:Refresh()
|
||||
self:PlayInAni()
|
||||
end
|
||||
function ImportPreselectionCtrl:OnEnable()
|
||||
end
|
||||
function ImportPreselectionCtrl:OnDisable()
|
||||
end
|
||||
function ImportPreselectionCtrl:OnDestroy()
|
||||
end
|
||||
function ImportPreselectionCtrl:OnValueChanged_Import(_, sContent)
|
||||
if sContent == nil or sContent == "" then
|
||||
return
|
||||
end
|
||||
local sFiltered = string.gsub(sContent, "[^A-Za-z0-9+/=]", "")
|
||||
if sFiltered ~= sContent then
|
||||
NovaAPI.SetTMPInputFieldText(self._mapNode.input, sFiltered)
|
||||
end
|
||||
end
|
||||
function ImportPreselectionCtrl:OnBtnClick_Confirm(btn)
|
||||
local sCode = NovaAPI.GetTMPInputFieldText(self._mapNode.input)
|
||||
local tbPotential = PlayerData.PotentialPreselection:UnPackPotentialData(sCode)
|
||||
if tbPotential == nil then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Potential_Preselection_Import_Error"))
|
||||
return
|
||||
end
|
||||
local callback = function()
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Potential_Preselection_Import_Suc"))
|
||||
self:ClosePanel()
|
||||
EventManager.Hit("RefreshPreselectionList")
|
||||
end
|
||||
local sName = ConfigTable.GetUIText("Potential_Preselection_Name_Init")
|
||||
local bPreference = false
|
||||
PlayerData.PotentialPreselection:SendImportPotential(sName, bPreference, tbPotential, callback)
|
||||
end
|
||||
return ImportPreselectionCtrl
|
||||
@@ -0,0 +1,21 @@
|
||||
local BasePanel = require("GameCore.UI.BasePanel")
|
||||
local ImportPreselectionPanel = class("ImportPreselectionPanel", BasePanel)
|
||||
ImportPreselectionPanel._bIsMainPanel = false
|
||||
ImportPreselectionPanel._sSortingLayerName = AllEnum.SortingLayerName.UI
|
||||
ImportPreselectionPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "PotentialPreselection/ImportPreselectionPanel.prefab",
|
||||
sCtrlName = "Game.UI.PotentialPreselection.ImportPreselectionCtrl"
|
||||
}
|
||||
}
|
||||
function ImportPreselectionPanel:Awake()
|
||||
end
|
||||
function ImportPreselectionPanel:OnEnable()
|
||||
end
|
||||
function ImportPreselectionPanel:OnDisable()
|
||||
end
|
||||
function ImportPreselectionPanel:OnDestroy()
|
||||
end
|
||||
function ImportPreselectionPanel:OnRelease()
|
||||
end
|
||||
return ImportPreselectionPanel
|
||||
@@ -0,0 +1,80 @@
|
||||
local PotentialPreselectionCharItemCtrl = class("PotentialPreselectionCharItemCtrl", BaseCtrl)
|
||||
PotentialPreselectionCharItemCtrl._mapNodeConfig = {
|
||||
imgLockMask = {},
|
||||
txtCharLock = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Char_Lock"
|
||||
},
|
||||
imgSelect = {},
|
||||
goChar = {
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateCharCtrl"
|
||||
},
|
||||
btnGrid = {sComponentName = "UIButton"},
|
||||
t_team_leader = {},
|
||||
t_team_sub = {},
|
||||
txtLeader = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Build_Leader"
|
||||
},
|
||||
txtSub = {sComponentName = "TMP_Text", sLanguageId = "Build_Sub"},
|
||||
TMPSelectTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "RoguelikeBuild_Manage_SelectedTitle"
|
||||
},
|
||||
btnDetail = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Detail"
|
||||
}
|
||||
}
|
||||
PotentialPreselectionCharItemCtrl._mapEventConfig = {}
|
||||
function PotentialPreselectionCharItemCtrl:Awake()
|
||||
end
|
||||
function PotentialPreselectionCharItemCtrl:OnEnable()
|
||||
end
|
||||
function PotentialPreselectionCharItemCtrl:OnDisable()
|
||||
end
|
||||
function PotentialPreselectionCharItemCtrl:OnDestroy()
|
||||
end
|
||||
function PotentialPreselectionCharItemCtrl:RefreshItem(nSelectIdx, nCharId, nSortType)
|
||||
self.nCharId = nCharId
|
||||
local mapCharData = PlayerData.Char:GetCharDataByTid(nCharId)
|
||||
self.bUnlock = mapCharData ~= nil
|
||||
self._mapNode.goChar:SetChar(nCharId, false, not self.bUnlock, nil, nSortType)
|
||||
self._mapNode.goChar:SetSelect(0 < nSelectIdx)
|
||||
self._mapNode.imgSelect:SetActive(0 < nSelectIdx)
|
||||
if 0 < nSelectIdx then
|
||||
self._mapNode.t_team_leader:SetActive(nSelectIdx == 1)
|
||||
self._mapNode.t_team_sub:SetActive(nSelectIdx ~= 1)
|
||||
else
|
||||
self._mapNode.t_team_leader:SetActive(false)
|
||||
self._mapNode.t_team_sub:SetActive(false)
|
||||
end
|
||||
self._mapNode.imgLockMask.gameObject:SetActive(false)
|
||||
self._mapNode.txtCharLock.gameObject:SetActive(not self.bUnlock)
|
||||
end
|
||||
function PotentialPreselectionCharItemCtrl:SetSelect(bSelect, nIdx)
|
||||
self._mapNode.imgSelect:SetActive(bSelect)
|
||||
self._mapNode.goChar:SetSelect(bSelect)
|
||||
if nIdx ~= nil then
|
||||
self._mapNode.t_team_leader:SetActive(nIdx == 1)
|
||||
self._mapNode.t_team_sub:SetActive(nIdx ~= 1)
|
||||
else
|
||||
self._mapNode.t_team_leader:SetActive(false)
|
||||
self._mapNode.t_team_sub:SetActive(false)
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionCharItemCtrl:OnBtnClick_Mask(btn)
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Potential_Preselection_Char_Selected"))
|
||||
end
|
||||
function PotentialPreselectionCharItemCtrl:OnBtnClick_Detail(btn)
|
||||
if self.nCharId ~= nil then
|
||||
if self.bUnlock then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.CharBgPanel, PanelId.CharInfo, self.nCharId, {
|
||||
self.nCharId
|
||||
}, false)
|
||||
else
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.CharBgTrialPanel, PanelId.CharInfoTrial, self.nCharId)
|
||||
end
|
||||
end
|
||||
end
|
||||
return PotentialPreselectionCharItemCtrl
|
||||
@@ -0,0 +1,300 @@
|
||||
local PotentialPreselectionCharListCtrl = class("PotentialPreselectionCharListCtrl", BaseCtrl)
|
||||
PotentialPreselectionCharListCtrl._mapNodeConfig = {
|
||||
sv = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
labEmpty = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Filter_NoAim"
|
||||
},
|
||||
btnCloseList = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Clear"
|
||||
},
|
||||
btnConfirm = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Confirm"
|
||||
},
|
||||
rtCharListContent = {sComponentName = "Transform"},
|
||||
btnFilter = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Filter"
|
||||
},
|
||||
imgFilterChoose = {},
|
||||
txtBtnListConifrm = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "MainLine_Select_Btn_Confirm"
|
||||
},
|
||||
txtBtnListClose = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "ClearFormation"
|
||||
},
|
||||
btnOrder = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Order"
|
||||
},
|
||||
goSortDropdown = {
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateDropdownCtrl"
|
||||
},
|
||||
imgArrowUpEnable = {},
|
||||
imgArrowUpDisable = {},
|
||||
imgArrowDownEnable = {},
|
||||
imgArrowDownDisable = {}
|
||||
}
|
||||
PotentialPreselectionCharListCtrl._mapEventConfig = {
|
||||
[EventId.FilterConfirm] = "RefreshByFilter",
|
||||
ForamtionDown = "OnEvent_ForamtionDown",
|
||||
SelectTemplateDD = "OnEvent_SortRuleChange"
|
||||
}
|
||||
PotentialPreselectionCharListCtrl._mapRedDotConfig = {}
|
||||
function PotentialPreselectionCharListCtrl:ShowList(tbCurSelectChar)
|
||||
local isDirty = PlayerData.Filter:IsDirty(AllEnum.OptionType.Char)
|
||||
self._mapNode.imgFilterChoose:SetActive(isDirty)
|
||||
self.tbOriginChar = clone(tbCurSelectChar)
|
||||
self.gameObject:SetActive(true)
|
||||
if self.tbAllChar == nil then
|
||||
self.tbAllChar = {}
|
||||
local func_EachChar = function(mapLineData)
|
||||
if mapLineData.Visible == true and mapLineData.Available == true then
|
||||
local mapChar = {}
|
||||
local nCharId = mapLineData.Id
|
||||
local mapCharData = PlayerData.Char:GetCharDataByTid(nCharId)
|
||||
local nCharLv = 0
|
||||
local nCreateTime = 0
|
||||
local nCharAdvance = 0
|
||||
local nAffinityLevel = 0
|
||||
if mapCharData ~= nil then
|
||||
nCharLv = PlayerData.Char:GetCharLv(nCharId)
|
||||
nCreateTime = PlayerData.Char:GetCreateTime(nCharId)
|
||||
nCharAdvance = PlayerData.Char:GetCharAdvance(nCharId)
|
||||
local mapData = PlayerData.Char:GetCharAffinityData(nCharId)
|
||||
nAffinityLevel = mapData ~= nil and mapData.Level or 0
|
||||
end
|
||||
mapChar.nId = nCharId
|
||||
mapChar.Name = mapLineData.Name
|
||||
mapChar.Rare = mapLineData.Grade
|
||||
mapChar.Class = mapLineData.Class
|
||||
mapChar.EET = mapLineData.EET
|
||||
mapChar.Level = nCharLv
|
||||
mapChar.CreateTime = nCreateTime
|
||||
mapChar.Advance = nCharAdvance
|
||||
mapChar.Favorability = nAffinityLevel
|
||||
table.insert(self.tbAllChar, mapChar)
|
||||
end
|
||||
end
|
||||
ForEachTableLine(DataTable.Character, func_EachChar)
|
||||
end
|
||||
self.curChar = tbCurSelectChar
|
||||
self.tbSortCfg = {
|
||||
nSortType = PlayerData.Filter.nFormationCharSrotType,
|
||||
bOrder = PlayerData.Filter.bFormationCharOrder
|
||||
}
|
||||
local curSortIdx = 1
|
||||
local tbSortType = PlayerData.Char:GetCharSortType()
|
||||
for nIdx, nSortType in ipairs(tbSortType) do
|
||||
if self.tbSortCfg.nSortType == nSortType then
|
||||
curSortIdx = nIdx
|
||||
end
|
||||
end
|
||||
self._mapNode.goSortDropdown:SetList(PlayerData.Char:GetCharSortNameTextCfg(), curSortIdx - 1)
|
||||
self.tbFilterCfg = {}
|
||||
self:RefreshOrderState()
|
||||
self:FilterChar()
|
||||
self:SortChar()
|
||||
for nInstanceId, mapCtrl in pairs(self.mapGridCtrl) do
|
||||
self:UnbindCtrlByNode(mapCtrl)
|
||||
self.mapGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self._mapNode.sv:Init(#self.tbSortedChar, self, self.OnGridRefresh, self.OnGridBtnClick)
|
||||
self._mapNode.btnConfirm.gameObject:SetActive(true)
|
||||
self._mapNode.btnCloseList.gameObject:SetActive(true)
|
||||
end
|
||||
function PotentialPreselectionCharListCtrl:Refresh()
|
||||
local isDirty = PlayerData.Filter:IsDirty(AllEnum.OptionType.Char)
|
||||
self._mapNode.imgFilterChoose:SetActive(isDirty)
|
||||
self:FilterChar()
|
||||
self:SortChar()
|
||||
self:RefreshOrderState()
|
||||
local nCurCount = #self.tbSortedChar
|
||||
if 0 < nCurCount then
|
||||
self._mapNode.labEmpty.gameObject:SetActive(false)
|
||||
self._mapNode.sv.gameObject:SetActive(true)
|
||||
self._mapNode.sv:Init(#self.tbSortedChar, self, self.OnGridRefresh, self.OnGridBtnClick)
|
||||
else
|
||||
self._mapNode.sv.gameObject:SetActive(false)
|
||||
self._mapNode.labEmpty.gameObject:SetActive(true)
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionCharListCtrl:CloseList()
|
||||
self.tbFilterCfg = {}
|
||||
for nInstanceId, mapCtrl in pairs(self.mapGridCtrl) do
|
||||
self:UnbindCtrlByNode(mapCtrl)
|
||||
self.mapGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self.mapGridCtrl = {}
|
||||
self.gameObject:SetActive(false)
|
||||
end
|
||||
function PotentialPreselectionCharListCtrl:OnGridRefresh(goGrid, gridIndex)
|
||||
local nInstanceId = goGrid:GetInstanceID()
|
||||
if not self.mapGridCtrl[nInstanceId] then
|
||||
self.mapGridCtrl[nInstanceId] = self:BindCtrlByNode(goGrid, "Game.UI.PotentialPreselection.PotentialPreselectionCharItemCtrl")
|
||||
end
|
||||
local nIndex = gridIndex + 1
|
||||
local nCharId = self.tbSortedChar[nIndex]
|
||||
local selectIdx = table.indexof(self.curChar, nCharId)
|
||||
self.mapGridCtrl[nInstanceId]:RefreshItem(selectIdx, nCharId, self.tbSortCfg.nSortType)
|
||||
end
|
||||
function PotentialPreselectionCharListCtrl:OnGridBtnClick(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local nCharId = self.tbSortedChar[nIndex]
|
||||
local nTeamIdx = table.indexof(self.curChar, nCharId)
|
||||
if 0 < nTeamIdx then
|
||||
self.curChar[nTeamIdx] = 0
|
||||
self:SetGridIndex(nCharId, 0)
|
||||
for idx, CharId in ipairs(self.curChar) do
|
||||
self:SetGridIndex(CharId, idx)
|
||||
end
|
||||
else
|
||||
local nPos = table.indexof(self.curChar, 0)
|
||||
if 0 < nPos then
|
||||
self.curChar[nPos] = nCharId
|
||||
for idx, CharId in ipairs(self.curChar) do
|
||||
self:SetGridIndex(CharId, idx)
|
||||
end
|
||||
else
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Formation_FullTeam") or "")
|
||||
end
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionCharListCtrl:SetGridIndex(nCharId, nIdx)
|
||||
local nGirdIdx = table.indexof(self.tbSortedChar, nCharId)
|
||||
local trGrid = self._mapNode.rtCharListContent:Find(tostring(nGirdIdx - 1))
|
||||
if trGrid ~= nil then
|
||||
local nInstanceId = trGrid.gameObject:GetInstanceID()
|
||||
self.mapGridCtrl[nInstanceId]:SetSelect(0 < nIdx, nIdx)
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionCharListCtrl:FilterChar()
|
||||
self.tbSortedChar = {}
|
||||
for nId, data in pairs(self.tbAllChar) do
|
||||
local isFilter = PlayerData.Filter:CheckFilterByChar(data.nId)
|
||||
local bCur = table.indexof(self.curChar, data.nId) > 0
|
||||
if isFilter or bCur then
|
||||
local mapSkill = PlayerData.Char:GetCharSkillUpgradeData(data.nId)
|
||||
local nSkillLevelSum = 0
|
||||
for k, v in pairs(mapSkill) do
|
||||
nSkillLevelSum = nSkillLevelSum + v.nLv
|
||||
end
|
||||
data.SkillLevel = nSkillLevelSum
|
||||
table.insert(self.tbSortedChar, data)
|
||||
end
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionCharListCtrl:SortChar()
|
||||
local tbCharId = {}
|
||||
UTILS.SortByPriority(self.tbSortedChar, {
|
||||
AllEnum.CharSortField[self.tbSortCfg.nSortType]
|
||||
}, PlayerData.Char:GetCharSortField(), self.tbSortCfg.bOrder)
|
||||
self.tbSortedChar = self:MoveElementsToFront(self.tbSortedChar, self.curChar)
|
||||
for _, mapCharId in ipairs(self.tbSortedChar) do
|
||||
table.insert(tbCharId, mapCharId.nId)
|
||||
end
|
||||
self.tbSortedChar = tbCharId
|
||||
end
|
||||
function PotentialPreselectionCharListCtrl:MoveElementsToFront(sortedList, elementsToMove)
|
||||
local lookup = {}
|
||||
for _, v in ipairs(elementsToMove) do
|
||||
lookup[v] = true
|
||||
end
|
||||
local moved, rest = {}, {}
|
||||
for _, v in ipairs(sortedList) do
|
||||
if lookup[v.nId] then
|
||||
table.insert(moved, v)
|
||||
else
|
||||
table.insert(rest, v)
|
||||
end
|
||||
end
|
||||
for _, v in ipairs(rest) do
|
||||
table.insert(moved, v)
|
||||
end
|
||||
return moved
|
||||
end
|
||||
function PotentialPreselectionCharListCtrl:RefreshOrderState()
|
||||
self._mapNode.imgArrowUpEnable:SetActive(self.tbSortCfg.bOrder)
|
||||
self._mapNode.imgArrowUpDisable:SetActive(not self.tbSortCfg.bOrder)
|
||||
self._mapNode.imgArrowDownEnable:SetActive(not self.tbSortCfg.bOrder)
|
||||
self._mapNode.imgArrowDownDisable:SetActive(self.tbSortCfg.bOrder)
|
||||
end
|
||||
function PotentialPreselectionCharListCtrl:RefreshByFilter()
|
||||
self:Refresh()
|
||||
end
|
||||
function PotentialPreselectionCharListCtrl:Awake()
|
||||
self.mapGridCtrl = {}
|
||||
local isDirty = PlayerData.Filter:IsDirty(AllEnum.OptionType.Char)
|
||||
self._mapNode.imgFilterChoose:SetActive(isDirty)
|
||||
end
|
||||
function PotentialPreselectionCharListCtrl:OnEnable()
|
||||
end
|
||||
function PotentialPreselectionCharListCtrl:OnDisable()
|
||||
self:CloseList()
|
||||
end
|
||||
function PotentialPreselectionCharListCtrl:OnDestroy()
|
||||
end
|
||||
function PotentialPreselectionCharListCtrl:OnRelease()
|
||||
end
|
||||
function PotentialPreselectionCharListCtrl:OnEvent_ForamtionDown(nIdx)
|
||||
local nCurCharId = self.curChar[nIdx]
|
||||
self.curChar[nIdx] = 0
|
||||
local nGridIdx = table.indexof(self.tbSortedChar, nCurCharId)
|
||||
local trGrid = self._mapNode.rtCharListContent:Find(tostring(nGridIdx - 1))
|
||||
if trGrid ~= nil then
|
||||
local nInstanceId = trGrid.gameObject:GetInstanceID()
|
||||
self.mapGridCtrl[nInstanceId]:SetSelect(false, nIdx)
|
||||
end
|
||||
EventManager.Hit("OnEvent_ChangeTeamModel", self.curChar)
|
||||
end
|
||||
function PotentialPreselectionCharListCtrl:OnEvent_SortRuleChange(nValue)
|
||||
local nV = nValue + 1
|
||||
self.tbSortCfg.nSortType = PlayerData.Char:GetCharSortType()[nV]
|
||||
self.tbSortCfg.bOrder = false
|
||||
PlayerData.Filter:CacheCharSort(self.tbSortCfg.nSortType, self.tbSortCfg.bOrder)
|
||||
self:Refresh()
|
||||
end
|
||||
function PotentialPreselectionCharListCtrl:OnBtnClick_Order(btn)
|
||||
self.tbSortCfg.bOrder = not self.tbSortCfg.bOrder
|
||||
PlayerData.Filter:CacheCharSort(self.tbSortCfg.nSortType, self.tbSortCfg.bOrder)
|
||||
self:Refresh()
|
||||
end
|
||||
function PotentialPreselectionCharListCtrl:OnBtnClick_Clear()
|
||||
for i = 1, 3 do
|
||||
if self.curChar[i] ~= 0 then
|
||||
self:SetGridIndex(self.curChar[i], 0)
|
||||
self.curChar[i] = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionCharListCtrl:OnBtnClick_Confirm()
|
||||
local bFull = true
|
||||
for _, v in ipairs(self.curChar) do
|
||||
if v == 0 then
|
||||
bFull = false
|
||||
break
|
||||
end
|
||||
end
|
||||
if not bFull then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Potential_Preselection_Char_Not_Full"))
|
||||
return
|
||||
end
|
||||
EventManager.Hit("ClosePreselectionCharList", self.curChar)
|
||||
end
|
||||
function PotentialPreselectionCharListCtrl:OnBtnClick_Filter()
|
||||
local tbOption = {
|
||||
AllEnum.ChooseOption.Char_Element,
|
||||
AllEnum.ChooseOption.Char_Rarity,
|
||||
AllEnum.ChooseOption.Char_PowerStyle,
|
||||
AllEnum.ChooseOption.Char_TacticalStyle,
|
||||
AllEnum.ChooseOption.Char_AffiliatedForces
|
||||
}
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.FilterPopupPanel, tbOption)
|
||||
end
|
||||
return PotentialPreselectionCharListCtrl
|
||||
@@ -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
|
||||
@@ -0,0 +1,916 @@
|
||||
local PotentialPreselectionEditCtrl = class("PotentialPreselectionEditCtrl", BaseCtrl)
|
||||
local LayoutRebuilder = CS.UnityEngine.UI.LayoutRebuilder
|
||||
PotentialPreselectionEditCtrl._mapNodeConfig = {
|
||||
TopBar = {
|
||||
sNodeName = "TopBarPanel",
|
||||
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
|
||||
},
|
||||
txtTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Member"
|
||||
},
|
||||
txtPreselectionName = {sComponentName = "TMP_Text"},
|
||||
btnEditName = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_EditName"
|
||||
},
|
||||
imgEmptyChar = {nCount = 3},
|
||||
imgCharBg = {nCount = 3},
|
||||
imgCharIcon = {nCount = 3, sComponentName = "Image"},
|
||||
imgCharFrame = {nCount = 3, sComponentName = "Image"},
|
||||
imgCharElement = {nCount = 3, sComponentName = "Image"},
|
||||
txtLeaderCn = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Build_Leader"
|
||||
},
|
||||
txtSubCn = {
|
||||
nCount = 2,
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Build_Sub"
|
||||
},
|
||||
txtCharName = {nCount = 3, sComponentName = "TMP_Text"},
|
||||
txtPotentialCount = {nCount = 3, sComponentName = "TMP_Text"},
|
||||
btnSelectChar = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_CharList"
|
||||
},
|
||||
btn_Preference = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Preference"
|
||||
},
|
||||
txtLike = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "StarTower_Build_Like"
|
||||
},
|
||||
btn_PreferenceIcon = {sComponentName = "Button"},
|
||||
goEmpty = {
|
||||
sNodeName = "---empty---"
|
||||
},
|
||||
txt_Empty = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Select_Char"
|
||||
},
|
||||
btnPreviewRoot = {},
|
||||
btnUse = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Use"
|
||||
},
|
||||
txtBtnUse = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Use"
|
||||
},
|
||||
btnCancel = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Cancel"
|
||||
},
|
||||
txtBtnCancel = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Cancel"
|
||||
},
|
||||
btnEdit = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Edit"
|
||||
},
|
||||
txtBtnEdit = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Edit"
|
||||
},
|
||||
btnShare = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Share"
|
||||
},
|
||||
txtBtnShare = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Share"
|
||||
},
|
||||
btnDelete = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Delete"
|
||||
},
|
||||
txtBtnDelete = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Delete"
|
||||
},
|
||||
btnEditRoot = {},
|
||||
btnSave = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Save"
|
||||
},
|
||||
txtBtnSave = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Edit_Save"
|
||||
},
|
||||
btnAbandon = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Abandon"
|
||||
},
|
||||
txtBtnAbandon = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Edit_Abandon"
|
||||
},
|
||||
goPotential = {
|
||||
sNodeName = "---potential---"
|
||||
},
|
||||
potentialCardRoot = {},
|
||||
animPotentialCard = {
|
||||
sNodeName = "potentialCardRoot",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
PotentialCard = {
|
||||
sCtrlName = "Game.UI.StarTower.Potential.PotentialCardItemCtrl"
|
||||
},
|
||||
CharList = {},
|
||||
PotentialList = {
|
||||
nCount = 3,
|
||||
sCtrlName = "Game.UI.PotentialPreselection.CharPotentialListCtrl"
|
||||
},
|
||||
PotentialDepotItem = {},
|
||||
rtPotentialContent = {
|
||||
sNodeName = "PotentialContent",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
switch_des = {},
|
||||
switch_img_bg = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
switch_name = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Change_Desc"
|
||||
},
|
||||
btnSwitch_on = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_SetDes"
|
||||
},
|
||||
btnSwitch_off = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_SetSimpleDes"
|
||||
},
|
||||
goQuantitySelector = {
|
||||
sNodeName = "tc_quantity_selector",
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateQuantitySelectorCtrl"
|
||||
},
|
||||
potentialEmpty = {},
|
||||
txt_EmptyPotential = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Potential_Empty"
|
||||
},
|
||||
goCharList = {
|
||||
sNodeName = "---charList---",
|
||||
sCtrlName = "Game.UI.PotentialPreselection.PotentialPreselectionCharListCtrl"
|
||||
},
|
||||
animCharList = {
|
||||
sNodeName = "---charList---",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
btnCharListMask = {}
|
||||
}
|
||||
PotentialPreselectionEditCtrl._mapEventConfig = {
|
||||
SelectPreselectionChar = "OnEvent_SelectPreselectionChar",
|
||||
ClosePreselectionCharList = "OnEvent_CloseCharList",
|
||||
SelectDepotPotential = "OnEvent_SelectPotential",
|
||||
[EventId.UIBackConfirm] = "OnEvent_Back",
|
||||
[EventId.UIHomeConfirm] = "OnEvent_BackHome"
|
||||
}
|
||||
PotentialPreselectionEditCtrl._mapRedDotConfig = {}
|
||||
function PotentialPreselectionEditCtrl:InitSelectList()
|
||||
self.tbSelectCharList = {}
|
||||
if self.initPreselectData ~= nil and next(self.initPreselectData) ~= nil then
|
||||
local tbChar = self.initPreselectData.tbCharPotential
|
||||
for k, v in ipairs(tbChar) do
|
||||
self.tbSelectCharList[k] = {}
|
||||
self.tbSelectCharList[k].nCharId = v.nCharId
|
||||
self.tbSelectCharList[k].tbPotential = self:GetAllPotentialList(v.nCharId, k, v.tbPotential)
|
||||
end
|
||||
else
|
||||
for i = 1, 3 do
|
||||
if self.tbSelectCharList[i] == nil then
|
||||
self.tbSelectCharList[i] = {}
|
||||
self.tbSelectCharList[i].nCharId = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:CheckPotentialSpecialCount()
|
||||
if self.bSelectSpecial and self.nSelectSpecialCount >= 2 then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Potential_Preselection_Sepcail_Max"))
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:ChangePanel()
|
||||
self._mapNode.btnPreviewRoot.gameObject:SetActive(self._panel.nPanelType == AllEnum.PreselectionPanelType.Preview)
|
||||
self._mapNode.btnEditRoot.gameObject:SetActive(self._panel.nPanelType ~= AllEnum.PreselectionPanelType.Preview)
|
||||
self._mapNode.btn_Preference.gameObject:SetActive(self._panel.nPanelType == AllEnum.PreselectionPanelType.Preview)
|
||||
self._mapNode.btnEditName.gameObject:SetActive(self._panel.nPanelType == AllEnum.PreselectionPanelType.Preview)
|
||||
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)
|
||||
else
|
||||
self._mapNode.btnUse.gameObject:SetActive(false)
|
||||
self._mapNode.btnCancel.gameObject:SetActive(false)
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:RefreshContent()
|
||||
self:ChangePanel()
|
||||
self.bEmpty = false
|
||||
for _, v in ipairs(self.tbSelectCharList) do
|
||||
if v.nCharId == 0 then
|
||||
self.bEmpty = true
|
||||
break
|
||||
end
|
||||
end
|
||||
self._mapNode.goEmpty.gameObject:SetActive(self.bEmpty)
|
||||
self._mapNode.goPotential.gameObject:SetActive(not self.bEmpty)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtPreselectionName, self.curPreselectData.sName)
|
||||
self._mapNode.btn_PreferenceIcon.interactable = self.curPreselectData.bPreference
|
||||
NovaAPI.SetTMPColor(self._mapNode.txtLike, self.curPreselectData.bPreference and Color(0.14901960784313725, 0.25882352941176473, 0.47058823529411764) or Color(0.5803921568627451, 0.6666666666666666, 0.7529411764705882))
|
||||
if self.bEmpty then
|
||||
self:SetEmpty()
|
||||
return
|
||||
end
|
||||
self:RefreshCharList()
|
||||
self:RefreshPotentialList()
|
||||
if self._panel.nPanelType ~= AllEnum.PreselectionPanelType.Preview and self.bShowCharList then
|
||||
local tbSelect = {}
|
||||
for _, v in ipairs(self.tbSelectCharList) do
|
||||
table.insert(tbSelect, v.nCharId)
|
||||
end
|
||||
self._mapNode.goCharList:ShowList(tbSelect)
|
||||
self._mapNode.btnCharListMask.gameObject:SetActive(true)
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:RefreshCharList()
|
||||
for i = 1, 3 do
|
||||
local bEmpty = self.tbSelectCharList[i].nCharId == 0
|
||||
self._mapNode.imgEmptyChar[i].gameObject:SetActive(bEmpty)
|
||||
self._mapNode.imgCharBg[i].gameObject:SetActive(not bEmpty)
|
||||
self._mapNode.txtPotentialCount[i].gameObject:SetActive(not bEmpty)
|
||||
if bEmpty then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCharName[i], ConfigTable.GetUIText("Potential_Preselection_Char_Empty"))
|
||||
else
|
||||
local nCharId = self.tbSelectCharList[i].nCharId
|
||||
local mapCharCfg = ConfigTable.GetData_Character(nCharId)
|
||||
if mapCharCfg ~= nil then
|
||||
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
|
||||
local mapCharSkin = ConfigTable.GetData_CharacterSkin(nSkinId)
|
||||
local sFrame = AllEnum.FrameType_New.BoardFrame .. AllEnum.BoardFrameColor[mapCharCfg.Grade]
|
||||
self:SetPngSprite(self._mapNode.imgCharIcon[i], mapCharSkin.Icon .. AllEnum.CharHeadIconSurfix.XXL)
|
||||
self:SetAtlasSprite(self._mapNode.imgCharFrame[i], "12_rare", sFrame)
|
||||
self:SetAtlasSprite(self._mapNode.imgCharElement[i], "12_rare", AllEnum.Char_Element[mapCharCfg.EET].icon)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCharName[i], mapCharCfg.Name)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtPotentialCount[i], 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:RefreshPotentialList()
|
||||
local bEmpty = true
|
||||
self.nSelectId = nil
|
||||
self.nSelectCharIdx = 0
|
||||
local nPotentialCount = 0
|
||||
for k, v in ipairs(self.tbSelectCharList) do
|
||||
local nAllCount = 0
|
||||
local nSelectId = 0
|
||||
if 0 < v.nCharId then
|
||||
bEmpty = false
|
||||
if v.tbPotential == nil then
|
||||
v.tbPotential = self:GetAllPotentialList(v.nCharId, k)
|
||||
end
|
||||
for style, tb in ipairs(v.tbPotential) do
|
||||
for _, data in ipairs(tb) do
|
||||
nAllCount = nAllCount + data.nLevel
|
||||
if 0 < data.nLevel and nSelectId == 0 then
|
||||
nSelectId = data.nId
|
||||
end
|
||||
end
|
||||
end
|
||||
nPotentialCount = nPotentialCount + nAllCount
|
||||
if self.nSelectId == nil then
|
||||
if self._panel.nPanelType == AllEnum.PreselectionPanelType.Preview then
|
||||
if nSelectId ~= 0 then
|
||||
self.nSelectId = nSelectId
|
||||
end
|
||||
elseif v.tbPotential[1] and v.tbPotential[1][1] then
|
||||
self.nSelectId = v.tbPotential[1][1].nId
|
||||
end
|
||||
self.nSelectCharIdx = k
|
||||
end
|
||||
self._mapNode.PotentialList[k]:RefreshPotential(v.nCharId, v.tbPotential, self._mapNode.PotentialDepotItem, k == 1, self._panel.nPanelType)
|
||||
self._mapNode.PotentialList[k]:ShowAllCount(false)
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtPotentialCount[k], nAllCount)
|
||||
end
|
||||
self._mapNode.goEmpty.gameObject:SetActive(bEmpty)
|
||||
self._mapNode.goPotential.gameObject:SetActive(not bEmpty)
|
||||
if not bEmpty then
|
||||
if self.nSelectId ~= nil and self.nSelectId ~= 0 then
|
||||
self._mapNode.potentialCardRoot.gameObject:SetActive(true)
|
||||
EventManager.Hit("SelectDepotPotential", self.nSelectId)
|
||||
else
|
||||
self._mapNode.potentialCardRoot.gameObject:SetActive(false)
|
||||
end
|
||||
self._mapNode.potentialEmpty.gameObject:SetActive(self._panel.nPanelType == AllEnum.PreselectionPanelType.Preview and nPotentialCount == 0)
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.rtPotentialContent)
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
self:InitSwitch()
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:RefreshSelectPotential(bPlayAnim)
|
||||
self._mapNode.PotentialCard.gameObject:SetActive(true)
|
||||
local potentialCfg = ConfigTable.GetData("Potential", self.nSelectId)
|
||||
if nil ~= potentialCfg then
|
||||
self.nSelectCharIdx = 0
|
||||
for k, v in ipairs(self.tbSelectCharList) do
|
||||
if v.nCharId == potentialCfg.CharId then
|
||||
self.nSelectCharIdx = k
|
||||
break
|
||||
end
|
||||
end
|
||||
local nLevel = 0
|
||||
local nMaxLevel = 0
|
||||
self.nSelectSpecialCount = 0
|
||||
self.bSelectSpecial = false
|
||||
local mapData = self.tbSelectCharList[self.nSelectCharIdx]
|
||||
if mapData ~= nil then
|
||||
for nType, tb in ipairs(mapData.tbPotential) do
|
||||
for _, data in ipairs(tb) do
|
||||
if data.nId == self.nSelectId then
|
||||
nLevel = data.nLevel
|
||||
nMaxLevel = data.nMaxLevel
|
||||
self.bSelectSpecial = data.nSpecial == 1
|
||||
end
|
||||
if data.nSpecial == 1 then
|
||||
self.nSelectSpecialCount = self.nSelectSpecialCount + data.nLevel
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
self.nSelectLevel = nLevel
|
||||
self.nLastSelectLevel = nLevel
|
||||
nLevel = math.max(nLevel, 1)
|
||||
local bSimple = PlayerData.StarTower:GetPotentialDescSimple()
|
||||
if bPlayAnim then
|
||||
self._mapNode.animPotentialCard:Play("potentialCardRoot_in", 0, 0)
|
||||
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
|
||||
local callback = function(nCount)
|
||||
self.nSelectLevel = nCount
|
||||
self:RefreshPotentialCount()
|
||||
end
|
||||
local addCallback = function()
|
||||
return self:CheckPotentialSpecialCount()
|
||||
end
|
||||
self._mapNode.goQuantitySelector:Init(callback, self.nSelectLevel, nMaxLevel, false, true, addCallback)
|
||||
end
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:RefreshPotentialCount()
|
||||
if self.nSelectCharIdx ~= 0 then
|
||||
local bSimple = PlayerData.StarTower:GetPotentialDescSimple()
|
||||
local nLevel = math.max(self.nSelectLevel, 1)
|
||||
self._mapNode.PotentialCard:SetPotentialItem(self.nSelectId, nLevel, nil, bSimple, nil, 0, AllEnum.PotentialCardType.CharInfo)
|
||||
self._mapNode.PotentialCard:ChangeWordRaycast(true)
|
||||
if self._mapNode.PotentialList[self.nSelectCharIdx] ~= nil then
|
||||
self._mapNode.PotentialList[self.nSelectCharIdx]:RefreshPotentialLevel(self.nSelectId, self.nSelectLevel, self.nLastSelectLevel)
|
||||
end
|
||||
self.nLastSelectLevel = self.nSelectLevel
|
||||
self.nSelectSpecialCount = 0
|
||||
local mapData = self.tbSelectCharList[self.nSelectCharIdx]
|
||||
if mapData ~= nil then
|
||||
local nAllCount = 0
|
||||
for nType, tb in ipairs(mapData.tbPotential) do
|
||||
for _, data in ipairs(tb) do
|
||||
if data.nId == self.nSelectId then
|
||||
data.nLevel = self.nSelectLevel
|
||||
end
|
||||
nAllCount = nAllCount + data.nLevel
|
||||
if data.nSpecial == 1 then
|
||||
self.nSelectSpecialCount = self.nSelectSpecialCount + data.nLevel
|
||||
end
|
||||
end
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtPotentialCount[self.nSelectCharIdx], nAllCount)
|
||||
end
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:InitSwitch()
|
||||
local bSimple = PlayerData.StarTower:GetPotentialDescSimple()
|
||||
self._mapNode.btnSwitch_on.gameObject:SetActive(bSimple)
|
||||
self._mapNode.btnSwitch_off.gameObject:SetActive(not bSimple)
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:GetAllPotentialList(nCharId, nIndex, tbPotential)
|
||||
local tbAllPotential = {}
|
||||
local charPotentialCfg = PlayerData.Char:GetCharPotentialList(nCharId)
|
||||
if charPotentialCfg ~= nil then
|
||||
if nIndex == 1 then
|
||||
tbAllPotential = charPotentialCfg.master
|
||||
else
|
||||
tbAllPotential = charPotentialCfg.assist
|
||||
end
|
||||
end
|
||||
local tbSortList = {}
|
||||
for style, tb in ipairs(tbAllPotential) do
|
||||
tbSortList[style] = {}
|
||||
for _, data in ipairs(tb) do
|
||||
local itemCfg = ConfigTable.GetData_Item(data.nId)
|
||||
if itemCfg ~= nil then
|
||||
local nLevel = 0
|
||||
if tbPotential ~= nil and 0 < #tbPotential then
|
||||
for _, v in ipairs(tbPotential) do
|
||||
if v.nId == data.nId then
|
||||
nLevel = v.nLevel
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
data.nLevel = nLevel
|
||||
local nSpecial = itemCfg.Stype == GameEnum.itemStype.SpecificPotential and 1 or 0
|
||||
local nMaxLevel = nSpecial == 1 and 1 or ConfigTable.GetConfigNumber("PotentialPreselectionMaxLevel")
|
||||
table.insert(tbSortList[style], {
|
||||
nId = data.nId,
|
||||
nLevel = data.nLevel,
|
||||
nMaxLevel = nMaxLevel,
|
||||
nSpecial = nSpecial,
|
||||
nRarity = itemCfg.Rarity
|
||||
})
|
||||
end
|
||||
end
|
||||
table.sort(tbSortList[style], function(a, b)
|
||||
if a.nSpecial == b.nSpecial then
|
||||
if a.nRarity == b.nRarity then
|
||||
if a.nLevel == b.nLevel then
|
||||
return a.nId < b.nId
|
||||
end
|
||||
return a.nLevel > b.nLevel
|
||||
end
|
||||
return a.nRarity < b.nRarity
|
||||
end
|
||||
return a.nSpecial > b.nSpecial
|
||||
end)
|
||||
end
|
||||
return tbSortList
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:SetEmpty()
|
||||
for i = 1, 3 do
|
||||
self._mapNode.imgEmptyChar[i].gameObject:SetActive(true)
|
||||
self._mapNode.imgCharBg[i].gameObject:SetActive(false)
|
||||
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
|
||||
local tbSelect = {}
|
||||
for _, v in ipairs(self.tbSelectCharList) do
|
||||
table.insert(tbSelect, v.nCharId)
|
||||
end
|
||||
self._mapNode.goCharList:ShowList(tbSelect)
|
||||
self._mapNode.btnCharListMask.gameObject:SetActive(true)
|
||||
self.bShowCharList = true
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:CheckChange()
|
||||
local bChange = false
|
||||
local tbChangeChar = {}
|
||||
if self.initPreselectData ~= nil and next(self.initPreselectData) ~= nil then
|
||||
local tbCharPotential = self.initPreselectData.tbCharPotential
|
||||
for k, v in ipairs(self.tbSelectCharList) do
|
||||
if tbCharPotential[k].nCharId ~= v.nCharId then
|
||||
bChange = true
|
||||
table.insert(tbChangeChar, tbCharPotential[k].nCharId)
|
||||
end
|
||||
if v.tbPotential ~= nil and tbCharPotential[k].tbPotential == nil then
|
||||
bChange = true
|
||||
break
|
||||
end
|
||||
local tbTemp = {}
|
||||
for _, data in ipairs(tbCharPotential[k].tbPotential) do
|
||||
tbTemp[data.nId] = data.nLevel
|
||||
end
|
||||
if v.tbPotential ~= nil and tbCharPotential[k].tbPotential ~= nil then
|
||||
for nType, tb in ipairs(v.tbPotential) do
|
||||
for _, potential in ipairs(tb) do
|
||||
local nInitLevel = tbTemp[potential.nId] or 0
|
||||
if nInitLevel ~= potential.nLevel then
|
||||
bChange = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
for k, v in ipairs(self.tbSelectCharList) do
|
||||
if v.nCharId ~= 0 then
|
||||
bChange = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
return bChange, tbChangeChar
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:ClosePanel(bCloseList)
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.PotentialPreselectionEdit)
|
||||
if bCloseList then
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.PotentialPreselectionList)
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:Awake()
|
||||
local tbParam = self:GetPanelParam()
|
||||
if type(tbParam) == "table" and self._panel.nPanelType == 0 then
|
||||
self._panel.nPanelType = tbParam[1]
|
||||
self.initPreselectData = tbParam[2]
|
||||
self.tbBuildChar = tbParam[3]
|
||||
self.nTeamIndex = tbParam[4] or 0
|
||||
self.bShowCharList = false
|
||||
self.curPreselectData = nil
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnEnable()
|
||||
self.tbOption = {
|
||||
AllEnum.ChooseOption.Char_Element,
|
||||
AllEnum.ChooseOption.Char_Rarity,
|
||||
AllEnum.ChooseOption.Char_PowerStyle,
|
||||
AllEnum.ChooseOption.Char_TacticalStyle,
|
||||
AllEnum.ChooseOption.Char_AffiliatedForces
|
||||
}
|
||||
self._mapNode.goCharList.gameObject:SetActive(self.bShowCharList)
|
||||
self._mapNode.btnCharListMask.gameObject:SetActive(self.bShowCharList)
|
||||
self._mapNode.PotentialDepotItem.gameObject:SetActive(false)
|
||||
self._mapNode.btnUse.gameObject:SetActive(self.tbBuildChar ~= nil)
|
||||
self.nSelectId = nil
|
||||
self.nSelectCharIdx = 0
|
||||
self.nSelectLevel = 0
|
||||
self.nLastSelectLevel = 0
|
||||
if self.curPreselectData == nil then
|
||||
self.curPreselectData = {}
|
||||
if self._panel.nPanelType == AllEnum.PreselectionPanelType.Create then
|
||||
self.curPreselectData.sName = ConfigTable.GetUIText("Potential_Preselection_Name_Init")
|
||||
self.curPreselectData.bPreference = false
|
||||
self.curPreselectData.tbCharPotential = {}
|
||||
else
|
||||
self.curPreselectData = clone(self.initPreselectData)
|
||||
end
|
||||
self:InitSelectList()
|
||||
end
|
||||
self:RefreshContent()
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnDisable()
|
||||
PlayerData.Filter:Reset(self.tbOption)
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnDestroy()
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnBtnClick_EditName()
|
||||
local callback = function(sName)
|
||||
self.curPreselectData = PlayerData.PotentialPreselection:GetPreselectionById(self.curPreselectData.nId)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtPreselectionName, self.curPreselectData.sName)
|
||||
end
|
||||
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
|
||||
return
|
||||
end
|
||||
self.bShowCharList = true
|
||||
local tbSelect = {}
|
||||
for _, v in ipairs(self.tbSelectCharList) do
|
||||
table.insert(tbSelect, v.nCharId)
|
||||
end
|
||||
self._mapNode.goCharList:ShowList(tbSelect)
|
||||
self._mapNode.btnCharListMask.gameObject:SetActive(true)
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnBtnClick_Preference()
|
||||
if self._panel.nPanelType == AllEnum.PreselectionPanelType.Preview then
|
||||
local tbCheckIn = {}
|
||||
local tbCheckOut = {}
|
||||
if self.curPreselectData.bPreference then
|
||||
table.insert(tbCheckOut, self.curPreselectData.nId)
|
||||
else
|
||||
table.insert(tbCheckIn, self.curPreselectData.nId)
|
||||
end
|
||||
local callback = function()
|
||||
self.curPreselectData = PlayerData.PotentialPreselection:GetPreselectionById(self.curPreselectData.nId)
|
||||
self._mapNode.btn_PreferenceIcon.interactable = self.curPreselectData.bPreference
|
||||
NovaAPI.SetTMPColor(self._mapNode.txtLike, self.curPreselectData.bPreference and Color(0.14901960784313725, 0.25882352941176473, 0.47058823529411764) or Color(0.5803921568627451, 0.6666666666666666, 0.7529411764705882))
|
||||
end
|
||||
PlayerData.PotentialPreselection:SendPreselectionPreference(tbCheckIn, tbCheckOut, callback)
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnBtnClick_Use()
|
||||
local bCharDiff = false
|
||||
local bCharLock = false
|
||||
for k, v in ipairs(self.tbSelectCharList) do
|
||||
if k == 1 then
|
||||
if v.nCharId ~= self.tbBuildChar[k] then
|
||||
bCharDiff = true
|
||||
end
|
||||
elseif table.indexof(self.tbBuildChar, v.nCharId) == 0 then
|
||||
bCharDiff = true
|
||||
end
|
||||
if not PlayerData.Char:CheckCharUnlock(v.nCharId) then
|
||||
bCharLock = true
|
||||
end
|
||||
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)
|
||||
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
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnBtnClick_Cancel()
|
||||
local callback = function()
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Potential_Preselection_Cancel_Suc"))
|
||||
if PanelManager.CheckPanelOpen(PanelId.PotentialPreselectionList) then
|
||||
self:ClosePanel()
|
||||
EventManager.Hit("RefreshPreselectionList")
|
||||
else
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.PotentialPreselectionList, self.tbBuildChar or {}, self.nTeamIndex)
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
self:ClosePanel()
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
end
|
||||
end
|
||||
local tmpDisc = PlayerData.Team:GetTeamDiscData(self.nTeamIndex)
|
||||
local _, tbTeamMemberId = PlayerData.Team:GetTeamData(self.nTeamIndex)
|
||||
PlayerData.Team:UpdateFormationInfo(self.nTeamIndex, tbTeamMemberId, tmpDisc, 0, callback)
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnBtnClick_Edit()
|
||||
self._panel.nPanelType = AllEnum.PreselectionPanelType.Edit
|
||||
self:ChangePanel()
|
||||
self:RefreshContent()
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnBtnClick_Share()
|
||||
if self.initPreselectData ~= nil and next(self.initPreselectData) ~= nil then
|
||||
local sCode = PlayerData.PotentialPreselection:PackPotentialData(self.initPreselectData.tbCharPotential)
|
||||
if sCode ~= nil then
|
||||
CS.UnityEngine.GUIUtility.systemCopyBuffer = sCode
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Potential_Preselection_Share_Suc"))
|
||||
else
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Potential_Preselection_Share_Fail"))
|
||||
end
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnBtnClick_Delete()
|
||||
local sucCallback = function()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.PotentialPreselectionEdit)
|
||||
end
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Confirm,
|
||||
sContent = ConfigTable.GetUIText("Potential_Preselection_Delete_Tip"),
|
||||
callbackConfirm = function()
|
||||
local tbIds = {
|
||||
self.curPreselectData.nId
|
||||
}
|
||||
PlayerData.PotentialPreselection:SendDeletePreselection(tbIds, sucCallback)
|
||||
end
|
||||
}
|
||||
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 callback = function(mapBuildData)
|
||||
self.initPreselectData = mapBuildData
|
||||
self.curPreselectData = clone(self.initPreselectData)
|
||||
self._panel.nPanelType = AllEnum.PreselectionPanelType.Preview
|
||||
self:RefreshContent()
|
||||
end
|
||||
if self._panel.nPanelType == AllEnum.PreselectionPanelType.Create then
|
||||
local sName = self.curPreselectData.sName
|
||||
local bPreference = self.curPreselectData.bPreference
|
||||
PlayerData.PotentialPreselection:SavePreselection(sName, bPreference, tbCharPotential, callback)
|
||||
else
|
||||
PlayerData.PotentialPreselection:SendUpdatePotential(self.curPreselectData.nId, tbCharPotential, callback)
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnBtnClick_Abandon()
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Confirm,
|
||||
sContent = ConfigTable.GetUIText("Potential_Preselection_Abandon_Edit"),
|
||||
callbackConfirm = function()
|
||||
if self._panel.nPanelType == AllEnum.PreselectionPanelType.Create then
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.PotentialPreselectionEdit)
|
||||
else
|
||||
self._panel.nPanelType = AllEnum.PreselectionPanelType.Preview
|
||||
self:InitSelectList()
|
||||
self:RefreshContent()
|
||||
end
|
||||
end
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnBtnClick_SetDes()
|
||||
PlayerData.StarTower:SetPotentialDescSimple(false)
|
||||
EventManager.Hit("SelectDepotPotential", self.nSelectId)
|
||||
self._mapNode.btnSwitch_on.gameObject:SetActive(false)
|
||||
self._mapNode.btnSwitch_off.gameObject:SetActive(true)
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnBtnClick_SetSimpleDes()
|
||||
PlayerData.StarTower:SetPotentialDescSimple(true)
|
||||
EventManager.Hit("SelectDepotPotential", self.nSelectId)
|
||||
self._mapNode.btnSwitch_on.gameObject:SetActive(true)
|
||||
self._mapNode.btnSwitch_off.gameObject:SetActive(false)
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnEvent_SelectPreselectionChar(tbChar)
|
||||
for i = 1, 3 do
|
||||
if tbChar[i] == nil then
|
||||
self.tbSelectCharList[i].nCharId = 0
|
||||
self.tbSelectCharList[i].tbPotential = nil
|
||||
elseif self.tbSelectCharList[i].nCharId == 0 or self.tbSelectCharList[i].nCharId ~= tbChar[i] then
|
||||
self.tbSelectCharList[i].nCharId = tbChar[i]
|
||||
self.tbSelectCharList[i].tbPotential = nil
|
||||
end
|
||||
end
|
||||
self:RefreshCharList()
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnEvent_CloseCharList(tbChar)
|
||||
local confirmCallback = function()
|
||||
for i = 1, 3 do
|
||||
if tbChar[i] == nil then
|
||||
self.tbSelectCharList[i].nCharId = 0
|
||||
self.tbSelectCharList[i].tbPotential = nil
|
||||
elseif self.tbSelectCharList[i].nCharId == 0 or self.tbSelectCharList[i].nCharId ~= tbChar[i] then
|
||||
self.tbSelectCharList[i].nCharId = tbChar[i]
|
||||
self.tbSelectCharList[i].tbPotential = nil
|
||||
end
|
||||
end
|
||||
self._mapNode.btnCharListMask.gameObject:SetActive(false)
|
||||
local nAnimLen = NovaAPI.GetAnimClipLength(self._mapNode.animCharList, {
|
||||
"charList_out"
|
||||
})
|
||||
self._mapNode.animCharList:Play("charList_out")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, nAnimLen)
|
||||
self:AddTimer(1, nAnimLen, function()
|
||||
self._mapNode.goCharList:CloseList()
|
||||
self.bShowCharList = false
|
||||
self:RefreshContent()
|
||||
end, true, true, true)
|
||||
end
|
||||
local tbChangeChar = {}
|
||||
for k, v in ipairs(self.tbSelectCharList) do
|
||||
local nCharId = v.nCharId
|
||||
if tbChar[k] ~= nCharId and v.nCharId ~= 0 then
|
||||
table.insert(tbChangeChar, nCharId)
|
||||
end
|
||||
end
|
||||
if 0 < #tbChangeChar then
|
||||
local sContentSub = ""
|
||||
for k, v in ipairs(tbChangeChar) do
|
||||
local mapCharCfg = ConfigTable.GetData_Character(v)
|
||||
if mapCharCfg ~= nil then
|
||||
sContentSub = sContentSub .. mapCharCfg.Name
|
||||
if k ~= #tbChangeChar then
|
||||
sContentSub = sContentSub .. ", "
|
||||
end
|
||||
end
|
||||
end
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Confirm,
|
||||
sContent = ConfigTable.GetUIText("Potential_Preselection_Char_Change"),
|
||||
sContentSub = sContentSub,
|
||||
callbackConfirm = confirmCallback
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
else
|
||||
confirmCallback()
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnEvent_SelectPotential(nPotentialId, nLevel, nPotentialAdd, btn)
|
||||
local bPlayAnim = self.nSelectId ~= nPotentialId
|
||||
self.nSelectId = nPotentialId
|
||||
self:RefreshSelectPotential(bPlayAnim)
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnEvent_Back()
|
||||
if self._panel.nPanelType ~= AllEnum.PreselectionPanelType.Preview then
|
||||
if self.bShowCharList then
|
||||
local bCloseCharList = true
|
||||
if self._panel.nPanelType == AllEnum.PreselectionPanelType.Create then
|
||||
for _, v in ipairs(self.tbSelectCharList) do
|
||||
if v.nCharId == 0 then
|
||||
bCloseCharList = false
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if bCloseCharList then
|
||||
self._mapNode.btnCharListMask.gameObject:SetActive(false)
|
||||
local nAnimLen = NovaAPI.GetAnimClipLength(self._mapNode.animCharList, {
|
||||
"charList_out"
|
||||
})
|
||||
self._mapNode.animCharList:Play("charList_out")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, nAnimLen)
|
||||
self:AddTimer(1, nAnimLen, function()
|
||||
self._mapNode.goCharList:CloseList()
|
||||
self.bShowCharList = false
|
||||
end, true, true, true)
|
||||
return
|
||||
end
|
||||
end
|
||||
local bChange, tbChangeChar = self:CheckChange()
|
||||
if bChange then
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Confirm,
|
||||
sContent = ConfigTable.GetUIText("Potential_Preselection_UnSave_Tip"),
|
||||
callbackConfirm = function()
|
||||
self:ClosePanel()
|
||||
end
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
return
|
||||
end
|
||||
end
|
||||
self:ClosePanel()
|
||||
end
|
||||
function PotentialPreselectionEditCtrl:OnEvent_BackHome()
|
||||
if self._panel.nPanelType ~= AllEnum.PreselectionPanelType.Preview then
|
||||
local bChange, tbChangeChar = self:CheckChange()
|
||||
if bChange then
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Confirm,
|
||||
sContent = ConfigTable.GetUIText("Potential_Preselection_UnSave_Tip"),
|
||||
callbackConfirm = function()
|
||||
PanelManager.Home()
|
||||
end
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
return
|
||||
end
|
||||
end
|
||||
PanelManager.Home()
|
||||
end
|
||||
return PotentialPreselectionEditCtrl
|
||||
@@ -0,0 +1,17 @@
|
||||
local PotentialPreselectionEditPanel = class("PotentialPreselectionEditPanel", BasePanel)
|
||||
PotentialPreselectionEditPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "PotentialPreselection/PotentialPreselectionEditPanel.prefab",
|
||||
sCtrlName = "Game.UI.PotentialPreselection.PotentialPreselectionEditCtrl"
|
||||
}
|
||||
}
|
||||
function PotentialPreselectionEditPanel:Awake()
|
||||
self.nPanelType = 0
|
||||
end
|
||||
function PotentialPreselectionEditPanel:OnEnable()
|
||||
end
|
||||
function PotentialPreselectionEditPanel:OnDisable()
|
||||
end
|
||||
function PotentialPreselectionEditPanel:OnDestroy()
|
||||
end
|
||||
return PotentialPreselectionEditPanel
|
||||
@@ -0,0 +1,99 @@
|
||||
local PotentialPreselectionItemCtrl = class("PotentialPreselectionItemCtrl", BaseCtrl)
|
||||
PotentialPreselectionItemCtrl._mapNodeConfig = {
|
||||
img_SelectPreference = {},
|
||||
txtBuildName = {sComponentName = "TMP_Text"},
|
||||
imgLike = {},
|
||||
imgCharIcon = {nCount = 3, sComponentName = "Image"},
|
||||
imgCharFrame = {nCount = 3, sComponentName = "Image"},
|
||||
txtLeaderCn = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Build_Leader"
|
||||
},
|
||||
txtSubCn = {
|
||||
nCount = 2,
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Build_Sub"
|
||||
},
|
||||
txtPotentialCount = {nCount = 3, sComponentName = "TMP_Text"},
|
||||
imgCharElement = {nCount = 3, sComponentName = "Image"},
|
||||
btnDelete = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Delete"
|
||||
},
|
||||
imgSelect = {},
|
||||
txtSelect = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Select"
|
||||
},
|
||||
goMask = {},
|
||||
txtMask = {sComponentName = "TMP_Text"}
|
||||
}
|
||||
PotentialPreselectionItemCtrl._mapEventConfig = {}
|
||||
PotentialPreselectionItemCtrl._mapRedDotConfig = {}
|
||||
function PotentialPreselectionItemCtrl:RefreshItem(mapData, bCharDiff, bSelect)
|
||||
self.mapData = mapData
|
||||
self:ShowDelete(false)
|
||||
self:SetSelect(bSelect)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtBuildName, mapData.sName)
|
||||
self._mapNode.imgLike.gameObject:SetActive(mapData.bPreference)
|
||||
local bCharLock = false
|
||||
for k, v in ipairs(mapData.tbCharPotential) do
|
||||
local nCharId = v.nCharId
|
||||
local mapCharData = PlayerData.Char:GetCharDataById(nCharId)
|
||||
if mapCharData == nil or next(mapCharData) == nil then
|
||||
bCharLock = true
|
||||
end
|
||||
local mapCharCfg = ConfigTable.GetData_Character(nCharId)
|
||||
if mapCharCfg ~= nil then
|
||||
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
|
||||
local mapCharSkin = ConfigTable.GetData_CharacterSkin(nSkinId)
|
||||
local sFrame = AllEnum.FrameType_New.BoardFrame .. AllEnum.BoardFrameColor[mapCharCfg.Grade]
|
||||
self:SetPngSprite(self._mapNode.imgCharIcon[k], mapCharSkin.Icon .. AllEnum.CharHeadIconSurfix.XXL)
|
||||
self:SetAtlasSprite(self._mapNode.imgCharFrame[k], "12_rare", sFrame)
|
||||
self:SetAtlasSprite(self._mapNode.imgCharElement[k], "12_rare", AllEnum.Char_Element[mapCharCfg.EET].icon)
|
||||
end
|
||||
local tbPotential = v.tbPotential
|
||||
local nCount = 0
|
||||
for _, potential in ipairs(tbPotential) do
|
||||
nCount = nCount + potential.nLevel
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtPotentialCount[k], nCount)
|
||||
end
|
||||
self._mapNode.goMask.gameObject:SetActive(bCharDiff or bCharLock)
|
||||
if bCharLock then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtMask, ConfigTable.GetUIText("Potential_Preselection_Item_Char_Lock"))
|
||||
elseif bCharDiff then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtMask, ConfigTable.GetUIText("Potential_Preselection_Item_Char_Diff"))
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionItemCtrl:ShowDelete(bShow)
|
||||
if self.mapData ~= nil and not self.mapData.bPreference then
|
||||
self._mapNode.btnDelete.gameObject:SetActive(bShow)
|
||||
else
|
||||
self._mapNode.btnDelete.gameObject:SetActive(false)
|
||||
end
|
||||
end
|
||||
function PotentialPreselectionItemCtrl:SetSelect(bSelect)
|
||||
self._mapNode.img_SelectPreference.gameObject:SetActive(bSelect)
|
||||
self._mapNode.imgSelect.gameObject:SetActive(bSelect)
|
||||
end
|
||||
function PotentialPreselectionItemCtrl:Awake()
|
||||
end
|
||||
function PotentialPreselectionItemCtrl:OnEnable()
|
||||
end
|
||||
function PotentialPreselectionItemCtrl:OnDisable()
|
||||
end
|
||||
function PotentialPreselectionItemCtrl:OnDestroy()
|
||||
end
|
||||
function PotentialPreselectionItemCtrl:OnBtnClick_Delete()
|
||||
if self.mapData ~= nil then
|
||||
local callback = function()
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Potential_Preselection_Delete_Suc"))
|
||||
end
|
||||
local tbDelete = {
|
||||
self.mapData.nId
|
||||
}
|
||||
PlayerData.PotentialPreselection:SendDeletePreselection(tbDelete, callback)
|
||||
end
|
||||
end
|
||||
return PotentialPreselectionItemCtrl
|
||||
@@ -0,0 +1,16 @@
|
||||
local PotentialPreselectionPanel = class("PotentialPreselectionPanel", BasePanel)
|
||||
PotentialPreselectionPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "PotentialPreselection/PotentialPreselectionListPanel.prefab",
|
||||
sCtrlName = "Game.UI.PotentialPreselection.PotentialPreselectionCtrl"
|
||||
}
|
||||
}
|
||||
function PotentialPreselectionPanel:Awake()
|
||||
end
|
||||
function PotentialPreselectionPanel:OnEnable()
|
||||
end
|
||||
function PotentialPreselectionPanel:OnDisable()
|
||||
end
|
||||
function PotentialPreselectionPanel:OnDestroy()
|
||||
end
|
||||
return PotentialPreselectionPanel
|
||||
@@ -0,0 +1,137 @@
|
||||
local PreselectionRenameCtrl = class("PreselectionRenameCtrl", BaseCtrl)
|
||||
PreselectionRenameCtrl._mapNodeConfig = {
|
||||
blur = {
|
||||
sNodeName = "t_fullscreen_blur_blue"
|
||||
},
|
||||
aniBlur = {
|
||||
sNodeName = "t_fullscreen_blur_blue",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
aniWindow = {
|
||||
sNodeName = "---Rename---",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
goWindow = {
|
||||
sNodeName = "---Rename---"
|
||||
},
|
||||
txtWindowTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Change_Name"
|
||||
},
|
||||
txtOldName = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Cur_Name"
|
||||
},
|
||||
txtNameDesc = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Potential_Preselection_Name_Input"
|
||||
},
|
||||
txtCurName = {sComponentName = "TMP_Text"},
|
||||
inputRename = {
|
||||
sComponentName = "TMP_InputField"
|
||||
},
|
||||
btnBlur = {
|
||||
sNodeName = "snapshot",
|
||||
sComponentName = "Button",
|
||||
callback = "OnBtnClick_Cancel"
|
||||
},
|
||||
btnClose = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Cancel"
|
||||
},
|
||||
btnCancel = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Cancel"
|
||||
},
|
||||
btnConfirm1 = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Confirm"
|
||||
},
|
||||
txtBtnConfirm = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Btn_Confirm"
|
||||
},
|
||||
txtBtnCancel = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Btn_Cancel"
|
||||
}
|
||||
}
|
||||
PreselectionRenameCtrl._mapEventConfig = {}
|
||||
function PreselectionRenameCtrl:Open()
|
||||
self:Refresh()
|
||||
self:PlayInAni()
|
||||
end
|
||||
function PreselectionRenameCtrl:Refresh()
|
||||
local bInit = NovaAPI.IsDirtyWordsInit()
|
||||
if not bInit then
|
||||
NovaAPI.InitDirtyWords()
|
||||
end
|
||||
NovaAPI.SetTMPInputFieldText(self._mapNode.inputRename, "")
|
||||
if self.sCurName ~= nil and self.sCurName ~= "" then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCurName, self.sCurName)
|
||||
elseif self.mapPreselection.sName == "" or self.mapPreselection.sName == nil then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCurName, ConfigTable.GetUIText("RoguelikeBuild_EmptyBuildName"))
|
||||
else
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCurName, self.mapPreselection.sName)
|
||||
end
|
||||
end
|
||||
function PreselectionRenameCtrl:PlayInAni()
|
||||
self._mapNode.goWindow:SetActive(true)
|
||||
self._mapNode.blur:SetActive(true)
|
||||
self._mapNode.aniWindow:Play("t_window_04_t_in")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.3)
|
||||
end
|
||||
function PreselectionRenameCtrl:PlayOutAni()
|
||||
self._mapNode.aniWindow:Play("t_window_04_t_out")
|
||||
self._mapNode.aniBlur:SetTrigger("tOut")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.2)
|
||||
self:AddTimer(1, 0.2, "Close", true, true, true)
|
||||
end
|
||||
function PreselectionRenameCtrl:Close()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.PreselectionRename)
|
||||
end
|
||||
function PreselectionRenameCtrl:Awake()
|
||||
local tbParam = self:GetPanelParam()
|
||||
if type(tbParam) == "table" then
|
||||
self.mapPreselection = tbParam[1]
|
||||
self.callback = tbParam[2]
|
||||
self.bSkip = tbParam[3]
|
||||
self.sCurName = tbParam[4]
|
||||
end
|
||||
end
|
||||
function PreselectionRenameCtrl:OnEnable()
|
||||
self:Open()
|
||||
end
|
||||
function PreselectionRenameCtrl:OnDisable()
|
||||
end
|
||||
function PreselectionRenameCtrl:OnDestroy()
|
||||
end
|
||||
function PreselectionRenameCtrl:OnBtnClick_Cancel(btn)
|
||||
self:PlayOutAni()
|
||||
end
|
||||
function PreselectionRenameCtrl:OnBtnClick_Confirm(btn)
|
||||
local sNewName = NovaAPI.GetTMPInputFieldText(self._mapNode.inputRename)
|
||||
if sNewName == "" then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("BUILD_05"))
|
||||
return
|
||||
end
|
||||
local bInit = NovaAPI.IsDirtyWordsInit()
|
||||
if not bInit then
|
||||
NovaAPI.InitDirtyWords()
|
||||
end
|
||||
if NovaAPI.IsDirtyString(sNewName) then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("PLAYER_01"))
|
||||
return
|
||||
end
|
||||
if self.bSkip then
|
||||
self:PlayOutAni()
|
||||
self.callback(sNewName)
|
||||
else
|
||||
local callback = function()
|
||||
self:PlayOutAni()
|
||||
self.callback(sNewName)
|
||||
end
|
||||
PlayerData.PotentialPreselection:SendChangePreselectionName(self.mapPreselection.nId, sNewName, callback)
|
||||
end
|
||||
end
|
||||
return PreselectionRenameCtrl
|
||||
@@ -0,0 +1,17 @@
|
||||
local PreselectionRenamePanel = class("PreselectionRenamePanel", BasePanel)
|
||||
PreselectionRenamePanel._bIsMainPanel = false
|
||||
PreselectionRenamePanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "PotentialPreselection/PreselectionRenamePanel.prefab",
|
||||
sCtrlName = "Game.UI.PotentialPreselection.PreselectionRenameCtrl"
|
||||
}
|
||||
}
|
||||
function PreselectionRenamePanel:Awake()
|
||||
end
|
||||
function PreselectionRenamePanel:OnEnable()
|
||||
end
|
||||
function PreselectionRenamePanel:OnDisable()
|
||||
end
|
||||
function PreselectionRenamePanel:OnDestroy()
|
||||
end
|
||||
return PreselectionRenamePanel
|
||||
Reference in New Issue
Block a user