Add 4 teams on first start of Hedgewars
authorWuzzy <almikes@aol.com>
Thu, 13 Apr 2017 05:44:23 +0200
changeset 12246 0b5aa545e058
parent 12245 88b31fdc760b
child 12247 09010333c947
Add 4 teams on first start of Hedgewars
QTfrontend/hwform.cpp
QTfrontend/ui/page/pageoptions.cpp
--- a/QTfrontend/hwform.cpp	Wed Apr 12 23:05:18 2017 +0200
+++ b/QTfrontend/hwform.cpp	Thu Apr 13 05:44:23 2017 +0200
@@ -462,9 +462,10 @@
         QString currentNickName = config->value("net/nick",tr("Guest")+QString("%1").arg(rand())).toString().toUtf8();
         QString teamName;
 
+        // Default team
         if (currentNickName.isEmpty())
         {
-            teamName = tr("DefaultTeam");
+            teamName = tr("Team 1");
         }
         else
         {
@@ -474,6 +475,15 @@
         HWTeam defaultTeam(teamName);
         defaultTeam.saveToFile();
         teamslist.push_back(teamName);
+
+        // Team 2, Team 3, Team 4
+        for(int i=2; i<=4; i++)
+        {
+            teamName = tr("Team %1").arg(i);
+            HWTeam numberTeam(teamName);
+            numberTeam.saveToFile();
+            teamslist.push_back(teamName);
+        }
     }
 
     ui.pageOptions->CBTeamName->clear();
--- a/QTfrontend/ui/page/pageoptions.cpp	Wed Apr 12 23:05:18 2017 +0200
+++ b/QTfrontend/ui/page/pageoptions.cpp	Thu Apr 13 05:44:23 2017 +0200
@@ -32,6 +32,7 @@
 #include <QSlider>
 #include <QSignalMapper>
 #include <QColorDialog>
+#include <QMessageBox>
 #include <QStandardItemModel>
 #include <QDebug>
 
@@ -985,7 +986,10 @@
 
 void PageOptions::requestDeleteSelectedTeam()
 {
-    emit deleteTeamRequested(CBTeamName->currentText());
+    if(CBTeamName->count() > 1)
+        emit deleteTeamRequested(CBTeamName->currentText());
+    else
+        QMessageBox::warning(this, tr("Can't delete last team"), tr("You can't delete the last team!"));
 }
 
 void PageOptions::setTeamOptionsEnabled(bool enabled)