---@class WB_SpectatorSelectWeapon_C:UUserWidget ---@field Image_BG UImage ---@field TextBlock_CountDown UTextBlock ---@field TextBlock_MapName UTextBlock ---@field TextBlock_Mode UTextBlock ---@field VerticalBox_Selects UVerticalBox ---@field WB_SettingButton UWB_SettingButton_C --Edit Below-- ---@type WB_SpectatorSelectWeapon_C local WB_SpectatorSelectWeapon = { bInitDoOnce = false } function WB_SpectatorSelectWeapon:Construct() self:LuaInit(); end function WB_SpectatorSelectWeapon:LuaInit() if self.bInitDoOnce then return ; end self.bInitDoOnce = true; UGCLogSystem.Log("[WB_SpectatorSelectWeapon:LuaInit] 执行") UGCEventSystem.AddListener(EventTypes.UpdateSelectWeapons, self.OnUpdateSelectWeapons, self) UGCEventSystem.AddListener(EventTypes.GameCountDownTimeChange, self.OnCountDownChange, self) UGCEventSystem.AddListener(EventTypes.OnMapLoaded, self.OnMapLoaded, self) UGCEventSystem.AddListener(EventTypes.PlayerDisable, self.OnPlayerDisable, self) -- 更新用户数据(除了观战的) UGCEventSystem.AddListener(EventTypes.UpdateAccountInfo, self.OnUpdateAccountInfo, self) UGCEventSystem.AddListener(EventTypes.UpdateModeType, self.OnUpdateModeType, self) -- 清空列表 UITool.ForeachAllChildren(self.VerticalBox_Selects, function(index, Widget) Widget:LuaInit(); end); -- 读取数据 self:OnUpdateAccountInfo(); if GlobalModeType then self:OnUpdateModeType(GlobalModeType); end if table.isEmpty(ArchiveTable) then return ; end local Disables = {}; for PlayerKey, Archive in pairs(ArchiveTable) do Disables[PlayerKey] = Archive.Disables; end UGCLogSystem.LogTree(string.format("[WB_SpectatorSelectWeapon:LuaInit] Disables ="), Disables) self:OnPlayerDisable(Disables); end ---@type table WB_SpectatorSelectWeapon.PlayerItems = {}; function WB_SpectatorSelectWeapon:OnUpdateModeType(ModeType) local Name = GameModeConfig.GameModeInfo[ModeType].Name; self.TextBlock_Mode:SetText(Name); self.TextBlock_Mode:SetVisibility(ESlateVisibility.SelfHitTestInvisible); UGCLogSystem.Log("[WB_SpectatorSelectWeapon:OnUpdateModeType] ModeType = ".. Name); end function WB_SpectatorSelectWeapon:OnUpdateAccountInfo(InList) UGCLogSystem.Log("[WB_SpectatorSelectWeapon:OnUpdateAccountInfo] 执行") local SelectIndex = 0; for PlayerKey, Info in pairs(UE.GetAccountInfo()) do local Item = self.VerticalBox_Selects:GetChildAt(SelectIndex); Item:SetPlayerKey(PlayerKey); self.PlayerItems[PlayerKey] = Item; SelectIndex = SelectIndex + 1; end end ---@type table function WB_SpectatorSelectWeapon:OnUpdateSelectWeapons(InList) -- 首先清空两个 for PlayerKey, Widget in pairs(self.PlayerItems) do Widget:OnUpdateSelectWeapons(InList[PlayerKey]); end end function WB_SpectatorSelectWeapon:OnMapLoaded(MapName) for i, v in pairs(LevelTable.LevelInfo) do if v.MapName == MapName then self.TextBlock_MapName:SetText(v.ShowName); UE.AsyncLoadObject(v.MiniMapInfo.BG_Path, function(TargetObject) self.Image_BG:SetBrushFromTexture(TargetObject, true); end); end end end --- 倒计时 ---@param InTime int function WB_SpectatorSelectWeapon:OnCountDownChange(InTime) self.TextBlock_CountDown:SetText(tostring(InTime) .. 's'); -- 检查当前是什么状态 if MiniManager.State >= MiniGameState.ROUND_PREPARE then -- 关闭当前界面 WidgetManager:ClosePanel(self.UIType); end end function WB_SpectatorSelectWeapon:OnPlayerDisable(Disables) if table.isEmpty(Disables) then return ; end for PlayerKey, Table in pairs(Disables) do if self.PlayerItems[PlayerKey] then self.PlayerItems[PlayerKey]:OnPlayerDisable(Table); end end end -- function WB_SpectatorSelectWeapon:Tick(MyGeometry, InDeltaTime) -- end -- function WB_SpectatorSelectWeapon:Destruct() -- end return WB_SpectatorSelectWeapon