Sort all core missions in training menu more logically
The missions are now sorted as specified in the new order.cfg files in the Missions subfolders.
Training missions are now sorted in the order you should play them.
Challenges are semi-logically grouped.
Scenarios are roughly sorted by difficulty.
All missions not mentioned in order.cfg are simply added in no particular
order at the end.
--- a/QTfrontend/ui/page/pagetraining.cpp Wed Mar 07 10:44:30 2018 +0100
+++ b/QTfrontend/ui/page/pagetraining.cpp Wed Mar 07 12:33:56 2018 +0100
@@ -23,6 +23,7 @@
#include <QListWidgetItem>
#include <QPushButton>
+#include <QTextStream>
#include <QFile>
#include <QLocale>
#include <QSettings>
@@ -194,14 +195,46 @@
m_widget = lstScenarios;
break;
}
+ // scripts to load
+ // first, load scripts in order specified in order.cfg (if present)
+ QFile orderFile(QString("physfs://Missions/%1/order.cfg").arg(subFolder));
+ QStringList orderedMissions;
+ if (orderFile.open(QFile::ReadOnly))
+ {
+ QString m_id;
+ QTextStream input(&orderFile);
+ while(true)
+ {
+ m_id = input.readLine();
+ if(m_id.isNull() || m_id.isEmpty())
+ {
+ break;
+ }
+ QListWidgetItem * item = new QListWidgetItem(m_id);
+ QString name = item->text().replace("_", " ");
+ name = m_info->value(m_id + ".name", name).toString();
+ item->setText(name);
+ item->setData(Qt::UserRole, m_id);
+ m_widget->addItem(item);
+
+ orderedMissions << m_id;
+ }
+ }
+
+ // then, just load anything else in no particular order
m_list = dataMgr.entryList(
"Missions/" + subFolder,
QDir::Files, QStringList("*.lua")).
replaceInStrings(QRegExp("\\.lua$"), "");
- // scripts to load - TODO: model?
foreach (const QString & m_id, m_list)
{
+ // Disallow duplicates from order.cfg
+ if (orderedMissions.contains(m_id))
+ {
+ continue;
+ }
+
QListWidgetItem * item = new QListWidgetItem(m_id);
// fallback name: replace underscores in mission name with spaces
--- a/share/hedgewars/Data/Missions/Challenge/CMakeLists.txt Wed Mar 07 10:44:30 2018 +0100
+++ b/share/hedgewars/Data/Missions/Challenge/CMakeLists.txt Wed Mar 07 12:33:56 2018 +0100
@@ -2,4 +2,5 @@
install(FILES
${Scripts}
+ order.cfg
DESTINATION ${SHAREPATH}Data/Missions/Challenge)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Missions/Challenge/order.cfg Wed Mar 07 12:33:56 2018 +0100
@@ -0,0 +1,15 @@
+Target_Practice_-_Bazooka_easy
+Target_Practice_-_Bazooka_hard
+Target_Practice_-_Homing_Bee
+Target_Practice_-_Grenade_easy
+Target_Practice_-_Grenade_hard
+Target_Practice_-_Cluster_Bomb
+Target_Practice_-_Shotgun
+Basic_Training_-_Sniper_Rifle
+Challenge_-_Speed_Shoppa_-_Hedgelove
+Challenge_-_Speed_Shoppa_-_Ropes
+Challenge_-_Speed_Shoppa_-_ShoppaKing
+User_Mission_-_Rope_Knock_Challenge
+User_Mission_-_RCPlane_Challenge
+User_Mission_-_That_Sinking_Feeling
+ClimbHome
--- a/share/hedgewars/Data/Missions/Scenario/CMakeLists.txt Wed Mar 07 10:44:30 2018 +0100
+++ b/share/hedgewars/Data/Missions/Scenario/CMakeLists.txt Wed Mar 07 12:33:56 2018 +0100
@@ -2,4 +2,5 @@
install(FILES
${Scripts}
+ order.cfg
DESTINATION ${SHAREPATH}Data/Missions/Scenario)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Missions/Scenario/order.cfg Wed Mar 07 12:33:56 2018 +0100
@@ -0,0 +1,13 @@
+User_Mission_-_Dangerous_Ducklings
+Bazooka_Battlefield
+User_Mission_-_Bamboo_Thicket
+User_Mission_-_The_Great_Escape
+User_Mission_-_Teamwork
+User_Mission_-_Teamwork_2
+User_Mission_-_Newton_and_the_Hammock
+User_Mission_-_Diver
+User_Mission_-_Spooky_Tree
+User_Mission_-_Nobody_Laugh
+portal
+Tentacle_Terror
+Big_Armory
--- a/share/hedgewars/Data/Missions/Training/CMakeLists.txt Wed Mar 07 10:44:30 2018 +0100
+++ b/share/hedgewars/Data/Missions/Training/CMakeLists.txt Wed Mar 07 12:33:56 2018 +0100
@@ -1,5 +1,6 @@
file(GLOB Scripts *.lua)
install(FILES
+ order.cfg
${Scripts}
DESTINATION ${SHAREPATH}Data/Missions/Training)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Missions/Training/order.cfg Wed Mar 07 12:33:56 2018 +0100
@@ -0,0 +1,5 @@
+Basic_Training_-_Movement
+Basic_Training_-_Bazooka
+Basic_Training_-_Grenade
+Basic_Training_-_Rope
+Basic_Training_-_Flying_Saucer