QTfrontend/selectWeapon.h
branchhedgeroid
changeset 6224 42b256eca362
parent 6055 88cfcd9161d3
parent 6223 cc3eb9b7230f
child 6226 3106add9a5bf
equal deleted inserted replaced
6055:88cfcd9161d3 6224:42b256eca362
     1 /*
       
     2  * Hedgewars, a free turn based strategy game
       
     3  * Copyright (c) 2006-2008 Igor Ulyanov <iulyanov@gmail.com>
       
     4  * Copyright (c) 2008-2011 Andrey Korotaev <unC0Rr@gmail.com>
       
     5  *
       
     6  * This program is free software; you can redistribute it and/or modify
       
     7  * it under the terms of the GNU General Public License as published by
       
     8  * the Free Software Foundation; version 2 of the License
       
     9  *
       
    10  * This program is distributed in the hope that it will be useful,
       
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    13  * GNU General Public License for more details.
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License
       
    16  * along with this program; if not, write to the Free Software
       
    17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
       
    18  */
       
    19 
       
    20 #ifndef _SELECT_WEAPON_INCLUDED
       
    21 #define _SELECT_WEAPON_INCLUDED
       
    22 
       
    23 #include <QFrame>
       
    24 #include <QMap>
       
    25 #include <QList>
       
    26 
       
    27 class QGridLayout;
       
    28 class WeaponItem;
       
    29 class QLineEdit;
       
    30 class QSettings;
       
    31 
       
    32 class SelWeaponItem : public QWidget
       
    33 {
       
    34   Q_OBJECT
       
    35 
       
    36 public:
       
    37   SelWeaponItem(bool allowInfinite, int iconNum, int wNum, QImage image, QImage imagegrey, QWidget* parent=0);
       
    38 
       
    39   unsigned char getItemsNum() const;
       
    40   void setItemsNum(const unsigned char num);
       
    41   void setEnabled(bool value);
       
    42 
       
    43  private:
       
    44   WeaponItem* item;
       
    45 };
       
    46 
       
    47 class SelWeaponWidget : public QFrame
       
    48 {
       
    49   Q_OBJECT
       
    50 
       
    51  public:
       
    52   SelWeaponWidget(int numItems, QWidget* parent=0);
       
    53   QString getWeaponsString(const QString& name) const;
       
    54   QStringList getWeaponNames() const;
       
    55 
       
    56  public slots:
       
    57   void setDefault();
       
    58   void setWeapons(const QString& ammo);
       
    59   //sets the name of the current set
       
    60   void setWeaponsName(const QString& name);
       
    61   void deleteWeaponsName();
       
    62   void newWeaponsName();
       
    63   void save();
       
    64   void copy();
       
    65 
       
    66  signals:
       
    67   void weaponsChanged();
       
    68   void weaponsDeleted();
       
    69 
       
    70  private:
       
    71   //the name of the current weapon set
       
    72   QString curWeaponsName;
       
    73 
       
    74   QLineEdit* m_name;
       
    75 
       
    76   //storage for all the weapons sets
       
    77   QSettings* wconf;
       
    78 
       
    79   const int m_numItems;
       
    80   int operator [] (unsigned int weaponIndex) const;
       
    81 
       
    82   typedef QList<SelWeaponItem*> ItemsList;
       
    83   typedef QMap<int, ItemsList> twi;
       
    84   twi weaponItems;
       
    85   //layout element for each tab:
       
    86   QGridLayout* p1Layout;
       
    87   QGridLayout* p2Layout;
       
    88   QGridLayout* p3Layout;
       
    89   QGridLayout* p4Layout;
       
    90 };
       
    91 
       
    92 #endif // _SELECT_WEAPON_INCLUDED