# HG changeset patch # User Wuzzy # Date 1507394611 -7200 # Node ID 1d25f5555c38446bc5b5b685cc0261595e333ba8 # Parent 5664ec82aed7bf3751a031dca7b59703561b2011 Names of new or copied game schemes are now unique diff -r 5664ec82aed7 -r 1d25f5555c38 ChangeLog.txt --- a/ChangeLog.txt Sat Oct 07 03:43:06 2017 +0200 +++ b/ChangeLog.txt Sat Oct 07 18:43:31 2017 +0200 @@ -265,6 +265,7 @@ + Hedgewars creates 4 human teams and 2 computer teams on its first launch + Allow to randomize hog names, hats, team name, flag, grave, voice and fort separately + “Random team” button is now able to randomly select from all available hats + + Creating new game/weapon schemes guarantees unique names * Fix flag being selectable for computer players although it had no effect * Campaign screen does no longer show AI-controlled teams * Campaign names and campaign mission names can now be translated diff -r 5664ec82aed7 -r 1d25f5555c38 QTfrontend/model/ammoSchemeModel.cpp --- a/QTfrontend/model/ammoSchemeModel.cpp Sat Oct 07 03:43:06 2017 +0200 +++ b/QTfrontend/model/ammoSchemeModel.cpp Sat Oct 07 18:43:31 2017 +0200 @@ -724,6 +724,18 @@ return defaultScheme.size(); } +bool AmmoSchemeModel::hasScheme(QString name) +{ + for(int i=0; i newScheme = defaultScheme; - newScheme[0] = QVariant(tr("New")); + + QString newName = tr("New"); + if(hasScheme(newName)) + { + //name already used -> look for an appropriate name: + int i=2; + while(hasScheme(newName = tr("New (%1)").arg(i++))) ; + } + newScheme[0] = QVariant(newName); schemes.insert(schemes.size(), newScheme); } else { QList newScheme = schemes[row]; - newScheme[0] = QVariant(tr("Copy of %1").arg(newScheme[0].toString())); + QString oldName = newScheme[0].toString(); + QString newName = tr("Copy of %1").arg(oldName); + if(hasScheme(newName)) + { + //name already used -> look for an appropriate name: + int i=2; + while(hasScheme(newName = tr("Copy of %1 (%2)").arg(oldName).arg(i++))); + } + newScheme[0] = QVariant(newName); schemes.insert(schemes.size(), newScheme); } diff -r 5664ec82aed7 -r 1d25f5555c38 QTfrontend/model/ammoSchemeModel.h --- a/QTfrontend/model/ammoSchemeModel.h Sat Oct 07 03:43:06 2017 +0200 +++ b/QTfrontend/model/ammoSchemeModel.h Sat Oct 07 18:43:31 2017 +0200 @@ -34,6 +34,7 @@ QVariant headerData(int section, Qt::Orientation orientation, int role) const; int rowCount(const QModelIndex & parent) const; int columnCount(const QModelIndex & parent) const; + bool hasScheme(QString name); Qt::ItemFlags flags(const QModelIndex & index) const; bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex()); diff -r 5664ec82aed7 -r 1d25f5555c38 share/hedgewars/Data/Locale/hedgewars_de.ts --- a/share/hedgewars/Data/Locale/hedgewars_de.ts Sat Oct 07 03:43:06 2017 +0200 +++ b/share/hedgewars/Data/Locale/hedgewars_de.ts Sat Oct 07 18:43:31 2017 +0200 @@ -120,6 +120,14 @@ Copy of %1 Kopie von %1 + + New (%1) + Neu (%1) + + + Copy of %1 (%2) + Kopie von %1 (%2) + BanDialog @@ -3670,6 +3678,7 @@ toggle team bars + This refers to the team info bars (name/flag/health) of all teams. These are shown at the bottom center of the screen Teamleisten umschalten diff -r 5664ec82aed7 -r 1d25f5555c38 share/hedgewars/Data/Locale/hedgewars_en.ts --- a/share/hedgewars/Data/Locale/hedgewars_en.ts Sat Oct 07 03:43:06 2017 +0200 +++ b/share/hedgewars/Data/Locale/hedgewars_en.ts Sat Oct 07 18:43:31 2017 +0200 @@ -100,6 +100,14 @@ Copy of %1 Copy of %1 + + New (%1) + New (%1) + + + Copy of %1 (%2) + Copy of %1 (%2) + BanDialog @@ -562,6 +570,7 @@ Team %1 + Default team name Team %1 @@ -576,6 +585,11 @@ Password: + + Computer %1 + Default computer team name + Computer %1 + HWGame @@ -3455,6 +3469,7 @@ toggle team bars + This refers to the team info bars (name/flag/health) of all teams. These are shown at the bottom center of the screen toggle team bars