120 lines
4.2 KiB
Lua
120 lines
4.2 KiB
Lua
---@class WB_MiniGameLoading_C:UUserWidget
|
|
---@field Button_Ready UButton
|
|
---@field HorizontalBox_PlayerReadys UHorizontalBox
|
|
---@field Image_MiniGame UImage
|
|
---@field TextBlock_Desc UTextBlock
|
|
---@field TextBlock_LoadingTime UTextBlock
|
|
---@field TextBlock_MiniGameName UTextBlock
|
|
---@field WidgetSwitcher_IsReady UWidgetSwitcher
|
|
---@field WidgetSwitcher_MiniGame UWidgetSwitcher
|
|
--Edit Below--
|
|
local WB_MiniGameLoading = {
|
|
bInitDoOnce = false;
|
|
CanClickIsReady = true;
|
|
};
|
|
|
|
|
|
function WB_MiniGameLoading:Construct()
|
|
self:LuaInit();
|
|
WidgetLibrary.TextBlockBindingPropertyText(self.TextBlock_LoadingTime, self.UpdateLoadingTime, self)
|
|
WidgetLibrary.BindButtonClicked(self.Button_Ready, self.ClickIsReady, self)
|
|
|
|
UGCEventSystem.AddListener(EventEnum.UpdatePlayerIsReady, self.SetPlayerReady, self)
|
|
UGCEventSystem.AddListener(ArchiveDataConfig.GetParamNotifyEvent(ArchiveDataConfig.EArchiveType.MapStar), self.UpdateStarCount, self)
|
|
end
|
|
|
|
function WB_MiniGameLoading:OnShowPanel(MiniGameType, OnlinePlayerKeys)
|
|
self.MiniGameType = MiniGameType
|
|
self.IsReady = false
|
|
self.WidgetSwitcher_IsReady:SetActiveWidgetIndex(0)
|
|
local MiniGameInfo = MiniGameConfig.MiniGameInfo[MiniGameType]
|
|
if MiniGameInfo then
|
|
self.TextBlock_Desc:SetText(MiniGameInfo.DescText)
|
|
self.TextBlock_MiniGameName:SetText(MiniGameInfo.MiniGameName)
|
|
--local DescTex = UGCSystemLibrary.LoadAsset(MiniGameInfo.DescImage, false)
|
|
--if DescTex then
|
|
-- self.Image_MiniGame:SetBrushFromTexture(DescTex)
|
|
--end
|
|
end
|
|
self.WidgetSwitcher_MiniGame:SetActiveWidgetIndex(MiniGameType)
|
|
|
|
if OnlinePlayerKeys then
|
|
local NullPlayerKeyItem = {}
|
|
for i = 1, self.HorizontalBox_PlayerReadys:GetChildrenCount() do
|
|
local Item = self.HorizontalBox_PlayerReadys:GetChildAt(i - 1)
|
|
Item:ResetIsReady()
|
|
local PlayerKey = Item:GetPlayerKey()
|
|
if PlayerKey == nil or not table.hasValue(OnlinePlayerKeys, PlayerKey) then
|
|
NullPlayerKeyItem[#NullPlayerKeyItem + 1] = Item
|
|
Item:InitPlayerReady(nil)
|
|
else
|
|
table.removeValue(OnlinePlayerKeys, PlayerKey)
|
|
end
|
|
end
|
|
for i, v in pairs(OnlinePlayerKeys) do
|
|
if NullPlayerKeyItem[i] then
|
|
NullPlayerKeyItem[i]:InitPlayerReady(v)
|
|
end
|
|
end
|
|
end
|
|
self:UpdateStarCount()
|
|
end
|
|
|
|
function WB_MiniGameLoading:UpdateLoadingTime()
|
|
return tostring(UGCGameSystem.GameState:GetGameTime())
|
|
end
|
|
|
|
function WB_MiniGameLoading:ClickIsReady()
|
|
if self.IsReady == false and self.CanClickIsReady then
|
|
self.CanClickIsReady = false
|
|
UGCSendRPCSystem.ActorRPCNotify(nil, UGCGameSystem.GameState, "PlayerMiniGameReady", UGCSystemLibrary.GetLocalPlayerKey())
|
|
UGCEventSystem.SetTimer(self, function() self.CanClickIsReady = true end, 0.5)
|
|
end
|
|
end
|
|
|
|
function WB_MiniGameLoading:SetPlayerReady(InPlayerIsReady)
|
|
if not self.IsReady and table.hasValue(InPlayerIsReady, UGCSystemLibrary.GetLocalPlayerKey()) then
|
|
self.IsReady = true
|
|
self.WidgetSwitcher_IsReady:SetActiveWidgetIndex(1)
|
|
end
|
|
end
|
|
|
|
-- function WB_MiniGameLoading:Tick(MyGeometry, InDeltaTime)
|
|
|
|
-- end
|
|
|
|
-- function WB_MiniGameLoading:Destruct()
|
|
|
|
-- end
|
|
|
|
function WB_MiniGameLoading:UpdateStarCount()
|
|
if self.MiniGameType then
|
|
for i = 1, self.HorizontalBox_PlayerReadys:GetChildrenCount() do
|
|
local Item = self.HorizontalBox_PlayerReadys:GetChildAt(i - 1)
|
|
local PlayerKey = Item:GetPlayerKey()
|
|
Item:UpdateStarCount(UGCGameSystem.GameState:GetPlayerStarFromMapType(PlayerKey, self.MiniGameType))
|
|
end
|
|
end
|
|
end
|
|
|
|
-- [Editor Generated Lua] function define Begin:
|
|
function WB_MiniGameLoading:LuaInit()
|
|
if self.bInitDoOnce then
|
|
return;
|
|
end
|
|
self.bInitDoOnce = true;
|
|
-- [Editor Generated Lua] BindingProperty Begin:
|
|
-- self.CanvasPanel_36:BindingProperty("bIsEnabled", self.CanvasPanel_36_bIsEnabled, self);
|
|
-- [Editor Generated Lua] BindingProperty End;
|
|
|
|
-- [Editor Generated Lua] BindingEvent Begin:
|
|
-- [Editor Generated Lua] BindingEvent End;
|
|
end
|
|
|
|
--function WB_MiniGameLoading:CanvasPanel_36_bIsEnabled(ReturnValue)
|
|
-- return true;
|
|
--end
|
|
|
|
-- [Editor Generated Lua] function define End;
|
|
|
|
return WB_MiniGameLoading; |