2025-02-03 23:08:27 +08:00

88 lines
2.5 KiB
Lua

---@class WB_PreviewFX_C:UUserWidget
---@field Image_Color UImage
---@field NewButton_Close UNewButton
---@field VerticalBox_FXItemPanel UVerticalBox
---@field WB_Item_Slide_B UWB_Item_Slide_C
---@field WB_Item_Slide_G UWB_Item_Slide_C
---@field WB_Item_Slide_R UWB_Item_Slide_C
--Edit Below--
local WB_PreviewFX = {
bInitDoOnce = false;
NowColor = {R = 1., G = 1., B = 1., A = 1.}
}
function WB_PreviewFX:Construct()
self:LuaInit()
end
function WB_PreviewFX:LuaInit()
if self.bInitDoOnce then return ; end
WidgetLibrary.BindButtonClicked(self.NewButton_Close, self.CloseSelf, self)
local RGBSlide = {
self.WB_Item_Slide_R,
self.WB_Item_Slide_G,
self.WB_Item_Slide_B,
}
for i, v in pairs(RGBSlide) do
v:LuaInit()
v:SetID(i)
v:BindValueCallBack(self.UpdateColor, self)
end
for i = 1, self.VerticalBox_FXItemPanel:GetChildrenCount() do
local Item = self.VerticalBox_FXItemPanel:GetChildAt(i - 1)
if i <= table.getCount(EFXType) then
Item:SetType(i)
Item:BindLockCallBack(self.LockChange, self)
end
end
end
function WB_PreviewFX:CloseSelf()
self:SetVisibility(ESlateVisibility.Collapsed)
end
function WB_PreviewFX:UpdateColor(ColorID, Val)
UGCLogSystem.Log("[WB_PreviewFX_UpdateColor] ColorID:%s, Val:%s", tostring(ColorID), tostring(Val))
if ColorID == 1 then
self.NowColor.R = Val
elseif ColorID == 2 then
self.NowColor.G = Val
elseif ColorID == 3 then
self.NowColor.B = Val
end
self.Image_Color:SetColorAndOpacity(self.NowColor)
local TempPreViewActor = UGCGameSystem.GameState:GetPreViewFXActor()
if UE.IsValid(TempPreViewActor) then
for i = 1, self.VerticalBox_FXItemPanel:GetChildrenCount() do
local Item = self.VerticalBox_FXItemPanel:GetChildAt(i - 1)
if i <= table.getCount(EFXType) then
if Item:GetIsBindColor() then
UGCLogSystem.Log("[WB_PreviewFX_UpdateColor] i:%s", tostring(i))
TempPreViewActor:SetOverrideColor(i, self.NowColor)
end
end
end
end
end
function WB_PreviewFX:LockChange(FXType, IsBind)
if IsBind then
local TempPreViewActor = UGCGameSystem.GameState:GetPreViewFXActor()
if UE.IsValid(TempPreViewActor) then
TempPreViewActor:SetOverrideColor(FXType, self.NowColor)
end
end
end
return WB_PreviewFX