Make sure new teams start with an unique name
authorWuzzy <almikes@aol.com>
Sat, 07 Oct 2017 19:11:25 +0200
changeset 12672 2e0a38566178
parent 12671 1d25f5555c38
child 12673 308846e05154
Make sure new teams start with an unique name
QTfrontend/hwform.cpp
share/hedgewars/Data/Locale/hedgewars_de.ts
share/hedgewars/Data/Locale/hedgewars_en.ts
--- a/QTfrontend/hwform.cpp	Sat Oct 07 18:43:31 2017 +0200
+++ b/QTfrontend/hwform.cpp	Sat Oct 07 19:11:25 2017 +0200
@@ -1036,7 +1036,16 @@
 
 void HWForm::NewTeam()
 {
-    ui.pageEditTeam->createTeam(QLineEdit::tr("unnamed"), playerHash);
+    QString teamName = QLineEdit::tr("unnamed");
+    QStringList teamslist = config->GetTeamsList();
+    if(teamslist.contains(teamName))
+    {
+        //name already used -> look for an appropriate name:
+        int i=2;
+        while(teamslist.contains(teamName = QLineEdit::tr("unnamed (%1)").arg(i++)));
+    }
+
+    ui.pageEditTeam->createTeam(teamName, playerHash);
     UpdateTeamsLists();
     GoToPage(ID_PAGE_SETUP_TEAM);
 }
--- a/share/hedgewars/Data/Locale/hedgewars_de.ts	Sat Oct 07 18:43:31 2017 +0200
+++ b/share/hedgewars/Data/Locale/hedgewars_de.ts	Sat Oct 07 19:11:25 2017 +0200
@@ -2861,6 +2861,10 @@
         <source>anonymous</source>
         <translation>anonym</translation>
     </message>
+    <message>
+        <source>unnamed (%1)</source>
+        <translation>unbenannt (%1)</translation>
+    </message>
 </context>
 <context>
     <name>QMainWindow</name>
--- a/share/hedgewars/Data/Locale/hedgewars_en.ts	Sat Oct 07 18:43:31 2017 +0200
+++ b/share/hedgewars/Data/Locale/hedgewars_en.ts	Sat Oct 07 19:11:25 2017 +0200
@@ -2699,6 +2699,10 @@
         <source>anonymous</source>
         <translation>anonymous</translation>
     </message>
+    <message>
+        <source>unnamed (%1)</source>
+        <translation>unnamed (%1)</translation>
+    </message>
 </context>
 <context>
     <name>QMainWindow</name>