62 lines
1.7 KiB
Lua
62 lines
1.7 KiB
Lua
---@class WB_CountDownButton_C:UUserWidget
|
|
---@field Button_Main UButton
|
|
---@field Image_CountDown UImage
|
|
---@field Image_Icon UImage
|
|
---@field Overlay_CountDown UOverlay
|
|
---@field TextBlock_CountDown UTextBlock
|
|
--Edit Below--
|
|
---@type WB_CountDownButton_C
|
|
local WB_CountDownButton = { bInitDoOnce = false; };
|
|
|
|
WB_CountDownButton.Func = nil;
|
|
WB_CountDownButton.CountDownTimer = nil;
|
|
WB_CountDownButton.CountDownTime = 0;
|
|
WB_CountDownButton.ConstCountDownTime = 0;
|
|
WB_CountDownButton.CountDownIntervalTime = 0.3;
|
|
|
|
function WB_CountDownButton:Construct()
|
|
UITool.BindButtonClicked(self.Button_Main, self.OnClickMain, self)
|
|
end
|
|
|
|
function WB_CountDownButton:OnClickMain()
|
|
if self.Func ~= nil then
|
|
self.Func()
|
|
self.Button_Main:SetIsEnabled(false);
|
|
self.Overlay_CountDown:SetVisibility(ESlateVisibility.SelfHitTestInvisible);
|
|
end
|
|
end
|
|
|
|
-- function WB_CountDownButton:Tick(MyGeometry, InDeltaTime)
|
|
|
|
-- end
|
|
|
|
-- function WB_CountDownButton:Destruct()
|
|
|
|
-- end
|
|
|
|
---@param InFunc fun()
|
|
function WB_CountDownButton:SetFunc(InFunc)
|
|
self.Func = InFunc;
|
|
end
|
|
|
|
---@param InTime float
|
|
function WB_CountDownButton:SetTime(InTime)
|
|
if InTime == nil then return end
|
|
self.ConstCountDownTime = InTime;
|
|
self.CountDownTime = InTime;
|
|
if self.CountDownTimer ~= nil then
|
|
UGCEventSystem.StopTimer(self.CountDownTimer);
|
|
self.CountDownTimer = nil;
|
|
end
|
|
self.CountDownTimer = UGCEventSystem.SetTimer(self, function()
|
|
self.CountDownTime = self.CountDownTime - self.CountDownIntervalTime;
|
|
local Time = math.floor(self.CountDownTime);
|
|
if Time <= 0 then
|
|
UGCEventSystem.StopTimer(self.CountDownTimer);
|
|
self.CountDownTimer = nil;
|
|
self.Button_Main:SetIsEnabled(true);
|
|
end
|
|
end, self.CountDownIntervalTime)
|
|
end
|
|
|
|
return WB_CountDownButton; |