2023-07-15 02:35:33 +07:00
|
|
|
|
local XUiGridMemberItem = XClass(nil, "XUiGridMemberItem")
|
2024-09-01 22:49:41 +02:00
|
|
|
|
local CsVector2 = CS.UnityEngine.Vector2
|
2023-07-15 02:35:33 +07:00
|
|
|
|
|
|
|
|
|
function XUiGridMemberItem:Ctor(ui)
|
|
|
|
|
self.GameObject = ui.gameObject
|
|
|
|
|
self.Transform = ui.transform
|
|
|
|
|
XTool.InitUiObject(self)
|
|
|
|
|
self.CanSet = false
|
2024-09-01 22:49:41 +02:00
|
|
|
|
|
|
|
|
|
self.BtnDismiss.gameObject:SetActiveEx(false)
|
|
|
|
|
self.BtnDis.CallBack = function() self:OnBtnDismissClick() end
|
2023-07-15 02:35:33 +07:00
|
|
|
|
self.BtnGift.CallBack = function() self:OnBtnGiftClick() end
|
|
|
|
|
self.BtnKickOut.CallBack = function() self:OnBtnKickOut() end
|
|
|
|
|
self.BtnChangePosition.CallBack = function() self:OnBtnChangePosition() end
|
|
|
|
|
self.BtnSet.CallBack = function() self:OnBtnSet() end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XUiGridMemberItem:Init(uiRoot)
|
|
|
|
|
self.UiRoot = uiRoot
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XUiGridMemberItem:SetMemberInfo(memberInfo, selectIndex)
|
|
|
|
|
self.MemberInfo = memberInfo
|
|
|
|
|
self.IsSetPanel = memberInfo.IsSetPanel
|
|
|
|
|
self.Index = memberInfo.Index
|
|
|
|
|
self:UpdateGuildInfo()
|
|
|
|
|
local setBtnStatus = (selectIndex and self.Index == selectIndex)
|
|
|
|
|
if self.CanSet then
|
|
|
|
|
self.BtnSet:SetButtonState(setBtnStatus and CS.UiButtonState.Select or CS.UiButtonState.Normal)
|
|
|
|
|
end
|
|
|
|
|
if self.IsSetPanel then
|
|
|
|
|
-- self.PanelMemberInfo.gameObject:SetActiveEx(true)
|
|
|
|
|
self.PanelMemberSet.gameObject:SetActiveEx(true)
|
|
|
|
|
else
|
|
|
|
|
-- self.PanelMemberInfo.gameObject:SetActiveEx(true)
|
|
|
|
|
self.PanelMemberSet.gameObject:SetActiveEx(false)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self.TxtName.text = XDataCenter.SocialManager.GetPlayerRemark(memberInfo.Id, memberInfo.Name)
|
|
|
|
|
XUiPlayerLevel.UpdateLevel(memberInfo.Level, self.TextLv, CS.XTextManager.GetText("GuildMemberLevel", memberInfo.Level))
|
|
|
|
|
local jobName = XDataCenter.GuildManager.GetRankNameByLevel(memberInfo.RankLevel)
|
|
|
|
|
self.TxtJob.text = jobName
|
|
|
|
|
self.TxtContribution.text = memberInfo.ContributeAct or 0
|
|
|
|
|
self.TxtHistoryContribution.text = memberInfo.ContributeHistory or 0
|
|
|
|
|
if memberInfo.OnlineFlag == 1 then
|
|
|
|
|
self.TxtLastLogin.text = CS.XTextManager.GetText("GuildMemberOnline")
|
|
|
|
|
else
|
|
|
|
|
self.TxtLastLogin.text = XUiHelper.CalcLatelyLoginTime(memberInfo.LastLoginTime)
|
|
|
|
|
end
|
|
|
|
|
self.TxtPopulation.text = memberInfo.Popularity
|
|
|
|
|
self:UpdateDissmissState(self.MemberInfo)
|
|
|
|
|
XUiPLayerHead.InitPortrait(memberInfo.HeadPortraitId, memberInfo.HeadFrameId, self.Head)
|
|
|
|
|
local isPlayer = memberInfo.Id == XPlayer.Id
|
|
|
|
|
self.BtnGift:SetDisable(isPlayer, not isPlayer)
|
|
|
|
|
|
|
|
|
|
self.LayoutNode:SetDirty()
|
2024-09-01 22:49:41 +02:00
|
|
|
|
--#115837特殊修改,移动端适配显示异常问题
|
|
|
|
|
self.PanelMemberInfo.sizeDelta = CsVector2(self.Transform.parent.transform.rect.width, self.PanelMemberInfo.rect.height)
|
2023-07-15 02:35:33 +07:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XUiGridMemberItem:UpdateDissmissState(memberInfo)
|
|
|
|
|
if not memberInfo then return end
|
|
|
|
|
|
|
|
|
|
local hasImpeach = XDataCenter.GuildManager.HasImpeachLeader()
|
|
|
|
|
local canImpeach = XDataCenter.GuildManager.CanImpeachLeader()
|
|
|
|
|
local isLeaderMyself = XDataCenter.GuildManager.IsGuildLeader()
|
|
|
|
|
local memberIsLeader = memberInfo.RankLevel == XGuildConfig.GuildRankLevel.Leader
|
2024-09-01 22:49:41 +02:00
|
|
|
|
local showDis = canImpeach and not hasImpeach and not isLeaderMyself and memberIsLeader
|
|
|
|
|
self.BtnDis.gameObject:SetActiveEx(showDis)
|
|
|
|
|
self.PanelJob.gameObject:SetActiveEx(not showDis)
|
2023-07-15 02:35:33 +07:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XUiGridMemberItem:UpdateMemberJobInfo(memberInfo)
|
|
|
|
|
self.TxtJob.text = XDataCenter.GuildManager.GetRankNameByLevel(memberInfo.RankLevel)
|
|
|
|
|
self.TxtPopulation.text = memberInfo.Popularity
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XUiGridMemberItem:OnBtnDismissClick()
|
|
|
|
|
if self:CheckKickOut() then return end
|
|
|
|
|
self.DissmissCallBack = function()
|
|
|
|
|
XDataCenter.GuildManager.GuildImpeachLeader(function()
|
|
|
|
|
XDataCenter.GuildManager.SetImpeachLeader()
|
|
|
|
|
self:UpdateDissmissState(self.MemberInfo)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
XLuaUiManager.Open("UiGuildAsset", self.DissmissCallBack)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XUiGridMemberItem:OnBtnGiftClick()
|
|
|
|
|
if self:CheckKickOut() then return end
|
|
|
|
|
XLuaUiManager.Open("UiGuildGift", self.MemberInfo)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XUiGridMemberItem:UpdateGuildInfo()
|
|
|
|
|
-- 管理级别大于该成员则设置按钮可用:更换职位、踢出公会
|
|
|
|
|
self:ResetGuildBtns()
|
|
|
|
|
if not self.MemberInfo then return end
|
|
|
|
|
local targetRankLevel = self.MemberInfo.RankLevel
|
|
|
|
|
local isAdministor = XDataCenter.GuildManager.IsGuildAdminister()
|
|
|
|
|
local myRankLevel = XDataCenter.GuildManager.GetCurRankLevel()
|
|
|
|
|
local myGuildId = XDataCenter.GuildManager.GetGuildId()
|
|
|
|
|
if isAdministor then
|
|
|
|
|
self.BtnSet.gameObject:SetActiveEx(true)
|
|
|
|
|
if targetRankLevel ~= nil and targetRankLevel > 0 and myRankLevel < targetRankLevel then
|
|
|
|
|
self.CanSet = true
|
|
|
|
|
self.BtnKickOut.gameObject:SetActiveEx(true)
|
|
|
|
|
self.BtnChangePosition.gameObject:SetActiveEx(true)
|
|
|
|
|
self.BtnSet:SetButtonState(CS.UiButtonState.Normal)
|
|
|
|
|
else
|
|
|
|
|
self.CanSet = false
|
|
|
|
|
self.BtnSet:SetButtonState(CS.UiButtonState.Disable)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XUiGridMemberItem:ResetGuildBtns()
|
|
|
|
|
self.BtnSet.gameObject:SetActiveEx(false)
|
|
|
|
|
self.BtnKickOut.gameObject:SetActiveEx(false)
|
|
|
|
|
self.BtnChangePosition.gameObject:SetActiveEx(false)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function XUiGridMemberItem:OnBtnKickOut()
|
|
|
|
|
-- 中途被踢出公会
|
|
|
|
|
if self:CheckKickOut() then return end
|
|
|
|
|
-- 职位变更
|
|
|
|
|
if self:HasModifyGuildAccess() then return end
|
|
|
|
|
|
2024-09-01 22:49:41 +02:00
|
|
|
|
local title = CS.XTextManager.GetText("GuildDialogKickMemberTitle")
|
2023-07-15 02:35:33 +07:00
|
|
|
|
local content = CS.XTextManager.GetText("GuildIsKickMember")
|
|
|
|
|
|
2024-09-01 22:49:41 +02:00
|
|
|
|
--判断工会战是否开启 如果开启 置换踢出提示
|
|
|
|
|
if XDataCenter.GuildWarManager.CheckActivityIsInTime() then
|
|
|
|
|
content = CS.XTextManager.GetText("GuildIsKickMemberInGuildWarTime")
|
|
|
|
|
end
|
|
|
|
|
|
2023-07-15 02:35:33 +07:00
|
|
|
|
XUiManager.DialogTip(title, content, XUiManager.DialogType.Normal, function()
|
|
|
|
|
end, function()
|
|
|
|
|
XDataCenter.GuildManager.GuildKickMember(self.MemberInfo.Id, function()
|
|
|
|
|
XUiManager.TipMsg(CS.XTextManager.GetText("GuildKickMemberSuccess"))
|
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XUiGridMemberItem:OnBtnChangePosition()
|
|
|
|
|
-- 中途被踢出公会
|
|
|
|
|
if self:CheckKickOut() then return end
|
|
|
|
|
-- 职位变更
|
|
|
|
|
if self:HasModifyGuildAccess() then return end
|
|
|
|
|
-- 是否有更换职位的权利
|
|
|
|
|
local memberList = XDataCenter.GuildManager.GetMemberList()
|
|
|
|
|
local memberInfo = memberList[self.MemberInfo.Id]
|
|
|
|
|
if memberInfo then
|
2024-09-01 22:49:41 +02:00
|
|
|
|
RunAsyn(function()
|
|
|
|
|
XLuaUiManager.Open("UiGuildChangePosition", XGuildConfig.TipsType.ChangePosition, memberInfo)
|
|
|
|
|
local signalCode, targetMemberInfo = XLuaUiManager.AwaitSignal("UiGuildChangePosition", "Close", self)
|
|
|
|
|
if signalCode ~= XSignalCode.SUCCESS then return end
|
|
|
|
|
self.MemberInfo = targetMemberInfo
|
|
|
|
|
local jobName = XDataCenter.GuildManager.GetRankNameByLevel(self.MemberInfo.RankLevel)
|
|
|
|
|
self.TxtJob.text = jobName
|
|
|
|
|
end)
|
|
|
|
|
|
2023-07-15 02:35:33 +07:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XUiGridMemberItem:OnBtnSet()
|
|
|
|
|
if not self.CanSet then return end
|
|
|
|
|
XEventManager.DispatchEvent(XEventId.EVENT_GUILD_MEMBER_SET ,self.Index)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XUiGridMemberItem:CheckKickOut()
|
|
|
|
|
-- 中途被踢出公会
|
|
|
|
|
if not XDataCenter.GuildManager.IsJoinGuild() then
|
|
|
|
|
XUiManager.TipMsg(CS.XTextManager.GetText("GuildKickOutByAdministor"))
|
|
|
|
|
self.UiRoot:Close()
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XUiGridMemberItem:HasModifyGuildAccess()
|
|
|
|
|
if not XDataCenter.GuildManager.IsGuildAdminister() then
|
|
|
|
|
XUiManager.TipMsg(CS.XTextManager.GetText("GuildNotAdministor"))
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return XUiGridMemberItem
|