QTfrontend/ui/page/pageeditteam.cpp
changeset 12250 05f1935175da
parent 12249 d23695f96290
child 12296 62975c0a89c6
equal deleted inserted replaced
12249:d23695f96290 12250:05f1935175da
   148     CBGrave->setMaxVisibleItems(20);
   148     CBGrave->setMaxVisibleItems(20);
   149     CBGrave->setIconSize(QSize(32, 32));
   149     CBGrave->setIconSize(QSize(32, 32));
   150     CBGrave->setFixedHeight(44);
   150     CBGrave->setFixedHeight(44);
   151     GBTLayout->addWidget(CBGrave, 2, 1, 1, 2);
   151     GBTLayout->addWidget(CBGrave, 2, 1, 1, 2);
   152 
   152 
       
   153     // Player flags, combobox to select flag
   153     CBFlag = new QComboBox(GBoxTeam);
   154     CBFlag = new QComboBox(GBoxTeam);
   154     CBFlag->setMaxCount(65535);
   155     CBFlag->setMaxCount(65535);
   155     CBFlag->setMaxVisibleItems(50);
   156     CBFlag->setMaxVisibleItems(50);
   156     CBFlag->setIconSize(QSize(22, 15));
   157     CBFlag->setIconSize(QSize(22, 15));
   157     CBFlag->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
   158     CBFlag->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
   158     GBTLayout->addWidget(CBFlag, 3, 1, 1, 2);
   159     GBTLayout->addWidget(CBFlag, 3, 1, 1, 2);
       
   160 
       
   161     // CPU level flag. Static image, only displayed when computer player is selected
       
   162     QImage imgBotlevels = QImage("physfs://Graphics/botlevels.png");
       
   163 
       
   164     int botlevelOffsets[5]= { 19, 14, 10, 6, 0 };   
       
   165 
       
   166     for(int i=0; i<5; i++) {
       
   167         QImage imgCPU = QImage("physfs://Graphics/Flags/cpu.png");
       
   168         QPainter painter(&imgCPU);
       
   169         painter.drawImage(botlevelOffsets[i], 0, imgBotlevels, botlevelOffsets[i]);
       
   170 
       
   171         pixCPU[i] = QPixmap::fromImage(imgCPU);
       
   172     }
       
   173 
       
   174     QHBoxLayout* hboxCPU = new QHBoxLayout();
       
   175     hboxCPU->setContentsMargins(0, 0, 0, 0);
       
   176 
       
   177     hboxCPUWidget = new QWidget();
       
   178     hboxCPUWidget->setLayout(hboxCPU);
       
   179 
       
   180     CPUFlag = new QLabel();
       
   181     CPUFlag->setPixmap(pixCPU[0]);
       
   182     CPUFlag->setFixedHeight(38);
       
   183 
       
   184     hboxCPU->addWidget(CPUFlag);
       
   185 
       
   186     CPUFlagLabel = new QLabel("CPU");
       
   187     CPUFlagLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
       
   188     hboxCPU->addWidget(CPUFlagLabel);
       
   189 
       
   190     hboxCPUWidget->setHidden(true);
       
   191     GBTLayout->addWidget(hboxCPUWidget, 3, 1, 1, 1);
   159 
   192 
   160     btnRandomTeamName = addButton(":/res/dice.png", GBTLayout, 0, 3, 1, 1, true);
   193     btnRandomTeamName = addButton(":/res/dice.png", GBTLayout, 0, 3, 1, 1, true);
   161     btnRandomTeamName->setWhatsThis(tr("Randomize the team name"));
   194     btnRandomTeamName->setWhatsThis(tr("Randomize the team name"));
   162 
   195 
   163     btnRandomGrave = addButton(":/res/dice.png", GBTLayout, 2, 3, 1, 1, true);
   196     btnRandomGrave = addButton(":/res/dice.png", GBTLayout, 2, 3, 1, 1, true);
   231     }
   264     }
   232 
   265 
   233     connect(btnRandomTeam, SIGNAL(clicked()), this, SLOT(setRandomTeam()));
   266     connect(btnRandomTeam, SIGNAL(clicked()), this, SLOT(setRandomTeam()));
   234     connect(btnRandomNames, SIGNAL(clicked()), this, SLOT(setRandomHogNames()));
   267     connect(btnRandomNames, SIGNAL(clicked()), this, SLOT(setRandomHogNames()));
   235     connect(btnRandomHats, SIGNAL(clicked()), this, SLOT(setRandomHats()));
   268     connect(btnRandomHats, SIGNAL(clicked()), this, SLOT(setRandomHats()));
       
   269 
       
   270     connect(CBTeamLvl, SIGNAL(currentIndexChanged(const int)), this, SLOT(CBTeamLvl_activated(const int)));
   236 
   271 
   237     connect(btnRandomTeamName, SIGNAL(clicked()), this, SLOT(setRandomTeamName()));
   272     connect(btnRandomTeamName, SIGNAL(clicked()), this, SLOT(setRandomTeamName()));
   238     connect(btnRandomGrave, SIGNAL(clicked()), this, SLOT(setRandomGrave()));
   273     connect(btnRandomGrave, SIGNAL(clicked()), this, SLOT(setRandomGrave()));
   239     connect(btnRandomFlag, SIGNAL(clicked()), this, SLOT(setRandomFlag()));
   274     connect(btnRandomFlag, SIGNAL(clicked()), this, SLOT(setRandomFlag()));
   240     connect(btnRandomVoice, SIGNAL(clicked()), this, SLOT(setRandomVoice()));
   275     connect(btnRandomVoice, SIGNAL(clicked()), this, SLOT(setRandomVoice()));
   358 {
   393 {
   359     QPixmap pix("physfs://Forts/" + fortname + "L.png");
   394     QPixmap pix("physfs://Forts/" + fortname + "L.png");
   360     FortPreview->setPixmap(pix);
   395     FortPreview->setPixmap(pix);
   361 }
   396 }
   362 
   397 
       
   398 void PageEditTeam::CBTeamLvl_activated(const int index)
       
   399 {
       
   400     CBFlag->setHidden(index != 0);
       
   401     btnRandomFlag->setHidden(index != 0);
       
   402 
       
   403     if(index > 0) 
       
   404     {
       
   405         int cpuLevel = 6 - index;
       
   406         CPUFlag->setPixmap(pixCPU[cpuLevel - 1]);
       
   407         CPUFlagLabel->setText(tr("CPU %1").arg(cpuLevel));
       
   408     }
       
   409     hboxCPUWidget->setHidden(index == 0);
       
   410 }
       
   411 
   363 void PageEditTeam::testSound()
   412 void PageEditTeam::testSound()
   364 {
   413 {
   365     DataManager & dataMgr = DataManager::instance();
   414     DataManager & dataMgr = DataManager::instance();
   366 
   415 
   367     QString voiceDir = QString("Sounds/voices/") + CBVoicepack->currentText();
   416     QString voiceDir = QString("Sounds/voices/") + CBVoicepack->currentText();