Beispiel #1
0
MainWindow::MainWindow()
{
    QWidget *central = new QWidget;

    m_map.setMaximumSize(m_map.maximumSize());
    //m_controlPanel.setMaximumSize(m_controlPanel.maximumSize());

    QFrame *right_menu = new QFrame;
    QVBoxLayout *right_menu_lout = new QVBoxLayout;
    right_menu_lout->setAlignment(Qt::AlignTop);

    //    Timer Control
    QGroupBox *timer_control = new QGroupBox("Timer control");
    QPushButton *start_t = new QPushButton("start");
    connect(start_t, SIGNAL(clicked()), &m_map, SLOT(slotStartTimer()));
    QPushButton *stop_t = new QPushButton("stop");
    connect(stop_t, SIGNAL(clicked()), &m_map, SLOT(slotStopTimer()));
    QLabel *lbl = new QLabel("Delay (ms)");

    QSlider *slider_delay = new QSlider(Qt::Horizontal);
    slider_delay->setTickPosition(QSlider::TicksBelow);
    slider_delay->setTickInterval(50);
    slider_delay->setPageStep(50);
    slider_delay->setRange(50, 500);
    connect(slider_delay, SIGNAL(valueChanged(int)), &m_map, SLOT(slotChangeDelay(int)));
    QVBoxLayout *timer_lout = new QVBoxLayout;
    QHBoxLayout *timer_btn_lout = new QHBoxLayout;
    timer_btn_lout->addWidget(start_t);
    timer_btn_lout->addWidget(stop_t);
    timer_lout->addLayout(timer_btn_lout);
    timer_lout->addWidget(lbl);
    timer_lout->addWidget(slider_delay);
    timer_control->setLayout(timer_lout);
    timer_control->setMaximumSize(timer_control->sizeHint());

    //    Map control
    QGroupBox *map_control = new QGroupBox("Map control");
    QPushButton *clear_map = new QPushButton("clear map");
    connect(clear_map, SIGNAL(clicked()), &m_map, SLOT(slotClearMap()));
    QHBoxLayout *map_control_lout = new QHBoxLayout;
    map_control_lout->addWidget(clear_map);
    map_control->setLayout(map_control_lout);
    map_control->setMaximumSize((map_control->sizeHint()));

    right_menu_lout->addWidget(timer_control);
    right_menu_lout->addWidget(map_control);
    right_menu->setLayout(right_menu_lout);

    QHBoxLayout *lout = new QHBoxLayout;
    lout->setAlignment(Qt::AlignLeft | Qt::AlignTop);
    QScrollArea *scroll_map = new QScrollArea;
    scroll_map->setWidget(&m_map);
    lout->addWidget(scroll_map);
    lout->addWidget(right_menu);

    central->setLayout(lout);

    setCentralWidget(central);
    setWindowTitle("LiveCell");
}
Beispiel #2
0
MainWindow::MainWindow()
{
	setCaption(tr("GA Bots " VERSION));

	initActions();
	initMenuBar();
	initToolBar();
	initStatusBar();

	initGABotDoc();
	initView();

	ViewToolBar->setOn(true);
	ViewStatusBar->setOn(true);
	//ViewGame->setOn(true);

	connect(GABotDoc, SIGNAL(gameReady(bool)), this, SLOT(slotGameReady(bool)));
	connect(GABotDoc, SIGNAL(teamAScores()), View, SLOT(slotScoreA()));
	connect(GABotDoc, SIGNAL(teamBScores()), View, SLOT(slotScoreB()));
	connect(GABotDoc, SIGNAL(clearScores()), View, SLOT(slotClearScores()));

	connect(GABotDoc, SIGNAL(moveTeamA(Coordinate, Coordinate)), View,
		SLOT(slotMoveTeamA(Coordinate, Coordinate)));
	connect(GABotDoc, SIGNAL(moveTeamB(Coordinate, Coordinate)), View,
		SLOT(slotMoveTeamB(Coordinate, Coordinate)));
	connect(GABotDoc, SIGNAL(turnTeamA(Coordinate, Direction)), View,
		SLOT(slotTurnTeamA(Coordinate, Direction)));
	connect(GABotDoc, SIGNAL(turnTeamB(Coordinate, Direction)), View,
		SLOT(slotTurnTeamB(Coordinate, Direction)));

	connect(GABotDoc, SIGNAL(moveBall(Coordinate,Coordinate)), View,
		SLOT(slotMoveBall(Coordinate,Coordinate)));

	connect(GoGame, SIGNAL(activated()), this, SLOT(slotGoGame()));
	connect(GoGame, SIGNAL(activated()), GABotDoc, SLOT(slotStartTimer()));
	connect(StopGame, SIGNAL(activated()), GABotDoc, SLOT(slotStopTimer()));
	connect(StopGame, SIGNAL(activated()), this, SLOT(slotStopGame()));

	connect(View, SIGNAL(valueChanged(int)), this, SLOT(slotTickInterval(int)));
	connect(GABotDoc, SIGNAL(clearField()), View, SLOT(slotClearField()));

	connect(ResetScreen, SIGNAL(activated()), View, SLOT(slotClearField()));
//not sure if we should clear the field whenever regenerating the team
//	connect(TeamAGenerate,SIGNAL(activated()), View, SLOT(slotClearField()));
//	connect(TeamBGenerate,SIGNAL(activated()), View, SLOT(slotClearField()));

	connect(GABotDoc, SIGNAL(gameOver()), View, SLOT(slotClearField()));
	connect(GABotDoc, SIGNAL(gameOver()), View, SLOT(slotClearScores()));
	connect(GABotDoc, SIGNAL(gameOver()), this, SLOT(slotGameOver()));
	
}