Commit c8988ed3 authored by Frederik Schwarzer's avatar Frederik Schwarzer
Browse files

make the "game unsolvable" message optional

BUG: 393721
parent 6223be7d
......@@ -60,6 +60,7 @@ Board::Board(QWidget * parent)
, m_cheat(false)
, m_gravityFlag(true)
, m_solvableFlag(false)
, m_showUnsolvableMessageFlag(false)
, m_chineseStyleFlag(false)
, m_tilesCanSlideFlag(false)
, m_highlightedTile(-1)
......@@ -114,6 +115,7 @@ void Board::loadSettings()
// Need to load solvable before size because setSize calls newGame which
// uses the solvable flag. Same with shuffle.
setSolvableFlag(Prefs::solvable());
setShowUnsolvableMessageFlag(Prefs::showUnsolvableMessage());
m_shuffle = Prefs::level() * 4 + 1;
setSize(s_sizeX.at(Prefs::size()), s_sizeY.at(Prefs::size()));
setGravityFlag(Prefs::gravity());
......@@ -1346,7 +1348,9 @@ void Board::undrawConnection()
PossibleMoves dummyPossibleMoves;
// game is over?
if (!pathFoundBetweenMatchingTiles(dummyPossibleMoves)) {
if ((!pathFoundBetweenMatchingTiles(dummyPossibleMoves)
&& m_showUnsolvableMessageFlag)
|| (tilesLeft() == 0)) {
m_gameClock.pause();
Q_EMIT endOfGame();
}
......@@ -1796,6 +1800,19 @@ void Board::setSolvableFlag(bool enabled)
}
}
bool Board::showUnsolvableMessageFlag() const
{
return m_showUnsolvableMessageFlag;
}
void Board::setShowUnsolvableMessageFlag(bool enabled)
{
if (m_showUnsolvableMessageFlag == enabled) {
return;
}
m_showUnsolvableMessageFlag = enabled;
}
bool Board::gravityFlag() const
{
return m_gravityFlag;
......
......@@ -95,6 +95,8 @@ public:
bool solvableFlag() const;
void setSolvableFlag(bool enabled);
bool showUnsolvableMessageFlag() const;
void setShowUnsolvableMessageFlag(bool enabled);
bool gravityFlag() const;
void setGravityFlag(bool enabled);
void setChineseStyleFlag(bool enabled);
......@@ -317,6 +319,7 @@ private:
bool m_gravityFlag; ///< Whether game is played with gravity
bool m_solvableFlag; ///< Whether game is solvable
bool m_showUnsolvableMessageFlag; ///< Whether "game unsolvable" message is shown
bool m_chineseStyleFlag; ///< Whether game follows Chinese rules
bool m_tilesCanSlideFlag; ///< Whether tiles can slide when connecting
......
......@@ -22,6 +22,9 @@
<entry name="Solvable" type="Bool">
<default>false</default>
</entry>
<entry name="ShowUnsolvableMessage" type="Bool">
<default>true</default>
</entry>
<entry name="Gravity" type="Bool">
<default>true</default>
</entry>
......
......@@ -37,6 +37,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_ShowUnsolvableMessage">
<property name="whatsThis">
<string>&lt;b&gt;Show message if board can no longer be solved&lt;/b&gt;&lt;p&gt;Checking this makes the game show a message to abort the game in case there are no possible moves left to win the game.&lt;/p&gt;</string>
</property>
<property name="text">
<string>Show message if board can no longer be solved</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_ChineseStyle">
<property name="whatsThis">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment