51 lines
1.4 KiB
Lua
51 lines
1.4 KiB
Lua
---@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; |