准备制作食材预处理流程,为lua直接读data table做基建
...
This commit is contained in:
@ -7,6 +7,9 @@
|
||||
#include "LuaCppBinding.h"
|
||||
#include "GameplayTagsManager.h"
|
||||
|
||||
extern void RegisterDataTableExtension();
|
||||
|
||||
|
||||
static uint8* ReadFile(IPlatformFile& PlatformFile, FString path, uint32& len) {
|
||||
IFileHandle* FileHandle = PlatformFile.OpenRead(*path);
|
||||
if (FileHandle) {
|
||||
@ -94,6 +97,8 @@ void UBusyGameInstance::LuaStateInitCallback(NS_SLUA::lua_State* L) {
|
||||
LuaGameInstance = state->doFile("GameInstance");
|
||||
LuaGameInstance.getFromTable("OnEndFrame", OnLuaEndFrame);
|
||||
|
||||
// ע<><D7A2>extension
|
||||
RegisterDataTableExtension();
|
||||
}
|
||||
|
||||
void UBusyGameInstance::OnEndFrame(){
|
||||
|
||||
@ -2,8 +2,10 @@
|
||||
|
||||
|
||||
#include "Core/PW_UserWidget.h"
|
||||
#include "Core/UI/PW_UIHud.h"
|
||||
|
||||
UPW_SimpleWidget::UPW_SimpleWidget():bVisible(true){
|
||||
bVisible = true;
|
||||
SetVisibility(ESlateVisibility::SelfHitTestInvisible);
|
||||
}
|
||||
|
||||
@ -11,9 +13,9 @@ bool UPW_SimpleWidget::Initialize(){
|
||||
return UUserWidget::Initialize();
|
||||
}
|
||||
|
||||
void UPW_SimpleWidget::SetVisible(bool Visible){
|
||||
if (bVisible == Visible) { return; }
|
||||
if ((bVisible = Visible)) {
|
||||
void UPW_SimpleWidget::SetVisible(bool InVisible){
|
||||
if (bVisible == InVisible) { return; }
|
||||
if ((bVisible = InVisible)) {
|
||||
SetVisibility(ESlateVisibility::SelfHitTestInvisible);
|
||||
}
|
||||
else {
|
||||
@ -21,4 +23,32 @@ void UPW_SimpleWidget::SetVisible(bool Visible){
|
||||
}
|
||||
}
|
||||
|
||||
void UPW_SimpleWidget::BP_SetVisible(bool InVisible){
|
||||
SetVisible(InVisible);
|
||||
}
|
||||
|
||||
void UPW_UserWidget::BP_Close(){
|
||||
APW_UIHud* Hud = Cast<APW_UIHud>(GetPlayerContext().GetHUD());
|
||||
if (!Hud) return;
|
||||
Hud->PopWidget(this);
|
||||
}
|
||||
|
||||
void UPW_UserWidget::SetVisible(bool InVisible){
|
||||
bVisible = InVisible;
|
||||
_RefreshVisible();
|
||||
}
|
||||
|
||||
void UPW_UserWidget::FrameWorkSetVisible(bool InVisible){
|
||||
bFrameWorkVisible = InVisible;
|
||||
_RefreshVisible();
|
||||
}
|
||||
|
||||
void UPW_UserWidget::_RefreshVisible(){
|
||||
bool FinalVisible = bFrameWorkVisible && bVisible;
|
||||
if (FinalVisible) {
|
||||
SetVisibility(ESlateVisibility::SelfHitTestInvisible);
|
||||
}
|
||||
else {
|
||||
SetVisibility(ESlateVisibility::Collapsed);
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ UPW_UserWidget* APW_UIHud::PushWidget(const FName& WidgetName) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (UILayer->PushWidget(WidgetName, Inst)) {
|
||||
if (UILayer->PushWidget(Inst)) {
|
||||
return Inst;
|
||||
}
|
||||
else {
|
||||
@ -35,28 +35,15 @@ UPW_UserWidget* APW_UIHud::PushWidget(const FName& WidgetName) {
|
||||
}
|
||||
}
|
||||
|
||||
bool APW_UIHud::PopWidget(const FName& WidgetName){
|
||||
if (UILayer == nullptr) {
|
||||
return false;
|
||||
UPW_UserWidget* APW_UIHud::PushWidget(UPW_UserWidget* WidgetInst){
|
||||
if (UILayer && WidgetInst) {
|
||||
return UILayer->PushWidget(WidgetInst) ? WidgetInst : nullptr;
|
||||
}
|
||||
return UILayer->PopWidget(WidgetName);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UPW_UserWidget* APW_UIHud::ShowWidget(const FName& WidgetName){
|
||||
UPW_UserWidget* Widget;
|
||||
if (!UILayer) {
|
||||
return nullptr;
|
||||
void APW_UIHud::PopWidget(const UPW_UserWidget* WidgetInst){
|
||||
if (UILayer) {
|
||||
UILayer->PopWidget(WidgetInst);
|
||||
}
|
||||
if ((Widget = UILayer->ShowWidget(WidgetName))) {
|
||||
return Widget;
|
||||
}
|
||||
return PushWidget(WidgetName);
|
||||
}
|
||||
|
||||
bool APW_UIHud::HideWidget(const FName& WidgetName){
|
||||
if (UILayer == nullptr) {
|
||||
return false;
|
||||
}
|
||||
return UILayer->PopWidget(WidgetName);
|
||||
}
|
||||
|
||||
|
||||
60
Source/BusyRabbit/Private/CppBindings/DataTableBindings.cpp
Normal file
60
Source/BusyRabbit/Private/CppBindings/DataTableBindings.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
#include "LuaCppBinding.h"
|
||||
|
||||
using namespace slua;
|
||||
|
||||
//static int LuaBinding_FindRow(lua_State* L) {
|
||||
// UDataTable* DataTable = LuaObject::checkUD<UDataTable>(L, 1);
|
||||
// FName RowName = LuaObject::checkValue<FName>(L, 2);
|
||||
//
|
||||
// UScriptStruct* RowStruct = (UScriptStruct*)DataTable->GetRowStruct();
|
||||
//
|
||||
// uint8* RowData = DataTable->FindRowUnchecked(RowName);
|
||||
//
|
||||
// if (RowData && RowStruct) {
|
||||
// // <20><><EFBFBD><EFBFBD> LuaStruct <20><>װ<EFBFBD><D7B0>
|
||||
// uint32 size = RowStruct->GetStructureSize() ? RowStruct->GetStructureSize() : 1;
|
||||
// uint8* buf = (uint8*)FMemory::Malloc(size);
|
||||
// RowStruct->InitializeStruct(buf);
|
||||
// RowStruct->CopyScriptStruct(buf, RowData);
|
||||
//
|
||||
// LuaStruct* ls = new LuaStruct();
|
||||
// ls->Init(buf, size, RowStruct, false);
|
||||
// return LuaObject::push(L, ls);
|
||||
// }
|
||||
// else {
|
||||
// return LuaObject::pushNil(L);
|
||||
// }
|
||||
//}
|
||||
|
||||
static int LuaBinding_FindRow(lua_State* L) {
|
||||
UDataTable* DataTable = LuaObject::checkUD<UDataTable>(L, 1);
|
||||
FName RowName = LuaObject::checkValue<FName>(L, 2);
|
||||
|
||||
FTableRowBase* TableRow = DataTable->FindRow<FTableRowBase>(RowName, TEXT(""));
|
||||
|
||||
const UScriptStruct* rowStruct = DataTable->GetRowStruct();
|
||||
|
||||
LuaStruct* luaStruct = new LuaStruct();
|
||||
luaStruct->Init((uint8*)TableRow, rowStruct->GetStructureSize(), (UScriptStruct*)rowStruct, true);
|
||||
|
||||
LuaObject::addLink(L, TableRow); // ȷ<><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
//auto ret = LuaObject::push(L, luaStruct);
|
||||
return LuaObject::pushReference<LuaStruct*>(L, luaStruct, TableRow);
|
||||
}
|
||||
|
||||
|
||||
//FTableRowBase* tableRow = DataTable->FindRow<FTableRowBase>(RowName, TEXT(""));
|
||||
//
|
||||
//UScriptStruct* rowStruct = DataTable->GetRowStruct();
|
||||
//
|
||||
//LuaStruct* luaStruct = new LuaStruct();
|
||||
//luaStruct->Init((uint8*)tableRow, rowStruct->GetStructureSize(), rowStruct, true);
|
||||
//
|
||||
//int ret = LuaObject::push(L, luaStruct);
|
||||
|
||||
|
||||
|
||||
extern void RegisterDataTableExtension() {
|
||||
REG_EXTENSION_METHOD_IMP(UDataTable, "FindRow", { return LuaBinding_FindRow(L); });
|
||||
}
|
||||
@ -11,6 +11,7 @@
|
||||
#include "BusyActorManagerSubSystem.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "GameAsset/BusyItem.h"
|
||||
#include "LuaBlueprintLibrary.h"
|
||||
#include "BusyGamePlayLibrary.generated.h"
|
||||
|
||||
/**
|
||||
@ -57,4 +58,8 @@ public:
|
||||
|
||||
UFUNCTION(BlueprintPure)
|
||||
static bool GetCookMaterialStateConfig(const FName& RowName, FBusyCookMaterialStateConfig& RowData);
|
||||
|
||||
UFUNCTION(BlueprintPure)
|
||||
static FLuaBPVar TestTable(const FName& RowName);
|
||||
|
||||
};
|
||||
|
||||
Binary file not shown.
@ -28,12 +28,14 @@ public:
|
||||
virtual bool Initialize() override;
|
||||
|
||||
public:
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
bool bVisible;
|
||||
virtual void SetVisible(bool InVisible);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void BP_SetVisible(bool InVisible);
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetVisible(bool Visible);
|
||||
UPROPERTY(BlueprintReadOnly)
|
||||
bool bVisible;
|
||||
};
|
||||
|
||||
|
||||
@ -52,4 +54,21 @@ public:
|
||||
public:
|
||||
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly)
|
||||
EWidgetLayoutType LayoutType;
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void BP_Close();
|
||||
|
||||
public:
|
||||
virtual void SetVisible(bool InVisible)override;
|
||||
|
||||
public:
|
||||
void FrameWorkSetVisible(bool InVisible);
|
||||
|
||||
protected:
|
||||
void _RefreshVisible();
|
||||
|
||||
protected:
|
||||
bool bFrameWorkVisible; // 框架控制的显隐,高优先级
|
||||
|
||||
};
|
||||
|
||||
@ -17,16 +17,17 @@ class BUSYRABBIT_API APW_UIHud : public AHUD, public ILuaOverriderInterface {
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
UPW_UserWidget* BP_PushWidget(const FName& WidgetName) { return PushWidget(WidgetName); }
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void BP_PopWidget(const UPW_UserWidget* WidgetInst) { PopWidget(WidgetInst); }
|
||||
|
||||
public:
|
||||
UPW_UserWidget* PushWidget(const FName& WidgetName);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
bool PopWidget(const FName& WidgetName);
|
||||
UPW_UserWidget* PushWidget(UPW_UserWidget* WidgetInst);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
UPW_UserWidget* ShowWidget(const FName& WidgetName);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
bool HideWidget(const FName& WidgetName);
|
||||
void PopWidget(const UPW_UserWidget* WidgetInst);
|
||||
|
||||
public:
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
|
||||
@ -17,13 +17,12 @@ class BUSYRABBIT_API UPW_UILayer : public UPW_UserWidget
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPW_UserWidget* ShowWidget(const FName& WidgetName);
|
||||
bool PushWidget(UPW_UserWidget* WidgetInst);
|
||||
|
||||
bool HideWidget(const FName& WidgetName);
|
||||
void PopWidget(const UPW_UserWidget* WidgetInst);
|
||||
|
||||
bool PushWidget(const FName& WidgetName, UPW_UserWidget* WidgetInst);
|
||||
|
||||
bool PopWidget(const FName& WidgetName);
|
||||
protected:
|
||||
UOverlay* _GetOverlayByLayerType(EWidgetLayoutType InLayoutType);
|
||||
|
||||
|
||||
protected:
|
||||
@ -39,6 +38,4 @@ protected:
|
||||
UPROPERTY(BlueprintReadOnly, meta = (BindWidget))
|
||||
TObjectPtr<UOverlay> TopLayer;
|
||||
|
||||
protected:
|
||||
TMap<FName, UPW_UserWidget*> WidgetPool;
|
||||
};
|
||||
|
||||
23
Source/BusyRabbit/Public/Tables/BusyPreCookTable.h
Normal file
23
Source/BusyRabbit/Public/Tables/BusyPreCookTable.h
Normal file
@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/Texture2D.h"
|
||||
#include "BusyPreCookTable.generated.h"
|
||||
|
||||
|
||||
USTRUCT()
|
||||
struct FBusyPreCookItemConfig: public FTableRowBase {
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "名称")
|
||||
FText Name;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "描述")
|
||||
FText Desc;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "备注")
|
||||
FString Description;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "用于显示的资源")
|
||||
TSoftObjectPtr<UTexture2D> DisplayResource;
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user