summaryrefslogtreecommitdiff
path: root/menu.cpp
diff options
context:
space:
mode:
authorThomas Günther <tom@toms-cafe.de>2008-03-16 23:20:33 +0100
committerThomas Günther <tom@toms-cafe.de>2008-03-16 23:20:33 +0100
commit1a2247ccdfaba348b80fb2482c27e71b7cb17b92 (patch)
tree524beb5da87e819aa20d06ac4f650a579160b667 /menu.cpp
parent7aaa70fa39a1e9968ff08ffab4462231e80fbb67 (diff)
downloadvdr-plugin-sudoku-1a2247ccdfaba348b80fb2482c27e71b7cb17b92.tar.gz
vdr-plugin-sudoku-1a2247ccdfaba348b80fb2482c27e71b7cb17b92.tar.bz2
Added commands to load and save puzzles from/to the sudoku-list file
Diffstat (limited to 'menu.cpp')
-rw-r--r--menu.cpp50
1 files changed, 47 insertions, 3 deletions
diff --git a/menu.cpp b/menu.cpp
index 1400dc1..a65b9cc 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 113 2008-03-16 20:12:52Z tom $
+ * $Id: menu.cpp 114 2008-03-16 22:20:33Z tom $
*/
#include "menu.h"
@@ -25,6 +25,7 @@
#include "setup.h"
#include "bitmap.h"
#include "commands.h"
+#include "list.h"
#include "i18n.h"
#include <vdr/config.h>
#include <vdr/osdbase.h>
@@ -35,6 +36,9 @@ using namespace SudokuPlugin;
using namespace Sudoku;
+// Definition of the file name of the sudoku list
+#define SUDOKU_LIST "sudoku-list"
+
// Definitions for grid structure
#define CELL_SIZE 42
#define CELL_POS(i) ((i) * (CELL_SIZE + 2) + (i)/RDIM * 3 + 5)
@@ -61,8 +65,8 @@ using namespace Sudoku;
//--- class SudokuPlugin::Menu -------------------------------------------------
/** Constructor */
-Menu::Menu(const SetupData& setup, Puzzle& puzzle, Pos& curr) :
- cOsdObject(true), setup(setup), puzzle(puzzle), curr(curr)
+Menu::Menu(const SetupData& setup, const char* confdir, Puzzle& puzzle, Pos& curr) :
+ cOsdObject(true), setup(setup), confdir(confdir), puzzle(puzzle), curr(curr)
{
xPos = (720 - GRID_SIZE) / 2;
yPos = (576 - GRID_SIZE) / 2;
@@ -79,11 +83,13 @@ Menu::Menu(const SetupData& setup, Puzzle& puzzle, Pos& curr) :
mini_font = NULL;
#endif
command_menu = NULL;
+ list_menu = NULL;
}
/** Destructor */
Menu::~Menu()
{
+ delete list_menu;
delete command_menu;
#if VDRVERSNUM >= 10504
delete maxi_font;
@@ -127,6 +133,21 @@ eOSState Menu::ProcessKey(eKeys key)
return state;
}
+ if (list_menu)
+ {
+ eOSState state = list_menu->ProcessKey(key);
+ if (state == osBack)
+ {
+ state = osContinue;
+ const char* sudoku = list_menu->get_selected_sudoku();
+ if (sudoku)
+ puzzle = Puzzle(sudoku);
+ DELETENULL(list_menu);
+ Show();
+ }
+ return state;
+ }
+
eOSState state = cOsdObject::ProcessKey(key);
if (state == osUnknown)
{
@@ -209,6 +230,29 @@ eOSState Menu::generate()
return osContinue;
}
+/** Load a puzzle. */
+eOSState Menu::load()
+{
+ if (osd)
+ osd->Flush();
+ DELETENULL(osd);
+ list_menu = new ListMenu(AddDirectory(confdir, SUDOKU_LIST));
+ list_menu->Display();
+ return osUnknown;
+}
+
+/** Save the puzzle. */
+eOSState Menu::save()
+{
+ if (osd)
+ osd->Flush();
+ DELETENULL(osd);
+ list_menu = new ListMenu(AddDirectory(confdir, SUDOKU_LIST),
+ puzzle.get_dump());
+ list_menu->Display();
+ return osUnknown;
+}
+
/** Reset the puzzle. */
eOSState Menu::reset()
{