QTfrontend/ui/widget/selectWeapon.cpp
changeset 9900 34ba1d8e0e9a
parent 9080 9b42757d7e71
child 9998 736015b847e3
--- a/QTfrontend/ui/widget/selectWeapon.cpp	Wed Jan 01 13:22:46 2014 +0400
+++ b/QTfrontend/ui/widget/selectWeapon.cpp	Wed Jan 01 13:42:38 2014 +0400
@@ -93,7 +93,7 @@
     for(int i = 0; i < keys.size(); i++)
     {
         if (wconf->value(keys[i]).toString().size() != cDefaultAmmoStore->size())
-            wconf->remove(keys[i]);
+            wconf->setValue(keys[i], fixWeaponSet(wconf->value(keys[i]).toString()));
     }
 
     QString currentState = *cDefaultAmmoStore;
@@ -333,3 +333,22 @@
         setWeapons(ammo);
     }
 }
+
+QString SelWeaponWidget::fixWeaponSet(const QString &s)
+{
+    int neededLength = cDefaultAmmoStore->size() / 4;
+    int thisSetLength = s.size() / 4;
+
+    QStringList sl;
+    sl
+            << s.left(thisSetLength)
+            << s.mid(thisSetLength, thisSetLength)
+            << s.mid(thisSetLength * 2, thisSetLength)
+            << s.right(thisSetLength)
+               ;
+
+    for(int i = sl.length() - 1; i >= 0; --i)
+        sl[i] = sl[i].leftJustified(neededLength, '0', true);
+
+    return sl.join(QString());
+}