QTfrontend/ui/page/pageeditteam.cpp
changeset 12250 5206f9a803d1
parent 12249 45c83c88ac4b
child 12253 07f67ee424dc
equal deleted inserted replaced
12249:45c83c88ac4b 12250:5206f9a803d1
   112     tmpLabel->setText(QLabel::tr("Voice"));
   112     tmpLabel->setText(QLabel::tr("Voice"));
   113     GBTLayout->addWidget(tmpLabel, 4, 0);
   113     GBTLayout->addWidget(tmpLabel, 4, 0);
   114 
   114 
   115     TeamNameEdit = new QLineEdit(GBoxTeam);
   115     TeamNameEdit = new QLineEdit(GBoxTeam);
   116     TeamNameEdit->setMaxLength(64);
   116     TeamNameEdit->setMaxLength(64);
   117     GBTLayout->addWidget(TeamNameEdit, 0, 1);
   117     TeamNameEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
       
   118     GBTLayout->addWidget(TeamNameEdit, 0, 1, 1, 2);
   118     vbox2->addWidget(GBoxTeam);
   119     vbox2->addWidget(GBoxTeam);
   119 
   120 
   120     CBTeamLvl = new QComboBox(GBoxTeam);
   121     CBTeamLvl = new QComboBox(GBoxTeam);
       
   122     CBTeamLvl->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
   121     CBTeamLvl->setIconSize(QSize(32, 32));
   123     CBTeamLvl->setIconSize(QSize(32, 32));
   122     CBTeamLvl->addItem(QIcon(":/res/botlevels/small0.png"), QComboBox::tr("Human"));
   124     CBTeamLvl->addItem(QIcon(":/res/botlevels/small0.png"), QComboBox::tr("Human"));
   123     for(int i = 5; i > 0; i--)
   125     for(int i = 5; i > 0; i--)
   124         CBTeamLvl->addItem(
   126         CBTeamLvl->addItem(
   125             QIcon(QString(":/res/botlevels/small%1.png").arg(6 - i)),
   127             QIcon(QString(":/res/botlevels/small%1.png").arg(6 - i)),
   126             QComboBox::tr("Computer (Level %1)").arg(i)
   128             QComboBox::tr("Computer (Level %1)").arg(i)
   127         );
   129         );
   128     CBTeamLvl->setFixedHeight(38);
   130     CBTeamLvl->setFixedHeight(38);
   129     GBTLayout->addWidget(CBTeamLvl, 1, 1);
   131     GBTLayout->addWidget(CBTeamLvl, 1, 1, 1, 2);
   130 
   132 
   131     CBGrave = new QComboBox(GBoxTeam);
   133     CBGrave = new QComboBox(GBoxTeam);
       
   134     CBGrave->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
   132     CBGrave->setMaxCount(65535);
   135     CBGrave->setMaxCount(65535);
   133     CBGrave->setMaxVisibleItems(20);
   136     CBGrave->setMaxVisibleItems(20);
   134     CBGrave->setIconSize(QSize(32, 32));
   137     CBGrave->setIconSize(QSize(32, 32));
   135     CBGrave->setFixedHeight(44);
   138     CBGrave->setFixedHeight(44);
   136     GBTLayout->addWidget(CBGrave, 2, 1);
   139     GBTLayout->addWidget(CBGrave, 2, 1, 1, 2);
   137 
   140 
   138     CBFlag = new QComboBox(GBoxTeam);
   141     CBFlag = new QComboBox(GBoxTeam);
   139     CBFlag->setMaxCount(65535);
   142     CBFlag->setMaxCount(65535);
   140     CBFlag->setMaxVisibleItems(50);
   143     CBFlag->setMaxVisibleItems(50);
   141     CBFlag->setIconSize(QSize(22, 15));
   144     CBFlag->setIconSize(QSize(22, 15));
   142     GBTLayout->addWidget(CBFlag, 3, 1);
   145     CBFlag->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
   143 
   146     GBTLayout->addWidget(CBFlag, 3, 1, 1, 2);
   144     QHBoxLayout * hbox = new QHBoxLayout();
   147 
       
   148     btnRandomTeamName = addButton(":/res/dice.png", GBTLayout, 0, 3, 1, 1, true);
       
   149     btnRandomTeamName->setWhatsThis(tr("Randomize the team name"));
       
   150 
       
   151     btnRandomGrave = addButton(":/res/dice.png", GBTLayout, 2, 3, 1, 1, true);
       
   152     btnRandomGrave->setWhatsThis(tr("Randomize the grave"));
       
   153 
       
   154     btnRandomFlag = addButton(":/res/dice.png", GBTLayout, 3, 3, 1, 1, true);
       
   155     btnRandomFlag->setWhatsThis(tr("Randomize the flag"));
       
   156 
   145     CBVoicepack = new QComboBox(GBoxTeam);
   157     CBVoicepack = new QComboBox(GBoxTeam);
   146     CBVoicepack->setMaxVisibleItems(50);
   158     CBVoicepack->setMaxVisibleItems(50);
   147 
   159     CBVoicepack->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
   148     hbox->addWidget(CBVoicepack, 100);
   160 
   149     btnTestSound = addSoundlessButton(":/res/PlaySound.png", hbox, 1, true);
   161     GBTLayout->addWidget(CBVoicepack, 4, 1, 1, 1);
       
   162 
       
   163     btnTestSound = addSoundlessButton(":/res/PlaySound.png", GBTLayout, 4, 2, 1, 1, true);
   150     btnTestSound->setWhatsThis(tr("Play a random example of this voice"));
   164     btnTestSound->setWhatsThis(tr("Play a random example of this voice"));
   151     hbox->setStretchFactor(btnTestSound, 1);
   165 
   152 
   166     btnRandomVoice = addButton(":/res/dice.png", GBTLayout, 4, 3, 1, 1, true);
   153     GBTLayout->addLayout(hbox, 4, 1);
   167     btnRandomVoice->setWhatsThis(tr("Randomize the voice"));
   154 
   168 
   155     GBoxFort = new QGroupBox(this);
   169     GBoxFort = new QGroupBox(this);
   156     GBoxFort->setTitle(QGroupBox::tr("Fort"));
   170     GBoxFort->setTitle(QGroupBox::tr("Fort"));
   157     QGridLayout * GBFLayout = new QGridLayout(GBoxFort);
   171     QGridLayout * GBFLayout = new QGridLayout(GBoxFort);
   158     CBFort = new QComboBox(GBoxFort);
   172     CBFort = new QComboBox(GBoxFort);
       
   173     CBFort->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
   159     CBFort->setMaxVisibleItems(25);
   174     CBFort->setMaxVisibleItems(25);
   160     CBFort->setMaxCount(65535);
   175     CBFort->setMaxCount(65535);
       
   176 
   161     GBFLayout->addWidget(CBFort, 0, 0);
   177     GBFLayout->addWidget(CBFort, 0, 0);
       
   178 
       
   179     btnRandomFort = addButton(":/res/dice.png", GBFLayout, 0, 2, 1, 1, true);
       
   180     btnRandomFort->setWhatsThis(tr("Randomize the fort"));
       
   181 
   162     FortPreview = new SquareLabel(GBoxFort);
   182     FortPreview = new SquareLabel(GBoxFort);
   163     FortPreview->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
   183     FortPreview->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
   164     FortPreview->setMinimumSize(128, 128);
   184     FortPreview->setMinimumSize(128, 128);
   165     FortPreview->setPixmap(QPixmap());
   185     FortPreview->setPixmap(QPixmap());
   166     // perhaps due to handling its own paintevents, SquareLabel doesn't play nice with the stars
   186     // perhaps due to handling its own paintevents, SquareLabel doesn't play nice with the stars
   167     //FortPreview->setAttribute(Qt::WA_PaintOnScreen, true);
   187     //FortPreview->setAttribute(Qt::WA_PaintOnScreen, true);
   168     GBFLayout->addWidget(FortPreview, 1, 0);
   188     GBFLayout->addWidget(FortPreview, 1, 0, 1, 2);
   169     vbox2->addWidget(GBoxFort);
   189     vbox2->addWidget(GBoxFort);
   170 
   190 
   171     vbox1->addStretch();
   191     vbox1->addStretch();
   172     vbox2->addStretch();
   192     vbox2->addStretch();
   173 
   193 
   197         connect(btnRandomHogName[i], SIGNAL(clicked()), signalMapper2, SLOT(map()));
   217         connect(btnRandomHogName[i], SIGNAL(clicked()), signalMapper2, SLOT(map()));
   198         signalMapper2->setMapping(btnRandomHogName[i], i);
   218         signalMapper2->setMapping(btnRandomHogName[i], i);
   199     }
   219     }
   200 
   220 
   201     connect(btnRandomTeam, SIGNAL(clicked()), this, SLOT(setRandomTeam()));
   221     connect(btnRandomTeam, SIGNAL(clicked()), this, SLOT(setRandomTeam()));
       
   222     connect(btnRandomTeamName, SIGNAL(clicked()), this, SLOT(setRandomTeamName()));
       
   223     connect(btnRandomGrave, SIGNAL(clicked()), this, SLOT(setRandomGrave()));
       
   224     connect(btnRandomFlag, SIGNAL(clicked()), this, SLOT(setRandomFlag()));
       
   225     connect(btnRandomVoice, SIGNAL(clicked()), this, SLOT(setRandomVoice()));
       
   226     connect(btnRandomFort, SIGNAL(clicked()), this, SLOT(setRandomFort()));
   202 
   227 
   203     connect(btnTestSound, SIGNAL(clicked()), this, SLOT(testSound()));
   228     connect(btnTestSound, SIGNAL(clicked()), this, SLOT(testSound()));
   204 
   229 
   205     connect(CBFort, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(CBFort_activated(const QString &)));
   230     connect(CBFort, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(CBFort_activated(const QString &)));
   206 }
   231 }
   391     HWTeam team = data();
   416     HWTeam team = data();
   392     HWNamegen::teamRandomHogName(team,hh_index);
   417     HWNamegen::teamRandomHogName(team,hh_index);
   393     loadTeam(team);
   418     loadTeam(team);
   394 }
   419 }
   395 
   420 
       
   421 void PageEditTeam::setRandomTeamName()
       
   422 {
       
   423     HWTeam team = data();
       
   424     HWNamegen::teamRandomTeamName(team);
       
   425     loadTeam(team);
       
   426 }
       
   427 
       
   428 void PageEditTeam::setRandomGrave()
       
   429 {
       
   430     HWTeam team = data();
       
   431     HWNamegen::teamRandomGrave(team);
       
   432     loadTeam(team);
       
   433 }
       
   434 
       
   435 void PageEditTeam::setRandomFlag()
       
   436 {
       
   437     HWTeam team = data();
       
   438     HWNamegen::teamRandomFlag(team);
       
   439     loadTeam(team);
       
   440 }
       
   441 
       
   442 void PageEditTeam::setRandomVoice()
       
   443 {
       
   444     HWTeam team = data();
       
   445     HWNamegen::teamRandomVoice(team);
       
   446     loadTeam(team);
       
   447 }
       
   448 
       
   449 void PageEditTeam::setRandomFort()
       
   450 {
       
   451     HWTeam team = data();
       
   452     HWNamegen::teamRandomFort(team);
       
   453     loadTeam(team);
       
   454 }
       
   455 
   396 void PageEditTeam::loadTeam(const HWTeam & team)
   456 void PageEditTeam::loadTeam(const HWTeam & team)
   397 {
   457 {
   398     tbw->setCurrentIndex(0);
   458     tbw->setCurrentIndex(0);
   399     binder->resetInterface();
   459     binder->resetInterface();
   400 
   460