From a4ae71d55dda2bbeb431f93f73ae5363e0723fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Teuli=C3=A8re?= Date: Sun, 4 Jan 2009 17:39:27 +0000 Subject: [PATCH] - TODO update - Allow displaying letter points on the board with an option (on by default) - Fixed the tab order on the preferences window - Improved the behaviour and default size of the preferences window --- TODO | 36 +++++----- qt/board_widget.cpp | 34 ++++++++-- qt/prefs_dialog.cpp | 16 +++-- qt/prefs_dialog.h | 1 + qt/ui/prefs_dialog.ui | 151 ++++++++++++++++++++---------------------- 5 files changed, 129 insertions(+), 109 deletions(-) diff --git a/TODO b/TODO index 07b5aff..8c790e0 100644 --- a/TODO +++ b/TODO @@ -1,33 +1,29 @@ +TODO +==== -* ================== -* Next Eliot version -* ================== - + - unit tests for the navigation handling, in each mode - Improve error handling (use exceptions more) - Correct game save/load functions: Advanced format file saving for freegames and duplicate need a serious rewrite. We need to specify a file format that can handle all the information contained in a multiplayer game. - - rack shuffling - - new wxWidgets or QT interface - - support of the different modes - - ability to choose the number and type of the players - - ability to display the history and score of all the players - -- partly done: history is now a separate class + - getopt support for all the interfaces (only ncurses is done)? - detection of blocked positions? - - getopt support for all the interfaces (only ncurses is done) + - distinguish misplaced and incorrect words? -* ============= -* Not so urgent -* ============= +Implementation details +====================== + + - game.h included in board.cpp! + - board.h included in coord.cpp! + - use Boost.Format? + - compile with -ansi -pedantic by default? + +Not so urgent +============= - - network support - add timers + - network support - implement the dictionary as a GADDAG: http://www.cs.ubc.ca/local/reading/proceedings/spe91-95/spe/vol24/issue2/spe880.pdf - -%%% Local Variables: -%%% mode: outline -%%% End: - diff --git a/qt/board_widget.cpp b/qt/board_widget.cpp index 5745e95..d07e5ec 100644 --- a/qt/board_widget.cpp +++ b/qt/board_widget.cpp @@ -21,8 +21,10 @@ #include #include #include +#include #include "board_widget.h" +#include "prefs_dialog.h" #include "qtcommon.h" #include "public_game.h" #include "tile.h" @@ -71,16 +73,22 @@ QSize BoardWidget::sizeHint() const return QSize(400, 400); } - void BoardWidget::paintEvent(QPaintEvent *) { - int size = std::min(width(), height()); - int squareSize = (int)floor((size - 1) / (BOARD_MAX - BOARD_MIN + 2)); + const int size = std::min(width(), height()); + const int squareSize = (int)floor((size - 1) / (BOARD_MAX - BOARD_MIN + 2)); // The font must grow with the square size - QFont f = font(); - f.setPixelSize(squareSize * 2 / 3); - setFont(f); + QFont letterFont = font(); + letterFont.setPixelSize(squareSize * 2 / 3); + + QFont pointsFont = font(); + const double pointsCoeff = 8. / 25.; + pointsFont.setPixelSize(squareSize * pointsCoeff); + + // Should we display the tiles points? + QSettings qs(ORGANIZATION, PACKAGE_NAME); + bool showPoints = qs.value(PrefsDialog::kINTF_SHOW_TILES_POINTS, true).toBool(); // XXX: Naive implementation: we repaint everything every time QPainter painter(this); @@ -117,18 +125,32 @@ void BoardWidget::paintEvent(QPaintEvent *) wchar_t chr = m_game->getBoard().getTile(row, col).toChar(); if (m_game->getBoard().getCharAttr(row, col) & ATTR_JOKER) painter.setPen(JokerColour); + painter.setFont(letterFont); painter.drawText((col - BOARD_MIN + 1) * squareSize, (row - BOARD_MIN + 1) * squareSize + 1, squareSize, squareSize, Qt::AlignCenter, qfw(wstring(1, chr))); painter.setPen(NormalColour); + + // Draw the points of the tile + if (showPoints && + !m_game->getBoard().getCharAttr(row, col) & ATTR_JOKER) + { + painter.setFont(pointsFont); + painter.drawText((col - BOARD_MIN + 1) * squareSize + squareSize * (1 - pointsCoeff), + (row - BOARD_MIN + 1) * squareSize + squareSize * (1 - pointsCoeff) + 1, + squareSize * pointsCoeff, squareSize * pointsCoeff + 3, + Qt::AlignRight | Qt::AlignBottom, + QString("%1").arg(m_game->getBoard().getTile(row, col).getPoints())); + } } } } // Draw the coordinates for (unsigned x = 1; x <= BOARD_MAX - BOARD_MIN + 1; ++x) { + painter.setFont(letterFont); painter.drawText(x * squareSize, 1, squareSize, squareSize, Qt::AlignCenter, diff --git a/qt/prefs_dialog.cpp b/qt/prefs_dialog.cpp index 1475121..546727a 100644 --- a/qt/prefs_dialog.cpp +++ b/qt/prefs_dialog.cpp @@ -31,6 +31,7 @@ const QString PrefsDialog::kINTF_ALIGN_HISTORY = "Interface/AlignHistory"; const QString PrefsDialog::kINTF_DIC_PATH = "Interface/DicPath"; +const QString PrefsDialog::kINTF_SHOW_TILES_POINTS = "Interface/ShowTilesPoints"; const QString PrefsDialog::kINTF_WARN_REPLAY_TURN = "Interface/WarnReplayTurn"; const QString PrefsDialog::kINTF_SHOW_TOOLBAR = "Interface/ShowToolBar"; const QString PrefsDialog::kINTF_LINK_TRAINING_7P1 = "Interface/LinkTrainingRackWith7P1"; @@ -47,6 +48,8 @@ PrefsDialog::PrefsDialog(QWidget *iParent) QSettings qs(ORGANIZATION, PACKAGE_NAME); lineEditIntfDicPath->setText(qs.value(kINTF_DIC_PATH, "").toString()); checkBoxIntfAlignHistory->setChecked(qs.value(kINTF_ALIGN_HISTORY).toBool()); + bool showPoints = qs.value(kINTF_SHOW_TILES_POINTS, true).toBool(); + checkBoxIntfShowPoints->setChecked(showPoints); bool warnReplayTurn = qs.value(kINTF_WARN_REPLAY_TURN, true).toBool(); checkBoxIntfWarnReplayTurn->setChecked(warnReplayTurn); bool linkTraining7P1 = qs.value(kINTF_LINK_TRAINING_7P1, false).toBool(); @@ -68,9 +71,6 @@ PrefsDialog::PrefsDialog(QWidget *iParent) QMessageBox::warning(this, _q("%1 error").arg(PACKAGE_NAME), _q("Cannot load preferences: %1").arg(e.what())); } - - // Resize the dialog so that it gets its minimal size - resize(10, 10); } @@ -99,14 +99,20 @@ void PrefsDialog::updateSettings() // Interface settings QSettings qs(ORGANIZATION, PACKAGE_NAME); qs.setValue(kINTF_DIC_PATH, lineEditIntfDicPath->text()); - if (qs.value(kINTF_ALIGN_HISTORY).toBool() != checkBoxIntfAlignHistory->isChecked()) + if (qs.value(kINTF_ALIGN_HISTORY, true).toBool() != checkBoxIntfAlignHistory->isChecked()) { // We need to redraw the history widget shouldEmitUpdate = true; qs.setValue(kINTF_ALIGN_HISTORY, checkBoxIntfAlignHistory->isChecked()); } + if (qs.value(kINTF_SHOW_TILES_POINTS, true).toBool() != checkBoxIntfShowPoints->isChecked()) + { + // We need to redraw the board + shouldEmitUpdate = true; + qs.setValue(kINTF_SHOW_TILES_POINTS, checkBoxIntfShowPoints->isChecked()); + } qs.setValue(kINTF_WARN_REPLAY_TURN, checkBoxIntfWarnReplayTurn->isChecked()); - if (qs.value(kINTF_LINK_TRAINING_7P1).toBool() != checkBoxIntfLinkTraining7P1->isChecked()) + if (qs.value(kINTF_LINK_TRAINING_7P1, false).toBool() != checkBoxIntfLinkTraining7P1->isChecked()) { // We need to (dis)connect the training widget with the dictionary // tools window diff --git a/qt/prefs_dialog.h b/qt/prefs_dialog.h index 4a80623..ac58423 100644 --- a/qt/prefs_dialog.h +++ b/qt/prefs_dialog.h @@ -36,6 +36,7 @@ public: static const QString kINTF_ALIGN_HISTORY; static const QString kINTF_DIC_PATH; + static const QString kINTF_SHOW_TILES_POINTS; static const QString kINTF_WARN_REPLAY_TURN; static const QString kINTF_SHOW_TOOLBAR; static const QString kINTF_LINK_TRAINING_7P1; diff --git a/qt/ui/prefs_dialog.ui b/qt/ui/prefs_dialog.ui index ac14d8f..707714f 100644 --- a/qt/ui/prefs_dialog.ui +++ b/qt/ui/prefs_dialog.ui @@ -1,14 +1,6 @@ PrefsDialog - - - 0 - 0 - 508 - 442 - - _("Preferences") @@ -18,7 +10,7 @@ _("Interface") - + @@ -32,7 +24,7 @@ - 130 + 140 0 @@ -53,6 +45,19 @@ + + + + _("Show/hide the tiles points on the board.") + + + _("Display tiles points") + + + true + + + @@ -87,8 +92,8 @@ _("Duplicate mode") - - + + _("If checked, playing an invalid or misplaced word will not be possible. If unchecked, you will get 0 point and lose your turn") @@ -98,75 +103,60 @@ - - - - - - _("Min. players for a solo:") - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - _("Minimum number of players needed to take into account the solo bonus") - - - 16 - - - - + + + + _("Min. players for a solo:") + + - - - - - - _("Solo value:") - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - _("Value of the solo bonus. Set it to 0 if you don't want solo bonus") - - - 10 - - - - + + + + _("Solo value:") + + + + + + + _("Value of the solo bonus. Set it to 0 if you don't want solo bonus") + + + 10 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + _("Minimum number of players needed to take into account the solo bonus") + + + 16 + + + checkBoxDuplRefuseInvalid + label_2 + label_3 + spinBoxDuplSoloValue + horizontalSpacer + spinBoxDuplSoloPlayers @@ -220,11 +210,16 @@ + lineEditIntfDicPath + pushButtonIntfDicBrowse + checkBoxIntfShowPoints checkBoxIntfAlignHistory + checkBoxIntfWarnReplayTurn checkBoxDuplRefuseInvalid spinBoxDuplSoloPlayers spinBoxDuplSoloValue checkBoxFreeRefuseInvalid + checkBoxIntfLinkTraining7P1 buttonBox