Skip to content

Commit

Permalink
sort categories within mods
Browse files Browse the repository at this point in the history
  • Loading branch information
jackhumbert committed Oct 20, 2023
1 parent 13b1535 commit 87bc84f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/red4ext/ModSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,20 +225,20 @@ DynArray<CName> ModSettings::GetMods() {

DynArray<CName> ModSettings::GetCategories(CName modName) {
auto array = DynArray<CName>(new Memory::DefaultAllocator);
std::vector<std::pair<CName, ModCategory>> modCategories;
for (auto const &[modClassName, modClass] : modSettings.mods[modName].classes) {
std::vector<std::pair<CName, ModCategory>> modCategories;
for (auto itr = modClass.categories.begin(); itr != modClass.categories.end(); ++itr ) {
modCategories.push_back(*itr);
}
sort(modCategories.begin(), modCategories.end(), [=](std::pair<CName, ModCategory>& a, std::pair<CName, ModCategory>& b) {
return a.second.order < b.second.order;
});
for (auto const &[categoryName, category] : modCategories) {
if (categoryName != "None" && !category.variables.empty()) {
auto position = std::find(array.begin(), array.end(), categoryName);
if (position == array.end())
array.EmplaceBack(categoryName);
}
}
sort(modCategories.begin(), modCategories.end(), [=](std::pair<CName, ModCategory>& a, std::pair<CName, ModCategory>& b) {
return a.second.order < b.second.order;
});
for (auto const &[categoryName, category] : modCategories) {
if (categoryName != "None" && !category.variables.empty()) {
auto position = std::find(array.begin(), array.end(), categoryName);
if (position == array.end())
array.EmplaceBack(categoryName);
}
}
return array;
Expand Down

0 comments on commit 87bc84f

Please sign in to comment.