MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / FindOrBrowseInstallDirectory

Function FindOrBrowseInstallDirectory

src/openrct2/config/Config.cpp:903–1058  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

901 }
902
903 bool FindOrBrowseInstallDirectory()
904 {
905 std::string path = FindRCT2Path();
906 if (!path.empty())
907 {
908 Get().general.rct2Path = path;
909 }
910 else
911 {
912 if (gOpenRCT2Headless)
913 {
914 return false;
915 }
916
917 auto& uiContext = GetContext()->GetUiContext();
918 if (!uiContext.HasFilePicker())
919 {
920 uiContext.ShowMessageBox(LanguageGetString(STR_NEEDS_RCT2_FILES_MANUAL));
921 return false;
922 }
923
924 try
925 {
926 const char* g1DatPath = PATH_SEPARATOR "Data" PATH_SEPARATOR "g1.dat";
927 while (true)
928 {
929 uiContext.ShowMessageBox(LanguageGetString(STR_NEEDS_RCT2_FILES));
930 std::string gog = LanguageGetString(STR_OWN_ON_GOG);
931 std::string steam = LanguageGetString(STR_OWN_ON_STEAM);
932 std::string hdd = LanguageGetString(STR_INSTALLED_ON_HDD);
933 std::string exit = LanguageGetString(STR_QUIT_ONBOARDING);
934
935 std::string chosenOption;
936
937 if (uiContext.HasMenuSupport())
938 {
939 std::vector<std::string> options;
940 options.push_back(hdd);
941 options.push_back(gog);
942 options.push_back(steam);
943 options.push_back(exit);
944 int optionIndex = uiContext.ShowMenuDialog(
945 options, LanguageGetString(STR_OPENRCT2_SETUP), LanguageGetString(STR_WHICH_APPLIES_BEST));
946 // Error while trying to show menu options, fall back.
947 if (optionIndex < 0)
948 {
949 chosenOption = hdd;
950 }
951 // User clicked the Cancel or Close button
952 else if (static_cast<uint32_t>(optionIndex) >= options.size())
953 {
954 chosenOption = exit;
955 }
956 else
957 {
958 chosenOption = options[optionIndex];
959 }
960 }

Callers 1

GetOrPromptRCT2PathMethod · 0.85

Calls 15

FindRCT2PathFunction · 0.85
GetContextFunction · 0.85
LanguageGetStringFunction · 0.85
SelectGogInstallerFunction · 0.85
ExtractGogInstallerFunction · 0.85
triggerSteamDownloadFunction · 0.85
FindRCT2SteamPathFunction · 0.85
ContextQuitFunction · 0.85
OriginalGameDataExistsFunction · 0.85
FormatStringIDLegacyFunction · 0.85
WriteLineFunction · 0.85
FindRCT1PathFunction · 0.85

Tested by

no test coverage detected