diff options
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | README | 1 | ||||
-rw-r--r-- | commands.cpp | 3 | ||||
-rw-r--r-- | menu.cpp | 41 | ||||
-rw-r--r-- | menu.h | 14 | ||||
-rw-r--r-- | sudoku.cpp | 4 |
6 files changed, 52 insertions, 12 deletions
@@ -36,3 +36,4 @@ ____-__-__: Version _._._ - Changed the background color of marked cells to darkgreen. - Added commands menu. - Added commands to load and save puzzles from/to the sudoku-list file. +- Added setup to commands menu. @@ -130,6 +130,7 @@ Commands menu: - Save the puzzle Add the puzzle to the sudoku list, together with an optional description. - Reset the puzzle Reset the numbers in all cells, excluding the givens. +- Open setup menu Open the setup menu of the plug-in. - Exit Quit the plug-in. diff --git a/commands.cpp b/commands.cpp index 37dd5b8..f95ad2a 100644 --- a/commands.cpp +++ b/commands.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: commands.cpp 114 2008-03-16 22:20:33Z tom $ + * $Id: commands.cpp 116 2008-03-21 16:41:20Z tom $ */ #include "commands.h" @@ -42,6 +42,7 @@ CommandMenu::CommandMenu() : Add(new Command(hk(tr("Load a puzzle")), &Menu::load)); Add(new Command(hk(tr("Save the puzzle")), &Menu::save)); Add(new Command(hk(tr("Reset the puzzle")), &Menu::reset)); + Add(new Command(hk(tr("Open setup menu")), &Menu::open_setup)); Add(new Command(hk(tr("Exit")), &Menu::exit)); command = NULL; } @@ -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 114 2008-03-16 22:20:33Z tom $ + * $Id: menu.cpp 116 2008-03-21 16:41:20Z tom $ */ #include "menu.h" @@ -65,8 +65,8 @@ using namespace Sudoku; //--- class SudokuPlugin::Menu ------------------------------------------------- /** Constructor */ -Menu::Menu(const SetupData& setup, const char* confdir, Puzzle& puzzle, Pos& curr) : - cOsdObject(true), setup(setup), confdir(confdir), puzzle(puzzle), curr(curr) +Menu::Menu(cPlugin* plugin, const SetupData& setup, Puzzle& puzzle, Pos& curr) : + cOsdObject(true), plugin(plugin), setup(setup), puzzle(puzzle), curr(curr) { xPos = (720 - GRID_SIZE) / 2; yPos = (576 - GRID_SIZE) / 2; @@ -84,11 +84,14 @@ Menu::Menu(const SetupData& setup, const char* confdir, Puzzle& puzzle, Pos& cur #endif command_menu = NULL; list_menu = NULL; + setup_menu = NULL; + listfile = AddDirectory(plugin->ConfigDirectory(plugin->Name()), SUDOKU_LIST); } /** Destructor */ Menu::~Menu() { + delete setup_menu; delete list_menu; delete command_menu; #if VDRVERSNUM >= 10504 @@ -129,6 +132,7 @@ eOSState Menu::ProcessKey(eKeys key) state = (this->*command)(); if (state == osContinue) Show(); + state = osContinue; } return state; } @@ -148,6 +152,20 @@ eOSState Menu::ProcessKey(eKeys key) return state; } + if (setup_menu) + { + eOSState state = setup_menu->ProcessKey(key); + if (state == osBack) + { + state = osContinue; + if (key == kOk) + Setup.Save(); + DELETENULL(setup_menu); + Show(); + } + return state; + } + eOSState state = cOsdObject::ProcessKey(key); if (state == osUnknown) { @@ -236,7 +254,7 @@ eOSState Menu::load() if (osd) osd->Flush(); DELETENULL(osd); - list_menu = new ListMenu(AddDirectory(confdir, SUDOKU_LIST)); + list_menu = new ListMenu(listfile); list_menu->Display(); return osUnknown; } @@ -247,8 +265,7 @@ eOSState Menu::save() if (osd) osd->Flush(); DELETENULL(osd); - list_menu = new ListMenu(AddDirectory(confdir, SUDOKU_LIST), - puzzle.get_dump()); + list_menu = new ListMenu(listfile, puzzle.get_dump()); list_menu->Display(); return osUnknown; } @@ -260,6 +277,18 @@ eOSState Menu::reset() return osContinue; } +/** Open setup menu. */ +eOSState Menu::open_setup() +{ + if (osd) + osd->Flush(); + DELETENULL(osd); + setup_menu = plugin->SetupMenu(); + setup_menu->SetPlugin(plugin); + setup_menu->Display(); + return osUnknown; +} + /** Exit plugin menu. */ eOSState Menu::exit() { @@ -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.h 114 2008-03-16 22:20:33Z tom $ + * $Id: menu.h 116 2008-03-21 16:41:20Z tom $ */ #ifndef VDR_SUDOKU_MENU_H @@ -28,6 +28,8 @@ namespace Sudoku { class Puzzle; class Pos; } #include <vdr/config.h> #include <vdr/osdbase.h> #include <vdr/osd.h> +#include <vdr/plugin.h> +#include <vdr/tools.h> namespace SudokuPlugin @@ -36,14 +38,15 @@ namespace SudokuPlugin class Bitmap; class CommandMenu; class ListMenu; + class SetupPage; //--- class SudokuPlugin::Menu ----------------------------------------------- /** Main menu of the plugin */ class Menu : public cOsdObject { + cPlugin* plugin; const SetupData& setup; - const char* confdir; Sudoku::Puzzle& puzzle; Sudoku::Pos& curr; int xPos, yPos; @@ -55,11 +58,13 @@ namespace SudokuPlugin const cFont* mini_font; CommandMenu* command_menu; ListMenu* list_menu; + cMenuSetupPage* setup_menu; + cString listfile; public: /** Constructor */ - Menu(const SetupData& setup, const char* confdir, + Menu(cPlugin* plugin, const SetupData& setup, Sudoku::Puzzle& puzzle, Sudoku::Pos& curr); /** Destructor */ @@ -83,6 +88,9 @@ namespace SudokuPlugin /** Reset the puzzle. */ eOSState reset(); + /** Open setup menu. */ + eOSState open_setup(); + /** Exit plugin menu. */ eOSState exit(); @@ -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: sudoku.cpp 114 2008-03-16 22:20:33Z tom $ + * $Id: sudoku.cpp 116 2008-03-21 16:41:20Z tom $ */ #include "sudoku.h" @@ -105,7 +105,7 @@ bool Plugin::Start() */ cOsdObject* Plugin::MainMenuAction() { - return new Menu(setup, ConfigDirectory(Name()), puzzle, curr); + return new Menu(this, setup, puzzle, curr); } /** Setup menu page to adjust the setup parameters of the plugin |