73 lines
2.0 KiB
Lua
73 lines
2.0 KiB
Lua
|
---@class WBP_DifficultyItem_C:UUserWidget
|
||
|
---@field Button_Select UButton
|
||
|
---@field Image_0 UImage
|
||
|
---@field Image_Select UImage
|
||
|
---@field TextBlock_Select UTextBlock
|
||
|
---@field WidgetSwitcher_BG UWidgetSwitcher
|
||
|
--Edit Below--
|
||
|
local WBP_DifficultyItem = {
|
||
|
bInitDoOnce = false;
|
||
|
Difficulty = 0; --难度
|
||
|
CanSelect = false; --是否可以选择
|
||
|
};
|
||
|
|
||
|
function WBP_DifficultyItem:Construct()
|
||
|
self.SuperClass:Construct();
|
||
|
self.Button_Select.OnClicked:Add(WBP_DifficultyItem.OnSelected, self);
|
||
|
self.WidgetSwitcher_BG:SetActiveWidgetIndex(0);
|
||
|
end
|
||
|
|
||
|
function WBP_DifficultyItem:OnSelected()
|
||
|
-- 发送过去难度
|
||
|
-- 需要判断当前是否选择过了
|
||
|
print(string.format('[WBP_DifficultyItem:OnSelected] 执行'))
|
||
|
if UIManager:GetPanel(EUIType.SelectDifficulty).SelectDifficulty ~= 0 then
|
||
|
return
|
||
|
end
|
||
|
if not self.CanSelect then
|
||
|
return
|
||
|
end
|
||
|
-- 打开界面
|
||
|
local UI = UIManager:GetPanel(EUIType.DifficultInfo)
|
||
|
UI:SetDifficult(self.Difficulty, self)
|
||
|
UIManager:ShowPanel(EUIType.DifficultInfo)
|
||
|
|
||
|
NewPlayerGuideManager:RemoveGuide(2)
|
||
|
--self:SetVisualType(2)
|
||
|
end
|
||
|
|
||
|
function WBP_DifficultyItem:SetDifficulty(InNum)
|
||
|
self.Difficulty = InNum
|
||
|
-- 显示文本
|
||
|
self.TextBlock_Select:SetText('难度\n' .. tostring(InNum))
|
||
|
end
|
||
|
|
||
|
-- function WBP_DifficultyItem:Tick(MyGeometry, InDeltaTime)
|
||
|
|
||
|
-- end
|
||
|
|
||
|
-- function WBP_DifficultyItem:Destruct()
|
||
|
|
||
|
-- end
|
||
|
|
||
|
--- 0: 隐藏
|
||
|
--- 1: 显示
|
||
|
--- 2: 点击
|
||
|
function WBP_DifficultyItem:SetVisualType(InType)
|
||
|
print(string.format('[WBP_DifficultyItem:SetVisualType] Type = %d', InType))
|
||
|
if InType == 1 then
|
||
|
self.CanSelect = true
|
||
|
self.WidgetSwitcher_BG:SetActiveWidgetIndex(1)
|
||
|
self.Image_Select:SetVisibility(ESlateVisibility.Hidden)
|
||
|
elseif InType == 0 then
|
||
|
self.CanSelect = false
|
||
|
self.WidgetSwitcher_BG:SetActiveWidgetIndex(0)
|
||
|
self.Image_Select:SetVisibility(ESlateVisibility.Hidden)
|
||
|
elseif InType == 2 then
|
||
|
self.CanSelect = false
|
||
|
self.WidgetSwitcher_BG:SetActiveWidgetIndex(1)
|
||
|
self.Image_Select:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
return WBP_DifficultyItem;
|