- 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
This commit is contained in:
Olivier Teulière 2009-01-04 17:39:27 +00:00
parent 6a2eca1db1
commit a4ae71d55d
5 changed files with 129 additions and 109 deletions

36
TODO
View file

@ -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:

View file

@ -21,8 +21,10 @@
#include <math.h>
#include <QtGui/QPainter>
#include <QtGui/QPaintEvent>
#include <QtCore/QSettings>
#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,

View file

@ -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

View file

@ -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;

View file

@ -1,14 +1,6 @@
<ui version="4.0" >
<class>PrefsDialog</class>
<widget class="QDialog" name="PrefsDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>508</width>
<height>442</height>
</rect>
</property>
<property name="windowTitle" >
<string>_("Preferences")</string>
</property>
@ -18,7 +10,7 @@
<property name="title" >
<string>_("Interface")</string>
</property>
<layout class="QVBoxLayout" >
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<layout class="QHBoxLayout" >
<item>
@ -32,7 +24,7 @@
<widget class="QLineEdit" name="lineEditIntfDicPath" >
<property name="minimumSize" >
<size>
<width>130</width>
<width>140</width>
<height>0</height>
</size>
</property>
@ -53,6 +45,19 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxIntfShowPoints" >
<property name="toolTip" >
<string>_("Show/hide the tiles points on the board.")</string>
</property>
<property name="text" >
<string>_("Display tiles points")</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxIntfAlignHistory" >
<property name="toolTip" >
@ -87,8 +92,8 @@
<property name="title" >
<string>_("Duplicate mode")</string>
</property>
<layout class="QVBoxLayout" >
<item>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" colspan="2" >
<widget class="QCheckBox" name="checkBoxDuplRefuseInvalid" >
<property name="toolTip" >
<string>_("If checked, playing an invalid or misplaced word will not be possible. If unchecked, you will get 0 point and lose your turn")</string>
@ -98,75 +103,60 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>_("Min. players for a solo:")</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="spinBoxDuplSoloPlayers" >
<property name="toolTip" >
<string>_("Minimum number of players needed to take into account the solo bonus")</string>
</property>
<property name="value" >
<number>16</number>
</property>
</widget>
</item>
</layout>
<item row="2" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>_("Min. players for a solo:")</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>_("Solo value:")</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="spinBoxDuplSoloValue" >
<property name="toolTip" >
<string>_("Value of the solo bonus. Set it to 0 if you don't want solo bonus")</string>
</property>
<property name="value" >
<number>10</number>
</property>
</widget>
</item>
</layout>
<item row="3" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>_("Solo value:")</string>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QSpinBox" name="spinBoxDuplSoloValue" >
<property name="toolTip" >
<string>_("Value of the solo bonus. Set it to 0 if you don't want solo bonus")</string>
</property>
<property name="value" >
<number>10</number>
</property>
</widget>
</item>
<item row="2" column="2" >
<spacer name="horizontalSpacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1" >
<widget class="QSpinBox" name="spinBoxDuplSoloPlayers" >
<property name="toolTip" >
<string>_("Minimum number of players needed to take into account the solo bonus")</string>
</property>
<property name="value" >
<number>16</number>
</property>
</widget>
</item>
</layout>
<zorder>checkBoxDuplRefuseInvalid</zorder>
<zorder>label_2</zorder>
<zorder>label_3</zorder>
<zorder>spinBoxDuplSoloValue</zorder>
<zorder>horizontalSpacer</zorder>
<zorder>spinBoxDuplSoloPlayers</zorder>
</widget>
</item>
<item>
@ -220,11 +210,16 @@
</layout>
</widget>
<tabstops>
<tabstop>lineEditIntfDicPath</tabstop>
<tabstop>pushButtonIntfDicBrowse</tabstop>
<tabstop>checkBoxIntfShowPoints</tabstop>
<tabstop>checkBoxIntfAlignHistory</tabstop>
<tabstop>checkBoxIntfWarnReplayTurn</tabstop>
<tabstop>checkBoxDuplRefuseInvalid</tabstop>
<tabstop>spinBoxDuplSoloPlayers</tabstop>
<tabstop>spinBoxDuplSoloValue</tabstop>
<tabstop>checkBoxFreeRefuseInvalid</tabstop>
<tabstop>checkBoxIntfLinkTraining7P1</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>