1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-22 14:24:33 +01:00

Create function to trigger Steam download

This commit is contained in:
Gymnasiast
2025-12-13 14:55:53 +01:00
parent b7608126a7
commit 3c318a82cc
5 changed files with 52 additions and 0 deletions

View File

@@ -3843,3 +3843,6 @@ STR_7010 :Could not start replay, file {STRING} doesnt exist or isn
STR_7011 :Could not start replay
STR_7012 :Polish Złoty (PLN)
STR_7013 :Drag areas of path
STR_7014 :I own the game on Steam, but I havent installed it yet.
STR_7015 :Please close Steam if its running, then click OK.
STR_7016 :OpenRCT2 has tried to trigger a download in Steam. Please open Steam and let it download the game. When Steam is finished, click OK.

View File

@@ -909,6 +909,7 @@ namespace OpenRCT2::Config
{
uiContext.ShowMessageBox(LanguageGetString(STR_NEEDS_RCT2_FILES));
std::string gog = LanguageGetString(STR_OWN_ON_GOG);
std::string steam = LanguageGetString(STR_OWN_ON_STEAM);
std::string hdd = LanguageGetString(STR_INSTALLED_ON_HDD);
std::vector<std::string> options;
@@ -918,6 +919,7 @@ namespace OpenRCT2::Config
{
options.push_back(hdd);
options.push_back(gog);
options.push_back(steam);
int optionIndex = uiContext.ShowMenuDialog(
options, LanguageGetString(STR_OPENRCT2_SETUP), LanguageGetString(STR_WHICH_APPLIES_BEST));
if (optionIndex < 0 || static_cast<uint32_t>(optionIndex) >= options.size())
@@ -975,6 +977,21 @@ namespace OpenRCT2::Config
possibleInstallPaths.emplace_back(dest);
possibleInstallPaths.emplace_back(Path::Combine(dest, u8"app"));
}
else if (chosenOption == steam)
{
uiContext.ShowMessageBox(LanguageGetString(STR_PLEASE_CLOSE_STEAM));
Platform::triggerSteamDownload();
uiContext.ShowMessageBox(LanguageGetString(STR_WAIT_FOR_STEAM_DOWNLOAD));
auto steamPath = FindRCT2SteamPath();
if (!steamPath.empty())
{
Get().general.rct2Path = steamPath;
return true;
}
}
if (possibleInstallPaths.empty())
{
return false;

View File

@@ -1602,6 +1602,9 @@ enum : StringId
STR_THIS_WILL_TAKE_A_FEW_MINUTES = 6407,
STR_INSTALL_INNOEXTRACT = 6408,
STR_NOT_THE_GOG_INSTALLER = 6409,
STR_OWN_ON_STEAM = 7014,
STR_PLEASE_CLOSE_STEAM = 7015,
STR_WAIT_FOR_STEAM_DOWNLOAD = 7016,
STR_TILE_INSPECTOR_TOGGLE_INVISIBILITY_TIP = 6436,

View File

@@ -224,4 +224,32 @@ namespace OpenRCT2::Platform
steamroot, downloadDepotFolder, "app_" + std::to_string(data.appId), "depot_" + std::to_string(data.depotId));
}
bool triggerSteamDownload()
{
const auto steamPaths = GetSteamPaths();
if (!steamPaths.isSteamPresent() || steamPaths.manifests.empty())
return false;
const auto manifestsDir = Path::Combine(steamPaths.roots[0], steamPaths.manifests);
const std::array<SteamGameData, 3> gamesToTrigger = { kSteamRCT2Data, kSteamRCTCData, kSteamRCT1Data };
for (const auto& game : gamesToTrigger)
{
auto fullFilename = Path::Combine(manifestsDir, "appmanifest_" + std::to_string(game.appId) + ".acf");
// If the file exists, we assume a download has been triggered already.
if (File::Exists(fullFilename))
continue;
// clang-format off
auto buffer = u8string("\"AppState\"\r\n") + u8string("{\r\n")
+ u8string(" \"AppID\" \"" + std::to_string(game.appId) + "\"\r\n")
+ u8string(" \"Universe\" \"1\"\r\n")
+ u8string(" \"installdir\" \"" + game.nativeFolder + "\"\r\n")
+ u8string(" \"StateFlags\" \"1026\"\r\n") + u8string("}\r\n");
// clang-format on
File::WriteAllBytes(fullFilename, buffer.data(), buffer.size());
}
return true;
}
} // namespace OpenRCT2::Platform

View File

@@ -146,6 +146,7 @@ namespace OpenRCT2::Platform
std::string GetUsername();
SteamPaths GetSteamPaths();
bool triggerSteamDownload();
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__) || defined(__NetBSD__)
std::string GetEnvironmentPath(const char* name);
std::string GetHomePath();