void SamplesTreeCtrl::onChangeSampleSpeaker( char const *speakerName, smp::Sample *sample ) { // Is there a speaker of this new name? wxTreeItemId speakerItem = getSpeaker( speakerName ); wxTreeItemId speechItem = getTreeItem( sample ); if ( speakerItem.IsOk() ) { // The speaker of this name already exists. // So I merge the item into that tree. wxTreeItemId currentSpeakerItem = getSpeaker( speechItem ); if ( currentSpeakerItem.IsOk() ) SelectItem( changeSpeaker( speechItem, currentSpeakerItem, speakerItem ) ); } else { // The speaker doesn't already exist. speakerItem = getSpeaker( speechItem ); // Do I have siblings? if ( GetChildrenCount( speakerItem ) == 1 ) // There's nobody else. I should change the speaker name in place. SetItemText( speakerItem, speakerName ); else { // I have a different name than my siblings, I should create a // new parent and move there. wxTreeItemId newSpeakerItem = AppendItem( GetRootItem(), speakerName ); SelectItem( changeSpeaker( speechItem, speakerItem, newSpeakerItem ) ); } } }
void MainWindow::on_actionRestart_triggered() { for (QList<Player*>::iterator i = players.begin(); i != players.end(); i++) delete (*i); players.clear(); QStringList avaibleForVote; avaibleForVote.push_back(NOBODY); for (int i=1;i<=10;i++) avaibleForVote.push_back(QString("%1").arg(i)); roleBoxController->setEnableRoleComboBoxes(true); roleBoxController->clearAll(); voteBoxController->setNobodyToAll(); for (int i = 0; i < 10; i++) { names[i]->setEnabled(true); names[i]->clear(); warningButtons[i]->setEnabled(true); warningButtons[i]->removeAllWarnings(); players.push_back(new Player(roleBoxController->getRoleComboBoxes()[i],this->voteBoxController->getVoteComboBoxes()[i],names[i],warningButtons[i], i + 1)); } currentSpeaker = players.begin(); ui->label_6->setText(QString("<html><head/><body><p><span style=\" font-size:22pt;\">Enter roles.</span></p></body></html>")); ui->pushButton_11->setEnabled(false); ui->pushButton_15->setEnabled(false); voteBoxController->setEnabled(false); disconnect(this,SIGNAL(timeIsLeft()),this,SLOT(changeSpeaker())); connect(this,SIGNAL(timeIsLeft()),this,SLOT(handleMafiaAgreement())); }
void MainWindow::afterNight() { if (isEndOfTheGame(players)) { bool mafiaWon = false; for(QList<Player*>::iterator i = players.begin(); i != players.end(); i++) { if ((*i)->isAlive && ((*i)->getRole() == "Mafia" || (*i)->getRole() == "Don")) mafiaWon = true; } logger->setMafiaWon(mafiaWon); logger->writeLog(); on_actionRestart_triggered(); return; } disconnect(this,SIGNAL(timeIsLeft()),0,0); connect(this,SIGNAL(timeIsLeft()),this,SLOT(changeSpeaker())); players = shift(players); currentSpeaker = players.begin(); while(currentSpeaker != players.end() && !(*currentSpeaker)->isAlive ) currentSpeaker++; voteBoxController->setEnabledVoteBox((*currentSpeaker)->getNumber()); ui->label_6->setText(QString("<html><head/><body><p><span style=\" font-size:22pt;\">%1 player is speaking</span></p></body></html>").arg((*currentSpeaker)->getNumber())); }
void MainWindow::afterDay() { QList<int> votes = voteBoxController->getNominations(); logger->addNominations(voteBoxController->getPairNominationsAndNominators()); if (!votes.empty() && votes.size() != 1) { VoteDialog* d = new VoteDialog(players,votes,this); connect(d,SIGNAL(revoting(QList<int>)),this,SLOT(revote(QList<int>))); connect(d,SIGNAL(playersWereCondemned(QList<int>)),this,SLOT(lastWordAfterDay(QList<int>))); d->showFullScreen(); } else { if (votes.size() == 1 && players[0]->getNumber() != 1) //not first circle { for (int i = 0; i < players.size(); i++) if (players.at(i)->getNumber() == votes.first()) { players.at(i)->die(); QList<int> l; l.push_back(players[i]->getNumber()); lastWordAfterDay(l); } } else { disconnect(this,SIGNAL(timeIsLeft()),this,SLOT(changeSpeaker())); night(); } } }
void MainWindow::night() { connect(this,SIGNAL(timeIsLeft()),this,SLOT(changeSpeaker())); disconnect(this,SIGNAL(timeIsLeft()),this,SLOT(night())); NightDialog *d = new NightDialog(players,this); connect(d,SIGNAL(nightEnded(int,int,int)),this,SLOT(lastWordAfterNight(int,int,int))); d->showFullScreen(); }
void MainWindow::handleMafiaAgreement() { secondsLeft = 60; ui->label_5->setText(QString("<html><head/><body><p><span style=\" font-size:22pt;\">Time left: %1</span></p>").arg(secondsLeft)); ui->label_6->setText(QString("<html><head/><body><p><span style=\" font-size:22pt;\">%1 player is speaking</span></p></body></html>").arg((*currentSpeaker)->getNumber())); timer->stop(); pause = true; ui->pushButton_11->setText("Start"); disconnect(this,SIGNAL(timeIsLeft()),0,0); connect(this,SIGNAL(timeIsLeft()),this,SLOT(changeSpeaker())); voteBoxController->setEnabledVoteBox(1); }