Add scenery category detection, launcher category list parity with Starter

This commit is contained in:
jakubg1
2025-09-04 18:01:48 +02:00
parent d07b0e76c4
commit c83c123596
3 changed files with 41 additions and 20 deletions

View File

@@ -22,6 +22,8 @@ void scenery_scanner::scan()
std::sort(scenarios.begin(), scenarios.end(),
[](const scenery_desc &a, const scenery_desc &b) { return a.path < b.path; });
build_categories();
}
void scenery_scanner::scan_scn(std::filesystem::path path)
@@ -57,6 +59,8 @@ void scenery_scanner::scan_scn(std::filesystem::path path)
desc.name = win1250_to_utf8(line.substr(5));
else if (line[3] == 'd')
desc.description += win1250_to_utf8(line.substr(5)) + '\n';
else if (line[3] == 'l')
desc.category = win1250_to_utf8(line.substr(5));
else if (line[3] == 'f') {
std::string lang;
std::string file;
@@ -154,3 +158,14 @@ void scenery_scanner::parse_trainset(cParser &parser)
trainset.file_bounds.second = parser.Line();
}
void scenery_scanner::build_categories()
{
for (auto &desc : scenarios) {
std::string name = desc.path.stem().string();
std::string prefix = desc.category;
// If the scenario does have a category, add it to the list so we can render it later in a group.
if (!prefix.empty())
categories[prefix].push_back(&desc);
}
}