--- a/QTfrontend/ui/widget/selectWeapon.cpp Wed Mar 14 01:33:37 2018 +0100
+++ b/QTfrontend/ui/widget/selectWeapon.cpp Wed Mar 14 12:17:11 2018 +0100
@@ -85,32 +85,37 @@
QFrame(parent),
m_numItems(numItems)
{
- if (!QDir(cfgdir->absolutePath() + "/Schemes").exists()) QDir().mkdir(cfgdir->absolutePath() + "/Schemes");
+ if (!QDir(cfgdir->absolutePath() + "/Schemes").exists()) {
+ QDir().mkdir(cfgdir->absolutePath() + "/Schemes");
+ }
if (!QDir(cfgdir->absolutePath() + "/Schemes/Ammo").exists()) {
+ qDebug("No /Schemes/Ammo directory found. Trying to import weapon schemes from weapons.ini.");
QDir().mkdir(cfgdir->absolutePath() + "/Schemes/Ammo");
wconf = new QSettings("Hedgewars", "Hedgewars");
wconf->clear();
QSettings old_wconf(cfgdir->absolutePath() + "/weapons.ini", QSettings::IniFormat);
- QList<QVariant> defaultAmmos;
+ QStringList defaultAmmos;
for(int i = 0; i < cDefaultAmmos.size(); ++i) {
wconf->setValue(cDefaultAmmos[i].first, cDefaultAmmos[i].second);
defaultAmmos.append(cDefaultAmmos[i].first);
}
QStringList keys = old_wconf.allKeys();
+ int imported = 0;
for(int i = 0; i < keys.size(); i++)
{
- wconf->setValue(keys[i], fixWeaponSet(old_wconf.value(keys[i]).toString()));
-
if (!defaultAmmos.contains(keys[i])) {
+ wconf->setValue(keys[i], fixWeaponSet(old_wconf.value(keys[i]).toString()));
QFile file(cfgdir->absolutePath() + "/Schemes/Ammo/" + keys[i] + ".hwa");
if (file.open(QIODevice::WriteOnly)) {
QTextStream stream( &file );
stream << old_wconf.value(keys[i]).toString() << endl;
}
+ imported++;
}
}
+ qDebug("%d weapon scheme(s) imported.", imported);
} else {
wconf = new QSettings("Hedgewars", "Hedgewars");
wconf->clear();