---@class WB_Main_C:UAEUserWidget ---@field ShowInfo UWidgetAnimation ---@field ShowScore UWidgetAnimation ---@field Border_LeftSideTeam UBorder ---@field Border_RightSideTeam UBorder ---@field Button_BodySize UButton ---@field Button_FaceNotice UButton ---@field Button_Score UButton ---@field Button_Test UButton ---@field Button_Test_Custom UButton ---@field Button_TestSide UButton ---@field CanvasPanel_2 UCanvasPanel ---@field CanvasPanel_LeftSidechampion UCanvasPanel ---@field CanvasPanel_Prepare UCanvasPanel ---@field CanvasPanel_RightSidechampion UCanvasPanel ---@field CanvasPanel_ScoreBoard UCanvasPanel ---@field CanvasPanel_Test UCanvasPanel ---@field HorizontalBox_5 UHorizontalBox ---@field HorizontalBox_6 UHorizontalBox ---@field Image_BodySizeAlert UImage ---@field Image_LeftSide_ScoreBG UImage ---@field Image_LeftSide_ScoreBG2 UImage ---@field Image_LeftSide_SlotBG UImage ---@field Image_LeftSideKillBar UImage ---@field Image_RightSide_ScoreBG UImage ---@field Image_RightSide_ScoreBG2 UImage ---@field Image_RightSide_SlotBG UImage ---@field Image_RightSideKillBar UImage ---@field LeftSide_ChampionTitle UTextBlock ---@field NewButton_TC_ScoreBoard UNewButton ---@field RightSide_ChampionTitle UTextBlock ---@field TextBlock_BodySize UTextBlock ---@field TextBlock_EnemyScore UTextBlock ---@field TextBlock_GameTime UTextBlock ---@field TextBlock_LeftSide_Champion_Level UTextBlock ---@field TextBlock_LeftSide_Current_Num UTextBlock ---@field TextBlock_LeftSide_Total_Num UTextBlock ---@field TextBlock_MaxHealth UTextBlock ---@field TextBlock_Prepare UTextBlock ---@field TextBlock_RightSide_Champion_Level UTextBlock ---@field TextBlock_RightSide_Current_Num UTextBlock ---@field TextBlock_RightSide_Total_Num UTextBlock ---@field TextBlock_SelfScore UTextBlock ---@field TextBlock_TargetNum UTextBlock ---@field TextBlock_Time UTextBlock ---@field WB_InTest_Side UWB_InTest_Side_C ---@field WB_PlayerInfo_Small UWB_PlayerInfo_Small_C ---@field WB_SelectParts UWB_SelectParts_C ---@field WidgetSwitcher_LeftSide_ScoreBG UWidgetSwitcher ---@field WidgetSwitcher_RightSide_ScoreBG UWidgetSwitcher --Edit Below-- ---@type WB_Main_C local WB_Main = { bInitDoOnce = false; }; WB_Main.IsTestSideShow = true; WB_Main.IsTestShow = true; function WB_Main:Construct() UGCLogSystem.Log("[WB_Main:Construct] 111") UGCEventSystem.AddListener(EventTypes.GameProgressCountDownTimeChange, self.OnCountDownChange, self) UGCEventSystem.AddListener(EventTypes.AllPlayerKDAChange, self.OnAllPlayerKDAChange, self) UGCEventSystem.AddListener(EventTypes.PlayerAttributeChanged, self.OnAttributeChanged, self) UGCEventSystem.AddListener(EventTypes.UpdatePlayerDatas, self.OnUpdatePlayerDatas, self) --UGCEventSystem.AddListener(EventTypes.GameProgressChange_Gaming, self.OnClientAlready, self) --UGCEventSystem.AddListener(EventTypes.GameProgressChange, self.OnGameProgressChange, self) UITool.ButtonOnClickShowPanel(self.Button_FaceNotice, WidgetConfig.EUIType.FaceNotice, true) if DefaultSettings.EnableTest then self.WB_InTest_Side:LuaInit(); UITool.ButtonOnClickShowPanel(self.Button_Test, WidgetConfig.EUIType.Test, true); UITool.BindButtonClicked(self.Button_TestSide, self.OnClickTestSide, self); UITool.BindButtonClicked(self.Button_Test_Custom, self.OnClickCustomTest, self); else self.CanvasPanel_Test:SetVisibility(ESlateVisibility.Collapsed); end UITool.BindButtonClicked(self.NewButton_TC_ScoreBoard, self.OnShowScore, self) self.TextBlock_GameTime:SetText("00:00") self.TextBlock_LeftSide_Current_Num:SetText("00") self.TextBlock_RightSide_Total_Num:SetText("00") self.WB_PlayerInfo_Small:SetInGaming(); self:OnPrepare(); self.PrepareTickTimer = UGCEventSystem.SetTimerLoop(self, self.OnPrepareTick, 0.6) --GlobalTickTool:AddTick(self, self.OnPrepareTick, 0.6) self:OnBodySizeChange(); self.WB_SelectParts:LuaInit(); self.WB_SelectParts:SetType({ EWeaponPartType.Telescope, EWeaponPartType.Grip, EWeaponPartType.Muzzle, }); -- 检查当前是什么 if GlobalMiniMode ~= nil and GlobalMiniMode.State >= MiniGameState.ROUND_GAMING then UGCLogSystem.Log("[WB_Main:Construct] 执行") self.CanvasPanel_Prepare:SetVisibility(ESlateVisibility.Collapsed); end GlobalTickTool:AddTick(self, function() self:CheckMaxHealth(); end, 0.2) end function WB_Main:Tick(MyGeometry, InDeltaTime) end function WB_Main:Destruct() UGCEventSystem.RemoveListener(EventTypes.GameProgressCountDownTimeChange, self.OnCountDownChange, self) end function WB_Main:OnClickTestSide() self.WB_InTest_Side:ShowTestWidget(not self.IsTestSideShow); self.IsTestSideShow = not self.IsTestSideShow; end function WB_Main:OnClientAlready() end function WB_Main:OnGameProgressChange(Type) if Type == DefaultSettings.EGameProgress.PREPARE then self.CanvasPanel_Prepare:SetVisibility(ESlateVisibility.HitTestInvisible); else self.CanvasPanel_Prepare:SetVisibility(ESlateVisibility.Collapsed); end end function WB_Main:OnClickCustomTest() if self.IsTestShow then self.WB_InTest_Side:SetVisibility(ESlateVisibility.Collapsed) self.Button_FaceNotice:SetVisibility(ESlateVisibility.Collapsed) self.Button_Test:SetVisibility(ESlateVisibility.Collapsed) self.Button_TestSide:SetVisibility(ESlateVisibility.Collapsed) else self.WB_InTest_Side:SetVisibility(ESlateVisibility.SelfHitTestInvisible) self.Button_FaceNotice:SetVisibility(ESlateVisibility.SelfHitTestInvisible) self.Button_Test:SetVisibility(ESlateVisibility.SelfHitTestInvisible) self.Button_TestSide:SetVisibility(ESlateVisibility.SelfHitTestInvisible) end self.IsTestShow = not self.IsTestShow; end function WB_Main:OnCountDownChange(InTime) --UGCLogSystem.Log("[WB_Main:OnCountDownChange] InTime = %s", tostring(InTime)); if InTime <= 0 then self.TextBlock_GameTime:SetText("00:00") else self.TextBlock_GameTime:SetText(string.format("%02d:%02d", InTime // 60, InTime % 60)); end end ---@param InList table function WB_Main:OnAllPlayerKDAChange(InList) UGCLogSystem.LogTree(string.format("[WB_Main:OnAllPlayerKDAChange] InList ="), InList) -- 计算总数 local Total = 0; local Max = 0; for i, v in pairs(InList) do -- 加载头像 if v.KDA and v.KDA.Kill then Total = Total + v.KDA.Kill; if v.KDA.Kill > Max then Max = v.KDA.Kill; end if LocalPlayerKey == v.PlayerKey then self.TextBlock_LeftSide_Current_Num:SetText(string.format("%02d", v.KDA.Kill)); break ; end end end self.TextBlock_RightSide_Total_Num:SetText(string.format("%02d", Max)); if table.isEmpty(InList) then self:SetMaxIcon(LocalPlayerKey); else self:SetMaxIcon(InList[1].PlayerKey); end end function WB_Main:SetMyselfIcon(InIconUrl) UITool.DownloadImage(InIconUrl, function(Texture) self.Image_LeftSide_SlotBG:SetBrushFromTextureDynamic(Texture); end) end function WB_Main:SetMaxIcon(InPlayerKey) local AccountInfo = GameState.PlayerDatas.AccountInfo[InPlayerKey] if AccountInfo == nil then local Path = '/Game/Arts/UI/Atlas/BattleUI/Tmode/Frames/Armament_img_kuang2_50x50_png.Armament_img_kuang2_50x50_png'; UE.AsyncLoadObject_Cached(Path, function(TargetObject) self.Image_RightSide_SlotBG:SetBrushFromTexture(TargetObject, true); end) return ; end UITool.DownloadImage(AccountInfo.IconURL, function(Texture) self.Image_RightSide_SlotBG:SetBrushFromTextureDynamic(Texture); end) end WB_Main.IsShowScore = false; function WB_Main:OnShowScore() self.IsShowScore = not self.IsShowScore; if self.IsShowScore then self:PlayAnimation(self.ShowScore, 0, 1, EUMGSequencePlayMode.Forward, 1) self:SetInfos(GameState.PlayerKDA_Damages); else self:PlayAnimation(self.ShowScore, 0, 1, EUMGSequencePlayMode.Reverse, 1); end end function WB_Main:SetInfos(InInfo) self.WB_PlayerInfo_Small:SetInfos(InInfo); end function WB_Main:OnPrepare() --self.CanvasPanel_Prepare:SetVisibility(ESlateVisibility.SelfHitTestInvisible); end WB_Main.DotCount = 0; function WB_Main:OnPrepareTick() --UGCLogSystem.Log("[WB_Main:OnPrepareTick] DotCount = %s", tostring(self.DotCount)); self.DotCount = (self.DotCount + 1) % 3; local Str = "游戏准备中." for i = 1, self.DotCount do Str = Str .. '.' end self.TextBlock_Prepare:SetText(Str); end WB_Main.IsShowDetail = false; function WB_Main:OnClickBodySize() --self:PlayAnimation(self.ShowScore, 0, 1, EUMGSequencePlayMode.Forward, 1) if self.IsShowDetail then self:PlayAnimation(self.ShowInfo, 0, 1, EUMGSequencePlayMode.Reverse, 1) else self:PlayAnimation(self.ShowInfo, 0, 1, EUMGSequencePlayMode.Forward, 1) end self.IsShowDetail = not self.IsShowDetail; end function WB_Main:OnGameStart() if self.PrepareTickTimer then UGCEventSystem.StopTimer(self.PrepareTickTimer); self.PrepareTickTimer = nil; end GlobalTickTool:RemoveAll(self); self.DotCount = nil; UGCLogSystem.Log("[WB_Main:OnGameStart] self.CanvasPanel_Prepare Visible = %s", tostring(self.CanvasPanel_Prepare:GetVisibility())); self.CanvasPanel_Prepare:SetVisibility(ESlateVisibility.Collapsed); end function WB_Main:OnAttributeChanged(InAttrs) if table.isEmpty(InAttrs) then return ; end if LocalPlayerKey == nil then return end if table.isEmpty(InAttrs[LocalPlayerKey]) then return ; end self:OnBodySizeChange(InAttrs[LocalPlayerKey][DefaultSettings.EPawnBenefitType.BodySize]) end WB_Main.Colors = { [1] = { 1., 1., 1. }, -- 白色 [2] = { 0, 0.397292, 0.453 }, -- 青色 [3] = { 0.061195, 1, 0 }, -- 绿色 [4] = { 1, 1, 0 }, -- 黄色 [5] = { 1, 0, 0 }, -- 红色 } function WB_Main:OnBodySizeChange(InSize) if InSize == nil then InSize = 1; end if InSize < 0.5 then InSize = 0.5; end self.Image_BodySizeAlert:SetVisibility(ESlateVisibility.Visible); if InSize > DefaultSettings.MaxBodySize then self.TextBlock_BodySize:SetText(string.format("体型:%0.1f(+%0.1f)", DefaultSettings.MaxBodySize, InSize - DefaultSettings.MaxBodySize)); else self.TextBlock_BodySize:SetText(string.format("体型:%0.1f", InSize)); end if InSize >= 3 then self.TextBlock_BodySize:SetColorAndOpacity({ SpecifiedColor = VectorHelper.ArrToColor(self.Colors[5]), ColorUseRule = 0 }) elseif InSize >= 2 then self.TextBlock_BodySize:SetColorAndOpacity({ SpecifiedColor = VectorHelper.ArrToColor(self.Colors[4]), ColorUseRule = 0 }) elseif InSize > 1 then self.TextBlock_BodySize:SetColorAndOpacity({ SpecifiedColor = VectorHelper.ArrToColor(self.Colors[2]), ColorUseRule = 0 }) elseif InSize == 1 then self.TextBlock_BodySize:SetColorAndOpacity({ SpecifiedColor = VectorHelper.ArrToColor(self.Colors[1]), ColorUseRule = 0 }) else self.TextBlock_BodySize:SetColorAndOpacity({ SpecifiedColor = VectorHelper.ArrToColor(self.Colors[3]), ColorUseRule = 0 }) end UGCEventSystem.SetTimer(self, function() self.Image_BodySizeAlert:SetVisibility(ESlateVisibility.Collapsed); end, 2.5); end function WB_Main:CheckMaxHealth() local Pawn = UGCGameSystem.GetPlayerPawnByPlayerKey(LocalPlayerKey); if UE.IsValid(Pawn) and Pawn:IsAlive() then local MaxHealth = UGCPawnAttrSystem.GetHealthMax(Pawn); UGCLogSystem.Log("[WB_Main:OnBodySizeChange] MaxHealth = %s", tostring(MaxHealth)); self.TextBlock_MaxHealth:SetText(tostring(MaxHealth)); else self.TextBlock_MaxHealth:SetText("0") end end function WB_Main:SetKillTarget(InVal) self.TextBlock_TargetNum:SetText(InVal); end function WB_Main:OnUpdatePlayerDatas(InDatas) local Val = InDatas.AccountInfo[LocalPlayerKey] if Val and Val.IconURL then self:SetMyselfIcon(Val.IconURL); end for i, v in pairs(InDatas.AccountInfo) do -- 先缓存一波 UITool.DownloadImage(v.IconURL); end end return WB_Main;