UGCProjects/OneShotKill/Script/UI/SecondaryConfirmation/WB_SecondaryConfirmation.lua
2025-01-04 23:00:19 +08:00

89 lines
2.7 KiB
Lua

---@class WB_SecondaryConfirmation_C:UUserWidget
---@field ShowAnim UWidgetAnimation
---@field Button_Cancellation UButton
---@field Button_Confirm UButton
---@field TextBlock_Cancellation UTextBlock
---@field TextBlock_Confirm UTextBlock
---@field TextBlock_ShowInfo UTextBlock
--Edit Below--
local WB_SecondaryConfirmation = {
bInitDoOnce = false;
bIsShowing = false;
};
function WB_SecondaryConfirmation:Construct()
WidgetLibrary.BindButtonClicked(self.Button_Cancellation, self.ClickCancellation, self)
WidgetLibrary.BindButtonClicked(self.Button_Confirm, self.ClickConfirm, self)
end
function WB_SecondaryConfirmation:OnShowPanel()
self.bIsShowing = true
self:PlayAnimation(self.ShowAnim, 0, 1, EUMGSequencePlayMode.Forward, 1);
end
function WB_SecondaryConfirmation:SetTextInfo(TextInfo, CancellationText, ConfirmText)
self.TextBlock_ShowInfo:SetText(TextInfo)
if CancellationText then
self.TextBlock_Cancellation:SetText(CancellationText)
end
if ConfirmText then
self.TextBlock_Confirm:SetText(ConfirmText)
end
end
function WB_SecondaryConfirmation:BindCancellationCallBack(InCancellationCallBackFunc, InCancellationCallBackObj)
self.CancellationCallBackFunc = InCancellationCallBackFunc
self.CancellationCallBackObj = InCancellationCallBackObj
end
function WB_SecondaryConfirmation:BindConfirmCallBack(InConfirmCallBackFunc, InConfirmCallBackObj)
self.ConfirmCallBackFunc = InConfirmCallBackFunc
self.ConfirmCallBackObj = InConfirmCallBackObj
end
function WB_SecondaryConfirmation:Reset()
self.bIsShowing = false
self:BindCancellationCallBack()
self:BindConfirmCallBack()
self.TextBlock_Cancellation:SetText("取消")
self.TextBlock_Confirm:SetText("确认")
WidgetManager:ClosePanel(WidgetConfig.EUIType.SecondaryConfirmation)
end
function WB_SecondaryConfirmation:ClickCancellation()
if not self.bIsShowing then return end
SoundSystem.PlaySound(SoundSystem.ESound.Click)
if self.CancellationCallBackFunc then
if self.CancellationCallBackObj then
self.CancellationCallBackFunc(self.CancellationCallBackObj)
else
self.CancellationCallBackFunc()
end
end
self:Reset()
end
function WB_SecondaryConfirmation:ClickConfirm()
if not self.bIsShowing then return end
SoundSystem.PlaySound(SoundSystem.ESound.Click)
if self.ConfirmCallBackFunc then
if self.ConfirmCallBackObj then
self.ConfirmCallBackFunc(self.ConfirmCallBackObj)
else
self.ConfirmCallBackFunc()
end
end
self:Reset()
end
-- function WB_SecondaryConfirmation:Tick(MyGeometry, InDeltaTime)
-- end
-- function WB_SecondaryConfirmation:Destruct()
-- end
return WB_SecondaryConfirmation;