---@class WB_PlayerSelectedMap_C:UUserWidget ---@field General_AvatarFrame_UIBP UCommon_Avatar_BP_C ---@field TextBlock_MapMode UTextBlock ---@field TextBlock_MapName UTextBlock ---@field TextBlock_TC_Loading_PlayerName1 UTextBlock ---@field WidgetSwitcher_TC_Loading_Gender1 UWidgetSwitcher ---@field WidgetSwitcher_TC_Loading_Item UWidgetSwitcher ---@field WidgetSwitcher_TeamBG UWidgetSwitcher --Edit Below-- local WB_PlayerSelectedMap = { bInitDoOnce = false } --[==[ Construct function WB_PlayerSelectedMap:Construct() end -- Construct ]==] -- function WB_PlayerSelectedMap:Tick(MyGeometry, InDeltaTime) -- end -- function WB_PlayerSelectedMap:Destruct() -- end function WB_PlayerSelectedMap:LuaInit() if self.bInitDoOnce then return end self.bInitDoOnce = true UGCEventSystem.AddListener(EventEnum.UpdatePlayerSelectedMap, self.UpdatePlayerSelectedMap, self) UGCEventSystem.AddListener(EventEnum.UpdatePlayerSelectedTeam, self.UpdateSelectTeam, self) end function WB_PlayerSelectedMap:SetPlayerKey(InPlayerKey) self:LuaInit() if self.PlayerKey ~= InPlayerKey then self.PlayerKey = InPlayerKey if self.PlayerKey then self:UpdatePlayerInfo() self:UpdateSelectTeam() self:UpdatePlayerSelectedMap() end end end function WB_PlayerSelectedMap:UpdatePlayerInfo() if self.PlayerKey == nil then return end local PlayerInfo = UGCGameSystem.GameState:GetPlayerHeadInfo(self.PlayerKey) ---@param PlayerInfo table {UID:string, IconURL:string, Gender:int, AvatarBoxId:int, PlayerLevel:int, PlayerName:string} 其中AvatarBoxId可以从PlayerState中获取 UGCLogSystem.LogTree(string.format("[WB_PlayerInfo_L_UpdatePlayerInfo] PlayerInfo ="), PlayerInfo) UGCLogSystem.Log("[WB_ShowVSPlayerInfo:UpdatePlayerInfo] PlayerName = %s", PlayerInfo.PlayerName) self.TextBlock_TC_Loading_PlayerName1:SetText(PlayerInfo.PlayerName) self.WidgetSwitcher_TC_Loading_Gender1:SetActiveWidgetIndex(PlayerInfo.Gender - 1) ---@field InitView:fun(style:int32,uid:FString,iconURL:FString,gender:int32,frameLevel:int32,playerLevel:int32,ignoreFrame:bool,IsMySelf:bool) self.General_AvatarFrame_UIBP:InitView(2, PlayerInfo.UIDString, PlayerInfo.IconURL, PlayerInfo.Gender, PlayerInfo.AvatarBoxId, PlayerInfo.PlayerLevel, false, false) end function WB_PlayerSelectedMap:UpdateSelectTeam() if self.PlayerKey == nil then return end local SelectTeam = UGCGameSystem.GameState:GetPlayerSelectedTeam(self.PlayerKey) if SelectTeam == nil then self.WidgetSwitcher_TeamBG:SetActiveWidgetIndex(0) elseif SelectTeam == 1 then self.WidgetSwitcher_TeamBG:SetActiveWidgetIndex(1) else self.WidgetSwitcher_TeamBG:SetActiveWidgetIndex(2) end end function WB_PlayerSelectedMap:UpdatePlayerSelectedMap() if self.PlayerKey == nil then return end local SelectMapIndex = UGCGameSystem.GameState:GetPlayerSelectedMap(self.PlayerKey) local MapInfo = MapConfig.MapInfo[SelectMapIndex] if MapInfo then self.TextBlock_MapName:SetText(MapInfo.ShowName) self.TextBlock_MapMode:SetText("-" .. MapConfig.ModeTypeName[MapInfo.ModeType]) else self.TextBlock_MapName:SetText("") self.TextBlock_MapMode:SetText("") end end return WB_PlayerSelectedMap