UGCProjects/TrainingCamp/Script/UI/InTest/WB_InTestWidget.lua

102 lines
4.9 KiB
Lua
Raw Normal View History

2025-01-04 23:00:19 +08:00
---@class WB_InTestWidget_C:UUserWidget
---@field Button_AddBody_Slow UButton
---@field Button_AddHealth_Quick UButton
---@field Button_AddHealth_Slow UButton
---@field Button_AddHealthMax UButton
---@field Button_AddJump UButton
---@field Button_AddSpeed UButton
---@field Button_Back UButton
---@field Button_BigBody UButton
---@field Button_MaxBodySize UButton
---@field Button_ReduceHealth UButton
---@field Button_ReduceHealth_Slow UButton
---@field Button_ReduceHealthMax UButton
---@field Button_ReduceJump UButton
---@field Button_ReduceSpeed UButton
---@field Button_SmallBody UButton
---@field Button_SmallBody_Slow UButton
---@field Button_StopChangeBody UButton
---@field Button_Test1 UButton
---@field Button_Test_Tips UButton
---@field CheckBox_Custom UCheckBox
---@field CheckBox_Props UCheckBox
---@field CheckBox_Skill UCheckBox
---@field Slider_Value USlider
---@field TextBlock_Current UTextBlock
---@field TextBlock_Max UTextBlock
---@field VerticalBox_CheckBox UVerticalBox
---@field WidgetSwitcher_Main UWidgetSwitcher
--Edit Below--
---@type WB_InTestWidget_C
local WB_InTestWidget = { bInitDoOnce = false; };
function WB_InTestWidget:Construct()
UITool.BindButtonClicked(self.Button_Back, function() WidgetManager:ClosePanel(WidgetConfig.EUIType.Test) end, self);
UITool.BindButtonClicked(self.Button_AddHealth_Quick, function() self:SendTestBuffFunc("AddHealth_Quick") end, self);
UITool.BindButtonClicked(self.Button_AddHealth_Slow, function() self:SendTestBuffFunc("AddHealth_Slow") end, self);
UITool.BindButtonClicked(self.Button_ReduceHealth, function() self:SendTestBuffFunc("ReduceHealth_Quick") end, self);
UITool.BindButtonClicked(self.Button_AddHealthMax, function() self:SendTestBuffFunc("AddHealthMax") end, self);
UITool.BindButtonClicked(self.Button_AddSpeed, function() self:SendTestBuffFunc("AddSpeed") end, self);
UITool.BindButtonClicked(self.Button_BigBody, function() self:SendTestBuffFunc("AddBodySize") end, self);
UITool.BindButtonClicked(self.Button_ReduceHealthMax, function() self:SendTestBuffFunc("ReduceHealthMax") end, self);
UITool.BindButtonClicked(self.Button_ReduceSpeed, function() self:SendTestBuffFunc("ReduceSpeed") end, self);
UITool.BindButtonClicked(self.Button_SmallBody, function() self:SendTestBuffFunc("SmallBody") end, self);
UITool.BindButtonClicked(self.Button_ReduceHealth_Slow, function() self:SendTestBuffFunc("ReduceHealth_Slow") end, self);
UITool.BindButtonClicked(self.Button_AddJump, function() self:SendTestBuffFunc("AddJump") end, self);
UITool.BindButtonClicked(self.Button_ReduceJump, function() self:SendTestBuffFunc("ReduceJump") end, self);
UITool.BindButtonClicked(self.Button_AddBody_Slow, function() self:SendBodyChangeRPC(true, 1) end, self);
UITool.BindButtonClicked(self.Button_SmallBody_Slow, function() self:SendBodyChangeRPC(true, 2) end, self);
UITool.BindButtonClicked(self.Button_StopChangeBody, function() self:SendBodyChangeRPC(false, 1) end, self);
UITool.BindButtonClicked(self.Button_Test1, function() self:SendRPC("Test1", 100) end, self);
UITool.BindButtonClicked(self.Button_Test_Tips, function() WidgetManager:ShowPanel(WidgetConfig.EUIType.Tips1, false, 3, "显示出来 %d", 123) end, self);
self.CheckBox_Props.OnCheckStateChanged:Add(function(bIsChecked)
self.CheckBox_Skill:SetCheckedState(ECheckBoxState.Unchecked);
self.CheckBox_Custom:SetCheckedState(ECheckBoxState.Unchecked);
self.WidgetSwitcher_Main:SetActiveWidgetIndex(0);
end, self)
self.CheckBox_Skill.OnCheckStateChanged:Add(function(bIsChecked)
self.CheckBox_Props:SetCheckedState(ECheckBoxState.Unchecked);
self.CheckBox_Custom:SetCheckedState(ECheckBoxState.Unchecked);
self.WidgetSwitcher_Main:SetActiveWidgetIndex(1);
end, self)
self.CheckBox_Custom.OnCheckStateChanged:Add(function(bIsChecked)
self.CheckBox_Skill:SetCheckedState(ECheckBoxState.Unchecked);
self.CheckBox_Props:SetCheckedState(ECheckBoxState.Unchecked);
self.WidgetSwitcher_Main:SetActiveWidgetIndex(2);
end, self)
self.TextBlock_Current:SetText(0)
self.Slider_Value.OnValueChanged:Add(self.OnChangeSliderValue, self)
self.Slider_Value.OnMouseCaptureEnd:Add(self.OnMouseEnd, self)
end
function WB_InTestWidget:OnChangeCheck(InIndex)
end
function WB_InTestWidget:SendRPC(InStr, ...)
UnrealNetwork.CallUnrealRPC(LocalPlayerController, LocalPlayerController, "Test_Func", InStr, ...);
end
function WB_InTestWidget:SendTestBuffFunc(InStr)
UnrealNetwork.CallUnrealRPC(LocalPlayerController, LocalPlayerController, "Test_Func", "Test_Buff", InStr);
end
function WB_InTestWidget:OnChangeSliderValue(InValue)
self.TextBlock_Current:SetText(string.format('%0.2f', InValue * 100))
end
function WB_InTestWidget:OnMouseEnd()
-- 发送到服务器
UnrealNetwork.CallUnrealRPC(LocalPlayerController, LocalPlayerController, "Test_Func", "OnSliderMouseEnd", self.Slider_Value:GetValue());
end
-- function WB_InTestWidget:Tick(MyGeometry, InDeltaTime)
-- end
-- function WB_InTestWidget:Destruct()
-- end
return WB_InTestWidget;