2025-01-04 23:00:19 +08:00

97 lines
3.7 KiB
Lua

---@class WB_MapOperate_C:UUserWidget
---@field AnimShow UWidgetAnimation
---@field Button_Break UNewButton
---@field Button_Load UNewButton
---@field Button_Remove UNewButton
---@field Button_ResetName UNewButton
---@field Button_SetPlayMap UNewButton
---@field TextBlock_MapName UTextBlock
--Edit Below--
local WB_MapOperate = {
bInitDoOnce = false;
bCanUse = true
};
function WB_MapOperate:Construct()
WidgetLibrary.BindButtonClicked(self.Button_Break, self.CloseSelf, self)
WidgetLibrary.BindButtonClicked(self.Button_Load, self.LoadMap, self)
WidgetLibrary.BindButtonClicked(self.Button_Remove, self.RemoveMap, self)
WidgetLibrary.BindButtonClicked(self.Button_SetPlayMap, self.ClickPlayMap, self)
WidgetLibrary.BindButtonClicked(self.Button_ResetName, self.ResetMapName, self)
end
function WB_MapOperate:OnShowPanel(InLoadPlaceItemsType, InLoadIndex, CanUse)
self.bCanUse = true
self.LoadPlaceItemsType = InLoadPlaceItemsType
self.LoadIndex = InLoadIndex
if self.LoadPlaceItemsType ~= PlacementModeConfig.LoadPlaceItemsType.SavedMap then
self.Button_Remove:SetVisibility(ESlateVisibility.Collapsed)
if self.LoadPlaceItemsType == PlacementModeConfig.LoadPlaceItemsType.Default then
self.TextBlock_MapName:SetText("默认模板")
else
self.TextBlock_MapName:SetText("空模板")
self.Button_SetPlayMap:SetVisibility(ESlateVisibility.Collapsed)
end
else
self.Button_Remove:SetVisibility(ESlateVisibility.Visible)
self.Button_SetPlayMap:SetVisibility(ESlateVisibility.Visible)
local SavedMapList = ArchiveDataConfig.GetPlayerArchiveDataFromType(UGCSystemLibrary.GetLocalPlayerKey(), ArchiveDataConfig.EArchiveType.SavedMap)
if SavedMapList and SavedMapList[InLoadIndex] then
self.TextBlock_MapName:SetText(SavedMapList[InLoadIndex].MapName)
end
self.bCanUse = CanUse
end
end
function WB_MapOperate:CloseSelf()
WidgetManager:ClosePanel(WidgetConfig.EUIType.MapOperate)
end
function WB_MapOperate:LoadMap()
PlacementModeConfig.GetPlaceManager():LoadSavedPlaceMap(self.LoadPlaceItemsType, self.LoadIndex)
self:CloseSelf()
end
function WB_MapOperate:RemoveMap()
UGCSendRPCSystem.ActorRPCNotify(nil, UGCGameSystem.GameState, "RemoveSavedMap", UGCSystemLibrary.GetLocalPlayerKey(), self.LoadIndex)
self:CloseSelf()
end
function WB_MapOperate:ClickPlayMap()
if self.bCanUse then
self:SetPlayMap()
else
local SecondaryConfirmationWidget = WidgetManager:GetPanel(WidgetConfig.EUIType.SecondaryConfirmation)
SecondaryConfirmationWidget:SetTextInfo("该放置代码超过了可放置上限,强制游玩会缺少组件!", "取消", "游玩")
SecondaryConfirmationWidget:BindConfirmCallBack(self.SetPlayMap, self)
WidgetManager:ShowPanel(WidgetConfig.EUIType.SecondaryConfirmation, false)
end
end
function WB_MapOperate:SetPlayMap()
UGCSendRPCSystem.ActorRPCNotify(nil, UGCGameSystem.GameState, "SetPlayMap", UGCSystemLibrary.GetLocalPlayerKey(), self.LoadIndex)
self:CloseSelf()
end
function WB_MapOperate:ResetMapName()
local SecondaryConfirmationWidget = WidgetManager:GetPanel(WidgetConfig.EUIType.SecondaryConfirmation_EditableText)
SecondaryConfirmationWidget:SetTextInfo("请输入地图名称", PlacementModeConfig.PlacingAttr.PlaceMapNameLengthLimit, "取消", "修改")
SecondaryConfirmationWidget:BindConfirmCallBack(self.SubmitMapName, self)
WidgetManager:ShowPanel(WidgetConfig.EUIType.SecondaryConfirmation_EditableText, false)
end
function WB_MapOperate:SubmitMapName(InText)
UGCSendRPCSystem.ActorRPCNotify(nil, UGCGameSystem.GameState, "SetSavedMapName", UGCSystemLibrary.GetLocalPlayerKey(), self.LoadIndex, InText)
self:CloseSelf()
end
-- function WB_MapOperate:Tick(MyGeometry, InDeltaTime)
-- end
-- function WB_MapOperate:Destruct()
-- end
return WB_MapOperate;