Exemplo n.º 1
0
Server_Game *Server_Room::createGame(const QString &description, const QString &password, int maxPlayers, bool spectatorsAllowed, bool spectatorsNeedPassword, bool spectatorsCanTalk, bool spectatorsSeeEverything, Server_ProtocolHandler *creator)
{
	Server_Game *newGame = new Server_Game(creator, static_cast<Server *>(parent())->getNextGameId(), description, password, maxPlayers, spectatorsAllowed, spectatorsNeedPassword, spectatorsCanTalk, spectatorsSeeEverything, this);
	games.insert(newGame->getGameId(), newGame);
	connect(newGame, SIGNAL(gameClosing()), this, SLOT(removeGame()));
	
	broadcastGameListUpdate(newGame);
	
	emit gameCreated(newGame);
	emit roomInfoChanged();
	
	return newGame;
}
Exemplo n.º 2
0
void MainWindow::destroyGame(ChessGame* game)
{
	Q_ASSERT(game != nullptr);

	int index = tabIndex(game);
	Q_ASSERT(index != -1);
	TabData tab = m_tabs.at(index);

	removeGame(index);

	if (tab.tournament == nullptr)
		game->deleteLater();
	delete tab.pgn;

	if (m_tabs.isEmpty())
		close();
}
Exemplo n.º 3
0
void MainWindow::onTabCloseRequested(int index)
{
	const TabData& tab = m_tabs.at(index);

	if (tab.game == nullptr)
	{
		delete tab.pgn;
		removeGame(index);

		if (m_tabs.isEmpty())
			close();

		return;
	}

	if (tab.game->isFinished())
		destroyGame(tab.game);
	else
	{
		connect(tab.game, SIGNAL(finished(ChessGame*)),
			this, SLOT(destroyGame(ChessGame*)));
		QMetaObject::invokeMethod(tab.game, "stop", Qt::QueuedConnection);
	}
}