40 QWidget(parent) |
40 QWidget(parent) |
41 { |
41 { |
42 QHBoxLayout* hbLayout = new QHBoxLayout(this); |
42 QHBoxLayout* hbLayout = new QHBoxLayout(this); |
43 hbLayout->setSpacing(1); |
43 hbLayout->setSpacing(1); |
44 hbLayout->setMargin(1); |
44 hbLayout->setMargin(1); |
45 |
45 |
46 QLabel* lbl = new QLabel(this); |
46 QLabel* lbl = new QLabel(this); |
47 lbl->setPixmap(QPixmap::fromImage(getAmmoImage(iconNum))); |
47 lbl->setPixmap(QPixmap::fromImage(getAmmoImage(iconNum))); |
48 lbl->setMaximumWidth(30); |
48 lbl->setMaximumWidth(30); |
49 lbl->setGeometry(0, 0, 30, 30); |
49 lbl->setGeometry(0, 0, 30, 30); |
50 hbLayout->addWidget(lbl); |
50 hbLayout->addWidget(lbl); |
95 p1Layout->setMargin(1); |
95 p1Layout->setMargin(1); |
96 QWidget * page2 = new QWidget(this); |
96 QWidget * page2 = new QWidget(this); |
97 p2Layout = new QGridLayout(page2); |
97 p2Layout = new QGridLayout(page2); |
98 p2Layout->setSpacing(1); |
98 p2Layout->setSpacing(1); |
99 p2Layout->setMargin(1); |
99 p2Layout->setMargin(1); |
100 |
100 |
101 tbw->addTab(page1, tr("Weapon set")); |
101 tbw->addTab(page1, tr("Weapon set")); |
102 tbw->addTab(page2, tr("Probabilities")); |
102 tbw->addTab(page2, tr("Probabilities")); |
103 |
103 |
104 QGridLayout * pageLayout = new QGridLayout(this); |
104 QGridLayout * pageLayout = new QGridLayout(this); |
105 pageLayout->addWidget(tbw); |
105 pageLayout->addWidget(tbw); |
106 |
106 |
107 |
107 |
108 int j = -1; |
108 int j = -1; |
111 if (i == 6) continue; |
111 if (i == 6) continue; |
112 if (k % 4 == 0) ++j; |
112 if (k % 4 == 0) ++j; |
113 SelWeaponItem * swi = new SelWeaponItem(true, i, currentState[i].digitValue(), this); |
113 SelWeaponItem * swi = new SelWeaponItem(true, i, currentState[i].digitValue(), this); |
114 weaponItems[i].append(swi); |
114 weaponItems[i].append(swi); |
115 p1Layout->addWidget(swi, j, k % 4); |
115 p1Layout->addWidget(swi, j, k % 4); |
116 |
116 |
117 SelWeaponItem * pwi = new SelWeaponItem(false, i, currentState[numItems + i].digitValue(), this); |
117 SelWeaponItem * pwi = new SelWeaponItem(false, i, currentState[numItems + i].digitValue(), this); |
118 weaponItems[i].append(pwi); |
118 weaponItems[i].append(pwi); |
119 p2Layout->addWidget(pwi, j, k % 4); |
119 p2Layout->addWidget(pwi, j, k % 4); |
120 |
120 |
121 ++k; |
121 ++k; |
122 } |
122 } |
123 |
123 |
124 //pLayout->setRowStretch(5, 100); |
124 //pLayout->setRowStretch(5, 100); |
125 m_name = new QLineEdit(this); |
125 m_name = new QLineEdit(this); |
147 if (m_name->text() == "Default") { |
147 if (m_name->text() == "Default") { |
148 QMessageBox impossible(QMessageBox::Warning, QMessageBox::tr("Weapons"), QMessageBox::tr("Can not edit default weapon set")); |
148 QMessageBox impossible(QMessageBox::Warning, QMessageBox::tr("Weapons"), QMessageBox::tr("Can not edit default weapon set")); |
149 impossible.exec(); |
149 impossible.exec(); |
150 return; |
150 return; |
151 } |
151 } |
152 |
152 |
153 if (m_name->text() == "") return; |
153 if (m_name->text() == "") return; |
154 |
154 |
155 QString state1; |
155 QString state1; |
156 QString state2; |
156 QString state2; |
157 |
157 |
158 for(int i = 0; i < m_numItems; ++i) { |
158 for(int i = 0; i < m_numItems; ++i) { |
159 twi::const_iterator it = weaponItems.find(i); |
159 twi::const_iterator it = weaponItems.find(i); |
160 int num = it == weaponItems.end() ? 9 : it.value()[0]->getItemsNum(); // 9 is for 'skip turn' |
160 int num = it == weaponItems.end() ? 9 : it.value()[0]->getItemsNum(); // 9 is for 'skip turn' |
161 state1.append(QString::number(num)); |
161 state1.append(QString::number(num)); |
162 int prob = it == weaponItems.end() ? 0 : it.value()[1]->getItemsNum(); |
162 int prob = it == weaponItems.end() ? 0 : it.value()[1]->getItemsNum(); |
190 impossible.exec(); |
190 impossible.exec(); |
191 return; |
191 return; |
192 } |
192 } |
193 |
193 |
194 QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Weapons"), QMessageBox::tr("Really delete this weapon set?"), QMessageBox::Ok | QMessageBox::Cancel); |
194 QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Weapons"), QMessageBox::tr("Really delete this weapon set?"), QMessageBox::Ok | QMessageBox::Cancel); |
195 |
195 |
196 if (reallyDelete.exec() == QMessageBox::Ok) { |
196 if (reallyDelete.exec() == QMessageBox::Ok) { |
197 wconf->remove(curWeaponsName); |
197 wconf->remove(curWeaponsName); |
198 emit weaponsDeleted(); |
198 emit weaponsDeleted(); |
199 } |
199 } |
200 } |
200 } |