刀光预研
初步实现了刀光交互效果
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
|
||||
#include "Core/PW_UserWidget.h"
|
||||
#include "Core/UI/PW_UIHud.h"
|
||||
#include "slua.h"
|
||||
|
||||
UPW_SimpleWidget::UPW_SimpleWidget():bVisible(true){
|
||||
bVisible = true;
|
||||
@ -27,6 +28,67 @@ void UPW_SimpleWidget::BP_SetVisible(bool InVisible){
|
||||
SetVisible(InVisible);
|
||||
}
|
||||
|
||||
FLuaWidgetEventHandle UPW_SimpleWidget::BP_BindLuaEvent(const FName& EventName, const FLuaBPVar& InLuaFunction){
|
||||
FLuaWidgetEventHandle Handle;
|
||||
if (!InLuaFunction.value.isFunction()) {
|
||||
return Handle;
|
||||
}
|
||||
TMap<int32, slua::LuaVar>& FunctionPool = LuaFuncMappings.FindOrAdd(EventName);
|
||||
HandleIndex += 1;
|
||||
FunctionPool.Add(HandleIndex, InLuaFunction.value);
|
||||
//FunctionPool[HandleIndex] = InLuaFunction.value;
|
||||
Handle.EventName = EventName;
|
||||
Handle.HandleIndex = HandleIndex;
|
||||
return Handle;
|
||||
}
|
||||
|
||||
|
||||
void UPW_SimpleWidget::BP_UnBindLuaEvent(const FLuaWidgetEventHandle &InHandle){
|
||||
TMap<int32, slua::LuaVar>* FunctionPool = LuaFuncMappings.Find(InHandle.EventName);
|
||||
if (FunctionPool == nullptr) {
|
||||
return;
|
||||
}
|
||||
FunctionPool->Remove(InHandle.HandleIndex);
|
||||
}
|
||||
|
||||
void UPW_SimpleWidget::BP_EmitLuaEvent(const FName& EventName, const FLuaBPVar& InLuaArgs){
|
||||
TMap<int32, slua::LuaVar>* FunctionPool = LuaFuncMappings.Find(EventName);
|
||||
if (FunctionPool == nullptr) {
|
||||
return;
|
||||
}
|
||||
for (auto &Pair : *FunctionPool) {
|
||||
slua::LuaVar& Callback = Pair.Value;
|
||||
if (!Callback.isFunction()) {
|
||||
continue;
|
||||
}
|
||||
Callback.call(InLuaArgs.value);
|
||||
}
|
||||
}
|
||||
|
||||
FReply UPW_SimpleWidget::NativeOnMouseButtonDown(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent){
|
||||
slua::LuaVar SelfTable = GetSelfTable();
|
||||
if (SelfTable.isTable()) {
|
||||
slua::LuaVar LuaCallback = SelfTable.getFromTable<slua::LuaVar, FString>(TEXT("LuaMouseButtonDown"));
|
||||
if (LuaCallback.isFunction()) {
|
||||
LuaCallback.call();
|
||||
}
|
||||
}
|
||||
return FReply::Unhandled();
|
||||
//return Super::NativeOnMouseButtonDown(InGeometry, InMouseEvent);
|
||||
}
|
||||
|
||||
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(){
|
||||
APW_UIHud* Hud = Cast<APW_UIHud>(GetPlayerContext().GetHUD());
|
||||
if (!Hud) return;
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "LuaUserWidget.h"
|
||||
#include "LuaBlueprintLibrary.h"
|
||||
#include "PW_UserWidget.generated.h"
|
||||
|
||||
UENUM(BlueprintType)
|
||||
@ -16,6 +17,14 @@ enum class EWidgetLayoutType: uint8 {
|
||||
};
|
||||
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FLuaWidgetEventHandle {
|
||||
GENERATED_BODY()
|
||||
FName EventName;
|
||||
int32 HandleIndex;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -33,9 +42,29 @@ public:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void BP_SetVisible(bool InVisible);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
FLuaWidgetEventHandle BP_BindLuaEvent(const FName& EventName, const FLuaBPVar& InLuaFunction);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void BP_UnBindLuaEvent(const FLuaWidgetEventHandle& InHandle);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void BP_EmitLuaEvent(const FName& EventName, const FLuaBPVar& InLuaArgs);
|
||||
|
||||
public:
|
||||
virtual FReply NativeOnMouseButtonDown(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent)override;
|
||||
|
||||
virtual FReply NativeOnMouseButtonUp(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent)override;
|
||||
|
||||
|
||||
public:
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
bool bVisible;
|
||||
|
||||
|
||||
protected: // lua相关
|
||||
int32 HandleIndex = 0;
|
||||
TMap<FName, TMap<int32, slua::LuaVar>> LuaFuncMappings;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -3,8 +3,16 @@
|
||||
#include "Engine/Texture2D.h"
|
||||
#include "BusyPreCookTable.generated.h"
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EPreCookSlotType: uint8{
|
||||
PreCookTool = 0,
|
||||
PreCookContainer = 1,
|
||||
PreCookRawMaterial = 2,
|
||||
PreCookFinishedMaterial = 3
|
||||
};
|
||||
|
||||
USTRUCT()
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FBusyPreCookItemConfig: public FTableRowBase {
|
||||
GENERATED_BODY()
|
||||
|
||||
@ -20,4 +28,7 @@ struct FBusyPreCookItemConfig: public FTableRowBase {
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "用于显示的资源")
|
||||
TSoftObjectPtr<UTexture2D> DisplayResource;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "放在中心时的资源")
|
||||
TSoftObjectPtr<UTexture2D> CenterDisplayResource;
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user