PGRData/Script/matrix/xui/xuidormbag/XUiGridDormCharacter.lua
2024-09-01 22:49:41 +02:00

69 lines
No EOL
2.3 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)
self.ImgLove:SetSprite(loveTypeConfig.TypeIcon)
self.ImgLike:SetSprite(likeTypeConfig.TypeIcon)
local showNew = XDataCenter.FurnitureManager.CheckNewHint(characterId)
self.ImgNew.gameObject:SetActiveEx(showNew)
if showNew then
XDataCenter.FurnitureManager.AddNewHint({characterId})
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