From bc10d00252d22e5a37a0b83e2d031b833190a496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=BCnther?= Date: Fri, 21 Mar 2008 17:41:20 +0100 Subject: Added setup to commands menu --- HISTORY | 1 + README | 1 + commands.cpp | 3 ++- menu.cpp | 41 +++++++++++++++++++++++++++++++++++------ menu.h | 14 +++++++++++--- sudoku.cpp | 4 ++-- 6 files changed, 52 insertions(+), 12 deletions(-) diff --git a/HISTORY b/HISTORY index a69edb3..e7eaf71 100644 --- a/HISTORY +++ b/HISTORY @@ -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. diff --git a/README b/README index 797e9e2..0010b82 100644 --- a/README +++ b/README @@ -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; } diff --git a/menu.cpp b/menu.cpp index a65b9cc..28e1970 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 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() { diff --git a/menu.h b/menu.h index 6dcde4c..c1edb92 100644 --- a/menu.h +++ b/menu.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: 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 #include #include +#include +#include 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(); diff --git a/sudoku.cpp b/sudoku.cpp index a62b475..d37abc3 100644 --- a/sudoku.cpp +++ b/sudoku.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: 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 -- cgit v1.2.3