-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAirSimGameMode.cpp
75 lines (60 loc) · 2.23 KB
/
AirSimGameMode.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "AirSimGameMode.h"
#include "Misc/FileHelper.h"
#include "IImageWrapperModule.h"
#include "SimHUD/SimHUD.h"
#include "common/Common.hpp"
#include "AirBlueprintLib.h"
class AUnrealLog : public msr::airlib::Utils::Logger
{
public:
virtual void log(int level, const std::string& message) override
{
size_t tab_pos;
static const std::string delim = ":\t";
if ((tab_pos = message.find(delim)) != std::string::npos) {
UAirBlueprintLib::LogMessageString(message.substr(0, tab_pos),
message.substr(tab_pos + delim.size(), std::string::npos), LogDebugLevel::Informational);
return; //display only
}
if (level == msr::airlib::Utils::kLogLevelError) {
UE_LOG(LogAirSim, Error, TEXT("%s"), *FString(message.c_str()));
}
else if (level == msr::airlib::Utils::kLogLevelWarn) {
UE_LOG(LogAirSim, Warning, TEXT("%s"), *FString(message.c_str()));
}
else {
UE_LOG(LogAirSim, Log, TEXT("%s"), *FString(message.c_str()));
}
//#ifdef _MSC_VER
// //print to VS output window
// OutputDebugString(std::wstring(message.begin(), message.end()).c_str());
//#endif
//also do default logging
msr::airlib::Utils::Logger::log(level, message);
}
};
static AUnrealLog GlobalASimLog;
AAirSimGameMode::AAirSimGameMode(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
DefaultPawnClass = nullptr;
HUDClass = ASimHUD::StaticClass();
common_utils::Utils::getSetLogger(&GlobalASimLog);
//module loading is not allowed outside of the main thread, so we load the ImageWrapper module ahead of time.
static IImageWrapperModule& ImageWrapperModule = FModuleManager::LoadModuleChecked<IImageWrapperModule>(TEXT("ImageWrapper"));
}
UGameUserSettings* AAirSimGameMode::GetGameUserSettings()
{
if (GEngine != nullptr)
{
return GEngine->GameUserSettings;
}
return nullptr;
}
void AAirSimGameMode::StartPlay()
{
Super::StartPlay();
//UGameUserSettings* game_settings = GetGameUserSettings();
//game_settings->SetFullscreenMode(EWindowMode::WindowedFullscreen);
//game_settings->ApplySettings(true);
}