FName FActorFolders::GetDefaultFolderName(UWorld& InWorld, FName ParentPath) { // This is potentially very slow but necessary to find a unique name const auto& ExistingFolders = GetFolderPropertiesForWorld(InWorld); // Create a valid base name for this folder uint32 Suffix = 1; FText LeafName = FText::Format(LOCTEXT("DefaultFolderNamePattern", "NewFolder{0}"), FText::AsNumber(Suffix++)); FString ParentFolderPath = ParentPath.IsNone() ? TEXT("") : ParentPath.ToString(); if (!ParentFolderPath.IsEmpty()) { ParentFolderPath += "/"; } FName FolderName(*(ParentFolderPath + LeafName.ToString())); while (ExistingFolders.Contains(FolderName)) { LeafName = FText::Format(LOCTEXT("DefaultFolderNamePattern", "NewFolder{0}"), FText::AsNumber(Suffix++)); FolderName = FName(*(ParentFolderPath + LeafName.ToString())); if (Suffix == 0) { // We've wrapped around a 32bit unsigned int - something must be seriously wrong! return FName(); } } return FolderName; }
void LootState::SelectGame(std::string preferredGame) { if (preferredGame.empty()) { // Get preferred game from settings. if (_settings["game"] && _settings["game"].as<string>() != "auto") preferredGame = _settings["game"].as<string>(); else if (_settings["lastGame"] && _settings["lastGame"].as<string>() != "auto") preferredGame = _settings["lastGame"].as<string>(); } // Get iterator to preferred game if there is one. _currentGame = _games.end(); for (auto it = _games.begin(); it != _games.end(); ++it) { if ((preferredGame.empty() && it->IsInstalled()) || (!preferredGame.empty() && preferredGame == it->FolderName() && it->IsInstalled())) { _currentGame = it; return; } } // Preferred game not found, just pick the first installed one. for (auto it = _games.begin(); it != _games.end(); ++it) { if (it->IsInstalled()) { _currentGame = it; return; } } BOOST_LOG_TRIVIAL(error) << "None of the supported games were detected."; throw error(error::no_game_detected, translate("None of the supported games were detected.")); }
void LootState::load(YAML::Node& settings) { lock_guard<mutex> guard(mutex_); LootSettings::load(settings); // Enable/disable debug logging in case it has changed. boost::log::core::get()->set_logging_enabled(isDebugLoggingEnabled()); // Update existing games, add new games. std::unordered_set<string> newGameFolders; BOOST_LOG_TRIVIAL(trace) << "Updating existing games and adding new games."; for (const auto &game : getGameSettings()) { auto pos = find(games_.begin(), games_.end(), game); if (pos != games_.end()) { pos->SetName(game.Name()) .SetMaster(game.Master()) .SetRepoURL(game.RepoURL()) .SetRepoBranch(game.RepoBranch()) .SetGamePath(game.GamePath()) .SetRegistryKey(game.RegistryKey()); } else { BOOST_LOG_TRIVIAL(trace) << "Adding new game entry for: " << game.FolderName(); games_.push_back(game); } newGameFolders.insert(game.FolderName()); } // Remove deleted games. As the current game is stored using its index, // removing an earlier game may invalidate it. BOOST_LOG_TRIVIAL(trace) << "Removing deleted games."; for (auto it = games_.begin(); it != games_.end();) { if (newGameFolders.find(it->FolderName()) == newGameFolders.end()) { BOOST_LOG_TRIVIAL(trace) << "Removing game: " << it->FolderName(); it = games_.erase(it); } else ++it; } // Re-initialise the current game in case the game path setting was changed. currentGame_->Init(true); // Update game path in settings object. storeGameSettings(toGameSettings(games_)); }
void LootState::UpdateGames(std::list<GameSettings>& games) { // Acquire the lock for the scope of this method. base::AutoLock lock_scope(_lock); unordered_set<string> newGameFolders; // Update existing games, add new games. BOOST_LOG_TRIVIAL(trace) << "Updating existing games and adding new games."; for (auto &game : games) { auto pos = find(_games.begin(), _games.end(), game); if (pos != _games.end()) { pos->SetDetails(game.Name(), game.Master(), game.RepoURL(), game.RepoBranch(), game.GamePath().string(), game.RegistryKey()); } else { BOOST_LOG_TRIVIAL(trace) << "Adding new game entry for: " << game.FolderName(); _games.push_back(game); } newGameFolders.insert(game.FolderName()); } // Remove deleted games. As the current game is stored using its index, // removing an earlier game may invalidate it. BOOST_LOG_TRIVIAL(trace) << "Removing deleted games."; for (auto it = _games.begin(); it != _games.end();) { if (newGameFolders.find(it->FolderName()) == newGameFolders.end()) { BOOST_LOG_TRIVIAL(trace) << "Removing game: " << it->FolderName(); it = _games.erase(it); } else ++it; } // Re-initialise the current game in case the game path setting was changed. _currentGame->Init(true); // Update game path in settings object. _settings["games"] = ToGameSettings(_games); }
void UActorRecording::FindOrAddFolder(UMovieScene* MovieScene) { check(GetActorToRecord() != nullptr); FName FolderName(NAME_None); if(GetActorToRecord()->IsA<ACharacter>() || GetActorToRecord()->IsA<ASkeletalMeshActor>()) { FolderName = TEXT("Characters"); } else if(GetActorToRecord()->IsA<ACameraActor>() || GetActorToRecord()->IsA<ACameraRig_Crane>() || GetActorToRecord()->IsA<ACameraRig_Rail>()) { FolderName = TEXT("Cameras"); } else { FolderName = TEXT("Misc"); } // look for a folder to put us in UMovieSceneFolder* FolderToUse = nullptr; for(UMovieSceneFolder* Folder : MovieScene->GetRootFolders()) { if(Folder->GetFolderName() == FolderName) { FolderToUse = Folder; break; } } if(FolderToUse == nullptr) { FolderToUse = NewObject<UMovieSceneFolder>(MovieScene, NAME_None, RF_Transactional); FolderToUse->SetFolderName(FolderName); MovieScene->GetRootFolders().Add(FolderToUse); } FolderToUse->AddChildObjectBinding(Guid); }