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