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

62 lines
2.1 KiB
Lua

---@class WB_Guide_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 WB_BuffDesc UWB_BuffDesc_C
---@field WidgetSwitcher_page UWidgetSwitcher
--Edit Below--
---@type WB_Guide_C
local WB_Guide = {
bInitDoOnce = false;
SelectColor = {R = 1., G = 0.51, B = 0.14, A = 1.};
NotSelectColor = {R = 1., G = 1., B = 1., A = 1.};
MechanismInfoWidgetPath = UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/Guide/WB_MechanismInfo.WB_MechanismInfo_C');
};
function WB_Guide:Construct()
WidgetLibrary.BindButtonClicked(self.Button_close, self.CloseGuide, self)
WidgetLibrary.BindButtonClicked(self.Button_left, self.LastGuide, self)
WidgetLibrary.BindButtonClicked(self.Button_right, self.NextGuide, self)
end
function WB_Guide:GetNowIndex()
return self.WidgetSwitcher_page:GetActiveWidgetIndex()
end
function WB_Guide: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_Guide:NextGuide()
self:UpdateIndex(self:GetNowIndex() + 1)
SoundSystem.PlaySound(SoundSystem.ESound.Btn)
end
function WB_Guide:LastGuide()
self:UpdateIndex(self:GetNowIndex() - 1)
SoundSystem.PlaySound(SoundSystem.ESound.Btn)
end
function WB_Guide:CloseGuide()
WidgetManager:ClosePanel(WidgetConfig.EUIType.Guide)
end
-- function WB_Guide:Tick(MyGeometry, InDeltaTime)
-- end
-- function WB_Guide:Destruct()
-- end
return WB_Guide;