|
|
@ -11,14 +11,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
|
|
#if QT_VERSION >= 0x040000
|
|
|
|
|
|
|
|
#include <QtGui/QApplication>
|
|
|
|
|
|
|
|
#include <QtGui/QPainter>
|
|
|
|
|
|
|
|
#include <QtGui/QCursor>
|
|
|
|
|
|
|
|
#include <QtGui/QMessageBox>
|
|
|
|
|
|
|
|
#include <QtGui/QFileDialog>
|
|
|
|
|
|
|
|
#include <QtCore/QDateTime>
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#include <ntqapplication.h>
|
|
|
|
#include <ntqapplication.h>
|
|
|
|
#include <ntqpainter.h>
|
|
|
|
#include <ntqpainter.h>
|
|
|
|
#include <ntqcursor.h>
|
|
|
|
#include <ntqcursor.h>
|
|
|
@ -26,24 +18,15 @@
|
|
|
|
#include <ntqfiledialog.h>
|
|
|
|
#include <ntqfiledialog.h>
|
|
|
|
#include <ntqdatetime.h>
|
|
|
|
#include <ntqdatetime.h>
|
|
|
|
#include <ntqwmatrix.h>
|
|
|
|
#include <ntqwmatrix.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "gameboard.h"
|
|
|
|
#include "gameboard.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define DELAY 10
|
|
|
|
#define DELAY 10
|
|
|
|
#define STEP 5
|
|
|
|
#define STEP 5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if QT_VERSION >= 0x040000
|
|
|
|
|
|
|
|
BoardItem::BoardItem(int n, QWidget *parent)
|
|
|
|
|
|
|
|
:QLabel(parent)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
BoardItem::BoardItem(int n, TQWidget *parent, const char *name)
|
|
|
|
BoardItem::BoardItem(int n, TQWidget *parent, const char *name)
|
|
|
|
:TQLabel(parent, name)
|
|
|
|
:TQLabel(parent, name)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
num = n;
|
|
|
|
num = n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -51,7 +34,6 @@ BoardItem::~BoardItem()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
BoardItem::paintEvent(TQPaintEvent *e)
|
|
|
|
BoardItem::paintEvent(TQPaintEvent *e)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -73,13 +55,8 @@ BoardItem::paintEvent(TQPaintEvent *e)
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
#if QT_VERSION >= 0x040000
|
|
|
|
|
|
|
|
GameBoard::GameBoard(QWidget *parent)
|
|
|
|
|
|
|
|
:QWidget(parent)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
GameBoard::GameBoard(TQWidget *parent, const char *name)
|
|
|
|
GameBoard::GameBoard(TQWidget *parent, const char *name)
|
|
|
|
:TQWidget(parent, name)
|
|
|
|
:TQWidget(parent, name)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#include "cat.xpm"
|
|
|
|
#include "cat.xpm"
|
|
|
|
TQPixmap xpm(cat_xpm);
|
|
|
|
TQPixmap xpm(cat_xpm);
|
|
|
@ -109,7 +86,6 @@ GameBoard::~GameBoard()
|
|
|
|
void
|
|
|
|
void
|
|
|
|
GameBoard::resizeEvent(TQResizeEvent *e)
|
|
|
|
GameBoard::resizeEvent(TQResizeEvent *e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
TQWidget::resizeEvent(e);
|
|
|
|
TQWidget::resizeEvent(e);
|
|
|
|
initMap();
|
|
|
|
initMap();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -126,15 +102,10 @@ GameBoard::initMap()
|
|
|
|
TQPixmap xpm;
|
|
|
|
TQPixmap xpm;
|
|
|
|
|
|
|
|
|
|
|
|
if (!origin.isNull()) {
|
|
|
|
if (!origin.isNull()) {
|
|
|
|
#if QT_VERSION >= 0x040000
|
|
|
|
|
|
|
|
xpm = origin.scaled(width(), height(),
|
|
|
|
|
|
|
|
Qt::KeepAspectRatioByExpanding);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
TQWMatrix mtx;
|
|
|
|
TQWMatrix mtx;
|
|
|
|
mtx.scale((float)width() / (float)origin.width(),
|
|
|
|
mtx.scale((float)width() / (float)origin.width(),
|
|
|
|
(float)height() / (float)origin.height());
|
|
|
|
(float)height() / (float)origin.height());
|
|
|
|
xpm = origin.xForm(mtx);
|
|
|
|
xpm = origin.xForm(mtx);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < num; ++i) {
|
|
|
|
for (i = 0; i < num; ++i) {
|
|
|
@ -148,15 +119,10 @@ GameBoard::initMap()
|
|
|
|
y = (i >> 2);
|
|
|
|
y = (i >> 2);
|
|
|
|
x = i - (y << 2);
|
|
|
|
x = i - (y << 2);
|
|
|
|
map[i]->move(x * w, y * h);
|
|
|
|
map[i]->move(x * w, y * h);
|
|
|
|
#if QT_VERSION >= 0x040000
|
|
|
|
|
|
|
|
map[i]->setPixmap(xpm.copy(map[i]->x(), map[i]->y(),
|
|
|
|
|
|
|
|
w, h));
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
TQPixmap xpm1(map[i]->size());
|
|
|
|
TQPixmap xpm1(map[i]->size());
|
|
|
|
copyBlt(&xpm1, 0, 0, &xpm,
|
|
|
|
copyBlt(&xpm1, 0, 0, &xpm,
|
|
|
|
map[i]->x(), map[i]->y(), w, h);
|
|
|
|
map[i]->x(), map[i]->y(), w, h);
|
|
|
|
map[i]->setPixmap(xpm1);
|
|
|
|
map[i]->setPixmap(xpm1);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (map[num] != NULL)
|
|
|
|
if (map[num] != NULL)
|
|
|
@ -279,7 +245,6 @@ GameBoard::index(int x, int y)
|
|
|
|
void
|
|
|
|
void
|
|
|
|
GameBoard::startMoving(int i, int t)
|
|
|
|
GameBoard::startMoving(int i, int t)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
n = i; nt = t;
|
|
|
|
n = i; nt = t;
|
|
|
|
xt = (t - (t & ~3)) * map[n]->width();
|
|
|
|
xt = (t - (t & ~3)) * map[n]->width();
|
|
|
|
yt = (t >> 2) * map[n]->height();
|
|
|
|
yt = (t >> 2) * map[n]->height();
|
|
|
@ -382,7 +347,6 @@ GameBoard::checkEndGame()
|
|
|
|
void
|
|
|
|
void
|
|
|
|
GameBoard::newGame()
|
|
|
|
GameBoard::newGame()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
setEnabled(TRUE);
|
|
|
|
setEnabled(TRUE);
|
|
|
|
initMap();
|
|
|
|
initMap();
|
|
|
|
newTask();
|
|
|
|
newTask();
|
|
|
@ -429,13 +393,8 @@ GameBoard::loadImage()
|
|
|
|
TQString str;
|
|
|
|
TQString str;
|
|
|
|
TQPixmap img;
|
|
|
|
TQPixmap img;
|
|
|
|
|
|
|
|
|
|
|
|
#if QT_VERSION >= 0x040000
|
|
|
|
|
|
|
|
str = QFileDialog::getOpenFileName(this, tr("Open an image..."),
|
|
|
|
|
|
|
|
QString::null, "*");
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
str = TQFileDialog::getOpenFileName(TQString::null, "*", this, NULL,
|
|
|
|
str = TQFileDialog::getOpenFileName(TQString::null, "*", this, NULL,
|
|
|
|
tr("Open an image..."));
|
|
|
|
tr("Open an image..."));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!str.isEmpty()) {
|
|
|
|
if (!str.isEmpty()) {
|
|
|
|
if (img.load(str)) {
|
|
|
|
if (img.load(str)) {
|
|
|
|