96 lines
2.9 KiB
Lua
96 lines
2.9 KiB
Lua
|
---@class WB_SavedMap_C:UUserWidget
|
||
|
---@field Button_Select UNewButton
|
||
|
---@field CanvasPanel_CanNotUse UCanvasPanel
|
||
|
---@field TextBlock_MapName UTextBlock
|
||
|
---@field TextBlock_Size UTextBlock
|
||
|
---@field WidgetSwitcherIsSelected UWidgetSwitcher
|
||
|
--Edit Below--
|
||
|
local WB_SavedMap = {
|
||
|
bInitDoOnce = false;
|
||
|
PlayerPlaceCount = 0;
|
||
|
PlaceCount = 0;
|
||
|
};
|
||
|
|
||
|
--[==[ Construct
|
||
|
function WB_SavedMap:Construct()
|
||
|
|
||
|
end
|
||
|
-- Construct ]==]
|
||
|
|
||
|
-- function WB_SavedMap:Tick(MyGeometry, InDeltaTime)
|
||
|
|
||
|
-- end
|
||
|
|
||
|
-- function WB_SavedMap:Destruct()
|
||
|
|
||
|
-- end
|
||
|
|
||
|
function WB_SavedMap:LuaInit()
|
||
|
if self.bInitDoOnce then
|
||
|
return;
|
||
|
end
|
||
|
self.bInitDoOnce = true;
|
||
|
UGCEventSystem.AddListener(ArchiveDataConfig.GetParamNotifyEvent(ArchiveDataConfig.EArchiveType.Exp), self.UpdatePlayerMaxPlaceCount, self)
|
||
|
WidgetLibrary.BindButtonClicked(self.Button_Select, self.ClickBtn, self)
|
||
|
end
|
||
|
|
||
|
function WB_SavedMap:Init(InCallBackFunc, InCallBackObj, InIndex, InShowName)
|
||
|
self:LuaInit()
|
||
|
self.CallBackFunc, self.CallBackObj = InCallBackFunc, InCallBackObj
|
||
|
self.TextBlock_MapName:SetText(InShowName)
|
||
|
self.Index = InIndex
|
||
|
end
|
||
|
|
||
|
function WB_SavedMap:GetIndex()
|
||
|
return self.Index
|
||
|
end
|
||
|
|
||
|
function WB_SavedMap:SetIsSelected(IsSelect)
|
||
|
if IsSelect then
|
||
|
self.WidgetSwitcherIsSelected:SetActiveWidgetIndex(1)
|
||
|
else
|
||
|
self.WidgetSwitcherIsSelected:SetActiveWidgetIndex(0)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WB_SavedMap:ResetName(InShowName)
|
||
|
self.TextBlock_MapName:SetText(InShowName)
|
||
|
end
|
||
|
|
||
|
function WB_SavedMap:ResetCode(InCode)
|
||
|
self.PlayerPlaceCount = PlacementModeConfig.GetPlaceMaxValue(UGCSystemLibrary.GetLocalPlayerKey())
|
||
|
local CanUse, PlaceCount = PlacementModeConfig.CheckPlayerCanUsePlaceCode(InCode, UGCSystemLibrary.GetLocalPlayerKey())
|
||
|
self.PlaceCount = PlaceCount
|
||
|
if CanUse then
|
||
|
self.CanvasPanel_CanNotUse:SetVisibility(ESlateVisibility.Collapsed)
|
||
|
else
|
||
|
self.CanvasPanel_CanNotUse:SetVisibility(ESlateVisibility.HitTestInvisible)
|
||
|
end
|
||
|
self.TextBlock_Size:SetText(self.PlaceCount .. "/" .. self.PlayerPlaceCount)
|
||
|
end
|
||
|
|
||
|
function WB_SavedMap:UpdatePlayerMaxPlaceCount()
|
||
|
self.PlayerPlaceCount = PlacementModeConfig.GetPlaceMaxValue(UGCSystemLibrary.GetLocalPlayerKey())
|
||
|
self.TextBlock_Size:SetText(self.PlaceCount .. "/" .. self.PlayerPlaceCount)
|
||
|
end
|
||
|
|
||
|
function WB_SavedMap:SetIsDefaultSavedMap(IsDefaultMap)
|
||
|
if IsDefaultMap then
|
||
|
self.TextBlock_Size:SetVisibility(ESlateVisibility.Collapsed)
|
||
|
else
|
||
|
self.TextBlock_Size:SetVisibility(ESlateVisibility.HitTestInvisible)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WB_SavedMap:ClickBtn()
|
||
|
if self.CallBackFunc then
|
||
|
if self.CallBackObj then
|
||
|
self.CallBackFunc(self.CallBackObj, self.Index, self.PlaceCount <= self.PlayerPlaceCount)
|
||
|
else
|
||
|
self.CallBackFunc(self.Index, self.PlaceCount <= self.PlayerPlaceCount)
|
||
|
end
|
||
|
end
|
||
|
-- SoundSystem.PlaySound(SoundSystem.ESound.Btn)
|
||
|
end
|
||
|
|
||
|
return WB_SavedMap;
|