UGCProjects/SoloKing/Script/UI/Tool/Child/WB_SelectMapItem.lua
2025-01-04 23:00:19 +08:00

103 lines
2.9 KiB
Lua

---@class WB_SelectMapItem_C:UUserWidget
---@field HorizontalBox_Tags UHorizontalBox
---@field NewButton_Item UNewButton
---@field TextBlock_Name UTextBlock
---@field WidgetSwitcher_Select UWidgetSwitcher
--Edit Below--
---@type WB_SelectMapItem_C
local WB_SelectMapItem = { bInitDoOnce = false }
function WB_SelectMapItem:Construct()
self:LuaInit();
end
function WB_SelectMapItem:LuaInit()
if self.bInitDoOnce then return ; end
UITool.EnableButtonScroll(self.NewButton_Item);
UITool.BindButtonClicked(self.NewButton_Item, self.OnClickItem, self);
self:HideAllTags();
self.bInitDoOnce = true;
end
WB_SelectMapItem.Owner = nil;
WB_SelectMapItem.Func = nil;
function WB_SelectMapItem:SetOwnerWidget(InOwner, InFunc)
self.Owner = InOwner;
self.Func = InFunc;
end
WB_SelectMapItem.MapName = nil;
function WB_SelectMapItem:SetMapName(Name)
self.MapName = Name;
UGCLogSystem.LogTree(string.format("[WB_SelectMapItem:SetMapName] Name ="), Name)
for i, Info in pairs(LevelTable.LevelInfo) do
if Info.MapName == Name then
self.TextBlock_Name:SetText(Info.ShowName);
break;
end
end
end
function WB_SelectMapItem:EnableItem(Enable)
self.NewButton_Item:SetIsEnabled(Enable);
end
function WB_SelectMapItem:OnClickItem()
if self.Func and self.Owner then
UGCLogSystem.Log("[WB_SelectMapItem:OnClickItem] 执行")
self.Func(self.Owner, self);
end
end
function WB_SelectMapItem:GetMapName()
return self.MapName;
end
function WB_SelectMapItem:HideAllTags()
UITool.ForeachAllChildren(self.HorizontalBox_Tags, function(index, Widget)
Widget:SetVisibility(ESlateVisibility.Hidden);
end)
end
function WB_SelectMapItem:SetSelect(IsSelect)
--self.WidgetSwitcher_Select:SetActiveWidgetIndex(IsSelect and 1 or 0);
end
function WB_SelectMapItem:UpdateSelectBG(InMapToPlayerKeys)
if InMapToPlayerKeys[self.MapName] == nil then
self.WidgetSwitcher_Select:SetActiveWidgetIndex(0);
self:HideAllTags();
elseif #InMapToPlayerKeys[self.MapName] == 1 then
if InMapToPlayerKeys[self.MapName][1] == LocalPlayerKey then
self.WidgetSwitcher_Select:SetActiveWidgetIndex(1);
local Item = UITool.GetChildAt(self.HorizontalBox_Tags, 0)
Item:SetVisibility(ESlateVisibility.SelfHitTestInvisible);
local Item1 = UITool.GetChildAt(self.HorizontalBox_Tags, 1)
Item1:SetVisibility(ESlateVisibility.Hidden);
else
local Item = UITool.GetChildAt(self.HorizontalBox_Tags, 0)
Item:SetVisibility(ESlateVisibility.Hidden);
self.WidgetSwitcher_Select:SetActiveWidgetIndex(2);
local Item1 = UITool.GetChildAt(self.HorizontalBox_Tags, 1)
Item1:SetVisibility(ESlateVisibility.SelfHitTestInvisible);
end
else
self.WidgetSwitcher_Select:SetActiveWidgetIndex(3);
UITool.ForeachAllChildren(self.HorizontalBox_Tags, function(index, Widget)
Widget:SetVisibility(ESlateVisibility.HitTestInvisible);
end)
end
end
-- function WB_SelectMapItem:Tick(MyGeometry, InDeltaTime)
-- end
-- function WB_SelectMapItem:Destruct()
-- end
return WB_SelectMapItem