store a position in area config and sort areas numerically

This commit is contained in:
in1tiate 2021-03-11 09:57:41 -06:00
parent d0dbd41232
commit 9d10431da7
2 changed files with 12 additions and 3 deletions

View File

@ -1,5 +1,5 @@
[Basement]
[0:Basement]
background=gs4
[Courtroom 1]
[1:Courtroom 1]
background=gs4

View File

@ -79,7 +79,16 @@ void Server::start()
bg_file.close();
QSettings areas_ini("config/areas.ini", QSettings::IniFormat);
area_names = areas_ini.childGroups();
area_names = areas_ini.childGroups(); // invisibly does a lexicographical sort, because Qt is great like that
std::sort(area_names.begin(), area_names.end(), [] (const QString &a, const QString &b) {return a.split(":")[0].toInt() < b.split(":")[0].toInt();});
QStringList sanitized_area_names;
for (QString area_name : area_names) {
QStringList name_split = area_name.split(":");
name_split.removeFirst();
QString area_name_sanitized = name_split.join(":");
sanitized_area_names.append(area_name_sanitized);
}
area_names = sanitized_area_names;
for (int i = 0; i < area_names.length(); i++) {
QString area_name = area_names[i];
areas.insert(i, new AreaData(characters, area_name, i));