diff --git a/LuaMachine.uplugin b/LuaMachine.uplugin index c4bef5c..80b2dba 100644 --- a/LuaMachine.uplugin +++ b/LuaMachine.uplugin @@ -1,7 +1,7 @@ { "FileVersion": 3, "Version": 1, - "VersionName": "20221203", + "VersionName": "20230514", "FriendlyName": "LuaMachine", "Description": "Expose a Lua api for your project", "Category": "Scripting", diff --git a/Source/LuaMachine/Private/LuaMultiLineEditableTextBox.cpp b/Source/LuaMachine/Private/LuaMultiLineEditableTextBox.cpp index ca373dd..d826f80 100644 --- a/Source/LuaMachine/Private/LuaMultiLineEditableTextBox.cpp +++ b/Source/LuaMachine/Private/LuaMultiLineEditableTextBox.cpp @@ -7,6 +7,10 @@ #define LOCTEXT_NAMESPACE "UMG" +#if ENGINE_MAJOR_VERSION >=5 && ENGINE_MINOR_VERSION >= 2 +static FEditableTextBoxStyle EditableTextBoxStyle; +#endif + FLuaCustomHighlighter::FLuaCustomHighlighter() { Color = FLinearColor::White; @@ -14,6 +18,9 @@ FLuaCustomHighlighter::FLuaCustomHighlighter() ULuaMultiLineEditableTextBox::ULuaMultiLineEditableTextBox() { +#if ENGINE_MAJOR_VERSION >=5 && ENGINE_MINOR_VERSION >= 2 + EditableTextBoxStyle.SetTextStyle(CodeStyle); +#endif SEditableTextBox::FArguments Defaults; WidgetStyle = *Defaults._Style; @@ -213,7 +220,11 @@ TSharedRef 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) diff --git a/Source/LuaMachineEditor/Private/LuaMachineEditor.cpp b/Source/LuaMachineEditor/Private/LuaMachineEditor.cpp index 45cbc0b..4ebdcd6 100644 --- a/Source/LuaMachineEditor/Private/LuaMachineEditor.cpp +++ b/Source/LuaMachineEditor/Private/LuaMachineEditor.cpp @@ -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 @@ -67,18 +67,24 @@ 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( "AssetTools" ).Get(); + IAssetTools& AssetTools = FModuleManager::LoadModuleChecked("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 FLuaMachineEditorModule::GetStyleSet() @@ -86,10 +92,10 @@ TSharedPtr FLuaMachineEditorModule::GetStyleSet() return StyleSet; } -void FLuaMachineEditorModule::RegisterAssetTypeAction( IAssetTools& AssetTools, TSharedRef Action ) +void FLuaMachineEditorModule::RegisterAssetTypeAction(IAssetTools& AssetTools, TSharedRef Action) { - AssetTools.RegisterAssetTypeActions( Action ); - CreatedAssetTypeActions.Add( Action ); + AssetTools.RegisterAssetTypeActions(Action); + CreatedAssetTypeActions.Add(Action); } struct FTableViewLuaValue : public TSharedFromThis @@ -512,15 +518,15 @@ TSharedRef 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( "AssetTools" ).Get(); - for ( int32 Index = 0; Index < CreatedAssetTypeActions.Num(); ++Index ) + IAssetTools& AssetTools = FModuleManager::GetModuleChecked("AssetTools").Get(); + for (int32 Index = 0; Index < CreatedAssetTypeActions.Num(); ++Index) { - AssetTools.UnregisterAssetTypeActions( CreatedAssetTypeActions[Index].ToSharedRef() ); + AssetTools.UnregisterAssetTypeActions(CreatedAssetTypeActions[Index].ToSharedRef()); } } CreatedAssetTypeActions.Empty();