83 lines
3.1 KiB
Lua
83 lines
3.1 KiB
Lua
---@class WB_WeaponProficiency_C:UUserWidget
|
|
---@field Image_CD UImage
|
|
---@field Image_Weapon_Write UImage
|
|
---@field TextBlock_AllDamage UTextBlock
|
|
---@field TextBlock_CriticalHitRate UTextBlock
|
|
---@field TextBlock_CriticalStrikeCount UTextBlock
|
|
---@field TextBlock_MatchNumber UTextBlock
|
|
---@field TextBlock_Proficiency UTextBlock
|
|
---@field TextBlock_WeaponName UTextBlock
|
|
---@field TextBlock_WinRate UTextBlock
|
|
---@field WidgetSwitcher_BG UWidgetSwitcher
|
|
---@field WidgetSwitcher_IsFullProficiency UWidgetSwitcher
|
|
--Edit Below--
|
|
local WB_WeaponProficiency = { bInitDoOnce = false }
|
|
|
|
--[==[ Construct
|
|
function WB_WeaponProficiency:Construct()
|
|
|
|
end
|
|
-- Construct ]==]
|
|
|
|
-- function WB_WeaponProficiency:Tick(MyGeometry, InDeltaTime)
|
|
|
|
-- end
|
|
|
|
-- function WB_WeaponProficiency:Destruct()
|
|
|
|
-- end
|
|
|
|
function WB_WeaponProficiency:SetWeaponID(InWeaponID)
|
|
self.WeaponID = InWeaponID
|
|
if UGCItemSystem.IsUGCItem(self.WeaponID) then
|
|
local Info = UGCItemSystem.GetItemData(self.WeaponID);
|
|
local ItemName = Info.ItemName;
|
|
if WeaponTable[self.WeaponID] then
|
|
local TypeNew = WeaponTable[self.WeaponID].TypeNew
|
|
if TypeNew then
|
|
if type(WeaponTypePost[TypeNew]) == 'string' then
|
|
ItemName = string.gsub(Info.ItemName, WeaponTypePost[TypeNew], "")
|
|
elseif type(WeaponTypePost[TypeNew]) == 'table' then
|
|
for i, v in pairs(WeaponTypePost[TypeNew]) do
|
|
ItemName = string.gsub(ItemName, v, "");
|
|
end
|
|
end
|
|
end
|
|
end
|
|
self.TextBlock_WeaponName:SetText(ItemName);
|
|
UE.AsyncLoadObject_Cached(Info.ItemWhiteIcon_n, function(ImageIcon)
|
|
if UE.IsValid(ImageIcon) then
|
|
self.Image_Weapon_Write:SetBrushFromTexture(ImageIcon, false)
|
|
end
|
|
end)
|
|
end
|
|
end
|
|
|
|
function WB_WeaponProficiency:SetWeaponProficiencyInfo(WeaponProficiencyInfo)
|
|
local Proficiency, IsFull = WeaponProficiencyCalculation(WeaponProficiencyInfo)
|
|
self:SetProficiency(Proficiency, IsFull)
|
|
self.TextBlock_CriticalHitRate:SetText(string.format("%.2f%%", WeaponProficiencyInfo[EWeaponProficiencyType.CriticalHitRate] * 100))
|
|
self.TextBlock_MatchNumber:SetText(tostring(WeaponProficiencyInfo[EWeaponProficiencyType.MatchNumber]))
|
|
self.TextBlock_CriticalStrikeCount:SetText(tostring(WeaponProficiencyInfo[EWeaponProficiencyType.CriticalStrikeCount]))
|
|
self.TextBlock_WinRate:SetText(string.format("%.2f%%", WeaponProficiencyInfo[EWeaponProficiencyType.WinRate] * 100))
|
|
self.TextBlock_AllDamage:SetText(tostring(math.floor(WeaponProficiencyInfo[EWeaponProficiencyType.AllDamage])))
|
|
end
|
|
|
|
function WB_WeaponProficiency:SetProficiency(InProficiency, IsFull)
|
|
if IsFull then
|
|
self.WidgetSwitcher_IsFullProficiency:SetActiveWidgetIndex(1)
|
|
else
|
|
self.WidgetSwitcher_IsFullProficiency:SetActiveWidgetIndex(0)
|
|
self.TextBlock_Proficiency:SetText(tostring(InProficiency))
|
|
local Material = self.Image_CD:GetDynamicMaterial();
|
|
local Percent = InProficiency / 100
|
|
Material:SetScalarParameterValue("Mask_Percent", Percent);
|
|
end
|
|
end
|
|
|
|
function WB_WeaponProficiency:ChangeBG(Index)
|
|
self.WidgetSwitcher_BG:SetActiveWidgetIndex((Index % 2))
|
|
-- UGCLogSystem.Log("[WB_WeaponProficiency_ChangeBG] " .. Index % 2)
|
|
end
|
|
|
|
return WB_WeaponProficiency |