# HG changeset patch # User Henek # Date 1290425752 -3600 # Node ID c9a78ba03679f9b70c6c2d8f58035b4fcb95688c # Parent 79fbc444584cc932e62d7b56688be7888962c902 added disabling option to itemNum and grey images for that. also made default weapon sets uneditable and not deleteable. diff -r 79fbc444584c -r c9a78ba03679 QTfrontend/hedgehogerWidget.cpp --- a/QTfrontend/hedgehogerWidget.cpp Mon Nov 22 10:04:08 2010 +0100 +++ b/QTfrontend/hedgehogerWidget.cpp Mon Nov 22 12:35:52 2010 +0100 @@ -20,8 +20,8 @@ #include "frameTeam.h" -CHedgehogerWidget::CHedgehogerWidget(const QImage& im, QWidget * parent) : - ItemNum(im, parent, 1) +CHedgehogerWidget::CHedgehogerWidget(const QImage& im, const QImage& img, QWidget * parent) : + ItemNum(im, img, parent, 1) { // TODO: maxHedgehogsPerGame doesn't reset properly and won't match map limits for now /*if(parent) { diff -r 79fbc444584c -r c9a78ba03679 QTfrontend/hedgehogerWidget.h --- a/QTfrontend/hedgehogerWidget.h Mon Nov 22 10:04:08 2010 +0100 +++ b/QTfrontend/hedgehogerWidget.h Mon Nov 22 12:35:52 2010 +0100 @@ -28,7 +28,7 @@ Q_OBJECT public: - CHedgehogerWidget(const QImage& im, QWidget * parent); + CHedgehogerWidget(const QImage& im, const QImage& img, QWidget * parent); virtual ~CHedgehogerWidget(); unsigned char getHedgehogsNum() const; void setHHNum (unsigned int num); diff -r 79fbc444584c -r c9a78ba03679 QTfrontend/hedgewars.qrc --- a/QTfrontend/hedgewars.qrc Mon Nov 22 10:04:08 2010 +0100 +++ b/QTfrontend/hedgewars.qrc Mon Nov 22 12:35:52 2010 +0100 @@ -2,8 +2,15 @@ ../share/hedgewars/Data/Graphics/AmmoMenu/Ammos.png res/hh25x25.png + res/hh25x25grey.png res/ammopic.png + res/ammopicgrey.png + res/ammopicbox.png + res/ammopicboxgrey.png + res/ammopicdelay.png + res/ammopicdelaygrey.png res/infinity.png + res/infinitygrey.png res/botlevels/0.png res/botlevels/1.png res/botlevels/2.png @@ -94,8 +101,6 @@ res/chat_default_off.png res/chat_ignore_off.png res/chat_friend_off.png - res/ammopicbox.png - res/ammopicdelay.png res/addfriend.png res/remfriend.png res/ignore.png diff -r 79fbc444584c -r c9a78ba03679 QTfrontend/itemNum.cpp --- a/QTfrontend/itemNum.cpp Mon Nov 22 10:04:08 2010 +0100 +++ b/QTfrontend/itemNum.cpp Mon Nov 22 12:35:52 2010 +0100 @@ -22,10 +22,11 @@ #include #include -ItemNum::ItemNum(const QImage& im, QWidget * parent, unsigned char min, unsigned char max) : - QFrame(parent), m_im(im), infinityState(false), nonInteractive(false), minItems(min), maxItems(max), +ItemNum::ItemNum(const QImage& im, const QImage& img, QWidget * parent, unsigned char min, unsigned char max) : + QFrame(parent), m_im(im), m_img(img), infinityState(false), nonInteractive(false), minItems(min), maxItems(max), numItems(min+2 >= max ? min : min+2) { + enabled = true; if(frontendEffects) setAttribute(Qt::WA_PaintOnScreen, true); } @@ -36,7 +37,7 @@ void ItemNum::mousePressEvent ( QMouseEvent * event ) { if(nonInteractive) return; - if(event->button()==Qt::LeftButton) { + if(event->button()==Qt::LeftButton && enabled) { event->accept(); if((infinityState && numItems <= maxItems) || (!infinityState && numItems < maxItems)) { incItems(); @@ -45,7 +46,7 @@ // appears there's an emit in there decItems(); } - } else if (event->button()==Qt::RightButton) { + } else if (event->button()==Qt::RightButton && enabled) { event->accept(); if(numItems > minItems) { decItems(); @@ -71,11 +72,19 @@ if (numItems==maxItems+1) { QRect target(0, 0, 100, 32); - painter.drawImage(target, QImage(":/res/infinity.png")); + if (enabled) { + painter.drawImage(target, QImage(":/res/infinity.png")); + } else { + painter.drawImage(target, QImage(":/res/infinitygrey.png")); + } } else { for(int i=0; isetToolTip(tr("Campaign Mode (...). IN DEVELOPMENT")); - BtnCampaignPage->setVisible(false); + //BtnCampaignPage->setVisible(false); BtnTrainPage = addButton(":/res/Trainings.png", middleLine, 1, true); BtnTrainPage->setToolTip(tr("Training Mode (Practice your skills in a range of training missions). IN DEVELOPMENT")); diff -r 79fbc444584c -r c9a78ba03679 QTfrontend/res/ammopicboxgrey.png Binary file QTfrontend/res/ammopicboxgrey.png has changed diff -r 79fbc444584c -r c9a78ba03679 QTfrontend/res/ammopicdelaygrey.png Binary file QTfrontend/res/ammopicdelaygrey.png has changed diff -r 79fbc444584c -r c9a78ba03679 QTfrontend/res/ammopicgrey.png Binary file QTfrontend/res/ammopicgrey.png has changed diff -r 79fbc444584c -r c9a78ba03679 QTfrontend/res/hh25x25grey.png Binary file QTfrontend/res/hh25x25grey.png has changed diff -r 79fbc444584c -r c9a78ba03679 QTfrontend/res/infinitygrey.png Binary file QTfrontend/res/infinitygrey.png has changed diff -r 79fbc444584c -r c9a78ba03679 QTfrontend/selectWeapon.cpp --- a/QTfrontend/selectWeapon.cpp Mon Nov 22 10:04:08 2010 +0100 +++ b/QTfrontend/selectWeapon.cpp Mon Nov 22 12:35:52 2010 +0100 @@ -40,7 +40,7 @@ return ammo.copy(x, y, 32, 32); } -SelWeaponItem::SelWeaponItem(bool allowInfinite, int iconNum, int wNum, QImage image, QWidget* parent) : +SelWeaponItem::SelWeaponItem(bool allowInfinite, int iconNum, int wNum, QImage image, QImage imagegrey, QWidget* parent) : QWidget(parent) { QHBoxLayout* hbLayout = new QHBoxLayout(this); @@ -53,7 +53,7 @@ lbl->setGeometry(0, 0, 30, 30); hbLayout->addWidget(lbl); - item = new WeaponItem(image, this); + item = new WeaponItem(image, imagegrey, this); item->setItemsNum(wNum); item->setInfinityState(allowInfinite); hbLayout->addWidget(item); @@ -74,6 +74,11 @@ return item->getItemsNum(); } +void SelWeaponItem::setEnabled(bool value) +{ + item->setEnabled(value); +} + SelWeaponWidget::SelWeaponWidget(int numItems, QWidget* parent) : QFrame(parent), m_numItems(numItems) @@ -124,19 +129,19 @@ for(; i < m_numItems; ++i) { if (i == 6) continue; if (k % 4 == 0) ++j; - SelWeaponItem * swi = new SelWeaponItem(true, i, currentState[i].digitValue(), QImage(":/res/ammopic.png"), this); + SelWeaponItem * swi = new SelWeaponItem(true, i, currentState[i].digitValue(), QImage(":/res/ammopic.png"), QImage(":/res/ammopicgrey.png"), this); weaponItems[i].append(swi); p1Layout->addWidget(swi, j, k % 4); - SelWeaponItem * pwi = new SelWeaponItem(false, i, currentState[numItems + i].digitValue(), QImage(":/res/ammopicbox.png"), this); + SelWeaponItem * pwi = new SelWeaponItem(false, i, currentState[numItems + i].digitValue(), QImage(":/res/ammopicbox.png"), QImage(":/res/ammopicboxgrey.png"), this); weaponItems[i].append(pwi); p2Layout->addWidget(pwi, j, k % 4); - SelWeaponItem * dwi = new SelWeaponItem(false, i, currentState[numItems*2 + i].digitValue(), QImage(":/res/ammopicdelay.png"), this); + SelWeaponItem * dwi = new SelWeaponItem(false, i, currentState[numItems*2 + i].digitValue(), QImage(":/res/ammopicdelay.png"), QImage(":/res/ammopicdelaygrey.png"), this); weaponItems[i].append(dwi); p3Layout->addWidget(dwi, j, k % 4); - SelWeaponItem * awi = new SelWeaponItem(false, i, currentState[numItems*3 + i].digitValue(), QImage(":/res/ammopic.png"), this); + SelWeaponItem * awi = new SelWeaponItem(false, i, currentState[numItems*3 + i].digitValue(), QImage(":/res/ammopic.png"), QImage(":/res/ammopicgrey.png"), this); weaponItems[i].append(awi); p4Layout->addWidget(awi, j, k % 4); @@ -150,6 +155,11 @@ void SelWeaponWidget::setWeapons(const QString& ammo) { + bool enable = true; + for(int i = 0; i < cDefaultAmmos.size(); i++) + if (!cDefaultAmmos[i].first.compare(m_name->text())) { + enable = false; + } for(int i = 0; i < m_numItems; ++i) { twi::iterator it = weaponItems.find(i); if (it == weaponItems.end()) continue; @@ -157,12 +167,20 @@ it.value()[1]->setItemsNum(ammo[m_numItems + i].digitValue()); it.value()[2]->setItemsNum(ammo[m_numItems*2 + i].digitValue()); it.value()[3]->setItemsNum(ammo[m_numItems*3 + i].digitValue()); + it.value()[0]->setEnabled(enable); + it.value()[1]->setEnabled(enable); + it.value()[2]->setEnabled(enable); + it.value()[3]->setEnabled(enable); } - update(); + m_name->setEnabled(enable); } void SelWeaponWidget::setDefault() { + for(int i = 0; i < cDefaultAmmos.size(); i++) + if (!cDefaultAmmos[i].first.compare(m_name->text())) { + return; + } setWeapons(*cDefaultAmmoStore); } @@ -215,11 +233,11 @@ { if (curWeaponsName == "") return; - if (curWeaponsName == "Default") { - QMessageBox impossible(QMessageBox::Warning, QMessageBox::tr("Weapons"), QMessageBox::tr("Can not delete default weapon set")); - impossible.exec(); - return; - } + for(int i = 0; i < cDefaultAmmos.size(); i++) + if (!cDefaultAmmos[i].first.compare(m_name->text())) { + QMessageBox::warning(0, QMessageBox::tr("Weapons"), QMessageBox::tr("Can not delete default weapon set '%1'!").arg(cDefaultAmmos[i].first)); + return; + } QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Weapons"), QMessageBox::tr("Really delete this weapon set?"), QMessageBox::Ok | QMessageBox::Cancel); @@ -231,13 +249,13 @@ void SelWeaponWidget::setWeaponsName(const QString& name) { + m_name->setText(name); + + curWeaponsName = name; + if(name != "" && wconf->contains(name)) { setWeapons(wconf->value(name).toString()); } - - curWeaponsName = name; - - m_name->setText(name); } QStringList SelWeaponWidget::getWeaponNames() const diff -r 79fbc444584c -r c9a78ba03679 QTfrontend/selectWeapon.h --- a/QTfrontend/selectWeapon.h Mon Nov 22 10:04:08 2010 +0100 +++ b/QTfrontend/selectWeapon.h Mon Nov 22 12:35:52 2010 +0100 @@ -33,10 +33,11 @@ Q_OBJECT public: - SelWeaponItem(bool allowInfinite, int iconNum, int wNum, QImage image, QWidget* parent=0); + SelWeaponItem(bool allowInfinite, int iconNum, int wNum, QImage image, QImage imagegrey, QWidget* parent=0); unsigned char getItemsNum() const; void setItemsNum(const unsigned char num); + void setEnabled(bool value); private: WeaponItem* item; diff -r 79fbc444584c -r c9a78ba03679 QTfrontend/teamselhelper.cpp --- a/QTfrontend/teamselhelper.cpp Mon Nov 22 10:04:08 2010 +0100 +++ b/QTfrontend/teamselhelper.cpp Mon Nov 22 12:35:52 2010 +0100 @@ -73,7 +73,7 @@ connect(colorButt, SIGNAL(clicked()), this, SLOT(changeTeamColor())); mainLayout.addWidget(colorButt); - phhoger = new CHedgehogerWidget(QImage(":/res/hh25x25.png"), this); + phhoger = new CHedgehogerWidget(QImage(":/res/hh25x25.png"), QImage(":/res/hh25x25grey.png"), this); connect(phhoger, SIGNAL(hedgehogsNumChanged()), this, SLOT(hhNumChanged())); phhoger->setHHNum(team.numHedgehogs); mainLayout.addWidget(phhoger); diff -r 79fbc444584c -r c9a78ba03679 QTfrontend/weaponItem.cpp --- a/QTfrontend/weaponItem.cpp Mon Nov 22 10:04:08 2010 +0100 +++ b/QTfrontend/weaponItem.cpp Mon Nov 22 12:35:52 2010 +0100 @@ -18,8 +18,8 @@ #include "weaponItem.h" -WeaponItem::WeaponItem(const QImage& im, QWidget * parent) : - ItemNum(im, parent, 0) +WeaponItem::WeaponItem(const QImage& im, const QImage& img, QWidget * parent) : + ItemNum(im, img, parent, 0) { } diff -r 79fbc444584c -r c9a78ba03679 QTfrontend/weaponItem.h --- a/QTfrontend/weaponItem.h Mon Nov 22 10:04:08 2010 +0100 +++ b/QTfrontend/weaponItem.h Mon Nov 22 12:35:52 2010 +0100 @@ -26,7 +26,7 @@ Q_OBJECT public: - WeaponItem(const QImage& im, QWidget * parent); + WeaponItem(const QImage& im, const QImage& img, QWidget * parent); virtual ~WeaponItem(); signals: