Exemplo n.º 1
0
void Field::reallocateRobot(boost::shared_ptr<Robot> robot)
{
    removeRobot(robot);
    Field *nextField=_ourEther->findFieldWithCoords(_xCoord+robot->getNextFieldXPos(),
                                                    _yCoord+robot->getNextFieldYPos());
    if (nextField!=NULL) {
        nextField->addRobot(robot);
        robot->setPrevFieldXPos(_xCoord);
        robot->setPrevFieldYPos(_yCoord);
        robot->setXPos(robot->getXPos()-xSize()*robot->getNextFieldXPos());
        robot->setYPos(robot->getYPos()-ySize()*robot->getNextFieldYPos());
    }
    else {
        std::cerr << "Error: robot appears to have gone out of scene bounds. Rofl." << std::endl;
    }
}
Exemplo n.º 2
0
void RobotManager::removeRobot()
{
    if (m_robots.size() > 0)
        removeRobot(m_robots.last());
}
Exemplo n.º 3
0
	ChallengeApplication::ChallengeApplication(World* world, int ePuckCount) :
		viewer(world, ePuckCount)
	{
		// help viewer
		helpViewer = new QTextBrowser();
		helpViewer->setReadOnly(true);
		helpViewer->resize(600, 500);
		// help files generated by txt2tags, xhtml mode, with TOC
		if (localName.left(2) == "fr")
			helpViewer->setSource(QString("qrc:/doc/challenge.fr.html"));
		else if (localName.left(2) == "es")
			helpViewer->setSource(QString("qrc:/doc/challenge.es.html"));
		else if (localName.left(2) == "it")
			helpViewer->setSource(QString("qrc:/doc/challenge.it.html"));
		else
			helpViewer->setSource(QString("qrc:/doc/challenge.en.html"));
		helpViewer->moveCursor(QTextCursor::Start);
		helpViewer->setWindowTitle(tr("Aseba Challenge Help"));

		connect(this, SIGNAL(windowClosed()), helpViewer, SLOT(close()));

		// main windows layout
		QVBoxLayout *vLayout = new QVBoxLayout;
		QHBoxLayout *hLayout = new QHBoxLayout;

		hLayout->addStretch();

		// construction of menu frame
		QFrame* menuFrame = new QFrame();
		//menuFrame->setFrameStyle(QFrame::Box | QFrame::Plain);
		menuFrame->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
		QHBoxLayout *frameLayout = new QHBoxLayout;
		QPushButton* addRobotButton = new QPushButton(tr("Add a new robot"));
		frameLayout->addWidget(addRobotButton);
		QPushButton* delRobotButton = new QPushButton(tr("Remove all robots"));
		frameLayout->addWidget(delRobotButton);
		QCheckBox* autoCamera = new QCheckBox(tr("Auto camera"));
		frameLayout->addWidget(autoCamera);
		QCheckBox* fullScreen = new QCheckBox(tr("Full screen"));
		frameLayout->addWidget(fullScreen);
		//hideButtons = new QCheckBox(tr("Auto hide"));
		//frameLayout->addWidget(hideButtons);
		QPushButton* helpButton = new QPushButton(tr("Help"));
		frameLayout->addWidget(helpButton);
		QPushButton* quitButton = new QPushButton(tr("Quit"));
		frameLayout->addWidget(quitButton);
		menuFrame->setLayout(frameLayout);

//		menuFrame->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
		viewer.setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
		resize(780, 560);

		// construction of the screen layout
		hLayout->addWidget(menuFrame);
		hLayout->addStretch();

		vLayout->addLayout(hLayout);
		vLayout->addWidget(&viewer);
		vLayout->setContentsMargins(0,4,0,0);
		setLayout(vLayout);

		connect(addRobotButton, SIGNAL(clicked()), &viewer, SLOT(addNewRobot()));
		connect(delRobotButton, SIGNAL(clicked()), &viewer, SLOT(removeRobot()));
		connect(autoCamera, SIGNAL(toggled(bool)), &viewer, SLOT(autoCameraStateChanged(bool)));
		connect(fullScreen, SIGNAL(toggled(bool)), SLOT(fullScreenStateChanged(bool)));
		connect(helpButton, SIGNAL(clicked()), helpViewer, SLOT(show()));
		connect(quitButton, SIGNAL(clicked()), SLOT(close()));
		
		autoCamera->setCheckState(Qt::Checked);

		/*
		#else // Q_WS_MAC

		QMenuBar *menuBar = new QMenuBar(0);
		QMenu *menu = menuBar->addMenu(tr("Simulator control"));
		menu->addAction(tr("Add a new robot"), this, SLOT(addNewRobot()));
		menu->addAction(tr("Remove all robots"), this, SLOT(removeRobot()));
		menu->addSeparator();
		autoCamera = new QAction(tr("Auto camera"), 0);
		autoCamera->setCheckable(true);
		menu->addAction(autoCamera);
		menu->addSeparator();
		menu->addAction(tr("Help"), helpViewer, SLOT(show()));
		
		#endif // Q_WS_MAC
		*/
	}