00001 /* 00002 * Sudoku: A plug-in for the Video Disk Recorder 00003 * 00004 * Copyright (C) 2005-2010, Thomas Günther <tom@toms-cafe.de> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License along 00017 * with this program; if not, write to the Free Software Foundation, Inc., 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00019 */ 00020 00021 #include "sudoku.h" 00022 namespace Sudoku { class PuzzleGame; } 00023 #include "menu.h" 00024 #include "setup.h" 00025 #include <vdr/i18n.h> 00026 #include <vdr/plugin.h> 00027 #include <vdr/config.h> 00028 00029 #if APIVERSNUM < 10600 00030 #error "VDR-1.6.0 API version or greater is required!" 00031 #endif 00032 00033 00034 /** 'Sudoku' is a VDR plugin to generate and solve Number Place puzzles. */ 00035 namespace SudokuPlugin 00036 { 00037 00038 /** Version number of the plugin */ 00039 static const char* VERSION = "0.3.5"; 00040 00041 /** Short description of the plugin's purpose */ 00042 static const char* DESCRIPTION = 00043 trNOOP("Sudoku - generate and solve Number Place puzzles"); 00044 00045 /** Name of the entry in VDR's main menu */ 00046 static const char* MAINMENUENTRY = trNOOP("Sudoku"); 00047 00048 00049 //--- class SudokuPlugin::Plugin --------------------------------------------- 00050 00051 /** Main class of the VDR plugin 'Sudoku' */ 00052 class Plugin : public cPlugin 00053 { 00054 SetupData setup; 00055 Sudoku::PuzzleGame* puzzle; 00056 00057 public: 00058 00059 /** Version number of the plugin */ 00060 virtual const char* Version() { return VERSION; } 00061 00062 /** Localized short description of the plugin's purpose */ 00063 virtual const char* Description() { return tr(DESCRIPTION); } 00064 00065 /** Perform the startup actions of the plugin. */ 00066 virtual bool Start(); 00067 00068 /** Localized name of the entry in VDR's main menu */ 00069 virtual const char* MainMenuEntry() { return tr(MAINMENUENTRY); } 00070 00071 /** OSD object that shows the plugin's main menu */ 00072 virtual cOsdObject* MainMenuAction(); 00073 00074 /** Setup menu page to adjust the setup parameters of the plugin */ 00075 virtual cMenuSetupPage* SetupMenu(); 00076 00077 /** Parse the setup parameters of the plugin. */ 00078 virtual bool SetupParse(const char* name, const char* value); 00079 }; 00080 00081 } // namespace SudokuPlugin 00082 00083 00084 using namespace SudokuPlugin; 00085 00086 00087 //--- class SudokuPlugin::Plugin ----------------------------------------------- 00088 00089 /** Perform the startup actions of the plugin. 00090 * 00091 * This method is called once at VDR's startup. 00092 */ 00093 bool Plugin::Start() 00094 { 00095 puzzle = NULL; 00096 return true; 00097 } 00098 00099 /** OSD object that shows the plugin's main menu 00100 * 00101 * This method is called every time the plugin's main menu entry is selected. 00102 */ 00103 cOsdObject* Plugin::MainMenuAction() 00104 { 00105 return new Menu(this, setup, puzzle); 00106 } 00107 00108 /** Setup menu page to adjust the setup parameters of the plugin 00109 * 00110 * This method is called every time the plugin's setup menu entry is selected. 00111 */ 00112 cMenuSetupPage* Plugin::SetupMenu() 00113 { 00114 return new SetupPage(setup); 00115 } 00116 00117 /** Parse the setup parameters of the plugin. 00118 * 00119 * This method is called for each setup parameter the plugin has previously 00120 * stored in the global setup data. 00121 */ 00122 bool Plugin::SetupParse(const char* name, const char* value) 00123 { 00124 return setup.parse(name, value); 00125 } 00126 00127 /** "Magic" hook that allows VDR to load the plugin into its memory */ 00128 VDRPLUGINCREATOR(Plugin); // Don't touch this!