Compare commits
2 Commits
be6e40383d
...
4e7f89bd38
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e7f89bd38 | |||
| 11896c87b1 |
BIN
Content/Data/Input/Homeland/Hearth/IA_PreCookTouchBegin.uasset
Normal file
BIN
Content/Data/Input/Homeland/Hearth/IA_PreCookTouchBegin.uasset
Normal file
Binary file not shown.
BIN
Content/Data/Input/Homeland/Hearth/IA_PreCookTouchEnd.uasset
Normal file
BIN
Content/Data/Input/Homeland/Hearth/IA_PreCookTouchEnd.uasset
Normal file
Binary file not shown.
Binary file not shown.
@ -2,16 +2,20 @@ local DataTableUtils = require("Utils.DataTableUtils")
|
|||||||
local ESlateVisibility = import("ESlateVisibility")
|
local ESlateVisibility = import("ESlateVisibility")
|
||||||
local SlateBlueprintLibrary = import("SlateBlueprintLibrary")
|
local SlateBlueprintLibrary = import("SlateBlueprintLibrary")
|
||||||
local WidgetLayoutLibrary = import("WidgetLayoutLibrary")
|
local WidgetLayoutLibrary = import("WidgetLayoutLibrary")
|
||||||
|
local BusyGamePlayLibrary = import("BusyGamePlayLibrary")
|
||||||
|
|
||||||
|
local CUT_MASK_DISPLAY_TIME = 1.2 -- 刀光显示的时长
|
||||||
|
local CUT_MASK_FADEOUT_TIME = 0.6 -- 刀光开始渐隐的时间点
|
||||||
|
|
||||||
--- @class PreCookCenterWidget
|
--- @class PreCookCenterWidget
|
||||||
--- @field ImgContainer table
|
--- @field ImgContainer table
|
||||||
--- @field ImgCookMaterial table
|
--- @field ImgCookMaterial table
|
||||||
|
--- @field BtnMain table
|
||||||
local PreCookCenterWidget = {}
|
local PreCookCenterWidget = {}
|
||||||
|
|
||||||
function PreCookCenterWidget:ctor()
|
function PreCookCenterWidget:ctor()
|
||||||
self.mouse_tracks = {}
|
self.mouse_tracks = {} -- 记录当前鼠标的轨迹
|
||||||
|
self.rendering_tracks = {} -- 正在被渲染的刀光
|
||||||
self.is_pressed = false
|
self.is_pressed = false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -19,20 +23,20 @@ end
|
|||||||
function PreCookCenterWidget:OnInitialized()
|
function PreCookCenterWidget:OnInitialized()
|
||||||
self.bHasScriptImplementedTick = true
|
self.bHasScriptImplementedTick = true
|
||||||
|
|
||||||
self.BtnMain.OnReleased:Add(function()
|
self:BP_BindLuaEnhancedInput(self.IA_TouchBegin, function()
|
||||||
-- self.bHasScriptImplementedTick = false
|
|
||||||
self.is_pressed = false
|
|
||||||
print("release")
|
|
||||||
end)
|
|
||||||
self.BtnMain.OnPressed:Add(function()
|
|
||||||
self.mouse_tracks = {}
|
|
||||||
self.is_pressed = true
|
self.is_pressed = true
|
||||||
-- self.bHasScriptImplementedTick = true
|
self.mouse_tracks = {}
|
||||||
print("pressed")
|
self.rendering_tracks = {self.mouse_tracks}
|
||||||
|
print("new track start")
|
||||||
end)
|
end)
|
||||||
-- self.BtnMain.OnClicked:Add(function()
|
|
||||||
-- print("onclicked")
|
self:BP_BindLuaEnhancedInput(self.IA_TouchEnd, function()
|
||||||
-- end)
|
self.is_pressed = false
|
||||||
|
self.mouse_tracks = {}
|
||||||
|
print("track end")
|
||||||
|
end)
|
||||||
|
|
||||||
|
self.BtnMain:SetVisibility(ESlateVisibility.Collapsed)
|
||||||
end
|
end
|
||||||
|
|
||||||
function PreCookCenterWidget:Construct()
|
function PreCookCenterWidget:Construct()
|
||||||
@ -66,110 +70,154 @@ function PreCookCenterWidget:AddCookMaterial(pre_cook_material_id)
|
|||||||
self.ImgCookMaterial:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
self.ImgCookMaterial:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- 从起点到终点画一条线,以这条线为新的x坐标轴,将所有的点坐标映射到新坐标系下
|
||||||
|
local function TransformCurveToEndpointAxes(points)
|
||||||
|
local A = points[1]
|
||||||
|
local B = points[#points]
|
||||||
|
|
||||||
local function UpdateOldMouseTrack(old_mouse_tracks, delta_time)
|
-- 计算向量AB
|
||||||
local new_mouse_tracks = {}
|
local dx = B.X - A.X
|
||||||
-- local new_track = {x=fixed_x, y=fixed_y, remain=1.0}
|
local dy = B.Y - A.Y
|
||||||
for _, track in pairs(old_mouse_tracks) do
|
local len = math.sqrt(dx * dx + dy * dy)
|
||||||
track.remain = track.remain - delta_time
|
if len == 0 then
|
||||||
if track.remain > 0 then
|
return {}
|
||||||
table.insert(new_mouse_tracks, track)
|
-- error("Start and end points are the same, cannot define X-axis.")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 计算X轴单位向量
|
||||||
|
local ux = dx / len
|
||||||
|
local uy = dy / len
|
||||||
|
|
||||||
|
-- 计算Y轴单位向量(逆时针旋转90度)
|
||||||
|
local vx = -uy
|
||||||
|
local vy = ux
|
||||||
|
|
||||||
|
-- 映射所有点到新坐标系
|
||||||
|
local new_points = {}
|
||||||
|
for i, point in ipairs(points) do
|
||||||
|
local apx = point.X - A.X
|
||||||
|
local apy = point.Y - A.Y
|
||||||
|
local new_x = apx * ux + apy * uy -- 点积与X轴单位向量
|
||||||
|
local new_y = apx * vx + apy * vy -- 点积与Y轴单位向量
|
||||||
|
new_points[i] = {X = new_x, Y = new_y}
|
||||||
|
end
|
||||||
|
|
||||||
|
return new_points
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- 将曲线的Y坐标规范到(-0.5,0.5)的范围内,供材质使用
|
||||||
|
local function NormalizeCurveYToHalfRange(points)
|
||||||
|
if #points < 2 then return end
|
||||||
|
local length = points[#points].X - points[1].X
|
||||||
|
for _, point in pairs(points) do
|
||||||
|
point.Y = - point.Y / length -- 临时加个取反
|
||||||
|
point.X = point.X / length
|
||||||
|
end
|
||||||
|
return points
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function UpdateCutMaskData(rendering_tracks, delta_time)
|
||||||
|
local new_visible_tracks = {}
|
||||||
|
for _, track in ipairs(rendering_tracks) do
|
||||||
|
local is_visible = false
|
||||||
|
for _, point in pairs(track) do
|
||||||
|
local remain = math.max(point.remain - delta_time, 0)
|
||||||
|
point.remain = remain
|
||||||
|
if remain > 0 then is_visible = true end
|
||||||
|
end
|
||||||
|
if is_visible then
|
||||||
|
table.insert(new_visible_tracks, track)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return new_mouse_tracks
|
return new_visible_tracks
|
||||||
end
|
end
|
||||||
|
|
||||||
--- 将鼠标的轨迹坐标规范到以起始点到终点所连直线为x轴的坐标系下
|
local function DrawCutMaskImage(widget, mouse_tracks)
|
||||||
local function NormalizeTrackParam(mouse_tracks)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
--- 根据指定点坐标,求解三次样条参数
|
|
||||||
local function GetSplineParams(normalize_params)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
local function UpdateCutMaskByTracks(widget, mouse_tracks)
|
|
||||||
local FVector2D = import("Vector2D")
|
local FVector2D = import("Vector2D")
|
||||||
local FWidgetTransform = import("WidgetTransform")
|
local FWidgetTransform = import("WidgetTransform")
|
||||||
if #mouse_tracks < 2 then return end
|
-- 设置图片合理的位移、旋转、缩放的参数
|
||||||
|
|
||||||
local translation, scale = FVector2D(), FVector2D()
|
local translation, scale = FVector2D(), FVector2D()
|
||||||
local render_transform = FWidgetTransform()
|
local render_transform = FWidgetTransform()
|
||||||
local first_point, last_point = mouse_tracks[1], mouse_tracks[#mouse_tracks]
|
local first_point, last_point = mouse_tracks[1], mouse_tracks[#mouse_tracks]
|
||||||
local delta_x = last_point.X - first_point.X
|
local delta_x = last_point.X - first_point.X
|
||||||
local delta_y = last_point.Y - first_point.Y
|
local delta_y = last_point.Y - first_point.Y
|
||||||
local mask_length = (delta_x^2 + delta_y^2)^0.5
|
local mask_length = (delta_x^2 + delta_y^2)^0.5 -- 轨迹长度,确定缩放参数
|
||||||
|
translation.X, translation.Y = first_point.X, first_point.Y -- 第一个点确定图片唯一
|
||||||
|
|
||||||
|
|
||||||
translation.X, translation.Y = first_point.X, first_point.Y
|
|
||||||
scale.X, scale.Y = mask_length / 512, 1
|
scale.X, scale.Y = mask_length / 512, 1
|
||||||
render_transform.Scale = scale
|
render_transform.Scale = scale
|
||||||
render_transform.Translation = translation
|
render_transform.Translation = translation
|
||||||
render_transform.Angle = (math.atan(delta_y, delta_x) / (2 * math.pi)) * 360
|
render_transform.Angle = (math.atan(delta_y, delta_x) / (2 * math.pi)) * 360 -- 第一个点与最后一个点连线确定图片旋转角度
|
||||||
-- render_transform.Scale = FVector2D(mask_length / 512, 1)
|
|
||||||
print(render_transform.Angle, math.atan(delta_y, delta_x))
|
|
||||||
|
|
||||||
widget:SetRenderTransform(render_transform)
|
widget:SetRenderTransform(render_transform)
|
||||||
--[[
|
|
||||||
|
|
||||||
/** The amount to translate the widget in slate units */
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Transform, meta=( Delta = "1" ))
|
|
||||||
FVector2D Translation;
|
|
||||||
|
|
||||||
/** The scale to apply to the widget */
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Transform, meta=( UIMin = "-5", UIMax = "5", Delta = "0.05" ))
|
|
||||||
FVector2D Scale;
|
|
||||||
|
|
||||||
/** The amount to shear the widget in slate units */
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Transform, meta=( UIMin = "-89", ClampMin = "-89", UIMax = "89", ClampMax = "89", Delta = "1" ))
|
|
||||||
FVector2D Shear;
|
|
||||||
|
|
||||||
/** The angle in degrees to rotate */
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Transform, meta=( UIMin = "-180", UIMax = "180", Delta = "1" ))
|
|
||||||
float Angle;
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- 更新刀痕的材质
|
||||||
|
local function UpdateCusMaskMaterial(widget, texture, mouse_track)
|
||||||
|
local transformed_tracks = TransformCurveToEndpointAxes(mouse_track)
|
||||||
|
local normalize_tracks = NormalizeCurveYToHalfRange(transformed_tracks)
|
||||||
|
|
||||||
|
local offsets = {}
|
||||||
|
for _, track in ipairs(normalize_tracks) do
|
||||||
|
table.insert(offsets, track.Y)
|
||||||
|
end
|
||||||
|
|
||||||
|
BusyGamePlayLibrary.UpdateTextureBuffer(texture, offsets)
|
||||||
|
|
||||||
|
local material = widget:GetDynamicMaterial()
|
||||||
|
material:SetTextureParameterValue("Param", texture)
|
||||||
|
material:SetScalarParameterValue("VertexCount", #offsets)
|
||||||
|
material:SetScalarParameterValue("SourceWidth", 512)
|
||||||
|
end
|
||||||
|
|
||||||
|
function PreCookCenterWidget:GetValidCutMaskWidget()
|
||||||
|
return self.ImgMask
|
||||||
|
end
|
||||||
|
|
||||||
|
function PreCookCenterWidget:ResetAllCutMaskWidget()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function PreCookCenterWidget:Tick(geometry, delta_time)
|
function PreCookCenterWidget:Tick(geometry, delta_time)
|
||||||
|
-- 计算鼠标点被限定在该区域下的坐标
|
||||||
|
|
||||||
local size = SlateBlueprintLibrary.GetLocalSize(geometry)
|
local size = SlateBlueprintLibrary.GetLocalSize(geometry)
|
||||||
local cursor_pos = WidgetLayoutLibrary.GetMousePositionOnViewport(self)
|
local cursor_pos = WidgetLayoutLibrary.GetMousePositionOnViewport(self)
|
||||||
local left_top = SlateBlueprintLibrary.GetLocalTopLeft(geometry)
|
local left_top = SlateBlueprintLibrary.GetLocalTopLeft(geometry)
|
||||||
local fixed_x = math.min(math.max(cursor_pos.X - left_top.X, 0), size.X)
|
|
||||||
local fixed_y = math.min(math.max(cursor_pos.Y - left_top.Y, 0), size.Y)
|
|
||||||
|
|
||||||
local mouse_tracks = UpdateOldMouseTrack(self.mouse_tracks, delta_time)
|
-- local fixed_x = math.min(math.max(cursor_pos.X - left_top.X, 0), size.X)
|
||||||
|
-- local fixed_y = math.min(math.max(cursor_pos.Y - left_top.Y, 0), size.Y)
|
||||||
|
|
||||||
|
local fixed_x, fixed_y = cursor_pos.X - left_top.X, cursor_pos.Y - left_top.Y
|
||||||
|
if fixed_x < 0 or fixed_x > size.X or fixed_y < 0 or fixed_y > size.Y then return end
|
||||||
|
|
||||||
|
|
||||||
|
-- 更新鼠标移动轨迹
|
||||||
if self.is_pressed then
|
if self.is_pressed then
|
||||||
table.insert(mouse_tracks, {X=fixed_x, Y=fixed_y, remain=0.5})
|
local last_point = self.mouse_tracks[#self.mouse_tracks]
|
||||||
|
if not last_point or math.abs(last_point.X - fixed_x) > 1 or math.abs(last_point.Y - fixed_y) > 1 then
|
||||||
|
table.insert(self.mouse_tracks, {X=fixed_x, Y=fixed_y, remain=0.5})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 计算样条参数
|
-- 更新正在渲染的轨迹数据
|
||||||
local normalize_params = NormalizeTrackParam(mouse_tracks)
|
local rendering_tracks = UpdateCutMaskData(self.rendering_tracks, delta_time)
|
||||||
local A, B, C, D = GetSplineParams(normalize_params) -- Ax^3 + Bx^2 + Cx + D
|
|
||||||
|
|
||||||
-- 计算划痕位置
|
-- 绘制刀迹
|
||||||
|
for _, track in ipairs(rendering_tracks) do
|
||||||
|
if #track > 2 then
|
||||||
|
local widget = self:GetValidCutMaskWidget()
|
||||||
|
DrawCutMaskImage(widget, track)
|
||||||
|
-- UpdateCusMaskMaterial(widget, self.DataTexture, track)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
UpdateCutMaskByTracks(self.ImgMask, mouse_tracks)
|
-- print("Ticking", #rendering_tracks)
|
||||||
|
|
||||||
self.mouse_tracks = mouse_tracks
|
self.rendering_tracks = rendering_tracks
|
||||||
|
|
||||||
|
|
||||||
-- print(fixed_x, fixed_y, #self.mouse_tracks)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- function PreCookCenterWidget:LuaMouseButtonDown()
|
|
||||||
-- print("on mouse button down")
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- function PreCookCenterWidget:LuaMouseButtonUp()
|
|
||||||
-- print("on mouse button up")
|
|
||||||
-- end
|
|
||||||
|
|
||||||
|
|
||||||
return Class(nil, nil, PreCookCenterWidget)
|
return Class(nil, nil, PreCookCenterWidget)
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -83,9 +83,26 @@ bool UBusyGamePlayLibrary::GetCookMaterialStateConfig(const FName& RowName, FBus
|
|||||||
return GetTableConfig<FBusyCookMaterialStateConfig>(TEXT("CookMaterialStateConfig"), RowName, RowData);
|
return GetTableConfig<FBusyCookMaterialStateConfig>(TEXT("CookMaterialStateConfig"), RowName, RowData);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLuaBPVar UBusyGamePlayLibrary::TestTable(const FName& RowName){
|
FLuaBPVar UBusyGamePlayLibrary::CreateTextureBuffer(UObject* WorldContextObject){
|
||||||
UDataTable* Table = UBusyGamePlayLibrary::GetGameDataTable("CookMaterialStateConfig");
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
auto Config = Table->FindRow<FTableRowBase>(RowName, "", true);
|
auto DataTexture = UTexture2D::CreateTransient(512, 1, PF_R32_FLOAT);
|
||||||
|
DataTexture->Filter = TF_Trilinear;
|
||||||
return FLuaBPVar();
|
DataTexture->AddressX = TA_Clamp;
|
||||||
|
DataTexture->AddressY = TA_Clamp;
|
||||||
|
DataTexture->UpdateResource();
|
||||||
|
return ULuaBlueprintLibrary::CreateVarFromObject(WorldContextObject, DataTexture);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UBusyGamePlayLibrary::UpdateTextureBuffer(UTexture2D *DataTexture, TArray<float> FloatData){
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>д<EFBFBD><D0B4>
|
||||||
|
DataTexture->GetPlatformData()->Mips[0];
|
||||||
|
FTexture2DMipMap& Mip = DataTexture->GetPlatformData()->Mips[0];
|
||||||
|
void* Data = Mip.BulkData.Lock(LOCK_READ_WRITE);
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
FMemory::Memcpy(Data, FloatData.GetData(), FloatData.Num() * sizeof(float));
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
Mip.BulkData.Unlock();
|
||||||
|
DataTexture->UpdateResource();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,8 @@
|
|||||||
#include "Core/PW_UserWidget.h"
|
#include "Core/PW_UserWidget.h"
|
||||||
#include "Core/UI/PW_UIHud.h"
|
#include "Core/UI/PW_UIHud.h"
|
||||||
#include "slua.h"
|
#include "slua.h"
|
||||||
|
#include "EnhancedInput/Public/EnhancedInputSubsystems.h"
|
||||||
|
#include "EnhancedInput/Public/EnhancedInputComponent.h"
|
||||||
|
|
||||||
UPW_SimpleWidget::UPW_SimpleWidget():bVisible(true){
|
UPW_SimpleWidget::UPW_SimpleWidget():bVisible(true){
|
||||||
bVisible = true;
|
bVisible = true;
|
||||||
@ -36,7 +38,6 @@ FLuaWidgetEventHandle UPW_SimpleWidget::BP_BindLuaEvent(const FName& EventName,
|
|||||||
TMap<int32, slua::LuaVar>& FunctionPool = LuaFuncMappings.FindOrAdd(EventName);
|
TMap<int32, slua::LuaVar>& FunctionPool = LuaFuncMappings.FindOrAdd(EventName);
|
||||||
HandleIndex += 1;
|
HandleIndex += 1;
|
||||||
FunctionPool.Add(HandleIndex, InLuaFunction.value);
|
FunctionPool.Add(HandleIndex, InLuaFunction.value);
|
||||||
//FunctionPool[HandleIndex] = InLuaFunction.value;
|
|
||||||
Handle.EventName = EventName;
|
Handle.EventName = EventName;
|
||||||
Handle.HandleIndex = HandleIndex;
|
Handle.HandleIndex = HandleIndex;
|
||||||
return Handle;
|
return Handle;
|
||||||
@ -65,29 +66,22 @@ void UPW_SimpleWidget::BP_EmitLuaEvent(const FName& EventName, const FLuaBPVar&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FReply UPW_SimpleWidget::NativeOnMouseButtonDown(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent){
|
void UPW_SimpleWidget::BP_BindLuaEnhancedInput(UInputAction* Action, FLuaBPVar Callback) {
|
||||||
slua::LuaVar SelfTable = GetSelfTable();
|
UEnhancedInputComponent* EnhancedInput;
|
||||||
if (SelfTable.isTable()) {
|
if (!Action) return;
|
||||||
slua::LuaVar LuaCallback = SelfTable.getFromTable<slua::LuaVar, FString>(TEXT("LuaMouseButtonDown"));
|
|
||||||
if (LuaCallback.isFunction()) {
|
EnhancedInput = CastChecked<UEnhancedInputComponent>(GetOwningPlayer()->InputComponent);
|
||||||
LuaCallback.call();
|
if (!EnhancedInput) return;
|
||||||
}
|
|
||||||
}
|
EnhancedInput->BindActionInstanceLambda(Action, ETriggerEvent::Triggered, [Callback](const FInputActionInstance& ActionInstance) {
|
||||||
return FReply::Unhandled();
|
slua::LuaVar LuaCallback = Callback.value;
|
||||||
//return Super::NativeOnMouseButtonDown(InGeometry, InMouseEvent);
|
if (!LuaCallback.isFunction()) return;
|
||||||
|
LuaCallback.call();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
FReply UPW_SimpleWidget::NativeOnMouseButtonUp(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent){
|
|
||||||
slua::LuaVar SelfTable = GetSelfTable();
|
|
||||||
if (SelfTable.isTable()) {
|
|
||||||
slua::LuaVar LuaCallback = SelfTable.getFromTable<slua::LuaVar, FString>(TEXT("LuaMouseButtonUp"));
|
|
||||||
if (LuaCallback.isFunction()) {
|
|
||||||
LuaCallback.call();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return FReply::Unhandled();
|
|
||||||
//return Super::NativeOnMouseButtonUp(InGeometry, InMouseEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UPW_UserWidget::BP_Close(){
|
void UPW_UserWidget::BP_Close(){
|
||||||
APW_UIHud* Hud = Cast<APW_UIHud>(GetPlayerContext().GetHUD());
|
APW_UIHud* Hud = Cast<APW_UIHud>(GetPlayerContext().GetHUD());
|
||||||
@ -105,12 +99,33 @@ void UPW_UserWidget::FrameWorkSetVisible(bool InVisible){
|
|||||||
_RefreshVisible();
|
_RefreshVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UPW_UserWidget::_UpdateInputState(bool bNeedRegister) {
|
||||||
|
APlayerController* PC;
|
||||||
|
UEnhancedInputLocalPlayerSubsystem* Subsystem;
|
||||||
|
|
||||||
|
if (!InputMappingContext) return;
|
||||||
|
|
||||||
|
PC = GetOwningPlayer();
|
||||||
|
if (!PC) return;
|
||||||
|
|
||||||
|
Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PC->GetLocalPlayer());
|
||||||
|
if (!Subsystem) return;
|
||||||
|
|
||||||
|
if (bNeedRegister) {
|
||||||
|
Subsystem->AddMappingContext(InputMappingContext, 0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Subsystem->RemoveMappingContext(InputMappingContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UPW_UserWidget::_RefreshVisible(){
|
void UPW_UserWidget::_RefreshVisible(){
|
||||||
bool FinalVisible = bFrameWorkVisible && bVisible;
|
bool bFinalVisible = bFrameWorkVisible && bVisible;
|
||||||
if (FinalVisible) {
|
if (bFinalVisible) {
|
||||||
SetVisibility(ESlateVisibility::SelfHitTestInvisible);
|
SetVisibility(ESlateVisibility::SelfHitTestInvisible);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SetVisibility(ESlateVisibility::Collapsed);
|
SetVisibility(ESlateVisibility::Collapsed);
|
||||||
}
|
}
|
||||||
|
_UpdateInputState(bFinalVisible);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,6 +65,7 @@ void UPW_UILayer::PopWidget(const UPW_UserWidget* WidgetInst){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < NeedRemoveWidgets.Num(); ++i) {
|
for (i = 0; i < NeedRemoveWidgets.Num(); ++i) {
|
||||||
|
NeedRemoveWidgets[i]->FrameWorkSetVisible(false);
|
||||||
NeedRemoveWidgets[i]->RemoveFromParent();
|
NeedRemoveWidgets[i]->RemoveFromParent();
|
||||||
}
|
}
|
||||||
if (NeedShowWidget) {
|
if (NeedShowWidget) {
|
||||||
|
|||||||
@ -60,6 +60,10 @@ public:
|
|||||||
static bool GetCookMaterialStateConfig(const FName& RowName, FBusyCookMaterialStateConfig& RowData);
|
static bool GetCookMaterialStateConfig(const FName& RowName, FBusyCookMaterialStateConfig& RowData);
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure)
|
UFUNCTION(BlueprintPure)
|
||||||
static FLuaBPVar TestTable(const FName& RowName);
|
static FLuaBPVar CreateTextureBuffer(UObject* WorldContextObject);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
static void UpdateTextureBuffer(UTexture2D* DataTexture, TArray<float> FloatData);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -51,10 +51,8 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void BP_EmitLuaEvent(const FName& EventName, const FLuaBPVar& InLuaArgs);
|
void BP_EmitLuaEvent(const FName& EventName, const FLuaBPVar& InLuaArgs);
|
||||||
|
|
||||||
public:
|
UFUNCTION(BlueprintCallable)
|
||||||
virtual FReply NativeOnMouseButtonDown(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent)override;
|
void BP_BindLuaEnhancedInput(class UInputAction* Action, FLuaBPVar Callback);
|
||||||
|
|
||||||
virtual FReply NativeOnMouseButtonUp(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent)override;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -73,8 +71,7 @@ protected: // lua相关
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class BUSYRABBIT_API UPW_UserWidget : public UPW_SimpleWidget
|
class BUSYRABBIT_API UPW_UserWidget : public UPW_SimpleWidget{
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
public:
|
public:
|
||||||
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, DisplayName="是否全局唯一")
|
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, DisplayName="是否全局唯一")
|
||||||
@ -84,6 +81,9 @@ public:
|
|||||||
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly)
|
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly)
|
||||||
EWidgetLayoutType LayoutType;
|
EWidgetLayoutType LayoutType;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, Category = "Input")
|
||||||
|
TObjectPtr<class UInputMappingContext> InputMappingContext;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void BP_Close();
|
void BP_Close();
|
||||||
@ -95,6 +95,8 @@ public:
|
|||||||
void FrameWorkSetVisible(bool InVisible);
|
void FrameWorkSetVisible(bool InVisible);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void _UpdateInputState(bool bNeedRegister);
|
||||||
|
|
||||||
void _RefreshVisible();
|
void _RefreshVisible();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
Reference in New Issue
Block a user