CARLA
Carla.cpp
Go to the documentation of this file.
1 // Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
2 
3 #include "Carla.h"
4 #include "Developer/Settings/Public/ISettingsModule.h"
5 #include "Developer/Settings/Public/ISettingsSection.h"
6 #include "Developer/Settings/Public/ISettingsContainer.h"
8 
9 #define LOCTEXT_NAMESPACE "FCarlaModule"
10 
11 DEFINE_LOG_CATEGORY(LogCarla);
12 DEFINE_LOG_CATEGORY(LogCarlaServer);
13 
15 {
17 }
18 
20 {
21  if (UObjectInitialized())
22  {
24  }
25 }
26 
28 {
29  // Registering some settings is just a matter of exposing the default UObject of
30  // your desired class, add here all those settings you want to expose
31  // to your LDs or artists.
32 
33  if (ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings"))
34  {
35  // Create the new category
36  ISettingsContainerPtr SettingsContainer = SettingsModule->GetContainer("Project");
37 
38  SettingsContainer->DescribeCategory("CARLASettings",
39  LOCTEXT("RuntimeWDCategoryName", "CARLA Settings"),
40  LOCTEXT("RuntimeWDCategoryDescription", "CARLA plugin settings"));
41 
42  // Register the settings
43  ISettingsSectionPtr SettingsSection = SettingsModule->RegisterSettings("Project", "CARLASettings", "General",
44  LOCTEXT("RuntimeGeneralSettingsName", "General"),
45  LOCTEXT("RuntimeGeneralSettingsDescription", "General configuration for the CARLA plugin"),
46  GetMutableDefault<UCarlaSettings>()
47  );
48 
49  // Register the save handler to your settings, you might want to use it to
50  // validate those or just act to settings changes.
51  if (SettingsSection.IsValid())
52  {
53  SettingsSection->OnModified().BindRaw(this, &FCarlaModule::HandleSettingsSaved);
54  }
55  }
56 }
57 
59 {
60  // Ensure to unregister all of your registered settings here, hot-reload would
61  // otherwise yield unexpected results.
62 
63  if (ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings"))
64  {
65  SettingsModule->UnregisterSettings("Project", "CustomSettings", "General");
66  }
67 }
68 
70 {
71  UCarlaSettings* Settings = GetMutableDefault<UCarlaSettings>();
72  bool ResaveSettings = false;
73 
74  // Put any validation code in here and resave the settings in case an invalid
75  // value has been entered
76 
77  if (ResaveSettings)
78  {
79  Settings->SaveConfig();
80  }
81 
82  return true;
83 }
84 
85 #undef LOCTEXT_NAMESPACE
86 
87 IMPLEMENT_MODULE(FCarlaModule, Carla)
88 
89 // =============================================================================
90 // -- Implement carla throw_exception ------------------------------------------
91 // =============================================================================
92 
93 #include <compiler/disable-ue4-macros.h>
94 #include <carla/Exception.h>
96 
97 #include <exception>
98 
99 namespace carla {
100 
101  void throw_exception(const std::exception &e) {
102  UE_LOG(LogCarla, Fatal, TEXT("Exception thrown: %s"), UTF8_TO_TCHAR(e.what()));
103  // It should never reach this part.
104  std::terminate();
105  }
106 
107 } // namespace carla
void UnregisterSettings()
Definition: Carla.cpp:58
void throw_exception(const std::exception &e)
Definition: Carla.cpp:101
virtual void StartupModule() override
IModuleInterface implementation.
Definition: Carla.cpp:14
Definition: Carla.cpp:99
bool HandleSettingsSaved()
Definition: Carla.cpp:69
Global settings for CARLA.
Definition: CarlaSettings.h:21
virtual void ShutdownModule() override
Definition: Carla.cpp:19
void RegisterSettings()
Definition: Carla.cpp:27
DEFINE_LOG_CATEGORY(LogCarla)