60 lines
1.9 KiB
Lua
60 lines
1.9 KiB
Lua
WidgetLibrary = WidgetLibrary or {}
|
|
|
|
|
|
--- 设置
|
|
---@param widget UUserWidget
|
|
---@param offset float
|
|
function WidgetLibrary.SetWidgetToRightBorder(widget, offset)
|
|
if not widget then return end
|
|
local slot = WidgetLayoutLibrary.SlotAsCanvasSlot(widget)
|
|
slot:SetAnchors({ Minimum = { X = 1, Y = 0 }, Maximum = { X = 1, Y = 0 } })
|
|
slot:SetAlignment({ X = 1, Y = 0 })
|
|
local offsets = slot:GetOffsets()
|
|
slot:SetOffsets({ Left = offset, Right = offsets.Right, Bottom = offsets.Bottom, Top = offsets.Top })
|
|
end
|
|
|
|
--- 为防止被清除做出的全局处理
|
|
function WidgetLibrary.BindButtonClicked(TargetButton, Func, Obj)
|
|
TargetButton.OnClicked:Add(Func, Obj)
|
|
end
|
|
|
|
--- 为防止被清除做出的全局处理
|
|
function WidgetLibrary.BindButtonPressed(TargetButton, Func, Obj)
|
|
TargetButton.OnPressed:Add(Func, Obj)
|
|
end
|
|
|
|
--- 为防止被清除做出的全局处理
|
|
function WidgetLibrary.BindButtonReleased(TargetButton, Func, Obj)
|
|
TargetButton.OnReleased:Add(Func, Obj)
|
|
end
|
|
|
|
--- 绑定UI文本
|
|
function WidgetLibrary.TextBlockBindingPropertyText(TargetTextBlock, Func, Obj)
|
|
TargetTextBlock:BindingProperty("Text", Func, Obj)
|
|
end
|
|
|
|
--- 直接绑定按键点击打开WidgetManager的页面
|
|
function WidgetLibrary.ButtonOnClickShowPanel(TargetButton, UIType, IsClose)
|
|
TargetButton.OnClicked:Add(
|
|
function()
|
|
if IsClose then
|
|
WidgetManager:ClosePanel(UIType)
|
|
else
|
|
WidgetManager:ShowPanel(UIType, false)
|
|
end
|
|
end
|
|
)
|
|
end
|
|
|
|
function WidgetLibrary.SliderOnValueChanged(Slider, Func, Obj)
|
|
Slider.OnValueChanged:Add(Func, Obj)
|
|
end
|
|
|
|
function WidgetLibrary.GetGameID()
|
|
---@type MainControlPanelTochButton_C
|
|
local MainControlPanel = GameBusinessManager.GetWidgetFromName(ingame, "MainControlPanelTochButton_C");
|
|
local MainControlBaseUI = MainControlPanel.MainControlBaseUI;
|
|
local PID = MainControlBaseUI.TextBlock_PID.Text
|
|
local BID = MainControlBaseUI.TextBlock_BID.Text
|
|
return PID, BID;
|
|
end |