summaryrefslogtreecommitdiff
path: root/sudoku.cpp
diff options
context:
space:
mode:
authorThomas Günther <tom@toms-cafe.de>2005-10-28 03:00:00 +0200
committerThomas Günther <tom@toms-cafe.de>2005-10-28 03:00:00 +0200
commita0863e7f249e0a4eae8f71f8946cb90071fba985 (patch)
treedb2138d8e12e3138d7305bc0c6e5679fdd3163af /sudoku.cpp
downloadvdr-plugin-sudoku-0.1.0.tar.gz
vdr-plugin-sudoku-0.1.0.tar.bz2
Initial versionv0.1.0
Diffstat (limited to 'sudoku.cpp')
-rw-r--r--sudoku.cpp114
1 files changed, 114 insertions, 0 deletions
diff --git a/sudoku.cpp b/sudoku.cpp
new file mode 100644
index 0000000..1c9ab86
--- /dev/null
+++ b/sudoku.cpp
@@ -0,0 +1,114 @@
+/*
+ * Sudoku: A plugin for the Video Disk Recorder
+ *
+ * See the README file for copyright information and how to reach the author.
+ *
+ * $Id: sudoku.cpp 11 2005-10-28 01:00:01Z tom $
+ */
+
+#include "sudoku.h"
+#include "puzzle.h"
+#include "menu.h"
+#include "setup.h"
+#include "i18n.h"
+#include <vdr/plugin.h>
+
+
+/** 'Sudoku' is a VDR plugin to generate and solve Number Place puzzles. */
+namespace SudokuPlugin
+{
+
+ /** Version number of the plugin */
+ static const char* VERSION = "0.1.0";
+
+ /** Short description of the plugin's purpose */
+ static const char* DESCRIPTION =
+ "Sudoku - generate and solve Number Place puzzles";
+
+ /** Name of the entry in VDR's main menu */
+ static const char* MAINMENUENTRY = "Sudoku";
+
+
+ //--- class SudokuPlugin::Plugin ---------------------------------------------
+
+ /** Main class of the VDR plugin 'Sudoku' */
+ class Plugin : public cPlugin
+ {
+ SetupData setup;
+ Sudoku::Puzzle puzzle;
+ Sudoku::Pos curr;
+
+ public:
+
+ /** Version number of the plugin */
+ virtual const char* Version() { return VERSION; }
+
+ /** Localized short description of the plugin's purpose */
+ virtual const char* Description() { return tr(DESCRIPTION); }
+
+ /** Perform the startup actions of the plugin. */
+ virtual bool Start();
+
+ /** Localized name of the entry in VDR's main menu */
+ virtual const char* MainMenuEntry() { return tr(MAINMENUENTRY); }
+
+ /** OSD object that shows the plugin's main menu */
+ virtual cOsdObject* MainMenuAction();
+
+ /** Setup menu page to adjust the parameters of the plugin */
+ virtual cMenuSetupPage* SetupMenu();
+
+ /** Parse the parameters of the plugin. */
+ virtual bool SetupParse(const char* name, const char* value);
+ };
+
+} // namespace SudokuPlugin
+
+
+using namespace SudokuPlugin;
+
+
+//--- class SudokuPlugin::Plugin -----------------------------------------------
+
+/** Perform the startup actions of the plugin.
+ *
+ * This method is called once at VDR's startup.
+ */
+bool Plugin::Start()
+{
+ RegisterI18n(Phrases);
+ puzzle.generate(setup.givens_count, setup.symmetric);
+ curr = curr.center();
+ return true;
+}
+
+/** OSD object that shows the plugin's main menu
+ *
+ * This method is called every time the plugin's main menu entry is selected.
+ */
+cOsdObject* Plugin::MainMenuAction()
+{
+ return new Menu(setup, puzzle, curr);
+}
+
+/** Setup menu page to adjust the parameters of the plugin
+ *
+ * This method is called every time the plugin's setup menu entry is selected.
+ */
+cMenuSetupPage* Plugin::SetupMenu()
+{
+ return new SetupPage(setup);
+}
+
+/** Parse the parameters of the plugin.
+ *
+ * This method is called for each parameter the plugin has previously
+ * stored in the global setup data.
+ */
+bool Plugin::SetupParse(const char* name, const char* value)
+{
+ return setup.parse(name, value);
+}
+
+/** "Magic" hook that allows VDR to load the plugin into its memory */
+VDRPLUGINCREATOR(Plugin); // Don't touch this!