118 lines
4.8 KiB
Lua
Raw Permalink Normal View History

2025-01-04 23:00:19 +08:00
---@class W_GamePreparation_2_C:UUserWidget
---@field CanvasPanel_Loading UCanvasPanel
---@field Image_MapBG UImage
---@field Overlay_SelectMapName UOverlay
---@field Overlay_WaitTime UOverlay
---@field TextBlock_Loading UTextBlock
---@field TextBlock_MapShowName UTextBlock
---@field TextBlock_MapSpecialMode UTextBlock
---@field TextBlock_SelectMapName UTextBlock
---@field TextBlock_WaitTime UTextBlock
---@field VerticalBox_Loading UVerticalBox
---@field WB_RandomSelectPlayerVoteMap UWB_RandomSelectPlayerVoteMap_C
---@field WidgetSwitcher_MapBG UWidgetSwitcher
--Edit Below--
---@type W_GamePreparation_2_C
local W_GamePreparation_2 = {
bInitDoOnce = false;
bSelected = false;
SelectMapType = -1;
bLoading = false;
};
function W_GamePreparation_2:Construct()
self.TextBlock_WaitTime:BindingProperty("Text", self.TextBlock_WaitTime_Text, self)
UGCEventSystem.AddListener(EventEnum.GameWillBegin, self.GameWillBegin, self)
UGCEventSystem.AddListener(EventEnum.LoadMap, self.LoadingMap, self)
UGCEventSystem.AddListener(EventEnum.GameStateChange, self.RemoveSelf, self)
UGCEventSystem.AddListener(EventEnum.RandomSelectVoteMap, self.RandomSelectVoteMap, self)
UGCEventSystem.AddListener(EventEnum.SelectMapCallBack, self.SelectMapCallBack, self)
local LoadMapType = UGCGameSystem.GameState:GetMapSelectionResult(false)
if LoadMapType ~= nil then
self:LoadingMap(LoadMapType)
end
end
function W_GamePreparation_2:OnClosePanel()
UGCLogSystem.Log("[W_GamePreparation_2_OnClosePanel]")
self.bLoading = false
WidgetManager:DestroyPanel(WidgetConfig.EUIType.WaitingTime)
end
function W_GamePreparation_2:RemoveSelf(NewGameState)
if NewGameState ~= CustomEnum.EGameState.Waiting and UE.IsValid(self) then
UGCEventSystem.SetTimer(self, self.OnClosePanel, GlobalConfigs.GameSetting.ClientLoadMapTime)
end
end
function W_GamePreparation_2:TextBlock_WaitTime_Text(ReturnValue)
return tostring(UGCGameSystem.GameState.WaitPlayerJoinTime)
end
function W_GamePreparation_2:GameWillBegin()
UGCLogSystem.Log("[W_GamePreparation_2_GameWillBegin]")
UGCEventSystem.SendEvent(EventEnum.AddTip, TipConfig.TipType.GameWillStart)
end
function W_GamePreparation_2:LoadingMap(LoadMapType)
UGCGameSystem.GameState:LoadNowMiniMap()
self.WB_RandomSelectPlayerVoteMap:SetVisibility(ESlateVisibility.Collapsed)
self.Overlay_WaitTime:SetVisibility(ESlateVisibility.Collapsed)
self.Overlay_SelectMapName:SetVisibility(ESlateVisibility.Collapsed)
--self.CanvasPanel_Select:SetVisibility(ESlateVisibility.Collapsed)
self.CanvasPanel_Loading:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
self.bLoading = true
self:SetMapSelect(LoadMapType)
end
function W_GamePreparation_2:SetMapSelect(SelectMapType)
UGCLogSystem.Log("[W_GamePreparation_2_SetMapSelect] SelectMapType:%s", tostring(SelectMapType))
if SelectMapType == MapConfig.MapType.Random then
self.WidgetSwitcher_MapBG:SetActiveWidgetIndex(1)
else
self.WidgetSwitcher_MapBG:SetActiveWidgetIndex(0)
self.Image_MapBG:SetBrushFromTexture(UGCSystemLibrary.LoadAsset(MapConfig.MapInfo[SelectMapType].Icon, true), true)
end
self:SetShowName(SelectMapType)
end
function W_GamePreparation_2:SetShowName(SelectMapType)
local MapName = MapConfig.MapInfo[SelectMapType].ShowName
local ModeName = MapConfig.SpecialModeName[MapConfig.MapInfo[SelectMapType].SpecialModeType]
if ModeName and ModeName ~= "" then
MapName = string.format("%s - ( %s )", MapName, ModeName)
end
self.TextBlock_MapShowName:SetText(MapName)
end
function W_GamePreparation_2:SelectMapCallBack(bSucceed, InSelectMapType)
UGCLogSystem.Log("[W_GamePreparation_2_SelectMapCallBack] InSelectMapType:%s", tostring(InSelectMapType))
self.SelectMapType = InSelectMapType
local MapInfo = MapConfig.MapInfo[InSelectMapType]
if MapInfo then
SoundSystem.PlaySound(SoundSystem.ESound.Btn)
self.Overlay_SelectMapName:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
self.TextBlock_SelectMapName:SetText(MapInfo.ShowName)
if MapInfo.SpecialModeType ~= MapConfig.ESpecialModeType.Default then
self.TextBlock_MapSpecialMode:SetText(string.format(" (%s)", MapConfig.SpecialModeName[MapInfo.SpecialModeType]))
else
self.TextBlock_MapSpecialMode:SetText("")
end
end
end
function W_GamePreparation_2:RandomSelectVoteMap(MapList, InTargetIndex)
self.Overlay_WaitTime:SetVisibility(ESlateVisibility.Collapsed)
self.Overlay_SelectMapName:SetVisibility(ESlateVisibility.Collapsed)
self.WB_RandomSelectPlayerVoteMap:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
self.WB_RandomSelectPlayerVoteMap:ShowVoteRandomMap(MapList, InTargetIndex, GlobalConfigs.GameSetting.RollMapTime)
end
-- function W_GamePreparation_2:Destruct()
-- end
return W_GamePreparation_2;