初始化提交

This commit is contained in:
2025-07-09 01:08:35 +08:00
parent d3296791cf
commit 62e0f56c60
618 changed files with 173543 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,150 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "lua_wrapper.h"
#include "lua_wrapperStyle.h"
#include "lua_wrapperCommands.h"
#include "LevelEditor.h"
#include "Widgets/Docking/SDockTab.h"
#include "Widgets/Layout/SBox.h"
#include "Widgets/Text/STextBlock.h"
#include "Widgets/Input/SEditableTextBox.h"
#include "Framework/MultiBox/MultiBoxBuilder.h"
#include "HAL/FileManager.h"
#ifndef _MSC_VER
#include <iostream>
#include <stdexcept>
#include <stdio.h>
#include <string>
#include <unistd.h>
#endif
static const FName lua_wrapperTabName("LuaWrapper");
#define LOCTEXT_NAMESPACE "Flua_wrapperModule"
void Flua_wrapperModule::StartupModule()
{
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
Flua_wrapperStyle::Initialize();
Flua_wrapperStyle::ReloadTextures();
Flua_wrapperCommands::Register();
PluginCommands = MakeShareable(new FUICommandList);
PluginCommands->MapAction(
Flua_wrapperCommands::Get().OpenPluginWindow,
FExecuteAction::CreateRaw(this, &Flua_wrapperModule::PluginButtonClicked),
FCanExecuteAction());
FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
{
TSharedPtr<FExtender> MenuExtender = MakeShareable(new FExtender());
MenuExtender->AddMenuExtension("WindowLayout", EExtensionHook::After, PluginCommands, FMenuExtensionDelegate::CreateRaw(this, &Flua_wrapperModule::AddMenuExtension));
LevelEditorModule.GetMenuExtensibilityManager()->AddExtender(MenuExtender);
}
{
TSharedPtr<FExtender> ToolbarExtender = MakeShareable(new FExtender);
ToolbarExtender->AddToolBarExtension("Settings", EExtensionHook::After, PluginCommands, FToolBarExtensionDelegate::CreateRaw(this, &Flua_wrapperModule::AddToolbarExtension));
LevelEditorModule.GetToolBarExtensibilityManager()->AddExtender(ToolbarExtender);
}
FGlobalTabmanager::Get()->RegisterNomadTabSpawner(lua_wrapperTabName, FOnSpawnTab::CreateRaw(this, &Flua_wrapperModule::OnSpawnPluginTab))
.SetDisplayName(LOCTEXT("Flua_wrapperTabTitle", "lua_wrapper"))
.SetMenuType(ETabSpawnerMenuType::Hidden);
}
void Flua_wrapperModule::ShutdownModule()
{
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
// we call this function before unloading the module.
Flua_wrapperStyle::Shutdown();
Flua_wrapperCommands::Unregister();
FGlobalTabmanager::Get()->UnregisterNomadTabSpawner(lua_wrapperTabName);
}
TSharedRef<SDockTab> Flua_wrapperModule::OnSpawnPluginTab(const FSpawnTabArgs& SpawnTabArgs)
{
FText WidgetText = FText::Format(
LOCTEXT("WindowWidgetText", "Add code to {0} in {1} to override this window's contents"),
FText::FromString(TEXT("Flua_wrapperModule::OnSpawnPluginTab")),
FText::FromString(TEXT("lua_wrapper.cpp"))
);
return SNew(SDockTab)
.TabRole(ETabRole::NomadTab)
[
// Put your tab content here!
SNew(SBox)
.HAlign(HAlign_Left)
.VAlign(VAlign_Top)
[
SNew(SVerticalBox)
+ SVerticalBox::Slot()[
SNew(STextBlock)
.Text(WidgetText)
]
]
];
}
#ifndef _MSC_VER
std::string exec(const char* cmd) {
char buffer[128];
std::string result = "";
FILE* f = popen(cmd, "r");
if (!f) {
return "popen() failed...";
}
try {
while (!feof(f)) {
if (fgets(buffer, 128, f) != NULL) {
result += buffer;
}
}
} catch (...) {
pclose(f);
return "run cmd failed...";
}
pclose(f);
return result;
}
#endif
void Flua_wrapperModule::PluginButtonClicked()
{
//FGlobalTabmanager::Get()->InvokeTab(lua_wrapperTabName);
#ifdef _MSC_VER
auto contentDir = IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*FPaths::ProjectContentDir());
auto cmd = contentDir + TEXT("/../Tools/lua-wrapper.exe");
system(TCHAR_TO_UTF8(*cmd));
#else
auto contentDir = IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*FPaths::ProjectContentDir());
auto toolsDir = contentDir + TEXT("../Tools/");
chdir(TCHAR_TO_UTF8(*toolsDir));
auto ret = exec("/Library/Frameworks/Mono.framework/Versions/Current/Commands/mono lua-wrapper.exe");
GEngine->AddOnScreenDebugMessage(-1, 30.0f, FColor::Red, ret.c_str());
#endif
}
void Flua_wrapperModule::AddMenuExtension(FMenuBuilder& Builder)
{
Builder.AddMenuEntry(Flua_wrapperCommands::Get().OpenPluginWindow);
}
void Flua_wrapperModule::AddToolbarExtension(FToolBarBuilder& Builder)
{
Builder.AddToolBarButton(Flua_wrapperCommands::Get().OpenPluginWindow);
}
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(Flua_wrapperModule, lua_wrapper)

View File

@ -0,0 +1,12 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "lua_wrapperCommands.h"
#define LOCTEXT_NAMESPACE "Flua_wrapperModule"
void Flua_wrapperCommands::RegisterCommands()
{
UI_COMMAND(OpenPluginWindow, "LuaWrapper", "Generate Lua Interface (Windows only)", EUserInterfaceActionType::Button, FInputGesture());
}
#undef LOCTEXT_NAMESPACE

View File

@ -0,0 +1,70 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "lua_wrapperStyle.h"
#include "Styling/SlateStyleRegistry.h"
#include "Framework/Application/SlateApplication.h"
#include "Slate/SlateGameResources.h"
#include "Interfaces/IPluginManager.h"
TSharedPtr< FSlateStyleSet > Flua_wrapperStyle::StyleInstance = NULL;
void Flua_wrapperStyle::Initialize()
{
if (!StyleInstance.IsValid())
{
StyleInstance = Create();
FSlateStyleRegistry::RegisterSlateStyle(*StyleInstance);
}
}
void Flua_wrapperStyle::Shutdown()
{
FSlateStyleRegistry::UnRegisterSlateStyle(*StyleInstance);
ensure(StyleInstance.IsUnique());
StyleInstance.Reset();
}
FName Flua_wrapperStyle::GetStyleSetName()
{
static FName StyleSetName(TEXT("lua_wrapperStyle"));
return StyleSetName;
}
#define IMAGE_BRUSH( RelativePath, ... ) FSlateImageBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ )
#define BOX_BRUSH( RelativePath, ... ) FSlateBoxBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ )
#define BORDER_BRUSH( RelativePath, ... ) FSlateBorderBrush( Style->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ )
#define TTF_FONT( RelativePath, ... ) FSlateFontInfo( Style->RootToContentDir( RelativePath, TEXT(".ttf") ), __VA_ARGS__ )
#define OTF_FONT( RelativePath, ... ) FSlateFontInfo( Style->RootToContentDir( RelativePath, TEXT(".otf") ), __VA_ARGS__ )
const FVector2D Icon16x16(16.0f, 16.0f);
const FVector2D Icon20x20(20.0f, 20.0f);
const FVector2D Icon40x40(40.0f, 40.0f);
TSharedRef< FSlateStyleSet > Flua_wrapperStyle::Create()
{
TSharedRef< FSlateStyleSet > Style = MakeShareable(new FSlateStyleSet("lua_wrapperStyle"));
Style->SetContentRoot(IPluginManager::Get().FindPlugin("lua_wrapper")->GetBaseDir() / TEXT("Resources"));
Style->Set("lua_wrapper.OpenPluginWindow", new IMAGE_BRUSH(TEXT("ButtonIcon_40x"), Icon40x40));
return Style;
}
#undef IMAGE_BRUSH
#undef BOX_BRUSH
#undef BORDER_BRUSH
#undef TTF_FONT
#undef OTF_FONT
void Flua_wrapperStyle::ReloadTextures()
{
if (FSlateApplication::IsInitialized())
{
FSlateApplication::Get().GetRenderer()->ReloadTextureResources();
}
}
const ISlateStyle& Flua_wrapperStyle::Get()
{
return *StyleInstance;
}

View File

@ -0,0 +1,31 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"
class FToolBarBuilder;
class FMenuBuilder;
class Flua_wrapperModule : public IModuleInterface
{
public:
/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
/** This function will be bound to Command (by default it will bring up plugin window) */
void PluginButtonClicked();
private:
void AddToolbarExtension(FToolBarBuilder& Builder);
void AddMenuExtension(FMenuBuilder& Builder);
TSharedRef<class SDockTab> OnSpawnPluginTab(const class FSpawnTabArgs& SpawnTabArgs);
private:
TSharedPtr<class FUICommandList> PluginCommands;
};

View File

@ -0,0 +1,23 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Framework/Commands/Commands.h"
#include "lua_wrapperStyle.h"
class Flua_wrapperCommands : public TCommands<Flua_wrapperCommands>
{
public:
Flua_wrapperCommands()
: TCommands<Flua_wrapperCommands>(TEXT("lua_wrapper"), NSLOCTEXT("Contexts", "lua_wrapper", "lua_wrapper Plugin"), NAME_None, Flua_wrapperStyle::GetStyleSetName())
{
}
// TCommands<> interface
virtual void RegisterCommands() override;
public:
TSharedPtr< FUICommandInfo > OpenPluginWindow;
};

View File

@ -0,0 +1,32 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Styling/SlateStyle.h"
/** */
class Flua_wrapperStyle
{
public:
static void Initialize();
static void Shutdown();
/** reloads textures used by slate renderer */
static void ReloadTextures();
/** @return The Slate style set for the Shooter game */
static const ISlateStyle& Get();
static FName GetStyleSetName();
private:
static TSharedRef< class FSlateStyleSet > Create();
private:
static TSharedPtr< class FSlateStyleSet > StyleInstance;
};

View File

@ -0,0 +1,60 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
using System.IO;
public class lua_wrapper : ModuleRules
{
public lua_wrapper(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
PublicIncludePaths.AddRange(
new string[] {
Path.Combine(ModuleDirectory, "Public")
// ... add public include paths required here ...
}
);
PrivateIncludePaths.AddRange(
new string[] {
Path.Combine(ModuleDirectory, "Private"),
// ... add other private include paths required here ...
}
);
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
// ... add other public dependencies that you statically link with here ...
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
"Projects",
"InputCore",
"UnrealEd",
"LevelEditor",
"CoreUObject",
"Engine",
"Slate",
"SlateCore",
// ... add private dependencies that you statically link with here ...
}
);
DynamicallyLoadedModuleNames.AddRange(
new string[]
{
// ... add any modules that your module loads dynamically here ...
}
);
}
}

View File

@ -0,0 +1,23 @@
{
"FileVersion": 3,
"Version": 1,
"VersionName": "1.0",
"FriendlyName": "lua_wrapper",
"Description": "lua wrapper",
"Category": "Other",
"CreatedBy": "leeyi",
"CreatedByURL": "",
"DocsURL": "",
"MarketplaceURL": "",
"SupportURL": "",
"CanContainContent": false,
"IsBetaVersion": false,
"Installed": false,
"Modules": [
{
"Name": "lua_wrapper",
"Type": "Editor",
"LoadingPhase": "Default"
}
]
}