Skip to content

Commit

Permalink
added support for 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
rdeioris committed May 14, 2023
1 parent eb82e53 commit b378f0d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion LuaMachine.uplugin
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"FileVersion": 3,
"Version": 1,
"VersionName": "20221203",
"VersionName": "20230514",
"FriendlyName": "LuaMachine",
"Description": "Expose a Lua api for your project",
"Category": "Scripting",
Expand Down
11 changes: 11 additions & 0 deletions Source/LuaMachine/Private/LuaMultiLineEditableTextBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@

#define LOCTEXT_NAMESPACE "UMG"

#if ENGINE_MAJOR_VERSION >=5 && ENGINE_MINOR_VERSION >= 2
static FEditableTextBoxStyle EditableTextBoxStyle;
#endif

FLuaCustomHighlighter::FLuaCustomHighlighter()
{
Color = FLinearColor::White;
}

ULuaMultiLineEditableTextBox::ULuaMultiLineEditableTextBox()
{
#if ENGINE_MAJOR_VERSION >=5 && ENGINE_MINOR_VERSION >= 2
EditableTextBoxStyle.SetTextStyle(CodeStyle);
#endif

SEditableTextBox::FArguments Defaults;
WidgetStyle = *Defaults._Style;
Expand Down Expand Up @@ -213,7 +220,11 @@ TSharedRef<SWidget> ULuaMultiLineEditableTextBox::RebuildWidget()

EditableTextBoxPtr = SNew(SMultiLineEditableTextBox)
.Marshaller(FLuaMachineSyntaxHighlighterTextLayoutMarshaller::Create(Style))
#if ENGINE_MAJOR_VERSION >=5 && ENGINE_MINOR_VERSION >= 2
.Style(&EditableTextBoxStyle)
#else
.TextStyle(&CodeStyle)
#endif
.OnKeyCharHandler_UObject(this, &ULuaMultiLineEditableTextBox::OnKeyChar)
.OnKeyDownHandler_UObject(this, &ULuaMultiLineEditableTextBox::OnKeyDown)
.IsReadOnly(bIsReadonly)
Expand Down
34 changes: 20 additions & 14 deletions Source/LuaMachineEditor/Private/LuaMachineEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
#define LOCTEXT_NAMESPACE "FLuaMachineEditorModule"

FLuaMachineEditorModule::FLuaMachineEditorModule()
: LuaMachineAssetCategoryBit( EAssetTypeCategories::Misc )
: LuaMachineAssetCategoryBit(EAssetTypeCategories::Misc)
{

}

void FLuaMachineEditorModule::StartupModule()
{
FCoreDelegates::OnPostEngineInit.AddRaw( this, &FLuaMachineEditorModule::OnPostEngineInit );
FCoreDelegates::OnPostEngineInit.AddRaw(this, &FLuaMachineEditorModule::OnPostEngineInit);

// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module

Expand Down Expand Up @@ -67,29 +67,35 @@ void FLuaMachineEditorModule::StartupModule()
FGlobalTabmanager::Get()->RegisterNomadTabSpawner("LuaMachineDebugger", FOnSpawnTab::CreateStatic(&FLuaMachineEditorModule::CreateLuaMachineDebugger))
.SetDisplayName(LOCTEXT("LuaMachine Debugger", "LuaMachine Debugger"))
.SetTooltipText(LOCTEXT("Open the LuaMachine Debugger", "Open the LuaMachine Debugger"))
.SetIcon(FSlateIcon(FEditorStyle::GetStyleSetName(), "DebugTools.TabIcon"))
.SetIcon(FSlateIcon(
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2
FAppStyle::GetAppStyleSetName()
#else
FEditorStyle::GetStyleSetName()
#endif
, "DebugTools.TabIcon"))
.SetGroup(WorkspaceMenu::GetMenuStructure().GetDeveloperToolsMiscCategory());
}

void FLuaMachineEditorModule::OnPostEngineInit()
{
IAssetTools& AssetTools = FModuleManager::LoadModuleChecked<FAssetToolsModule>( "AssetTools" ).Get();
IAssetTools& AssetTools = FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools").Get();

LuaMachineAssetCategoryBit = AssetTools.RegisterAdvancedAssetCategory( FName( TEXT( "LuaMachine" ) ), LOCTEXT( "AssetCategory", "Lua Machine" ) );
LuaMachineAssetCategoryBit = AssetTools.RegisterAdvancedAssetCategory(FName(TEXT("LuaMachine")), LOCTEXT("AssetCategory", "Lua Machine"));

//Add LuaCode to Filters.
RegisterAssetTypeAction( AssetTools, MakeShareable( new FLuaCodeAssetTypeActions( LuaMachineAssetCategoryBit ) ) );
RegisterAssetTypeAction(AssetTools, MakeShareable(new FLuaCodeAssetTypeActions(LuaMachineAssetCategoryBit)));
}

TSharedPtr<FSlateStyleSet> FLuaMachineEditorModule::GetStyleSet()
{
return StyleSet;
}

void FLuaMachineEditorModule::RegisterAssetTypeAction( IAssetTools& AssetTools, TSharedRef<IAssetTypeActions> Action )
void FLuaMachineEditorModule::RegisterAssetTypeAction(IAssetTools& AssetTools, TSharedRef<IAssetTypeActions> Action)
{
AssetTools.RegisterAssetTypeActions( Action );
CreatedAssetTypeActions.Add( Action );
AssetTools.RegisterAssetTypeActions(Action);
CreatedAssetTypeActions.Add(Action);
}

struct FTableViewLuaValue : public TSharedFromThis<FTableViewLuaValue>
Expand Down Expand Up @@ -512,15 +518,15 @@ TSharedRef<SDockTab> FLuaMachineEditorModule::CreateLuaMachineDebugger(const FSp

void FLuaMachineEditorModule::ShutdownModule()
{
FCoreDelegates::OnPostEngineInit.RemoveAll( this );
FCoreDelegates::OnPostEngineInit.RemoveAll(this);

// Unregister all the asset types that we registered
if ( FModuleManager::Get().IsModuleLoaded( "AssetTools" ) )
if (FModuleManager::Get().IsModuleLoaded("AssetTools"))
{
IAssetTools& AssetTools = FModuleManager::GetModuleChecked<FAssetToolsModule>( "AssetTools" ).Get();
for ( int32 Index = 0; Index < CreatedAssetTypeActions.Num(); ++Index )
IAssetTools& AssetTools = FModuleManager::GetModuleChecked<FAssetToolsModule>("AssetTools").Get();
for (int32 Index = 0; Index < CreatedAssetTypeActions.Num(); ++Index)
{
AssetTools.UnregisterAssetTypeActions( CreatedAssetTypeActions[Index].ToSharedRef() );
AssetTools.UnregisterAssetTypeActions(CreatedAssetTypeActions[Index].ToSharedRef());
}
}
CreatedAssetTypeActions.Empty();
Expand Down

0 comments on commit b378f0d

Please sign in to comment.