<context>
<name>Field</name>
<message>
- <location filename="field.cpp" line="262"/>
+ <location filename="field.cpp" line="273"/>
<source>You won!</source>
<extracomment>win message</extracomment>
<translation type="unfinished">Вы выиграли!</translation>
</message>
<message>
- <location filename="field.cpp" line="268"/>
+ <location filename="field.cpp" line="279"/>
<source>You lost!</source>
<extracomment>fail message</extracomment>
<translation type="unfinished">Вы проиграли!</translation>
<name>QObject</name>
<message>
<location filename="colorscheme.cpp" line="33"/>
- <source>Default</source>
+ <source>Default scheme</source>
+ <oldsource>Default</oldsource>
<extracomment>default color scheme name</extracomment>
- <translation type="unfinished">Стандартная</translation>
+ <translation type="unfinished">Стандартная схема</translation>
</message>
<message>
<location filename="colorscheme.cpp" line="43"/>
- <source>Black-and-white</source>
+ <source>Black-and-white scheme</source>
+ <oldsource>Black-and-white</oldsource>
<extracomment>black-and-white color scheme name</extracomment>
- <translation type="unfinished">Чёрно-белая</translation>
+ <translation type="unfinished">Чёрно-белая схема</translation>
</message>
</context>
<context>
<name>Window</name>
<message>
- <location filename="window.cpp" line="49"/>
+ <location filename="window.cpp" line="51"/>
<source>New game</source>
<translation type="unfinished">Новая игра</translation>
</message>
<message>
- <location filename="window.cpp" line="86"/>
- <source><font size="16">Turns: %1/%2</font></source>
+ <location filename="window.cpp" line="72"/>
+ <source>Fullscreen mode</source>
+ <translation type="unfinished">Полноэкранный режим</translation>
+ </message>
+ <message>
+ <location filename="window.cpp" line="84"/>
+ <source>Less cells</source>
+ <translation type="unfinished">Меньше клеток</translation>
+ </message>
+ <message>
+ <location filename="window.cpp" line="96"/>
+ <source>More cells</source>
+ <translation type="unfinished">Больше клеток</translation>
+ </message>
+ <message>
+ <location filename="window.cpp" line="110"/>
+ <source><font size="12">Turns: %1/%2</font></source>
+ <oldsource><font size="16">Turns: %1/%2</font></oldsource>
<extracomment>number of turns</extracomment>
- <translation type="unfinished"><font size="16">Шагов: %1/%2</font></translation>
+ <translation type="unfinished"><font size="12">Шагов: %1/%2</font></translation>
</message>
</context>
</TS>
s << QColor(0xf0, 0x70, 0xa0);
s << QColor(0xdc, 0x4a, 0x20);
/*: default color scheme name */
- schemes << QPair<QString, QVector<QBrush> >(QObject::tr("Default"), s);
+ schemes << QPair<QString, QVector<QBrush> >(QObject::tr("Default scheme"), s);
s.clear();
s << QBrush(QColor(0x00, 0x00, 0x00), Qt::SolidPattern);
- s << QBrush(QColor(0x33, 0x33, 0x33), Qt::Dense3Pattern);
+ s << QBrush(QColor(0x20, 0x20, 0x20), Qt::Dense3Pattern);
s << QBrush(QColor(0x66, 0x66, 0x66), Qt::Dense1Pattern);
s << QBrush(QColor(0x99, 0x99, 0x99), Qt::SolidPattern);
s << QBrush(QColor(0xcc, 0xcc, 0xcc), Qt::CrossPattern);
s << QBrush(QColor(0xff, 0xff, 0xff), Qt::SolidPattern);
/*: black-and-white color scheme name */
- schemes << QPair<QString, QVector<QBrush> >(QObject::tr("Black-and-white"), s);
+ schemes << QPair<QString, QVector<QBrush> >(QObject::tr("Black-and-white scheme"), s);
QSettings settings;
currentScheme = settings.value("colorScheme", 0).toInt();
return schemes.size();
}
+int ColorScheme::getNextColorScheme ()
+{
+ return (currentScheme + 1) % schemes.size();
+}
+
QString ColorScheme::getSchemeName (int scheme)
{
- Q_ASSERT(scheme > 0 && scheme < getNumSchemes());
+ Q_ASSERT(scheme >= 0 && scheme < getNumSchemes());
return schemes.at(scheme).first;
}
}
static int getNumSchemes ();
+ static int getNextColorScheme ();
static QString getSchemeName (int scheme);
const QVector<QBrush> &getScheme (int scheme);
static QString getSchemeName ();
return size;
}
+void Field::setSize (int size)
+{
+ Q_ASSERT(size >= 0 && size < NUM_SIZES);
+
+ if (this->size == size)
+ return;
+
+ this->size = (FieldSize)size;
+ randomize();
+}
+
void Field::randomize ()
{
FieldRect rect;
~Field ();
FieldSize getSize () const;
+ void setSize (int size);
static int getNumRectsOfSize (FieldSize size);
static int getNumTurnsOfSize (FieldSize size);
#include <QHBoxLayout>
#include <QLabel>
#include <QSettings>
+#include <QMenuBar>
#include "window.hpp"
#include "colorbuttons.hpp"
#include "field.hpp"
#include "fullscreenexitbutton.hpp"
+#include "colorscheme.hpp"
Window::Window ()
: QWidget()
setLayout(hl);
- QSettings settings;
+ /* menu bar */
+ QMenuBar *bar = new QMenuBar(this);
- if (settings.value("fullscreen", true).toBool())
- showFullScreen();
+ QObject::connect(bar->addAction(tr("Fullscreen mode")),
+ SIGNAL(triggered()),
+ this,
+ SLOT(fullScreenMode()));
- new FullScreenExitButton(this);
-}
+ QObject::connect(bar->addAction(
+ ColorScheme::getSchemeName(
+ ColorScheme::getNextColorScheme())),
+ SIGNAL(triggered()),
+ this,
+ SLOT(colorScheme()));
-Window::~Window ()
-{
- bool isFullscreen = windowState() & Qt::WindowFullScreen;
+ less = bar->addAction(tr("Less cells"));
+
+ QObject::connect(less,
+ SIGNAL(triggered()),
+ this,
+ SLOT(lessCells()));
+
+ more = bar->addAction(tr("More cells"));
- QSettings settings;
- settings.setValue("fullscreen", isFullscreen);
+ QObject::connect(more,
+ SIGNAL(triggered()),
+ this,
+ SLOT(moreCells()));
+
+ if (!field->getSize())
+ less->setEnabled(false);
+ else if (field->getSize() == Field::NUM_SIZES - 1)
+ more->setEnabled(false);
+
+ new FullScreenExitButton(this);
+ showFullScreen();
}
void Window::updateTurns (int turns)
{
/*: number of turns */
- turnsLabel->setText(tr("<font size=\"16\">Turns: %1/%2</font>")
+ turnsLabel->setText(tr("<font size=\"12\">Turns: %1/%2</font>")
.arg(turns)
.arg(field->getNumTurnsOfSize(field->getSize())));
}
+
+void Window::fullScreenMode ()
+{
+ showFullScreen();
+}
+
+void Window::lessCells ()
+{
+ int s = field->getSize() - 1;
+
+ field->setSize(s);
+ more->setEnabled(true);
+
+ if (!s)
+ less->setEnabled(false);
+}
+
+void Window::moreCells ()
+{
+ int s = field->getSize() + 1;
+
+ field->setSize(s);
+ less->setEnabled(true);
+
+ if (s == Field::NUM_SIZES - 1)
+ more->setEnabled(false);
+}
+
+void Window::colorScheme ()
+{
+ QAction *action = static_cast<typeof(action)>(QObject::sender());
+
+ ColorScheme::setScheme(ColorScheme::getNextColorScheme());
+
+ field->update();
+ colorButtons->update();
+
+ action->setText(ColorScheme::getSchemeName(
+ ColorScheme::getNextColorScheme()));
+}
class ColorButtons;
class Field;
class QLabel;
+class QAction;
class Window : public QWidget
{
public:
Window ();
- ~Window ();
private slots:
void updateTurns (int turns);
+ void fullScreenMode ();
+ void colorScheme ();
+ void lessCells ();
+ void moreCells ();
private:
ColorButtons *colorButtons;
Field *field;
QLabel *turnsLabel;
+ QAction *less;
+ QAction *more;
};
#endif // !_WINDOW_HPP