summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Günther <tom@toms-cafe.de>2008-01-06 20:43:20 +0100
committerThomas Günther <tom@toms-cafe.de>2008-01-06 20:43:20 +0100
commitad7c2eccc34abc3208d4a00d425945d509d0a2d1 (patch)
treeccbe2305c2cdfe7a7c1d0c25a9699702237d76b0
parent3dc1e9efaee46e8de32b935d65f1df9d9d246491 (diff)
downloadvdr-plugin-sudoku-ad7c2eccc34abc3208d4a00d425945d509d0a2d1.tar.gz
vdr-plugin-sudoku-ad7c2eccc34abc3208d4a00d425945d509d0a2d1.tar.bz2
Show possible numbers as pattern
-rw-r--r--HISTORY1
-rw-r--r--README8
-rw-r--r--menu.cpp20
-rw-r--r--puzzle.cpp10
-rw-r--r--puzzle.h5
-rw-r--r--setup.cpp8
-rw-r--r--setup.h3
7 files changed, 50 insertions, 5 deletions
diff --git a/HISTORY b/HISTORY
index 5326ae1..787c1d3 100644
--- a/HISTORY
+++ b/HISTORY
@@ -30,3 +30,4 @@ ____-__-__: Version _._._
- Updated FSF address in the license information.
- Improved copyright and license information in the header of all source files.
- Fixed (un)marking the cell on the bottom right.
+- Show possible numbers as pattern.
diff --git a/README b/README
index 694f914..a6f066a 100644
--- a/README
+++ b/README
@@ -71,6 +71,14 @@ Setup:
- Mark ambiguous numbers Cells with ambiguous numbers are marked with magenta
color (yes/no).
Default is yes.
+- Show possible numbers as pattern
+ Show a pattern in all empty cells representing the
+ possible numbers. The pattern is structured by a small
+ 3 x 3 grid featuring the numbers from 1 to 9 from top
+ left to bottom right. If a number is possible in this
+ cell the background of the corresponding grid section
+ is colored.
+ Default is yes.
- Clear marks on reset Unmark all cells when the puzzle is reset (yes/no).
Default is no.
- Transparency (%) Set the transparency of the menu (0-100).
diff --git a/menu.cpp b/menu.cpp
index 6fbe293..848b40c 100644
--- a/menu.cpp
+++ b/menu.cpp
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: menu.cpp 106 2007-12-03 23:28:24Z tom $
+ * $Id: menu.cpp 109 2008-01-06 19:43:20Z tom $
*/
#include "menu.h"
@@ -53,6 +53,8 @@ using namespace Sudoku;
#define MARKED_BG clrGreen
#define GIVEN_FG clrBlack
#define GIVEN_BG clrCyan
+#define POSSIBLE_FG clrBlack
+#define POSSIBLE_BG(n) (((n) % 2) ? clrYellow : 0xFF8C00 /* darkorange */)
//--- class SudokuPlugin::Menu -------------------------------------------------
@@ -210,6 +212,22 @@ void Menu::paint()
const cFont* font = cFont::GetFont(fontFix);
osd->DrawText(x1, y1, txt, fg, bg, font, CELL_SIZE, CELL_SIZE, taCenter);
}
+ else if (setup.show_possibles_pattern)
+ {
+ for (unsigned int n = 1; n <= DIM; ++n)
+ {
+ if (puzzle.possible_number(p, n))
+ {
+ int x3 = x1 + (((n - 1) % RDIM) * CELL_SIZE) / RDIM;
+ int y3 = y1 + (((n - 1) / RDIM) * CELL_SIZE) / RDIM;
+ int x4 = x1 + (((n - 1) % RDIM + 1) * CELL_SIZE) / RDIM - 1;
+ int y4 = y1 + (((n - 1) / RDIM + 1) * CELL_SIZE) / RDIM - 1;
+ fg = TRANS(POSSIBLE_FG, trans);
+ bg = TRANS(POSSIBLE_BG(n), trans);
+ osd->DrawRectangle(x3, y3, x4, y4, bg);
+ }
+ }
+ }
}
// Paint the cursor.
diff --git a/puzzle.cpp b/puzzle.cpp
index 461549b..947e7ba 100644
--- a/puzzle.cpp
+++ b/puzzle.cpp
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: puzzle.cpp 108 2008-01-06 16:01:26Z tom $
+ * $Id: puzzle.cpp 109 2008-01-06 19:43:20Z tom $
*/
#include "puzzle.h"
@@ -247,6 +247,14 @@ unsigned int Puzzle::numbers_count(Pos pos)
return count[pos];
}
+/** Is this number in this cell a possible number? */
+bool Puzzle::possible_number(Pos pos, unsigned int number)
+{
+ assert(pos <= Pos::last());
+ assert(0 <= number && number <= DIM);
+ return numbers[pos][number];
+}
+
/** Compute all possible numbers for this cell. */
void Puzzle::compute_numbers(Pos pos)
{
diff --git a/puzzle.h b/puzzle.h
index 0b5713d..e9d4f13 100644
--- a/puzzle.h
+++ b/puzzle.h
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: puzzle.h 106 2007-12-03 23:28:24Z tom $
+ * $Id: puzzle.h 109 2008-01-06 19:43:20Z tom $
*/
#ifndef VDR_SUDOKU_PUZZLE_H
@@ -166,6 +166,9 @@ namespace Sudoku
/** Get the count of possible numbers for this cell. */
unsigned int numbers_count(Pos pos);
+ /** Is this number in this cell a possible number? */
+ bool possible_number(Pos pos, unsigned int number);
+
private:
/** Compute all possible numbers for this cell. */
diff --git a/setup.cpp b/setup.cpp
index 6c86fb8..190404e 100644
--- a/setup.cpp
+++ b/setup.cpp
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: setup.cpp 106 2007-12-03 23:28:24Z tom $
+ * $Id: setup.cpp 109 2008-01-06 19:43:20Z tom $
*/
#include "setup.h"
@@ -39,6 +39,7 @@ SetupData::SetupData()
symmetric = 1;
mark_errors = 1;
mark_ambiguous = 1;
+ show_possibles_pattern = 1;
clear_marks = 0;
transparency = 50;
}
@@ -58,6 +59,8 @@ bool SetupData::parse(const char* name, const char* value)
mark_errors = atoi(value);
else if (!strcasecmp(name, "MarkAmbiguous"))
mark_ambiguous = atoi(value);
+ else if (!strcasecmp(name, "ShowPossiblesPattern"))
+ show_possibles_pattern = atoi(value);
else if (!strcasecmp(name, "ClearMarks"))
clear_marks = atoi(value);
else if (!strcasecmp(name, "Transparency"))
@@ -79,6 +82,8 @@ SetupPage::SetupPage(SetupData& setup) :
Add(new cMenuEditBoolItem(tr("Mark errors"), &data.mark_errors));
Add(new cMenuEditBoolItem(tr("Mark ambiguous numbers"),
&data.mark_ambiguous));
+ Add(new cMenuEditBoolItem(tr("Show possible numbers as pattern"),
+ &data.show_possibles_pattern));
Add(new cMenuEditBoolItem(tr("Clear marks on reset"), &data.clear_marks));
Add(new cMenuEditIntItem(tr("Transparency (%)"), &data.transparency, 0, 100));
}
@@ -95,6 +100,7 @@ void SetupPage::Store()
SetupStore("Symmetric", setup.symmetric);
SetupStore("MarkErrors", setup.mark_errors);
SetupStore("MarkAmbiguous", setup.mark_ambiguous);
+ SetupStore("ShowPossiblesPattern", setup.show_possibles_pattern);
SetupStore("ClearMarks", setup.clear_marks);
SetupStore("Transparency", setup.transparency);
}
diff --git a/setup.h b/setup.h
index 09f3e7d..3ad6d59 100644
--- a/setup.h
+++ b/setup.h
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: setup.h 106 2007-12-03 23:28:24Z tom $
+ * $Id: setup.h 109 2008-01-06 19:43:20Z tom $
*/
#ifndef VDR_SUDOKU_SETUP_H
@@ -40,6 +40,7 @@ namespace SudokuPlugin
int symmetric;
int mark_errors;
int mark_ambiguous;
+ int show_possibles_pattern;
int clear_marks;
int transparency;