222 lines
7.5 KiB
Lua
222 lines
7.5 KiB
Lua
|
---@class WB_Main_C:UAEUserWidget
|
||
|
---@field ShowScore UWidgetAnimation
|
||
|
---@field Button_FaceNotice UButton
|
||
|
---@field Button_Test UButton
|
||
|
---@field Button_Test_Custom UButton
|
||
|
---@field Button_TestSide UButton
|
||
|
---@field CanvasPanel_Test UCanvasPanel
|
||
|
---@field Overlay_EnemyHP UOverlay
|
||
|
---@field TextBlock_1 UTextBlock
|
||
|
---@field TextBlock_EnemyHP UTextBlock
|
||
|
---@field TextBlock_State UTextBlock
|
||
|
---@field TextBlock_WinnerPlayerName UTextBlock
|
||
|
---@field WB_DamageTextButton UWB_DamageTextButton_C
|
||
|
---@field WB_InTest_Side UWB_InTest_Side_C
|
||
|
---@field WB_PID UWB_PID_C
|
||
|
---@field WB_PlayerInfo_Small UWB_PlayerInfo_Small_C
|
||
|
---@field WB_ReselectWeaponBtn UWB_ReselectWeaponBtn_C
|
||
|
---@field WB_RoundEnd UWB_RoundEnd_C
|
||
|
---@field WB_SelectParts UWB_SelectParts_C
|
||
|
---@field WB_SettingButton UWB_SettingButton_C
|
||
|
---@field WB_Title1_2 UWB_Title1_2_C
|
||
|
---@field WB_Title2_2 UWB_Title2_2_C
|
||
|
---@field WidgetSwitcher_Title UWidgetSwitcher
|
||
|
--Edit Below--
|
||
|
---@type WB_Main_C
|
||
|
local WB_Main = { bInitDoOnce = false; };
|
||
|
|
||
|
WB_Main.IsTestShow = true;
|
||
|
|
||
|
function WB_Main:Construct()
|
||
|
self:LuaInit();
|
||
|
UGCLogSystem.Log("[WB_Main:Construct] MainUI = %s", UE.GetName(self));
|
||
|
end
|
||
|
|
||
|
function WB_Main:LuaInit()
|
||
|
if self.bInitDoOnce then return ; end
|
||
|
self.bInitDoOnce = true;
|
||
|
-- 发送 RPC
|
||
|
UGCEventSystem.AddListener(EventTypes.MiniStateChange, self.OnMiniStateChange, self)
|
||
|
UGCEventSystem.AddListener(EventTypes.ChangeSpector, self.OnChangeSpector, self)
|
||
|
UGCEventSystem.AddListener(EventTypes.ShowRoundWin, self.ShowRoundWin, self)
|
||
|
|
||
|
--- 死亡的时候显示 ID Panel
|
||
|
UGCEventSystem.AddListener(EventTypes.PlayerRespawn, function(MainUI, PlayerKey)
|
||
|
if PlayerKey == LocalPlayerKey then
|
||
|
UGCLogSystem.Log("[WB_Main:LuaInit] 隐藏 IDPanel")
|
||
|
self.WB_PID:SetVisibility(ESlateVisibility.Collapsed);
|
||
|
self.WB_SettingButton:SetVisibility(ESlateVisibility.Collapsed);
|
||
|
end
|
||
|
self.Overlay_EnemyHP:SetVisibility(ESlateVisibility.Collapsed);
|
||
|
end, self);
|
||
|
|
||
|
UGCEventSystem.AddListener(EventTypes.PlayerDead, function(MainUI, DeadPlayerKey, KillerPlayerKey)
|
||
|
if DeadPlayerKey == LocalPlayerKey then
|
||
|
UGCLogSystem.Log("[WB_Main:LuaInit] 显示 IDPanel")
|
||
|
self.WB_PID:SetVisibility(ESlateVisibility.HitTestInvisible);
|
||
|
self.WB_SettingButton:SetVisibility(ESlateVisibility.SelfHitTestInvisible);
|
||
|
|
||
|
local Pawns = UGCGameSystem.GetAllPlayerPawn()
|
||
|
for i, v in pairs(Pawns) do
|
||
|
if v and UE.IsValidPawn(v) and v.PlayerKey ~= DeadPlayerKey then
|
||
|
local Health = UGCPawnAttrSystem.GetHealth(v);
|
||
|
if Health then
|
||
|
if Health > 1 then
|
||
|
self.TextBlock_EnemyHP:SetText(string.format('%0.f', Health));
|
||
|
else
|
||
|
self.TextBlock_EnemyHP:SetText('1');
|
||
|
end
|
||
|
self.Overlay_EnemyHP:SetVisibility(ESlateVisibility.HitTestInvisible);
|
||
|
end
|
||
|
break
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end, self);
|
||
|
|
||
|
--UITool.ButtonOnClickShowPanel(self.Button_FaceNotice, WidgetConfig.EUIType.FaceNotice, true)
|
||
|
|
||
|
self.WB_SettingButton:LuaInit();
|
||
|
self.WB_PID:LuaInit();
|
||
|
self.WB_Title1_2:LuaInit();
|
||
|
self.WB_Title2_2:LuaInit();
|
||
|
self.WB_SelectParts:LuaInit();
|
||
|
self.WB_ReselectWeaponBtn:LuaInit();
|
||
|
self.WB_SelectParts:SetType({ EWeaponPartType.Telescope, EWeaponPartType.Grip, EWeaponPartType.Muzzle, });
|
||
|
|
||
|
self:ShowCustomSelectWeaponBtn(false);
|
||
|
|
||
|
--- 获取
|
||
|
self.TextBlock_WinnerPlayerName:SetVisibility(ESlateVisibility.Collapsed);
|
||
|
self.WB_PID:SetVisibility(ESlateVisibility.Collapsed);
|
||
|
if self.WB_ShovelButton then self.WB_ShovelButton:LuaInit(); end
|
||
|
if self.WB_DamageTextButton then self.WB_DamageTextButton:LuaInit(); end
|
||
|
-- 观战玩家
|
||
|
if LocalIsGlobalSpectator then
|
||
|
self.WB_DamageTextButton:SetVisibility(ESlateVisibility.Collapsed);
|
||
|
self.WB_SelectParts:SetVisibility(ESlateVisibility.Collapsed);
|
||
|
self.WidgetSwitcher_Title:SetActiveWidgetIndex(1);
|
||
|
else
|
||
|
self.WidgetSwitcher_Title:SetActiveWidgetIndex(0);
|
||
|
end
|
||
|
|
||
|
if DefaultSettings.EnableTest then
|
||
|
if not LocalIsGlobalSpectator then
|
||
|
self.CanvasPanel_Test:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
||
|
self.WB_InTest_Side:LuaInit();
|
||
|
--UITool.ButtonOnClickShowPanel(self.Button_Test, WidgetConfig.EUIType.Test, true);
|
||
|
UITool.BindButtonClicked(self.Button_Test_Custom, self.OnClickCustomTest, self);
|
||
|
end
|
||
|
else
|
||
|
self.CanvasPanel_Test:SetVisibility(ESlateVisibility.Collapsed);
|
||
|
end
|
||
|
|
||
|
GameState:UIAlready();
|
||
|
end
|
||
|
|
||
|
function WB_Main:OnShowPanel(...)
|
||
|
self.WB_PID:SetIDs()
|
||
|
end
|
||
|
|
||
|
function WB_Main:Tick(MyGeometry, InDeltaTime)
|
||
|
if self.WB_ReselectWeaponBtn then
|
||
|
self.WB_ReselectWeaponBtn:OnTick();
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WB_Main:Destruct()
|
||
|
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
|
||
|
|
||
|
WB_Main.IsShowScore = false;
|
||
|
|
||
|
function WB_Main:OnShowScore()
|
||
|
-- 如果显示的话
|
||
|
if self.WB_PlayerInfo_Small:IsVisible() then
|
||
|
self:PlayAnimation(self.ShowScore, 0, 1, EUMGSequencePlayMode.Reverse, 1);
|
||
|
else
|
||
|
self:PlayAnimation(self.ShowScore, 0, 1, EUMGSequencePlayMode.Forward, 1);
|
||
|
-- 过一段时间自动关闭
|
||
|
UGCEventSystem.SetTimer(self, function()
|
||
|
if self.WB_PlayerInfo_Small:IsVisible() then
|
||
|
self:OnShowScore();
|
||
|
end
|
||
|
end, 5);
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WB_Main:OnGameStart()
|
||
|
UGCLogSystem.Log("[WB_Main:OnGameStart] 执行")
|
||
|
end
|
||
|
|
||
|
WB_Main.ShowRoundWinTimer = nil;
|
||
|
|
||
|
function WB_Main:ShowRoundWin(IsShow, Winner)
|
||
|
UGCLogSystem.Log("[WB_Main:ShowRoundWin] IsShow = %s, Winner = %s", tostring(IsShow), tostring(Winner));
|
||
|
if IsShow then
|
||
|
self.WB_RoundEnd:SetVisibility(ESlateVisibility.HitTestInvisible);
|
||
|
if LocalIsGlobalSpectator then
|
||
|
self.TextBlock_WinnerPlayerName:SetText(UE.GetPlayerName(Winner));
|
||
|
self.TextBlock_WinnerPlayerName:SetVisibility(ESlateVisibility.SelfHitTestInvisible);
|
||
|
self.WB_RoundEnd:SetWin(true);
|
||
|
else
|
||
|
self.WB_RoundEnd:SetWin(Winner == LocalPlayerKey);
|
||
|
end
|
||
|
-- 定时关闭
|
||
|
UGCEventSystem.SetTimer(self, function()
|
||
|
self.WB_RoundEnd:SetVisibility(ESlateVisibility.Collapsed);
|
||
|
self.TextBlock_WinnerPlayerName:SetVisibility(ESlateVisibility.Collapsed);
|
||
|
end, 10);
|
||
|
else
|
||
|
self.WB_RoundEnd:SetVisibility(ESlateVisibility.Collapsed);
|
||
|
self.TextBlock_WinnerPlayerName:SetVisibility(ESlateVisibility.Collapsed);
|
||
|
if self.ShowRoundWinTimer ~= nil then
|
||
|
UGCEventSystem.StopTimer(self.ShowRoundWinTimer);
|
||
|
self.ShowRoundWinTimer = nil;
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WB_Main:OnMiniStateChange(InState)
|
||
|
self.TextBlock_State:SetText(TableHelper.printEnum(MiniGameState, InState));
|
||
|
end
|
||
|
|
||
|
function WB_Main:SetRoundKill(InList)
|
||
|
self.WB_Title1_2:SetRoundKill(InList)
|
||
|
self.WB_Title2_2:SetRoundKill(InList)
|
||
|
end
|
||
|
|
||
|
function WB_Main:OnChangeSpector(IsGlobal)
|
||
|
UGCLogSystem.Log("[WB_Main:OnChangeSpector] IsGlobal = %s", tostring(IsGlobal));
|
||
|
--if IsGlobal then
|
||
|
-- -- 切换到全局
|
||
|
-- self.WidgetSwitcher_Title:SetActiveWidgetIndex(1);
|
||
|
--else
|
||
|
-- self.WidgetSwitcher_Title:SetActiveWidgetIndex(0);
|
||
|
--end
|
||
|
end
|
||
|
|
||
|
function WB_Main:ShowCustomSelectWeaponBtn(IsShow)
|
||
|
if IsShow then
|
||
|
self.WB_ReselectWeaponBtn:OnShowPanel()
|
||
|
self.WB_ReselectWeaponBtn:SetVisibility(ESlateVisibility.SelfHitTestInvisible);
|
||
|
else
|
||
|
self.WB_ReselectWeaponBtn:SetVisibility(ESlateVisibility.Collapsed);
|
||
|
end
|
||
|
end
|
||
|
|
||
|
return WB_Main;
|