67 lines
1.9 KiB
Lua
67 lines
1.9 KiB
Lua
---@class WB_Tip1_C:UUserWidget
|
|
---@field ShowTips UWidgetAnimation
|
|
---@field TextBlock_Tips UTextBlock
|
|
--Edit Below--
|
|
---@type WB_Tip1_C
|
|
local WB_Tip1 = { bInitDoOnce = false; };
|
|
|
|
WB_Tip1.AnimeTime = 0;
|
|
|
|
function WB_Tip1:Construct()
|
|
self.AnimeTime = self.ShowTips:GetEndTime();
|
|
UGCLogSystem.Log("[WB_Tip1:Construct] AnimeTime = %f", self.AnimeTime);
|
|
end
|
|
|
|
-- function WB_Tip1:Tick(MyGeometry, InDeltaTime)
|
|
|
|
-- end
|
|
|
|
-- function WB_Tip1:Destruct()
|
|
|
|
-- end
|
|
|
|
function WB_Tip1:OnShowPanel(ShowTime, Color, fmt, ...)
|
|
UGCLogSystem.Log("[WB_Tip1:OnShowPanel] 执行")
|
|
if ShowTime then
|
|
self:PlayAnimation(self.ShowTips, 0, 1, EUMGSequencePlayMode.Forward, 1);
|
|
|
|
local Time = 0;
|
|
if type(ShowTime) == 'number' then
|
|
Time = ShowTime > 1 and ShowTime or 1;
|
|
if type(Color) == 'string' then
|
|
-- 设置为白色
|
|
local ColorVec = LogColorConfig[Color]
|
|
if ColorVec then
|
|
self:SetTips(fmt, ...);
|
|
self.TextBlock_Tips:SetColorAndOpacity(UITool.MakeSlateColor(LogColorConfig[ColorVec]));
|
|
else
|
|
self:SetTips(Color, fmt, ...);
|
|
end
|
|
elseif type(Color) == 'nil' then
|
|
self:SetTips(fmt, ...)
|
|
elseif type(Color) == 'number' then
|
|
self:SetTips(fmt, ...)
|
|
self.TextBlock_Tips:SetColorAndOpacity(UITool.MakeSlateColor(LogColorConfig[Color]));
|
|
end
|
|
elseif type(ShowTime) == 'string' or ShowTime == nil then
|
|
Time = 3;
|
|
self:SetTips(ShowTime, Color, fmt, ...);
|
|
end
|
|
-- 动画默认是 0.5 秒显示
|
|
UGCEventSystem.SetTimer(self, function()
|
|
self:PlayAnimation(self.ShowTips, 0, 1, EUMGSequencePlayMode.Reverse, 1);
|
|
-- 再过仪表设置为白色
|
|
UGCEventSystem.SetTimer(self, function()
|
|
self.TextBlock_Tips:SetColorAndOpacity(UITool.MakeSlateColor(LogColorConfig[ELogColor.Default]));
|
|
end, self.AnimeTime);
|
|
end, Time);
|
|
end
|
|
end
|
|
|
|
function WB_Tip1:SetTips(fmt, ...)
|
|
if fmt ~= nil then
|
|
self.TextBlock_Tips:SetText(string.format(fmt, ...));
|
|
end
|
|
end
|
|
|
|
return WB_Tip1; |