QTfrontend/gamecfgwidget.cpp
changeset 4410 f9e38ce1e813
parent 4396 3cfd2e15464a
child 4416 29d2d1548387
equal deleted inserted replaced
4409:a752e543d7b4 4410:f9e38ce1e813
    45     mainLayout.addWidget(GBoxOptions);
    45     mainLayout.addWidget(GBoxOptions);
    46 
    46 
    47     QGridLayout *GBoxOptionsLayout = new QGridLayout(GBoxOptions);
    47     QGridLayout *GBoxOptionsLayout = new QGridLayout(GBoxOptions);
    48 
    48 
    49     GameSchemes = new QComboBox(GBoxOptions);
    49     GameSchemes = new QComboBox(GBoxOptions);
    50     GBoxOptionsLayout->addWidget(GameSchemes, 0, 1);
    50     GBoxOptionsLayout->addWidget(GameSchemes, 0, 2);
    51     connect(GameSchemes, SIGNAL(currentIndexChanged(int)), this, SLOT(schemeChanged(int)));
    51     connect(GameSchemes, SIGNAL(currentIndexChanged(int)), this, SLOT(schemeChanged(int)));
    52 
    52 
    53     GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Game scheme"), GBoxOptions), 0, 0);
    53     GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Game scheme"), GBoxOptions), 0, 0);
    54 
    54 
    55     QPixmap pmEdit(":/res/edit.png");
    55     QPixmap pmEdit(":/res/edit.png");
    57     QPushButton * goToSchemePage = new QPushButton(GBoxOptions);
    57     QPushButton * goToSchemePage = new QPushButton(GBoxOptions);
    58     goToSchemePage->setToolTip(tr("Edit schemes"));
    58     goToSchemePage->setToolTip(tr("Edit schemes"));
    59     goToSchemePage->setIconSize(pmEdit.size());
    59     goToSchemePage->setIconSize(pmEdit.size());
    60     goToSchemePage->setIcon(pmEdit);
    60     goToSchemePage->setIcon(pmEdit);
    61     goToSchemePage->setMaximumWidth(pmEdit.width() + 6);
    61     goToSchemePage->setMaximumWidth(pmEdit.width() + 6);
    62     GBoxOptionsLayout->addWidget(goToSchemePage, 0, 2);
    62     GBoxOptionsLayout->addWidget(goToSchemePage, 0, 3);
    63     connect(goToSchemePage, SIGNAL(clicked()), this, SIGNAL(goToSchemes()));
    63     connect(goToSchemePage, SIGNAL(clicked()), this, SLOT(jumpToSchemes()));
    64 
    64 
    65     GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Weapons"), GBoxOptions), 1, 0);
    65     GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Weapons"), GBoxOptions), 1, 0);
    66 
    66 
    67     WeaponsName = new QComboBox(GBoxOptions);
    67     WeaponsName = new QComboBox(GBoxOptions);
    68     GBoxOptionsLayout->addWidget(WeaponsName, 1, 1);
    68     GBoxOptionsLayout->addWidget(WeaponsName, 1, 2);
    69 
    69 
    70     connect(WeaponsName, SIGNAL(currentIndexChanged(int)), this, SLOT(ammoChanged(int)));
    70     connect(WeaponsName, SIGNAL(currentIndexChanged(int)), this, SLOT(ammoChanged(int)));
    71 
    71 
    72     QPushButton * goToWeaponPage = new QPushButton(GBoxOptions);
    72     QPushButton * goToWeaponPage = new QPushButton(GBoxOptions);
    73     goToWeaponPage->setToolTip(tr("Edit weapons"));
    73     goToWeaponPage->setToolTip(tr("Edit weapons"));
    74     goToWeaponPage->setIconSize(pmEdit.size());
    74     goToWeaponPage->setIconSize(pmEdit.size());
    75     goToWeaponPage->setIcon(pmEdit);
    75     goToWeaponPage->setIcon(pmEdit);
    76     goToWeaponPage->setMaximumWidth(pmEdit.width() + 6);
    76     goToWeaponPage->setMaximumWidth(pmEdit.width() + 6);
    77     GBoxOptionsLayout->addWidget(goToWeaponPage, 1, 2);
    77     GBoxOptionsLayout->addWidget(goToWeaponPage, 1, 3);
    78 
       
    79     connect(goToWeaponPage, SIGNAL(clicked()), this, SLOT(jumpToWeapons()));
    78     connect(goToWeaponPage, SIGNAL(clicked()), this, SLOT(jumpToWeapons()));
    80 
    79 
    81     GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Bind schemes and weapons"), GBoxOptions), 2, 0);
    80     //GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Bind schemes with weapons"), GBoxOptions), 2, 0);
    82 
    81 
    83     bindEntries = new QCheckBox(GBoxOptions);
    82     bindEntries = new QCheckBox(GBoxOptions);
    84     bindEntries->setToolTip(tr("When this option is enabled selecting a game scheme will auto-select a weapon (and viceversa)"));
    83     bindEntries->setToolTip(tr("When this option is enabled selecting a game scheme will auto-select a weapon"));
    85     bindEntries->setChecked(true);
    84     bindEntries->setChecked(true);
    86     GBoxOptionsLayout->addWidget(bindEntries, 2, 2);
    85     bindEntries->setMaximumWidth(42);
       
    86     bindEntries->setStyleSheet( "QCheckBox::indicator:checked   { image: url(\":/res/lock.png\"); }"
       
    87                                 "QCheckBox::indicator:unchecked { image: url(\":/res/unlock.png\");   }" );
       
    88     GBoxOptionsLayout->addWidget(bindEntries, 0, 1, 0, 1, Qt::AlignVCenter);
       
    89     //GBoxOptionsLayout->addWidget(bindEntries, 2, 2);
    87 
    90 
    88     connect(pMapContainer, SIGNAL(seedChanged(const QString &)), this, SLOT(seedChanged(const QString &)));
    91     connect(pMapContainer, SIGNAL(seedChanged(const QString &)), this, SLOT(seedChanged(const QString &)));
    89     connect(pMapContainer, SIGNAL(mapChanged(const QString &)), this, SLOT(mapChanged(const QString &)));
    92     connect(pMapContainer, SIGNAL(mapChanged(const QString &)), this, SLOT(mapChanged(const QString &)));
    90     connect(pMapContainer, SIGNAL(mapgenChanged(MapGenerator)), this, SLOT(mapgenChanged(MapGenerator)));
    93     connect(pMapContainer, SIGNAL(mapgenChanged(MapGenerator)), this, SLOT(mapgenChanged(MapGenerator)));
    91     connect(pMapContainer, SIGNAL(maze_sizeChanged(int)), this, SLOT(maze_sizeChanged(int)));
    94     connect(pMapContainer, SIGNAL(maze_sizeChanged(int)), this, SLOT(maze_sizeChanged(int)));
    92     connect(pMapContainer, SIGNAL(themeChanged(const QString &)), this, SLOT(themeChanged(const QString &)));
    95     connect(pMapContainer, SIGNAL(themeChanged(const QString &)), this, SLOT(themeChanged(const QString &)));
    93     connect(pMapContainer, SIGNAL(newTemplateFilter(int)), this, SLOT(templateFilterChanged(int)));
    96     connect(pMapContainer, SIGNAL(newTemplateFilter(int)), this, SLOT(templateFilterChanged(int)));
       
    97 }
       
    98 
       
    99 void GameCFGWidget::jumpToSchemes()
       
   100 {
       
   101     emit goToSchemes(GameSchemes->currentIndex());
    94 }
   102 }
    95 
   103 
    96 void GameCFGWidget::jumpToWeapons()
   104 void GameCFGWidget::jumpToWeapons()
    97 {
   105 {
    98     emit goToWeapons(WeaponsName->currentText());
   106     emit goToWeapons(WeaponsName->currentText());
   278     if (index >= 0) {
   286     if (index >= 0) {
   279         emit paramChanged(
   287         emit paramChanged(
   280             "AMMO",
   288             "AMMO",
   281             QStringList() << WeaponsName->itemText(index) << WeaponsName->itemData(index).toString()
   289             QStringList() << WeaponsName->itemText(index) << WeaponsName->itemData(index).toString()
   282         );
   290         );
   283         if (bindEntries->isChecked() == true) {
       
   284             QString weapName = WeaponsName->itemText(index);
       
   285             for (int i = 0; i < GameSchemes->count(); i++) {
       
   286                  QString schemeName = GameSchemes->itemText(i);
       
   287                  int res = QString::compare(weapName, schemeName, Qt::CaseSensitive);
       
   288                  if (0 == res) {
       
   289                      GameSchemes->setCurrentIndex(i);
       
   290                      break;
       
   291                  }
       
   292             }
       
   293         }
       
   294     }
   291     }
   295 }
   292 }
   296 
   293 
   297 void GameCFGWidget::mapChanged(const QString & value)
   294 void GameCFGWidget::mapChanged(const QString & value)
   298 {
   295 {
   343         for (int i = 0; i < WeaponsName->count(); i++) {
   340         for (int i = 0; i < WeaponsName->count(); i++) {
   344              QString weapName = WeaponsName->itemText(i);
   341              QString weapName = WeaponsName->itemText(i);
   345              int res = QString::compare(weapName, schemeName, Qt::CaseSensitive);
   342              int res = QString::compare(weapName, schemeName, Qt::CaseSensitive);
   346              if (0 == res) {
   343              if (0 == res) {
   347                  WeaponsName->setCurrentIndex(i);
   344                  WeaponsName->setCurrentIndex(i);
       
   345                  emit ammoChanged(i);
   348                  break;
   346                  break;
   349              }
   347              }
   350         }
   348         }
   351     }
   349     }
   352 }
   350 }