Initial commit

This commit is contained in:
2024-11-30 09:36:15 +02:00
commit 289ad112e3
19 changed files with 1427 additions and 0 deletions

37
QTicTacToe.pro Normal file
View File

@@ -0,0 +1,37 @@
#-------------------------------------------------
#
# Project created by QtCreator 2011-02-12T15:39:17
#
#-------------------------------------------------
QT += core gui network widgets
TARGET = QTicTacToe
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
qtictactoegame.cpp \
qtictactoeboard.cpp \
gamesettingsdialog.cpp
HEADERS += mainwindow.h \
qtictactoegame.h \
qtictactoeboard.h \
gamesettingsdialog.h
FORMS += mainwindow.ui \
gamesettingsdialog.ui
RESOURCES += \
images.qrc
TRANSLATIONS += tictactoe_ru.ts
#INCLUDEPATH += ../../qxmpp-0.2.0/src
#LIBS += -L../../qxmpp-0.2.0/lib -lqxmpp
#OTHER_FILES += \
# Board.qml

BIN
cross.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

51
gamesettingsdialog.cpp Normal file
View File

@@ -0,0 +1,51 @@
#include "gamesettingsdialog.h"
#include "ui_gamesettingsdialog.h"
GameSettingsDialog::GameSettingsDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::GameSettingsDialog)
{
ui->setupUi(this);
}
GameSettingsDialog::~GameSettingsDialog()
{
delete ui;
}
void GameSettingsDialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void GameSettingsDialog::on_sbBoardSize_valueChanged(int value)
{
ui->sbCountToWin->setMaximum(value);
}
int GameSettingsDialog::getBoardSize()
{
return ui->sbBoardSize->value();
}
int GameSettingsDialog::getCountToWin()
{
return ui->sbCountToWin->value();
}
void GameSettingsDialog::setBoardSize(int size)
{
ui->sbBoardSize->setValue(size);
}
void GameSettingsDialog::setCountToWin(int count)
{
ui->sbCountToWin->setValue(count);
}

34
gamesettingsdialog.h Normal file
View File

@@ -0,0 +1,34 @@
#ifndef GAMESETTINGSDIALOG_H
#define GAMESETTINGSDIALOG_H
#include <QDialog>
namespace Ui {
class GameSettingsDialog;
}
class GameSettingsDialog : public QDialog
{
Q_OBJECT
public:
explicit GameSettingsDialog(QWidget *parent = 0);
~GameSettingsDialog();
int getBoardSize();
int getCountToWin();
void setBoardSize(int size);
void setCountToWin(int count);
protected:
void changeEvent(QEvent *e);
private:
Ui::GameSettingsDialog *ui;
private slots:
void on_sbBoardSize_valueChanged(int );
};
#endif // GAMESETTINGSDIALOG_H

126
gamesettingsdialog.ui Normal file
View File

@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GameSettingsDialog</class>
<widget class="QDialog" name="GameSettingsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>228</width>
<height>159</height>
</rect>
</property>
<property name="windowTitle">
<string>Game settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Game settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Board size:</string>
</property>
<property name="buddy">
<cstring>sbBoardSize</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="sbBoardSize">
<property name="minimum">
<number>3</number>
</property>
<property name="maximum">
<number>150</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Count to win:</string>
</property>
<property name="buddy">
<cstring>sbCountToWin</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="sbCountToWin">
<property name="minimum">
<number>3</number>
</property>
<property name="maximum">
<number>3</number>
</property>
</widget>
</item>
<item row="2" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>98</width>
<height>28</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>GameSettingsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>GameSettingsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

BIN
i18n/qt_ru_RU.qm Normal file

Binary file not shown.

BIN
i18n/tictactoe_ru_RU.qm Normal file

Binary file not shown.

6
images.qrc Normal file
View File

@@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/">
<file alias="1">cross.PNG</file>
<file alias="2">ought.PNG</file>
</qresource>
</RCC>

26
main.cpp Normal file
View File

@@ -0,0 +1,26 @@
#include <QtWidgets/QApplication>
#include "mainwindow.h"
#include <QTranslator>
#include <QLocale>
#include <QDir>
#include "qtictactoegame.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QDir dir(QApplication::applicationDirPath());
dir.cd("i18n");
QTranslator translator,qt;
translator.load("tictactoe_"+QLocale::system().name(),dir.absolutePath());
a.installTranslator(&translator);
qt.load("qt_"+QLocale::system().name(),dir.absolutePath());
a.installTranslator(&qt);
MainWindow w;
w.showMaximized();
return a.exec();
}

250
mainwindow.cpp Normal file
View File

@@ -0,0 +1,250 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QInputDialog>
#include <QSettings>
#include <QNetworkInterface>
#include "gamesettingsdialog.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
board = new QTicTacToeBoard(ui->scrollArea, 2);
ui->scrollArea->setWidget(board);
ui->actionNew_game->setIcon(QIcon::fromTheme("document-new"));
ui->actionGame_settings->setIcon(QIcon::fromTheme("document-properties"));
game = 0;
tcpServer = 0;
tcpSocket = 0;
clientSocket = 0;
isServer = false;
isClient = false;
isLocalGame = true;
newGame();
}
void MainWindow::newGame()
{
if (isClient)
{
QMessageBox::information(this,tr("QTicTacToe"),tr("You connected to server! Only server can start game!"));
return;
}
if (game) delete game;
QSettings settings("Home inc.","TicTacToe",this);
settings.beginGroup("gameSettings");
boardSize = settings.value("boardSize",3).toInt();
countToWin = settings.value("countToWin",3).toInt();
game = new QTicTacToeGame(boardSize,countToWin,this);
board->setGame(game);
connect(game,SIGNAL(gameOver(int)), this, SLOT(gameOver(int)));
connect(game,SIGNAL(itemPuted(int,int,int)), this, SLOT(turn(int,int,int)));
if (isServer)
{
clientSocket->write(QString("settings:%1:%2").arg(boardSize).arg(countToWin).toUtf8());
}
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void MainWindow::gameOver(int player)
{
QString mess(player?tr("Game over! Player %1 win!").arg(player):tr("Game over! No win!"));
QMessageBox::information(this,tr("Game over"),mess);
game->clear();
}
void MainWindow::turn(int x, int y, int player)
{
QString data = QString("%1:%2:%3").arg(x).arg(y).arg(player);
if (isServer)
{
clientSocket->write(data.toUtf8());
}
if (isClient)
{
tcpSocket->write(data.toUtf8());
}
this->statusBar()->showMessage(tr("Opponent turn"));
}
void MainWindow::readTurn()
{
QString data = QString::fromUtf8(isClient?tcpSocket->readAll():clientSocket->readAll());
QStringList t = data.split(":");
if (t.at(0) == "settings")
{
delete game;
game = new QTicTacToeGame(t.at(1).toInt(), t.at(2).toInt(), this);
board->setGame(game);
connect(game,SIGNAL(gameOver(int)), this, SLOT(gameOver(int)));
connect(game,SIGNAL(itemPuted(int,int,int)), this, SLOT(turn(int,int,int)));
ui->actionStart_server->setEnabled(false);
ui->actionConnect_to_Server->setEnabled(false);
ui->actionDisconnect->setEnabled(true);
this->statusBar()->showMessage(tr("Connected to server!"), 5000);
} else
{
if (game->put(t.at(0).toInt(), t.at(1).toInt(), t.at(2).toInt()))
{
this->statusBar()->showMessage(tr("Your turn"));
}
}
}
void MainWindow::on_actionNew_game_triggered()
{
newGame();
}
void MainWindow::on_actionGame_settings_triggered()
{
GameSettingsDialog *dialog = new GameSettingsDialog(this);
dialog->setBoardSize(boardSize);
dialog->setCountToWin(countToWin);
if (dialog->exec())
{
QSettings settings("Home inc.","TicTacToe",this);
settings.beginGroup("gameSettings");
settings.setValue("boardSize",dialog->getBoardSize());
settings.setValue("countToWin", dialog->getCountToWin());
newGame();
}
delete dialog;
}
void MainWindow::on_actionStart_server_triggered()
{
tcpServer = new QTcpServer(this);
tcpServer->setMaxPendingConnections(1);
connect(tcpServer,SIGNAL(newConnection()),this,SLOT(newConnection()));
if (!tcpServer->listen(QHostAddress::Any, 1515)) {
QMessageBox::critical(this, tr("QTicTacToe Server"), tr("Unable to start the server: %1.").arg(tcpServer->errorString()));
return;
}
board->setBoardPlayer(1);
this->statusBar()->showMessage(tr("Waiting for connection"));
ui->actionStart_server->setEnabled(false);
ui->actionConnect_to_Server->setEnabled(false);
ui->actionDisconnect->setEnabled(true);
board->setEnabled(false);
isClient = false;
isLocalGame = false;
isServer = true;
}
void MainWindow::newConnection()
{
this->statusBar()->showMessage(tr("New player connected!"), 5000);
clientSocket = tcpServer->nextPendingConnection();
connect(clientSocket,SIGNAL(readyRead()),this, SLOT(readTurn()));
connect(clientSocket,SIGNAL(disconnected()),clientSocket,SLOT(deleteLater()));
connect(clientSocket,SIGNAL(disconnected()),this,SLOT(on_actionDisconnect_triggered()));
newGame();
board->setEnabled(true);
}
void MainWindow::on_actionConnect_to_Server_triggered()
{
tcpSocket = new QTcpSocket(this);
tcpSocket->abort();
QString address = QInputDialog::getText(this,tr("QTicTacToe"),tr("Address"));
if (address.length()>0) {
tcpSocket->connectToHost(address,1515);
isClient = true;
isLocalGame = false;
isServer = false;
connect(tcpSocket,SIGNAL(readyRead()),this, SLOT(readTurn()));
connect(tcpSocket,SIGNAL(disconnected()),tcpSocket,SLOT(deleteLater()));
connect(tcpSocket,SIGNAL(disconnected()),this,SLOT(on_actionDisconnect_triggered()));
board->setBoardPlayer(2);
}
}
void MainWindow::on_actionDisconnect_triggered()
{
if (isServer)
{
disconnect(clientSocket,SIGNAL(disconnected()),this,SLOT(on_actionDisconnect_triggered()));
clientSocket->disconnectFromHost();
tcpServer->close();
}
if (isClient)
{
disconnect(tcpSocket,SIGNAL(disconnected()),this,SLOT(on_actionDisconnect_triggered()));
tcpSocket->disconnectFromHost();
}
isClient = false;
isLocalGame = true;
isServer = false;
ui->actionDisconnect->setEnabled(false);
ui->actionConnect_to_Server->setEnabled(true);
ui->actionStart_server->setEnabled(true);
board->setEnabled(true);
board->setBoardPlayer(0);
newGame();
this->statusBar()->clearMessage();
this->statusBar()->showMessage(tr("Player disconnected!"), 5000);
}
void MainWindow::on_actionAbout_triggered()
{
QMessageBox::about(this, tr("About"), tr("QTicTacToe v 0.1"));
}

66
mainwindow.h Normal file
View File

@@ -0,0 +1,66 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QtWidgets/QMainWindow>
#include <QTcpServer>
#include <QTcpSocket>
#include "qtictactoegame.h"
#include "qtictactoeboard.h"
//#include <QXmppClient.h>
//#include <QXmppMessage.h>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
protected:
void changeEvent(QEvent *e);
private:
Ui::MainWindow *ui;
QTicTacToeGame *game;
QTicTacToeBoard *board;
QTcpServer *tcpServer;
QTcpSocket *tcpSocket;
QTcpSocket *clientSocket;
//QXmppClient *c;
void newGame();
int boardSize;
int countToWin;
bool isServer;
bool isClient;
bool isLocalGame;
private slots:
//void on_actionConnectToJabber_triggered();
void on_actionAbout_triggered();
void on_actionDisconnect_triggered();
void on_actionConnect_to_Server_triggered();
void on_actionStart_server_triggered();
void on_actionGame_settings_triggered();
void on_actionNew_game_triggered();
void gameOver(int player);
void newConnection();
void turn(int x, int y, int player);
void readTurn();
//void message(QXmppMessage message);
};
#endif // MAINWINDOW_H

123
mainwindow.ui Normal file
View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>572</width>
<height>444</height>
</rect>
</property>
<property name="windowTitle">
<string>TicTacToe</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QScrollArea" name="scrollArea">
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>552</width>
<height>360</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2"/>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>572</width>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menuGame">
<property name="title">
<string>Game</string>
</property>
<addaction name="actionNew_game"/>
<addaction name="actionGame_settings"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
<string>Help</string>
</property>
<addaction name="actionAbout"/>
</widget>
<addaction name="menuGame"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionNew_game"/>
<addaction name="actionGame_settings"/>
<addaction name="actionStart_server"/>
<addaction name="actionConnect_to_Server"/>
<addaction name="actionDisconnect"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionNew_game">
<property name="text">
<string>New game</string>
</property>
<property name="toolTip">
<string>Start new game</string>
</property>
<property name="shortcut">
<string>Ctrl+N</string>
</property>
</action>
<action name="actionGame_settings">
<property name="text">
<string>Game settings</string>
</property>
<property name="toolTip">
<string>Show game settings dialog</string>
</property>
<property name="shortcut">
<string>Ctrl+P</string>
</property>
</action>
<action name="actionStart_server">
<property name="text">
<string>Start server</string>
</property>
</action>
<action name="actionConnect_to_Server">
<property name="text">
<string>Connect to Server</string>
</property>
</action>
<action name="actionDisconnect">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Disconnect</string>
</property>
</action>
<action name="actionAbout">
<property name="text">
<string>About</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

BIN
ought.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

365
qrc_images.cpp Normal file
View File

@@ -0,0 +1,365 @@
/****************************************************************************
** Resource object code
**
** Created by: The Resource Compiler for Qt version 5.15.2
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
static const unsigned char qt_resource_data[] = {
// /home/denis/projects/QTicTacToe/cross.PNG
0x0,0x0,0x9,0xc1,
0x89,
0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,
0x0,0x0,0x32,0x0,0x0,0x0,0x32,0x8,0x6,0x0,0x0,0x0,0x1e,0x3f,0x88,0xb1,
0x0,0x0,0x0,0x1,0x73,0x52,0x47,0x42,0x0,0xae,0xce,0x1c,0xe9,0x0,0x0,0x0,
0x6,0x62,0x4b,0x47,0x44,0x0,0xff,0x0,0xff,0x0,0xff,0xa0,0xbd,0xa7,0x93,0x0,
0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,
0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xdb,0x2,0xc,
0xe,0x1c,0x17,0xeb,0x1,0x5f,0x4,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,
0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,
0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x9,0x1c,
0x49,0x44,0x41,0x54,0x68,0xde,0xed,0x9a,0x5d,0x6c,0x1c,0x57,0x15,0x80,0xbf,0x3b,
0x33,0xfb,0xe3,0xb5,0xd7,0x4e,0x89,0xbd,0x5e,0xbb,0x8d,0xe3,0xd8,0x21,0xc4,0x49,
0xa8,0xd2,0xc8,0x81,0x16,0x35,0xae,0xe2,0x1a,0x28,0x48,0x21,0x55,0x24,0x8,0xa0,
0x88,0x42,0x5,0x3c,0x50,0x5e,0x50,0x5a,0x24,0xe8,0x53,0xd5,0x38,0xf4,0xa5,0x82,
0xa,0x4,0x94,0x84,0xd6,0xed,0x43,0x5,0x2,0x91,0x28,0x69,0x22,0xf1,0x50,0x12,
0x87,0x86,0x2a,0x4a,0x13,0x50,0xda,0x92,0x34,0x89,0x88,0x9d,0x84,0x54,0xb1,0xbd,
0x8e,0xe3,0xdd,0xb5,0xbd,0x3f,0xb3,0xc3,0xc3,0xdc,0xeb,0xb9,0x3b,0xde,0xb5,0xd7,
0x76,0xdc,0x82,0xc4,0x4a,0x57,0xeb,0xf5,0xce,0xdc,0x7b,0xbe,0x7b,0xce,0x3d,0x7f,
0xb3,0xf0,0xff,0xd7,0xff,0xf6,0x4b,0xfc,0xb7,0xae,0x2b,0x16,0x30,0x89,0xf3,0x11,
0x2,0x38,0xb,0x1,0x51,0xdf,0x19,0x72,0xe8,0x93,0x15,0xe4,0xb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x75,0xbf,0x7b,0x19,0x9a,0x4f,0x42,0x9d,0xd,0x13,
0xb7,0xc1,0x39,0x5,0xc9,0x57,0xe0,0xb5,0x17,0xee,0x80,0x26,0x66,0xd1,0xcc,0xbb,
0xfd,0xb0,0x6e,0x4,0x82,0x37,0xc1,0x1e,0x85,0xc0,0x31,0xb8,0xf2,0x23,0xf8,0x7d,
0xbf,0xd7,0x57,0x2b,0x76,0xbf,0x62,0x8e,0x44,0x51,0x3e,0xe,0xde,0x50,0xef,0x1e,
0xc2,0xb8,0x25,0x9b,0x4,0x46,0x89,0x1a,0x7b,0x31,0x10,0xa2,0x44,0x82,0x5a,0x80,
0x4d,0xf5,0x30,0x94,0x83,0xbb,0x80,0x77,0x46,0xa4,0x3c,0xa5,0xd2,0xe7,0xb2,0xe5,
0xa4,0x3f,0x42,0xc9,0xd4,0x40,0x18,0xe0,0x38,0x25,0x3a,0x1d,0x77,0xe2,0x17,0x10,
0x62,0x26,0xd0,0xf4,0x7a,0x6a,0xd8,0xe5,0x7e,0x75,0x21,0xe6,0x31,0x79,0x51,0xe1,
0xb0,0x84,0x3f,0xdf,0xf0,0xaf,0x4d,0x89,0x6a,0xd1,0x59,0xcc,0xc4,0x4b,0xf5,0xb3,
0x8d,0x4a,0x36,0xf1,0xa3,0xfa,0x55,0xd2,0x87,0xff,0xfa,0xf,0x45,0xf6,0x6f,0x22,
0x15,0xd8,0xdc,0x18,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82,
// /home/denis/projects/QTicTacToe/ought.PNG
0x0,0x0,0x7,0x40,
0x89,
0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,
0x0,0x0,0x32,0x0,0x0,0x0,0x32,0x8,0x6,0x0,0x0,0x0,0x1e,0x3f,0x88,0xb1,
0x0,0x0,0x0,0x1,0x73,0x52,0x47,0x42,0x0,0xae,0xce,0x1c,0xe9,0x0,0x0,0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12,0x3,0x53,0x62,0x89,0xad,0x78,0x83,0x30,0x60,
0xca,0xf7,0x23,0xd2,0xa0,0x2d,0xdf,0xbf,0xe1,0x2,0x9d,0xbb,0xa,0xef,0xef,0x85,
0x5f,0xa5,0x29,0x4f,0xa1,0xbc,0x30,0xda,0x28,0x21,0xa2,0x1b,0xe1,0x9d,0x89,0xb0,
0x7e,0x2a,0xe8,0xa5,0xa2,0xc0,0x10,0x90,0x0,0xfa,0x5d,0xa3,0x8e,0x25,0xe1,0x48,
0x2,0x7a,0xce,0xc3,0xc9,0x83,0x70,0xfe,0x49,0x88,0xcc,0x87,0xea,0x5a,0x98,0x13,
0x87,0x5,0x51,0x58,0x18,0x85,0x86,0x32,0x20,0x2e,0xd,0x5b,0xa2,0xce,0x65,0xb0,
0x6f,0xc1,0xee,0x9d,0xf0,0xa9,0x30,0x16,0x4,0x93,0xf,0xc4,0x83,0x30,0x1,0x73,
0x13,0x6c,0xad,0x80,0x37,0xaa,0xc5,0x80,0x61,0xe9,0xfc,0x5f,0x48,0x25,0xa0,0xed,
0x14,0xec,0x39,0x0,0x67,0xb2,0x78,0x21,0xfc,0x5e,0xae,0x19,0x66,0xcc,0x86,0xb5,
0x71,0x58,0x59,0x9,0x66,0x89,0x74,0x94,0x70,0x61,0xb8,0xe,0x5f,0xed,0x80,0xf7,
0x44,0xdc,0x94,0xf,0x66,0x44,0x31,0xf2,0xa8,0xe1,0x29,0x61,0x6e,0x84,0x77,0x27,
0xc3,0xba,0x1a,0xa0,0x44,0x5e,0x53,0x1f,0x70,0x5,0xba,0x8e,0xc3,0x9a,0x7d,0xf0,
0x43,0x2f,0x5c,0x51,0x86,0x44,0x5a,0x99,0xb8,0xde,0xe4,0xf5,0x3e,0xad,0x5e,0xb8,
0xf6,0x1b,0xb4,0x97,0xc3,0x2f,0x31,0x98,0xe5,0x40,0x9d,0x9,0x4c,0x90,0xb7,0x66,
0x43,0xe3,0x3c,0x70,0xba,0xe1,0x8f,0x42,0x26,0xbd,0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,0x94,0x58,0x37,0x55,0xda,0x4f,0x0,0x17,0xc1,0xbe,0x4,0x6f,0xf5,0xc0,
0x5f,0xa2,0x86,0x95,0x4d,0x8d,0x7c,0x8a,0x64,0x88,0x7b,0xe0,0xef,0x5,0xa0,0xd9,
0xf0,0xbc,0x97,0x44,0x8b,0xb9,0x16,0x35,0x2e,0x86,0x45,0x53,0xe0,0x78,0x2f,0xdc,
0xf6,0x19,0xeb,0xaf,0x86,0xf,0x20,0xc,0x98,0xcd,0x30,0xeb,0x75,0xf8,0xba,0x12,
0x56,0x55,0x9,0xc4,0x80,0x64,0x1b,0x6f,0xc0,0x27,0x9f,0xc3,0xb7,0xf9,0xd4,0x28,
0x64,0x68,0x65,0x54,0xea,0x86,0x23,0x8d,0x50,0x6a,0x41,0x63,0x44,0x40,0x62,0x6e,
0xc7,0x75,0x65,0xb0,0x66,0x29,0x4c,0xaf,0x82,0xb3,0x2,0x64,0x28,0x8e,0x20,0xe4,
0x7b,0xfb,0x11,0x20,0xd2,0xc,0xb3,0x5e,0x85,0xf,0x9e,0x84,0x9d,0x35,0xf0,0x54,
0xb9,0x7c,0x21,0x81,0xbb,0x7c,0xdf,0x80,0x7d,0x3b,0xdc,0x94,0xd3,0x90,0xa2,0xc6,
0x7d,0xe7,0x7e,0xc7,0x45,0x12,0x7b,0xdc,0x1c,0x2b,0x8c,0xab,0x83,0x9e,0x82,0x8f,
0xde,0x4c,0x68,0x9a,0xf0,0x88,0x1f,0xbd,0x3d,0xac,0xc3,0xd0,0x51,0x9d,0xbd,0x8f,
0x9b,0xe3,0xe9,0x62,0x4,0x7b,0x50,0xbc,0x1f,0xc,0xdc,0x77,0x72,0x63,0xdc,0xfc,
0x84,0x63,0xdc,0xfc,0xa8,0xe6,0x71,0x79,0xd4,0xca,0x7f,0xc7,0x6d,0xf4,0xf7,0xf5,
0x87,0x59,0xe8,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82,
};
static const unsigned char qt_resource_name[] = {
// 1
0x0,0x1,
0x0,0x0,0x0,0x31,
0x0,0x31,
// 2
0x0,0x1,
0x0,0x0,0x0,0x32,
0x0,0x32,
};
static const unsigned char qt_resource_struct[] = {
// :
0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
// :/1
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,
0x0,0x0,0x1,0x2e,0x1a,0x45,0xc7,0x40,
// :/2
0x0,0x0,0x0,0x8,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x9,0xc5,
0x0,0x0,0x1,0x2e,0x1a,0x49,0x9f,0xa0,
};
#ifdef QT_NAMESPACE
# define QT_RCC_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name
# define QT_RCC_MANGLE_NAMESPACE0(x) x
# define QT_RCC_MANGLE_NAMESPACE1(a, b) a##_##b
# define QT_RCC_MANGLE_NAMESPACE2(a, b) QT_RCC_MANGLE_NAMESPACE1(a,b)
# define QT_RCC_MANGLE_NAMESPACE(name) QT_RCC_MANGLE_NAMESPACE2( \
QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE))
#else
# define QT_RCC_PREPEND_NAMESPACE(name) name
# define QT_RCC_MANGLE_NAMESPACE(name) name
#endif
#ifdef QT_NAMESPACE
namespace QT_NAMESPACE {
#endif
bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *);
#ifdef QT_NAMESPACE
}
#endif
int QT_RCC_MANGLE_NAMESPACE(qInitResources_images)();
int QT_RCC_MANGLE_NAMESPACE(qInitResources_images)()
{
int version = 3;
QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData)
(version, qt_resource_struct, qt_resource_name, qt_resource_data);
return 1;
}
int QT_RCC_MANGLE_NAMESPACE(qCleanupResources_images)();
int QT_RCC_MANGLE_NAMESPACE(qCleanupResources_images)()
{
int version = 3;
QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData)
(version, qt_resource_struct, qt_resource_name, qt_resource_data);
return 1;
}
namespace {
struct initializer {
initializer() { QT_RCC_MANGLE_NAMESPACE(qInitResources_images)(); }
~initializer() { QT_RCC_MANGLE_NAMESPACE(qCleanupResources_images)(); }
} dummy;
}

83
qtictactoeboard.cpp Normal file
View File

@@ -0,0 +1,83 @@
#include "qtictactoeboard.h"
#include <QPainter>
#include <QMouseEvent>
QTicTacToeBoard::QTicTacToeBoard(QWidget *parent, int playersCount) :
QWidget(parent)
{
currPlayer = 1;
boardPlayer = 0;
this->playersCount = playersCount;
}
void QTicTacToeBoard::setBoardPlayer(int player)
{
boardPlayer = player;
currPlayer = 1;
}
void QTicTacToeBoard::setGame(QTicTacToeGame *game)
{
this->game = game;
setGeometry(0,0,game->getSize()*cellSize,game->getSize()*cellSize);
connect(game,SIGNAL(itemPuted(int,int,int)), this, SLOT(turn(int,int,int)));
update();
}
void QTicTacToeBoard::turn(int /*x*/, int /*y*/, int /*player*/)
{
currPlayer = (currPlayer == playersCount?1:currPlayer+1);
update();
}
QSize QTicTacToeBoard::sizeHint()
{
if (game)
return QSize(game->getSize()*cellSize, game->getSize()*cellSize);
else
return QSize(0,0);
}
void QTicTacToeBoard::mousePressEvent(QMouseEvent *event)
{
if (boardPlayer && currPlayer != boardPlayer) return;
int x = event->x() / cellSize;
int y = event->y() / cellSize;
game->put(x,y,currPlayer);
}
void QTicTacToeBoard::paintEvent(QPaintEvent *)
{
if (!game) return;
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(QPen(Qt::darkGreen, 1));
int size = game->getSize();
for (int i=1; i<size; i++)
{
painter.drawLine(i*cellSize,0,i*cellSize,this->height());
painter.drawLine(0,i*cellSize,this->width(),i*cellSize);
}
for (int i=0; i<size; i++)
{
for (int j=0; j<size;j++)
{
int player = game->getPlayer(i,j);
if (player)
{
painter.drawImage(i*cellSize, j*cellSize, QImage(QString(":/%1").arg(player)));
}
}
}
}

33
qtictactoeboard.h Normal file
View File

@@ -0,0 +1,33 @@
#ifndef QTICTACTOEBOARD_H
#define QTICTACTOEBOARD_H
#include <QtWidgets/QWidget>
#include "qtictactoegame.h"
const int cellSize = 50;
class QTicTacToeBoard : public QWidget
{
Q_OBJECT
public:
explicit QTicTacToeBoard(QWidget *parent = 0, int playersCount = 2);
void setGame(QTicTacToeGame *game);
void setBoardPlayer(int player);
private:
QTicTacToeGame *game;
void paintEvent(QPaintEvent *);
QSize sizeHint();
void mousePressEvent(QMouseEvent *);
int currPlayer;
int boardPlayer;
int playersCount;
private slots:
void turn(int x, int y, int player);
};
#endif // QTICTACTOEBOARD_H

116
qtictactoegame.cpp Normal file
View File

@@ -0,0 +1,116 @@
#include "qtictactoegame.h"
QTicTacToeGame::QTicTacToeGame(int size, int countToWin, QObject *parent) :
QObject(parent)
{
board = new int*[size];
for (int i=0; i<size; i++)
board[i] = new int[size];
this->size = size;
this->countToWin = countToWin;
clear();
}
void QTicTacToeGame::clear()
{
aviableCells = size*size;
for (int i=0; i<size;i++)
for (int j=0; j<size; j++)
board[i][j] = 0;
}
bool QTicTacToeGame::put(int x, int y, int player)
{
if (x<0||y<0||x>=size||y>=size) return false;
if (board[x][y]) return false;
board[x][y] = player;
emit itemPuted(x,y, player);
if (checkFromPoint(x,y)) emit gameOver(player);
aviableCells--;
if (!aviableCells)
emit gameOver(0);
return true;
}
bool QTicTacToeGame::checkFromPoint(int x, int y)
{
int currPlayer = board[x][y];
int cnt = 0;
int minXBorder = qMax(x-countToWin,0);
int maxXBorder = qMin(x+countToWin,size);
int minYBorder = qMax(y-countToWin,0);
int maxYBorder = qMin(y+countToWin,size);
// check X axis
for (int i=minXBorder; i<maxXBorder; i++)
{
if (board[i][y]==currPlayer) cnt++;
else cnt=0;
if (cnt==countToWin) return true;
}
// check Y axis
cnt = 0;
for (int i=minYBorder; i<maxYBorder; i++)
{
if (board[x][i]==currPlayer) cnt++;
else cnt=0;
if (cnt==countToWin) return true;
}
int vX = x;
int vY = y;
cnt = 0;
// check TopLeft - BottomRight diag
while (vX >= 0 && vX >= x-countToWin && vY >=0 && vY >= y-countToWin && board[vX][vY] == currPlayer)
{
cnt++; vX--; vY--;
}
vX = x; vY = y; cnt--;
while (vX < size && vX < x+countToWin && vY < size && vY < y+countToWin && board[vX][vY] == currPlayer)
{
cnt++; vX++; vY++;
}
if (cnt>=countToWin) return true;
// check BottomLeft - TopRight diag
vX = x; vY = y; cnt = 0;
while (vX >= 0 && vX >= x-countToWin && vY < size && vY < y+countToWin && board[vX][vY] == currPlayer)
{
cnt++; vX--; vY++;
}
vX = x; vY = y; cnt--;
while (vX < size && vX < x+countToWin && vY >=0 && vY >= y-countToWin && board[vX][vY] == currPlayer)
{
cnt++; vX++; vY--;
}
if (cnt>=countToWin) return true;
return false;
}
int QTicTacToeGame::getPlayer(int x, int y)
{
Q_ASSERT(x>=0&&y>=0&&x<size&&y<size);
return board[x][y];
}
int QTicTacToeGame::getSize()
{
return size;
}

30
qtictactoegame.h Normal file
View File

@@ -0,0 +1,30 @@
#ifndef QTICTACTOEGAME_H
#define QTICTACTOEGAME_H
#include <QObject>
class QTicTacToeGame : public QObject
{
Q_OBJECT
public:
explicit QTicTacToeGame(int size = 3, int countToWin = 3, QObject *parent = 0);
bool put(int x, int y, int player);
int getPlayer(int x, int y);
Q_INVOKABLE int getSize();
void clear();
private:
int **board;
int size, countToWin, aviableCells;
bool checkFromPoint(int x, int y);
signals:
void gameOver(int player);
void itemPuted(int x, int y, int player);
public slots:
};
#endif // QTICTACTOEGAME_H

81
tictactoe_ru.ts Normal file
View File

@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="ru_RU">
<context>
<name>GameSettingsDialog</name>
<message>
<location filename="gamesettingsdialog.ui" line="14"/>
<location filename="gamesettingsdialog.ui" line="20"/>
<source>Game settings</source>
<translation>Настройки игры</translation>
</message>
<message>
<location filename="gamesettingsdialog.ui" line="26"/>
<source>&amp;Board size:</source>
<translation>&amp;Размер поля:</translation>
</message>
<message>
<location filename="gamesettingsdialog.ui" line="46"/>
<source>&amp;Count to win:</source>
<translation>&amp;Количество для победы:</translation>
</message>
</context>
<context>
<name>MainWindow</name>
<message>
<location filename="mainwindow.ui" line="14"/>
<source>TicTacToe</source>
<translation>Крестики нолики</translation>
</message>
<message>
<location filename="mainwindow.ui" line="46"/>
<source>Game</source>
<translation>Игра</translation>
</message>
<message>
<location filename="mainwindow.ui" line="66"/>
<source>New game</source>
<translation>Новая игра</translation>
</message>
<message>
<location filename="mainwindow.ui" line="69"/>
<source>Start new game</source>
<translation>Начать новую игру</translation>
</message>
<message>
<location filename="mainwindow.ui" line="72"/>
<source>Ctrl+N</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="77"/>
<source>Game settings</source>
<translation>Настройки игры</translation>
</message>
<message>
<location filename="mainwindow.ui" line="80"/>
<source>Show game settings dialog</source>
<translation>Показать диалог настроек игры</translation>
</message>
<message>
<location filename="mainwindow.ui" line="83"/>
<source>Ctrl+P</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="60"/>
<source>Game over! Player %1 win!</source>
<translation>Игра окончена! Победил игрок %1!</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="60"/>
<source>Game over! No win!</source>
<translation>Игра окончена! Ничья!</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="61"/>
<source>Game over</source>
<translation>Игра окончена</translation>
</message>
</context>
</TS>