77 lines
2.1 KiB
Lua
77 lines
2.1 KiB
Lua
|
---@class WB_MapItem_C:UUserWidget
|
||
|
---@field HorizontalBox_PlayerHead UHorizontalBox
|
||
|
---@field NewButton_Select UNewButton
|
||
|
---@field TextBlock_MapName UTextBlock
|
||
|
---@field WidgetSwitcher_IsSelect UWidgetSwitcher
|
||
|
--Edit Below--
|
||
|
local WB_MapItem = { bInitDoOnce = false }
|
||
|
|
||
|
|
||
|
function WB_MapItem:Construct()
|
||
|
self:LuaInit()
|
||
|
end
|
||
|
|
||
|
function WB_MapItem:LuaInit()
|
||
|
if self.bInitDoOnce then return end
|
||
|
self.bInitDoOnce = true
|
||
|
|
||
|
self.NewButton_Select:SetTouchMethod(EButtonTouchMethod.PreciseTap)
|
||
|
WidgetLibrary.BindButtonClicked(self.NewButton_Select, self.ClickSelect, self)
|
||
|
for i = 1, self.HorizontalBox_PlayerHead:GetChildrenCount() do
|
||
|
local Item = self.HorizontalBox_PlayerHead:GetChildAt(i - 1)
|
||
|
Item:SetVisibility(ESlateVisibility.Hidden)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WB_MapItem:SetMapIndex(MapType)
|
||
|
self.MapType = MapType
|
||
|
if MapConfig.MapInfo[MapType] then
|
||
|
self.TextBlock_MapName:SetText(MapConfig.MapInfo[MapType].ShowName)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WB_MapItem:GetIndex()
|
||
|
return self.MapType
|
||
|
end
|
||
|
|
||
|
function WB_MapItem:ClickSelect()
|
||
|
UGCLogSystem.Log("[WB_SelectMap_ClickSelect]")
|
||
|
if self.SelectCallBackFunc then
|
||
|
if self.SelectCallBackObj then
|
||
|
self.SelectCallBackFunc(self.SelectCallBackObj, self:GetIndex())
|
||
|
else
|
||
|
self.SelectCallBackFunc(self:GetIndex())
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WB_MapItem:BindClickSelect(Func, Obj)
|
||
|
self.SelectCallBackFunc = Func
|
||
|
self.SelectCallBackObj = Obj
|
||
|
end
|
||
|
|
||
|
function WB_MapItem:SetSelect(IsSelect)
|
||
|
self.WidgetSwitcher_IsSelect:SetActiveWidgetIndex(IsSelect and 1 or 0)
|
||
|
end
|
||
|
|
||
|
function WB_MapItem:SetSelectedPlayer(InPlayerKeys)
|
||
|
for i = 1, self.HorizontalBox_PlayerHead:GetChildrenCount() do
|
||
|
local Item = self.HorizontalBox_PlayerHead:GetChildAt(i - 1)
|
||
|
if InPlayerKeys[i] then
|
||
|
Item:UpdatePlayerInfo(InPlayerKeys[i])
|
||
|
Item:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
||
|
else
|
||
|
Item:SetVisibility(ESlateVisibility.Hidden)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
-- function WB_MapItem:Tick(MyGeometry, InDeltaTime)
|
||
|
|
||
|
-- end
|
||
|
|
||
|
-- function WB_MapItem:Destruct()
|
||
|
|
||
|
-- end
|
||
|
|
||
|
return WB_MapItem
|