Exemplo n.º 1
0
void Kingdom::ApplyPlayWithStartingHero(void)
{
    if(isPlay() && castles.size())
    {
	// get first castle
	Castle* first = castles.GetFirstCastle();
	if(NULL == first) first = castles.front();

	// check manual set hero (castle position + point(0, 1))?
	const Point & cp = (first)->GetCenter();
	Heroes* hero = world.GetTiles(cp.x, cp.y + 1).GetHeroes();

    	// and move manual set hero to castle
	if(hero && hero->GetColor() == GetColor())
	{
		bool patrol = hero->Modes(Heroes::PATROL);
    		hero->SetFreeman(0);
    		hero->Recruit(*first);

		if(patrol)
		{
		    hero->SetModes(Heroes::PATROL);
		    hero->SetCenterPatrol(cp);
		}
	}
	else
	if(Settings::Get().GameStartWithHeroes())
	{
    	    Heroes* hero = world.GetFreemanHeroes(first->GetRace());
	    if(hero && AllowRecruitHero(false, 0)) hero->Recruit(*first);
	}
    }
}
Exemplo n.º 2
0
void fileList::onStop()
{
	if(isRecorded)
	{
		pIqWriter->close();
		ui.pbPlay->setEnabled(true);
		ui.pbLoop->setEnabled(true);
		ui.pbBack->setEnabled(true);
		ui.pbRec->setChecked(false);
		ui.slIqTrack->setMaximum(0);
		isRecorded = false;
		emit isRec(false);
		QFileInfo info;
		info.setFile(pIqWriter->getFileName());
		if(info.isFile())
			addFile(info);
	}
	else if(isPlayed)
	{
		ui.pbRec->setEnabled(true);
		killTimer(timerId);
		ui.pbPlay->setChecked(false);
		pIqReader->close();
		ui.slIqTrack->setMaximum(0);
		isPlayed = false;
		emit isPlay(false);
	}
	ui.pbPause->setEnabled(false);
	ui.slIqTrack->setValue(0);
}
Exemplo n.º 3
0
void fileList::onPlay()
{
    int currentTrack = 0;
	if(ui.pbRec->isChecked())
	{
		ui.pbPlay->setChecked(false);
		isPlayed = false;
	}
	else
	{
		if(ui.twList->rowCount() < 1)
		{
			ui.pbPlay->setChecked(false);
			isPlayed = false;
			QMessageBox::warning(this, tr("ExpertSDR message"),
			                           tr("Can't play IQ files.\n"
			                              "Playlist is empty. Please add IQ wav files to the list and try again."),
			                              QMessageBox::Ok);
			onAddFile();
			return;
		}
		ui.pbRec->setEnabled(false);
		ui.pbPlay->setChecked(true);
		if(pIqReader->isOpen()) pIqReader->close();
        currentTrack = ui.twList->currentRow();
        if(currentTrack < 0)
        {
            currentTrack = 0;
            ui.twList->setCurrentCell(0, 0);
            reinterpret_cast<wavSample*>(ui.twList->cellWidget(0 ,0))->setStyleSheet("QLabel{background-color: transparent; color: rgb(255, 106, 0);}");
            reinterpret_cast<wavSample*>(ui.twList->cellWidget(0 ,0))->setActive(true);
            lastRow = 0;
        }
        iqFile.setFileName(reinterpret_cast<wavSample*>(ui.twList->cellWidget(currentTrack ,0))->fileName());
        pIqReader->open(&iqFile);
        if(!pIqReader->isOpen())
        {
            ui.pbPlay->setChecked(false);
            isPlayed = false;
            return;
        }
        ui.slIqTrack->setMaximum(pIqReader->time().second() + pIqReader->time().minute()*60 + pIqReader->time().hour()*3600);
        timerId = startTimer(100);
        if(!isPlayed)
        	emit isPlay(true);
        else
        	emit isChangedPlayFile(true);
		isPlayed = true;
		ui.pbPause->setEnabled(true);
	}
}
Exemplo n.º 4
0
void Kingdom::LossPostActions(void)
{
    if(isPlay())
    {
	Players::SetPlayerInGame(color, false);

	if(heroes.size())
	{
	    std::for_each(heroes.begin(), heroes.end(),
		std::bind2nd(std::mem_fun(&Heroes::SetFreeman), static_cast<u8>(Battle::RESULT_LOSS)));
	    heroes.clear();
	}
	if(castles.size())
	{
	    castles.ChangeColors(GetColor(), Color::NONE);
	    castles.clear();
	}
	world.ResetCapturedObjects(GetColor());
    }
}