13
13
#include " AssetActions/InteractableComponentAssetActions.h"
14
14
15
15
#include " AssetToolsModule.h"
16
+ #include " GameplayTagsManager.h"
16
17
#include " HttpModule.h"
17
18
#include " HelpButton/AIntPCommands.h"
18
19
#include " HelpButton/AIntPHelpStyle.h"
28
29
29
30
#include " Interfaces/IMainFrameModule.h"
30
31
#include " Serialization/JsonReader.h"
32
+ #include " Settings/MounteaInteractionEditorSettings.h"
31
33
32
34
DEFINE_LOG_CATEGORY (ActorInteractionPluginEditor);
33
35
34
- static const FName AIntPHelpTabName (" MounteaFramework" );
35
-
36
36
const FString ChangelogURL = FString(" https://raw.githubusercontent.com/Mountea-Framework/MounteaInteractionSystem/5.1/CHANGELOG.md" );
37
37
38
38
#define LOCTEXT_NAMESPACE " FActorInteractionPluginEditor"
39
39
40
+ static const FName MenuName (" LevelEditor.LevelEditorToolBar.PlayToolBar" );
41
+
40
42
void FActorInteractionPluginEditor::StartupModule ()
41
43
{
42
- // Try to request Changelog from GitHub
44
+ // Try to request Changelog from GitHub & GameplayTags
43
45
{
44
46
Http = &FHttpModule::Get ();
45
47
SendHTTPGet ();
48
+ SendHTTPGet_Tags ();
46
49
}
47
50
48
51
// Register Category
@@ -158,7 +161,7 @@ void FActorInteractionPluginEditor::StartupModule()
158
161
}
159
162
}
160
163
161
- // Register Help Button
164
+ // Register Menu Button
162
165
{
163
166
FAIntPHelpStyle::Initialize ();
164
167
FAIntPHelpStyle::ReloadTextures ();
@@ -257,7 +260,108 @@ void FActorInteractionPluginEditor::HandleNewInteractableBlueprintCreated(UBluep
257
260
Blueprint->BroadcastChanged ();
258
261
}
259
262
260
- void FActorInteractionPluginEditor::PluginButtonClicked ()
263
+ bool FActorInteractionPluginEditor::DoesHaveValidTags () const
264
+ {
265
+ if (!GConfig) return false ;
266
+
267
+ const FString PluginDirectory = IPluginManager::Get ().FindPlugin (TEXT (" ActorInteractionPlugin" ))->GetBaseDir ();
268
+ const FString ConfigFilePath = PluginDirectory + " /Config/Tags/MounteaInteractionSystemTags.ini" ;
269
+ FString NormalizedConfigFilePath = FConfigCacheIni::NormalizeConfigIniPath (ConfigFilePath);
270
+
271
+ if (FPaths::FileExists (ConfigFilePath))
272
+ {
273
+ return GConfig->Find (NormalizedConfigFilePath) != nullptr ;
274
+ }
275
+
276
+ return false ;
277
+ }
278
+
279
+ void FActorInteractionPluginEditor::RefreshGameplayTags ()
280
+ {
281
+ TSharedPtr<IPlugin> ThisPlugin = IPluginManager::Get ().FindPlugin (TEXT (" ActorInteractionPlugin" ));
282
+ check (ThisPlugin.IsValid ());
283
+
284
+ UGameplayTagsManager::Get ().EditorRefreshGameplayTagTree ();
285
+ }
286
+
287
+ void FActorInteractionPluginEditor::UpdateTagsConfig (const FString& NewContent)
288
+ {
289
+ if (!GConfig) return ;
290
+
291
+ const FString PluginDirectory = IPluginManager::Get ().FindPlugin (TEXT (" ActorInteractionPlugin" ))->GetBaseDir ();
292
+ const FString ConfigFilePath = PluginDirectory + " /Config/Tags/MounteaInteractionSystemTags.ini" ;
293
+
294
+ FConfigFile* CurrentConfig = GConfig->Find (ConfigFilePath);
295
+
296
+ FString CurrentContent;
297
+ CurrentConfig->WriteToString (CurrentContent);
298
+
299
+ TArray<FString> Lines;
300
+ NewContent.ParseIntoArray (Lines, TEXT (" \n " ), true );
301
+
302
+ TArray<FString> CleanedLines;
303
+ for (FString& Itr : Lines)
304
+ {
305
+ if (Itr.Equals (" [/Script/GameplayTags.GameplayTagsList]" )) continue ;
306
+
307
+ if (Itr.Contains (" GameplayTagList=" ))
308
+ {
309
+ FString NewValue = Itr.Replace (TEXT (" GameplayTagList=" ), TEXT (" " ));
310
+
311
+ CleanedLines.Add (NewValue);
312
+ }
313
+ }
314
+
315
+ if (!CurrentContent.Equals (NewContent))
316
+ {
317
+ TArray<FString> CurrentLines;
318
+ FConfigFile NewConfig;
319
+ NewConfig.SetArray (TEXT (" /Script/GameplayTags.GameplayTagsList" ), TEXT (" GameplayTagList" ), CleanedLines);
320
+ CurrentConfig->GetArray (TEXT (" /Script/GameplayTags.GameplayTagsList" ), TEXT (" GameplayTagList" ), CurrentLines);
321
+
322
+ for (const FString& Itr : CleanedLines)
323
+ {
324
+ if (CurrentLines.Contains (Itr)) continue ;
325
+
326
+ CurrentLines.AddUnique (Itr);
327
+ }
328
+
329
+ CurrentConfig->SetArray (TEXT (" /Script/GameplayTags.GameplayTagsList" ), TEXT (" GameplayTagList" ), CurrentLines);
330
+ CurrentConfig->Write (ConfigFilePath);
331
+
332
+ RefreshGameplayTags ();
333
+ }
334
+ }
335
+
336
+ void FActorInteractionPluginEditor::CreateTagsConfig (const FString& NewContent)
337
+ {
338
+ if (!GConfig) return ;
339
+
340
+ const FString PluginDirectory = IPluginManager::Get ().FindPlugin (TEXT (" ActorInteractionPlugin" ))->GetBaseDir ();
341
+ const FString ConfigFilePath = PluginDirectory + " /Config/Tags/MounteaInteractionSystemTags.ini" ;
342
+
343
+ TArray<FString> Lines;
344
+ NewContent.ParseIntoArray (Lines, TEXT (" \n " ), true );
345
+
346
+ TArray<FString> CleanedLines;
347
+ for (FString& Itr : Lines)
348
+ {
349
+ if (Itr.Equals (" [/Script/GameplayTags.GameplayTagsList]" )) continue ;
350
+
351
+ if (Itr.Contains (" GameplayTagList=" ))
352
+ {
353
+ FString NewValue = Itr.Replace (TEXT (" GameplayTagList=" ), TEXT (" " ));
354
+
355
+ CleanedLines.Add (NewValue);
356
+ }
357
+ }
358
+
359
+ FConfigFile NewConfig;
360
+ NewConfig.SetArray (TEXT (" /Script/GameplayTags.GameplayTagsList" ), TEXT (" GameplayTagList" ), CleanedLines);
361
+ NewConfig.Write (ConfigFilePath);
362
+ }
363
+
364
+ void FActorInteractionPluginEditor::PluginButtonClicked () const
261
365
{
262
366
const FString URL = " https://discord.gg/waYT2cn37z" ; // Interaction Specific Link
263
367
@@ -267,46 +371,124 @@ void FActorInteractionPluginEditor::PluginButtonClicked()
267
371
}
268
372
}
269
373
374
+ void FActorInteractionPluginEditor::WikiButtonClicked () const
375
+ {
376
+ const FString URL = " https://github.com/Mountea-Framework/MounteaInteractionSystem/wiki/How-to-Setup-Interaction" ;
377
+
378
+ if (!URL.IsEmpty ())
379
+ {
380
+ FPlatformProcess::LaunchURL (*URL, nullptr , nullptr );
381
+ }
382
+ }
383
+
384
+ void FActorInteractionPluginEditor::DialoguerButtonClicked () const
385
+ {
386
+ const FString URL = " https://mountea-framework.github.io/MounteaDialoguer/" ;
387
+
388
+ if (!URL.IsEmpty ())
389
+ {
390
+ FPlatformProcess::LaunchURL (*URL, nullptr , nullptr );
391
+ }
392
+ }
393
+
270
394
void FActorInteractionPluginEditor::RegisterMenus ()
271
395
{
272
396
// Owner will be used for cleanup in call to UToolMenus::UnregisterOwner
273
397
FToolMenuOwnerScoped OwnerScoped (this );
274
398
275
399
// Register in Window tab
276
400
{
277
- UToolMenu* Menu = UToolMenus::Get ()->ExtendMenu (" LevelEditor.MainMenu.Help" );
401
+ if ( UToolMenu* Menu = UToolMenus::Get ()->ExtendMenu (" LevelEditor.MainMenu.Help" ))
278
402
{
279
- FToolMenuSection& Section = Menu->FindOrAddSection (" MounteaFramework" );
280
- Section.Label = FText::FromString (TEXT (" Mountea Framework" ));
281
-
282
- FToolMenuEntry Entry = Section.AddMenuEntryWithCommandList
283
- (
284
- FAIntPCommands::Get ().PluginAction ,
285
- PluginCommands,
286
- NSLOCTEXT (" MounteaSupport" , " TabTitle" , " Mountea Support" ),
287
- NSLOCTEXT(" MounteaSupport" , " TooltipText" , " Opens Mountea Framework Support channel" ),
288
- FSlateIcon(FAIntPHelpStyle::GetStyleSetName(), "AIntPSupport.PluginAction.small")
289
- );
403
+ if (Menu->ContainsSection (" MounteaFramework" ) == false )
404
+ {
405
+ FToolMenuSection& Section = Menu->FindOrAddSection (" MounteaFramework" );
406
+
407
+ Section.InsertPosition .Position = EToolMenuInsertType::First;
408
+ Section.Label = FText::FromString (TEXT (" Mountea Framework" ));
409
+
410
+ FToolMenuEntry SupportEntry = Section.AddMenuEntryWithCommandList
411
+ (
412
+ FAIntPCommands::Get ().PluginAction ,
413
+ PluginCommands,
414
+ LOCTEXT (" MounteaSystemEditor_SupportButton_Label" , " Mountea Support" ),
415
+ LOCTEXT (" MounteaSystemEditor_SupportButton_ToolTip" , " 🆘 Open Mountea Framework Support channel" ),
416
+ FSlateIcon (FAIntPHelpStyle::GetStyleSetName (), " AIntPStyleSet.Help" )
417
+ );
418
+ SupportEntry.Name = FName (" MounteaFrameworkSupport" );
419
+ }
290
420
}
291
421
}
292
422
293
423
// Register in Level Editor Toolbar
294
424
{
295
- UToolMenu* ToolbarMenu = UToolMenus::Get ()->ExtendMenu (" LevelEditor.LevelEditorToolBar.PlayToolBar " );
425
+ UToolMenu* ToolbarMenu = UToolMenus::Get ()->ExtendMenu (MenuName );
296
426
{
297
- FToolMenuSection& Section = ToolbarMenu->FindOrAddSection (" MounteaFramework" );
298
- {
299
- Section.Label = FText::FromString (TEXT (" Mountea Framework" ));
300
-
301
- FToolMenuEntry& Entry = Section.AddEntry (FToolMenuEntry::InitToolBarButton (FAIntPCommands::Get ().PluginAction ));
302
- Entry.SetCommandList (PluginCommands);
303
-
304
- Entry.InsertPosition .Position = EToolMenuInsertType::First;
305
- }
427
+ ToolbarMenu->RemoveSection (" MounteaFramework" ); // Cleanup
428
+ FToolMenuEntry& Entry = ToolbarMenu->FindOrAddSection (" MounteaFramework" )
429
+ .AddEntry (FToolMenuEntry::InitComboButton (
430
+ " MounteaMenu" ,
431
+ FUIAction (),
432
+ FOnGetContent::CreateRaw (this , &FActorInteractionPluginEditor::MakeMounteaMenuWidget),
433
+ LOCTEXT (" MounteaMainMenu_Label" , " Mountea Framework" ),
434
+ LOCTEXT (" MounteaMainMenu_Tooltip" , " 📂 Open Mountea Framework menu.\n\n ❔ Provides link to Documentation, Support Discord and Dialogue tool." ),
435
+ FSlateIcon (FAIntPHelpStyle::Get ().GetStyleSetName (), " AIntPStyleSet.Dialoguer" ),
436
+ false ,
437
+ " MounteaMenu"
438
+ ));
439
+
440
+ Entry.Label = LOCTEXT (" MounteaFramework_Label" , " Mountea Framework" );
441
+ Entry.Name = TEXT (" MounteaMenu" );
442
+ Entry.StyleNameOverride = " CalloutToolbar" ;
443
+ Entry.SetCommandList (PluginCommands);
306
444
}
307
445
}
308
446
}
309
447
448
+ TSharedRef<SWidget> FActorInteractionPluginEditor::MakeMounteaMenuWidget () const
449
+ {
450
+ FMenuBuilder MenuBuilder (true , PluginCommands);
451
+
452
+ MenuBuilder.BeginSection (" MounteaMenu_Links" , LOCTEXT (" MounteaMenuOptions_Options" , " Mountea Links" ));
453
+ {
454
+ // Support Entry
455
+ MenuBuilder.AddMenuEntry (
456
+ LOCTEXT (" MounteaSystemEditor_SupportButton_Label" , " Mountea Support" ),
457
+ LOCTEXT (" MounteaSystemEditor_SupportButton_ToolTip" , " 🆘 Open Mountea Framework Support channel" ),
458
+ FSlateIcon (FAIntPHelpStyle::GetStyleSetName (), " AIntPStyleSet.Help" ),
459
+ FUIAction (
460
+ FExecuteAction::CreateRaw (this , &FActorInteractionPluginEditor::PluginButtonClicked)
461
+ )
462
+ );
463
+ // Wiki Entry
464
+ MenuBuilder.AddMenuEntry (
465
+ LOCTEXT (" MounteaSystemEditor_WikiButton_Label" , " Mountea Wiki" ),
466
+ LOCTEXT (" MounteaSystemEditor_WikiButton_ToolTip" , " 📖 Open Mountea Framework Documentation" ),
467
+ FSlateIcon (FAIntPHelpStyle::GetStyleSetName (), " AIntPStyleSet.Wiki" ),
468
+ FUIAction (
469
+ FExecuteAction::CreateRaw (this , &FActorInteractionPluginEditor::WikiButtonClicked)
470
+ )
471
+ );
472
+ }
473
+ MenuBuilder.EndSection ();
474
+
475
+ MenuBuilder.BeginSection (" MounteaMenu_Tools" , LOCTEXT (" MounteaMenuOptions_Tools" , " Mountea Tools" ));
476
+ {
477
+ // Dialoguer Entry
478
+ MenuBuilder.AddMenuEntry (
479
+ LOCTEXT (" MounteaSystemEditor_DialoguerButton_Label" , " Mountea Dialoguer" ),
480
+ LOCTEXT (" MounteaSystemEditor_DialoguerButton_ToolTip" , " ⛰ Open Mountea Dialoguer Standalone Tool\n\n ❔ Mountea Dialoguer is a standalone tool created for Dialogue crafting. Mountea Dialogue System supports native import for `.mnteadlg` files." ),
481
+ FSlateIcon (FAIntPHelpStyle::GetStyleSetName (), " AIntPStyleSet.Dialoguer" ),
482
+ FUIAction (
483
+ FExecuteAction::CreateRaw (this , &FActorInteractionPluginEditor::DialoguerButtonClicked)
484
+ )
485
+ );
486
+ }
487
+ MenuBuilder.EndSection ();
488
+
489
+ return MenuBuilder.MakeWidget ();
490
+ }
491
+
310
492
void FActorInteractionPluginEditor::OnGetResponse (FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
311
493
{
312
494
FString ResponseBody;
@@ -337,6 +519,33 @@ void FActorInteractionPluginEditor::SendHTTPGet()
337
519
Request->ProcessRequest ();
338
520
}
339
521
522
+ void FActorInteractionPluginEditor::OnGetResponse_Tags (FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
523
+ {
524
+
525
+ }
526
+
527
+ void FActorInteractionPluginEditor::SendHTTPGet_Tags ()
528
+ {
529
+ const UMounteaInteractionEditorSettings* Settings = GetDefault<UMounteaInteractionEditorSettings>();
530
+ if (DoesHaveValidTags ())
531
+ {
532
+ if (!Settings->AllowCheckTagUpdate ())
533
+ {
534
+ return ;
535
+ }
536
+ }
537
+
538
+ const TSharedRef<IHttpRequest, ESPMode::ThreadSafe> Request = Http->CreateRequest ();
539
+
540
+ Request->OnProcessRequestComplete ().BindRaw (this , &FActorInteractionPluginEditor::OnGetResponse_Tags);
541
+ Request->SetURL (Settings->GetGameplayTagsURL ());
542
+
543
+ Request->SetVerb (" GET" );
544
+ Request->SetHeader (" User-Agent" , " X-UnrealEngine-Agent" );
545
+ Request->SetHeader (" Content-Type" , " text" );
546
+ Request->ProcessRequest ();
547
+ }
548
+
340
549
#undef LOCTEXT_NAMESPACE
341
550
342
551
IMPLEMENT_MODULE (FActorInteractionPluginEditor, ActorInteractionPluginEditor);
0 commit comments