78 lines
2.9 KiB
C++
78 lines
2.9 KiB
C++
/***************************************************************************
|
|
* Copyright (C) 2009 by Stefan Bühler *
|
|
* stbuehler@web.de *
|
|
* *
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
* (at your option) any later version. *
|
|
* *
|
|
* This program is distributed in the hope that it will be useful, *
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
* GNU General Public License for more details. *
|
|
* *
|
|
* You should have received a copy of the GNU General Public License *
|
|
* along with this program; if not, write to the *
|
|
* Free Software Foundation, Inc., *
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
***************************************************************************/
|
|
#include "testgame.h"
|
|
|
|
#include <QGridLayout>
|
|
#include <QResizeEvent>
|
|
#include <QMouseEvent>
|
|
#include <QPainter>
|
|
#include <QStatusBar>
|
|
|
|
#include <QMenuBar>
|
|
#include <QMenu>
|
|
|
|
#include "field2d.h"
|
|
#include "field3d.h"
|
|
|
|
#include "ai.h"
|
|
|
|
namespace toruschess {
|
|
|
|
TestGame::TestGame(QWidget *parent) : QMainWindow(parent), m_game(new Game()), m_optionDlg(new OptionDlg(m_game, this)) {
|
|
setWindowTitle("Torus Chess");
|
|
// PieceLibrary *lib = new PieceLibrary(this);
|
|
// setCentralWidget(new TestField(this, lib, m_game));
|
|
setCentralWidget(new Field2D(m_game, this));
|
|
statusBar()->show();
|
|
connect(m_game, SIGNAL(updated()), this, SLOT(gameUpdated()));
|
|
connect(m_game, SIGNAL(changed(GameState)), this, SLOT(gameChanged(GameState)));
|
|
m_game->restart();
|
|
|
|
QMenuBar *menuBar = new QMenuBar(this);
|
|
QMenu *menuGame = menuBar->addMenu("Game");
|
|
menuGame->addAction("New Game", this, SLOT(menuRestart()));
|
|
menuGame->addAction("Options", this, SLOT(menuOptions()));
|
|
menuGame->addSeparator();
|
|
menuGame->addAction("Quit", this, SLOT(close()));
|
|
setMenuBar(menuBar);
|
|
|
|
}
|
|
|
|
void TestGame::gameUpdated() {
|
|
/* if (m_game->state() == TURN_BLACK) {
|
|
Move m = ai::getMove(m_game);
|
|
if (m.valid()) m_game->move(m);
|
|
}*/
|
|
}
|
|
|
|
void TestGame::gameChanged(GameState state) {
|
|
statusBar()->showMessage(state2string(state));
|
|
}
|
|
|
|
void TestGame::menuRestart() {
|
|
m_game->restart();
|
|
}
|
|
|
|
void TestGame::menuOptions() {
|
|
m_optionDlg->exec();
|
|
}
|
|
|
|
}
|