|
|
|
@ -71,7 +71,7 @@ const uint CHIP_SIZE = 36;
|
|
|
|
|
// class KReversiBoardView
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TQReversiBoardView::TQReversiBoardView(TQWidget *tqparent, TQReversiGame *krgame)
|
|
|
|
|
QReversiBoardView::QReversiBoardView(TQWidget *tqparent, QReversiGame *krgame)
|
|
|
|
|
: TQWidget(tqparent, "board"),
|
|
|
|
|
chiptype(Unloaded)
|
|
|
|
|
{
|
|
|
|
@ -86,7 +86,7 @@ TQReversiBoardView::TQReversiBoardView(TQWidget *tqparent, TQReversiGame *krgame
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TQReversiBoardView::~TQReversiBoardView()
|
|
|
|
|
QReversiBoardView::~QReversiBoardView()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -97,14 +97,14 @@ TQReversiBoardView::~TQReversiBoardView()
|
|
|
|
|
// Start it all up.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::start()
|
|
|
|
|
void QReversiBoardView::start()
|
|
|
|
|
{
|
|
|
|
|
updateBoard(true);
|
|
|
|
|
adjustSize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::loadChips(ChipType type)
|
|
|
|
|
void QReversiBoardView::loadChips(ChipType type)
|
|
|
|
|
{
|
|
|
|
|
TQString name("pics/");
|
|
|
|
|
name += (type==Colored ? "chips.png" : "chips_mono.png");
|
|
|
|
@ -123,7 +123,7 @@ void TQReversiBoardView::loadChips(ChipType type)
|
|
|
|
|
// no animations are displayed.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::setAnimationSpeed(uint speed)
|
|
|
|
|
void QReversiBoardView::setAnimationSpeed(uint speed)
|
|
|
|
|
{
|
|
|
|
|
if (speed <= 10)
|
|
|
|
|
anim_speed = speed;
|
|
|
|
@ -133,7 +133,7 @@ void TQReversiBoardView::setAnimationSpeed(uint speed)
|
|
|
|
|
// Handle mouse clicks.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::mousePressEvent(TQMouseEvent *e)
|
|
|
|
|
void QReversiBoardView::mousePressEvent(TQMouseEvent *e)
|
|
|
|
|
{
|
|
|
|
|
// Only handle left button. No context menu.
|
|
|
|
|
if ( e->button() != Qt::LeftButton ) {
|
|
|
|
@ -155,7 +155,7 @@ void TQReversiBoardView::mousePressEvent(TQMouseEvent *e)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::showHint(Move move)
|
|
|
|
|
void QReversiBoardView::showHint(Move move)
|
|
|
|
|
{
|
|
|
|
|
// Only show a hint if there is a move to show.
|
|
|
|
|
if (move.x() == -1)
|
|
|
|
@ -201,26 +201,26 @@ void TQReversiBoardView::showHint(Move move)
|
|
|
|
|
// end, if it is running.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::quitHint()
|
|
|
|
|
void QReversiBoardView::quitHint()
|
|
|
|
|
{
|
|
|
|
|
m_hintShowing = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::setShowLegalMoves(bool show)
|
|
|
|
|
void QReversiBoardView::setShowLegalMoves(bool show)
|
|
|
|
|
{
|
|
|
|
|
m_legalMovesShowing = show;
|
|
|
|
|
updateBoard(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::setShowMarks(bool show)
|
|
|
|
|
void QReversiBoardView::setShowMarks(bool show)
|
|
|
|
|
{
|
|
|
|
|
m_marksShowing = show;
|
|
|
|
|
updateBoard(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::setShowLastMove(bool show)
|
|
|
|
|
void QReversiBoardView::setShowLastMove(bool show)
|
|
|
|
|
{
|
|
|
|
|
m_showLastMove = show;
|
|
|
|
|
updateBoard(true);
|
|
|
|
@ -236,7 +236,7 @@ void TQReversiBoardView::setShowLastMove(bool show)
|
|
|
|
|
// NOTE: This code is quite a hack. Should make it better.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::animateChanged(Move move)
|
|
|
|
|
void QReversiBoardView::animateChanged(Move move)
|
|
|
|
|
{
|
|
|
|
|
if (anim_speed == 0)
|
|
|
|
|
return;
|
|
|
|
@ -252,13 +252,13 @@ void TQReversiBoardView::animateChanged(Move move)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TQReversiBoardView::isField(int row, int col) const
|
|
|
|
|
bool QReversiBoardView::isField(int row, int col) const
|
|
|
|
|
{
|
|
|
|
|
return ((0 <= row) && (row < 8) && (0 <= col) && (col < 8));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::animateChangedRow(int row, int col, int dy, int dx)
|
|
|
|
|
void QReversiBoardView::animateChangedRow(int row, int col, int dy, int dx)
|
|
|
|
|
{
|
|
|
|
|
row = row + dy;
|
|
|
|
|
col = col + dx;
|
|
|
|
@ -275,7 +275,7 @@ void TQReversiBoardView::animateChangedRow(int row, int col, int dy, int dx)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::rotateChip(uint row, uint col)
|
|
|
|
|
void QReversiBoardView::rotateChip(uint row, uint col)
|
|
|
|
|
{
|
|
|
|
|
// Check which direction the chip has to be rotated. If the new
|
|
|
|
|
// chip is white, the chip was black first, so lets begin at index
|
|
|
|
@ -301,7 +301,7 @@ void TQReversiBoardView::rotateChip(uint row, uint col)
|
|
|
|
|
// m_krgame->squareModified(col, row)).
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::updateBoard (bool force)
|
|
|
|
|
void QReversiBoardView::updateBoard (bool force)
|
|
|
|
|
{
|
|
|
|
|
TQPainter p(this);
|
|
|
|
|
p.setPen(black);
|
|
|
|
@ -402,7 +402,7 @@ void TQReversiBoardView::updateBoard (bool force)
|
|
|
|
|
|
|
|
|
|
// Show legal moves on the board.
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::showLegalMoves()
|
|
|
|
|
void QReversiBoardView::showLegalMoves()
|
|
|
|
|
{
|
|
|
|
|
TQPainter p(this);
|
|
|
|
|
p.setPen(black);
|
|
|
|
@ -418,7 +418,7 @@ void TQReversiBoardView::showLegalMoves()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::drawSmallCircle(int x, int y, TQPainter &p)
|
|
|
|
|
void QReversiBoardView::drawSmallCircle(int x, int y, TQPainter &p)
|
|
|
|
|
{
|
|
|
|
|
int offset = m_marksShowing ? OFFSET() : 0;
|
|
|
|
|
int ellipseSize = zoomedSize() / 3;
|
|
|
|
@ -432,7 +432,7 @@ void TQReversiBoardView::drawSmallCircle(int x, int y, TQPainter &p)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TQPixmap TQReversiBoardView::chipPixmap(Color color, uint size) const
|
|
|
|
|
TQPixmap QReversiBoardView::chipPixmap(Color color, uint size) const
|
|
|
|
|
{
|
|
|
|
|
return chipPixmap(CHIP_OFFSET[color], size);
|
|
|
|
|
}
|
|
|
|
@ -441,7 +441,7 @@ TQPixmap TQReversiBoardView::chipPixmap(Color color, uint size) const
|
|
|
|
|
// Get a pixmap for the chip 'i' at size 'size'.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
TQPixmap TQReversiBoardView::chipPixmap(uint i, uint size) const
|
|
|
|
|
TQPixmap QReversiBoardView::chipPixmap(uint i, uint size) const
|
|
|
|
|
{
|
|
|
|
|
// Get the part of the 'allchips' pixmap that contains exactly that
|
|
|
|
|
// chip that we want to use.
|
|
|
|
@ -457,20 +457,20 @@ TQPixmap TQReversiBoardView::chipPixmap(uint i, uint size) const
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint TQReversiBoardView::zoomedSize() const
|
|
|
|
|
uint QReversiBoardView::zoomedSize() const
|
|
|
|
|
{
|
|
|
|
|
return tqRound(float(CHIP_SIZE) * Prefs::zoom() / 100);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::drawPiece(uint row, uint col, Color color)
|
|
|
|
|
void QReversiBoardView::drawPiece(uint row, uint col, Color color)
|
|
|
|
|
{
|
|
|
|
|
int i = (color == Nobody ? -1 : int(CHIP_OFFSET[color]));
|
|
|
|
|
drawOnePiece(row, col, i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::drawOnePiece(uint row, uint col, int i)
|
|
|
|
|
void QReversiBoardView::drawOnePiece(uint row, uint col, int i)
|
|
|
|
|
{
|
|
|
|
|
int px = col * zoomedSize() + 1;
|
|
|
|
|
int py = row * zoomedSize() + 1;
|
|
|
|
@ -502,13 +502,13 @@ void TQReversiBoardView::drawOnePiece(uint row, uint col, int i)
|
|
|
|
|
// entire board.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::paintEvent(TQPaintEvent *)
|
|
|
|
|
void QReversiBoardView::paintEvent(TQPaintEvent *)
|
|
|
|
|
{
|
|
|
|
|
updateBoard(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::adjustSize()
|
|
|
|
|
void QReversiBoardView::adjustSize()
|
|
|
|
|
{
|
|
|
|
|
int w = 8 * zoomedSize();
|
|
|
|
|
|
|
|
|
@ -519,7 +519,7 @@ void TQReversiBoardView::adjustSize()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::setPixmap(TQPixmap &pm)
|
|
|
|
|
void QReversiBoardView::setPixmap(TQPixmap &pm)
|
|
|
|
|
{
|
|
|
|
|
if ( pm.width() == 0 )
|
|
|
|
|
return;
|
|
|
|
@ -530,7 +530,7 @@ void TQReversiBoardView::setPixmap(TQPixmap &pm)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::setColor(const TQColor &c)
|
|
|
|
|
void QReversiBoardView::setColor(const TQColor &c)
|
|
|
|
|
{
|
|
|
|
|
bgColor = c;
|
|
|
|
|
bg = TQPixmap();
|
|
|
|
@ -542,7 +542,7 @@ void TQReversiBoardView::setColor(const TQColor &c)
|
|
|
|
|
// Load all settings that have to do with the board view, such as
|
|
|
|
|
// piece colors, background, animation speed, an so on.
|
|
|
|
|
|
|
|
|
|
void TQReversiBoardView::loadSettings()
|
|
|
|
|
void QReversiBoardView::loadSettings()
|
|
|
|
|
{
|
|
|
|
|
// Colors of the pieces (red/blue or black/white)
|
|
|
|
|
if ( Prefs::grayscale() ) {
|
|
|
|
|