123 lines
4.0 KiB
Lua
123 lines
4.0 KiB
Lua
|
---@class W_SelectMapItem_C:UUserWidget
|
||
|
---@field Button_Select UButton
|
||
|
---@field CanvasPanel_SpecialModeMain UCanvasPanel
|
||
|
---@field Image_Map UImage
|
||
|
---@field Overlay_Defaut UOverlay
|
||
|
---@field Overlay_IsSelect UOverlay
|
||
|
---@field Overlay_IsVote UOverlay
|
||
|
---@field TextBlock_IsNew UTextBlock
|
||
|
---@field TextBlock_MapName UTextBlock
|
||
|
---@field TextBlock_SelectNum UTextBlock
|
||
|
---@field TextBlock_SpecialModeName UTextBlock
|
||
|
---@field WidgetSwitcher_Enable UWidgetSwitcher
|
||
|
---@field WidgetSwitcher_ShowSelect UWidgetSwitcher
|
||
|
---@field WidgetSwitcher_VoteState UWidgetSwitcher
|
||
|
--Edit Below--
|
||
|
---@type W_SelectMapItem_C
|
||
|
local W_SelectMapItem = {
|
||
|
bInitDoOnce = false;
|
||
|
SelectMapType = -1;
|
||
|
bVote = false;
|
||
|
};
|
||
|
|
||
|
|
||
|
function W_SelectMapItem:Construct()
|
||
|
|
||
|
end
|
||
|
|
||
|
|
||
|
-- function W_SelectMapItem:Tick(MyGeometry, InDeltaTime)
|
||
|
|
||
|
-- end
|
||
|
|
||
|
-- function W_SelectMapItem:Destruct()
|
||
|
|
||
|
-- end
|
||
|
|
||
|
---@param SelectMapType MapConfig.MapType
|
||
|
function W_SelectMapItem:InitSelectItem(SelectMapType, ParentObj, ParentObjSelectCallBack)
|
||
|
UGCEventSystem.AddListener(EventEnum.SelectMapCallBack, self.LocalPlayerVote, self)
|
||
|
|
||
|
self.Button_Select:SetTouchMethod(EButtonTouchMethod.PreciseTap)
|
||
|
|
||
|
if MapConfig.MapEnable[SelectMapType] then
|
||
|
self.WidgetSwitcher_Enable:SetActiveWidgetIndex(0)
|
||
|
else
|
||
|
self.WidgetSwitcher_Enable:SetActiveWidgetIndex(1)
|
||
|
end
|
||
|
self.SelectMapType = SelectMapType
|
||
|
self.ParentObj = ParentObj
|
||
|
self.CallBackFunc = ParentObjSelectCallBack
|
||
|
|
||
|
|
||
|
if table.hasValue(MapConfig.NEWMaps, self.SelectMapType) then
|
||
|
self.TextBlock_IsNew:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
||
|
--UGCLogSystem.Log("[W_SelectMapItem_InitSelectItem]")
|
||
|
end
|
||
|
--UGCLogSystem.LogTree("[W_SelectMapItem_InitSelectItem] " .. self.SelectMapType, MapConfig.NEWMaps)
|
||
|
|
||
|
self.TextBlock_MapName:SetText(MapConfig.MapInfo[self.SelectMapType].ShowName)
|
||
|
local SpecialModeType = MapConfig.MapInfo[self.SelectMapType].SpecialModeType
|
||
|
if SpecialModeType == nil or SpecialModeType == MapConfig.ESpecialModeType.Default then
|
||
|
self.CanvasPanel_SpecialModeMain:SetVisibility(ESlateVisibility.Collapsed)
|
||
|
elseif MapConfig.SpecialModeName[SpecialModeType] then
|
||
|
self.TextBlock_SpecialModeName:SetText(MapConfig.SpecialModeName[SpecialModeType])
|
||
|
end
|
||
|
|
||
|
|
||
|
if SelectMapType == MapConfig.MapType.Random then
|
||
|
self.WidgetSwitcher_ShowSelect:SetActiveWidgetIndex(1)
|
||
|
else
|
||
|
self.WidgetSwitcher_ShowSelect:SetActiveWidgetIndex(0)
|
||
|
self.Image_Map:SetBrushFromTexture(UGCSystemLibrary.LoadAsset(MapConfig.MapInfo[self.SelectMapType].IconSelect, true))
|
||
|
end
|
||
|
|
||
|
|
||
|
|
||
|
WidgetLibrary.BindButtonClicked(self.Button_Select, self.ClickSelect, self)
|
||
|
WidgetLibrary.TextBlockBindingPropertyText(self.TextBlock_SelectNum, self.TextBlock_SelectNum_Text, self)
|
||
|
end
|
||
|
|
||
|
function W_SelectMapItem:GetSelectMapType()
|
||
|
return self.SelectMapType
|
||
|
end
|
||
|
|
||
|
function W_SelectMapItem:ClickSelect()
|
||
|
self.CallBackFunc(self.ParentObj, self.SelectMapType)
|
||
|
SoundSystem.PlaySound(SoundSystem.ESound.Btn)
|
||
|
end
|
||
|
|
||
|
function W_SelectMapItem:LocalPlayerVote(bSucceed, InMapType)
|
||
|
if bSucceed and InMapType == self.SelectMapType then
|
||
|
self.bVote = true
|
||
|
self.WidgetSwitcher_VoteState:SetActiveWidgetIndex(2)
|
||
|
else
|
||
|
self.bVote = false
|
||
|
self.WidgetSwitcher_VoteState:SetActiveWidgetIndex(0)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function W_SelectMapItem:TextBlock_SelectNum_Text(ReturnValue)
|
||
|
local Res = UGCGameSystem.GameState:GetSelectMapNumFromMapType(self.SelectMapType)
|
||
|
return tostring(Res)
|
||
|
end
|
||
|
|
||
|
function W_SelectMapItem:SetSelect(bSelect)
|
||
|
if self.bVote == false then
|
||
|
if bSelect then
|
||
|
self.WidgetSwitcher_VoteState:SetActiveWidgetIndex(1)
|
||
|
else
|
||
|
self.WidgetSwitcher_VoteState:SetActiveWidgetIndex(0)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function W_SelectMapItem:SetVote()
|
||
|
if self.bVote == false then
|
||
|
self.WidgetSwitcher_VoteState:SetActiveWidgetIndex(2)
|
||
|
else
|
||
|
UGCLogSystem.LogError("[W_SelectMapItem_SetVote] 已投票")
|
||
|
end
|
||
|
end
|
||
|
|
||
|
return W_SelectMapItem;
|