# HG changeset patch # User unc0rr # Date 1388569358 -14400 # Node ID 34ba1d8e0e9aa481fce600ac490d7be9cc0a09e9 # Parent b87695f82d2e6ea7e6792c1622b07696e4f946fe Try to keep old weapon sets (not tested at all) diff -r b87695f82d2e -r 34ba1d8e0e9a QTfrontend/ui/widget/selectWeapon.cpp --- 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()); +} diff -r b87695f82d2e -r 34ba1d8e0e9a QTfrontend/ui/widget/selectWeapon.h --- a/QTfrontend/ui/widget/selectWeapon.h Wed Jan 01 13:22:46 2014 +0400 +++ b/QTfrontend/ui/widget/selectWeapon.h Wed Jan 01 13:42:38 2014 +0400 @@ -87,6 +87,8 @@ QGridLayout* p2Layout; QGridLayout* p3Layout; QGridLayout* p4Layout; + + QString fixWeaponSet(const QString & s); }; #endif // _SELECT_WEAPON_INCLUDED