Added explicit sorting of the custom event scripts.

This commit is contained in:
Leon Styhre 2022-09-07 20:01:04 +02:00
parent c537de51ef
commit d362f62b45
2 changed files with 14 additions and 2 deletions

View file

@ -18,6 +18,9 @@
#include "Settings.h"
#include "utils/FileSystemUtil.h"
#include "utils/PlatformUtil.h"
#include "utils/StringUtil.h"
#include <algorithm>
namespace Scripting
{
@ -42,7 +45,16 @@ namespace Scripting
scriptDirList.push_back(scriptDir);
for (auto dirIt = scriptDirList.cbegin(); dirIt != scriptDirList.cend(); ++dirIt) {
std::list<std::string> scripts = Utils::FileSystem::getDirContent(*dirIt);
std::list<std::string> scripts {Utils::FileSystem::getDirContent(*dirIt)};
// Sort the scripts in case-sensitive order on Unix/Linux and in case-insensitive order
// on macOS and Windows.
#if defined(__unix__)
scripts.sort([](std::string a, std::string b) { return a.compare(b) < 0; });
#else
scripts.sort([](std::string a, std::string b) {
return Utils::String::toUpper(a).compare(Utils::String::toUpper(b)) < 0;
});
#endif
for (auto it = scripts.cbegin(); it != scripts.cend(); ++it) {
std::string arg1Quotation;
std::string arg2Quotation;

View file

@ -24,6 +24,6 @@ namespace Scripting
const std::string& arg2 = "",
const std::string& arg3 = "",
const std::string& arg4 = "");
} // namespace Scripting
}
#endif // ES_CORE_SCRIPTING_H