98 lines
3.4 KiB
Lua
Raw Normal View History

2025-01-04 23:00:19 +08:00
---@class WB_MiniGameSettlement_C:UUserWidget
---@field ShowSettlement UWidgetAnimation
---@field Button_ReturnToLobby UButton
---@field Button_Share UButton
---@field HorizontalBox_Items UHorizontalBox
---@field TextBlock_AutoReturnToLobby UTextBlock
---@field TextBlock_Levels2_2 UTextBlock
--Edit Below--
local WB_MiniGameSettlement = {
bInitDoOnce = false;
SettlementTime = 30;
};
function WB_MiniGameSettlement:Construct()
WidgetLibrary.BindButtonClicked(self.Button_ReturnToLobby, self.Button_AutoReturnToLobby_OnClicked, self)
WidgetLibrary.BindButtonClicked(self.Button_Share, self.ShareSettlement, self)
end
-- function WB_MiniGameSettlement:Tick(MyGeometry, InDeltaTime)
-- end
-- function WB_MiniGameSettlement:Destruct()
-- end
--- AllPlayerScore {{RankNum = uint, PlayerKey = uint, Score = uint}, ...}
function WB_MiniGameSettlement:OnShowPanel()
UGCGameSystem.ShowUGCRankAndAchievementUI()
for i, v in pairs(WidgetConfig.Configs) do
if i ~= WidgetConfig.EUIType.Settlement then
WidgetManager:ClosePanel(i)
end
end
local ShootingPanel = UGCWidgetManagerSystem.GetShootingUIPanel()
if ShootingPanel then
ShootingPanel:SetVisibility(ESlateVisibility.Collapsed)
end
local MainControlPanel = GameBusinessManager.GetWidgetFromName(ingame, "MainControlPanelTochButton_C")
if MainControlPanel then
MainControlPanel:SetVisibility(ESlateVisibility.Collapsed)
end
local AllPlayerScore = UGCGameSystem.GameState:GetMiniGameScoreRank()
if AllPlayerScore then
for i = 1, self.HorizontalBox_Items:GetChildrenCount() do
local Item = self.HorizontalBox_Items:GetChildAt(i - 1)
local PlayerScoreInfo = AllPlayerScore[i]
if PlayerScoreInfo then
Item:UpdatePlayerRankInfo(PlayerScoreInfo.RankNum, PlayerScoreInfo)
else
Item:UpdatePlayerRankInfo(i)
end
end
else
UGCLogSystem.LogError("[WB_MiniGameFinish_OnShowPanel] AllPlayerScore is nil")
end
self:PlayAnimation(self.ShowSettlement, 0, 1, EUMGSequencePlayMode.Forward, 1);
self:AutoReturnToLobby()
end
function WB_MiniGameSettlement:AutoReturnToLobby()
self.DelayReturnToLobbyTime = GlobalConfigs.GameSetting.DelayReturnToLobbyTime
self.SettlementTime = UGCSystemLibrary.GetGameTime()
self.DelayReturnToLobbyTimerHandle = UGCEventSystem.SetTimerLoop(
self,
function ()
local NowTime = UGCSystemLibrary.GetGameTime()
local ShowTime = math.floor(self.DelayReturnToLobbyTime - (NowTime - self.SettlementTime))
ShowTime = ShowTime >= 0 and ShowTime or 0
self.TextBlock_AutoReturnToLobby:SetText(string.format("返回大厅(%ds)", ShowTime))
if ShowTime <= 0 then self:Button_AutoReturnToLobby_OnClicked() end
end,
0.5
)
end
function WB_MiniGameSettlement:Button_AutoReturnToLobby_OnClicked()
if UGCGameSystem.GameState.GameStateType ~= CustomEnum.EGameState.End then return end
if self == nil or self.DoOnceReturnToLobby then return end
if self.DelayReturnToLobbyTimerHandle then
UGCEventSystem.StopTimer(self.DelayReturnToLobbyTimerHandle)
self.DelayReturnToLobbyTimerHandle = nil
end
self.DoOnceReturnToLobby = true
UGCGameSystem.ReturnToLobby()
end
--- 分享战绩
function WB_MiniGameSettlement:ShareSettlement()
UGCWidgetManagerSystem.Share();
end
return WB_MiniGameSettlement;