79 lines
2.8 KiB
Lua
79 lines
2.8 KiB
Lua
|
---@class WB_HookTraceMove_C:UUserWidget
|
||
|
---@field Overlay_TraceLeft UOverlay
|
||
|
---@field Overlay_TraceRight UOverlay
|
||
|
---@field WidgetSwitcher_L UWidgetSwitcher
|
||
|
---@field WidgetSwitcher_R UWidgetSwitcher
|
||
|
--Edit Below--
|
||
|
---@type WB_HookTraceMove_C
|
||
|
local WB_HookTraceMove = {
|
||
|
bInitDoOnce = false;
|
||
|
CenterOffset = 200;
|
||
|
TargetPosL = {X = 0., Y = 0., Z = 0.};
|
||
|
TargetPosR = {X = 0., Y = 0., Z = 0.};
|
||
|
EnableInterp = false;
|
||
|
InterpSpeed = 10;
|
||
|
};
|
||
|
|
||
|
--[==[ Construct
|
||
|
function WB_HookTraceMove:Construct()
|
||
|
|
||
|
end
|
||
|
-- Construct ]==]
|
||
|
|
||
|
function WB_HookTraceMove:Tick(MyGeometry, InDeltaTime)
|
||
|
if self.EnableInterp then
|
||
|
local BtnSlotR = WidgetLayoutLibrary.SlotAsCanvasSlot(self.Overlay_TraceRight)
|
||
|
local BtnSlotL = WidgetLayoutLibrary.SlotAsCanvasSlot(self.Overlay_TraceLeft)
|
||
|
local RPos = KismetMathLibrary.Vector2DInterpTo(BtnSlotR:GetPosition(), self.TargetPosR, InDeltaTime, self.InterpSpeed)
|
||
|
local LPos = KismetMathLibrary.Vector2DInterpTo(BtnSlotL:GetPosition(), self.TargetPosL, InDeltaTime, self.InterpSpeed)
|
||
|
BtnSlotR:SetPosition(RPos)
|
||
|
BtnSlotL:SetPosition(LPos)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
-- function WB_HookTraceMove:Destruct()
|
||
|
|
||
|
-- end
|
||
|
|
||
|
function WB_HookTraceMove:OnShowPanel()
|
||
|
self.EnableInterp = true
|
||
|
end
|
||
|
|
||
|
function WB_HookTraceMove:OnClosePanel()
|
||
|
self.EnableInterp = false
|
||
|
end
|
||
|
|
||
|
function WB_HookTraceMove:UpdateTracePos(IsRight, bFound, TargetPos)
|
||
|
WidgetManager:ShowPanel(WidgetConfig.EUIType.HookTrace, false)
|
||
|
--local TargetWidget
|
||
|
local TargetSwitcher
|
||
|
local TargetCenterOffset
|
||
|
if IsRight then
|
||
|
--TargetWidget = self.Overlay_TraceRight
|
||
|
TargetSwitcher = self.WidgetSwitcher_R
|
||
|
TargetCenterOffset = self.CenterOffset
|
||
|
else
|
||
|
--TargetWidget = self.Overlay_TraceLeft
|
||
|
TargetSwitcher = self.WidgetSwitcher_L
|
||
|
TargetCenterOffset = -self.CenterOffset
|
||
|
end
|
||
|
local IsOnScreen, ScreenPosition
|
||
|
if bFound then
|
||
|
TargetSwitcher:SetActiveWidgetIndex(0)
|
||
|
IsOnScreen, ScreenPosition = WidgetLayoutLibrary.ProjectWorldLocationToWidgetPosition(UGCSystemLibrary.GetLocalPlayerController(), TargetPos, nil);
|
||
|
else
|
||
|
TargetSwitcher:SetActiveWidgetIndex(1)
|
||
|
local ScreenSize = WidgetLayoutLibrary.GetViewportSize(self);
|
||
|
---@field ScreenToWidgetLocal fun(WorldContextObject:UObject,Geometry:FGeometry,ScreenPosition:FVector2D,LocalCoordinate:FVector2D):FVector2D
|
||
|
ScreenPosition = SlateBlueprintLibrary.ScreenToWidgetLocal(self, self:GetCachedGeometry(), {X = ScreenSize.X / 2 + TargetCenterOffset, Y = ScreenSize.Y / 2 })
|
||
|
end
|
||
|
if IsRight then
|
||
|
self.TargetPosR = ScreenPosition
|
||
|
else
|
||
|
self.TargetPosL = ScreenPosition
|
||
|
end
|
||
|
--local BtnSlot = WidgetLayoutLibrary.SlotAsCanvasSlot(TargetWidget)
|
||
|
--BtnSlot:SetPosition(ScreenPosition)
|
||
|
end
|
||
|
|
||
|
return WB_HookTraceMove;
|