Initial version - 1.2.0.60
EN: 1.2.0.60 CN: 1.2.0.61 JP: 1.2.0.63 KR: 1.2.0.67
This commit is contained in:
@@ -0,0 +1,222 @@
|
||||
local FriendCarteCtrl = class("FriendCarteCtrl", BaseCtrl)
|
||||
FriendCarteCtrl._mapNodeConfig = {
|
||||
blur = {
|
||||
sNodeName = "t_fullscreen_blur_blue"
|
||||
},
|
||||
aniBlur = {
|
||||
sNodeName = "t_fullscreen_blur_blue",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
btnBlur = {
|
||||
sNodeName = "snapshot",
|
||||
sComponentName = "Button",
|
||||
callback = "OnBtnClick_Close"
|
||||
},
|
||||
txtWindowTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Title_Carte"
|
||||
},
|
||||
btnClose = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Close"
|
||||
},
|
||||
goRoot = {
|
||||
sNodeName = "---Carte---"
|
||||
},
|
||||
aniRoot = {
|
||||
sNodeName = "---Carte---",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
imgPlayerHead = {sComponentName = "Image"},
|
||||
txtWorldClass = {sComponentName = "TMP_Text"},
|
||||
txtRankCn = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "MainView_RANK"
|
||||
},
|
||||
txtName = {sComponentName = "TMP_Text"},
|
||||
txtFriendTitle = {sComponentName = "TMP_Text"},
|
||||
txtFriendTitleName = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_TitleTag"
|
||||
},
|
||||
txtUIDCn = {sComponentName = "TMP_Text", sLanguageId = "Friend_UID"},
|
||||
txtUID = {sComponentName = "TMP_Text"},
|
||||
txtSign = {sComponentName = "TMP_Text"},
|
||||
txtTitleChar = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_CoreMember"
|
||||
},
|
||||
goChar = {
|
||||
nCount = 3,
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateCharCtrl"
|
||||
},
|
||||
imgEmpty = {nCount = 3},
|
||||
btnAdd = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Add"
|
||||
},
|
||||
txtBtnAdd = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Btn_Add"
|
||||
},
|
||||
btnDel = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Del"
|
||||
},
|
||||
txtBtnDel = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Btn_Del"
|
||||
},
|
||||
btnDone = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Done"
|
||||
},
|
||||
txtBtnDone = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_HasRequested"
|
||||
},
|
||||
goHonorTitle = {
|
||||
nCount = 3,
|
||||
sCtrlName = "Game.UI.FriendEx.HonorTitleCtrl"
|
||||
}
|
||||
}
|
||||
FriendCarteCtrl._mapEventConfig = {}
|
||||
function FriendCarteCtrl:Open()
|
||||
self:RefreshButton()
|
||||
self:RefreshInfo()
|
||||
self:RefreshMember()
|
||||
self:RefreshHonorTitle()
|
||||
self:PlayInAni()
|
||||
end
|
||||
function FriendCarteCtrl:RefreshButton()
|
||||
local bFriend = PlayerData.Friend:JudgeIsFriend(self.mapFriend.nUId)
|
||||
if bFriend then
|
||||
self._mapNode.btnAdd.gameObject:SetActive(false)
|
||||
self._mapNode.btnDone.gameObject:SetActive(false)
|
||||
self._mapNode.btnDel.gameObject:SetActive(true)
|
||||
else
|
||||
self._mapNode.btnAdd.gameObject:SetActive(self.bDone == false and self.nType == 3 or self.nType == 2)
|
||||
self._mapNode.btnDone.gameObject:SetActive(self.bDone == true)
|
||||
self._mapNode.btnDel.gameObject:SetActive(false)
|
||||
end
|
||||
end
|
||||
function FriendCarteCtrl:RefreshInfo()
|
||||
local mapCfg = ConfigTable.GetData("PlayerHead", self.mapFriend.nHeadIconId)
|
||||
if mapCfg then
|
||||
self:SetPngSprite(self._mapNode.imgPlayerHead, mapCfg.Icon)
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtWorldClass, self.mapFriend.nWorldClass)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtName, self.mapFriend.sName)
|
||||
local sTitle = orderedFormat(ConfigTable.GetUIText("FriendPanel_PlayerTitle") or "", ConfigTable.GetData("Title", self.mapFriend.nTitlePrefix).Desc, ConfigTable.GetData("Title", self.mapFriend.nTitleSuffix).Desc)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtFriendTitle, self.mapFriend.nTitlePrefix == 0 and "" or sTitle)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtUID, self.mapFriend.nUId)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtSign, self.mapFriend.sSign == "" and ConfigTable.GetUIText("Friend_DefaultSign") or self.mapFriend.sSign)
|
||||
end
|
||||
function FriendCarteCtrl:RefreshMember()
|
||||
local tbChar = {}
|
||||
if self.mapFriend.tbChar then
|
||||
for i = 1, 3 do
|
||||
if not self.mapFriend.tbChar[i] then
|
||||
tbChar[i] = {CharId = 0}
|
||||
else
|
||||
tbChar[i] = self.mapFriend.tbChar[i]
|
||||
end
|
||||
end
|
||||
end
|
||||
for i = 1, 3 do
|
||||
self._mapNode.imgEmpty[i]:SetActive(tbChar[i].CharId == 0)
|
||||
self._mapNode.goChar[i].gameObject:SetActive(tbChar[i].CharId ~= 0)
|
||||
if tbChar[i].CharId ~= 0 then
|
||||
self._mapNode.goChar[i]:SetSpecificChar(tbChar[i].CharId, tbChar[i].Level, tbChar[i].Skin)
|
||||
end
|
||||
end
|
||||
end
|
||||
function FriendCarteCtrl:RefreshHonorTitle()
|
||||
for i = 1, 3 do
|
||||
local tbHonorTitle = self.mapFriend.tbHonorTitle or {}
|
||||
if tbHonorTitle[i] ~= nil and tbHonorTitle[i].Id > 0 then
|
||||
local honorData = ConfigTable.GetData("Honor", tbHonorTitle[i].Id)
|
||||
self._mapNode.goHonorTitle[i]:SetHonotTitle(honorData.Id, i == 1, tbHonorTitle[i].AffinityLV)
|
||||
end
|
||||
self._mapNode.goHonorTitle[i].gameObject:SetActive(tbHonorTitle[i] ~= nil and tbHonorTitle[i].Id > 0)
|
||||
end
|
||||
end
|
||||
function FriendCarteCtrl:PlayInAni()
|
||||
self._mapNode.goRoot:SetActive(true)
|
||||
self._mapNode.aniRoot:Play("t_window_04_t_in")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.3)
|
||||
end
|
||||
function FriendCarteCtrl:PlayOutAni()
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.2)
|
||||
self._mapNode.aniRoot:Play("t_window_04_t_out")
|
||||
self:AddTimer(1, 0.2, function()
|
||||
self._mapNode.goRoot:SetActive(false)
|
||||
end, true, true, true)
|
||||
end
|
||||
function FriendCarteCtrl:Awake()
|
||||
local tbParam = self:GetPanelParam()
|
||||
if type(tbParam) == "table" then
|
||||
self.mapFriend = tbParam[1]
|
||||
self.nType = tbParam[2]
|
||||
self.bDone = tbParam[3]
|
||||
self.callback = tbParam[4]
|
||||
end
|
||||
end
|
||||
function FriendCarteCtrl:OnEnable()
|
||||
self._mapNode.blur:SetActive(true)
|
||||
self:Open()
|
||||
end
|
||||
function FriendCarteCtrl:OnDisable()
|
||||
end
|
||||
function FriendCarteCtrl:OnDestroy()
|
||||
end
|
||||
function FriendCarteCtrl:OnBtnClick_Add()
|
||||
local nFriendNum = PlayerData.Friend:GetFriendListNum()
|
||||
if nFriendNum == ConfigTable.GetConfigNumber("FriendMax") then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("FRIEND_00"))
|
||||
return
|
||||
end
|
||||
if self.nType == 2 then
|
||||
local callback = function()
|
||||
self:OnBtnClick_Close()
|
||||
EventManager.Hit("FriendRefreshRequest")
|
||||
end
|
||||
PlayerData.Friend:SendFriendAddAgreeReq(self.mapFriend.nUId, callback)
|
||||
elseif self.nType == 3 then
|
||||
local callback = function()
|
||||
self.callback()
|
||||
self._mapNode.btnAdd.gameObject:SetActive(false)
|
||||
self._mapNode.btnDone.gameObject:SetActive(true)
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("FRIEND_01"))
|
||||
end
|
||||
PlayerData.Friend:SendAddFriendReq(self.mapFriend.nUId, callback)
|
||||
end
|
||||
end
|
||||
function FriendCarteCtrl:OnBtnClick_Del()
|
||||
local confirmCallback = function()
|
||||
local callback = function()
|
||||
self:OnBtnClick_Close()
|
||||
EventManager.Hit("FriendRefreshList")
|
||||
end
|
||||
PlayerData.Friend:SendFriendDeleteReq(self.mapFriend.nUId, callback)
|
||||
end
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Confirm,
|
||||
sContent = ConfigTable.GetUIText("Friend_DeleteHint"),
|
||||
callbackConfirm = confirmCallback
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
end
|
||||
function FriendCarteCtrl:OnBtnClick_Done()
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Friend_GraySend"))
|
||||
end
|
||||
function FriendCarteCtrl:OnBtnClick_Close()
|
||||
self:PlayOutAni()
|
||||
self._mapNode.aniBlur:SetTrigger("tOut")
|
||||
self:AddTimer(1, 0.2, function()
|
||||
self._mapNode.blur:SetActive(false)
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.FriendCarte)
|
||||
end, true, true, true)
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.2)
|
||||
end
|
||||
return FriendCarteCtrl
|
||||
@@ -0,0 +1,17 @@
|
||||
local FriendCartePanel = class("FriendCartePanel", BasePanel)
|
||||
FriendCartePanel._bIsMainPanel = false
|
||||
FriendCartePanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "FriendEx/FriendCartePanel.prefab",
|
||||
sCtrlName = "Game.UI.FriendEx.FriendCarteCtrl"
|
||||
}
|
||||
}
|
||||
function FriendCartePanel:Awake()
|
||||
end
|
||||
function FriendCartePanel:OnEnable()
|
||||
end
|
||||
function FriendCartePanel:OnDisable()
|
||||
end
|
||||
function FriendCartePanel:OnDestroy()
|
||||
end
|
||||
return FriendCartePanel
|
||||
@@ -0,0 +1,251 @@
|
||||
local FriendCtrl = class("FriendCtrl", BaseCtrl)
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local Tog = {
|
||||
Info = 1,
|
||||
List = 2,
|
||||
Request = 3
|
||||
}
|
||||
local AnimName = {
|
||||
[1] = "FriendPanel_Info_",
|
||||
[2] = "FriendPanel_List_",
|
||||
[3] = "FriendPanel_Request_"
|
||||
}
|
||||
FriendCtrl._mapNodeConfig = {
|
||||
TopBar = {
|
||||
sNodeName = "TopBarPanel",
|
||||
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
|
||||
},
|
||||
tog = {
|
||||
nCount = 3,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_ChangeSheet"
|
||||
},
|
||||
ctrlTog = {
|
||||
nCount = 3,
|
||||
sNodeName = "tog",
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateToggleCtrl"
|
||||
},
|
||||
blur = {
|
||||
sNodeName = "t_fullscreen_blur_blue"
|
||||
},
|
||||
aniBlur = {
|
||||
sNodeName = "t_fullscreen_blur_blue",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
animRoot = {
|
||||
sNodeName = "----SafeAreaRoot----",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
btnBlur = {
|
||||
sNodeName = "snapshot",
|
||||
sComponentName = "Button",
|
||||
callback = "OnBtnClick_ClosePop"
|
||||
},
|
||||
trActor2D_PNG = {
|
||||
sNodeName = "----Actor2D_PNG----",
|
||||
sComponentName = "Transform"
|
||||
},
|
||||
Info = {
|
||||
sNodeName = "---Info---",
|
||||
sCtrlName = "Game.UI.FriendEx.FriendInfoCtrl"
|
||||
},
|
||||
List = {
|
||||
sNodeName = "---List---",
|
||||
sCtrlName = "Game.UI.FriendEx.FriendListCtrl"
|
||||
},
|
||||
Request = {
|
||||
sNodeName = "---Request---",
|
||||
sCtrlName = "Game.UI.FriendEx.FriendRequestCtrl"
|
||||
},
|
||||
Rename = {
|
||||
sNodeName = "---Rename---",
|
||||
sCtrlName = "Game.UI.FriendEx.FriendRenameCtrl"
|
||||
},
|
||||
Head = {
|
||||
sNodeName = "---Head---",
|
||||
sCtrlName = "Game.UI.FriendEx.FriendHeadCtrl"
|
||||
},
|
||||
Search = {
|
||||
sNodeName = "---Search---",
|
||||
sCtrlName = "Game.UI.FriendEx.FriendSearchCtrl"
|
||||
},
|
||||
Title = {
|
||||
sNodeName = "---Title---",
|
||||
sCtrlName = "Game.UI.FriendEx.FriendTitleCtrl"
|
||||
},
|
||||
Signature = {
|
||||
sNodeName = "---Signature---",
|
||||
sCtrlName = "Game.UI.FriendEx.FriendSignatureCtrl"
|
||||
},
|
||||
Member = {
|
||||
sNodeName = "---Member---",
|
||||
sCtrlName = "Game.UI.FriendEx.FriendMemberCtrl"
|
||||
},
|
||||
Portrait = {
|
||||
sNodeName = "---Portrait---",
|
||||
sCtrlName = "Game.UI.FriendEx.FriendPortraitCtrl"
|
||||
},
|
||||
Recommend = {
|
||||
sNodeName = "---Recommend---",
|
||||
sCtrlName = "Game.UI.FriendEx.FriendRecommendCtrl"
|
||||
},
|
||||
HonorTitle = {
|
||||
sNodeName = "---HonorTitle---",
|
||||
sCtrlName = "Game.UI.FriendEx.FriendHonorTitleCtrl"
|
||||
},
|
||||
redDotTog = {nCount = 3}
|
||||
}
|
||||
FriendCtrl._mapEventConfig = {
|
||||
FriendChangeHead = "OnEvent_ChangeHead",
|
||||
FriendChangeName = "OnEvent_ChangeName",
|
||||
FriendChangeTitle = "OnEvent_ChangeTitle",
|
||||
FriendChangeSignature = "OnEvent_ChangeSignature",
|
||||
FriendChangePortrait = "OnEvent_ChangePortrait",
|
||||
FriendChangeMember = "OnEvent_ChangeMember",
|
||||
FriendClosePop = "OnBtnClick_ClosePop",
|
||||
FriendSearch = "OnEvent_Search",
|
||||
FriendRecommend = "OnEvent_Recommend",
|
||||
FriendRefreshActor2D = "OnEvent_RefreshActor2D",
|
||||
FriendChangeHonorTitle = "OnEvent_ChangeHonorTitle"
|
||||
}
|
||||
function FriendCtrl:RegisterRedDot()
|
||||
RedDotManager.RegisterNode(RedDotDefine.Friend_Info, nil, self._mapNode.redDotTog[1])
|
||||
RedDotManager.RegisterNode(RedDotDefine.Friend_Energy, nil, self._mapNode.redDotTog[2])
|
||||
RedDotManager.RegisterNode(RedDotDefine.Friend_Apply, nil, self._mapNode.redDotTog[3])
|
||||
end
|
||||
function FriendCtrl:SwitchTog()
|
||||
if self.nPrevTog ~= nil then
|
||||
local animPrev = AnimName[self.nPrevTog] .. "out"
|
||||
self._mapNode.animRoot:Play(animPrev)
|
||||
local nAnimTime = NovaAPI.GetAnimClipLength(self._mapNode.animRoot, {animPrev})
|
||||
if self.timerAnim ~= nil then
|
||||
self.timerAnim:Cancel()
|
||||
self.timerAnim = nil
|
||||
end
|
||||
self.timerAnim = self:AddTimer(1, nAnimTime, function()
|
||||
self:OpenCtrl()
|
||||
end, true, true, true)
|
||||
else
|
||||
self:OpenCtrl()
|
||||
end
|
||||
end
|
||||
function FriendCtrl:OpenCtrl()
|
||||
self._mapNode.Info.gameObject:SetActive(self.nCurTog == Tog.Info)
|
||||
self._mapNode.List.gameObject:SetActive(self.nCurTog == Tog.List)
|
||||
self._mapNode.Request.gameObject:SetActive(self.nCurTog == Tog.Request)
|
||||
self._mapNode.trActor2D_PNG.gameObject:SetActive(self.nCurTog == Tog.Info)
|
||||
if self.nCurTog == Tog.Info then
|
||||
self._mapNode.Info:Refresh(self._panel.nId)
|
||||
elseif self.nCurTog == Tog.List then
|
||||
self._mapNode.List:Refresh()
|
||||
elseif self.nCurTog == Tog.Request then
|
||||
self._mapNode.Request:Refresh()
|
||||
end
|
||||
if self.nPrevTog ~= nil then
|
||||
local animCur = AnimName[self.nCurTog] .. "in"
|
||||
self._mapNode.animRoot:Play(animCur)
|
||||
end
|
||||
end
|
||||
function FriendCtrl:SetDefaultTog()
|
||||
if self.nCurTog == nil then
|
||||
self.nCurTog = Tog.Info
|
||||
end
|
||||
for i = 1, 3 do
|
||||
self._mapNode.ctrlTog[i]:SetDefault(i == self.nCurTog)
|
||||
end
|
||||
self:SwitchTog()
|
||||
end
|
||||
function FriendCtrl:RefreshTogText()
|
||||
self._mapNode.ctrlTog[1]:SetText(ConfigTable.GetUIText("Friend_Tog_Info"))
|
||||
self._mapNode.ctrlTog[2]:SetText(ConfigTable.GetUIText("Friend_Tog_List"))
|
||||
self._mapNode.ctrlTog[3]:SetText(ConfigTable.GetUIText("Friend_Tog_Add"))
|
||||
end
|
||||
function FriendCtrl:FadeIn(bPlayFadeIn)
|
||||
EventManager.Hit(EventId.SetTransition)
|
||||
end
|
||||
function FriendCtrl:Awake()
|
||||
self.ctrlPop = nil
|
||||
self:RefreshTogText()
|
||||
end
|
||||
function FriendCtrl:OnEnable()
|
||||
self:SetDefaultTog()
|
||||
self:RegisterRedDot()
|
||||
end
|
||||
function FriendCtrl:OnDisable()
|
||||
if self.timerAnim ~= nil then
|
||||
self.timerAnim:Cancel()
|
||||
self.timerAnim = nil
|
||||
end
|
||||
end
|
||||
function FriendCtrl:OnDestroy()
|
||||
end
|
||||
function FriendCtrl:OnBtnClick_ChangeSheet(btn, nIndex)
|
||||
if nIndex == self.nCurTog then
|
||||
return
|
||||
end
|
||||
self._mapNode.ctrlTog[nIndex]:SetTrigger(true)
|
||||
self._mapNode.ctrlTog[self.nCurTog]:SetTrigger(false)
|
||||
self.nPrevTog = self.nCurTog
|
||||
self.nCurTog = nIndex
|
||||
self:SwitchTog()
|
||||
end
|
||||
function FriendCtrl:OnEvent_ChangeHead()
|
||||
self.ctrlPop = self._mapNode.Head
|
||||
self._mapNode.Head:Open()
|
||||
self._mapNode.blur:SetActive(true)
|
||||
end
|
||||
function FriendCtrl:OnEvent_ChangeName()
|
||||
self.ctrlPop = self._mapNode.Rename
|
||||
self._mapNode.Rename:Open()
|
||||
self._mapNode.blur:SetActive(true)
|
||||
end
|
||||
function FriendCtrl:OnEvent_ChangeTitle()
|
||||
self.ctrlPop = self._mapNode.Title
|
||||
self._mapNode.Title:Open()
|
||||
self._mapNode.blur:SetActive(true)
|
||||
end
|
||||
function FriendCtrl:OnEvent_ChangeSignature()
|
||||
self.ctrlPop = self._mapNode.Signature
|
||||
self._mapNode.Signature:Open()
|
||||
self._mapNode.blur:SetActive(true)
|
||||
end
|
||||
function FriendCtrl:OnEvent_ChangeMember()
|
||||
self.ctrlPop = self._mapNode.Member
|
||||
self._mapNode.Member:Open()
|
||||
self._mapNode.blur:SetActive(true)
|
||||
end
|
||||
function FriendCtrl:OnEvent_ChangePortrait()
|
||||
self.ctrlPop = self._mapNode.Portrait
|
||||
self._mapNode.Portrait:Open()
|
||||
self._mapNode.blur:SetActive(true)
|
||||
end
|
||||
function FriendCtrl:OnEvent_Search(mapData)
|
||||
self.ctrlPop = self._mapNode.Search
|
||||
self._mapNode.Search:Open(mapData)
|
||||
self._mapNode.blur:SetActive(true)
|
||||
end
|
||||
function FriendCtrl:OnEvent_Recommend(mapData)
|
||||
self.ctrlPop = self._mapNode.Recommend
|
||||
self._mapNode.Recommend:Open(mapData)
|
||||
self._mapNode.blur:SetActive(true)
|
||||
end
|
||||
function FriendCtrl:OnEvent_ChangeHonorTitle()
|
||||
self.ctrlPop = self._mapNode.HonorTitle
|
||||
self._mapNode.HonorTitle:Open()
|
||||
self._mapNode.blur:SetActive(true)
|
||||
end
|
||||
function FriendCtrl:OnBtnClick_ClosePop()
|
||||
if self.ctrlPop then
|
||||
self.ctrlPop:PlayOutAni()
|
||||
self.ctrlPop = nil
|
||||
end
|
||||
self._mapNode.aniBlur:SetTrigger("tOut")
|
||||
self:AddTimer(1, 0.2, function()
|
||||
self._mapNode.blur:SetActive(false)
|
||||
end, true, true, true)
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.2)
|
||||
end
|
||||
function FriendCtrl:OnEvent_RefreshActor2D(nCharId, nSkinId)
|
||||
Actor2DManager.SetActor2D_PNG(self._mapNode.trActor2D_PNG, self:GetPanelId(), nCharId, nSkinId)
|
||||
end
|
||||
return FriendCtrl
|
||||
@@ -0,0 +1,287 @@
|
||||
local FriendGridCtrl = class("FriendGridCtrl", BaseCtrl)
|
||||
local GridType = {
|
||||
Friend = 1,
|
||||
Request = 2,
|
||||
Search = 3,
|
||||
Energy = 4
|
||||
}
|
||||
FriendGridCtrl._mapNodeConfig = {
|
||||
imgHead = {sComponentName = "Image"},
|
||||
txtWorldClass = {sComponentName = "TMP_Text"},
|
||||
txtRankCn = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "MainView_RANK"
|
||||
},
|
||||
txtName = {sComponentName = "TMP_Text"},
|
||||
txtTitle = {sComponentName = "TMP_Text"},
|
||||
txtTitleName = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_TitleTag"
|
||||
},
|
||||
imgStar = {},
|
||||
txtLastLogin = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Login"
|
||||
},
|
||||
txtLoginTime1 = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_24Hours"
|
||||
},
|
||||
txtLoginTime2 = {sComponentName = "TMP_Text"},
|
||||
txtUID = {sComponentName = "TMP_Text"},
|
||||
txtUIDCn = {sComponentName = "TMP_Text", sLanguageId = "Friend_UID"},
|
||||
goEnergy = {},
|
||||
btnSend = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Send"
|
||||
},
|
||||
imgSend = {},
|
||||
btnGet = {
|
||||
nCount = 2,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Get"
|
||||
},
|
||||
imgGet = {},
|
||||
goRequest = {},
|
||||
btnAdopt = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Adopt"
|
||||
},
|
||||
btnRefuse = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Refuse"
|
||||
},
|
||||
goSearch = {},
|
||||
btnAdd = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Add"
|
||||
},
|
||||
imgUnable = {},
|
||||
txtUnable = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_HasRequested"
|
||||
},
|
||||
goFriend = {},
|
||||
btnStar = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Star"
|
||||
},
|
||||
imgStarOn = {},
|
||||
imgStarOff = {},
|
||||
btnDel = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Delete"
|
||||
},
|
||||
btnDetail = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Detail"
|
||||
},
|
||||
goHonorTitle_ = {
|
||||
nCount = 3,
|
||||
sCtrlName = "Game.UI.FriendEx.HonorTitleCtrl"
|
||||
}
|
||||
}
|
||||
FriendGridCtrl._mapEventConfig = {}
|
||||
function FriendGridCtrl:SetType(nType)
|
||||
self.nType = nType
|
||||
self._mapNode.goEnergy:SetActive(nType == GridType.Energy)
|
||||
self._mapNode.goRequest:SetActive(nType == GridType.Request)
|
||||
self._mapNode.goSearch:SetActive(nType == GridType.Search)
|
||||
self._mapNode.goFriend:SetActive(nType == GridType.Friend)
|
||||
end
|
||||
function FriendGridCtrl:Refresh(mapFriend)
|
||||
if self.nType == GridType.Search then
|
||||
self._mapNode.goSearch:SetActive(not PlayerData.Friend:JudgeIsFriend(mapFriend.nUId))
|
||||
end
|
||||
self.mapFriend = mapFriend
|
||||
self:RefreshInfo()
|
||||
self:RefreshStar()
|
||||
self:RefreshSend()
|
||||
self:RefreshGet()
|
||||
self:RefreshAdd()
|
||||
self:RefreshHonorTitle()
|
||||
end
|
||||
function FriendGridCtrl:RefreshInfo()
|
||||
local mapCfg = ConfigTable.GetData("PlayerHead", self.mapFriend.nHeadIconId)
|
||||
if mapCfg then
|
||||
self:SetPngSprite(self._mapNode.imgHead, mapCfg.Icon)
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtWorldClass, self.mapFriend.nWorldClass)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtName, self.mapFriend.sName)
|
||||
local sTitle = orderedFormat(ConfigTable.GetUIText("FriendPanel_PlayerTitle") or "", ConfigTable.GetData("Title", self.mapFriend.nTitlePrefix).Desc, ConfigTable.GetData("Title", self.mapFriend.nTitleSuffix).Desc)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTitle, self.mapFriend.nTitlePrefix == 0 and "" or sTitle)
|
||||
local sDate, nLoginTime = PlayerData.Friend:JudgeLogin(self.mapFriend.nLogin)
|
||||
self._mapNode.txtLoginTime1.gameObject:SetActive(nLoginTime == AllEnum.LoginTime.Today)
|
||||
self._mapNode.txtLoginTime2.gameObject:SetActive(nLoginTime ~= AllEnum.LoginTime.Today)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtLoginTime2, sDate)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtUID, self.mapFriend.nUId)
|
||||
end
|
||||
function FriendGridCtrl:RefreshStar()
|
||||
self._mapNode.imgStarOn:SetActive(self.mapFriend.bStar)
|
||||
self._mapNode.imgStarOff:SetActive(not self.mapFriend.bStar)
|
||||
self._mapNode.imgStar:SetActive(self.mapFriend.bStar)
|
||||
end
|
||||
function FriendGridCtrl:RefreshSend()
|
||||
self._mapNode.btnSend.gameObject:SetActive(not self.mapFriend.bSendEnergy)
|
||||
self._mapNode.imgSend:SetActive(self.mapFriend.bSendEnergy)
|
||||
end
|
||||
function FriendGridCtrl:RefreshGet()
|
||||
local nCount = PlayerData.Friend:GetEnergyCount()
|
||||
if nCount >= self.nMaxEnergy then
|
||||
self._mapNode.btnGet[1].gameObject:SetActive(false)
|
||||
self._mapNode.btnGet[2].gameObject:SetActive(false)
|
||||
self._mapNode.imgGet:SetActive(true)
|
||||
return
|
||||
end
|
||||
self._mapNode.btnGet[1].gameObject:SetActive(self.mapFriend.nGetEnergy == 1)
|
||||
self._mapNode.btnGet[2].gameObject:SetActive(self.mapFriend.nGetEnergy == 0)
|
||||
self._mapNode.imgGet:SetActive(self.mapFriend.nGetEnergy == 2)
|
||||
end
|
||||
function FriendGridCtrl:RefreshAdd()
|
||||
for _, v in pairs(self._panel.tbAddCache) do
|
||||
if v == self.mapFriend.nUId then
|
||||
self._mapNode.btnAdd.gameObject:SetActive(false)
|
||||
self._mapNode.imgUnable:SetActive(true)
|
||||
return
|
||||
end
|
||||
end
|
||||
self._mapNode.btnAdd.gameObject:SetActive(true)
|
||||
self._mapNode.imgUnable:SetActive(false)
|
||||
end
|
||||
function FriendGridCtrl:RefreshHonorTitle()
|
||||
for i = 1, 3 do
|
||||
local tbHonorTitle = self.mapFriend.tbHonorTitle or {}
|
||||
if tbHonorTitle[i] ~= nil and tbHonorTitle[i].Id > 0 then
|
||||
local honorData = ConfigTable.GetData("Honor", tbHonorTitle[i].Id)
|
||||
self._mapNode.goHonorTitle_[i]:SetHonotTitle(honorData.Id, i == 1, tbHonorTitle[i].AffinityLV)
|
||||
end
|
||||
self._mapNode.goHonorTitle_[i].gameObject:SetActive(tbHonorTitle[i] ~= nil and tbHonorTitle[i].Id > 0)
|
||||
end
|
||||
end
|
||||
function FriendGridCtrl:Awake()
|
||||
self.nMaxEnergy = ConfigTable.GetConfigNumber("FriendReceiveEnergyMax")
|
||||
end
|
||||
function FriendGridCtrl:OnEnable()
|
||||
end
|
||||
function FriendGridCtrl:OnDisable()
|
||||
end
|
||||
function FriendGridCtrl:OnDestroy()
|
||||
end
|
||||
function FriendGridCtrl:OnBtnClick_Delete(btn)
|
||||
local confirmCallback = function()
|
||||
local callback = function()
|
||||
EventManager.Hit("FriendRefreshList")
|
||||
end
|
||||
PlayerData.Friend:SendFriendDeleteReq(self.mapFriend.nUId, callback)
|
||||
end
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Confirm,
|
||||
sContent = ConfigTable.GetUIText("Friend_DeleteHint"),
|
||||
callbackConfirm = confirmCallback
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
end
|
||||
function FriendGridCtrl:OnBtnClick_Adopt(btn)
|
||||
local nFriendNum = PlayerData.Friend:GetFriendListNum()
|
||||
if nFriendNum == ConfigTable.GetConfigNumber("FriendMax") then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("FRIEND_00"))
|
||||
return
|
||||
end
|
||||
local callback = function()
|
||||
EventManager.Hit("FriendRefreshRequest")
|
||||
end
|
||||
PlayerData.Friend:SendFriendAddAgreeReq(self.mapFriend.nUId, callback)
|
||||
end
|
||||
function FriendGridCtrl:OnBtnClick_Refuse(btn)
|
||||
local callback = function()
|
||||
EventManager.Hit("FriendRefreshRequest")
|
||||
end
|
||||
PlayerData.Friend:SendFriendInvitesDeleteReq({
|
||||
self.mapFriend.nUId
|
||||
}, callback)
|
||||
end
|
||||
function FriendGridCtrl:OnBtnClick_Add(btn)
|
||||
local nFriendNum = PlayerData.Friend:GetFriendListNum()
|
||||
if nFriendNum == ConfigTable.GetConfigNumber("FriendMax") then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("FRIEND_00"))
|
||||
return
|
||||
end
|
||||
local callback = function()
|
||||
table.insert(self._panel.tbAddCache, self.mapFriend.nUId)
|
||||
self._mapNode.btnAdd.gameObject:SetActive(false)
|
||||
self._mapNode.imgUnable:SetActive(true)
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("FRIEND_01"))
|
||||
end
|
||||
PlayerData.Friend:SendAddFriendReq(self.mapFriend.nUId, callback)
|
||||
end
|
||||
function FriendGridCtrl:OnBtnClick_Star(btn)
|
||||
local callback = function()
|
||||
EventManager.Hit("FriendRefreshList")
|
||||
end
|
||||
PlayerData.Friend:SendFriendStarSetReq({
|
||||
self.mapFriend.nUId
|
||||
}, not self.mapFriend.bStar, callback)
|
||||
end
|
||||
function FriendGridCtrl:OnBtnClick_Send(btn)
|
||||
if self.mapFriend.bSendEnergy then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Friend_HasSend"))
|
||||
return
|
||||
end
|
||||
local callback = function(UIds)
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Friend_SendSuc"))
|
||||
for _, nId in pairs(UIds) do
|
||||
if nId == self.mapFriend.nUId then
|
||||
self.mapFriend.bSendEnergy = true
|
||||
break
|
||||
end
|
||||
end
|
||||
self:RefreshSend()
|
||||
end
|
||||
PlayerData.Friend:SendFriendSendEnergyReq({
|
||||
self.mapFriend.nUId
|
||||
}, callback)
|
||||
end
|
||||
function FriendGridCtrl:OnBtnClick_Get(btn, nIndex)
|
||||
if nIndex == 2 and self.mapFriend.nGetEnergy == 0 then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Friend_GetNone"))
|
||||
return
|
||||
end
|
||||
local nCount = PlayerData.Friend:GetEnergyCount()
|
||||
if nCount >= self.nMaxEnergy then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Friend_MaxGet"))
|
||||
return
|
||||
end
|
||||
local callback = function(UIds)
|
||||
for _, nId in pairs(UIds) do
|
||||
if nId == self.mapFriend.nUId then
|
||||
self.mapFriend.nGetEnergy = 2
|
||||
break
|
||||
end
|
||||
end
|
||||
self:RefreshGet()
|
||||
EventManager.Hit("FriendRefreshEnergy")
|
||||
end
|
||||
PlayerData.Friend:SendFriendReceiveEnergyReq({
|
||||
self.mapFriend.nUId
|
||||
}, callback)
|
||||
end
|
||||
function FriendGridCtrl:OnBtnClick_Detail(btn)
|
||||
if self.nType == GridType.Search then
|
||||
local bDone = false
|
||||
for _, v in pairs(self._panel.tbAddCache) do
|
||||
if v == self.mapFriend.nUId then
|
||||
bDone = true
|
||||
break
|
||||
end
|
||||
end
|
||||
local callback = function()
|
||||
table.insert(self._panel.tbAddCache, self.mapFriend.nUId)
|
||||
self._mapNode.btnAdd.gameObject:SetActive(false)
|
||||
self._mapNode.imgUnable:SetActive(true)
|
||||
end
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.FriendCarte, self.mapFriend, self.nType, bDone, callback)
|
||||
else
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.FriendCarte, self.mapFriend, self.nType)
|
||||
end
|
||||
end
|
||||
return FriendGridCtrl
|
||||
@@ -0,0 +1,160 @@
|
||||
local FriendHeadCtrl = class("FriendHeadCtrl", BaseCtrl)
|
||||
FriendHeadCtrl._mapNodeConfig = {
|
||||
txtWindowTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_SelectHead"
|
||||
},
|
||||
imgReviewHead = {sComponentName = "Image"},
|
||||
srHeadList = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
txtReview = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_HeadReview"
|
||||
},
|
||||
btnDetail = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Detail"
|
||||
},
|
||||
txtSource = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "ItemTips_GetWay"
|
||||
},
|
||||
imgSourceTip = {},
|
||||
txtSourceCn = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "ItemTips_GetWay"
|
||||
},
|
||||
txtSourceTip = {sComponentName = "TMP_Text"},
|
||||
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"
|
||||
}
|
||||
}
|
||||
FriendHeadCtrl._mapEventConfig = {}
|
||||
function FriendHeadCtrl:Open()
|
||||
self:Refresh()
|
||||
self:PlayInAni()
|
||||
end
|
||||
function FriendHeadCtrl:Refresh()
|
||||
self.bTipsOpen = false
|
||||
self._mapNode.imgSourceTip:SetActive(self.bTipsOpen)
|
||||
self.tbHead = PlayerData.HeadData:GetPlayerHeadList()
|
||||
self.nSelectIndex = 1
|
||||
self.nCurHead = PlayerData.Base:GetPlayerHeadId()
|
||||
local nHeadNum = #self.tbHead
|
||||
if 0 < nHeadNum then
|
||||
self:SetPngSprite(self._mapNode.imgReviewHead, self.tbHead[1].mapCfg.Icon)
|
||||
self._mapNode.btnDetail.gameObject:SetActive(self.tbHead[1].mapCfg.Desc ~= "")
|
||||
NovaAPI.SetTMPText(self._mapNode.txtSourceTip, self.tbHead[1].mapCfg.Desc)
|
||||
end
|
||||
self._mapNode.srHeadList:Init(nHeadNum, self, self.OnGridRefresh, self.OnGridBtnClick)
|
||||
end
|
||||
function FriendHeadCtrl:OnGridRefresh(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local mapData = self.tbHead[nIndex]
|
||||
local imgHeadIcon = goGrid.transform:Find("btnGrid/AnimRoot/imgCharIcon"):GetComponent("Image")
|
||||
local imgCur1 = goGrid.transform:Find("btnGrid/AnimRoot/imgCur1").gameObject
|
||||
local imgCur2 = goGrid.transform:Find("btnGrid/AnimRoot/imgCur2").gameObject
|
||||
local txtCur = goGrid.transform:Find("btnGrid/AnimRoot/imgCur2/txtCur"):GetComponent("TMP_Text")
|
||||
local imgSelect = goGrid.transform:Find("btnGrid/AnimRoot/imgSelect").gameObject
|
||||
local imgLockMask = goGrid.transform:Find("btnGrid/AnimRoot/imgLockMask").gameObject
|
||||
local mapCfg = mapData.mapCfg
|
||||
self:SetPngSprite(imgHeadIcon, mapCfg.Icon)
|
||||
NovaAPI.SetTMPText(txtCur, ConfigTable.GetUIText("Friend_CurSelect"))
|
||||
imgSelect:SetActive(nIndex == self.nSelectIndex)
|
||||
imgCur1:SetActive(mapData.nId == self.nCurHead)
|
||||
imgCur2:SetActive(mapData.nId == self.nCurHead)
|
||||
imgLockMask:SetActive(mapData.nUnlock == 0)
|
||||
local redDot = goGrid.transform:Find("btnGrid/AnimRoot/redDot").gameObject
|
||||
RedDotManager.RegisterNode(RedDotDefine.Friend_Head_Item, mapData.nId, redDot, nil, nil, true)
|
||||
end
|
||||
function FriendHeadCtrl:OnGridBtnClick(goGrid, gridIndex)
|
||||
self.bTipsOpen = false
|
||||
self._mapNode.imgSourceTip:SetActive(self.bTipsOpen)
|
||||
local nIndex = gridIndex + 1
|
||||
local mapData = self.tbHead[nIndex]
|
||||
if self.nSelectIndex == nIndex then
|
||||
return
|
||||
end
|
||||
local imgSelected = goGrid.transform:Find("btnGrid/AnimRoot/imgSelect").gameObject
|
||||
imgSelected:SetActive(true)
|
||||
self:SetPngSprite(self._mapNode.imgReviewHead, mapData.mapCfg.Icon)
|
||||
self._mapNode.btnDetail.gameObject:SetActive(mapData.mapCfg.Desc ~= "")
|
||||
NovaAPI.SetTMPText(self._mapNode.txtSourceTip, mapData.mapCfg.Desc)
|
||||
local sPath = "Viewport/Content/" .. tostring(self.nSelectIndex - 1) .. "/btnGrid/AnimRoot/imgSelect"
|
||||
local goSelectHead = self._mapNode.srHeadList.transform:Find(sPath)
|
||||
if goSelectHead then
|
||||
goSelectHead.gameObject:SetActive(false)
|
||||
end
|
||||
self.nSelectIndex = nIndex
|
||||
RedDotManager.SetValid(RedDotDefine.Friend_Head_Item, mapData.nId, false)
|
||||
end
|
||||
function FriendHeadCtrl:PlayInAni()
|
||||
self.gameObject:SetActive(true)
|
||||
self.ani:Play("t_window_04_t_in")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.3)
|
||||
end
|
||||
function FriendHeadCtrl:PlayOutAni()
|
||||
self.ani:Play("t_window_04_t_out")
|
||||
self:AddTimer(1, 0.2, "Close", true, true, true)
|
||||
end
|
||||
function FriendHeadCtrl:Close()
|
||||
for _, v in ipairs(self.tbHead) do
|
||||
RedDotManager.SetValid(RedDotDefine.Friend_Head_Item, v.nId, false)
|
||||
end
|
||||
self.gameObject:SetActive(false)
|
||||
end
|
||||
function FriendHeadCtrl:Awake()
|
||||
self.ani = self.gameObject.transform:GetComponent("Animator")
|
||||
self.nSelectIndex = 1
|
||||
self.nEquipIndex = nil
|
||||
self.tbGridRedDot = {}
|
||||
end
|
||||
function FriendHeadCtrl:OnEnable()
|
||||
end
|
||||
function FriendHeadCtrl:OnDisable()
|
||||
end
|
||||
function FriendHeadCtrl:OnDestroy()
|
||||
end
|
||||
function FriendHeadCtrl:OnBtnClick_Cancel(btn)
|
||||
EventManager.Hit("FriendClosePop")
|
||||
end
|
||||
function FriendHeadCtrl:OnBtnClick_Confirm(btn)
|
||||
if self.tbHead[self.nSelectIndex].nId == self.nCurHead then
|
||||
EventManager.Hit("FriendClosePop")
|
||||
return
|
||||
end
|
||||
local mapData = self.tbHead[self.nSelectIndex]
|
||||
if mapData.nUnlock == 0 then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("PlayerHead_Lock_Tip"))
|
||||
return
|
||||
end
|
||||
local nHeadIconId = mapData.nId
|
||||
local callback = function()
|
||||
EventManager.Hit("FriendClosePop")
|
||||
EventManager.Hit("FriendRefreshHead")
|
||||
end
|
||||
PlayerData.HeadData:SendPlayerHeadIconSetReq(nHeadIconId, callback)
|
||||
end
|
||||
function FriendHeadCtrl:OnBtnClick_Detail()
|
||||
self.bTipsOpen = not self.bTipsOpen
|
||||
self._mapNode.imgSourceTip.gameObject:SetActive(self.bTipsOpen)
|
||||
end
|
||||
return FriendHeadCtrl
|
||||
@@ -0,0 +1,386 @@
|
||||
local FriendHonorTitleCtrl = class("FriendHonorTitleCtrl", BaseCtrl)
|
||||
local localdata = require("GameCore.Data.LocalData")
|
||||
local RapidJson = require("rapidjson")
|
||||
FriendHonorTitleCtrl._mapNodeConfig = {
|
||||
btnCancel = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Cancel"
|
||||
},
|
||||
btnClose = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Cancel"
|
||||
},
|
||||
btnConfirm1 = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Confirm"
|
||||
},
|
||||
btnCurHonorTitle = {
|
||||
nCount = 3,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_ChangeHonorTitle"
|
||||
},
|
||||
goCurHonorTitle = {
|
||||
nCount = 3,
|
||||
sCtrlName = "Game.UI.FriendEx.HonorTitleCtrl"
|
||||
},
|
||||
imgSelect = {nCount = 3},
|
||||
svHonorTitle = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
btnTab = {
|
||||
sNodeName = "tab",
|
||||
nCount = 4,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_ChangeHonorTitleType"
|
||||
},
|
||||
imgTab = {nCount = 4},
|
||||
txtTab = {nCount = 4},
|
||||
txtTabUnSelect = {nCount = 4},
|
||||
imgCurHonorTitleBg = {nCount = 3},
|
||||
HonorTitleContent = {},
|
||||
txtWindowTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Honor_Title"
|
||||
},
|
||||
txtBtnCancel = {sComponentName = "TMP_Text", sLanguageId = "BtnCancel"},
|
||||
txtBtnConfirm = {sComponentName = "TMP_Text", sLanguageId = "BtnConfirm"},
|
||||
txtEquipHonorTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Cur_Honor_Title_Equiped"
|
||||
},
|
||||
txtTab1 = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Honor_Title_All"
|
||||
},
|
||||
txtTab2 = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Honor_Title_Achievement"
|
||||
},
|
||||
txtTab3 = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Honor_Title_Affinity"
|
||||
},
|
||||
txtTab4 = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Honor_Title_Activity"
|
||||
},
|
||||
txtTabUnSelect1 = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Honor_Title_All"
|
||||
},
|
||||
txtTabUnSelect2 = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Honor_Title_Achievement"
|
||||
},
|
||||
txtTabUnSelect3 = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Honor_Title_Affinity"
|
||||
},
|
||||
txtTabUnSelect4 = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Honor_Title_Activity"
|
||||
}
|
||||
}
|
||||
FriendHonorTitleCtrl._mapEventConfig = {}
|
||||
local HonorTitleType = {
|
||||
All = 1,
|
||||
Achievement = 2,
|
||||
Affinity = 3,
|
||||
Activity = 4
|
||||
}
|
||||
function FriendHonorTitleCtrl:Open()
|
||||
self:PlayInAni()
|
||||
self.tbCurHonorTitle = {}
|
||||
self.tbAllHonorData = {}
|
||||
self.tbGoChosenState = {}
|
||||
local ownHonorData = PlayerData.Base:GetPlayerHonorTitleList() or {}
|
||||
local curHononData = PlayerData.Base:GetPlayerHonorTitle() or {}
|
||||
for k, v in ipairs(curHononData) do
|
||||
table.insert(self.tbCurHonorTitle, v.Id)
|
||||
end
|
||||
local allData = ConfigTable.Get("Honor")
|
||||
local groupData = {}
|
||||
local foreachHonor = function(mapData)
|
||||
if mapData.IsUnlock == true or ownHonorData ~= nil and table.indexof(ownHonorData, mapData.Id) > 0 then
|
||||
if mapData.Type == GameEnum.honorType.Group then
|
||||
if groupData[mapData.Params[1]] == nil then
|
||||
groupData[mapData.Params[1]] = {}
|
||||
end
|
||||
table.insert(groupData[mapData.Params[1]], mapData)
|
||||
end
|
||||
table.insert(self.tbAllHonorData, mapData)
|
||||
end
|
||||
end
|
||||
ForEachTableLine(allData, foreachHonor)
|
||||
for _, group in pairs(groupData) do
|
||||
local maxPriotity = group[1]
|
||||
for k, v in ipairs(group) do
|
||||
if v.Priotity > maxPriotity.Priotity then
|
||||
table.removebyvalue(self.tbAllHonorData, maxPriotity)
|
||||
maxPriotity = v
|
||||
end
|
||||
end
|
||||
end
|
||||
self:OnBtnClick_ChangeHonorTitle(nil, 1)
|
||||
self:OnBtnClick_ChangeHonorTitleType(nil, 1)
|
||||
self:Refresh()
|
||||
end
|
||||
function FriendHonorTitleCtrl:Refresh()
|
||||
self:RefreshHonorTitle()
|
||||
self:RefreshHonorTitleList()
|
||||
end
|
||||
function FriendHonorTitleCtrl:RefreshHonorTitle()
|
||||
for i = 1, 3 do
|
||||
if self.tbCurHonorTitle[i] ~= nil and self.tbCurHonorTitle[i] ~= 0 then
|
||||
local honorData = ConfigTable.GetData("Honor", self.tbCurHonorTitle[i])
|
||||
local level
|
||||
if honorData.Type == GameEnum.honorType.Character then
|
||||
local affinityData = PlayerData.Char:GetCharAffinityData(honorData.Params[1])
|
||||
level = affinityData.Level
|
||||
end
|
||||
self._mapNode.goCurHonorTitle[i]:SetHonotTitle(honorData.Id, i == 1, level)
|
||||
end
|
||||
self._mapNode.goCurHonorTitle[i].gameObject:SetActive(self.tbCurHonorTitle[i] ~= nil and self.tbCurHonorTitle[i] ~= 0)
|
||||
self._mapNode.imgCurHonorTitleBg[i]:SetActive(self.tbCurHonorTitle[i] == nil or self.tbCurHonorTitle[i] == 0)
|
||||
end
|
||||
end
|
||||
function FriendHonorTitleCtrl:RefreshHonorTitleList()
|
||||
local nCount = 0
|
||||
self.tbRefreshDataList = {}
|
||||
local tbCachedGroupHonorData = {}
|
||||
if self.nSelectedType == HonorTitleType.All then
|
||||
nCount = #self.tbAllHonorData
|
||||
self.tbRefreshDataList = self.tbAllHonorData
|
||||
else
|
||||
for k, v in ipairs(self.tbAllHonorData) do
|
||||
local data = v
|
||||
if data.TabType == GameEnum.honorTabType.Achieve then
|
||||
if self.nSelectedType == HonorTitleType.Achievement then
|
||||
if tbCachedGroupHonorData[data.Id] ~= nil then
|
||||
if tbCachedGroupHonorData[data.Id] < data.Priotity then
|
||||
tbCachedGroupHonorData[data.Id] = data.Priotity
|
||||
table.insert(self.tbRefreshDataList, v)
|
||||
end
|
||||
else
|
||||
tbCachedGroupHonorData[data.Id] = data.Priotity
|
||||
table.insert(self.tbRefreshDataList, v)
|
||||
end
|
||||
end
|
||||
elseif data.TabType == GameEnum.honorTabType.Character then
|
||||
if self.nSelectedType == HonorTitleType.Affinity then
|
||||
table.insert(self.tbRefreshDataList, v)
|
||||
end
|
||||
elseif data.TabType == GameEnum.honorTabType.Activity and self.nSelectedType == HonorTitleType.Activity then
|
||||
table.insert(self.tbRefreshDataList, v)
|
||||
end
|
||||
end
|
||||
nCount = #self.tbRefreshDataList
|
||||
end
|
||||
table.sort(self.tbRefreshDataList, function(a, b)
|
||||
if a.Sort ~= b.Sort then
|
||||
return a.Sort > b.Sort
|
||||
else
|
||||
return a.Id < b.Id
|
||||
end
|
||||
end)
|
||||
self.tbHonorTitle = {}
|
||||
self.tbGridRedDot = {}
|
||||
self._mapNode.HonorTitleContent:SetActive(0 < nCount)
|
||||
if 0 < nCount then
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self._mapNode.svHonorTitle:Init(nCount, self, self.OnGridRefresh)
|
||||
end
|
||||
end
|
||||
function FriendHonorTitleCtrl:RefreshReddot(honorId)
|
||||
local sJson = localdata.GetPlayerLocalData("HonorTitle")
|
||||
local localHonorTilte = decodeJson(sJson)
|
||||
if type(localHonorTilte) ~= "table" then
|
||||
return
|
||||
end
|
||||
local bFind = false
|
||||
for k, v in pairs(localHonorTilte) do
|
||||
if tonumber(v) == honorId then
|
||||
RedDotManager.SetValid(RedDotDefine.Friend_Honor_Title_Item, honorId, false)
|
||||
table.remove(localHonorTilte, k)
|
||||
bFind = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if bFind then
|
||||
localdata.SetPlayerLocalData("HonorTitle", RapidJson.encode(localHonorTilte))
|
||||
end
|
||||
end
|
||||
function FriendHonorTitleCtrl:OnGridRefresh(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local honorData = self.tbRefreshDataList[nIndex]
|
||||
local btnGrid = goGrid.transform:Find("btnGrid"):GetComponent("UIButton")
|
||||
local animRoot = btnGrid.transform:Find("AnimRoot")
|
||||
local imgHonorTitleChooseBg = animRoot:Find("imgHonorTitleChooseBg"):GetComponent("Image")
|
||||
local goHonorTitle = animRoot:Find("goHonorTitle")
|
||||
local goChosenState = animRoot:Find("goChosenState")
|
||||
local goEquipState = animRoot:Find("goEquipState")
|
||||
local imgHonorTitleChooseBg1 = goChosenState:Find("imgHonorTitleChooseBg1"):GetComponent("Image")
|
||||
local imgHonorTitleEquipBg = goEquipState:Find("imgHonorTitleEquipBg"):GetComponent("Image")
|
||||
local txtCurChoose = goChosenState:Find("imgBg/txtCurChoose"):GetComponent("TMP_Text")
|
||||
local txtCurEquip = goEquipState:Find("imgBg/txtCurEquip"):GetComponent("TMP_Text")
|
||||
NovaAPI.SetTMPText(txtCurChoose, ConfigTable.GetUIText("Honor_Title_State_CurChoose"))
|
||||
NovaAPI.SetTMPText(txtCurEquip, ConfigTable.GetUIText("Honor_Title_State_CurEquip"))
|
||||
local nInstanceId = goGrid:GetInstanceID()
|
||||
if not self.tbGridCtrl[nInstanceId] then
|
||||
self.tbGridCtrl[nInstanceId] = self:BindCtrlByNode(goHonorTitle, "Game.UI.FriendEx.HonorTitleCtrl")
|
||||
end
|
||||
self.tbGridRedDot[nInstanceId] = honorData.Id
|
||||
local ctrl = self.tbGridCtrl[nInstanceId]
|
||||
ctrl:RegisterRedDot(honorData.Id)
|
||||
local level
|
||||
if honorData.Type == GameEnum.honorType.Character then
|
||||
local affinityData = PlayerData.Char:GetCharAffinityData(honorData.Params[1])
|
||||
level = affinityData ~= nil and affinityData.Level or 1
|
||||
end
|
||||
ctrl:SetHonotTitle(honorData.Id, true, level)
|
||||
self:SetPngSprite(imgHonorTitleEquipBg, honorData.MainRes)
|
||||
local spritePath = ""
|
||||
if honorData.BGType == GameEnum.HonorTitleBgType.Ellipse then
|
||||
spritePath = "db_choose_common_5"
|
||||
elseif honorData.BGType == GameEnum.HonorTitleBgType.Parallelogram then
|
||||
spritePath = "db_choose_common_6"
|
||||
end
|
||||
self:SetAtlasSprite(imgHonorTitleChooseBg, "08_db", spritePath)
|
||||
self:SetAtlasSprite(imgHonorTitleChooseBg1, "08_db", spritePath)
|
||||
local bCurChosen = self.tbCurHonorTitle[self.nSelectedIndex] == honorData.Id
|
||||
goChosenState.gameObject:SetActive(bCurChosen)
|
||||
imgHonorTitleChooseBg.gameObject:SetActive(bCurChosen)
|
||||
if self.tbCurHonorTitle[self.nSelectedIndex] == honorData.Id then
|
||||
self.tbGoChosenState[self.nSelectedIndex] = {goChosenState, imgHonorTitleChooseBg}
|
||||
end
|
||||
local bEquiped = false
|
||||
for k, v in pairs(self.tbCurHonorTitle) do
|
||||
if v == honorData.Id then
|
||||
bEquiped = true
|
||||
break
|
||||
end
|
||||
end
|
||||
goEquipState.gameObject:SetActive(not bCurChosen and bEquiped)
|
||||
btnGrid.onClick:RemoveAllListeners()
|
||||
btnGrid.onClick:AddListener(function()
|
||||
if self.tbCurHonorTitle[self.nSelectedIndex] ~= honorData.Id then
|
||||
for k, v in pairs(self.tbCurHonorTitle) do
|
||||
if v == honorData.Id then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Honor_Title_Equiped"))
|
||||
return
|
||||
end
|
||||
end
|
||||
if self.tbGoChosenState[self.nSelectedIndex] ~= nil then
|
||||
for k, v in ipairs(self.tbGoChosenState[self.nSelectedIndex]) do
|
||||
v.gameObject:SetActive(false)
|
||||
end
|
||||
end
|
||||
self.tbCurHonorTitle[self.nSelectedIndex] = honorData.Id
|
||||
self.tbGoChosenState[self.nSelectedIndex] = {goChosenState, imgHonorTitleChooseBg}
|
||||
for k, v in ipairs(self.tbGoChosenState[self.nSelectedIndex]) do
|
||||
v.gameObject:SetActive(true)
|
||||
end
|
||||
else
|
||||
self.tbCurHonorTitle[self.nSelectedIndex] = nil
|
||||
for k, v in ipairs(self.tbGoChosenState[self.nSelectedIndex]) do
|
||||
v.gameObject:SetActive(false)
|
||||
end
|
||||
self.tbGoChosenState[self.nSelectedIndex] = nil
|
||||
end
|
||||
self:RefreshHonorTitle()
|
||||
self:RefreshReddot(honorData.Id)
|
||||
end)
|
||||
end
|
||||
function FriendHonorTitleCtrl:PlayInAni()
|
||||
self.gameObject:SetActive(true)
|
||||
self.ani:Play("t_window_04_t_in")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.3)
|
||||
end
|
||||
function FriendHonorTitleCtrl:PlayOutAni()
|
||||
self.ani:Play("t_window_04_t_out")
|
||||
self:AddTimer(1, 0.2, "Close", true, true, true)
|
||||
end
|
||||
function FriendHonorTitleCtrl:Close()
|
||||
self.gameObject:SetActive(false)
|
||||
end
|
||||
function FriendHonorTitleCtrl:SetTimer()
|
||||
self.bCd = true
|
||||
if self.timer ~= nil then
|
||||
self.timer:Cancel(false)
|
||||
self.timer = nil
|
||||
end
|
||||
self.timer = self:AddTimer(1, 5, function()
|
||||
self.bCd = false
|
||||
end, true, true, false)
|
||||
end
|
||||
function FriendHonorTitleCtrl:Awake()
|
||||
self.ani = self.gameObject.transform:GetComponent("Animator")
|
||||
self.tbGridCtrl = {}
|
||||
self.tbGridRedDot = {}
|
||||
end
|
||||
function FriendHonorTitleCtrl:OnEnable()
|
||||
end
|
||||
function FriendHonorTitleCtrl:OnDisable()
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function FriendHonorTitleCtrl:OnDestroy()
|
||||
end
|
||||
function FriendHonorTitleCtrl:OnBtnClick_Cancel(btn)
|
||||
EventManager.Hit("FriendClosePop")
|
||||
end
|
||||
function FriendHonorTitleCtrl:OnBtnClick_ChangeHonorTitle(btn, nIndex, bInit)
|
||||
if self.nSelectedIndex ~= nil and self.nSelectedIndex == nIndex then
|
||||
return
|
||||
end
|
||||
if self.nSelectedIndex ~= nil then
|
||||
self._mapNode.imgSelect[self.nSelectedIndex]:SetActive(false)
|
||||
end
|
||||
self._mapNode.imgSelect[nIndex]:SetActive(true)
|
||||
self.nSelectedIndex = nIndex
|
||||
if not bInit then
|
||||
self:RefreshHonorTitleList()
|
||||
end
|
||||
end
|
||||
function FriendHonorTitleCtrl:OnBtnClick_ChangeHonorTitleType(btn, nIndex)
|
||||
if self.nSelectedType ~= nil and self.nSelectedType == nIndex then
|
||||
return
|
||||
end
|
||||
if self.nSelectedType ~= nil then
|
||||
self._mapNode.imgTab[self.nSelectedType]:SetActive(false)
|
||||
self._mapNode.txtTab[self.nSelectedType]:SetActive(false)
|
||||
self._mapNode.txtTabUnSelect[self.nSelectedType]:SetActive(true)
|
||||
end
|
||||
self._mapNode.imgTab[nIndex]:SetActive(true)
|
||||
self._mapNode.txtTab[nIndex]:SetActive(true)
|
||||
self._mapNode.txtTabUnSelect[nIndex]:SetActive(false)
|
||||
self.nSelectedType = nIndex
|
||||
self:RefreshHonorTitleList()
|
||||
end
|
||||
function FriendHonorTitleCtrl:OnBtnClick_Confirm()
|
||||
local callback = function()
|
||||
local mapMsg = {
|
||||
nType = AllEnum.MessageBox.Tips,
|
||||
bPositive = true,
|
||||
sContent = ConfigTable.GetUIText("Change_Success")
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, mapMsg)
|
||||
self:OnBtnClick_Cancel()
|
||||
end
|
||||
if self.tbCurHonorTitle == nil then
|
||||
self.tbhonorTitle = {}
|
||||
end
|
||||
for i = 1, 3 do
|
||||
if self.tbCurHonorTitle[i] == nil then
|
||||
self.tbCurHonorTitle[i] = 0
|
||||
end
|
||||
end
|
||||
PlayerData.Base:SendPlayerHonorTitleEditReq(self.tbCurHonorTitle, callback)
|
||||
end
|
||||
return FriendHonorTitleCtrl
|
||||
@@ -0,0 +1,192 @@
|
||||
local FriendIdCardCtrl = class("FriendIdCardCtrl", BaseCtrl)
|
||||
local LocalData = require("GameCore.Data.LocalData")
|
||||
FriendIdCardCtrl._mapNodeConfig = {
|
||||
goBlur = {},
|
||||
RectCard = {},
|
||||
imgSaveBtn = {},
|
||||
goTip = {},
|
||||
btnCloseCard = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_CloseIdCard"
|
||||
},
|
||||
btnSaveCard = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_OpenAskPermission"
|
||||
},
|
||||
txtTicketTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Ticket_Title"
|
||||
},
|
||||
txtNameCard = {sComponentName = "TMP_Text"},
|
||||
txtUidCard = {sComponentName = "TMP_Text"},
|
||||
txtUidTitle = {sComponentName = "TMP_Text", sLanguageId = "Friend_UID"},
|
||||
txtTitleTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_TitleTag"
|
||||
},
|
||||
txtTitleCard = {sComponentName = "TMP_Text"},
|
||||
txtProfileCard = {sComponentName = "TMP_Text"},
|
||||
imgPlayerHeadCard = {sComponentName = "Image"},
|
||||
txtRankCard = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "MainView_RANK"
|
||||
},
|
||||
txtWorldClassCard = {sComponentName = "TMP_Text"},
|
||||
goHonorTitleCard = {
|
||||
nCount = 3,
|
||||
sCtrlName = "Game.UI.FriendEx.HonorTitleCtrl"
|
||||
},
|
||||
txtMainline = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "MainLine_Progress"
|
||||
},
|
||||
txtMainlineProgress = {sComponentName = "TMP_Text"},
|
||||
txtAchievement = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Card_Achievement"
|
||||
},
|
||||
txtAchievementCount = {sComponentName = "TMP_Text"},
|
||||
txtDisc = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Card_Disc"
|
||||
},
|
||||
txtDiscCount = {sComponentName = "TMP_Text"},
|
||||
txtChar = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Card_Char"
|
||||
},
|
||||
txtCharCount = {sComponentName = "TMP_Text"},
|
||||
txtCardCloseTip = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "StarTower_Book_Close_Tip"
|
||||
},
|
||||
txtCardCloseTipShadow = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "StarTower_Book_Close_Tip"
|
||||
},
|
||||
txtSaveCard = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Save_Card_Button"
|
||||
}
|
||||
}
|
||||
function FriendIdCardCtrl:OnInit()
|
||||
self._mapNode.goTip:SetActive(false)
|
||||
self._mapNode.imgSaveBtn:SetActive(false)
|
||||
self._mapNode.RectCard:SetActive(false)
|
||||
self._mapNode.goBlur:SetActive(false)
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
self._mapNode.goBlur:SetActive(true)
|
||||
local innerWait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
self.gameObject.transform.parent.parent:GetComponent("Animator"):Play("FriendPanel_IdCard_in", -1, 0)
|
||||
self:Refresh()
|
||||
end
|
||||
cs_coroutine.start(innerWait)
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
end
|
||||
function FriendIdCardCtrl:Refresh()
|
||||
self._mapNode.RectCard:SetActive(true)
|
||||
self._mapNode.imgSaveBtn:SetActive(true)
|
||||
self._mapNode.goTip:SetActive(true)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtNameCard, PlayerData.Base:GetPlayerNickName())
|
||||
NovaAPI.SetTMPText(self._mapNode.txtUidCard, PlayerData.Base:GetPlayerId())
|
||||
self:RefreshTitle()
|
||||
self:RefreshHead()
|
||||
self:RefreshHonorTitle()
|
||||
NovaAPI.SetTMPText(self._mapNode.txtProfileCard, PlayerData.Base:GetPlayerSignature())
|
||||
NovaAPI.SetTMPText(self._mapNode.txtWorldClassCard, PlayerData.Base:GetWorldClass())
|
||||
self:RefreshMainlineProgress()
|
||||
NovaAPI.SetTMPText(self._mapNode.txtAchievementCount, PlayerData.Achievement:GetAchievementAllTypeCount().nCompleted)
|
||||
local tbDisc = PlayerData.Disc:GetDiscIdList()
|
||||
NovaAPI.SetTMPText(self._mapNode.txtDiscCount, #tbDisc)
|
||||
local tbChar = PlayerData.Char:GetCharIdList()
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCharCount, #tbChar)
|
||||
end
|
||||
function FriendIdCardCtrl:RefreshTitle()
|
||||
local nPre, nSuf = PlayerData.Base:GetPlayerTitle()
|
||||
if nPre == 0 or nSuf == 0 then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTitleCard, "")
|
||||
return
|
||||
end
|
||||
local sTitle = orderedFormat(ConfigTable.GetUIText("FriendPanel_PlayerTitle") or "", ConfigTable.GetData("Title", nPre).Desc, ConfigTable.GetData("Title", nSuf).Desc)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTitleCard, sTitle)
|
||||
end
|
||||
function FriendIdCardCtrl:RefreshHead()
|
||||
local nHeadId = PlayerData.Base:GetPlayerHeadId()
|
||||
local mapCfg = ConfigTable.GetData("PlayerHead", nHeadId)
|
||||
if mapCfg ~= nil then
|
||||
self:SetPngSprite(self._mapNode.imgPlayerHeadCard, mapCfg.Icon)
|
||||
end
|
||||
end
|
||||
function FriendIdCardCtrl:RefreshHonorTitle()
|
||||
local tbCurHonorTitle = PlayerData.Base:GetPlayerHonorTitle()
|
||||
for i = 1, 3 do
|
||||
if tbCurHonorTitle[i] ~= nil and tbCurHonorTitle[i].Id ~= 0 and tbCurHonorTitle[i] ~= nil then
|
||||
local honorData = ConfigTable.GetData("Honor", tbCurHonorTitle[i].Id)
|
||||
local level
|
||||
if honorData.Type == GameEnum.honorType.Character then
|
||||
local affinityData = PlayerData.Char:GetCharAffinityData(honorData.Params[1])
|
||||
level = affinityData.Level
|
||||
end
|
||||
self._mapNode.goHonorTitleCard[i]:SetHonotTitle(honorData.Id, i == 1, level)
|
||||
end
|
||||
self._mapNode.goHonorTitleCard[i].gameObject:SetActive(tbCurHonorTitle[i] ~= nil and tbCurHonorTitle[i].Id ~= 0)
|
||||
end
|
||||
end
|
||||
function FriendIdCardCtrl:RefreshMainlineProgress()
|
||||
local curStoryId = PlayerData.Avg:GetLastestStoryId()
|
||||
local storyConfig = ConfigTable.GetData_Story(curStoryId)
|
||||
local nChapter = storyConfig.Chapter
|
||||
local title = nChapter .. "-" .. storyConfig.Index
|
||||
NovaAPI.SetTMPText(self._mapNode.txtMainlineProgress, title)
|
||||
end
|
||||
function FriendIdCardCtrl:SaveIdCard()
|
||||
local compCapture = self.gameObject:GetComponent("UICapture")
|
||||
if compCapture ~= nil then
|
||||
local await = function(bRes)
|
||||
local sTip
|
||||
if bRes == true then
|
||||
local curPlatform = CS.ClientManager.Instance.Platform
|
||||
if curPlatform == "ios" or curPlatform == "android" then
|
||||
sTip = ConfigTable.GetUIText("Friend_Save_Card_Mobile")
|
||||
else
|
||||
sTip = ConfigTable.GetUIText("Friend_Save_Card_Pc")
|
||||
end
|
||||
else
|
||||
sTip = ConfigTable.GetUIText("Friend_Card_Save_Failed")
|
||||
end
|
||||
EventManager.Hit(EventId.OpenMessageBox, sTip)
|
||||
end
|
||||
compCapture:CaptureUIRect(await)
|
||||
end
|
||||
end
|
||||
function FriendIdCardCtrl:OnBtnClick_CloseIdCard()
|
||||
self.gameObject:SetActive(false)
|
||||
end
|
||||
function FriendIdCardCtrl:OnBtnClick_OpenAskPermission()
|
||||
local bSavePermission = LocalData.GetPlayerLocalData("SavePermission" .. tostring(PlayerData.Base:GetPlayerId()))
|
||||
if bSavePermission == true then
|
||||
self:SaveIdCard()
|
||||
return
|
||||
end
|
||||
local confirmCallback = function()
|
||||
self:SaveIdCard()
|
||||
end
|
||||
local againCallback = function(isSelect)
|
||||
if isSelect == true then
|
||||
LocalData.SetPlayerLocalData("SavePermission" .. tostring(PlayerData.Base:GetPlayerId()), true)
|
||||
end
|
||||
end
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Confirm,
|
||||
sContent = ConfigTable.GetUIText("Friend_Save_Card_Permission_Tips"),
|
||||
callbackConfirm = confirmCallback,
|
||||
callbackAgain = againCallback,
|
||||
sAgain = ConfigTable.GetUIText("SavePermission_Tips_NeverAgain"),
|
||||
bBlur = false
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
end
|
||||
return FriendIdCardCtrl
|
||||
@@ -0,0 +1,228 @@
|
||||
local FriendInfoCtrl = class("FriendInfoCtrl", BaseCtrl)
|
||||
FriendInfoCtrl._mapNodeConfig = {
|
||||
btnPortrait = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_ChangePortrait"
|
||||
},
|
||||
btnIdCard = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_ShowIdCard"
|
||||
},
|
||||
btnHead = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_ChangeHead"
|
||||
},
|
||||
imgPlayerHead = {sComponentName = "Image"},
|
||||
txtWorldClass = {sComponentName = "TMP_Text"},
|
||||
txtRankCn = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "MainView_RANK"
|
||||
},
|
||||
txtName = {sComponentName = "TMP_Text"},
|
||||
btnName = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_ChangeName"
|
||||
},
|
||||
txtTitle = {sComponentName = "TMP_Text"},
|
||||
btnTitle = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_ChangeTitle"
|
||||
},
|
||||
txtUIDCn = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_UIDInfo"
|
||||
},
|
||||
txtUID = {sComponentName = "TMP_Text"},
|
||||
btnCopyUID = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_CopyUID"
|
||||
},
|
||||
txtSign = {sComponentName = "TMP_Text"},
|
||||
txtBtnSign = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Btn_Sign"
|
||||
},
|
||||
btnSign = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_ChangeSign"
|
||||
},
|
||||
txtTitleChar = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_CoreMember"
|
||||
},
|
||||
btnChar = {
|
||||
nCount = 3,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Char"
|
||||
},
|
||||
goChar = {
|
||||
nCount = 3,
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateCharCtrl"
|
||||
},
|
||||
imgEmpty = {nCount = 3},
|
||||
btnHonorTitle = {
|
||||
nCount = 3,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_ChangeHonorTitle"
|
||||
},
|
||||
btnChangeHonorTitle = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_ChangeHonorTitle"
|
||||
},
|
||||
goHonorTitle = {
|
||||
nCount = 3,
|
||||
sCtrlName = "Game.UI.FriendEx.HonorTitleCtrl"
|
||||
},
|
||||
imgHonorTitleBg = {nCount = 3},
|
||||
redDotTitle = {},
|
||||
redDotHead = {},
|
||||
HonorTitleReddot = {},
|
||||
IdCard = {
|
||||
sNodeName = "--IdCard--",
|
||||
sCtrlName = "Game.UI.FriendEx.FriendIdCardCtrl"
|
||||
}
|
||||
}
|
||||
FriendInfoCtrl._mapEventConfig = {
|
||||
FriendRefreshHead = "RefreshHead",
|
||||
FriendRefreshName = "RefreshName",
|
||||
FriendRefreshTitle = "RefreshTitle",
|
||||
FriendRefreshSign = "RefreshSign",
|
||||
FriendRefreshMember = "RefreshMember",
|
||||
FriendRefreshActor = "RefreshActor",
|
||||
HonorTitle_Change = "RefreshHonorTitle"
|
||||
}
|
||||
FriendInfoCtrl._mapRedDotConfig = {
|
||||
[RedDotDefine.Friend_Info_Title] = {
|
||||
sNodeName = "redDotTitle"
|
||||
},
|
||||
[RedDotDefine.Friend_Info_Head] = {sNodeName = "redDotHead"},
|
||||
[RedDotDefine.Friend_Honor_Title] = {
|
||||
sNodeName = "HonorTitleReddot"
|
||||
}
|
||||
}
|
||||
function FriendInfoCtrl:Refresh()
|
||||
self:RefreshName()
|
||||
self:RefreshHead()
|
||||
self:RefreshTitle()
|
||||
self:RefreshSign()
|
||||
self:RefreshMember()
|
||||
self:RefreshOther()
|
||||
self:RefreshActor()
|
||||
self:RefreshHonorTitle()
|
||||
end
|
||||
function FriendInfoCtrl:RefreshName()
|
||||
local sName = PlayerData.Base:GetPlayerNickName()
|
||||
local nHashtag = PlayerData.Base:GetPlayerHashtag()
|
||||
NovaAPI.SetTMPText(self._mapNode.txtName, sName)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtUID, PlayerData.Base:GetPlayerId())
|
||||
end
|
||||
function FriendInfoCtrl:RefreshHead()
|
||||
local nHeadId = PlayerData.Base:GetPlayerHeadId()
|
||||
local mapCfg = ConfigTable.GetData("PlayerHead", nHeadId)
|
||||
if mapCfg ~= nil then
|
||||
self:SetPngSprite(self._mapNode.imgPlayerHead, mapCfg.Icon)
|
||||
end
|
||||
end
|
||||
function FriendInfoCtrl:RefreshTitle()
|
||||
local nPre, nSuf = PlayerData.Base:GetPlayerTitle()
|
||||
if nPre == 0 or nSuf == 0 then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTitle, "")
|
||||
return
|
||||
end
|
||||
local sTitle = orderedFormat(ConfigTable.GetUIText("FriendPanel_PlayerTitle") or "", ConfigTable.GetData("Title", nPre).Desc, ConfigTable.GetData("Title", nSuf).Desc)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTitle, sTitle)
|
||||
end
|
||||
function FriendInfoCtrl:RefreshSign()
|
||||
NovaAPI.SetTMPText(self._mapNode.txtSign, PlayerData.Base:GetPlayerSignature())
|
||||
end
|
||||
function FriendInfoCtrl:RefreshMember()
|
||||
local tbChar = PlayerData.Base:GetPlayerCoreTeam()
|
||||
for i = 1, 3 do
|
||||
self._mapNode.imgEmpty[i]:SetActive(tbChar[i] == 0)
|
||||
self._mapNode.goChar[i].gameObject:SetActive(tbChar[i] ~= 0)
|
||||
if tbChar[i] ~= 0 then
|
||||
self._mapNode.goChar[i]:SetChar(tbChar[i])
|
||||
end
|
||||
end
|
||||
end
|
||||
function FriendInfoCtrl:RefreshOther()
|
||||
NovaAPI.SetTMPText(self._mapNode.txtWorldClass, PlayerData.Base:GetWorldClass())
|
||||
end
|
||||
function FriendInfoCtrl:RefreshActor()
|
||||
local nSkinId = PlayerData.Base:GetPlayerShowSkin()
|
||||
local nCharId = ConfigTable.GetData_CharacterSkin(nSkinId).CharId
|
||||
EventManager.Hit("FriendRefreshActor2D", nCharId, nSkinId)
|
||||
end
|
||||
function FriendInfoCtrl:RefreshHonorTitle()
|
||||
local tbCurHonorTitle = PlayerData.Base:GetPlayerHonorTitle()
|
||||
for i = 1, 3 do
|
||||
if tbCurHonorTitle[i] ~= nil and tbCurHonorTitle[i].Id ~= 0 and tbCurHonorTitle[i] ~= nil then
|
||||
local honorData = ConfigTable.GetData("Honor", tbCurHonorTitle[i].Id)
|
||||
local level
|
||||
if honorData.Type == GameEnum.honorType.Character then
|
||||
local affinityData = PlayerData.Char:GetCharAffinityData(honorData.Params[1])
|
||||
if affinityData ~= nil then
|
||||
level = affinityData.Level
|
||||
else
|
||||
printError("不存在角色" .. honorData.Params[1])
|
||||
end
|
||||
end
|
||||
self._mapNode.goHonorTitle[i]:SetHonotTitle(honorData.Id, i == 1, level)
|
||||
end
|
||||
self._mapNode.goHonorTitle[i].gameObject:SetActive(tbCurHonorTitle[i] ~= nil and tbCurHonorTitle[i].Id ~= 0)
|
||||
self._mapNode.imgHonorTitleBg[i].gameObject:SetActive(tbCurHonorTitle[i] == nil or tbCurHonorTitle[i].Id == 0)
|
||||
end
|
||||
end
|
||||
function FriendInfoCtrl:Awake()
|
||||
end
|
||||
function FriendInfoCtrl:OnEnable()
|
||||
self._mapNode.IdCard.gameObject:SetActive(false)
|
||||
end
|
||||
function FriendInfoCtrl:OnDisable()
|
||||
end
|
||||
function FriendInfoCtrl:OnDestroy()
|
||||
end
|
||||
function FriendInfoCtrl:OnBtnClick_CopyUID()
|
||||
CS.UnityEngine.GUIUtility.systemCopyBuffer = PlayerData.Base:GetPlayerId()
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Friend_UIDCopied_Tip"))
|
||||
end
|
||||
function FriendInfoCtrl:OnBtnClick_ShowIdCard()
|
||||
local dataCompleteCallback = function()
|
||||
self._mapNode.IdCard.gameObject:SetActive(true)
|
||||
self._mapNode.IdCard:OnInit()
|
||||
end
|
||||
PlayerData.Achievement:SendAchievementInfoReq(dataCompleteCallback)
|
||||
end
|
||||
function FriendInfoCtrl:OnBtnClick_ChangeHead(btn)
|
||||
local callback = function()
|
||||
EventManager.Hit("FriendChangeHead")
|
||||
end
|
||||
PlayerData.HeadData:SendGetHeadListMsg(callback)
|
||||
end
|
||||
function FriendInfoCtrl:OnBtnClick_ChangeName(btn)
|
||||
local bOpen = PlayerData.Base:CheckFunctionUnlock(GameEnum.OpenFuncType.NickNameReset, true)
|
||||
if not bOpen then
|
||||
return
|
||||
end
|
||||
local bCD = PlayerData.Base:CheckRenameCD()
|
||||
if bCD then
|
||||
return
|
||||
end
|
||||
EventManager.Hit("FriendChangeName")
|
||||
end
|
||||
function FriendInfoCtrl:OnBtnClick_ChangeTitle(btn)
|
||||
EventManager.Hit("FriendChangeTitle")
|
||||
end
|
||||
function FriendInfoCtrl:OnBtnClick_ChangePortrait(btn)
|
||||
EventManager.Hit("FriendChangePortrait")
|
||||
end
|
||||
function FriendInfoCtrl:OnBtnClick_ChangeSign(btn)
|
||||
EventManager.Hit("FriendChangeSignature")
|
||||
end
|
||||
function FriendInfoCtrl:OnBtnClick_Char(btn, nIndex)
|
||||
EventManager.Hit("FriendChangeMember")
|
||||
end
|
||||
function FriendInfoCtrl:OnBtnClick_ChangeHonorTitle()
|
||||
EventManager.Hit("FriendChangeHonorTitle")
|
||||
end
|
||||
return FriendInfoCtrl
|
||||
@@ -0,0 +1,173 @@
|
||||
local FriendListCtrl = class("FriendListCtrl", BaseCtrl)
|
||||
FriendListCtrl._mapNodeConfig = {
|
||||
imgEmptyBg = {},
|
||||
txtEmpty = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_ListNone"
|
||||
},
|
||||
srFriendList = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
txtFriendCount = {sComponentName = "TMP_Text"},
|
||||
btnGetAll = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_GetAll"
|
||||
},
|
||||
btnSendAll = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_SendAll"
|
||||
},
|
||||
txtGetAll = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Btn_Get"
|
||||
},
|
||||
txtSendAll = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Btn_Send"
|
||||
},
|
||||
txtToday = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Today"
|
||||
},
|
||||
txtEnergyCount = {sComponentName = "TMP_Text"},
|
||||
imgTodayEnergy = {sComponentName = "Image"},
|
||||
btnSwitch = {
|
||||
nCount = 2,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Switch"
|
||||
},
|
||||
SwitchOn = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Btn_Open"
|
||||
},
|
||||
SwitchOff = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Btn_Close"
|
||||
},
|
||||
goSwitch = {},
|
||||
redDotGetAll = {}
|
||||
}
|
||||
FriendListCtrl._mapEventConfig = {
|
||||
FriendRefreshList = "RefreshList",
|
||||
FriendRefreshEnergy = "RefreshEnergy"
|
||||
}
|
||||
FriendListCtrl._mapRedDotConfig = {
|
||||
[RedDotDefine.Friend_Energy] = {
|
||||
sNodeName = "redDotGetAll"
|
||||
}
|
||||
}
|
||||
function FriendListCtrl:Refresh()
|
||||
self.bOperating = false
|
||||
self:RefreshSwitch()
|
||||
self:ChangeShow(false)
|
||||
local callback = function()
|
||||
self:ChangeShow(true)
|
||||
self:RefreshList()
|
||||
self:RefreshEnergy()
|
||||
end
|
||||
PlayerData.Friend:SendFriendListGetReq(callback)
|
||||
end
|
||||
function FriendListCtrl:ChangeShow(bShow)
|
||||
self._mapNode.btnGetAll.gameObject:SetActive(bShow)
|
||||
self._mapNode.btnSendAll.gameObject:SetActive(bShow)
|
||||
self._mapNode.goSwitch.gameObject:SetActive(bShow)
|
||||
end
|
||||
function FriendListCtrl:RefreshSwitch()
|
||||
self._mapNode.btnSwitch[1].gameObject:SetActive(not self.bOperating)
|
||||
self._mapNode.btnSwitch[2].gameObject:SetActive(self.bOperating)
|
||||
end
|
||||
function FriendListCtrl:RefreshEnergy()
|
||||
NovaAPI.SetTMPText(self._mapNode.txtEnergyCount, PlayerData.Friend:GetEnergyCount() .. "/" .. self.nMaxEnergy)
|
||||
local itemInfo = ConfigTable.GetData_Item(AllEnum.CoinItemId.Energy)
|
||||
if itemInfo then
|
||||
self:SetPngSprite(self._mapNode.imgTodayEnergy, itemInfo.Icon)
|
||||
end
|
||||
end
|
||||
function FriendListCtrl:RefreshList()
|
||||
local nFriendNum = PlayerData.Friend:GetFriendListNum()
|
||||
self._mapNode.srFriendList.gameObject:SetActive(0 < nFriendNum)
|
||||
self._mapNode.imgEmptyBg:SetActive(nFriendNum == 0)
|
||||
if 0 < nFriendNum then
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self.tbFriendList = PlayerData.Friend:GetFriendListData()
|
||||
self._mapNode.srFriendList:Init(nFriendNum, self, self.OnGridRefresh)
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtFriendCount, nFriendNum .. "/" .. ConfigTable.GetConfigNumber("FriendMax"))
|
||||
end
|
||||
function FriendListCtrl:OnGridRefresh(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local mapFriend = self.tbFriendList[nIndex]
|
||||
local nInstanceID = goGrid:GetInstanceID()
|
||||
if not self.tbGridCtrl[nInstanceID] then
|
||||
self.tbGridCtrl[nInstanceID] = self:BindCtrlByNode(goGrid, "Game.UI.FriendEx.FriendGridCtrl")
|
||||
end
|
||||
self.tbGridCtrl[nInstanceID]:SetType(self.bOperating and 1 or 4)
|
||||
self.tbGridCtrl[nInstanceID]:Refresh(mapFriend)
|
||||
end
|
||||
function FriendListCtrl:Awake()
|
||||
self.tbGridCtrl = {}
|
||||
self.nMaxEnergy = ConfigTable.GetConfigNumber("FriendReceiveEnergyMax")
|
||||
end
|
||||
function FriendListCtrl:OnEnable()
|
||||
end
|
||||
function FriendListCtrl:OnDisable()
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function FriendListCtrl:OnDestroy()
|
||||
end
|
||||
function FriendListCtrl:OnBtnClick_GetAll()
|
||||
local nCount = PlayerData.Friend:GetEnergyCount()
|
||||
if nCount >= self.nMaxEnergy then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Friend_MaxGet"))
|
||||
return
|
||||
end
|
||||
if not PlayerData.Friend:JudgeEnergyGetAble() then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Friend_GetFail"))
|
||||
return
|
||||
end
|
||||
local callback = function(UIds)
|
||||
if #UIds == 0 then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Friend_GetFail"))
|
||||
else
|
||||
self:RefreshEnergy()
|
||||
if not self.bOperating then
|
||||
self:RefreshList()
|
||||
end
|
||||
end
|
||||
end
|
||||
PlayerData.Friend:SendFriendReceiveEnergyReq({}, callback)
|
||||
end
|
||||
function FriendListCtrl:OnBtnClick_SendAll()
|
||||
if not PlayerData.Friend:JudgeEnergySendAble() then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Friend_SendFail"))
|
||||
return
|
||||
end
|
||||
local callback = function(UIds)
|
||||
if #UIds == 0 then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Friend_SendFail"))
|
||||
else
|
||||
EventManager.Hit(EventId.OpenMessageBox, {
|
||||
nType = AllEnum.MessageBox.Tips,
|
||||
bPositive = true,
|
||||
sContent = ConfigTable.GetUIText("Friend_SendAllSuc")
|
||||
})
|
||||
if not self.bOperating then
|
||||
self:RefreshList()
|
||||
end
|
||||
end
|
||||
end
|
||||
PlayerData.Friend:SendFriendSendEnergyReq({}, callback)
|
||||
end
|
||||
function FriendListCtrl:OnBtnClick_Switch(btn, nIndex)
|
||||
self.bOperating = nIndex == 1
|
||||
self:RefreshSwitch()
|
||||
self:RefreshList()
|
||||
end
|
||||
return FriendListCtrl
|
||||
@@ -0,0 +1,169 @@
|
||||
local FriendMemberCtrl = class("FriendMemberCtrl", BaseCtrl)
|
||||
FriendMemberCtrl._mapNodeConfig = {
|
||||
txtWindowTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_CoreMemberTitle"
|
||||
},
|
||||
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"
|
||||
},
|
||||
svChar = {
|
||||
sComponentName = "LoopScrollView"
|
||||
}
|
||||
}
|
||||
FriendMemberCtrl._mapEventConfig = {}
|
||||
function FriendMemberCtrl:Open()
|
||||
self:Refresh()
|
||||
self:PlayInAni()
|
||||
end
|
||||
function FriendMemberCtrl:Refresh()
|
||||
self.tbTeam = PlayerData.Base:GetPlayerCoreTeam()
|
||||
local tbCur = {}
|
||||
for i = 1, 3 do
|
||||
if self.tbTeam[i] ~= 0 then
|
||||
tbCur[self.tbTeam[i]] = true
|
||||
end
|
||||
end
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
local tbAllChar = PlayerData.Char:GetDataForCharList()
|
||||
self.tbChar = {}
|
||||
for _, v in pairs(tbAllChar) do
|
||||
if not tbCur[v.nId] then
|
||||
table.insert(self.tbChar, v)
|
||||
end
|
||||
end
|
||||
table.sort(self.tbChar, function(a, b)
|
||||
return a.Rare < b.Rare or a.Rare == b.Rare and a.nId < b.nId
|
||||
end)
|
||||
for i = 3, 1, -1 do
|
||||
if self.tbTeam[i] ~= 0 then
|
||||
table.insert(self.tbChar, 1, tbAllChar[self.tbTeam[i]])
|
||||
end
|
||||
end
|
||||
local nAllCount = #self.tbChar
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self._mapNode.svChar:Init(nAllCount, self, self.OnGridRefresh, self.OnGridBtnClick)
|
||||
end
|
||||
function FriendMemberCtrl:OnGridRefresh(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local mapData = self.tbChar[nIndex]
|
||||
local nInstanceID = goGrid:GetInstanceID()
|
||||
if not self.tbGridCtrl[nInstanceID] then
|
||||
self.tbGridCtrl[nInstanceID] = self:BindCtrlByNode(goGrid, "Game.UI.TemplateEx.TemplateCharCtrl")
|
||||
end
|
||||
self.tbGridCtrl[nInstanceID]:SetChar(mapData.nId)
|
||||
local imgCur1 = goGrid.transform:Find("btnGrid/AnimRoot/imgChose").gameObject
|
||||
local imgCur2 = goGrid.transform:Find("btnGrid/AnimRoot/imgChoseMask").gameObject
|
||||
local imgCur3 = goGrid.transform:Find("btnGrid/AnimRoot/imgChoseBg").gameObject
|
||||
local imgCur = goGrid.transform:Find("btnGrid/AnimRoot/imgChoseBg/txtSelected/imgSelectIndex"):GetComponent("Image")
|
||||
local txtSelect = goGrid.transform:Find("btnGrid/AnimRoot/imgChoseBg/txtSelected"):GetComponent("TMP_Text")
|
||||
for i = 1, 3 do
|
||||
if self.tbTeam[i] ~= 0 and self.tbTeam[i] == mapData.nId then
|
||||
imgCur1:SetActive(true)
|
||||
imgCur2:SetActive(true)
|
||||
imgCur3:SetActive(true)
|
||||
self:SetAtlasSprite(imgCur, "11_ico", "zs_team_select_" .. i)
|
||||
NovaAPI.SetTMPText(txtSelect, ConfigTable.GetUIText("HomePage_Selected"))
|
||||
break
|
||||
else
|
||||
imgCur1:SetActive(false)
|
||||
imgCur2:SetActive(false)
|
||||
imgCur3:SetActive(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
function FriendMemberCtrl:OnGridBtnClick(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local mapData = self.tbChar[nIndex]
|
||||
local imgCur1 = goGrid.transform:Find("btnGrid/AnimRoot/imgChose").gameObject
|
||||
local imgCur2 = goGrid.transform:Find("btnGrid/AnimRoot/imgChoseMask").gameObject
|
||||
local imgCur3 = goGrid.transform:Find("btnGrid/AnimRoot/imgChoseBg").gameObject
|
||||
local imgCur = goGrid.transform:Find("btnGrid/AnimRoot/imgChoseBg/txtSelected/imgSelectIndex"):GetComponent("Image")
|
||||
local txtSelect = goGrid.transform:Find("btnGrid/AnimRoot/imgChoseBg/txtSelected"):GetComponent("TMP_Text")
|
||||
local nSelectIndex = 0
|
||||
for i = 1, 3 do
|
||||
if self.tbTeam[i] ~= 0 and self.tbTeam[i] == mapData.nId then
|
||||
nSelectIndex = i
|
||||
break
|
||||
end
|
||||
end
|
||||
if nSelectIndex == 0 then
|
||||
for i = 1, 3 do
|
||||
if self.tbTeam[i] == 0 then
|
||||
self.tbTeam[i] = mapData.nId
|
||||
imgCur1:SetActive(true)
|
||||
imgCur2:SetActive(true)
|
||||
imgCur3:SetActive(true)
|
||||
self:SetAtlasSprite(imgCur, "11_ico", "zs_team_select_" .. i)
|
||||
NovaAPI.SetTMPText(txtSelect, ConfigTable.GetUIText("HomePage_Selected"))
|
||||
break
|
||||
end
|
||||
end
|
||||
elseif nSelectIndex ~= 0 then
|
||||
self.tbTeam[nSelectIndex] = 0
|
||||
imgCur1:SetActive(false)
|
||||
imgCur2:SetActive(false)
|
||||
imgCur3:SetActive(false)
|
||||
end
|
||||
end
|
||||
function FriendMemberCtrl:PlayInAni()
|
||||
self.gameObject:SetActive(true)
|
||||
self.ani:Play("t_window_04_t_in")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.3)
|
||||
end
|
||||
function FriendMemberCtrl:PlayOutAni()
|
||||
self.ani:Play("t_window_04_t_out")
|
||||
self:AddTimer(1, 0.2, "Close", true, true, true)
|
||||
end
|
||||
function FriendMemberCtrl:Close()
|
||||
self.gameObject:SetActive(false)
|
||||
end
|
||||
function FriendMemberCtrl:Awake()
|
||||
self.ani = self.gameObject.transform:GetComponent("Animator")
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function FriendMemberCtrl:OnEnable()
|
||||
end
|
||||
function FriendMemberCtrl:OnDisable()
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function FriendMemberCtrl:OnDestroy()
|
||||
end
|
||||
function FriendMemberCtrl:OnBtnClick_Cancel(btn)
|
||||
EventManager.Hit("FriendClosePop")
|
||||
end
|
||||
function FriendMemberCtrl:OnBtnClick_Confirm(btn)
|
||||
local callback = function()
|
||||
EventManager.Hit("FriendClosePop")
|
||||
EventManager.Hit("FriendRefreshMember")
|
||||
end
|
||||
PlayerData.Base:SendPlayerCharsShowReq(self.tbTeam, callback)
|
||||
end
|
||||
return FriendMemberCtrl
|
||||
@@ -0,0 +1,17 @@
|
||||
local FriendPanel = class("FriendPanel", BasePanel)
|
||||
FriendPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "FriendEx/FriendPanel.prefab",
|
||||
sCtrlName = "Game.UI.FriendEx.FriendCtrl"
|
||||
}
|
||||
}
|
||||
function FriendPanel:Awake()
|
||||
self.tbAddCache = {}
|
||||
end
|
||||
function FriendPanel:OnEnable()
|
||||
end
|
||||
function FriendPanel:OnDisable()
|
||||
end
|
||||
function FriendPanel:OnDestroy()
|
||||
end
|
||||
return FriendPanel
|
||||
@@ -0,0 +1,231 @@
|
||||
local FriendPortraitCtrl = class("FriendPortraitCtrl", BaseCtrl)
|
||||
FriendPortraitCtrl._mapNodeConfig = {
|
||||
txtWindowTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_CharShowTitle"
|
||||
},
|
||||
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"
|
||||
},
|
||||
svChar = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
svSkin = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
snapSkin = {
|
||||
sNodeName = "svSkin",
|
||||
sComponentName = "LoopScrollSnap",
|
||||
callback = "OnGridSelect_Skin"
|
||||
},
|
||||
btnNext = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Next"
|
||||
},
|
||||
btnPre = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Pre"
|
||||
},
|
||||
txtSkinName = {sComponentName = "TMP_Text"},
|
||||
goPoint = {},
|
||||
trPoint = {sComponentName = "Transform"}
|
||||
}
|
||||
FriendPortraitCtrl._mapEventConfig = {}
|
||||
function FriendPortraitCtrl:Open()
|
||||
self:Refresh()
|
||||
self:PlayInAni()
|
||||
end
|
||||
function FriendPortraitCtrl:Refresh()
|
||||
self.nCurSkinId = PlayerData.Base:GetPlayerShowSkin()
|
||||
self.nCurCharId = ConfigTable.GetData_CharacterSkin(self.nCurSkinId).CharId
|
||||
local tbAllChar = PlayerData.Char:GetDataForCharList()
|
||||
self.tbChar = {}
|
||||
for _, v in pairs(tbAllChar) do
|
||||
if self.nCurCharId ~= v.nId then
|
||||
table.insert(self.tbChar, v)
|
||||
end
|
||||
end
|
||||
table.sort(self.tbChar, function(a, b)
|
||||
return a.Rare < b.Rare or a.Rare == b.Rare and a.nId < b.nId
|
||||
end)
|
||||
table.insert(self.tbChar, 1, tbAllChar[self.nCurCharId])
|
||||
for k, v in pairs(self.tbChar) do
|
||||
if v.nId == self.nCurCharId then
|
||||
self.nSelectIndex = k
|
||||
end
|
||||
end
|
||||
local nAllCount = #self.tbChar
|
||||
self._mapNode.svChar:Init(nAllCount, self, self.OnGridRefresh, self.OnGridBtnClick)
|
||||
self:SelectDefaultChar()
|
||||
end
|
||||
function FriendPortraitCtrl:SelectDefaultChar()
|
||||
local mapData = self.tbChar[self.nSelectIndex]
|
||||
self:RefreshSkin(mapData.nId)
|
||||
end
|
||||
function FriendPortraitCtrl:OnGridRefresh(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local mapData = self.tbChar[nIndex]
|
||||
local imgCur1 = goGrid.transform:Find("btnGrid/AnimRoot/imgCur1").gameObject
|
||||
local imgCur2 = goGrid.transform:Find("btnGrid/AnimRoot/imgCur2").gameObject
|
||||
local imgSelect = goGrid.transform:Find("btnGrid/AnimRoot/imgSelect").gameObject
|
||||
local txtCharName = goGrid.transform:Find("btnGrid/AnimRoot/txtCharName"):GetComponent("TMP_Text")
|
||||
local txtCur = goGrid.transform:Find("btnGrid/AnimRoot/imgCur2/txtCur"):GetComponent("TMP_Text")
|
||||
local imgCharIcon = goGrid.transform:Find("btnGrid/AnimRoot/tc_char_03/imgIconBg/imgCharIcon"):GetComponent("Image")
|
||||
local imgFrame = goGrid.transform:Find("btnGrid/AnimRoot/tc_char_03/imgFrame"):GetComponent("Image")
|
||||
local mapCharCfg = ConfigTable.GetData_Character(mapData.nId)
|
||||
local nSkinId = mapCharCfg.DefaultSkinId
|
||||
local mapSkinCfg = ConfigTable.GetData_CharacterSkin(nSkinId)
|
||||
local rareIconName = AllEnum.FrameType_New.BoardFrame .. AllEnum.BoardFrameColor[mapData.Rare]
|
||||
NovaAPI.SetTMPText(txtCur, ConfigTable.GetUIText("Friend_CurSelect"))
|
||||
NovaAPI.SetTMPText(txtCharName, mapData.Name)
|
||||
self:SetPngSprite(imgCharIcon, mapSkinCfg.Icon .. AllEnum.CharHeadIconSurfix.XXL)
|
||||
self:SetAtlasSprite(imgFrame, "12_rare", rareIconName)
|
||||
imgSelect:SetActive(self.nSelectIndex == nIndex)
|
||||
imgCur1:SetActive(mapData.nId == self.nCurCharId)
|
||||
imgCur2:SetActive(mapData.nId == self.nCurCharId)
|
||||
end
|
||||
function FriendPortraitCtrl:OnGridBtnClick(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
if self.nSelectIndex == nIndex then
|
||||
return
|
||||
end
|
||||
local mapData = self.tbChar[nIndex]
|
||||
if self.nSelectIndex then
|
||||
local goSelect = self._mapNode.svChar.transform:Find("Viewport/Content/" .. self.nSelectIndex - 1)
|
||||
if goSelect then
|
||||
local imgSelect = goSelect.transform:Find("btnGrid/AnimRoot/imgSelect").gameObject
|
||||
imgSelect:SetActive(false)
|
||||
end
|
||||
end
|
||||
local imgSelect = goGrid.transform:Find("btnGrid/AnimRoot/imgSelect").gameObject
|
||||
imgSelect:SetActive(true)
|
||||
self.nSelectIndex = nIndex
|
||||
self:RefreshSkin(mapData.nId)
|
||||
end
|
||||
function FriendPortraitCtrl:RefreshSkin(nCharId)
|
||||
local tbSkinList = PlayerData.CharSkin:GetSkinListByCharacterId(nCharId)
|
||||
self.tbSortSkinList = {}
|
||||
for _, v in pairs(tbSkinList) do
|
||||
if true == v:CheckUnlock() then
|
||||
table.insert(self.tbSortSkinList, v)
|
||||
end
|
||||
end
|
||||
table.sort(self.tbSortSkinList, function(a, b)
|
||||
return a:GetId() < b:GetId()
|
||||
end)
|
||||
self.nSkinIndex = 1
|
||||
for k, v in pairs(self.tbSortSkinList) do
|
||||
if v:GetId() == self.nCurSkinId then
|
||||
self.nSkinIndex = k
|
||||
end
|
||||
end
|
||||
self.nSkinCount = #self.tbSortSkinList
|
||||
self._mapNode.svSkin:Init(self.nSkinCount, self, self.OnSkinGridRefresh)
|
||||
self._mapNode.svSkin:SetScrollGridPos(self.nSkinIndex - 1, 0)
|
||||
self.tbPoint = {}
|
||||
delChildren(self._mapNode.trPoint)
|
||||
for i = 1, self.nSkinCount do
|
||||
local obj = instantiate(self._mapNode.goPoint, self._mapNode.trPoint)
|
||||
local on = obj.transform:Find("imgPointOn").gameObject
|
||||
local off = obj.transform:Find("imgPointOff").gameObject
|
||||
on:SetActive(self.nSkinIndex == i)
|
||||
off:SetActive(self.nSkinIndex ~= i)
|
||||
obj:SetActive(true)
|
||||
table.insert(self.tbPoint, obj)
|
||||
end
|
||||
self:SelectDefaultSkin()
|
||||
end
|
||||
function FriendPortraitCtrl:SelectDefaultSkin()
|
||||
local mapData = self.tbSortSkinList[self.nSkinIndex]
|
||||
local mapCfg = mapData:GetCfgData()
|
||||
NovaAPI.SetTMPText(self._mapNode.txtSkinName, mapCfg.Name)
|
||||
self._mapNode.btnPre.gameObject:SetActive(self.nSkinIndex > 1)
|
||||
self._mapNode.btnNext.gameObject:SetActive(self.nSkinIndex < self.nSkinCount)
|
||||
end
|
||||
function FriendPortraitCtrl:OnSkinGridRefresh(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local mapData = self.tbSortSkinList[nIndex]
|
||||
local imgSkin = goGrid.transform:Find("btnGrid/AnimRoot/imgSkin"):GetComponent("Image")
|
||||
local mapCfg = mapData:GetCfgData()
|
||||
self:SetPngSprite(imgSkin, mapCfg.Icon .. AllEnum.CharHeadIconSurfix.SK)
|
||||
end
|
||||
function FriendPortraitCtrl:PlayInAni()
|
||||
self.gameObject:SetActive(true)
|
||||
self.ani:Play("t_window_04_t_in")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.3)
|
||||
end
|
||||
function FriendPortraitCtrl:PlayOutAni()
|
||||
self.ani:Play("t_window_04_t_out")
|
||||
self:AddTimer(1, 0.2, "Close", true, true, true)
|
||||
end
|
||||
function FriendPortraitCtrl:Close()
|
||||
self.gameObject:SetActive(false)
|
||||
end
|
||||
function FriendPortraitCtrl:Awake()
|
||||
self.ani = self.gameObject.transform:GetComponent("Animator")
|
||||
self.nSelectIndex = 1
|
||||
self.nSkinIndex = 1
|
||||
end
|
||||
function FriendPortraitCtrl:OnEnable()
|
||||
end
|
||||
function FriendPortraitCtrl:OnDisable()
|
||||
end
|
||||
function FriendPortraitCtrl:OnDestroy()
|
||||
end
|
||||
function FriendPortraitCtrl:OnBtnClick_Cancel(btn)
|
||||
EventManager.Hit("FriendClosePop")
|
||||
end
|
||||
function FriendPortraitCtrl:OnBtnClick_Confirm(btn)
|
||||
local callback = function()
|
||||
EventManager.Hit("FriendClosePop")
|
||||
EventManager.Hit("FriendRefreshActor")
|
||||
end
|
||||
PlayerData.Base:SendPlayerSkinShowReq(self.tbSortSkinList[self.nSkinIndex]:GetId(), callback)
|
||||
end
|
||||
function FriendPortraitCtrl:OnGridSelect_Skin(_, goGrid)
|
||||
local nIndex = tonumber(goGrid.name) + 1
|
||||
local goBefore = self.tbPoint[self.nSkinIndex]
|
||||
goBefore.transform:Find("imgPointOn").gameObject:SetActive(false)
|
||||
goBefore.transform:Find("imgPointOff").gameObject:SetActive(true)
|
||||
self.nSkinIndex = nIndex
|
||||
local goCur = self.tbPoint[self.nSkinIndex]
|
||||
goCur.transform:Find("imgPointOn").gameObject:SetActive(true)
|
||||
goCur.transform:Find("imgPointOff").gameObject:SetActive(false)
|
||||
local mapData = self.tbSortSkinList[nIndex]
|
||||
local mapCfg = mapData:GetCfgData()
|
||||
NovaAPI.SetTMPText(self._mapNode.txtSkinName, mapCfg.Name)
|
||||
self._mapNode.btnPre.gameObject:SetActive(1 < self.nSkinIndex)
|
||||
self._mapNode.btnNext.gameObject:SetActive(self.nSkinIndex < self.nSkinCount)
|
||||
end
|
||||
function FriendPortraitCtrl:OnBtnClick_Next(btn)
|
||||
if self.nSkinIndex + 1 > self.nSkinCount then
|
||||
return
|
||||
end
|
||||
local nPos = self.nSkinIndex + 1
|
||||
self._mapNode.svSkin:SetScrollGridPos(nPos - 1, 0.5)
|
||||
end
|
||||
function FriendPortraitCtrl:OnBtnClick_Pre(btn)
|
||||
if self.nSkinIndex - 1 < 1 then
|
||||
return
|
||||
end
|
||||
local nPos = self.nSkinIndex - 1
|
||||
self._mapNode.svSkin:SetScrollGridPos(nPos - 1, 0.5)
|
||||
end
|
||||
return FriendPortraitCtrl
|
||||
@@ -0,0 +1,105 @@
|
||||
local FriendRecommendCtrl = class("FriendRecommendCtrl", BaseCtrl)
|
||||
FriendRecommendCtrl._mapNodeConfig = {
|
||||
txtWindowTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_RecommendTitle"
|
||||
},
|
||||
srRecommend = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
btnClose = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Cancel"
|
||||
},
|
||||
btnRefresh = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Research"
|
||||
},
|
||||
txtBtnRefresh = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Btn_Refresh"
|
||||
}
|
||||
}
|
||||
FriendRecommendCtrl._mapEventConfig = {}
|
||||
function FriendRecommendCtrl:Open(mapData)
|
||||
self:Refresh(mapData)
|
||||
self:PlayInAni()
|
||||
end
|
||||
function FriendRecommendCtrl:Refresh(mapData)
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self._panel.tbAddCache = {}
|
||||
self.tbFriendSearch = mapData
|
||||
local nNum = #self.tbFriendSearch
|
||||
self._mapNode.srRecommend:Init(nNum, self, self.OnGridRefresh)
|
||||
end
|
||||
function FriendRecommendCtrl:OnGridRefresh(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local mapFriend = self.tbFriendSearch[nIndex]
|
||||
local nInstanceID = goGrid:GetInstanceID()
|
||||
if not self.tbGridCtrl[nInstanceID] then
|
||||
self.tbGridCtrl[nInstanceID] = self:BindCtrlByNode(goGrid, "Game.UI.FriendEx.FriendGridCtrl")
|
||||
self.tbGridCtrl[nInstanceID]:SetType(3)
|
||||
end
|
||||
self.tbGridCtrl[nInstanceID]:Refresh(mapFriend)
|
||||
end
|
||||
function FriendRecommendCtrl:PlayInAni()
|
||||
self.gameObject:SetActive(true)
|
||||
self.ani:Play("t_window_04_t_in")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.3)
|
||||
end
|
||||
function FriendRecommendCtrl:PlayOutAni()
|
||||
self.ani:Play("t_window_04_t_out")
|
||||
self:AddTimer(1, 0.2, "Close", true, true, true)
|
||||
end
|
||||
function FriendRecommendCtrl:Close()
|
||||
self.gameObject:SetActive(false)
|
||||
EventManager.Hit("FriendClearSearch")
|
||||
end
|
||||
function FriendRecommendCtrl:SetTimer()
|
||||
self.bCd = true
|
||||
if self.timer ~= nil then
|
||||
self.timer:Cancel(false)
|
||||
self.timer = nil
|
||||
end
|
||||
self.timer = self:AddTimer(1, 5, function()
|
||||
self.bCd = false
|
||||
end, true, true, false)
|
||||
end
|
||||
function FriendRecommendCtrl:Awake()
|
||||
self.ani = self.gameObject.transform:GetComponent("Animator")
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function FriendRecommendCtrl:OnEnable()
|
||||
end
|
||||
function FriendRecommendCtrl:OnDisable()
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function FriendRecommendCtrl:OnDestroy()
|
||||
end
|
||||
function FriendRecommendCtrl:OnBtnClick_Cancel(btn)
|
||||
EventManager.Hit("FriendClosePop")
|
||||
end
|
||||
function FriendRecommendCtrl:OnBtnClick_Research(btn)
|
||||
if self.bCd then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Friend_RefreshLimit"))
|
||||
return
|
||||
end
|
||||
local callback = function(mapData)
|
||||
EventManager.Hit(EventId.OpenMessageBox, {
|
||||
nType = AllEnum.MessageBox.Tips,
|
||||
bPositive = true,
|
||||
sContent = ConfigTable.GetUIText("Friend_RefreshSuc")
|
||||
})
|
||||
self:Refresh(mapData)
|
||||
self:SetTimer()
|
||||
end
|
||||
PlayerData.Friend:SendFriendRecommendationGetReq(callback)
|
||||
end
|
||||
return FriendRecommendCtrl
|
||||
@@ -0,0 +1,128 @@
|
||||
local FriendRenameCtrl = class("FriendRenameCtrl", BaseCtrl)
|
||||
FriendRenameCtrl._mapNodeConfig = {
|
||||
txtWindowTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Rename"
|
||||
},
|
||||
txtOldName = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_OldName"
|
||||
},
|
||||
txtTimeLimit = {sComponentName = "TMP_Text"},
|
||||
txtNameDesc = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_NameDesc"
|
||||
},
|
||||
txtCurName = {sComponentName = "TMP_Text"},
|
||||
inputRename = {
|
||||
sComponentName = "TMP_InputField"
|
||||
},
|
||||
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"
|
||||
}
|
||||
}
|
||||
FriendRenameCtrl._mapEventConfig = {}
|
||||
function FriendRenameCtrl:Open()
|
||||
self:Refresh()
|
||||
self:PlayInAni()
|
||||
end
|
||||
function FriendRenameCtrl:Refresh()
|
||||
local bInit = NovaAPI.IsDirtyWordsInit()
|
||||
if not bInit then
|
||||
NovaAPI.InitDirtyWords()
|
||||
end
|
||||
NovaAPI.SetTMPInputFieldText(self._mapNode.inputRename, "")
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCurName, PlayerData.Base:GetPlayerNickName())
|
||||
local sec = ConfigTable.GetConfigNumber("NickNameResetTimeLimit")
|
||||
local day = math.ceil(sec / 86400)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTimeLimit, orderedFormat(ConfigTable.GetUIText("Friend_Rename_TimeLimit"), day))
|
||||
end
|
||||
function FriendRenameCtrl:PlayInAni()
|
||||
self.gameObject:SetActive(true)
|
||||
self.ani:Play("t_window_04_t_in")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.3)
|
||||
end
|
||||
function FriendRenameCtrl:PlayOutAni()
|
||||
self.ani:Play("t_window_04_t_out")
|
||||
self:AddTimer(1, 0.2, "Close", true, true, true)
|
||||
end
|
||||
function FriendRenameCtrl:Close()
|
||||
NovaAPI.SetTMPInputFieldText(self._mapNode.inputRename, "")
|
||||
self.gameObject:SetActive(false)
|
||||
end
|
||||
function FriendRenameCtrl:Awake()
|
||||
self.ani = self.gameObject.transform:GetComponent("Animator")
|
||||
end
|
||||
function FriendRenameCtrl:OnEnable()
|
||||
end
|
||||
function FriendRenameCtrl:OnDisable()
|
||||
end
|
||||
function FriendRenameCtrl:OnDestroy()
|
||||
end
|
||||
function FriendRenameCtrl:OnBtnClick_Cancel(btn)
|
||||
EventManager.Hit("FriendClosePop")
|
||||
end
|
||||
function FriendRenameCtrl:OnBtnClick_Confirm(btn)
|
||||
local bCD = PlayerData.Base:CheckRenameCD()
|
||||
if bCD then
|
||||
return
|
||||
end
|
||||
local sNewName = NovaAPI.GetTMPInputFieldText(self._mapNode.inputRename)
|
||||
local sOldName = PlayerData.Base:GetPlayerNickName()
|
||||
if sNewName == "" then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("PLAYER_04"))
|
||||
return
|
||||
end
|
||||
if sNewName == sOldName then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("PLAYER_03"))
|
||||
return
|
||||
end
|
||||
if not NovaAPI.IsChannelString(sNewName) then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("PLAYER_00"))
|
||||
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 string.find(sNewName, "%d") == 1 then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("PLAYER_05"))
|
||||
return
|
||||
end
|
||||
local isFullWidthDigit = function(s)
|
||||
local firstChar = string.sub(s, 1)
|
||||
local code = UFT8ToUnicode(firstChar)
|
||||
return 65296 <= code and code <= 65305
|
||||
end
|
||||
if isFullWidthDigit(sNewName) then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("PLAYER_05"))
|
||||
return
|
||||
end
|
||||
local callback = function()
|
||||
EventManager.Hit("FriendClosePop")
|
||||
EventManager.Hit("FriendRefreshName")
|
||||
end
|
||||
PlayerData.Base:SendPlayerNameEditReq(sNewName, callback)
|
||||
end
|
||||
return FriendRenameCtrl
|
||||
@@ -0,0 +1,179 @@
|
||||
local FriendRequestCtrl = class("FriendRequestCtrl", BaseCtrl)
|
||||
FriendRequestCtrl._mapNodeConfig = {
|
||||
inputSearch = {
|
||||
sComponentName = "TMP_InputField"
|
||||
},
|
||||
btnSearch = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Search"
|
||||
},
|
||||
txtSearchDesc = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_SearchDesc"
|
||||
},
|
||||
txtBtnSearch = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Btn_Search"
|
||||
},
|
||||
imgEmptyBg = {},
|
||||
txtEmpty = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_RequireNone"
|
||||
},
|
||||
srRequestList = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
btnAdoptAll = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_AdoptAll"
|
||||
},
|
||||
btnRefuseAll = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_RefuseAll"
|
||||
},
|
||||
btnRecommend = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Recommend"
|
||||
},
|
||||
txtAdoptAll = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Btn_AdoptAll"
|
||||
},
|
||||
txtRefuseAll = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Btn_RefuseAll"
|
||||
},
|
||||
txtRecommend = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_Btn_Recommend"
|
||||
},
|
||||
txtRequireCn = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_RequireStatistics"
|
||||
},
|
||||
txtRequireCount = {sComponentName = "TMP_Text"}
|
||||
}
|
||||
FriendRequestCtrl._mapEventConfig = {
|
||||
FriendRefreshRequest = "Refresh",
|
||||
FriendClearSearch = "OnEvent_ClearSearch"
|
||||
}
|
||||
function FriendRequestCtrl:Refresh()
|
||||
self:ChangeShow(false)
|
||||
local callback = function()
|
||||
self:ChangeShow(true)
|
||||
self:RefreshList()
|
||||
end
|
||||
PlayerData.Friend:SendFriendListGetReq(callback)
|
||||
end
|
||||
function FriendRequestCtrl:ChangeShow(bShow)
|
||||
self._mapNode.btnAdoptAll.gameObject:SetActive(bShow)
|
||||
self._mapNode.btnRefuseAll.gameObject:SetActive(bShow)
|
||||
self._mapNode.btnRecommend.gameObject:SetActive(bShow)
|
||||
self._mapNode.btnSearch.gameObject:SetActive(bShow)
|
||||
end
|
||||
function FriendRequestCtrl:RefreshList()
|
||||
local nRequestNum = PlayerData.Friend:GetFriendRequestNum()
|
||||
self._mapNode.srRequestList.gameObject:SetActive(0 < nRequestNum)
|
||||
self._mapNode.imgEmptyBg:SetActive(nRequestNum == 0)
|
||||
if 0 < nRequestNum then
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self.tbFriendRequest = PlayerData.Friend:GetFriendRequestData()
|
||||
self._mapNode.srRequestList:Init(nRequestNum, self, self.OnGridRefresh)
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtRequireCount, string.format("<color=#08D3D4>%d</color>/%d", nRequestNum, ConfigTable.GetConfigNumber("FriendApplyMax")))
|
||||
end
|
||||
function FriendRequestCtrl:OnGridRefresh(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local mapFriend = self.tbFriendRequest[nIndex]
|
||||
local nInstanceID = goGrid:GetInstanceID()
|
||||
if not self.tbGridCtrl[nInstanceID] then
|
||||
self.tbGridCtrl[nInstanceID] = self:BindCtrlByNode(goGrid, "Game.UI.FriendEx.FriendGridCtrl")
|
||||
self.tbGridCtrl[nInstanceID]:SetType(2)
|
||||
end
|
||||
self.tbGridCtrl[nInstanceID]:Refresh(mapFriend)
|
||||
end
|
||||
function FriendRequestCtrl:Awake()
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function FriendRequestCtrl:OnEnable()
|
||||
end
|
||||
function FriendRequestCtrl:OnDisable()
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function FriendRequestCtrl:OnDestroy()
|
||||
end
|
||||
function FriendRequestCtrl:OnBtnClick_Search()
|
||||
local sName = NovaAPI.GetTMPInputFieldText(self._mapNode.inputSearch)
|
||||
local sPlayerAll = PlayerData.Base:GetPlayerNickName() .. "#" .. PlayerData.Base:GetPlayerHashtag()
|
||||
local nUId = PlayerData.Base:GetPlayerId()
|
||||
if sName == sPlayerAll or tonumber(sName) == nUId then
|
||||
EventManager.Hit(EventId.OpenMessageBox, {
|
||||
nType = AllEnum.MessageBox.Alert,
|
||||
sContent = ConfigTable.GetUIText("Friend_UnableSelf")
|
||||
})
|
||||
return
|
||||
end
|
||||
if sName and sName ~= "" then
|
||||
local callback = function(mapData)
|
||||
EventManager.Hit("FriendSearch", mapData)
|
||||
end
|
||||
if string.gsub(sName, "%d", "") == "" then
|
||||
PlayerData.Friend:SendFriendUIdSearchReq(tonumber(sName), callback)
|
||||
else
|
||||
PlayerData.Friend:SendFriendNameSearchReq(sName, callback)
|
||||
end
|
||||
else
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("FRIEND_02"))
|
||||
end
|
||||
end
|
||||
function FriendRequestCtrl:OnBtnClick_AdoptAll()
|
||||
local nRequestNum = PlayerData.Friend:GetFriendRequestNum()
|
||||
if nRequestNum == 0 then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Friend_NoRequest"))
|
||||
return
|
||||
end
|
||||
local nFriendNum = PlayerData.Friend:GetFriendListNum()
|
||||
if nFriendNum == ConfigTable.GetConfigNumber("FriendMax") then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("FRIEND_00"))
|
||||
return
|
||||
end
|
||||
local callback = function(mapMainData)
|
||||
if mapMainData.Limit then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("FRIEND_00"))
|
||||
end
|
||||
self:RefreshList()
|
||||
end
|
||||
PlayerData.Friend:SendFriendAllAgreeReq(callback)
|
||||
end
|
||||
function FriendRequestCtrl:OnBtnClick_RefuseAll()
|
||||
local nRequestNum = PlayerData.Friend:GetFriendRequestNum()
|
||||
if nRequestNum == 0 then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Friend_NoRequest"))
|
||||
return
|
||||
end
|
||||
local callback = function()
|
||||
self:RefreshList()
|
||||
end
|
||||
local tbUId = {}
|
||||
for _, mapFriendInfo in pairs(self.tbFriendRequest) do
|
||||
table.insert(tbUId, mapFriendInfo.nUId)
|
||||
end
|
||||
PlayerData.Friend:SendFriendInvitesDeleteReq(tbUId, callback)
|
||||
end
|
||||
function FriendRequestCtrl:OnBtnClick_Recommend()
|
||||
local callback = function(mapData)
|
||||
EventManager.Hit("FriendRecommend", mapData)
|
||||
end
|
||||
PlayerData.Friend:SendFriendRecommendationGetReq(callback)
|
||||
end
|
||||
function FriendRequestCtrl:OnEvent_ClearSearch()
|
||||
NovaAPI.SetTMPInputFieldText(self._mapNode.inputSearch, "")
|
||||
end
|
||||
return FriendRequestCtrl
|
||||
@@ -0,0 +1,71 @@
|
||||
local FriendSearchCtrl = class("FriendSearchCtrl", BaseCtrl)
|
||||
FriendSearchCtrl._mapNodeConfig = {
|
||||
txtWindowTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_SearchTitle"
|
||||
},
|
||||
srSearchList = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
btnClose = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Cancel"
|
||||
}
|
||||
}
|
||||
FriendSearchCtrl._mapEventConfig = {}
|
||||
function FriendSearchCtrl:Open(mapData)
|
||||
self:Refresh(mapData)
|
||||
self:PlayInAni()
|
||||
end
|
||||
function FriendSearchCtrl:Refresh(mapData)
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self._panel.tbAddCache = {}
|
||||
self.tbFriendSearch = mapData
|
||||
local nNum = #self.tbFriendSearch
|
||||
self._mapNode.srSearchList:Init(nNum, self, self.OnGridRefresh)
|
||||
end
|
||||
function FriendSearchCtrl:OnGridRefresh(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local mapFriend = self.tbFriendSearch[nIndex]
|
||||
local nInstanceID = goGrid:GetInstanceID()
|
||||
if not self.tbGridCtrl[nInstanceID] then
|
||||
self.tbGridCtrl[nInstanceID] = self:BindCtrlByNode(goGrid, "Game.UI.FriendEx.FriendGridCtrl")
|
||||
self.tbGridCtrl[nInstanceID]:SetType(3)
|
||||
end
|
||||
self.tbGridCtrl[nInstanceID]:Refresh(mapFriend)
|
||||
end
|
||||
function FriendSearchCtrl:PlayInAni()
|
||||
self.gameObject:SetActive(true)
|
||||
self.ani:Play("t_window_04_t_in")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.3)
|
||||
end
|
||||
function FriendSearchCtrl:PlayOutAni()
|
||||
self.ani:Play("t_window_04_t_out")
|
||||
self:AddTimer(1, 0.2, "Close", true, true, true)
|
||||
end
|
||||
function FriendSearchCtrl:Close()
|
||||
self.gameObject:SetActive(false)
|
||||
EventManager.Hit("FriendClearSearch")
|
||||
end
|
||||
function FriendSearchCtrl:Awake()
|
||||
self.ani = self.gameObject.transform:GetComponent("Animator")
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function FriendSearchCtrl:OnEnable()
|
||||
end
|
||||
function FriendSearchCtrl:OnDisable()
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function FriendSearchCtrl:OnDestroy()
|
||||
end
|
||||
function FriendSearchCtrl:OnBtnClick_Cancel(btn)
|
||||
EventManager.Hit("FriendClosePop")
|
||||
end
|
||||
return FriendSearchCtrl
|
||||
@@ -0,0 +1,122 @@
|
||||
local FriendSignatureCtrl = class("FriendSignatureCtrl", BaseCtrl)
|
||||
FriendSignatureCtrl._mapNodeConfig = {
|
||||
txtWindowTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_SignTitle"
|
||||
},
|
||||
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"
|
||||
},
|
||||
inputSign = {
|
||||
sComponentName = "TMP_InputField",
|
||||
callback = "OnValueChanged_Sign"
|
||||
},
|
||||
txtSignDesc = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_ClickInput"
|
||||
},
|
||||
txtLimit = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_TextLimit"
|
||||
},
|
||||
txtCurCount = {sComponentName = "TMP_Text"}
|
||||
}
|
||||
FriendSignatureCtrl._mapEventConfig = {}
|
||||
function FriendSignatureCtrl:Open()
|
||||
self:Refresh()
|
||||
self:PlayInAni()
|
||||
end
|
||||
function FriendSignatureCtrl:Refresh()
|
||||
local sSign = PlayerData.Base:GetPlayerSignature()
|
||||
NovaAPI.SetTMPInputFieldText(self._mapNode.inputSign, sSign)
|
||||
local nCount = string.utf8len(sSign)
|
||||
if nCount > self.nMaxSignature then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCurCount, string.format("<color=#BD3059>%d</color>/%d", nCount, self.nMaxSignature))
|
||||
else
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCurCount, string.format("<color=#264278>%d</color>/%d", nCount, self.nMaxSignature))
|
||||
end
|
||||
end
|
||||
function FriendSignatureCtrl:PlayInAni()
|
||||
self.gameObject:SetActive(true)
|
||||
self.ani:Play("t_window_04_t_in")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.3)
|
||||
end
|
||||
function FriendSignatureCtrl:PlayOutAni()
|
||||
self.ani:Play("t_window_04_t_out")
|
||||
self:AddTimer(1, 0.2, "Close", true, true, true)
|
||||
end
|
||||
function FriendSignatureCtrl:Close()
|
||||
self.gameObject:SetActive(false)
|
||||
end
|
||||
function FriendSignatureCtrl:Awake()
|
||||
self.ani = self.gameObject.transform:GetComponent("Animator")
|
||||
self.nMaxSignature = ConfigTable.GetConfigNumber("FriendSignatureMax")
|
||||
end
|
||||
function FriendSignatureCtrl:OnEnable()
|
||||
end
|
||||
function FriendSignatureCtrl:OnDisable()
|
||||
end
|
||||
function FriendSignatureCtrl:OnDestroy()
|
||||
end
|
||||
function FriendSignatureCtrl:OnBtnClick_Cancel(btn)
|
||||
EventManager.Hit("FriendClosePop")
|
||||
end
|
||||
function FriendSignatureCtrl:OnBtnClick_Confirm(btn)
|
||||
local sSign = NovaAPI.GetTMPInputFieldText(self._mapNode.inputSign)
|
||||
local sOld = PlayerData.Base:GetPlayerSignature()
|
||||
if sSign == sOld then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Friend_SignSame"))
|
||||
return
|
||||
end
|
||||
if string.utf8len(sSign) > self.nMaxSignature then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Friend_SignLong"))
|
||||
return
|
||||
end
|
||||
if string.find(sSign, "[<>/']") then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Friend_SignUnableString"))
|
||||
sSign = string.gsub(sSign, "<u>", "")
|
||||
sSign = string.gsub(sSign, "</u>", "")
|
||||
sSign = string.gsub(sSign, "'", "")
|
||||
NovaAPI.SetTMPInputFieldText(self._mapNode.inputSign, sSign)
|
||||
return
|
||||
end
|
||||
local bInit = NovaAPI.IsDirtyWordsInit()
|
||||
if not bInit then
|
||||
NovaAPI.InitDirtyWords()
|
||||
end
|
||||
if NovaAPI.IsDirtyString(sSign) then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Friend_SignDirty"))
|
||||
return
|
||||
end
|
||||
local callback = function()
|
||||
EventManager.Hit("FriendClosePop")
|
||||
EventManager.Hit("FriendRefreshSign")
|
||||
end
|
||||
PlayerData.Base:SendPlayerSignatureEditReq(sSign, callback)
|
||||
end
|
||||
function FriendSignatureCtrl:OnValueChanged_Sign(_, sContent)
|
||||
local nCount = string.utf8len(sContent)
|
||||
if nCount > self.nMaxSignature then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCurCount, string.format("<color=#BD3059>%d</color>/%d", nCount, self.nMaxSignature))
|
||||
else
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCurCount, string.format("<color=#264278>%d</color>/%d", nCount, self.nMaxSignature))
|
||||
end
|
||||
end
|
||||
return FriendSignatureCtrl
|
||||
@@ -0,0 +1,161 @@
|
||||
local FriendTitleCtrl = class("FriendTitleCtrl", BaseCtrl)
|
||||
FriendTitleCtrl._mapNodeConfig = {
|
||||
txtWindowTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Friend_ChangeTitle"
|
||||
},
|
||||
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"
|
||||
},
|
||||
txtSelect = {nCount = 2, sComponentName = "TMP_Text"},
|
||||
sv = {
|
||||
nCount = 2,
|
||||
sComponentName = "LoopScrollView"
|
||||
}
|
||||
}
|
||||
FriendTitleCtrl._mapEventConfig = {}
|
||||
function FriendTitleCtrl:Open()
|
||||
self:Refresh()
|
||||
self:PlayInAni()
|
||||
end
|
||||
function FriendTitleCtrl:Refresh()
|
||||
local nPre, nSuf = PlayerData.Base:GetPlayerTitle()
|
||||
NovaAPI.SetTMPText(self._mapNode.txtSelect[1], nPre == 0 and "" or ConfigTable.GetData("Title", nPre).Desc)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtSelect[2], nSuf == 0 and "" or ConfigTable.GetData("Title", nSuf).Desc)
|
||||
self.tbPrefix, self.tbSuffix = PlayerData.Base:GetPlayerAllTitle()
|
||||
local nNumPre = #self.tbPrefix
|
||||
self._mapNode.sv[1].gameObject:SetActive(0 < nNumPre)
|
||||
if 0 < nNumPre then
|
||||
self.nPrefixIndex = 1
|
||||
for k, v in pairs(self.tbPrefix) do
|
||||
if v.nId == nPre then
|
||||
self.nPrefixIndex = k
|
||||
end
|
||||
end
|
||||
self._mapNode.sv[1]:Init(nNumPre, self, self.OnPrefixGridRefresh, self.OnPrefixGridClick)
|
||||
end
|
||||
local nNumSuf = #self.tbSuffix
|
||||
self._mapNode.sv[2].gameObject:SetActive(0 < nNumSuf)
|
||||
if 0 < nNumSuf then
|
||||
self.nSuffixIndex = 1
|
||||
for k, v in pairs(self.tbSuffix) do
|
||||
if v.nId == nSuf then
|
||||
self.nSuffixIndex = k
|
||||
end
|
||||
end
|
||||
self._mapNode.sv[2]:Init(nNumSuf, self, self.OnSuffixGridRefresh, self.OnSuffixGridClick)
|
||||
end
|
||||
end
|
||||
function FriendTitleCtrl:OnPrefixGridRefresh(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local mapData = self.tbPrefix[nIndex]
|
||||
local imgSelect = goGrid.transform:Find("btnGrid/AnimRoot/imgSelect").gameObject
|
||||
local txtPlayerTitle = goGrid.transform:Find("btnGrid/AnimRoot/txtPlayerTitle"):GetComponent("TMP_Text")
|
||||
local redDot = goGrid.transform:Find("btnGrid/AnimRoot/redDot").gameObject
|
||||
RedDotManager.RegisterNode(RedDotDefine.Friend_Title_Item, mapData.nId, redDot, nil, nil, true)
|
||||
imgSelect:SetActive(self.nPrefixIndex == nIndex)
|
||||
NovaAPI.SetTMPText(txtPlayerTitle, mapData.sDesc)
|
||||
end
|
||||
function FriendTitleCtrl:OnPrefixGridClick(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
if self.nPrefixIndex == nIndex then
|
||||
return
|
||||
end
|
||||
local mapData = self.tbPrefix[nIndex]
|
||||
if self.nPrefixIndex then
|
||||
local goSelect = self._mapNode.sv[1].transform:Find("Viewport/Content/" .. self.nPrefixIndex - 1)
|
||||
if goSelect then
|
||||
local imgSelect = goSelect.transform:Find("btnGrid/AnimRoot/imgSelect").gameObject
|
||||
imgSelect:SetActive(false)
|
||||
end
|
||||
end
|
||||
local imgSelect = goGrid.transform:Find("btnGrid/AnimRoot/imgSelect").gameObject
|
||||
imgSelect:SetActive(true)
|
||||
self.nPrefixIndex = nIndex
|
||||
NovaAPI.SetTMPText(self._mapNode.txtSelect[1], mapData.sDesc)
|
||||
RedDotManager.SetValid(RedDotDefine.Friend_Title_Item, mapData.nId, false)
|
||||
end
|
||||
function FriendTitleCtrl:OnSuffixGridRefresh(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local mapData = self.tbSuffix[nIndex]
|
||||
local imgSelect = goGrid.transform:Find("btnGrid/AnimRoot/imgSelect").gameObject
|
||||
local txtPlayerTitle = goGrid.transform:Find("btnGrid/AnimRoot/txtPlayerTitle"):GetComponent("TMP_Text")
|
||||
local redDot = goGrid.transform:Find("btnGrid/AnimRoot/redDot").gameObject
|
||||
RedDotManager.RegisterNode(RedDotDefine.Friend_Title_Item, mapData.nId, redDot, nil, nil, true)
|
||||
imgSelect:SetActive(self.nSuffixIndex == nIndex)
|
||||
NovaAPI.SetTMPText(txtPlayerTitle, mapData.sDesc)
|
||||
end
|
||||
function FriendTitleCtrl:OnSuffixGridClick(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
if self.nSuffixIndex == nIndex then
|
||||
return
|
||||
end
|
||||
local mapData = self.tbSuffix[nIndex]
|
||||
if self.nSuffixIndex then
|
||||
local goSelect = self._mapNode.sv[2].transform:Find("Viewport/Content/" .. self.nSuffixIndex - 1)
|
||||
if goSelect then
|
||||
local imgSelect = goSelect.transform:Find("btnGrid/AnimRoot/imgSelect").gameObject
|
||||
imgSelect:SetActive(false)
|
||||
end
|
||||
end
|
||||
local imgSelect = goGrid.transform:Find("btnGrid/AnimRoot/imgSelect").gameObject
|
||||
imgSelect:SetActive(true)
|
||||
self.nSuffixIndex = nIndex
|
||||
NovaAPI.SetTMPText(self._mapNode.txtSelect[2], mapData.sDesc)
|
||||
RedDotManager.SetValid(RedDotDefine.Friend_Title_Item, mapData.nId, false)
|
||||
end
|
||||
function FriendTitleCtrl:PlayInAni()
|
||||
self.gameObject:SetActive(true)
|
||||
self.ani:Play("t_window_04_t_in")
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.3)
|
||||
end
|
||||
function FriendTitleCtrl:PlayOutAni()
|
||||
self.ani:Play("t_window_04_t_out")
|
||||
self:AddTimer(1, 0.2, "Close", true, true, true)
|
||||
end
|
||||
function FriendTitleCtrl:Close()
|
||||
for _, v in ipairs(self.tbPrefix) do
|
||||
RedDotManager.SetValid(RedDotDefine.Friend_Title_Item, v.nId, false)
|
||||
end
|
||||
for _, v in ipairs(self.tbSuffix) do
|
||||
RedDotManager.SetValid(RedDotDefine.Friend_Title_Item, v.nId, false)
|
||||
end
|
||||
self.gameObject:SetActive(false)
|
||||
end
|
||||
function FriendTitleCtrl:Awake()
|
||||
self.ani = self.gameObject.transform:GetComponent("Animator")
|
||||
end
|
||||
function FriendTitleCtrl:OnEnable()
|
||||
end
|
||||
function FriendTitleCtrl:OnDisable()
|
||||
end
|
||||
function FriendTitleCtrl:OnDestroy()
|
||||
end
|
||||
function FriendTitleCtrl:OnBtnClick_Cancel(btn)
|
||||
EventManager.Hit("FriendClosePop")
|
||||
end
|
||||
function FriendTitleCtrl:OnBtnClick_Confirm(btn)
|
||||
local callback = function()
|
||||
EventManager.Hit("FriendClosePop")
|
||||
EventManager.Hit("FriendRefreshTitle")
|
||||
end
|
||||
PlayerData.Base:SendPlayerTitleEditReq(self.tbPrefix[self.nPrefixIndex].nId, self.tbSuffix[self.nSuffixIndex].nId, callback)
|
||||
end
|
||||
return FriendTitleCtrl
|
||||
@@ -0,0 +1,67 @@
|
||||
local BaseCtrl = require("GameCore.UI.BaseCtrl")
|
||||
local HonorTitleCtrl = class("HonorTitleCtrl", BaseCtrl)
|
||||
HonorTitleCtrl._mapNodeConfig = {
|
||||
imgHonorTitle = {sComponentName = "Image"},
|
||||
imgStar = {nCount = 5, sComponentName = "Image"},
|
||||
imgStarSmall = {nCount = 5, sComponentName = "Image"},
|
||||
goStarBig = {},
|
||||
goStarSmall = {},
|
||||
Reddot = {}
|
||||
}
|
||||
HonorTitleCtrl._mapEventConfig = {}
|
||||
local HonorTitleStarPath = {
|
||||
"zs_honor_level_0",
|
||||
"zs_honor_level_2",
|
||||
"zs_honor_level_1",
|
||||
"zs_honor_level_4",
|
||||
"zs_honor_level_3"
|
||||
}
|
||||
function HonorTitleCtrl:SetHonotTitle(honorTitleId, bBig, affinity_lv)
|
||||
local honorData = ConfigTable.GetData("Honor", honorTitleId)
|
||||
self:SetPngSprite(self._mapNode.imgHonorTitle, bBig and honorData.MainRes or honorData.SubRes)
|
||||
NovaAPI.SetImageNativeSize(self._mapNode.imgHonorTitle)
|
||||
if honorData.Type ~= GameEnum.honorType.Character then
|
||||
self._mapNode.goStarBig:SetActive(false)
|
||||
self._mapNode.goStarSmall:SetActive(false)
|
||||
return
|
||||
end
|
||||
local maxLevel = 1
|
||||
self.tbHonorTitle, maxLevel = PlayerData.Char:GetCharHonorTitleData(honorData.Params[1])
|
||||
if self.tbHonorTitle == nil then
|
||||
return
|
||||
end
|
||||
local level = affinity_lv
|
||||
self.curData = {}
|
||||
if maxLevel < level then
|
||||
self.curData = self.tbHonorTitle[maxLevel]
|
||||
else
|
||||
self.curData = self.tbHonorTitle[level]
|
||||
end
|
||||
if self.curData == nil then
|
||||
self._mapNode.goStarBig:SetActive(false)
|
||||
self._mapNode.goStarSmall:SetActive(false)
|
||||
return
|
||||
end
|
||||
self:SetPngSprite(self._mapNode.imgHonorTitle, bBig and self.curData.BigBgPath or self.curData.SmallBgPath)
|
||||
self._mapNode.goStarBig:SetActive(bBig)
|
||||
self._mapNode.goStarSmall:SetActive(not bBig)
|
||||
for i = 1, 5 do
|
||||
if self.curData.StarGroup[i] ~= nil then
|
||||
if bBig then
|
||||
self:SetAtlasSprite(self._mapNode.imgStar[i], "10_ico", HonorTitleStarPath[self.curData.StarGroup[i]])
|
||||
else
|
||||
self:SetAtlasSprite(self._mapNode.imgStarSmall[i], "10_ico", HonorTitleStarPath[self.curData.StarGroup[i]])
|
||||
end
|
||||
end
|
||||
if bBig then
|
||||
self._mapNode.imgStar[i].gameObject:SetActive(self.curData.StarGroup[i] ~= nil)
|
||||
else
|
||||
self._mapNode.imgStarSmall[i].gameObject:SetActive(self.curData.StarGroup[i] ~= nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
function HonorTitleCtrl:RegisterRedDot(honorTitleId)
|
||||
self.honorId = honorTitleId
|
||||
RedDotManager.RegisterNode(RedDotDefine.Friend_Honor_Title_Item, honorTitleId, self._mapNode.Reddot, nil, nil, true)
|
||||
end
|
||||
return HonorTitleCtrl
|
||||
Reference in New Issue
Block a user