2023-07-14 19:35:33 +00:00
|
|
|
|
local XUiGridDormCharacter = XClass(nil, "XUiGridDormCharacter")
|
|
|
|
|
|
|
|
|
|
function XUiGridDormCharacter:Ctor(ui, rootUi)
|
|
|
|
|
self.GameObject = ui.gameObject
|
|
|
|
|
self.Transform = ui.transform
|
|
|
|
|
self.RootUi = rootUi
|
|
|
|
|
XTool.InitUiObject(self)
|
|
|
|
|
self:AutoAddListener()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XUiGridDormCharacter:RegisterClickEvent(uiNode, func)
|
|
|
|
|
if func == nil then
|
|
|
|
|
XLog.Error("XUiGridDormCharacter:RegisterClickEvent函数参数错误:参数func不能为空")
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if type(func) ~= "function" then
|
|
|
|
|
XLog.Error("XUiGridDormCharacter:RegisterClickEvent函数错误, 参数func需要是function类型, func的类型是" .. type(func))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local listener = function(...)
|
|
|
|
|
func(self, ...)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
CsXUiHelper.RegisterClickEvent(uiNode, listener)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XUiGridDormCharacter:AutoAddListener()
|
|
|
|
|
self:RegisterClickEvent(self.BtnClick, self.OnBtnClickClick)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XUiGridDormCharacter:OnBtnClickClick()
|
|
|
|
|
self.ImgNew.gameObject:SetActiveEx(false)
|
|
|
|
|
XLuaUiManager.Open("UiDormCharacterDetail", self.CharacterId, self.RootUi.FromDorm)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function XUiGridDormCharacter:Refresh(characterId)
|
|
|
|
|
self.CharacterId = characterId
|
|
|
|
|
|
|
|
|
|
local charStyleConfig = XDormConfig.GetCharacterStyleConfigById(characterId)
|
|
|
|
|
if not charStyleConfig then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self.RImgIcon:SetRawImage(charStyleConfig.HeadIcon, nil, true)
|
|
|
|
|
self.TxtCharacterName.text = charStyleConfig.Name
|
|
|
|
|
local loveTypeConfig = XFurnitureConfigs.GetDormFurnitureType(charStyleConfig.LoveType)
|
|
|
|
|
local likeTypeConfig = XFurnitureConfigs.GetDormFurnitureType(charStyleConfig.LikeType)
|
2024-09-01 20:49:41 +00:00
|
|
|
|
|
|
|
|
|
self.ImgLove:SetSprite(loveTypeConfig.TypeIcon)
|
|
|
|
|
self.ImgLike:SetSprite(likeTypeConfig.TypeIcon)
|
2023-07-14 19:35:33 +00:00
|
|
|
|
|
|
|
|
|
local showNew = XDataCenter.FurnitureManager.CheckNewHint(characterId)
|
|
|
|
|
self.ImgNew.gameObject:SetActiveEx(showNew)
|
|
|
|
|
if showNew then
|
2024-09-01 20:49:41 +00:00
|
|
|
|
XDataCenter.FurnitureManager.AddNewHint({characterId})
|
2023-07-14 19:35:33 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self.TxtLove.text = CS.XTextManager.GetText("DormHightDescription")
|
|
|
|
|
self.TxtLike.text = CS.XTextManager.GetText("DormMiddleDescription")
|
|
|
|
|
|
|
|
|
|
local inRoomNumber = XDataCenter.DormManager.GetCharacterRoomNumber(characterId)
|
|
|
|
|
self.PanelInRoom.gameObject:SetActiveEx(inRoomNumber > 0)
|
|
|
|
|
if inRoomNumber > 0 then
|
|
|
|
|
self.TxtRoomNum.text = XDataCenter.DormManager.GetDormName(inRoomNumber)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return XUiGridDormCharacter
|