UGCProjects/GZJ/Script/UI/ChildWidgets/WBP_WeaponAttributeItem.lua
2025-01-08 22:46:12 +08:00

51 lines
1.4 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---@class WBP_WeaponAttributeItem_C:UUserWidget
---@field TextBlock_Name UTextBlock
---@field TextBlock_Value UTextBlock
---@field AttributeName FText
--Edit Below--
local WBP_WeaponAttributeItem = {
bInitDoOnce = false;
bHasConstruct = false;
};
function WBP_WeaponAttributeItem:Construct()
self.SuperClass:Construct()
self.bHasConstruct = true
end
-- Construct ]==]
-- function WBP_WeaponAttributeItem:Tick(MyGeometry, InDeltaTime)
-- end
-- function WBP_WeaponAttributeItem:Destruct()
-- end
function WBP_WeaponAttributeItem:SetAttributeItem(InData)
print(string.format("[WBP_WeaponAttributeItem:SetAttributeItem] 开始设置数据Type = %s", InData.Type))
local Name = InData.Type
local PercentIndex = string.find(Name, '%%')
local Val = ''
local ItemVal = 0
if PercentIndex ~= nil then
--print(string.format("[WBP_WeaponAttributeItem:SetAttributeItem] Name = %s, Index = %d", Name, PercentIndex))
Val = string.gsub(Name, '%%', '')
ItemVal = InData.Value * 100
self.TextBlock_Name:SetText(Val .. ':')
self.TextBlock_Value:SetText(tostring(ItemVal) .. '%')
else
ItemVal = InData.Value
if ItemVal > 1 then
ItemVal = math.ceil(ItemVal)
end
self.TextBlock_Name:SetText(Name .. ':')
if math.type(ItemVal) == 'float' then
self.TextBlock_Value:SetText(string.format('%2.2f', ItemVal))
else
self.TextBlock_Value:SetText(tostring(ItemVal))
end
end
end
return WBP_WeaponAttributeItem;