Пример #1
0
LuaMachine::LuaMachine( QXmppPeer * parent, TInit init )
    : QObject( parent )
{
	pd = new PD( this, init );
    pd->client = parent;

    connect( this,       SIGNAL(sigPrint(QString)), 
             this,       SLOT(slotPrint(QString)), 
             Qt::QueuedConnection );
    connect( this,       SIGNAL(sigStatus(QString, QString)),
             this,       SLOT(slotStatus(QString, QString)),
             Qt::QueuedConnection );
    connect( this,       SIGNAL(sigProcess(QString)),
             this,       SLOT(slotProcess(QString)),
             Qt::QueuedConnection );
    connect( pd->client, SIGNAL(textmsg(QString)),
             this,       SLOT(qxmppMessageReceived(QString)), 
             Qt::QueuedConnection );
}
Пример #2
0
// Constructor
Battleship::Battleship(QWidget *parent) : QMainWindow(parent)
{
	QApplication::setStyle("plastique");
	setupUi(this);
	gridLayoutHuman->sizePolicy().setHeightForWidth(true);
	gridLayoutEnemy->sizePolicy().setHeightForWidth(true);
	labelStatus = new QLabel(QString::fromUtf8("Press Ön to start the Game"), statusbar);
	statusbar->setSizeGripEnabled(true);
	statusbar->addWidget(labelStatus, 3);
	imageDialog = new ImageDialog(this);
	alignment = h;	// set default alignment
	enemyPlayer = new AI(enemy, this);		// Create players and their fields
	setupField(enemyPlayer);
	humanPlayer = new Human(human, this);
	setupField(humanPlayer);

	round = 0;		// for first round

	gridLayoutHuman->installEventFilter(this);	// EventFilter for right mouse button

	gridLayoutEnemy->setCursor(QCursor(Qt::ForbiddenCursor));
	gridLayoutHuman->setCursor(QCursor(Qt::ForbiddenCursor));


	// Buttons:
	connect(pushButtonEwo, SIGNAL(toggled(bool)), this, SLOT(slotSetEwoMode(bool)));
	connect(pushButtonStartGame, SIGNAL(clicked()), this, SLOT(slotStartGame()));

	// Place fleet & ships
	connect(this, SIGNAL(sigHumanPlaceShip(int, int, int)), humanPlayer, SLOT(slotPlaceShip(int, int, int)));
	connect(this, SIGNAL(sigPlaceFleet()), humanPlayer, SLOT(slotPlaceFleet()));
	connect(this, SIGNAL(sigPlaceFleet()), enemyPlayer, SLOT(slotPlaceFleet()));
	connect(humanPlayer, SIGNAL(sigFleetComplete()), this, SLOT(slotPlayerReady()));
	connect(enemyPlayer, SIGNAL(sigFleetComplete()), this, SLOT(slotPlayerReady()));

	// players get shot
	connect(this, SIGNAL(sigShotAtEnemy(int, int)), enemyPlayer, SLOT(slotShotAt(int, int)));
	connect(enemyPlayer, SIGNAL(sigShotAtHuman(int, int)), humanPlayer, SLOT(slotShotAt(int, int)));

	// toggle player turn
	connect(enemyPlayer, SIGNAL(sigDone(PlayerT)), this, SLOT(slotPlayerTurn(PlayerT)));
	connect(humanPlayer, SIGNAL(sigDone(PlayerT)), this, SLOT(slotPlayerTurn(PlayerT)));

	// AI shall shoot
	connect(this, SIGNAL(sigRequestShotFromEnemy()), enemyPlayer, SLOT(slotFire()));
	connect(humanPlayer, SIGNAL(sigEnemyTryAgain()), this, SLOT(slotRequestShotNow()));

	//Feedback of shots for AI
	connect(humanPlayer, SIGNAL(sigFireFeedback(int, int, ConditionT)), enemyPlayer, SLOT(slotFireFeedback(int, int, ConditionT)));

	// Game Over
	connect(enemyPlayer, SIGNAL(sigGameOver(PlayerT)), this, SLOT(slotGameOver(PlayerT)));
	connect(humanPlayer, SIGNAL(sigGameOver(PlayerT)), this, SLOT(slotGameOver(PlayerT)));

	// console output
	connect(humanPlayer, SIGNAL(sigPrint(QString)), this, SLOT(slotPrintToConsole(QString)));
	connect(enemyPlayer, SIGNAL(sigPrint(QString)), this, SLOT(slotPrintToConsole(QString)));

	//sound output
	connect(humanPlayer, SIGNAL(sigPlaySound(QString)), this, SLOT(slotPlaySound(QString)));
	connect(enemyPlayer, SIGNAL(sigPlaySound(QString)), this, SLOT(slotPlaySound(QString)));
	connect(humanPlayer, SIGNAL(sigPlayDelayedSound(QString, int)), this, SLOT(slotPlayDelayedSound(QString, int)));
	connect(enemyPlayer, SIGNAL(sigPlayDelayedSound(QString, int)), this, SLOT(slotPlayDelayedSound(QString, int)));

	// help menu -> display info
	infoDialog = new InfoDialog(this);
	connect(actionManual, SIGNAL(triggered()), infoDialog, SLOT(slotLoadTutorial()));
	connect(actionAbout, SIGNAL(triggered()), infoDialog, SLOT(slotLoadAbout()));
	connect(actionLicense, SIGNAL(triggered()), infoDialog, SLOT(slotLoadLicense()));

	//options menu
	connect(actionSound_on, SIGNAL(triggered()), this, SLOT(slotSoundOn()));

	if(QSound::isAvailable()) {
		soundAvailable = true;
		soundOn = true;
		slotPrintToConsole("Sound is availiable\n");
	} else {
		soundAvailable = false;
		soundOn = false;
		slotPrintToConsole("Sound is not availiable\n");
	}
}
Пример #3
0
void LuaMachine::print( const QString & stri )
{
    emit sigPrint( stri );
}