83 lines
2.1 KiB
Lua
83 lines
2.1 KiB
Lua
|
---@class WB_WeaponPartItem_C:UUserWidget
|
||
|
---@field Image_5 UImage
|
||
|
---@field Image_PartIcon UImage
|
||
|
---@field NewButton_ChangePart UNewButton
|
||
|
---@field WidgetSwitcher_IsSelect UWidgetSwitcher
|
||
|
---@field WidgetSwitcher_IsSelect_OLD UWidgetSwitcher
|
||
|
---@field WidgetSwitcher_SelectStyle UWidgetSwitcher
|
||
|
--Edit Below--
|
||
|
local WB_WeaponPartItem = {
|
||
|
bInitDoOnce = false;
|
||
|
};
|
||
|
|
||
|
--[==[ Construct
|
||
|
function WB_WeaponPartItem:Construct()
|
||
|
|
||
|
end
|
||
|
-- Construct ]==]
|
||
|
|
||
|
-- function WB_WeaponPartItem:Tick(MyGeometry, InDeltaTime)
|
||
|
|
||
|
-- end
|
||
|
|
||
|
-- function WB_WeaponPartItem:Destruct()
|
||
|
|
||
|
-- end
|
||
|
|
||
|
function WB_WeaponPartItem:LuaInit()
|
||
|
if self.bInitDoOnce then return end
|
||
|
self.bInitDoOnce = true
|
||
|
WidgetLibrary.BindButtonClicked(self.NewButton_ChangePart, self.ClickCallBack, self)
|
||
|
end
|
||
|
|
||
|
function WB_WeaponPartItem:ClickCallBack()
|
||
|
if self.SelectCallBackFunc then
|
||
|
if self.SelectCallBackObj then
|
||
|
self.SelectCallBackFunc(self.SelectCallBackObj, self:GetItemID())
|
||
|
else
|
||
|
self.SelectCallBackFunc(self:GetPartType())
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WB_WeaponPartItem:BindSelectCallBack(InFunc, InObj)
|
||
|
self.SelectCallBackFunc = InFunc
|
||
|
self.SelectCallBackObj = InObj
|
||
|
end
|
||
|
|
||
|
|
||
|
WB_WeaponPartItem.PartID = -100
|
||
|
function WB_WeaponPartItem:SetItemID(InPartID)
|
||
|
if self.PartID ~= InPartID then
|
||
|
self.PartID = InPartID
|
||
|
if self.PartID and self.PartID > 0 then
|
||
|
self:SetVisibility(ESlateVisibility.Visible)
|
||
|
MyWeaponSystem.AsyncLoadItemSmallIconToBrush(self.PartID, self.Image_PartIcon)
|
||
|
else
|
||
|
self:SetVisibility(ESlateVisibility.Collapsed)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WB_WeaponPartItem:GetItemID()
|
||
|
return self.PartID
|
||
|
end
|
||
|
|
||
|
function WB_WeaponPartItem:SetPartType(InType)
|
||
|
self:LuaInit()
|
||
|
self.PartType = InType
|
||
|
end
|
||
|
|
||
|
function WB_WeaponPartItem:GetPartType()
|
||
|
return self.PartType
|
||
|
end
|
||
|
|
||
|
function WB_WeaponPartItem:SetIsSelect(InIsSelect)
|
||
|
self.WidgetSwitcher_IsSelect:SetActiveWidgetIndex(InIsSelect and 1 or 0)
|
||
|
end
|
||
|
|
||
|
function WB_WeaponPartItem:SetSelectStyle(StyleIndex)
|
||
|
self.WidgetSwitcher_SelectStyle:SetActiveWidgetIndex(StyleIndex)
|
||
|
end
|
||
|
|
||
|
return WB_WeaponPartItem;
|