UGCProjects/GZJ/Script/UI/ChildWidgets/WBP_RewardItem.lua

50 lines
1.3 KiB
Lua
Raw Permalink Normal View History

2025-01-08 22:46:12 +08:00
---@class WBP_RewardItem_C:UUserWidget
---@field Button_Rewards UButton
---@field Image_0 UImage
---@field TextBlock_Rewards UTextBlock
--Edit Below--
local WBP_RewardItem = { bInitDoOnce = false; RewardsItem = nil};
function WBP_RewardItem:Construct()
self.Button_Rewards.OnClicked:Add(WBP_RewardItem.OnSelectRewards, self)
end
-- function WBP_RewardItem:Tick(MyGeometry, InDeltaTime)
-- end
function WBP_RewardItem:Destruct()
self.Button_Rewards.OnClicked:Remove(WBP_RewardItem.OnSelectRewards, self)
end
function WBP_RewardItem:SetRewardsData(InData)
self.RewardsItem = InData
-- 拼装 Text
local Unit = '+'
if InData.Type == '配件' or InData.Type == '技能书' then
Unit = '*'
end
local Value, Type
if math.type(InData.Value) == 'float' then
Value = string.format('%2.2f', InData.Value)
else
Value = tostring(InData.Value)
end
Type = InData.Type
if string.find(Type, '%%') ~= nil then
Type = string.gsub(Type, '%%', '')
Value = string.format('%.1f%%', InData.Value * 100)
end
self.TextBlock_Rewards:SetText(Type .. Unit .. Value)
end
function WBP_RewardItem:OnSelectRewards()
UIManager:HidePanel(EUIType.SealRewards)
local PC = GameDataManager.GetLocalPlayerController()
UnrealNetwork.CallUnrealRPC(PC, PC, "ServerRPC_ApplyRewards", self.RewardsItem)
end
return WBP_RewardItem;