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

85 lines
2.9 KiB
Lua

---@class WB_SceneItemGuide_2_C:UUserWidget
---@field Button_close UButton
---@field Button_left UButton
---@field Button_right UButton
---@field CanvasPanel_IPX UCanvasPanel
---@field TextBlock_TypeNum UTextBlock
---@field TextBlock_TypeNumMax UTextBlock
---@field WidgetSwitcher_Desc UWidgetSwitcher
--Edit Below--
---@type WB_SceneItemGuide_2_C
local WB_SceneItemGuide_2 = {
bInitDoOnce = false;
SelectColor = {R = 1., G = 0.51, B = 0.14, A = 1.};
NotSelectColor = {R = 1., G = 1., B = 1., A = 1.};
MaxMechanismNum = 0;
};
function WB_SceneItemGuide_2: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_SceneItemGuide_2:OnShowPanel(...)
self.WidgetSwitcher_Desc:SetActiveWidgetIndex(0);
end
function WB_SceneItemGuide_2:UpdateMechanismDesc(MapType)
UGCLogSystem.Log("[WB_SceneItemGuide_2_UpdateMechanismDesc] MapType:%s", tostring(MapType))
for i, MapMechanismType in pairs(MapConfig.MapInfo[MapType].MapMechanisms) do
local ItemWidget = UserWidget.NewWidgetObjectBP(UGCSystemLibrary.GetLocalPlayerController(), ObjectPathTable.WB_SceneItemGuideItem_Class)
self.WidgetSwitcher_Desc:AddChild(ItemWidget)
ItemWidget:UpdateDesc(MapMechanismType)
end
self.MaxMechanismNum = #MapConfig.MapInfo[MapType].MapMechanisms
self.TextBlock_TypeNumMax:SetText(tostring(self.MaxMechanismNum))
self.TextBlock_TypeNum:SetText("1")
end
function WB_SceneItemGuide_2:GetNowIndex()
return self.WidgetSwitcher_Desc:GetActiveWidgetIndex()
end
function WB_SceneItemGuide_2:UpdateIndex(NewIndex)
if NewIndex >= self.MaxMechanismNum then
NewIndex = 0
elseif NewIndex < 0 then
NewIndex = self.WidgetSwitcher_Desc:GetChildrenCount() - 1
end
self.TextBlock_TypeNum:SetText(tostring(NewIndex + 1))
self.WidgetSwitcher_Desc:SetActiveWidgetIndex(NewIndex)
--for i = 1, self.WidgetSwitcher_Desc: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_SceneItemGuide_2:NextGuide()
self:UpdateIndex(self:GetNowIndex() + 1)
SoundSystem.PlaySound(SoundSystem.ESound.Btn)
end
function WB_SceneItemGuide_2:LastGuide()
self:UpdateIndex(self:GetNowIndex() - 1)
SoundSystem.PlaySound(SoundSystem.ESound.Btn)
end
function WB_SceneItemGuide_2:CloseGuide()
WidgetManager:ClosePanel(WidgetConfig.EUIType.SceneItemGuide);
end
-- function WB_SceneItemGuide_2:Tick(MyGeometry, InDeltaTime)
-- end
-- function WB_SceneItemGuide_2:Destruct()
-- end
return WB_SceneItemGuide_2;