2025-01-04 23:00:19 +08:00

70 lines
2.2 KiB
Lua

---@class WB_FaceNotice_C:UUserWidget
---@field Button_close UButton
---@field Button_left UButton
---@field Button_right UButton
---@field CanvasPanel_IPX UCanvasPanel
---@field CheckBox_select UCheckBox
---@field HorizontalBox_Paging UHorizontalBox
---@field WidgetSwitcher_page UWidgetSwitcher
--Edit Below--
---@type WB_FaceNotice_C
local WB_FaceNotice = {
bInitDoOnce = true;
SelectColor = {R = 1., G = 0.51, B = 0.14, A = 1.};
NotSelectColor = {R = 1., G = 1., B = 1., A = 1.};
};
function WB_FaceNotice:Construct()
self.Button_close.OnClicked:Add(self.CloseGuide, self)
self.Button_left.OnClicked:Add(self.LastGuide, self)
self.Button_right.OnClicked:Add(self.NextGuide, self)
UGCEventSystem.SetTimer(self, function()
self:CloseGuide();
end, DefaultSettings.ShowFaceNoticeTime);
end
function WB_FaceNotice:CloseGuide()
UGCLogSystem.Log("[WB_FaceNotice:CloseGuide] 执行")
WidgetManager:ClosePanel(WidgetConfig.EUIType.FaceNotice)
self:SetVisibility(ESlateVisibility.Collapsed);
end
function WB_FaceNotice:LastGuide()
self:UpdateIndex(self:GetNowIndex() - 1)
end
function WB_FaceNotice:NextGuide()
self:UpdateIndex(self:GetNowIndex() + 1)
end
function WB_FaceNotice:GetNowIndex()
return self.WidgetSwitcher_page:GetActiveWidgetIndex()
end
function WB_FaceNotice:UpdateIndex(NewIndex)
if NewIndex >= self.WidgetSwitcher_page:GetChildrenCount() then
NewIndex = 0
elseif NewIndex < 0 then
NewIndex = self.WidgetSwitcher_page:GetChildrenCount() - 1
end
self.WidgetSwitcher_page:SetActiveWidgetIndex(NewIndex)
for i = 1, self.WidgetSwitcher_page:GetChildrenCount(), 1 do
local TempImage = self.HorizontalBox_Paging:GetChildAt(i - 1)
if TempImage ~= nil then
if (i - 1) == NewIndex then
TempImage:SetColorAndOpacity(self.SelectColor)
else
TempImage:SetColorAndOpacity(self.NotSelectColor)
end
end
end
end
-- function WB_FaceNotice:Tick(MyGeometry, InDeltaTime)
-- end
-- function WB_FaceNotice:Destruct()
-- end
function WB_FaceNotice:OnClosePanel(...)
--- 显示一下选择武器
if self.bInitDoOnce then
self.bInitDoOnce = false;
end
end
return WB_FaceNotice;