Skip to content

Commit

Permalink
[WIP] Add Starfield's My Games path as an additional data path
Browse files Browse the repository at this point in the history
  • Loading branch information
Ortham committed Sep 4, 2023
1 parent 16863a8 commit 56f2e3e
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions src/api/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,53 @@ bool IsMicrosoftStoreInstall(const GameType gameType,
}
}

#ifdef _WIN32
std::filesystem::path GetMyGamesPath() {
PWSTR path;

if (SHGetKnownFolderPath(FOLDERID_Documents, 0, NULL, &path) != S_OK)
throw std::system_error(GetLastError(),
std::system_category(),
"Failed to get %USERPROFILE% path.");

std::filesystem::path documentsPath(path);
CoTaskMemFree(path);

return documentsPath / "My Games";
}
#else
std::filesystem::path GetMyGamesPath(
const std::filesystem::path& gameLocalPath) {
// Get the documents path relative to the game's local path.
// TODO: Verify that this is correct.
return gameLocalPath.parent_path().parent_path().parent_path() / "Documents" /
"My Games";
}
#endif

std::vector<std::filesystem::path> GetAdditionalDataPaths(
const GameType gameType,
const std::filesystem::path& dataPath) {
const std::filesystem::path& dataPath,
const std::filesystem::path& gameLocalPath) {
const auto gamePath = dataPath.parent_path();

if (gameType == GameType::fo4 &&
IsMicrosoftStoreInstall(gameType, gamePath)) {
// All DLC directories are listed before the main data path because DLC
// plugins in those directories override any in the main data path.
return {gamePath / MS_FO4_AUTOMATRON_DATA_PATH,
gamePath / MS_FO4_NUKA_WORLD_DATA_PATH,
gamePath / MS_FO4_WASTELAND_DATA_PATH,
gamePath / MS_FO4_TEXTURE_PACK_DATA_PATH,
gamePath / MS_FO4_VAULT_TEC_DATA_PATH,
gamePath / MS_FO4_FAR_HARBOR_DATA_PATH,
gamePath / MS_FO4_CONTRAPTIONS_DATA_PATH,
dataPath};
gamePath / MS_FO4_CONTRAPTIONS_DATA_PATH};
}

if (gameType == GameType::starfield) {
#ifdef _WIN32
return {GetMyGamesPath() / "Starfield" / "Data"};
#else
return {GetMyGamesPath(gameLocalPath) / "Starfield" / "Data"};
#endif
}

return {};
Expand Down

0 comments on commit 56f2e3e

Please sign in to comment.