Skip to content

Commit

Permalink
Check for settings.json in launch folder as well
Browse files Browse the repository at this point in the history
  • Loading branch information
rajat2004 committed Mar 5, 2021
1 parent 4a91e0c commit ed30bca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 9 additions & 3 deletions Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,12 @@ void ASimHUD::initializeSubWindows()

}


FString ASimHUD::getLaunchPath(const std::string& filename)
{
FString launch_rel_path = FPaths::LaunchDir();
FString abs_path = FPaths::ConvertRelativePathToFull(launch_rel_path);
return FPaths::Combine(abs_path, FString(filename.c_str()) );
}

// Attempts to parse the settings text from one of multiple locations.
// First, check the command line for settings provided via "-s" or "--settings" arguments
Expand All @@ -368,6 +373,8 @@ bool ASimHUD::getSettingsText(std::string& settingsText)
||
readSettingsTextFromFile(FString(msr::airlib::Settings::getExecutableFullPath("settings.json").c_str()), settingsText)
||
readSettingsTextFromFile(getLaunchPath("settings.json"), settingsText)
||
readSettingsTextFromFile(FString(msr::airlib::Settings::Settings::getUserDirectoryFullPath("settings.json").c_str()), settingsText));
}

Expand Down Expand Up @@ -401,9 +408,8 @@ bool ASimHUD::getSettingsTextFromCommandLine(std::string& settingsText)
return found;
}

bool ASimHUD::readSettingsTextFromFile(FString settingsFilepath, std::string& settingsText)
bool ASimHUD::readSettingsTextFromFile(const FString& settingsFilepath, std::string& settingsText)
{

bool found = FPaths::FileExists(settingsFilepath);
if (found) {
FString settingsTextFStr;
Expand Down
4 changes: 3 additions & 1 deletion Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ class AIRSIM_API ASimHUD : public AHUD

bool getSettingsText(std::string& settingsText);
bool getSettingsTextFromCommandLine(std::string& settingsText);
bool readSettingsTextFromFile(FString fileName, std::string& settingsText);
bool readSettingsTextFromFile(const FString& fileName, std::string& settingsText);
std::string getSimModeFromUser();

static FString getLaunchPath(const std::string& filename);

private:
typedef common_utils::Utils Utils;
UClass* widget_class_;
Expand Down

0 comments on commit ed30bca

Please sign in to comment.