00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "setup.h"
00022 #include "commands.h"
00023 #include <vdr/i18n.h>
00024 #include <strings.h>
00025
00026 using namespace SudokuPlugin;
00027
00028
00029
00030
00031
00032
00033
00034
00035 SetupData::SetupData()
00036 {
00037 givens_count = 36;
00038 symmetric = 1;
00039 mark_errors = 1;
00040 mark_ambiguous = 1;
00041 show_possibles_pattern = 0;
00042 show_possibles_digits = 0;
00043 clear_marks = 0;
00044 key_red = CommandList::key_red_default_index();
00045 key_green = CommandList::key_green_default_index();
00046 key_yellow = CommandList::key_yellow_default_index();
00047 strcpy(maxi_font, DefaultFontOsd);
00048 maxi_font_height = 31;
00049 maxi_font_width = 42;
00050 strcpy(mini_font, DefaultFontOsd);
00051 mini_font_height = 10;
00052 mini_font_width = 14;
00053 transparency = 50;
00054 }
00055
00056
00057
00058
00059
00060
00061 bool SetupData::parse(const char* name, const char* value)
00062 {
00063 CommandList cl;
00064 if (!strcasecmp(name, "GivensCount"))
00065 givens_count = atoi(value);
00066 else if (!strcasecmp(name, "Symmetric"))
00067 symmetric = atoi(value);
00068 else if (!strcasecmp(name, "MarkErrors"))
00069 mark_errors = atoi(value);
00070 else if (!strcasecmp(name, "MarkAmbiguous"))
00071 mark_ambiguous = atoi(value);
00072 else if (!strcasecmp(name, "ShowPossiblesPattern"))
00073 show_possibles_pattern = atoi(value);
00074 else if (!strcasecmp(name, "ShowPossiblesDigits"))
00075 show_possibles_digits = atoi(value);
00076 else if (!strcasecmp(name, "ClearMarks"))
00077 clear_marks = atoi(value);
00078 else if (!strcasecmp(name, "KeyRed"))
00079 key_red = cl.id_to_index(atoi(value), cl.key_red_default_index());
00080 else if (!strcasecmp(name, "KeyGreen"))
00081 key_green = cl.id_to_index(atoi(value), cl.key_green_default_index());
00082 else if (!strcasecmp(name, "KeyYellow"))
00083 key_yellow = cl.id_to_index(atoi(value), cl.key_yellow_default_index());
00084 else if (!strcasecmp(name, "MaxiFont"))
00085 Utf8Strn0Cpy(maxi_font, value, MAXFONTNAME);
00086 else if (!strcasecmp(name, "MaxiFontHeight"))
00087 maxi_font_height = atoi(value);
00088 else if (!strcasecmp(name, "MaxiFontWidth"))
00089 maxi_font_width = atoi(value);
00090 else if (!strcasecmp(name, "MiniFont"))
00091 Utf8Strn0Cpy(mini_font, value, MAXFONTNAME);
00092 else if (!strcasecmp(name, "MiniFontHeight"))
00093 mini_font_height = atoi(value);
00094 else if (!strcasecmp(name, "MiniFontWidth"))
00095 mini_font_width = atoi(value);
00096 else if (!strcasecmp(name, "Transparency"))
00097 transparency = atoi(value);
00098 else
00099 return false;
00100 return true;
00101 }
00102
00103
00104
00105
00106
00107 SetupPage::SetupPage(SetupData& setup) :
00108 setup(setup), data(setup)
00109 {
00110 cFont::GetAvailableFontNames(&maxi_font_names);
00111 cFont::GetAvailableFontNames(&mini_font_names);
00112 maxi_font_names.Insert(strdup(DefaultFontOsd));
00113 mini_font_names.Insert(strdup(DefaultFontOsd));
00114 maxi_font_index = max(0, maxi_font_names.Find(data.maxi_font));
00115 mini_font_index = max(0, mini_font_names.Find(data.mini_font));
00116
00117 Add(new cMenuEditIntItem(tr("Givens count"), &data.givens_count, 26, 81));
00118 Add(new cMenuEditBoolItem(tr("Symmetric givens"), &data.symmetric));
00119 Add(new cMenuEditBoolItem(tr("Mark errors"), &data.mark_errors));
00120 Add(new cMenuEditBoolItem(tr("Mark ambiguous numbers"),
00121 &data.mark_ambiguous));
00122 Add(new cMenuEditBoolItem(tr("Show possible numbers as pattern"),
00123 &data.show_possibles_pattern));
00124 Add(new cMenuEditBoolItem(tr("Show possible numbers as digits"),
00125 &data.show_possibles_digits));
00126 Add(new cMenuEditBoolItem(tr("Clear marks on reset"), &data.clear_marks));
00127 Add(new cMenuEditStraItem(tr("Key Red"), &data.key_red,
00128 CommandList::count(), CommandList::texts()));
00129 Add(new cMenuEditStraItem(tr("Key Green"), &data.key_green,
00130 CommandList::count(), CommandList::texts()));
00131 Add(new cMenuEditStraItem(tr("Key Yellow"), &data.key_yellow,
00132 CommandList::count(), CommandList::texts()));
00133 Add(new cMenuEditStraItem(tr("Large font"), &maxi_font_index,
00134 maxi_font_names.Size(), &maxi_font_names[0]));
00135 Add(new cMenuEditIntItem(tr("Large font height (pixel)"),
00136 &data.maxi_font_height, 10, MAXFONTSIZE));
00137 Add(new cMenuEditIntItem(tr("Large font width (pixel)"),
00138 &data.maxi_font_width, 10, MAXFONTSIZE));
00139 Add(new cMenuEditStraItem(tr("Small font"), &mini_font_index,
00140 mini_font_names.Size(), &mini_font_names[0]));
00141 Add(new cMenuEditIntItem(tr("Small font height (pixel)"),
00142 &data.mini_font_height, 10, MAXFONTSIZE));
00143 Add(new cMenuEditIntItem(tr("Small font width (pixel)"),
00144 &data.mini_font_width, 10, MAXFONTSIZE));
00145 Add(new cMenuEditIntItem(tr("Transparency (%)"), &data.transparency, 0, 100));
00146 }
00147
00148
00149
00150
00151
00152
00153 void SetupPage::Store()
00154 {
00155 Utf8Strn0Cpy(data.maxi_font, maxi_font_names[maxi_font_index],
00156 sizeof(data.maxi_font));
00157 Utf8Strn0Cpy(data.mini_font, mini_font_names[mini_font_index],
00158 sizeof(data.mini_font));
00159
00160 setup = data;
00161 SetupStore("GivensCount", setup.givens_count);
00162 SetupStore("Symmetric", setup.symmetric);
00163 SetupStore("MarkErrors", setup.mark_errors);
00164 SetupStore("MarkAmbiguous", setup.mark_ambiguous);
00165 SetupStore("ShowPossiblesPattern", setup.show_possibles_pattern);
00166 SetupStore("ShowPossiblesDigits", setup.show_possibles_digits);
00167 SetupStore("ClearMarks", setup.clear_marks);
00168 SetupStore("KeyRed", CommandList::id(setup.key_red));
00169 SetupStore("KeyGreen", CommandList::id(setup.key_green));
00170 SetupStore("KeyYellow", CommandList::id(setup.key_yellow));
00171 SetupStore("MaxiFont", setup.maxi_font);
00172 SetupStore("MaxiFontHeight", setup.maxi_font_height);
00173 SetupStore("MaxiFontWidth", setup.maxi_font_width);
00174 SetupStore("MiniFont", setup.mini_font);
00175 SetupStore("MiniFontHeight", setup.mini_font_height);
00176 SetupStore("MiniFontWidth", setup.mini_font_width);
00177 SetupStore("Transparency", setup.transparency);
00178 }