Set menu language to game language on first run (#1577)

* feat(translations): set menu language to game language on first run
* fix(translations): add exception handlers
* fix: more exception handlers
This commit is contained in:
maybegreat48
2023-07-01 22:25:40 +00:00
committed by GitHub
parent 2e70faa4ad
commit f1f5d4f6c0
16 changed files with 259 additions and 86 deletions

View File

@ -30,14 +30,21 @@ namespace big
auto file_path = item.path();
if (file_path.extension() == ".json")
{
auto profile_file = std::ifstream(file_path, std::ios::binary);
nlohmann::json j;
profile_file >> j;
profile_file.close();
try
{
auto profile_file = std::ifstream(file_path, std::ios::binary);
nlohmann::json j;
profile_file >> j;
profile_file.close();
m_handling_profiles.emplace(file_path.stem().string(), j.get<handling_profile>());
m_handling_profiles.emplace(file_path.stem().string(), j.get<handling_profile>());
++files_loaded;
++files_loaded;
}
catch (std::exception& e)
{
LOG(WARNING) << "Failed to load " << file_path.filename() << ". " << e.what();
}
}
// deprecate this
else if (file_path.extension() == ".bin")
@ -46,7 +53,7 @@ namespace big
auto profile_file = std::ifstream(file_path, std::ios::binary);
auto profile = handling_profile();
profile_file.read(reinterpret_cast<char*>(&profile), 328);// hardcoded old size to prevent overreading
profile_file.read(reinterpret_cast<char*>(&profile), 328); // hardcoded old size to prevent overreading
profile_file.close();
const auto new_save = file_path.stem().string();

View File

@ -35,8 +35,16 @@ namespace big
nlohmann::json vehicle_json;
file_stream >> vehicle_json;
file_stream.close();
try
{
file_stream >> vehicle_json;
file_stream.close();
}
catch (std::exception& e)
{
g_notification_service->push_warning("PERSIST_CAR_TITLE"_T.data(), "Failed to load JSON file");
return NULL;
}
return spawn_vehicle_full(vehicle_json, self::ped);
}