--- a/QTfrontend/selectWeapon.cpp Sun Mar 20 08:42:32 2011 +0000
+++ b/QTfrontend/selectWeapon.cpp Fri Mar 25 23:35:04 2011 +0200
@@ -30,6 +30,7 @@
#include <QSettings>
#include <QMessageBox>
#include <QTabWidget>
+#include <QDebug>
#include <math.h>
QImage getAmmoImage(int num)
@@ -250,7 +251,13 @@
void SelWeaponWidget::newWeaponsName()
{
- setWeaponsName(tr("new"));
+ QString newName = tr("new");
+ if(wconf->contains(newName)) {
+ //name already used -> look for an appropriate name:
+ int i=2;
+ while(wconf->contains(newName = tr("new")+QString::number(i++)));
+ }
+ setWeaponsName(newName);
}
void SelWeaponWidget::setWeaponsName(const QString& name)
@@ -273,7 +280,15 @@
void SelWeaponWidget::copy()
{
- QString ammo = getWeaponsString(curWeaponsName);
- setWeaponsName(tr("copy of") + " " + curWeaponsName);
- setWeapons(ammo);
+ if(wconf->contains(curWeaponsName)) {
+ QString ammo = getWeaponsString(curWeaponsName);
+ QString newName = tr("copy of") + " " + curWeaponsName;
+ if(wconf->contains(newName)) {
+ //name already used -> look for an appropriate name:
+ int i=2;
+ while(wconf->contains(newName = tr("copy of") + " " + curWeaponsName+QString::number(i++)));
+ }
+ setWeaponsName(newName);
+ setWeapons(ammo);
+ }
}