author | unC0Rr |
Sat, 28 Sep 2024 22:27:13 +0200 | |
changeset 16037 | 2b4f361e3891 |
parent 15971 | cee831693af1 |
permissions | -rw-r--r-- |
612
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
598
diff
changeset
|
1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
4976 | 3 |
* Copyright (c) 2006-2008 Igor Ulyanov <iulyanov@gmail.com> |
11046 | 4 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
612
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
598
diff
changeset
|
5 |
* |
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
598
diff
changeset
|
6 |
* This program is free software; you can redistribute it and/or modify |
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
598
diff
changeset
|
7 |
* it under the terms of the GNU General Public License as published by |
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
598
diff
changeset
|
8 |
* the Free Software Foundation; version 2 of the License |
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
598
diff
changeset
|
9 |
* |
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
598
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
598
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
598
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
598
diff
changeset
|
13 |
* GNU General Public License for more details. |
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
598
diff
changeset
|
14 |
* |
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
598
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
598
diff
changeset
|
16 |
* along with this program; if not, write to the Free Software |
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
9998
diff
changeset
|
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
612
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
598
diff
changeset
|
18 |
*/ |
1509 | 19 |
|
624 | 20 |
#include "selectWeapon.h" |
629 | 21 |
#include "weaponItem.h" |
681 | 22 |
#include "hwconsts.h" |
612
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
598
diff
changeset
|
23 |
|
12922 | 24 |
#include <QDebug> |
624 | 25 |
#include <QPushButton> |
26 |
#include <QGridLayout> |
|
629 | 27 |
#include <QHBoxLayout> |
28 |
#include <QLabel> |
|
630 | 29 |
#include <QBitmap> |
694 | 30 |
#include <QLineEdit> |
31 |
#include <QSettings> |
|
724 | 32 |
#include <QMessageBox> |
2369
c3eb11f1ab3a
Implement probability editor for weapon schemes (engine doesn't support that yet)
unc0rr
parents:
1967
diff
changeset
|
33 |
#include <QTabWidget> |
14839
e239378a9400
Prevent entering “/”, “\” and “:” in team and scheme names.
Wuzzy <Wuzzy2@mail.ru>
parents:
14836
diff
changeset
|
34 |
#include <QRegExp> |
e239378a9400
Prevent entering “/”, “\” and “:” in team and scheme names.
Wuzzy <Wuzzy2@mail.ru>
parents:
14836
diff
changeset
|
35 |
#include <QRegExpValidator> |
e239378a9400
Prevent entering “/”, “\” and “:” in team and scheme names.
Wuzzy <Wuzzy2@mail.ru>
parents:
14836
diff
changeset
|
36 |
|
2467 | 37 |
#include <math.h> |
624 | 38 |
|
629 | 39 |
QImage getAmmoImage(int num) |
40 |
{ |
|
15971
cee831693af1
Add ExtraDamage icon variant for locales with comma as decimal separator
Wuzzy <Wuzzy@disroot.org>
parents:
15638
diff
changeset
|
41 |
// Show ammo image for ammo selection menu |
cee831693af1
Add ExtraDamage icon variant for locales with comma as decimal separator
Wuzzy <Wuzzy@disroot.org>
parents:
15638
diff
changeset
|
42 |
if (QLocale().decimalPoint() == "," && num == HW_AMMOTYPE_EXTRADAMAGE) { |
cee831693af1
Add ExtraDamage icon variant for locales with comma as decimal separator
Wuzzy <Wuzzy@disroot.org>
parents:
15638
diff
changeset
|
43 |
// Special case: Extra Damage icon showing "1,5" instead of "1.5" if locale |
cee831693af1
Add ExtraDamage icon variant for locales with comma as decimal separator
Wuzzy <Wuzzy@disroot.org>
parents:
15638
diff
changeset
|
44 |
// uses comma as decimal separator |
cee831693af1
Add ExtraDamage icon variant for locales with comma as decimal separator
Wuzzy <Wuzzy@disroot.org>
parents:
15638
diff
changeset
|
45 |
static QImage extradamage(":Ammos_ExtraDamage_comma.png"); |
cee831693af1
Add ExtraDamage icon variant for locales with comma as decimal separator
Wuzzy <Wuzzy@disroot.org>
parents:
15638
diff
changeset
|
46 |
return extradamage; |
cee831693af1
Add ExtraDamage icon variant for locales with comma as decimal separator
Wuzzy <Wuzzy@disroot.org>
parents:
15638
diff
changeset
|
47 |
} else { |
cee831693af1
Add ExtraDamage icon variant for locales with comma as decimal separator
Wuzzy <Wuzzy@disroot.org>
parents:
15638
diff
changeset
|
48 |
// Normal case: Pick icon from Ammos.png |
cee831693af1
Add ExtraDamage icon variant for locales with comma as decimal separator
Wuzzy <Wuzzy@disroot.org>
parents:
15638
diff
changeset
|
49 |
static QImage ammo(":Ammos.png"); |
cee831693af1
Add ExtraDamage icon variant for locales with comma as decimal separator
Wuzzy <Wuzzy@disroot.org>
parents:
15638
diff
changeset
|
50 |
int x = num/(ammo.height()/32); |
cee831693af1
Add ExtraDamage icon variant for locales with comma as decimal separator
Wuzzy <Wuzzy@disroot.org>
parents:
15638
diff
changeset
|
51 |
int y = (num-((ammo.height()/32)*x))*32; |
cee831693af1
Add ExtraDamage icon variant for locales with comma as decimal separator
Wuzzy <Wuzzy@disroot.org>
parents:
15638
diff
changeset
|
52 |
x*=32; |
cee831693af1
Add ExtraDamage icon variant for locales with comma as decimal separator
Wuzzy <Wuzzy@disroot.org>
parents:
15638
diff
changeset
|
53 |
return ammo.copy(x, y, 32, 32); |
cee831693af1
Add ExtraDamage icon variant for locales with comma as decimal separator
Wuzzy <Wuzzy@disroot.org>
parents:
15638
diff
changeset
|
54 |
} |
629 | 55 |
} |
56 |
||
4412
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
57 |
SelWeaponItem::SelWeaponItem(bool allowInfinite, int iconNum, int wNum, QImage image, QImage imagegrey, QWidget* parent) : |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
58 |
QWidget(parent) |
629 | 59 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
60 |
QHBoxLayout* hbLayout = new QHBoxLayout(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
61 |
hbLayout->setSpacing(1); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
62 |
hbLayout->setMargin(1); |
2377 | 63 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
64 |
QLabel* lbl = new QLabel(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
65 |
lbl->setPixmap(QPixmap::fromImage(getAmmoImage(iconNum))); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
66 |
lbl->setMaximumWidth(30); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
67 |
lbl->setGeometry(0, 0, 30, 30); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
68 |
hbLayout->addWidget(lbl); |
639 | 69 |
|
4412
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
70 |
item = new WeaponItem(image, imagegrey, this); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
71 |
item->setItemsNum(wNum); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
72 |
item->setInfinityState(allowInfinite); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
73 |
hbLayout->addWidget(item); |
639 | 74 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
75 |
hbLayout->setStretchFactor(lbl, 1); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
76 |
hbLayout->setStretchFactor(item, 99); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
77 |
hbLayout->setAlignment(lbl, Qt::AlignLeft | Qt::AlignVCenter); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
78 |
hbLayout->setAlignment(item, Qt::AlignLeft | Qt::AlignVCenter); |
629 | 79 |
} |
612
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
598
diff
changeset
|
80 |
|
683 | 81 |
void SelWeaponItem::setItemsNum(const unsigned char num) |
82 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
83 |
item->setItemsNum(num); |
683 | 84 |
} |
85 |
||
681 | 86 |
unsigned char SelWeaponItem::getItemsNum() const |
87 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
88 |
return item->getItemsNum(); |
681 | 89 |
} |
90 |
||
4412
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
91 |
void SelWeaponItem::setEnabled(bool value) |
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
92 |
{ |
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
93 |
item->setEnabled(value); |
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
94 |
} |
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
95 |
|
15594
fdca2af677a9
Cleaner digit parsing of ammo schemes
Wuzzy <Wuzzy2@mail.ru>
parents:
15542
diff
changeset
|
96 |
int SelWeaponWidget::readWeaponValue(const QChar chr, int max) |
fdca2af677a9
Cleaner digit parsing of ammo schemes
Wuzzy <Wuzzy2@mail.ru>
parents:
15542
diff
changeset
|
97 |
{ |
fdca2af677a9
Cleaner digit parsing of ammo schemes
Wuzzy <Wuzzy2@mail.ru>
parents:
15542
diff
changeset
|
98 |
int value = chr.digitValue(); |
fdca2af677a9
Cleaner digit parsing of ammo schemes
Wuzzy <Wuzzy2@mail.ru>
parents:
15542
diff
changeset
|
99 |
if (value == -1) |
fdca2af677a9
Cleaner digit parsing of ammo schemes
Wuzzy <Wuzzy2@mail.ru>
parents:
15542
diff
changeset
|
100 |
value = 0; |
fdca2af677a9
Cleaner digit parsing of ammo schemes
Wuzzy <Wuzzy2@mail.ru>
parents:
15542
diff
changeset
|
101 |
else if (value > max) |
fdca2af677a9
Cleaner digit parsing of ammo schemes
Wuzzy <Wuzzy2@mail.ru>
parents:
15542
diff
changeset
|
102 |
value = max; |
fdca2af677a9
Cleaner digit parsing of ammo schemes
Wuzzy <Wuzzy2@mail.ru>
parents:
15542
diff
changeset
|
103 |
return value; |
fdca2af677a9
Cleaner digit parsing of ammo schemes
Wuzzy <Wuzzy2@mail.ru>
parents:
15542
diff
changeset
|
104 |
} |
fdca2af677a9
Cleaner digit parsing of ammo schemes
Wuzzy <Wuzzy2@mail.ru>
parents:
15542
diff
changeset
|
105 |
|
683 | 106 |
SelWeaponWidget::SelWeaponWidget(int numItems, QWidget* parent) : |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
107 |
QFrame(parent), |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
108 |
m_numItems(numItems) |
612
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
598
diff
changeset
|
109 |
{ |
13314
fe85ba81b01b
I guess "Fix weapon scheme lookup being unnecesarily persisted"?.. or something
alfadur
parents:
13196
diff
changeset
|
110 |
wconf = new QMap<QString, QString>(); |
fe85ba81b01b
I guess "Fix weapon scheme lookup being unnecesarily persisted"?.. or something
alfadur
parents:
13196
diff
changeset
|
111 |
for(int i = 0; i < cDefaultAmmos.size(); ++i) |
13315 | 112 |
{ |
13314
fe85ba81b01b
I guess "Fix weapon scheme lookup being unnecesarily persisted"?.. or something
alfadur
parents:
13196
diff
changeset
|
113 |
wconf->insert(cDefaultAmmos[i].first, cDefaultAmmos[i].second); |
13315 | 114 |
} |
13314
fe85ba81b01b
I guess "Fix weapon scheme lookup being unnecesarily persisted"?.. or something
alfadur
parents:
13196
diff
changeset
|
115 |
|
13195
7d9462d49d4c
Fix bad import of old ammo schemes, improve debug output when importing schemes from old .ini files
Wuzzy <Wuzzy2@mail.ru>
parents:
12923
diff
changeset
|
116 |
if (!QDir(cfgdir->absolutePath() + "/Schemes").exists()) { |
7d9462d49d4c
Fix bad import of old ammo schemes, improve debug output when importing schemes from old .ini files
Wuzzy <Wuzzy2@mail.ru>
parents:
12923
diff
changeset
|
117 |
QDir().mkdir(cfgdir->absolutePath() + "/Schemes"); |
7d9462d49d4c
Fix bad import of old ammo schemes, improve debug output when importing schemes from old .ini files
Wuzzy <Wuzzy2@mail.ru>
parents:
12923
diff
changeset
|
118 |
} |
13852
e7c69e849005
Don't save default weapon scheme in file; don't load weapon scheme from file if name collides with default scheme
Wuzzy <Wuzzy2@mail.ru>
parents:
13555
diff
changeset
|
119 |
QStringList defaultAmmos; |
e7c69e849005
Don't save default weapon scheme in file; don't load weapon scheme from file if name collides with default scheme
Wuzzy <Wuzzy2@mail.ru>
parents:
13555
diff
changeset
|
120 |
for(int i = 0; i < cDefaultAmmos.size(); ++i) |
e7c69e849005
Don't save default weapon scheme in file; don't load weapon scheme from file if name collides with default scheme
Wuzzy <Wuzzy2@mail.ru>
parents:
13555
diff
changeset
|
121 |
{ |
e7c69e849005
Don't save default weapon scheme in file; don't load weapon scheme from file if name collides with default scheme
Wuzzy <Wuzzy2@mail.ru>
parents:
13555
diff
changeset
|
122 |
defaultAmmos.append(cDefaultAmmos[i].first.toLower()); |
e7c69e849005
Don't save default weapon scheme in file; don't load weapon scheme from file if name collides with default scheme
Wuzzy <Wuzzy2@mail.ru>
parents:
13555
diff
changeset
|
123 |
} |
12923 | 124 |
if (!QDir(cfgdir->absolutePath() + "/Schemes/Ammo").exists()) { |
13195
7d9462d49d4c
Fix bad import of old ammo schemes, improve debug output when importing schemes from old .ini files
Wuzzy <Wuzzy2@mail.ru>
parents:
12923
diff
changeset
|
125 |
qDebug("No /Schemes/Ammo directory found. Trying to import weapon schemes from weapons.ini."); |
12923 | 126 |
QDir().mkdir(cfgdir->absolutePath() + "/Schemes/Ammo"); |
13314
fe85ba81b01b
I guess "Fix weapon scheme lookup being unnecesarily persisted"?.. or something
alfadur
parents:
13196
diff
changeset
|
127 |
|
12923 | 128 |
QSettings old_wconf(cfgdir->absolutePath() + "/weapons.ini", QSettings::IniFormat); |
1004
4cbd91296df7
Don't let updated hedgewars version to make errors due to old weapons.ini
unc0rr
parents:
883
diff
changeset
|
129 |
|
12923 | 130 |
QStringList keys = old_wconf.allKeys(); |
13195
7d9462d49d4c
Fix bad import of old ammo schemes, improve debug output when importing schemes from old .ini files
Wuzzy <Wuzzy2@mail.ru>
parents:
12923
diff
changeset
|
131 |
int imported = 0; |
12922 | 132 |
for(int i = 0; i < keys.size(); i++) |
133 |
{ |
|
13852
e7c69e849005
Don't save default weapon scheme in file; don't load weapon scheme from file if name collides with default scheme
Wuzzy <Wuzzy2@mail.ru>
parents:
13555
diff
changeset
|
134 |
if (!defaultAmmos.contains(keys[i].toLower())) { |
13314
fe85ba81b01b
I guess "Fix weapon scheme lookup being unnecesarily persisted"?.. or something
alfadur
parents:
13196
diff
changeset
|
135 |
wconf->insert(keys[i], fixWeaponSet(old_wconf.value(keys[i]).toString())); |
12923 | 136 |
QFile file(cfgdir->absolutePath() + "/Schemes/Ammo/" + keys[i] + ".hwa"); |
137 |
if (file.open(QIODevice::WriteOnly)) { |
|
138 |
QTextStream stream( &file ); |
|
139 |
stream << old_wconf.value(keys[i]).toString() << endl; |
|
13196
f93658732448
Game scheme handling: Use QFile instead of QSettings for increased efficiency
Wuzzy <Wuzzy2@mail.ru>
parents:
13195
diff
changeset
|
140 |
file.close(); |
12923 | 141 |
} |
13195
7d9462d49d4c
Fix bad import of old ammo schemes, improve debug output when importing schemes from old .ini files
Wuzzy <Wuzzy2@mail.ru>
parents:
12923
diff
changeset
|
142 |
imported++; |
12922 | 143 |
} |
144 |
} |
|
13195
7d9462d49d4c
Fix bad import of old ammo schemes, improve debug output when importing schemes from old .ini files
Wuzzy <Wuzzy2@mail.ru>
parents:
12923
diff
changeset
|
145 |
qDebug("%d weapon scheme(s) imported.", imported); |
13315 | 146 |
} else { |
13320
b024cf25bde1
Use QDir::Files to read ammo schemes
Wuzzy <Wuzzy2@mail.ru>
parents:
13315
diff
changeset
|
147 |
QStringList schemes = QDir(cfgdir->absolutePath() + "/Schemes/Ammo").entryList(QDir::Files); |
12922 | 148 |
|
149 |
for(int i = 0; i < schemes.size(); i++) |
|
150 |
{ |
|
12923 | 151 |
QFile file(cfgdir->absolutePath() + "/Schemes/Ammo/" + schemes[i]); |
12922 | 152 |
QString config; |
153 |
if (file.open(QIODevice::ReadOnly)) { |
|
154 |
QTextStream stream( &file ); |
|
155 |
stream >> config; |
|
13196
f93658732448
Game scheme handling: Use QFile instead of QSettings for increased efficiency
Wuzzy <Wuzzy2@mail.ru>
parents:
13195
diff
changeset
|
156 |
file.close(); |
12922 | 157 |
} |
158 |
||
13196
f93658732448
Game scheme handling: Use QFile instead of QSettings for increased efficiency
Wuzzy <Wuzzy2@mail.ru>
parents:
13195
diff
changeset
|
159 |
// Chop off file name suffix |
f93658732448
Game scheme handling: Use QFile instead of QSettings for increased efficiency
Wuzzy <Wuzzy2@mail.ru>
parents:
13195
diff
changeset
|
160 |
QString schemeName = schemes[i]; |
f93658732448
Game scheme handling: Use QFile instead of QSettings for increased efficiency
Wuzzy <Wuzzy2@mail.ru>
parents:
13195
diff
changeset
|
161 |
if (schemeName.endsWith(".hwa", Qt::CaseInsensitive)) { |
f93658732448
Game scheme handling: Use QFile instead of QSettings for increased efficiency
Wuzzy <Wuzzy2@mail.ru>
parents:
13195
diff
changeset
|
162 |
schemeName.chop(4); |
f93658732448
Game scheme handling: Use QFile instead of QSettings for increased efficiency
Wuzzy <Wuzzy2@mail.ru>
parents:
13195
diff
changeset
|
163 |
} |
13852
e7c69e849005
Don't save default weapon scheme in file; don't load weapon scheme from file if name collides with default scheme
Wuzzy <Wuzzy2@mail.ru>
parents:
13555
diff
changeset
|
164 |
// Don't load weapon scheme if name collides with any default scheme |
e7c69e849005
Don't save default weapon scheme in file; don't load weapon scheme from file if name collides with default scheme
Wuzzy <Wuzzy2@mail.ru>
parents:
13555
diff
changeset
|
165 |
if (!defaultAmmos.contains(schemeName.toLower())) |
e7c69e849005
Don't save default weapon scheme in file; don't load weapon scheme from file if name collides with default scheme
Wuzzy <Wuzzy2@mail.ru>
parents:
13555
diff
changeset
|
166 |
wconf->insert(schemeName, fixWeaponSet(config)); |
e7c69e849005
Don't save default weapon scheme in file; don't load weapon scheme from file if name collides with default scheme
Wuzzy <Wuzzy2@mail.ru>
parents:
13555
diff
changeset
|
167 |
else |
e7c69e849005
Don't save default weapon scheme in file; don't load weapon scheme from file if name collides with default scheme
Wuzzy <Wuzzy2@mail.ru>
parents:
13555
diff
changeset
|
168 |
qWarning("Weapon scheme \"%s\" not loaded from file, name collides with a default scheme!", qPrintable(schemeName)); |
12922 | 169 |
} |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
170 |
} |
1576
a02353129a41
Check for deprecated ammo schemes at startup and delete them
unc0rr
parents:
1509
diff
changeset
|
171 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
172 |
QString currentState = *cDefaultAmmoStore; |
683 | 173 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
174 |
QTabWidget * tbw = new QTabWidget(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
175 |
QWidget * page1 = new QWidget(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
176 |
p1Layout = new QGridLayout(page1); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
177 |
p1Layout->setSpacing(1); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
178 |
p1Layout->setMargin(1); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
179 |
QWidget * page2 = new QWidget(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
180 |
p2Layout = new QGridLayout(page2); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
181 |
p2Layout->setSpacing(1); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
182 |
p2Layout->setMargin(1); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
183 |
QWidget * page3 = new QWidget(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
184 |
p3Layout = new QGridLayout(page3); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
185 |
p3Layout->setSpacing(1); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
186 |
p3Layout->setMargin(1); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
187 |
QWidget * page4 = new QWidget(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
188 |
p4Layout = new QGridLayout(page4); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
189 |
p4Layout->setSpacing(1); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
190 |
p4Layout->setMargin(1); |
2377 | 191 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
192 |
tbw->addTab(page1, tr("Weapon set")); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
193 |
tbw->addTab(page2, tr("Probabilities")); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
194 |
tbw->addTab(page4, tr("Ammo in boxes")); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
195 |
tbw->addTab(page3, tr("Delays")); |
2377 | 196 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
197 |
QGridLayout * pageLayout = new QGridLayout(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
198 |
pageLayout->addWidget(tbw); |
2369
c3eb11f1ab3a
Implement probability editor for weapon schemes (engine doesn't support that yet)
unc0rr
parents:
1967
diff
changeset
|
199 |
|
629 | 200 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
201 |
int j = -1; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
202 |
int i = 0, k = 0; |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
203 |
for(; i < m_numItems; ++i) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
204 |
{ |
15638 | 205 |
if (k % cAmmoMenuRows == 0) |
206 |
++j; |
|
207 |
unsigned int ammo = ammoMenuAmmos[i]; |
|
208 |
// Hide amSkip (7) |
|
209 |
if (ammo == 7) |
|
210 |
continue; |
|
211 |
// Hide unused amCreeper (58) |
|
212 |
else if (ammo == 58) |
|
213 |
{ |
|
214 |
++k; |
|
215 |
continue; |
|
216 |
} |
|
217 |
int a = ammo-1; // ammo ID for SelWeaponItem |
|
218 |
SelWeaponItem * swi = new SelWeaponItem(true, a, readWeaponValue(currentState[a], 9), QImage(":/res/ammopic.png"), QImage(":/res/ammopicgrey.png"), this); |
|
219 |
weaponItems[a].append(swi); |
|
220 |
p1Layout->addWidget(swi, j, k % cAmmoMenuRows); |
|
2377 | 221 |
|
15638 | 222 |
SelWeaponItem * pwi = new SelWeaponItem(false, a, readWeaponValue(currentState[numItems + a], 8), QImage(":/res/ammopicbox.png"), QImage(":/res/ammopicboxgrey.png"), this); |
223 |
weaponItems[a].append(pwi); |
|
224 |
p2Layout->addWidget(pwi, j, k % cAmmoMenuRows); |
|
3697 | 225 |
|
15638 | 226 |
SelWeaponItem * dwi = new SelWeaponItem(false, a, readWeaponValue(currentState[numItems*2 + a], 8), QImage(":/res/ammopicdelay.png"), QImage(":/res/ammopicdelaygrey.png"), this); |
227 |
weaponItems[a].append(dwi); |
|
228 |
p3Layout->addWidget(dwi, j, k % cAmmoMenuRows); |
|
3697 | 229 |
|
15638 | 230 |
SelWeaponItem * awi = new SelWeaponItem(false, a, readWeaponValue(currentState[numItems*3 + a], 8), QImage(":/res/ammopic.png"), QImage(":/res/ammopicgrey.png"), this); |
231 |
weaponItems[a].append(awi); |
|
232 |
p4Layout->addWidget(awi, j, k % cAmmoMenuRows); |
|
2377 | 233 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
234 |
++k; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
235 |
} |
694 | 236 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
237 |
//pLayout->setRowStretch(5, 100); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
238 |
m_name = new QLineEdit(this); |
14839
e239378a9400
Prevent entering “/”, “\” and “:” in team and scheme names.
Wuzzy <Wuzzy2@mail.ru>
parents:
14836
diff
changeset
|
239 |
QRegExp rx(*cSafeFileNameRegExp); |
e239378a9400
Prevent entering “/”, “\” and “:” in team and scheme names.
Wuzzy <Wuzzy2@mail.ru>
parents:
14836
diff
changeset
|
240 |
QRegExpValidator* val = new QRegExpValidator(rx, m_name); |
e239378a9400
Prevent entering “/”, “\” and “:” in team and scheme names.
Wuzzy <Wuzzy2@mail.ru>
parents:
14836
diff
changeset
|
241 |
m_name->setValidator(val); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
242 |
pageLayout->addWidget(m_name, i, 0, 1, 5); |
612
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
598
diff
changeset
|
243 |
} |
681 | 244 |
|
694 | 245 |
void SelWeaponWidget::setWeapons(const QString& ammo) |
683 | 246 |
{ |
4412
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
247 |
bool enable = true; |
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
248 |
for(int i = 0; i < cDefaultAmmos.size(); i++) |
13315 | 249 |
{ |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
250 |
if (!cDefaultAmmos[i].first.compare(m_name->text())) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
251 |
{ |
4412
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
252 |
enable = false; |
13315 | 253 |
break; |
4412
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
254 |
} |
13315 | 255 |
} |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
256 |
for(int i = 0; i < m_numItems; ++i) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
257 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
258 |
twi::iterator it = weaponItems.find(i); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
259 |
if (it == weaponItems.end()) continue; |
15594
fdca2af677a9
Cleaner digit parsing of ammo schemes
Wuzzy <Wuzzy2@mail.ru>
parents:
15542
diff
changeset
|
260 |
it.value()[0]->setItemsNum(readWeaponValue(ammo[i], 9)); |
fdca2af677a9
Cleaner digit parsing of ammo schemes
Wuzzy <Wuzzy2@mail.ru>
parents:
15542
diff
changeset
|
261 |
it.value()[1]->setItemsNum(readWeaponValue(ammo[m_numItems + i], 8)); |
fdca2af677a9
Cleaner digit parsing of ammo schemes
Wuzzy <Wuzzy2@mail.ru>
parents:
15542
diff
changeset
|
262 |
it.value()[2]->setItemsNum(readWeaponValue(ammo[m_numItems*2 + i], 8)); |
fdca2af677a9
Cleaner digit parsing of ammo schemes
Wuzzy <Wuzzy2@mail.ru>
parents:
15542
diff
changeset
|
263 |
it.value()[3]->setItemsNum(readWeaponValue(ammo[m_numItems*3 + i], 8)); |
4412
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
264 |
it.value()[0]->setEnabled(enable); |
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
265 |
it.value()[1]->setEnabled(enable); |
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
266 |
it.value()[2]->setEnabled(enable); |
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
267 |
it.value()[3]->setEnabled(enable); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
268 |
} |
4412
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
269 |
m_name->setEnabled(enable); |
683 | 270 |
} |
271 |
||
272 |
void SelWeaponWidget::setDefault() |
|
273 |
{ |
|
4412
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
274 |
for(int i = 0; i < cDefaultAmmos.size(); i++) |
13315 | 275 |
{ |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
276 |
if (!cDefaultAmmos[i].first.compare(m_name->text())) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
277 |
{ |
4412
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
278 |
return; |
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
279 |
} |
13315 | 280 |
} |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
281 |
setWeapons(*cDefaultAmmoStore); |
683 | 282 |
} |
283 |
||
12665
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
284 |
//Save current weapons set. |
683 | 285 |
void SelWeaponWidget::save() |
286 |
{ |
|
12665
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
287 |
//The save() function is called by ANY change of the combo box. |
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
288 |
//If an entry is deleted, this code would just re-add the deleted |
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
289 |
//item. We use isDeleted to check if we are currently deleting to |
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
290 |
//prevent this. |
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
291 |
if (isDeleting) |
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
292 |
return; |
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
293 |
if (m_name->text() == "") |
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
294 |
return; |
2377 | 295 |
|
13852
e7c69e849005
Don't save default weapon scheme in file; don't load weapon scheme from file if name collides with default scheme
Wuzzy <Wuzzy2@mail.ru>
parents:
13555
diff
changeset
|
296 |
// Don't save an default ammo scheme |
e7c69e849005
Don't save default weapon scheme in file; don't load weapon scheme from file if name collides with default scheme
Wuzzy <Wuzzy2@mail.ru>
parents:
13555
diff
changeset
|
297 |
for(int i = 0; i < cDefaultAmmos.size(); ++i) |
e7c69e849005
Don't save default weapon scheme in file; don't load weapon scheme from file if name collides with default scheme
Wuzzy <Wuzzy2@mail.ru>
parents:
13555
diff
changeset
|
298 |
{ |
e7c69e849005
Don't save default weapon scheme in file; don't load weapon scheme from file if name collides with default scheme
Wuzzy <Wuzzy2@mail.ru>
parents:
13555
diff
changeset
|
299 |
if(curWeaponsName == cDefaultAmmos[i].first) |
e7c69e849005
Don't save default weapon scheme in file; don't load weapon scheme from file if name collides with default scheme
Wuzzy <Wuzzy2@mail.ru>
parents:
13555
diff
changeset
|
300 |
return; |
e7c69e849005
Don't save default weapon scheme in file; don't load weapon scheme from file if name collides with default scheme
Wuzzy <Wuzzy2@mail.ru>
parents:
13555
diff
changeset
|
301 |
} |
e7c69e849005
Don't save default weapon scheme in file; don't load weapon scheme from file if name collides with default scheme
Wuzzy <Wuzzy2@mail.ru>
parents:
13555
diff
changeset
|
302 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
303 |
QString state1; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
304 |
QString state2; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
305 |
QString state3; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
306 |
QString state4; |
7830
72e52da6ea7f
fix for issue 441 ("Cannot overwrite default weapon set 'Default'!" message when no change to weapon set was made)
sheepluva
parents:
7797
diff
changeset
|
307 |
QString stateFull; |
2377 | 308 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
309 |
for(int i = 0; i < m_numItems; ++i) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
310 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
311 |
twi::const_iterator it = weaponItems.find(i); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
312 |
int num = it == weaponItems.end() ? 9 : it.value()[0]->getItemsNum(); // 9 is for 'skip turn' |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
313 |
state1.append(QString::number(num)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
314 |
int prob = it == weaponItems.end() ? 0 : it.value()[1]->getItemsNum(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
315 |
state2.append(QString::number(prob)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
316 |
int del = it == weaponItems.end() ? 0 : it.value()[2]->getItemsNum(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
317 |
state3.append(QString::number(del)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
318 |
int am = it == weaponItems.end() ? 0 : it.value()[3]->getItemsNum(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
319 |
state4.append(QString::number(am)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
320 |
} |
7830
72e52da6ea7f
fix for issue 441 ("Cannot overwrite default weapon set 'Default'!" message when no change to weapon set was made)
sheepluva
parents:
7797
diff
changeset
|
321 |
|
72e52da6ea7f
fix for issue 441 ("Cannot overwrite default weapon set 'Default'!" message when no change to weapon set was made)
sheepluva
parents:
7797
diff
changeset
|
322 |
stateFull = state1 + state2 + state3 + state4; |
72e52da6ea7f
fix for issue 441 ("Cannot overwrite default weapon set 'Default'!" message when no change to weapon set was made)
sheepluva
parents:
7797
diff
changeset
|
323 |
|
13555
43b72629d453
Prevent saving weapon scheme if name was already taken
Wuzzy <Wuzzy2@mail.ru>
parents:
13320
diff
changeset
|
324 |
// Check for duplicates |
43b72629d453
Prevent saving weapon scheme if name was already taken
Wuzzy <Wuzzy2@mail.ru>
parents:
13320
diff
changeset
|
325 |
QString inputNameLower = m_name->text().toLower(); |
43b72629d453
Prevent saving weapon scheme if name was already taken
Wuzzy <Wuzzy2@mail.ru>
parents:
13320
diff
changeset
|
326 |
QString curWeaponsNameLower = curWeaponsName.toLower(); |
43b72629d453
Prevent saving weapon scheme if name was already taken
Wuzzy <Wuzzy2@mail.ru>
parents:
13320
diff
changeset
|
327 |
QStringList keys = wconf->keys(); |
43b72629d453
Prevent saving weapon scheme if name was already taken
Wuzzy <Wuzzy2@mail.ru>
parents:
13320
diff
changeset
|
328 |
for(int i = 0; i < keys.size(); i++) |
7830
72e52da6ea7f
fix for issue 441 ("Cannot overwrite default weapon set 'Default'!" message when no change to weapon set was made)
sheepluva
parents:
7797
diff
changeset
|
329 |
{ |
13555
43b72629d453
Prevent saving weapon scheme if name was already taken
Wuzzy <Wuzzy2@mail.ru>
parents:
13320
diff
changeset
|
330 |
QString compName = keys[i]; |
43b72629d453
Prevent saving weapon scheme if name was already taken
Wuzzy <Wuzzy2@mail.ru>
parents:
13320
diff
changeset
|
331 |
QString compNameLower = compName.toLower(); |
43b72629d453
Prevent saving weapon scheme if name was already taken
Wuzzy <Wuzzy2@mail.ru>
parents:
13320
diff
changeset
|
332 |
// Don't allow same name as other weapon set, even case-insensitively. |
12689
5b135c26f320
Don't let player save ammo scheme with pre-installed name, even case-insensitively
Wuzzy <almikes@aol.com>
parents:
12665
diff
changeset
|
333 |
// This prevents some problems with saving/loading. |
13555
43b72629d453
Prevent saving weapon scheme if name was already taken
Wuzzy <Wuzzy2@mail.ru>
parents:
13320
diff
changeset
|
334 |
if ((compNameLower == inputNameLower) && (compNameLower != curWeaponsNameLower)) |
7830
72e52da6ea7f
fix for issue 441 ("Cannot overwrite default weapon set 'Default'!" message when no change to weapon set was made)
sheepluva
parents:
7797
diff
changeset
|
335 |
{ |
13555
43b72629d453
Prevent saving weapon scheme if name was already taken
Wuzzy <Wuzzy2@mail.ru>
parents:
13320
diff
changeset
|
336 |
// Discard changed made to current weapon scheme if there's a duplicate |
12689
5b135c26f320
Don't let player save ammo scheme with pre-installed name, even case-insensitively
Wuzzy <almikes@aol.com>
parents:
12665
diff
changeset
|
337 |
m_name->setText(curWeaponsName); |
7830
72e52da6ea7f
fix for issue 441 ("Cannot overwrite default weapon set 'Default'!" message when no change to weapon set was made)
sheepluva
parents:
7797
diff
changeset
|
338 |
QMessageBox deniedMsg(this); |
72e52da6ea7f
fix for issue 441 ("Cannot overwrite default weapon set 'Default'!" message when no change to weapon set was made)
sheepluva
parents:
7797
diff
changeset
|
339 |
deniedMsg.setIcon(QMessageBox::Warning); |
72e52da6ea7f
fix for issue 441 ("Cannot overwrite default weapon set 'Default'!" message when no change to weapon set was made)
sheepluva
parents:
7797
diff
changeset
|
340 |
deniedMsg.setWindowTitle(QMessageBox::tr("Weapons - Warning")); |
13555
43b72629d453
Prevent saving weapon scheme if name was already taken
Wuzzy <Wuzzy2@mail.ru>
parents:
13320
diff
changeset
|
341 |
deniedMsg.setText(QMessageBox::tr("A weapon scheme with the name '%1' already exists. Changes made to the weapon scheme have been discarded.").arg(compName)); |
14836
b9437746bffb
Frontend: Force plain text mode for many message windows
Wuzzy <Wuzzy2@mail.ru>
parents:
13854
diff
changeset
|
342 |
deniedMsg.setTextFormat(Qt::PlainText); |
7830
72e52da6ea7f
fix for issue 441 ("Cannot overwrite default weapon set 'Default'!" message when no change to weapon set was made)
sheepluva
parents:
7797
diff
changeset
|
343 |
deniedMsg.setWindowModality(Qt::WindowModal); |
72e52da6ea7f
fix for issue 441 ("Cannot overwrite default weapon set 'Default'!" message when no change to weapon set was made)
sheepluva
parents:
7797
diff
changeset
|
344 |
deniedMsg.exec(); |
72e52da6ea7f
fix for issue 441 ("Cannot overwrite default weapon set 'Default'!" message when no change to weapon set was made)
sheepluva
parents:
7797
diff
changeset
|
345 |
return; |
72e52da6ea7f
fix for issue 441 ("Cannot overwrite default weapon set 'Default'!" message when no change to weapon set was made)
sheepluva
parents:
7797
diff
changeset
|
346 |
} |
72e52da6ea7f
fix for issue 441 ("Cannot overwrite default weapon set 'Default'!" message when no change to weapon set was made)
sheepluva
parents:
7797
diff
changeset
|
347 |
} |
72e52da6ea7f
fix for issue 441 ("Cannot overwrite default weapon set 'Default'!" message when no change to weapon set was made)
sheepluva
parents:
7797
diff
changeset
|
348 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
349 |
if (curWeaponsName != "") |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
350 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
351 |
// remove old entry |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
352 |
wconf->remove(curWeaponsName); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
353 |
} |
13314
fe85ba81b01b
I guess "Fix weapon scheme lookup being unnecesarily persisted"?.. or something
alfadur
parents:
13196
diff
changeset
|
354 |
wconf->insert(m_name->text(), stateFull); |
12923 | 355 |
QFile file(cfgdir->absolutePath() + "/Schemes/Ammo/" + m_name->text()+ ".hwa"); |
12922 | 356 |
if (file.open(QIODevice::WriteOnly)) { |
357 |
QTextStream stream( &file ); |
|
358 |
stream << stateFull << endl; |
|
13196
f93658732448
Game scheme handling: Use QFile instead of QSettings for increased efficiency
Wuzzy <Wuzzy2@mail.ru>
parents:
13195
diff
changeset
|
359 |
file.close(); |
12922 | 360 |
} |
12665
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
361 |
emit weaponsEdited(curWeaponsName, m_name->text(), stateFull); |
15542
3b0b6ce76303
Fix weapon schemes sometimes not being saved properly
Wuzzy <Wuzzy2@mail.ru>
parents:
14839
diff
changeset
|
362 |
curWeaponsName = m_name->text(); |
683 | 363 |
} |
364 |
||
681 | 365 |
int SelWeaponWidget::operator [] (unsigned int weaponIndex) const |
366 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
367 |
twi::const_iterator it = weaponItems.find(weaponIndex); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
368 |
return it == weaponItems.end() ? 9 : it.value()[0]->getItemsNum(); |
681 | 369 |
} |
370 |
||
696 | 371 |
QString SelWeaponWidget::getWeaponsString(const QString& name) const |
372 |
{ |
|
13314
fe85ba81b01b
I guess "Fix weapon scheme lookup being unnecesarily persisted"?.. or something
alfadur
parents:
13196
diff
changeset
|
373 |
return wconf->find(name).value(); |
696 | 374 |
} |
375 |
||
718 | 376 |
void SelWeaponWidget::deleteWeaponsName() |
377 |
{ |
|
12665
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
378 |
QString delWeaponsName = curWeaponsName; |
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
379 |
if (delWeaponsName == "") return; |
724 | 380 |
|
4412
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
381 |
for(int i = 0; i < cDefaultAmmos.size(); i++) |
13315 | 382 |
{ |
12665
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
383 |
if (!cDefaultAmmos[i].first.compare(delWeaponsName)) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
384 |
{ |
7797 | 385 |
QMessageBox deniedMsg(this); |
386 |
deniedMsg.setIcon(QMessageBox::Warning); |
|
387 |
deniedMsg.setWindowTitle(QMessageBox::tr("Weapons - Warning")); |
|
388 |
deniedMsg.setText(QMessageBox::tr("Cannot delete default weapon set '%1'!").arg(cDefaultAmmos[i].first)); |
|
14836
b9437746bffb
Frontend: Force plain text mode for many message windows
Wuzzy <Wuzzy2@mail.ru>
parents:
13854
diff
changeset
|
389 |
deniedMsg.setTextFormat(Qt::PlainText); |
7797 | 390 |
deniedMsg.setWindowModality(Qt::WindowModal); |
391 |
deniedMsg.exec(); |
|
4412
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
392 |
return; |
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
393 |
} |
13315 | 394 |
} |
1509 | 395 |
|
7797 | 396 |
QMessageBox reallyDeleteMsg(this); |
397 |
reallyDeleteMsg.setIcon(QMessageBox::Question); |
|
398 |
reallyDeleteMsg.setWindowTitle(QMessageBox::tr("Weapons - Are you sure?")); |
|
12665
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
399 |
reallyDeleteMsg.setText(QMessageBox::tr("Do you really want to delete the weapon set '%1'?").arg(delWeaponsName)); |
14836
b9437746bffb
Frontend: Force plain text mode for many message windows
Wuzzy <Wuzzy2@mail.ru>
parents:
13854
diff
changeset
|
400 |
reallyDeleteMsg.setTextFormat(Qt::PlainText); |
7797 | 401 |
reallyDeleteMsg.setWindowModality(Qt::WindowModal); |
402 |
reallyDeleteMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); |
|
2377 | 403 |
|
7797 | 404 |
if (reallyDeleteMsg.exec() == QMessageBox::Ok) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
405 |
{ |
12665
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
406 |
isDeleting = true; |
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
407 |
wconf->remove(delWeaponsName); |
12923 | 408 |
QFile(cfgdir->absolutePath() + "/Schemes/Ammo/" + curWeaponsName + ".hwa").remove(); |
12665
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
409 |
emit weaponsDeleted(delWeaponsName); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
410 |
} |
718 | 411 |
} |
412 |
||
4416
29d2d1548387
adding a combobox to weapon editor as scheme editor, added a few notices for deleting and some buttons in this area.
Henek
parents:
4412
diff
changeset
|
413 |
void SelWeaponWidget::newWeaponsName() |
29d2d1548387
adding a combobox to weapon editor as scheme editor, added a few notices for deleting and some buttons in this area.
Henek
parents:
4412
diff
changeset
|
414 |
{ |
12665
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
415 |
save(); |
11817
5f21387edff1
Slightly better naming of new or copied ammo/game schemes
Wuzzy <almikes@aol.com>
parents:
11763
diff
changeset
|
416 |
QString newName = tr("New"); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
417 |
if(wconf->contains(newName)) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
418 |
{ |
5029
97c650500991
solved issue 197 and other issues that were caused when copying or creating a new weapon set that was named like an already existing one. this will now be avoided.
Tobias Domhan <tdomhan@gmail.com>
parents:
4976
diff
changeset
|
419 |
//name already used -> look for an appropriate name: |
97c650500991
solved issue 197 and other issues that were caused when copying or creating a new weapon set that was named like an already existing one. this will now be avoided.
Tobias Domhan <tdomhan@gmail.com>
parents:
4976
diff
changeset
|
420 |
int i=2; |
11817
5f21387edff1
Slightly better naming of new or copied ammo/game schemes
Wuzzy <almikes@aol.com>
parents:
11763
diff
changeset
|
421 |
while(wconf->contains(newName = tr("New (%1)").arg(i++))) ; |
5029
97c650500991
solved issue 197 and other issues that were caused when copying or creating a new weapon set that was named like an already existing one. this will now be avoided.
Tobias Domhan <tdomhan@gmail.com>
parents:
4976
diff
changeset
|
422 |
} |
97c650500991
solved issue 197 and other issues that were caused when copying or creating a new weapon set that was named like an already existing one. this will now be avoided.
Tobias Domhan <tdomhan@gmail.com>
parents:
4976
diff
changeset
|
423 |
setWeaponsName(newName); |
13314
fe85ba81b01b
I guess "Fix weapon scheme lookup being unnecesarily persisted"?.. or something
alfadur
parents:
13196
diff
changeset
|
424 |
wconf->insert(newName, *cEmptyAmmoStore); |
12665
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
425 |
emit weaponsAdded(newName, *cEmptyAmmoStore); |
4416
29d2d1548387
adding a combobox to weapon editor as scheme editor, added a few notices for deleting and some buttons in this area.
Henek
parents:
4412
diff
changeset
|
426 |
} |
29d2d1548387
adding a combobox to weapon editor as scheme editor, added a few notices for deleting and some buttons in this area.
Henek
parents:
4412
diff
changeset
|
427 |
|
1509 | 428 |
void SelWeaponWidget::setWeaponsName(const QString& name) |
694 | 429 |
{ |
4412
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
430 |
m_name->setText(name); |
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
431 |
|
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
432 |
curWeaponsName = name; |
c9a78ba03679
added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable.
Henek
parents:
3697
diff
changeset
|
433 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
434 |
if(name != "" && wconf->contains(name)) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
435 |
{ |
13314
fe85ba81b01b
I guess "Fix weapon scheme lookup being unnecesarily persisted"?.. or something
alfadur
parents:
13196
diff
changeset
|
436 |
setWeapons(wconf->find(name).value()); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
437 |
} |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
438 |
else |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
439 |
{ |
11763
59e979b1408f
Add empty weapons scheme (instead of default) when using “New” button
Wuzzy <almikes@aol.com>
parents:
11046
diff
changeset
|
440 |
setWeapons(*cEmptyAmmoStore); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2860
diff
changeset
|
441 |
} |
694 | 442 |
} |
443 |
||
12665
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
444 |
void SelWeaponWidget::switchWeapons(const QString& name) |
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
445 |
{ |
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
446 |
// Rescue old weapons set, then select new one |
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
447 |
save(); |
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
448 |
setWeaponsName(name); |
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
449 |
} |
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
450 |
|
694 | 451 |
QStringList SelWeaponWidget::getWeaponNames() const |
452 |
{ |
|
13314
fe85ba81b01b
I guess "Fix weapon scheme lookup being unnecesarily persisted"?.. or something
alfadur
parents:
13196
diff
changeset
|
453 |
return wconf->keys(); |
694 | 454 |
} |
4598 | 455 |
|
456 |
void SelWeaponWidget::copy() |
|
457 |
{ |
|
12665
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
458 |
save(); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
459 |
if(wconf->contains(curWeaponsName)) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
460 |
{ |
5029
97c650500991
solved issue 197 and other issues that were caused when copying or creating a new weapon set that was named like an already existing one. this will now be avoided.
Tobias Domhan <tdomhan@gmail.com>
parents:
4976
diff
changeset
|
461 |
QString ammo = getWeaponsString(curWeaponsName); |
11817
5f21387edff1
Slightly better naming of new or copied ammo/game schemes
Wuzzy <almikes@aol.com>
parents:
11763
diff
changeset
|
462 |
QString newName = tr("Copy of %1").arg(curWeaponsName); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
463 |
if(wconf->contains(newName)) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6479
diff
changeset
|
464 |
{ |
5029
97c650500991
solved issue 197 and other issues that were caused when copying or creating a new weapon set that was named like an already existing one. this will now be avoided.
Tobias Domhan <tdomhan@gmail.com>
parents:
4976
diff
changeset
|
465 |
//name already used -> look for an appropriate name: |
97c650500991
solved issue 197 and other issues that were caused when copying or creating a new weapon set that was named like an already existing one. this will now be avoided.
Tobias Domhan <tdomhan@gmail.com>
parents:
4976
diff
changeset
|
466 |
int i=2; |
12663
d7492247a368
Fix argument bug in default name of copy of copy of ammo scheme
Wuzzy <almikes@aol.com>
parents:
11817
diff
changeset
|
467 |
while(wconf->contains(newName = tr("Copy of %1 (%2)").arg(curWeaponsName).arg(i++))); |
5029
97c650500991
solved issue 197 and other issues that were caused when copying or creating a new weapon set that was named like an already existing one. this will now be avoided.
Tobias Domhan <tdomhan@gmail.com>
parents:
4976
diff
changeset
|
468 |
} |
97c650500991
solved issue 197 and other issues that were caused when copying or creating a new weapon set that was named like an already existing one. this will now be avoided.
Tobias Domhan <tdomhan@gmail.com>
parents:
4976
diff
changeset
|
469 |
setWeaponsName(newName); |
97c650500991
solved issue 197 and other issues that were caused when copying or creating a new weapon set that was named like an already existing one. this will now be avoided.
Tobias Domhan <tdomhan@gmail.com>
parents:
4976
diff
changeset
|
470 |
setWeapons(ammo); |
13314
fe85ba81b01b
I guess "Fix weapon scheme lookup being unnecesarily persisted"?.. or something
alfadur
parents:
13196
diff
changeset
|
471 |
wconf->insert(newName, ammo); |
12665
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
472 |
emit weaponsAdded(newName, ammo); |
5029
97c650500991
solved issue 197 and other issues that were caused when copying or creating a new weapon set that was named like an already existing one. this will now be avoided.
Tobias Domhan <tdomhan@gmail.com>
parents:
4976
diff
changeset
|
473 |
} |
4598 | 474 |
} |
9900 | 475 |
|
476 |
QString SelWeaponWidget::fixWeaponSet(const QString &s) |
|
477 |
{ |
|
478 |
int neededLength = cDefaultAmmoStore->size() / 4; |
|
479 |
int thisSetLength = s.size() / 4; |
|
480 |
||
481 |
QStringList sl; |
|
482 |
sl |
|
483 |
<< s.left(thisSetLength) |
|
484 |
<< s.mid(thisSetLength, thisSetLength) |
|
485 |
<< s.mid(thisSetLength * 2, thisSetLength) |
|
486 |
<< s.right(thisSetLength) |
|
487 |
; |
|
488 |
||
489 |
for(int i = sl.length() - 1; i >= 0; --i) |
|
13315 | 490 |
{ |
9900 | 491 |
sl[i] = sl[i].leftJustified(neededLength, '0', true); |
13315 | 492 |
} |
9900 | 493 |
|
494 |
return sl.join(QString()); |
|
495 |
} |
|
12665
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
496 |
|
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
497 |
void SelWeaponWidget::deletionDone() |
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
498 |
{ |
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
499 |
isDeleting = false; |
5664ec82aed7
Rework weapon scheme handling in frontend and fix a couple of bugs
Wuzzy <almikes@aol.com>
parents:
12663
diff
changeset
|
500 |
} |
12763
ad67a3804981
Fix sometimes ammo schemes not being saved after changing before an ammo scheme got deleted in session
Wuzzy <Wuzzy2@mail.ru>
parents:
12689
diff
changeset
|
501 |
|
ad67a3804981
Fix sometimes ammo schemes not being saved after changing before an ammo scheme got deleted in session
Wuzzy <Wuzzy2@mail.ru>
parents:
12689
diff
changeset
|
502 |
void SelWeaponWidget::init() |
ad67a3804981
Fix sometimes ammo schemes not being saved after changing before an ammo scheme got deleted in session
Wuzzy <Wuzzy2@mail.ru>
parents:
12689
diff
changeset
|
503 |
{ |
ad67a3804981
Fix sometimes ammo schemes not being saved after changing before an ammo scheme got deleted in session
Wuzzy <Wuzzy2@mail.ru>
parents:
12689
diff
changeset
|
504 |
isDeleting = false; |
ad67a3804981
Fix sometimes ammo schemes not being saved after changing before an ammo scheme got deleted in session
Wuzzy <Wuzzy2@mail.ru>
parents:
12689
diff
changeset
|
505 |
} |